我正在制作一个Wordpress插件,用于在帖子中添加图片地图。 目前我已经实现了图像映射作为自定义帖子类型。 不过,我在添加帖子时遇到了一些麻烦。
我在媒体插入/上传窗口中创建了一个名为Image map的新选项卡。 当您在标签中点击图片地图时,此功能将被触发:
function insertImageMap() { tinyMCE.execInstanceCommand('mceInsertContent', false, 'content', 'some text or html code' ); window.parent.tb_remove(); }但是没有任何东西被添加到tinyMCE编辑器中。 该函数被触发,但tinyMCE编辑器的实例未定义,即使我使用tinyMCE.getInstanceById('content')。 有没有办法访问编辑页面的编辑器?
我在我的插件中包含了tinyMCE脚本,并没有显示为未定义。
我发现一个较老的问题也一样,但答案并不是非常有用: 自定义Wordpress插件 - 如何在弹出窗口中插入内容在后期编辑器上?
I'm making a Wordpress plugin for adding image maps in the posts. Currently I have implemented the image maps as a custom post types. However I'm having some trouble with adding them in posts.
I have made a new tab in the media insert/upload window called Image map. When you click an image map in the tab, this function is fired:
function insertImageMap() { tinyMCE.execInstanceCommand('mceInsertContent', false, 'content', 'some text or html code' ); window.parent.tb_remove(); }However nothing is added to the tinyMCE editor. The function is fired, but the instance of tinyMCE editor is undefined even if I use tinyMCE.getInstanceById('content'). Is there a way to access the editor of a post editor page?
I have included tinyMCE script in my plugin and it doesn't show as undefined.
I found an older question asking the same, but the answer wasn't very helpful: Custom Wordpress Plugin - How do I insert content from popup on post editor?
最满意答案
在评论中找到解决方案
function insertImageMap() { window.parent.send_to_editor('any text'); window.parent.tb_remove(); }Solution found in comments:
function insertImageMap() { window.parent.send_to_editor('any text'); window.parent.tb_remove(); }更多推荐
发布评论