Closed tobimori closed 9 months ago
This is a bit more complicated, since toggleInlineFormat()
accepts a token name as parameter instead of the delimiter. The token itself has to be part of the language definition for this to work properly, since a lot of magic happens behind the scenes for this to work with more complex situations like nested formats. So I am afraid this won’t be possible by now. But if you got an important use case, please share it with me and we could consider to add an extension point for that.
I simply want to build an extension for a custom mark. The examples only show how to insert/replace text but not how to replicate the behavior from the built-in Marks.
A simple highlight extension just runs a regex on the editor content and adds a span round text, where it matches. But toggling inline formats really requires extending the language definition and requires the editor to be able to recognize the highlight as a language feature, so toggling cannot work without that. There’s a reason why src/components/Utils/markup.js
is such a monster. But what exactly do you want to add to the editor? If it would be of interest for other users, I’d be happy to integrate it into the core language definition.
It's pretty specific to the design, a mark for smaller text size, but one could probably use subscript for that.
@tobimori Okay, since this is not a generat use case and providing an extension point for additional inline formats would add a lot of complexity, so I close this as I don’t have the capacity for implementing this.
Doing something like this, similiar to how it is in the core, doesn't work: