将内容插入Wordpress帖子编辑器(Insert content to Wordpress post editor)

编程入门 行业动态 更新时间:2024-10-27 18:19:03
将内容插入Wordpress帖子编辑器(Insert content to Wordpress post editor)

我正在制作一个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(); }

更多推荐

本文发布于:2023-08-05 17:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1436028.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编辑器   帖子   内容   Wordpress   editor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!