SID-02142: How do I add a custom button or context menu entry?
| Status: |
Answered |
TWiki version: |
6.0.1 |
Perl version: |
5.018002 |
| Category: |
TinyMCEPlugin |
Server OS: |
Ubuntu 14.04.3 |
Last update: |
10 years ago |
I am trying to add a minor function to the
TinyMCE editor so that users can either press a button or context menu entry to add a text string to the cursor location.
Is there an article explaining how to perform either of these tasks?
--
Neil Roberts - 2016-01-04
Discussion and Answer
I have never done that, but I would start at
TinyMCEPlugin and
https://www.tinymce.com/docs/demo/custom-toolbar-button/
. The init topic of the plugin pointed to by the TINYMCEPLUGIN_INIT_TOPIC setting has a "TINYMCEPLUGIN_INIT" section where you can add a custom button.
--
Peter Thoeny - 2016-01-06
Ok. All the information I can find at the above and elsewhere, seems to relate to version 4 and over. As far as I understand it, version 3 and 4 are not compatible. Seems to be a bit too steep a learning curve to go the route of writing a whole plugin to do this.
Alternative workable option......
I now would like to add a static text string which people can copy and paste which would appear beneath the "Your signature to copy/paste: " box. In the same format and structure as that box.
Is that something I can add and where would I do it?
--
Neil Roberts - 2016-01-12
I did some digging. It is doable with the tinymce-3.5 we are using. Here is an example
helloworld button.
First, add this to the
"TINYMCEPLUGIN_INIT" section of the topic where the global
TINYMCEPLUGIN_INIT_TOPIC setting is pointing:
"setup" : function(ed) {
ed.addButton('helloworld', {
title : 'Hello world',
image : '%ICONURLPATH{globe}%',
onclick : function() {
ed.focus();
ed.selection.setContent('Hello world!');
}
});
},
Then, create a global
TINYMCEPLUGIN_ADDITIONAL_BUTTONS1 setting, listing the
helloworld button, such as:
* Set TINYMCEPLUGIN_ADDITIONAL_BUTTONS1 = helloworld
That will add a

button to the toolbar; when pressed, it will add text
"Hello world!" to the current cursor position.
--
Peter Thoeny - 2016-01-13
Took me a short time to work out where exactly to put that in the TINYMCEPLUGIN_INIT section but now it is there and working exactly as I had hoped. Thankyou very much for putting the time into helping me get this resolved.
--
Neil Roberts - 2016-01-13
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.