禁用 TinyMCE 绝对 URL 到相对 URL 转换
谁能告诉我如何让 TinyMCE 停止将我的 URL 转换为 Plone 中的相对链接?
例如,如果我在 HTML 源中输入:
<img src="/images/dir/subdir/my_image.png" />
它会将其转换为:
<img src="../../../my_image.png" />
我已编辑tiny_mce.js(在portal_skins 中)以设置:
convert_urls:false,
relative_urls:false,
但没有效果。我在这里阅读了所有类似的帖子,但没有一个真正回答这个问题。
当用户通过浏览文件系统(即目录)选择图像时,如果它执行相关的操作,那就没问题了。我只是希望它尊重我在 html 框中输入的内容...这样我就可以选择强制使用绝对路径(如果我认为合适)。这是 kupu 中的标准行为。
有什么想法吗?
Can anyone tell me how to get TinyMCE to stop converting my URLs to relative links in Plone?
For example, if I enter this in the HTML source:
<img src="/images/dir/subdir/my_image.png" />
it will convert it to:
<img src="../../../my_image.png" />
I've edited tiny_mce.js (in portal_skins) to set:
convert_urls:false,
relative_urls:false,
but to no effect. I've read all similar posts here, but none really answer this question.
It's fine if it does the relative thing when users are picking images by browsing the filesystem (i.e. the catalog). I just want it to respect what I type in the html box ... so that I have the option of forcing an absolute path if I deem it appropriate. This is the standard behavior in kupu.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在tiny_mce_init.js而不是tiny_mce.js中设置
convert_urls: false
。在tiny_mce_init.js的早期,您会看到对window.tinyMCE.init的调用传递了一堆初始化选项。在我正在查看的 Products.TinyMCE 中,最后一个选项是fix_list_elements: false
。在那里添加您的选项。编辑:Products.TinyMCE 1.3.x (Plone 4.3) 中不再使用tiny_mce_init.js。相反,覆盖
tinymce-jsonconfiguration
浏览器视图,例如:假设您有一个带有浏览器层的包,请添加
browser/configure.zcml
:然后添加
browser /tinymce.py
:Set
convert_urls: false
in tiny_mce_init.js, not tiny_mce.js. Early in tiny_mce_init.js you'll see a call to window.tinyMCE.init passing a bunch of initialisation options. In the Products.TinyMCE I'm looking at, the last option isfix_list_elements: false
. Add your option there.Edit: tiny_mce_init.js is no longer used in Products.TinyMCE 1.3.x (Plone 4.3). Instead, override the
tinymce-jsonconfiguration
browser view, e.g.:Assuming you have a package with a browser layer, add in
browser/configure.zcml
:Then add
browser/tinymce.py
:您应该将这些配置添加到tinymce.init中:
relative_urls: false,
convert_urls:假,
remove_script_host:假,
参考:https://www.tiny .cloud/docs/configure/url-handling/
You should add these configs into tinymce.init:
relative_urls: false,
convert_urls: false,
remove_script_host : false,
ref: https://www.tiny.cloud/docs/configure/url-handling/
另一种解决方案是使用控制面板配置 TinyMCE,为每个链接和图像使用 UID,而不是路径,这样您就不会修改任何现有的 javascript,也不会显示任何相对 url。
An other solution is to configure TinyMCE with the control panel to use UID for every links and images, instead of path, so you don't modify any existing javascripts and don't have any relative url displayed.
在 Plone 5 中,可以禁用 TinyMCE 绝对 URL 到相对 URL,在 TinyMCE 设置的“高级”选项卡中添加变量
站点设置 > TinyMCE>高级
更多变量可在 Products/CMFPlone/static/components/tinymce-builded/js/tinymce/tinymce.js 中找到
In Plone 5 is possible disable TinyMCE absolute to relative URL adding variables in Advanced tab of TinyMCE Settings
Site setup > TinyMCE > Advaced
Further variables are available in Products/CMFPlone/static/components/tinymce-builded/js/tinymce/tinymce.js