Tinymce-用于插入特定模板的自定义按钮

发布于 2025-01-22 16:49:50 字数 534 浏览 4 评论 0 原文

我正在使用Prestashop。我制作了几个模板。是否可以准备一个可以插入选定模板的按钮? 例如,我有4个模板,我想制作4个按钮。 第一个按钮插入第一个模板。 第二个按钮插入第二个模板,依此类推。 我尝试在文件 \ js \ admin \ tinymce.inc.js 中使用此代码,但是我的新按钮未显示:(

    toolbar2: 'customInsertButton',
    setup: function (editor) {
      editor.ui.registry.addButton('customInsertButton', {
        text: 'My Button',
        onAction: function (_) {
          editor.insertContent('My button works!');
        }
      });
    },

也许Prestashop有一些有限的编辑版本? 我问,因为例如,可以添加模板。但是我希望能够用一个按钮更快地插入它们...

I am using Prestashop. I have made several templates. Is it possible to prepare a button that will insert the selected template?
For example, I have 4 templates and I want to make 4 buttons.
the first button inserts the first template.
the second button inserts the second template and so on.
I tried to use this code in the file \js\admin\tinymce.inc.js but my new button is not displaying :(

    toolbar2: 'customInsertButton',
    setup: function (editor) {
      editor.ui.registry.addButton('customInsertButton', {
        text: 'My Button',
        onAction: function (_) {
          editor.insertContent('My button works!');
        }
      });
    },

Perhaps Prestashop has some limited version of this editor?
I ask because for example it is possible to add templates. but I would like to be able to insert them faster, with one button...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

从﹋此江山别 2025-01-29 16:49:50

Tinymce本身已经有一个模板插件:

https:> https://www.tiny.tiny.cloud/docs /plugins/opensource/template/

您是否考虑过使用该功能?

TinyMCE itself already has a template plugin:

https://www.tiny.cloud/docs/plugins/opensource/template/

Have you considered using that functionality?

二手情话 2025-01-29 16:49:50

我已经找到了解决方案。通过添加自定义插件可以。
在Tinymce网站上,一切都很好地描述了:

然后,我们修改tinymce.inc.js,并在工具栏中添加插件支持和定义的按钮。

I have already found a solution. It is possible by adding a custom plugin.
Everything is beautifully described on the TinyMCE website :
https://www.tiny.cloud/docs/advanced/creating-a-plugin/
then we modify tinymce.inc.js and add plugin support and a defined button in the toolbar.

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