You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//富文本编辑器初始化,来自ck demoif(CKEDITOR.env.ie&&CKEDITOR.env.version<9)CKEDITOR.tools.enableHtml5Elements(document);CKEDITOR.config.height=150;CKEDITOR.config.width='auto';varinitSample=(function(){varwysiwygareaAvailable=isWysiwygareaAvailable(),isBBCodeBuiltIn=!!CKEDITOR.plugins.get('bbcode');returnfunction(){vareditorElement=CKEDITOR.document.getById('editor');// :(((if(isBBCodeBuiltIn){editorElement.setHtml('<h1>Hello world1!</h1><p>I'm an instance of <a href="http://ckeditor.com">CKEditor</a>.');}// Depending on the wysiwygare plugin availability initialize classic or inline editor.if(wysiwygareaAvailable){CKEDITOR.replace('editor');}else{editorElement.setAttribute('contenteditable','true');CKEDITOR.inline('editor');// TODO we can consider displaying some info box that// without wysiwygarea the classic editor may not work.}};functionisWysiwygareaAvailable(){// If in development mode, then the wysiwygarea must be available.// Split REV into two strings so builder does not replace it :D.if(CKEDITOR.revision==('%RE'+'V%')){returntrue;}return!!CKEDITOR.plugins.get('wysiwygarea');}})();initSample();
ckeditor官网
引入js和css文件
在视图显示富文本编辑器的html结构,注意不要把注释写在id为editor的闭合标签里面,不然后面提交的时候会把注释也提交上去,刚开始可以用php显示数据库的html结构
当我们富文本经过初始化后,我们就可以尝试来获取富文本编辑器编写的html结构
获取html内容,然后可以通过表单提交或者ajax把html结构存进数据库
这里举例用ajax提交富文本数据
我这里使用了
CKEDITOR.instances.editor.getData()
来获取富文本html内容The text was updated successfully, but these errors were encountered: