1

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.

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. 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:

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

And I tried several other possibilities to find the create function:

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

4

1 回答 1

1

在版本 5 中,TinyMCE 使用了新的 UI 框架。为版本 4.x 编写的提供自定义 UI 控件元素的第三方插件可能不适用于版本 5。

本 GitHub 问题线程中所述,tinymce.ui.Factory已弃用且不会重新实现,因此不再可能创建控制工厂。

添加按钮等 UI 元素的方法也从 v4 更改为 v5。官方迁移指南详细介绍了这些方法的新位置和配置签名。

tl;dr 这个特定的插件可能不适用于 v5 的新 UI 框架,但仍有使用新系统自定义 UI 的方法。

于 2019-03-11T21:56:13.103 回答