简体   繁体   English

如何将自定义按钮和对话框迁移到 TinyMCE 5

[英]How to migrate custom buttons and dialogs to TinyMCE 5

I have a third party Bootstrap plugin (probably EOL), which added buttons to the toolbar, which in turn opened a dialog from where I could select Bootstrap elements to add to the content.我有一个第三方 Bootstrap 插件(可能是 EOL),它向工具栏添加了按钮,然后打开了一个对话框,我可以从中选择 Bootstrap 元素以添加到内容中。

It used the following code:它使用了以下代码:

var insertBtn = tinymce.ui.Factory.create({
    type: elType,
    classes: elClass,
    text: bsText['button'],
    icon: 'icon-btn',
    name: 'insertBtnBtn',
    tooltip: bsTip['button'],
    onclick: function() {
        showDialog('bootstrap-btn.php', 'Add button', 580, 'bsBtn');
    }
});
bsItems.push(insertBtn);

But it says that Factory is undefined or that create is a non-existing function.但它说 Factory 是未定义的,或者 create 是一个不存在的函数。 What can I use to make this work, to show the buttons as well as showing the dialog on click?我可以用什么来完成这项工作,显示按钮以及单击时显示对话框? I already updated the following code to view bsItems:我已经更新了以下代码来查看 bsItems:

editor.ui.registry.addButton('bootstrap', {
    type: 'buttongroup',
    classes: 'bs-btn',
    items: bsItems
});

And I tried several other possibilities to find the create function:我尝试了其他几种可能性来找到 create 函数:

editor.ui.registry.create()
editor.ui.Factory.create()
editor.ui.create()
tinymce.ui.registry.create()
tinymce.ui.Factory.create()
tinymce.ui.create()

All to no avail一切都无济于事

With version 5, TinyMCE uses a new UI framework.在第 5 版中,TinyMCE 使用了新的 UI 框架。 Third party plugins written for version 4.x that provided custom UI control elements will likely not work with version 5.为版本 4.x 编写的提供自定义 UI 控制元素的第三方插件可能不适用于版本 5。

As noted in this GitHub issue thread , tinymce.ui.Factory has been deprecated and will not be re-implemented, so it is no longer possible to create control Factories.如此 GitHub 问题线程中所述tinymce.ui.Factory已被弃用且不会重新实现,因此不再可能创建控制工厂。

The methods to add UI elements like buttons have also changed from v4 to v5.添加按钮等 UI 元素的方法也从 v4 更改为 v5。 The official migration guide goes into a fair amount of detail regarding the new locations and configuration signatures of these methods.官方迁移指南详细介绍了这些方法的新位置和配置签名。

tl;dr This particular plugin might not work with v5's new UI framework but there are still ways of customizing the UI using the new system. tl;dr 这个特定的插件可能不适用于 v5 的新 UI 框架,但仍然有使用新系统自定义 UI 的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM