将 CSS 样式添加到 WordPress 编辑器
我目前正在使用 TinyMCE Styleselect 菜单将 CSS 类添加到 WordPress 编辑器中。到目前为止,这对我来说效果很好,如果您只有几个想要使用的类,那就太棒了。然而,当我添加更多类时,样式选择下拉列表变得有点不用户友好,因为您必须滚动选项,这也可以使页面滚动。
我想要实现的解决方案涉及tinymce工具栏中的一个按钮,单击该按钮将打开一个弹出窗口,您可以从中选择一个类以应用于编辑器中选定的文本。
我知道如何向tinymce添加自定义按钮并创建弹出窗口,但如何使添加类的按钮实际将该类应用于选择?
任何人对我需要用来执行此操作的代码的任何想法或详细说明上述内容的教程都会很棒。
I'm currently using the TinyMCE Styleselect menu to add CSS classes into the WordPress editor. This has worked OK for me so far and is great if you only have a few classes that you want to use. When I have added more classes however, the styleselect dropdown becomes a little un-user friendly as you have to scroll through the options which can also make the page scroll also.
The solution I want to implement involves a button in the tinymce toolbar that when clicked will open a popup window, from which you can select a class to apply to the selected text in the editor.
I know how to add custom buttons to tinymce and create the popup window but how do I make the buttons that add the class actually apply the class to the the selection?
Anybody any ideas of the code I need to use to do this or a tutorial detailing the above would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全确定这是正确的,但我认为如果您想超越通过 WordPress 提供的挂钩自定义 TinyMCE,您将必须经历 TinyMCE 本身。因此,这可能更像是一个 TinyMCE 问题,而不是一个 WordPress 问题。我建议您查看 TinyMCE 插件文档。
然而,一旦你准备好插件,WordPress 加载它可能会遇到一些问题。我肯定会尽量避免像 TinyMCE 的其余部分一样手动将其放入 wp-includes 中,但 WordPress 似乎确实提供了一种 加载外部插件。
I am not entirely certain this is correct, but I think that if you want to go beyond customizing TinyMCE via the hooks provided by WordPress you will have to go through TinyMCE itself. Consequently this is probably more of a TinyMCE question, than it is a WordPress question. I suggest you check out the TinyMCE plugin documentation.
However, once you have your plugin ready there might be a bit of an issue getting WordPress to load it. I'd definitely try to avoid manually placing it inside wp-includes like the rest of TinyMCE, but it seems WordPress does actually provide a way of loading external plugins.