Wrap selected text in nested HTML? (And then delete it via UI?)

I’m curious if the following is possible with ProseMirror:

  1. Wrap selected text in a nested HTML structure
  2. REMOVE that nested HTML structure when that same text is selected and a button is clicked in the menu bar

Seems like a simple enough scenario, but this is the “make or break” functionality that’s caused me to abandon TinyMCE and Trix. That leaves CKEditor and ProseMirror, and frankly, ProseMirror seems easier to work with (and I’ve been using CodeMirror for many years).

Anyway, I want to know if it’s even possible to pull off the above scenario. More specifically, I want to avoid ending up in a situation where the only way to remove the nested HTML is to go into code view and remove it manually. (That’s a deal-breaker—this is a content composition editor for people who never want to see code.)

Thank you for any insights and guidance you can provide!

Assuming the wrapping HTML is predictable, this would be done by defining a custom document node type for it (similar to how blockquotes work in the basic schema), wrapping the content in that, and then unwrapping it again as needed.

1 Like

Thanks, @marijn—I’ll give custom document nodes a shot and see if I can get the results I want.