繁体   English   中英

从TinyMCE编辑器获取特定内容

[英]Getting specific content from TinyMCE editor

我有一个用于wordpress的插件im构建,在用户为该插件选择选项后,该插件会在其中注入包含内容的简码。 我遇到麻烦的是tinyMCE.get('content').getContent()当用户想要更新这些选项时会调用此方法,但是使用此方法可以拉住tinymce中的所有内容 ,我需要将其限制在shortcode open和关闭标签。 例如:在用户选择插件的选项之后,将创建[plugin]---HTML OPTIONS---[/plugin]的简码,但是当调用tinyMCE.get('content').getContent()需要它来获取所述插件标签中的所有内容,而无需像这样: [plugin]---GET THIS CODE----[/plugin]任何帮助将不胜感激。 让我知道您是否需要任何澄清。

如果我了解您在尝试什么,那么您正在寻找的是tinymce.dom.Selection类(doc)

进一步来说:

// Sets some contents to the current selection in the editor
tinymce.activeEditor.selection.setContent('Some contents');

// Gets the current selection
alert(tinymce.activeEditor.selection.getContent());

您可能会看一些可用插件中的代码。 链接插件尤其适用于文本选择。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM