CKEDOTOR没有带有引导程序的工具栏,并通过栏杆中的外部按钮显示预览



我即将使用CKEditor用于post功能。但是我不需要post功能的工具栏。我需要提供应该是HTML版本的preview的CC_4,preview功能应由onkeyup/any button完成。preview部分将在CKEditor下方。

图像 http://grab.by/h5sk

邮件目的是向user提供格式化的帖子。如果我使用的是textarea,则它将返回string,并且无法显示为在TextArea中输入的user

您应该使用editor#changeeditor#contentDom事件。您不应像

那样禁用工具栏
CKEDITOR.replace('editor1', {toolbar: []})

因为它会禁止编辑器中的任何类型的内容,因为工具栏与高级内容过滤器相对应,除非您通过设置config.allowedContent = true将其禁用,但不建议使用它。

请参阅JSFIDDLE。

html

<textarea id="editor">
    <p>Hello world! <a href="http://google.com">This is some link</a>.</p>
    <p>And there is some <s>deleted</s>&nbsp;text.</p>
</textarea>    
<div id="preview"></div>

JS

var preview = CKEDITOR.document.getById( 'preview' );
function syncPreview() {
    preview.setHtml( editor.getData() );
}
var editor = CKEDITOR.replace( 'editor', {
    on: {
        // Synchronize the preview on user action that changes the content.
        change: syncPreview,
        // Synchronize the preview when the new data is set.
        contentDom: syncPreview
    }
} );

CSS

/* Hide the toolbar with CSS */
.cke_top { display: none !important }

for ckeditor:测试

ckeditor.replace('editor1',{工具栏:[]});

另一个解决方案:

这就是stackoverflow使用

最新更新