[英]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.