我正在尝试使用tinyMCE api(jQuery 版本)将特定颜色应用于编辑器中的选定文本
这就是我到目前为止正在做的事情:
var node = tinyMCE.activeEditor.selection.getNode();
tinyMCE.DOM.setStyle(node, 'color', '#FFF');
问题是这会改变整个节点的颜色,而不仅仅是标记文本的颜色。 有没有办法通过tinyMCE API仅将颜色应用于标记的文本?
谢谢
最佳答案
我已经找到答案了。如果其他人被困在这里,我会发布解决方案。
// Registering the special format with a variable
tinymce.activeEditor.formatter.register('custom_format', {inline : 'span', styles : {color : '%value'}});
// Applying the specified format with the variable specified
tinymce.activeEditor.formatter.apply('custom_format', {value : 'red'});
关于jquery - 通过API将颜色样式设置为tinyMCE文本选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11591623/