-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert text using tinyMCE into a paragraph block shows text but doesn't save it #12126
Comments
Another way around this would be if there is an equivalent to the "mceInsertContent" to be used with the new blocks. It would insert content at the current cursor position in the active block. Is there anything like this in the Gutenberg block interface? |
If you're using |
TinyMCE is considered an implementation detail in Gutenberg and shouldn't be used as an API to insert content into Gutenberg blocks. We could in theory drop it from RichText. (In fact any imperative DOM API is not an official API) Instead, I'd suggest using the format API to manipulate the content of RichText content. We're still lacking documentation for this API but this plugin contains some good examples https://wordpress.org/plugins/advanced-rich-text-tools/ Thanks |
Is there a place to look for API Documentation for Gutenberg - what is available and what may be coming? I'm afraid that trying to reverse engineer from the plugin is beyond me. Besides, without the doc I'm sure I could easily cause problems for other plugins/themes. |
The documentation lives here https://wordpress.org/gutenberg/handbook/ And you should look at the the issues labeled with "Documentation" to see what's coming. |
Although this has been closed for 2 years I think it's rather telling that the official documentation still doesn't give a solution. Surely there has to be a simple way to insert "this is my new bit of text" into the block at the current cursor position. |
Is there a solution yet? We really need a way to insert text to paragraph block via js and make it save it. Looks like it saves it when the block loses focus, but .trigger('focusout') doesn't help. Also, .click() or .focus() on another block doesn't place cursor there. The focus is still on the previous block. How to save the value of the paragraph, guys? |
Describe the bug
My plugin uses the command tinyMCE.execCommand("mceInsertContent", false, selection); to insert text from a metabox into a Gutenberg paragraph (or quoute) block. The text shows up at the cursor in the block, but when I save it (save draft or publish or update) or preview it, it is not shown. If I edit the block with HTML it is also gone.
If I insert the text and then follow it up with some manual typing, the text I inserted, along with what I type, is saved and shown on the preview.
For backward compatibility, shouldn't the tinyMCE insert command work on a gutenberg block? As identified in issue #4855 and #10509, the tinyMCE insert command does not insert at the cursor in a classic block. In this bug, it is inserting at the cursor in a Gutenberg block, but it isn't saving the text that is inserted.
To Reproduce
To reproduce you would need to use a JS call to tinyMCE.execCommand("mceInsertContent", false, selection); where selection is the text you want to insert. In my plugin this is called when they highlight a paragraph in a metabox (created by my plugin) and then click. This did seem to work in earlier versions of the beta until this weekend sometime.
Expected behavior
I would expect the text to be inserted at the cursor within the Para or Quote block and that the newly inserted text would be saved when I press save draft or publish or update, as well as show when previewed.
Desktop (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: