0

我正在尝试通过单击按钮来过滤模板,我有三个模板列表,我希望每个按钮都在模板中显示这些列表之一。

我的尝试:

self.wysiwygConfig = {
    plugins: ['... template ...'],
    toolbar: '... | template | spellchecker | buttonA buttonB buttonC',
    setup: function (editor) {
        editor.ui.registry.addButton('buttonA', {
            text: 'A',
            onAction: function () {
                //filter the list
                //doesn't work
                self.wysiwygConfig.templates = [];

                //also this doean't work
                UserFilterTemplates = [];

                //open the modal
                $('.tox-tbtn[title="Insert template"]').trigger("click");
            }
        });
        /* same for buttonB && buttonC */
    },
    templates: UserFilterTemplates.map(item => ({ title: item.Title, description: item.Description, content: item.Template }))
};

有没有办法过滤或重新初始化模板?

4

0 回答 0