I am working on book creator in react and tinymce. User is allowed to create multiple textblock on canvas and fill them with text.
Everything works fine when button with onClick method for creating new textblock is called outside editor, like typical .
Problem started when i've tried adding a toolbar button:
setup: (editor) => {
editor.ui.registry.addButton("AddNew", {
text: "Add new",
onAction: (buttonApi) => addTextBlock()
});
},
and it works once. It creates textBlock object by updating the state object but consecutive clicks on this button reset state to initial value (empty list) and add again one object.
Same code executed from button that is placed outside editor correctly created clicked amount of textblocks.
I've no error or relevant warning in console.