ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
27.55k stars 2.29k forks source link

[Bug]: OrderedList no value supplied for attribute type #5659

Open jwellner opened 1 month ago

jwellner commented 1 month ago

Affected Packages

@tiptap/extension-ordered-list

Version(s)

2.6.3 and up

Bug Description

This change https://github.com/ueberdosis/tiptap/commit/c36e4c3afc0883ff1310b8ea5338fadcb0f71f4b causes that there is no default for "type" in our generated tiptap json schema with all enabled tiptap plugins.

The schema json gets generated using getSchema from @tiptap/core this results in the following part for orderedList

    "orderedList": {
      "content": "listItem+",
      "group": "block list",
      "attrs": {
        "start": {
          "default": 1
        },
        "type": {}
      },
      "parseDOM": [
        {
          "tag": "ol"
        }
      ]
    },

Our hocuspocus server uses this schema to read data and now throws this error message on some of our documents:

[onLoadDocument] No value supplied for attribute type

To fix this we downgraded @tiptap/extension-ordered-list to 2.6.2

I am not sure if this should be fixed in the plugin or if I should do something else generating the schema?

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

I think there should be a default in in the resulting TipTap schema.

Setting it undefined causes it to not add a default to the schema.

Additional Context (Optional)

No response

Dependency Updates

jwellner commented 1 month ago

Some additional digging, the error originates from prosemirror-model it seems that if the attribute is not required a default is needed?

https://github.com/ProseMirror/prosemirror-model/blob/a57531574336d00df43a68e3a2f69582b426033e/src/schema.ts#L27