将 CSS 样式添加到 WordPress 编辑器

发布于 2025-01-03 07:00:55 字数 332 浏览 1 评论 0原文

我目前正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面如桃花 2025-01-10 07:00:55

我不完全确定这是正确的,但我认为如果您想超越通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文