Adding Marks to a schema at runtime

Hello, I’d like to know if it’s possible to add MarkTypes to an editor instance, changing its schema on the fly.

This is the problem originating my question: in Pandoc a custom style is specified with a Span inline element, with a custom-style attribute set to the name of the style.

I modeled the Span with a Mark that has an optional customStyle attr.

But think of two overlapping custom styles: both have the same Mark type, they only differ in attributes.

So the solution would be using two different MarkTypes, but I don’t know in advance which ones are used in a document. That’s why I’d need to add MarkTypes to the schema of an already instantiated editor.

No, it isn’t.

The excludes mark spec option might be useful here.

Thanks Marijn, I suspected it wasn’t possible.

I don’t want to prevent custom styles (or, in general, custom inline markup) from overlapping, I want to make it possible, but I don’t know those custom inlines in advance, since their names are a free choice of the user.

An example:

<span custom-style="red-ink">This text is red, 
and <span custom-style="yellow-highlight">this is also highlighted in yellow</span></span>.

In Pandoc terms, they are both Span inlines with a different custom-style attribute. If I model them with the same MarkType I won’t be able to keep them distinct in Prosemirror.

So I’m going to define a certain amount of clones of the same MarkType with different names like customStyle1, customStyle2, … and associate them at runtime to each different custom style in the document.

I’m not expecting a big performance cost from defining – say – a hundred MarkTypes like those; do you?

So… did you look at the excludes option I linked?

Ops, now I did.

excludes: ""

should be the answer (wow, it’s subtle).

Thank you for your patience.