Ok I found the solution here
Just do
wp.editor.initialize('editor_id', {
tinymce: true,
quicktags: true
});
And then add buttons to the toolbar like so:
jQuery( document ).on( 'tinymce-editor-setup', function( event, editor ) {
if(editor.id !== 'editor_id') return;
editor.settings.toolbar1 += ',mybutton,alignleft,aligncenter,alignright,fontselect,hr';
editor.addButton( 'mybutton', {
text: 'My button',
icon: false,
onclick: function () {
editor.insertContent("It's my button!");
}
});
});
It only works with jQuery as I understand because it’s a special function added to jQuery by WordPress (in WP 4.8+).
You can see all possible toolbar buttons here: https://www.tiny.cloud/docs/advanced/editor-control-identifiers/#toolbarcontrols
Related Posts:
- Make TinyMCE checkbox that returns a value instead of true/false
- wp.editor.initialize does nothing
- Custom wp.editor.initialize settings ignored
- Button insert link on front wp_editor not working
- Media library not working with wp_editor() on the front end
- How to reference TinyMCE body in my script
- disable tags on wordpress text editor
- None of the JavaScript works when using wp_editor
- map function for objects (instead of arrays)
- Check if a string has a certain piece of text [duplicate]
- How to convert a string to an integer in JavaScript?
- How do I make the first letter of a string uppercase in JavaScript?
- window.location.href and window.open () methods in JavaScript
- “document.getElementByClass is not a function”
- How to create an associative array in JavaScript literal notation
- Include another HTML file in a HTML file
- Cannot open local file – Chrome: Not allowed to load local resource
- How to read a local text file?
- Compare dates with javascript
- Javascript Uncaught SyntaxError: Unexpected identifier
- What’s the best way to convert a number to a string in JavaScript?
- React Native: this.setState is not a function
- How to perform string interpolation in TypeScript?
- forEach is not a function error with JavaScript array
- Short circuit Array.forEach like calling break
- Bootstrap Dropdown menu is not working
- How do I format date in jQuery datetimepicker?
- Express Render not working return error: No default engine was specified and no extension was provided
- Remove Object from Array using JavaScript
- Angular4 – No value accessor for form control
- What is the difference between ( for… in ) and ( for… of ) statements?
- TypeError: Cannot read property “0” from undefined
- How to use npm jquery module?
- Cannot read property ‘bind’ of undefined. React.js
- Why is my asynchronous function returning Promise {
} instead of a value? - NodeJs : TypeError: require(…) is not a function
- Sort array by firstname (alphabetically) in Javascript
- Sorting arrays in javascript by object key value
- How do I get an element to scroll into view, using jQuery?
- document.getElementById not working / Display
- jQuery: Check if div with certain class name exists
- Objects are not valid as a React child. If you meant to render a collection of children, use an array instead
- Error: ENOENT: no such file or directory, stat ‘/public/main.html’ at Error (native)
- CreateElement with id?
- Print PDF directly from JavaScript
- Set value of hidden input with jquery
- How does AJAX work?
- How to remove all duplicates from an array of objects?
- Finding the average of an array using JS
- Creating a div element in jQuery
- e.target.value on an input field ReactJs, how does it work?
- gapi is not defined – Google sign in issue with gapi.auth2.init
- Remove all special characters with RegExp
- jQuery: Get selected element tag name
- Does ECMAScript 6 have a convention for abstract classes?
- Why is jquery show() not working in example
- console.log showing contents of array object
- How can I use jQuery to run MySQL queries?
- Using setTimeout on promise chain
- Regular Expression to reformat a US phone number in Javascript
- How to use forEach loop correctly in angular 2?
- javascript push multidimensional array
- How can I know which radio button is selected via jQuery?
- jquery toggleClass not working
- Positioning element at center of screen
- Get hours difference between two dates in Moment Js
- JQuery Number Formatting
- How to add jQuery in JS file
- Get query string parameters url values with jQuery / Javascript (querystring)
- trying to enqueue script in wordpress
- Does javascript have an equivalent to PHP’s preg_replace_callback?
- WP REST – video and audio players
- Headless WordPress: How to authenticate front end requests?
- Inserting ads within content
- Theme Customiser not live previewing changes on pseudo elements
- Instantiate TinyMCE via JS ( rather than PHP/wp_editor )
- Move all the JS files to the bottom|footer, the right way
- How to handle Gutenberg wp.data async errors?
- How do I access site and block editor state data and use `useSelect()` or `withSelect()` to bind it to my components?
- Modals using loops and ACF [closed]
- Changes to JS not reflected on site
- How to set translations in javascripts for my plugin?
- How to make wordpress URLS google friendly for ajax driven sites?
- js addclass function not working as expected, intereaction or special WP somethign needed?
- Get a default value of the Customizer setting using wp.customize API (JS)
- Google PageSpeed Enable Compression isn’t working?
- How can I add Javascript in the header of all post pages and only post pages
- wp_enqueue_script not loading my custom js file
- Javascript alert appears before tag
- Add captcha validation to my custom form for Frontend posting
- AddThis Sharing Bar Not Displaying on Custom Page Template – JS conflict?
- Bootstrap bundle present in page source but not working
- Web cover page open when button clicked
- Add JavaScript-Library “Fitty” to WordPress
- Access checks with custom REST endpoints and backbone
- How to pass data to javascript in custom widget class
- jQuery + more won’t load in header
- How to add additional JavaScript code [duplicate]
- JavaScript errors
- Unable to change the location of a file