Create the file /media/test/plugin.js with the following content:
window.tinymce.create("tinymce.plugins.InlineCodeButtonPlugin", {
InlineCodeButtonPlugin: function(editor, url) {
editor.ui.registry.addToggleButton("inlinecode", {
icon: "sourcecode",
title: "Inline Code",
tooltip: "Inline Code",
onAction: (_) => {
editor.execCommand('FormatBlock', false, 'code');
},
onSetup: (api) => {
editor.formatter.formatChanged('code', (state) => {
api.setActive(state);
})
}
});
}
});
window.tinymce.PluginManager.add("inlinecodebutton", tinymce.plugins.InlineCodeButtonPlugin);
Edit the Editor - TinyMCE options (System, Manage, Plugins, search for "Editor - TinyMCE", and click on it).
Towards the bottom of the page find the Custom Plugin setting and set it to inlinecodebutton
In the External Plugin URLs add a new row with the following settings:
inlinecodebutton
/media/test/plugin.js
Editing the "Editor - TinyMCE" I can see my custom "Inline Code" button and place it on the toolbar where I want.
Editing the "Editor - TinyMCE" plugin settings I cannot see my custom "Inline Code" button.
Instead, I have to set the Custom Button option to inlinecode
BUT it does not do what I need! It simply adds my custom button to the end of the toolbar.
Sure, it works, kinda sorta. The thing is, I do not want this button there; it makes no sense. I want it next to my Bold, Italic etc formatting buttons so I can correctly format inline code references in my blog posts without digging through the (very slow to render) drop-down menus.
Joomla 4.3.0
Everything else is irrelevant.
I think addressing this would require \Joomla\Plugin\Editors\TinyMCE\PluginTraits\KnownButtons::getKnownButtons
parsing the "Custom Button" plugin option and append the custom buttons to the returned array (perhaps trying to use a language string such as PLG_EDITORS_TINYMCE_CUSTOM_BUTTON_buttonName
for the label, so we can provide something meaningful here?).
Likewise, \Joomla\Plugin\Editors\TinyMCE\PluginTraits\DisplayTrait::onDisplay
would need to be modified so that the custom_button
option does not append buttons willy-nilly to the toolbar, i.e. it should never set $custom_button
.
BTW, allowing custom plugins in the TInyMCE editor plugin is FREAKING AWESOME, but there's scant documentation, y'all. I figured out how to do it by reading the code. I am not sure most users who'd like to use this feature are gluttons for punishment like yours truly
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
?
|
Seems that I forgot to actually include the information iin my report and I only documented the minification issue. So leaving my report open - and thanks for adding this @nikosdion
Found where I made the comment about the icons #36968 (comment)
AND YES it is awesome to be able to create your own tinymce plugins. I have created several.
As for the slow rendering of the dropdowns that can be resolved if we disable the rendering of the dropdown css
Yup, I am using custom TinyMCE plugins to simplify my life in my blog and on my site doing support.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-05-10 18:32:40 |
Closed_By | ⇒ | nikosdion | |
Labels |
Added:
Feature
Removed: ? |
please reopen this
Valid issue
Status | Closed | ⇒ | New |
Closed_Date | 2023-05-10 18:32:40 | ⇒ | |
Closed_By | nikosdion | ⇒ |
Hi guys,
Any idea of progress here?
This is a duplicate report of #39668 but this has more useful information so I will close mine