Preserving Custom attributes


#1

Is there a way to get the editor to not drop custom attributes on elements. I use data-id’s to map back to another document. The problem I have is I have not found in the documentation a way to make the editor not drop (or be aware) of these attributes when it does the transformation.

Is there a way to inform the transformations to keep the attributes?


Keep preexisting custom attributes on nodes
#2

AFAIK you’ll have to make custom schema for all block types that need to maintain that. Here’s our div schema that does that: https://github.com/the-grid/ed/blob/d12b957586891d9affeb710314e5b651c047ca7a/src/schema/media.js#L24-L34

If you’re doing this with normal editable HTML types you’ll have to consider duplicate ids when you split a paragraph into two, or copy and paste.

(We ended up only tracking ids on non-html block types, though this might change.)


#3

I had a feeling it had to be done that way and started to look at schemas. I already handle duplicate ids with my custom editor that I wrote that I am trying to replace so not a big issue there.


#4

That’s not working for me. :confused: The parse function highlighted is never called in my implementation. I’m using the https://prosemirror.net/examples/dino/](https://prosemirror.net/examples/dino/ demo. I’m totally new to ProseMirror.

I can’t get any attributes added to dinos in the content to stay preserved once the content is parsed and the dinos are converted into nodes.