TinyMCE 正在使我的代码有效,但我希望它停止! ( 标签包裹在

中)

发布于 2024-08-09 16:47:06 字数 459 浏览 3 评论 0原文

我在站点的后端安装了 TinyMCE。它访问的一些 html 并不完全有效,我意识到这本身就是问题所在。然而,TinyMCE 通过使事情变得有效而把事情搞砸了。我有一个没有父级的 (没有

、没有

等),TinyMCE 是将 包装在

中。我正在尝试找到一种设置来阻止这种情况发生。

本质上,我希望 TinyMCE 允许 成为它自己的元素,而不是子元素,如果这有意义的话。我当前的设置是:

tinyMCE.init({
   theme : "advanced",
   mode : "textareas",
   relative_urls : false
});

I have TinyMCE installed on the back end of a site. Some of the html it's accessing isn't totally valid, which I realize is the problem in itself. However, TinyMCE is messing things up by making things valid. I have an <img> with no parents (no <p>, no <div>, etc), and TinyMCE is wrapping the <img> in <p></p>. I'm trying to find a setting that will stop that from happening.

Essentially, I want TinyMCE to allow <img> to be it's own element, rather than a child element, if that makes sense. My current settings are:

tinyMCE.init({
   theme : "advanced",
   mode : "textareas",
   relative_urls : false
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

飘然心甜 2024-08-16 16:47:06

在发现这个之前我遇到了同样的问题:http://wiki.moxiecode。 com/index.php/TinyMCE:Configuration/forced_root_block

有点晚了,但也许将来会对某人有所帮助

I had the same problem before I found this: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/forced_root_block

A bit late, but maybe it will help someone in the future

此生挚爱伱 2024-08-16 16:47:06

我不是tinyMCE方面的专家,但我很确定可以配置那些自动“聪明”的源格式或修改。不确定你是否调查过这一点。

force_p_newlines 选项的使用示例:

tinyMCE.init({
    ...
    force_p_newlines : true
});

查看此处的参考:
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration

I'm not an expert in tinyMCE but I'm pretty sure those automatic 'clever' source formatting or modification can be configured. Not sure if you have looked into that.

Example of usage of the force_p_newlines option:

tinyMCE.init({
    ...
    force_p_newlines : true
});

Take a look at the reference here:
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration

滿滿的愛 2024-08-16 16:47:06

我又做了一些搜索,找到了答案。首先,我实际上通过将 包装在

中解决了固有问题。不过,可以在这里找到配置解决方案:

http://wiki.moxiecode。 com/index.php/TinyMCE:Configuration/valid_child_elements

我尝试强制 标记允许无父图像:

valid_child_elements: "body[img]"

但这拒绝了所有其他标记的工作。所以我添加了一些变量,如链接所示,然后我意识到了正确的解决方案。但是,如果有人需要为某个元素拼凑解决方案,该页面应该可以解决问题。

I did a little more searching, and found an answer. First, I actually fixed the inherent problem by wrapping the <img> in a <div style="display:inline;">. However, the configuration solution can be found here:

http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_child_elements

I attempted to just force the <body> tag to allow parentless images:

valid_child_elements: "body[img]"

but that denied all other tags from working. So I added some variables, like that link shows, and then I realized the proper solution. But, should anyone need to hack together a solution for an element, that page should solve the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文