ueberdosis / tiptap

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

[PRO]: Unique Id and node attrs when toggle/set Node #5668

Open shiz-ceo opened 1 month ago

shiz-ceo commented 1 month ago

Affected Packages

core, pm/commands

Version(s)

2.7.3

Description of the Bug

Wen you toggle heading or other block, that change Node type, id recretates. This affect by: setBlockType from @tiptap/pm/commands.

When user toggle or set node, we need to copy current attrs to new node.

Browser Used

Chrome

Code Example (Preferred)

https://tiptap.dev/docs/editor/extensions/functionality/uniqueid

Expected Behavior

paragraph id: cdaa15d5-f2ee-44a0-8fac-07377ded3676 toggle paragraph -> heading heading id: cdaa15d5-f2ee-44a0-8fac-07377ded3676 toggle heading -> paragraph paragraph id: cdaa15d5-f2ee-44a0-8fac-07377ded3676

Additional Context (Optional)

Current behavior:

paragraph id: cdaa15d5-f2ee-44a0-8fac-07377ded3676 toggle paragraph -> heading heading id: 0f3f33dd-5d18-4f7e-b4d2-0730303ab032 toggle heading -> paragraph paragraph id: 4df14d82-6983-4206-968f-be0d261ebbc1

Related functions & urls: https://github.com/ueberdosis/tiptap/blob/develop/packages/core/src/commands/toggleNode.ts#L26

https://github.com/ueberdosis/tiptap/blob/develop/packages/core/src/commands/setNode.ts#L21

Dependency Updates