TinyMCE 不必要地关闭自关闭标签 -TinyMCE 正在关闭标签,<image> <rect> 例如我如何阻止这种情况?



TinyMCE正在关闭自关闭标记,而<image><rect>等标记不需要这样做。我该如何阻止这种情况?

<div>
<div id="Test">
<p>Test response</p>
<svg viewbox="0 0 240 340"> 
<g> 
<image id="svg_1" x="4.1" xlink:href="https://upload.wikimedia.org/wikipedia/en/b/bc/Borg_Queen_2372.jpg" y="-49.2"> 
<rect fill="#FF0000" height="43" id="svg_2" stroke="#000000" width="150" x="75" y="60"></rect> 
</image>
</g> 
</svg>
</div>
<div id="Reply">reply</div>
</div>

这个问题已经解决了https://fiddle.tiny.cloud/XZhaab/2将此代码添加到编辑器初始化部分

extended_valid_elements: 'svg[*],g[*],image[*],rect[*]',
custom_elements: '~image,~rect',
setup: function(editor) {
editor.on('PreInit', function() {
var shortEndedElements = editor.schema.getShortEndedElements();
shortEndedElements['image'] = {};
shortEndedElements['rect'] = {};
});
}

最新更新