[英]CKEditor :: Wrap content by custom tag
I wrote a plugin for CKEditor.I want to wrap contents of editor between div
with custom style. 我为CKEditor写了一个插件。我想用自定义样式包装
div
之间的编辑器内容。
In this case I used dialog
for style div
tag. 在这种情况下,我使用了
dialog
样式div
标签。 How can I wrap contents of editor inside 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: [{ ...
Ok I found the solution : 好的我找到了解决方案:
first in config.js
put the below line : 首先在
config.js
输入以下行:
config.allowedContent = 'div{*}'; // this is important
then in onOk
function do this : 然后在
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.