https://ckeditor.com/ckeditor-4/ 官网地址
- 翻看源码和api文档,发现没有隐藏和显示的功能,只能通过初始化和销毁来创建。
$("#showCkEditor").click(function () {
let self = $(this);
if (self.data("lock")) { //防止重复创建
return;
} else {
self.data("lock", true);
}'
if (CKEDITOR.env.ie && CKEDITOR.env.version < 9)
CKEDITOR.tools.enableHtml5Elements(document);
try {
//CKEDITOR.instances.noticeEditorId.destroy();
//这块不太好用 销毁在重建就会报错``
} catch (ex) {
}
CKEDITOR.config.height = 550;
CKEDITOR.config.width = 'auto';
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
CKEDITOR.config.shiftEnterMode = CKEDITOR.ENTER_P;
CKEDITOR.config.linkDefaultProtocol = "https://"
CKEDITOR.replace('noticeEditorId',
{
toolbarGroups: [
{ name: 'document', groups: ['mode', 'document', 'doctools'] },
{ name: 'basicstyles', groups: ['cleanup', 'basicstyles'] },
{ name: 'clipboard', groups: ['undo', 'clipboard'] },
{ name: 'editing', groups: ['find', 'selection', 'spellchecker', 'editing'] },
{ name: 'links', groups: ['links'] },
{ name: 'insert', groups: ['insert'] },
{ name: 'tools', groups: ['tools'] },
'/',
{ name: 'colors', groups: ['colors'] },
{ name: 'styles', groups: ['styles'] },
{ name: 'paragraph', groups: ['list', 'indent', 'align', 'blocks', 'bidi', 'paragraph'] },
{ name: 'forms', groups: ['forms'] },
'/',
{ name: 'others', groups: ['others'] },
{ name: 'about', groups: ['about'] }
],
removeButtons: 'Save,NewPage,ExportPdf,Preview,Print,About,Superscript,Subscript,Find,Replace,Scayt,Form,ImageButton,HiddenField,CreateDiv,BidiLtr,BidiRtl,Language,Iframe,PageBreak',
filebrowserUploadUrl: '' 图片上传地址"
});
try {
CKEDITOR.instances.noticeEditorId.setData(DataBody.Intro);
} catch (ex) {
console.log(ex.message);
}
});