example onChange function:
const onChange = (changed) => { console.log(changed.key, //the auto increment of change index changed.content, //the final content value after changed changed.change //the changed delta compare to previous version ); }
In application such as React, it might be handy for parent level to receive the current instance of editor.
var _editor; const instance = (editor) => { _editor = editor; } var subeditor = new SubEditor(elm, {instance : instance}); console.log(_editor === subeditor ); //true
css style will be injected into document head upon initialization. your customized css should overwrite default style. For multiple instances within the same page, setting skipCss=true will prevent current instance from overwritting previous generated css style.
The full build-in list of toolbar items are listed as follow, you may change the order as you see fit:
"undo","redo","text","format","link","remove_format","indent","outdent","color","backgroundcolor","align","ol","ul","image", "library","table","hr","source","fullscreen"
Additonal style items:
Grouped items:
*note that image and library will require additional config variable setup
The full build-in list of plugins are listed as follow:
"fullscreen","hr", "color","source","align","text","undo","redo","indent","format","remove_format","link", "paste","list", "table","image"
This is for creating new language or making changes to existing language. The current default English language can be accessed by calling SubEditor.langList.en. All current avaiable languages are en, zhCN, zhTW.
const langFr = { "bold" : "audacieux" //...more } //this will create a new language and set the current display language to fr new SubEditor(element, {langList : {fr : langFr}, lang : "fr"});
Default is en, if you want to alter the display language you should change this value, provided that you supply the new language.
A callback function to translate every language during runtime. This is useful for large project that has its own language settings.
const lnFunction = (str) => { switch(str) { case "bold": return "bboolldd"; break; default: return str; break; } } new SubEditor(element, {ln : lnFunction});
Variables for plugins. Image and library comes with required variables for them to work. Please refer to the image plugin page for detail example.
var imageCfg = { //the features to enable, can set to [] if only url is supported "image.features" : ["url","upload","library"], //the accepted file types (mime format) "image.accept.types" : "image/jpeg, image/jpg, image/png, image/apng, image/gif, image/webp", "image.library.fetch" : null, "image.library.per.page" : 20, "image.library.allow.paging" : true, "image.library.allow.search" : true, "image.drop.to.content.upload" : true, "image.upload.url" : "", //limit total number of uploaded files in content, 0: no limit "image.upload.max.files" : 0, //number in mb, 0: no limit "image.upload.max.size" : 0, //number in mb, 0: no limit "image.upload.max.size.per.file" : 0, //0:accept multiple files, 1: accept 1 file "image.upload.accept.files" : 0, "image.upload.handler" : null, "image.url.rewrite.handler" : (u : string) => { return u.replace('http://','//').replace('https://','//')}, }; new SubEditor(element, {cfgList : imageCfg});