Я пытаюсь написать собственный плагин tinyMCE.
У меня проблема, когда я пытаюсь программно добавить элементы в свое окно.
Моя цель - добавить новые элементы "textbox" под существующимкаждый раз, когда пользователь нажимает кнопку «Добавить ответ».
Я пытаюсь сделать это несколькими способами, но ничего не получается.
Мой код:
const plugin = (editor) => {
var w;
var body_items = [
{
type: 'label',
text: 'Title',
},
{
type: 'textbox',
name: 'title',
size: 40
},
{
type: 'button',
text: 'Add reply',
onclick : (e) => {
body_items.push({
type: 'textbox',
name: 'title',
size: 40
});
}
}
];
var buildBody = function(){
return [{
type: 'container',
layout: 'flow',
items: body_items
}];
}
editor.addButton('dydu-quick-replies', {
text: 'quick replies',
icon: true,
onclick: () => {
w = editor.windowManager.open({
title: 'Quick replies plugin',
body: buildBody(),
onsubmit(e) {
editor.insertContent(e.data.title);
}
});
}
});
};
export default plugin;