tinymce图像插入,第二次工作,但不是第一次
tinymce image insert, works second time but not the first
我正在使用CakePHP和一个自定义文件浏览器,以及TinyMCE。
这是我的回拨:
<script type="text/javascript">
function fileBrowserCallBack(field_name, url, type, win) {
browserField = field_name;
browserWin = win;
window.open('/controller/mupload', 'browserWindow', 'modal,width=600,height=500,scrollbars=yes');
}
tinyMCE.init({
mode : 'textareas',
theme : 'advanced',
// theme specific stuff
file_browser_callback: 'fileBrowserCallBack',
width: '620',
height: '380',
relative_urls : false
});
</script>
回调中的window.open
引用了CakePHP中的上传脚本。这样可以上传并完美地显示图像。当我选择一个图像时,图像的路径显示在TinyMCE的Image URL
字段中,所有这些看起来都像在工作。
然后我点击Insert
,TinyMCE添加了这个HTML:
<p><img border="0" /></p>
-完全忽略图像的路径-即使已设置。
如果我点击"插入图像",浏览到另一个(或相同的)图像,然后选择插入,图像会完美显示,路径正确,正如你所期望的那样。
我可以提供更多的代码,但不幸的是,没有实时链接。
总之,当我第一次尝试插入图像时,它插入了一个无效的标签。第二次,它工作得很好。
Firebug没有显示错误。
有什么建议吗?
TinyMCE版本:
majorVersion:"3",
minorVersion:"4.2",
releaseDate:"2011-04-07"
谢谢。
这应该在他们的罚单中得到了回答:http://tinymce.moxiecode.com/develop/bugtracker_view.php?id=4427
但据报道:http://tinymce.moxiecode.com/develop/bugtracker_view.php?id=4499
中的一些修复程序http://tinymce.moxiecode.com/forum/viewtopic.php?id=25646
我通过将convert_urls配置设置为false来修复此问题。
有关该配置和相关配置的更多信息,请参阅此处:https://www.tiny.cloud/docs/configure/url-handling/#qhowdoiconvertmyurlstorelativeabsoluteorabsolutewithdomain
convert_urls
This option enables you to control whether TinyMCE is to be smart and restore URLs to their original values. URLs are automatically converted (messed up) by default because the browser’s built-in logic works this way. There is no way to get the real URL unless you store it away. If you set this option to false it tries to keep these URLs intact. This option is set to true by default, which means URLs are forced to be either absolute or relative depending on the state of relative_urls.
Type: Boolean
Default Value: true
相对URL对于与包含TinyMCE编辑器的页面具有相同域的URL。如果设置为:
true — All URLs created in TinyMCE will be converted to a link relative to the document_base_url.
false — All URLs will be converted to absolute URLs.
Type: Boolean
Default Value: true
document_base_url
This option specifies the base URL for all relative URLs in the document. The default value is the directory of the current document. If a value is provided, it must specify a directory (not a document) and must end with a /.
This option also interacts with the relative_urls, remove_script_host, and convert_urls options to determine whether TinyMCE returns relative or absolute URLs. The FAQ contains a thorough description and examples of working with relative and absolute URLs.
Type: String
- 相同的RegExp返回不同的结果-第一次是正确的结果,第二次是null
- 推特引导:弹出窗口不会在第一次点击时出现,但会在第二次点击时显示
- 尝试在两次迭代中警告同一选择器的值,在第一次迭代中得到正确的值,而在第二次迭代中获得不正确的值.为什么?
- 如果第一次选择中的选项1,则第二次选择被禁用
- 操作方法:第一次单击动画 1,第二次单击动画 2
- 在第一次可观测发射之后的第二次可观测的第一次发射时发射
- 此代码在第一次迭代时给出 0 作为高度和宽度,第二次给出正确的尺寸
- 如何在第一次点击时突出显示链接;并在第二次单击时跟随它,除非在其他地方单击,然后重新初始化未高亮显示的状态
- Javascript 渲染动画在 HTML5 DOM 上来自 Array.第一次运行慢!第二次运行顺利.怎么来了
- Ajax onClick 事件第一次获取错误的结果,但第二次获取正确的结果
- 第一次点击失败,第二次点击在 Ajax 调用 • JQuery / PHP 上成功
- 在jQuery中第一次单击时附加片段,然后在第二次单击时删除
- JQuery 单击事件在第二次单击时触发,但不在第一次单击时触发
- 如果第一次单击有效,则第二次单击元素
- 弹出模式仅适用于表格中的第一个元素,第二次单击后不会再次打开
- jsPDF 在第一次保存时工作,在第二次保存时不更新
- 第二次单击(而不是第一次)时的 ng 表更改页面操作
- 奇怪的是,在第二次单击切换隐藏/显示按钮而不是第一次单击后,有两行有效
- 如果脚本在第一次尝试时失败,请第二次执行脚本
- 我想改变“;text1”;至“;text2”;第一次点击并改变“;text2”;至“;text1”;第二次只点击一个按钮