cozy / prosemirror-go

A port in Go of ProseMirror for writing a collaborative editing server
GNU Affero General Public License v3.0
45 stars 9 forks source link

NodeType.DefaultAttrs not initialised properly #15

Closed vioricamancas closed 1 year ago

vioricamancas commented 1 year ago

When creating a new node type the defaultAttrs function is used. But instead of setting up the default value, it adds the entire Attribute object there. This leads to the created objects with CreateAndFill to have a bad format, this also affects the (n *Node) ToJSON method since the resulting object cannot be JSON-serialised if it has any Attributes.

Here is the original prosemirror-model counterpart of the method where you can see that attr.default is added to the map instead of just attr. https://github.com/cozy/prosemirror-go/blob/master/model/schema.go#L21 https://github.com/ProseMirror/prosemirror-model/blob/master/src/schema.ts#L22

nono commented 1 year ago

You are right. Thanks for this bug report, I'm fixing it.