[SOLVED] Criteria / condition for TinyMCE pluging (button)

Is there as way to make a (custom) TinyMCE plugin 'run' / show buttons just in certain conditions?

I would like to ONLY show the added buttons if content is beeing edited ( so not in add-view).
Also, if possible, I only want it for certain content types

UPDATE: It looks like it is possible to put the condition in the javeacript itself.
This will also prevent the button from showing. ( <body tag classes also includes 'portaltype-my-type and userrole/permissions )

tinymce.PluginManager.add("MyAddon_CreateSomething", function (editor) {
     const body = document.body;
     if (document.body.classList.contains('template-edit')) {
1 Like