[英]TinyMCE - exclude elements
I'm wondering if it's possible to exclude some elements from TinyMCE's editable DIV. 我想知道是否有可能从TinyMCE的可编辑DIV中排除某些元素。 Here's an example code: 这是一个示例代码:
<div class="editable-area">
<h2>heading</h2>
<p>paragraph</p>
<div class="exclude-this-element"></div>
</div>
.exclude-this-element:empty:before { content: "Editable Area"; }
tinymce.init({
inline: true,
fixed_toolbar_container: '.toolbar'
});
tinyMCE.execCommand('mceAddEditor', false, '.editable-area');
The problem is that, when TinyMCE is initialized on .editable-area
, it adds <br>
tag to .exclude-this-element
and Editable Area
text stops appearing. 问题在于,在.editable-area
上初始化TinyMCE时,它会在.exclude-this-element
添加<br>
标记,并且Editable Area
文本停止显示。 Actually, I think that entire .exclude-this-element
is erased after a while. 实际上,我认为一段时间后会删除整个.exclude-this-element
。 Can this element be excluded completely from being altered by TinyMCE? TinyMCE可以完全排除此元素吗?
I would also like to attach some actions (like click
or jQuery UI functions) to .exclude-this-element
and make it not interfere with TinyMCE. 我还想将一些动作(例如click
或jQuery UI函数)附加到.exclude-this-element
并使其不干扰TinyMCE。
I tried valid_children
, valid_elements
and invalid_elements
but I think that none of these can be used to exclude any elements from being editable (it only excludes them when saving the content of the editor): http://www.tinymce.com/wiki.php/Configuration 我尝试过valid_children
, valid_elements
和invalid_elements
但我认为这些都不能用来排除任何可编辑的元素(仅在保存编辑器内容时才排除它们): http : //www.tinymce.com/wiki。 PHP /配置
You can use content editable method 您可以使用内容可编辑的方法
http://www.tinymce.com/wiki.php/api4:property.tinymce.Env.contentEditable and also http://www.tinymce.com/wiki.php/api4:property.tinymce.Env.contentEditable以及
noneditable plugin. 不可编辑的插件。 This plugin makes elements with noneditable class to be - non editable 该插件使具有不可编辑类的元素变为-不可编辑
http://www.tinymce.com/wiki.php/Plugin:noneditable http://www.tinymce.com/wiki.php/插件:不可编辑
EDIT: 编辑:
Try to block the BR elements by adding this in tinyMCE INIT configuration: 通过在tinyMCE INIT配置中添加BR元素来尝试阻止它们:
force_br_newlines : false,
forced_root_block : "",
convert_newlines_to_brs: false,
If the BR tags appear inside content when you paste it from somewhere you also can add this: 如果您在从某处粘贴内容时将BR标签显示在内容中,也可以添加以下内容:
paste_preprocess: function(pl, o) {
o.content = o.content.replace(/<br><\/br>/gi, " ");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.