簡體   English   中英

CKEditor ::按自定義標記包裝內容

[英]CKEditor :: Wrap content by custom tag

我為CKEditor寫了一個插件。我想用自定義樣式包裝div之間的編輯器內容。

在這種情況下,我使用了dialog樣式div標簽。 如何在div包含編輯器的內容:

  onOk: function() {
            var dialog = this;
            var color = dialog.getValueOf('tab1', 'color');
            // other styles
            var tag= '<div style="';
            tag += 'color:' + color + ';';
            // ... other styles
            tag += '">';
            // tag += contents ;
            tag += "</div>";
            editor.insertHtml(tag)
        },
        contents: [{ ...

好的我找到了解決方案:

首先在config.js輸入以下行:

config.allowedContent = 'div{*}'; // this is important

看到這里這里

然后在onOk函數中執行此操作:

   onOk: function() {
            contents = editor.document.getBody().getHtml(); // get the content of CKEditor
            var dialog = this;
            var color = dialog.getValueOf('tab1', 'color');
            // other styles
            var tag= '<div style="';
            tag += 'color:' + color + ';';
            // ... other styles
            tag += '">';
            tag += contents ;
            tag += "</div>";
            editor.setData(tag);
        },
        contents: [{ ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM