我为TinyMCE编写了一个插件,它将用自己的属性生成的内容替换自己。这在Chrome和FF中运行良好,但它在IE11中不起作用。
当我处理文档以查找自定义标记并将其替换为生成的内容时,我使用editor.selection.select(element)
。这无法在IE11中选择元素。
JSFiddle:https://jsfiddle.net/bpstoxin/bsz69zcv/1/
代码摘录
tinymce.each(editor.dom.select(tagName, node), function(element) {
if (element.parentNode) {
editor.selection.select(element);
editor.selection.setContent(element.getAttribute('data-contents'));
}
});
由于未选择元素,因此内容将插入文档顶部,而不是替换我的自定义标记。
这是TinyMce的错误,还是我做错了什么?请记住,这是我的插件的缩小版本,以证明问题。
答案 0 :(得分:0)
我不明白为什么你在这种情况下使用选择试试这个。
tinymce.each(editor.dom.select(tagName, node), function(element) {
if (element.parentNode) {
// BUG: For some reason, this is failing in IE 11
var dataContent = element.getAttribute('data-contents');
element.outerHTML = dataContent.toString();
}
});