To get the editor content as a string in the classic editor use this:
content = tinymce.activeEditor.getContent();
Taken from https://stackoverflow.com/a/5843951/57482
Note that you should use the APIs provided rather than directly modifying the DOM if you want to modify the content. If you don’t, you won’t update plugins local states in javascript causing problems. Modifying the DOM should be a last resort.
Also note that this will not work for the block editor. The block editor requires a completely different approach, and you can’t then edit the content and put it back without breaking the blocks or turning everything into a custom HTML block causing other issues.
Related Posts:
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- How to include jQuery and JavaScript files correctly?
- How can I run AJAX on a button click event?
- Add async script
- How to provide translations for a WordPress TinyMCE plugin?
- Can I use the wp media uploader for my own plugin?
- How-to implement admin Ajax inside an admin WP_List_Table?
- API to trigger prompt on leaving page
- Customizing the 3.5 “Add Media” popup (Backbone.js)
- Test to see if jQuery or Prototype is queued by another plugin?
- jQuery in header or footer
- Hook the Keydown Event in the TinyMCE Post Editor
- lodash dependency in a Gutenberg plugin
- wp_localize_script $handle
- How to prevent loading of all plugin’s resources?
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- How do I only load js on the post-new.php and post.php pages in admin?
- creating elements/innerblocks via rangecontrol
- What’s the better way to add an inline script?
- Can’t get JS code to work with shortcode
- How do I add a javascript file to all admin pages via a plugin?
- Gutenberg: useDispatch is not a function – @wordpress/data included
- Make a list with header and subtext in Gutenberg blocks
- Gutenberg – What is the best way to save/update post meta?
- How to Load Plugin JS in theme’s footer section
- how to include javascript file and css file in wordpress
- Mixing Regular Javascript With jQuery in a Plugin
- How to run a external JavaScript file on wp-admin if admin, and other if normal user?
- Why is my javascript not invoked in my hooks except wp_head?
- WordPress Plugin with a shortcode that dynamically generates javascript. Can I use add_action without wrapping the javascript in a function?
- How to prevent UNDO on guternberg block editor
- Creating a custom Gutenberg block with columns
- “import declarations may only appear at top level of a module” when importing WooCommerce API node module
- Gutenberg: import dependency or assign from global variable?
- javascript datatables in a plugin
- Hide shortcodes “code” when using the “editor” the same as wordpress do with “gallery”
- add javascript files only when plugin is called?
- Inserting code to HTML view from a pop up initiated from visual view
- Plugin – Make sure jquery is loaded in my settings page plus my JS file
- How can I avoid conflicts between plugin and theme?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- should i be checking for jquery before enqueing it in a plugin
- Loading custom js file on the admin page through plugin
- Run JavaScript validation script on form submit in plugin
- Custom Plugin – CSS works, JS doesn’t
- Drawing the line between theme & plugin on large scale bespoke projects
- Translate javascript with WordPress built-in localization API for static strings
- How to add a panel/box/widget/are/screen to the right side of edit post/page confusion
- Insert Into Post Not Working For Audio File Using jQuery
- Service Worker Uncaught (in promise) DOMException
- Developing the save function in Gutenberg blocks
- Gutenberg – is it ok to load dependencies multiple times?
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- About a programming language starts with [closed]
- Referencing files in JavaScript in WordPress Plugin
- Should I put my plugin javascript inline?
- wp.media libary pdf type
- Query String Filtering API
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Multiple TinyMCE on button click is initialized and appended but why only last one is writeable?
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- converting a node.js project into a wp plugin
- What happens/fires when you select a block in the editor?
- Is “document loaded” different on admin side than public side?
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- jQueryUI draggable doesn’t work in WordPress plugin
- Reading plugin settings in esnext wordpress block
- Dynamically modify content added to table via javascript
- Load script on frontend from widget plugin
- WordPress with React: Saving and Using Data Collected with fetch
- Append php file to footer
- XMLHttpRequest to open PHP file responds with Missing Page
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Replace the WordPress Media Library Uploader
- Using JavaScript in WordPress page to call for server data using AJAX
- Pass javascript result to shortcode executer function
- Filterable posts using categories
- How to get values from Tinymce visual editor popup?
- Add language localisation to javascript alert?
- Uncaught ReferenceError: kpoejy is not defined
- How to display archive by selecting year and then selecting month
- On one of my sites a file is shown as 404 but the file IS there
- How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- How can i add insertion point between inner blocks in my custom block like core blocks
- How to get the value entered in the input field in wordpres
- How react js and other Javascript Technologies works on WordPress plugin?
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- Insert meta-description into Yoast-SEO input-field via JavaScript
- Reinitiate Gutenburg’s blocks using javascript
- how to add contact form 7 shortcode in javascript variable