-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
TinyMCE editor events and transformation APIs #6648
Comments
I'm not entirely sure what you're trying to create. So far I understand:
|
The product launched, so there's more detail available here. In a nutshell, the plugin automatically adds links around specific keywords on the frontend. But in the backend, rather than render the links themselves, the plugin creates a link-like UX around Taking a step back towards Gutenberg, what seems to be missing are APIs equivalent to Related #3688 |
I'm hesitant to let plugins use TinyMCE APIs because this might all change. We'll have to create something here to would enable you to create a similar experience. How about adding the links in the content before it loads in the editor? Why does it have to be a |
It has to be a Then a HTML comment is added:
I'm not suggesting we use TinyMCE APIs directly. A reasonable alternative would be to expose named Gutenberg APIs whose underlying implementation can change. More so though, I'd love to get up to speed on any existing conversation that's been had on this topic. |
Okay. It would almost seem ideal if it followed the normal link behaviour where the link would be added on text input only. Then when the user removes it, it just would no longer show up. Might not be what you want though. Not sure atm how else this would be possible without a huge amount of code. Related: #771. |
Closing to focus on #3688. |
We have just landed Format API with #10068. It allows registering any format you need. We are still working on a way to give better control which control can be displayed for a given block and documentation. It should be all ready early next week. I think that most of the functionality described here can be recreated with new API, I'm only not quite sure about HTML comment. |
@danielbachhuber you can now target it with |
@iseulde Should be good now, thanks! |
One of the plugins I help create is Tasty Links, which automatically adds links around specific keywords. For example, here is
Gutenberg
automatically linked towordpress.org/gutenberg
:If you click on a Tasty Link, a custom preview toolbar (based on
editor.wp._createToolbar
) appears:Notably, this isn't the standard WordPress link UX. The previewed Tasty Links look like links because of a custom editor stylesheet. In reality, they're
<span>
stripped on save:If I click the "Remove" icon in the preview toolbar, then the
<span>
is replaced with a HTML comment that is persisted on save:Here's the corresponding JavaScript for my TinyMCE plugin.
In order to recreate the same Tasty Links UX in Gutenberg, I think all I need is:
editor.dom
equivalent (which supportsselect()
,addClass()
,removeClass()
, etc).Related #4658
The text was updated successfully, but these errors were encountered: