Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
vue-froala-wysiwyg
Advanced tools
vue-froala-wyswiyg provides Vue bindings to the Froala WYSIWYG editor VERSION 3.
@legacy
Install vue-froala-wysiwyg
from npm
npm install vue-froala-wysiwyg --save
//Import Froala Editor
import 'froala-editor/js/plugins.pkgd.min.js';
//Import third party plugins
import 'froala-editor/js/third_party/embedly.min';
import 'froala-editor/js/third_party/font_awesome.min';
import 'froala-editor/js/third_party/spell_checker.min';
import 'froala-editor/js/third_party/image_tui.min';
// Import Froala Editor css files.
import 'froala-editor/css/froala_editor.pkgd.min.css';
// Import and use Vue Froala lib.
import VueFroala from 'vue-froala-wysiwyg'
Vue.use(VueFroala)
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')
<template>
<div id="app">
<froala id="edit" :tag="'textarea'" :config="config" v-model="model"></froala>
</div>
</template>
<script>
import VueFroala from 'vue-froala-wysiwyg';
export default {
name: 'app',
data () {
return {
config: {
events: {
initialized: function () {
console.log('initialized')
}
}
},
model: 'Edit Your Content Here!'
}
}
}
</script>
var webpack = require('webpack')
var path = require('path')
module.exports = {
module: {
loaders: [
// ...
// Css loader.
{
test: /\.css$/,
loader: 'vue-style-loader!css-loader'
}
]
},
vue: {
loaders: {
// ...
// Css loader for Webpack 1.x .
css: 'vue-style-loader!css-loader'
}
}
})
// If model is initialized, 'Init text' text child will be overwritten.
<froala :tag="'textarea'" :config="config" v-model="model">Init text</froala>
:tag attr is used to tell on which tag the editor is initialized.
There are special tags: a, button, img, input.
You can pass editor options as component attribute (optional).
:config="config"
You can pass any existing Froala option. Consult the Froala documentation to view the list of all the available options:
config: {
placeholderText: 'Edit Your Content Here!',
charCounterCount: false
}
Aditional option is used:
Events can be passed in with the options, with a key events and object where the key is the event name and the value is the callback function.
config: {
placeholder: "Edit Me",
events : {
focus : function(e, editor) {
console.log(editor.selection.get());
}
}
}
Using the editor instance from the arguments of the callback you can call editor methods as described in the method docs.
Froala events are described in the events docs.
The WYSIWYG HTML editor content model. Two way binding is suported.
v-model="model"
Use the content in other places:
<input v-model="model"/>
You can also use the editor on img, button, input and a tags:
<froala :tag="img" v-model="imgModel"></froala>
The model must be an object containing the attributes for your special tags. Example:
imgModel: {
src: require('./image.jpg')
}
The model will change as the attributes change during usage.
buttonModel: {
innerHTML: 'Click Me'
}
As the button text is modified by the editor, the innerHTML attribute from buttonModel model will be modified too.
config: {
vueIgnoreAttrs: ['class', 'id']
}
You can pass the custom buttons to the editor by following way:
<script>
import FroalaEditor from 'froala-editor';
FroalaEditor.DefineIcon('alert', {NAME: 'info', SVG_KEY: 'help'});
FroalaEditor.RegisterCommand('alert', {
title: 'Hello',
focus: false,
undo: false,
refreshAfterCallback: false,
callback: function () {
alert('Hello!');
}
});
FroalaEditor.DefineIcon('clear', {NAME: 'remove', SVG_KEY: 'remove'});
FroalaEditor.RegisterCommand('clear', {
title: 'Clear HTML',
focus: false,
undo: true,
refreshAfterCallback: true,
callback: function () {
this.html.set('');
this.events.focus();
}
});
FroalaEditor.DefineIcon('insert', {NAME: 'plus', SVG_KEY: 'add'});
FroalaEditor.RegisterCommand('insert', {
title: 'Insert HTML',
focus: true,
undo: true,
refreshAfterCallback: true,
callback: function () {
this.html.insert('My New HTML');
}
});
</script>
Now you can use these buttons in options:
toolbarButtons: [['undo', 'redo' , 'bold'], ['alert', 'clear', 'insert']],
Gets the functionality to operate on the editor: create, destroy and get editor instance. Use it if you want to manually initialize the editor.
:onManualControllerReady="initialize"
initialize: function(initControls) {
this.initControls = initControls;
this.deleteAll = () => {
this.initControls.getEditor().html.set('');
this.initControls.getEditor().undo.reset();
this.initControls.getEditor().undo.saveStep();
};
}
The object received by the function will contain the following methods:
To display content created with the froala editor use the froalaView
component.
<froala v-model="content"></froala>
<froalaView v-model="content"></froalaView>
The vue-froala-wyswiyg
project is under MIT license. However, in order to use Froala WYSIWYG HTML Editor plugin you should purchase a license for it.
Froala Editor has 3 different licenses for commercial use. For details please see License Agreement.
If you want to contribute to vue-froala-wyswiyg, you will first need to install the required tools to get the project going.
$ npm install
$ npm run build
$ npm run dev
FAQs
Vue plugin for Froala WYSIWYG HTML rich text editor.
The npm package vue-froala-wysiwyg receives a total of 10,080 weekly downloads. As such, vue-froala-wysiwyg popularity was classified as popular.
We found that vue-froala-wysiwyg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.