我的 HTML 包含这样的元素,因为它使用 django-basic-apps 中的内联。
<inline type="myapp.mymodel" id="4" />
我正在尝试使用tinymce 将其中之一插入到DOM 中。在网站的前端,这些被处理成好的代码。
在tinyMCE中,我添加了配置:
extend_valid_elements: 'inline[id|ids|type|filter|class|template]',
但任何时候我尝试插入via:
tinyMCE.execCommand('mceInsertRawHtml',false,'<inline type="myapp.mymodel" id="4" />');
都不会发生,
如果我这样做:
tinyMCE.activeEditor.getContent()
TinyMCE会删除我的代码中的任何元素。
此外,我希望这些元素通过CSS或其他方式显示在tinyMCE中,但我可能必须破解DTD。
如果这不起作用,我想到的一个可能的解决方案是将内容预渲染为有效的内容:
然后在保存之前,将其转换回应有的样子。
请就我应该研究的事情提供任何建议。
My HTML contains elements like this, because it uses inlines from django-basic-apps.
<inline type="myapp.mymodel" id="4" />
I'm trying to use tinymce to insert one of these into the DOM. On the frontend of the site, these are processed into good code.
In tinyMCE I've added the config:
extend_valid_elements: 'inline[id|ids|type|filter|class|template]',
But anytime I try to insert via:
tinyMCE.execCommand('mceInsertRawHtml',false,'<inline type="myapp.mymodel" id="4" />');
nothing happens,
And if I do:
tinyMCE.activeEditor.getContent()
TinyMCE removes any <inline
elements that are in my code.
Furthermore, I would like these elements to display in the tinyMCE via CSS or something, but I'll probably have to hack the DTD.
If that doesn't work a possible solution that I've thought of would be to pre-render the content to something that IS valid:
And then before save, convert that back to what it should be.
Please provide any suggestions for things I should look into.
发布评论
评论(2)
在tinymce tiny_mce_src.js 的源代码中搜索字符串valid_elements 并直接在其中添加元素和属性。
In the source code of tinymce tiny_mce_src.js search for the string valid_elements and add your elements and attributes directly there.
请改用
mceInsertContent
命令,并且不要使用自闭合标签:Use
mceInsertContent
command instead, and don't use self-closing tags: