I have found a great tutorial about making a custom button to the tinymce.
http://qnimate.com/adding-buttons-to-wordpress-visual-editor/
You can just follow this guide and copy all of it. Don’t forget to activate your new plugin in the plugin menu (in admin panel).
Then you can just change the code inside index.js and especially in the
ed.addCommand("green_command", function() {
For making the background of the selected cell toggle (on/off) you just change the code like this:
//button functionality.
ed.addCommand("green_command", function() {
ed.formatter.register('termin_format', {
selector: 'td',
styles: { backgroundColor: '#adf2a7'},
});
ed.formatter.toggle('termin_format');
});
Related Posts:
- How to add “Insert/Edit link” button in custom popup tinymce window?
- Add popup window to TinyMCE buttons
- How i can i add a split button or list box to the WordPress TinyMCE instance
- TinyMCE Anchor Button not showing
- Adding TinyMCE custom buttons when using teeny_mce_before_init
- Visual Editor freezing on text highlight since 4.3
- Add table controls with wp_editor minimal editor configuration (‘teeny’)
- Add buttons to the new TinyMCE WP Editor. Javascript API
- Can i set css class for table via TinyMCE [closed]
- TinyMCE: Move buttons from 2nd row to top row
- Adding a Media Button to the WordPress Content Editor
- Wordpres Tinymce custom button (Gavick guide)
- How to insert image from link in TinyMCE
- add button to tinymce
- How do I include a TinyMCE editor in the frontend?
- Switch between Visual and HTML tab freely
- Creating a wp_editor instance with custom tinyMCE buttons
- How to add custom CSS (theme option) to TinyMCE?
- Remove HTML editor and visual/HTML tabs from TinyMCE
- How to disable TinyMCE from removing span tags
- WordPress automatically adding ” “?
- How to customize TinyMCE4 in WP 3.9 – the old way for styles and formats doesn’t work anymore
- TinyMCE editor is breaking my beautiful HTML
- How to get the input of a TinyMCE editor when using on the front-end?
- Removing buttons from the editor
- Add button to TinyMCE bar without creating a plugin
- Load wp_editor via ajax [duplicate]
- Enqueue Script After TinyMCE initialized
- How to use tinyMCE for user “biographical info”?
- How to add multiple buttons to TinyMCE?
- Why did multiple line breaks stop working in text editor?
- TinyMCE 4.x : How to customize toolbar on wp_editor()
- Stop editor from removing tags and replacing them with nbsp
- Replace Taxomony Description Field with Visual/WYSIWYG Editor
- How to replace the content of tinyMCE editor in both text and visual mode using jQuery?
- Unable to add “code” button to TinyMCE toolbar
- TinyMCE format dropdown no longer showing style previews
- TinyMCE in customizer
- Possible to stop WordPress from adding p1, p2… classes to p tags in TinyMCE?
- Custom Tiny MCE button to bring up a custom php popup
- WordPress 3.2 has broken my TinyMCE code
- wp_editor disable after reaching character count limit
- When switching from html to visual editor the tag gets corrupted
- Is it possible to re-use the image details popup?
- Markup of oEmbed codes in the editor?
- Visual Tab Missing From Editor
- How to use the new Dashicons for custom TinyMCE buttons?
- Add unique class or ID information to tinyMCE
- Is it possible to create nested lists in the WYSIWYG editor?
- How can I stop TinyMCE from converting my HTML entities to characters?
- Add a button to tinyMCE editor on Custom Post Type
- How to keep non-breaking spaces in the visual editor?
- Is there a way to prevent the Editor from modifying my HTML
- Cite-Tag for blockquotes
- Wait for Gutenberg or built something in ACF?
- Replicating the_editor (Media Bar, TinyMCE, Visual/HTML Tabs) functionality without a huge rewrite
- “wp_editor” not displaying TinyMCE correctly when square brackets used in name
- HTML5, WordPress and Tiny MCE issue – wrapping anchor tag around div results in funky output
- Remove “Are You Sure” dialogue when leaving editor
- Secure Validation of wp_editor in Theme Options
- Creating a custom MCE view for your shortcodes [closed]
- Detecting when TinyMCE is “ready”
- Using a dashicon for a custom button in TinyMCE?
- Apply custom style to single word in WordPress
- How to disable TinyMCE 4 keyboard shortcuts
- How to customize the symbols that appear in the Visual Editor insert custom character
- Pasting code into pre-formatted text in Visual Editor not working in 3.3.1
- Tiny MCE not adding p tag when saving theme option
- Second toolbar in tinymce has “display:none” set?
- How to add TinyMCE keyboard shortcut
- How to keep a textarea and stop tinymce?
- Add Shortcode inline inside Gutenberg block
- Integrating inline tinymce editor in a component for a gutenberg block
- WordPress MultiSite Paste from Word Tool Does not work
- TinyMCE Editor Set Default Tab
- data-accordion removed in Visual Editor
- Registering custom TinyMCE buttons, for admin area, to work with custom instances of wp_editor
- Using post ID in custom tinyMCE button
- TinyMCE – Show Advanced Options (2nd Row) By Default
- Remove quicktag buttons but not Visual / Text editor and tabs
- How to make WordPress and TinyMCE accept tags wrapping block-level elements as allowed in HTML5?
- TinyMCE removes iframe attributes width and height
- TinyMCE editor – new lines not rendered on front end
- onClick inside post_content does not appear in post tinymce editor
- How to get WP editors tinyMCE instances
- WordPress tinymce prints empty P tag and break html format
- Append Font Family in TinyMCE
- Disabling TinyMCE keyboard shortcuts altogether
- Disable TinyMCE autoformatting
- Remove ‘Visual’ tab from TinyMCE editor
- Remove empty lines ( ) when author updates their post
- TinyMCE strips line breaks on mceAddControl
- tinyMCE duplicates previous block element when pressing return (visual editor)
- Easy way to inject js in tinymce iframe?
- Count Words using tinymce in the front-end
- WP 3.3 my rich text category editor toolbar is gone!
- TinyMCE – Add class to OL – selector doesn’t seem to get parent OL,UL, just LI’s (4.6.3)
- What is this: data-wplink-url-error=”true” and why is it added to my links?
- tinyMCE.activeEditor = null WP editor loaded in ‘Text’ mode?
- WordPress visual editor broke due to non standard port?