Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRO]: extension-unique-id does not maintain ids #3974

Open
1 of 2 tasks
arnaud-secondlayer opened this issue Apr 18, 2023 · 5 comments
Open
1 of 2 tasks

[PRO]: extension-unique-id does not maintain ids #3974

arnaud-secondlayer opened this issue Apr 18, 2023 · 5 comments
Labels
Category: Pro The issue or pull request is related to the pro packages of Tiptap. Triage: Open A new issue or pullrequest that requires triage (added by default) Type: Bug The issue or pullrequest is related to a bug

Comments

@arnaud-secondlayer
Copy link

Which packages did you experience the bug in?

extension-unique-id

What Tiptap version are you using?

2.0.0

What’s the bug you are facing?

I use setContent with the following content (already containing unique ids in field uid):

{
    "type": "doc",
    "content": [
        {
            "type": "title",
            "attrs": {
                "uid": "d23ac884-4609-49a4-a5a4-53d840fdd3cf",
                "name": "title",
                "class": "title"
            },
            "content": [
                {
                    "type": "text",
                    "text": "Title"
                }
            ]
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "9f9d65aa-8b17-49be-a4e0-d2a386351d6b"
            },
            "content": [
                {
                    "type": "text",
                    "text": "this is working"
                }
            ]
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "bbe397c0-8088-4cb2-9851-ee32bebd3312"
            }
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "c28cf653-531c-42d2-ad15-3efdb4a97c53"
            }
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "9f477b6e-d084-4916-899c-3ab452f6622e"
            }
        }
    ]
}

When retrieving the content with editor.getJSON(), I can notice that the final ids of the empty paragraph have changed:

{
    "type": "doc",
    "content": [
        {
            "type": "title",
            "attrs": {
                "uid": "d23ac884-4609-49a4-a5a4-53d840fdd3cf",
                "name": "title",
                "class": "title"
            },
            "content": [
                {
                    "type": "text",
                    "text": "Title"
                }
            ]
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "9f9d65aa-8b17-49be-a4e0-d2a386351d6b"
            },
            "content": [
                {
                    "type": "text",
                    "text": "this is working"
                }
            ]
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "1c5f884d-8421-419f-a9a6-dfd3a989ba14"
            }
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "6cf3e4d5-590b-4a4c-b0f4-8a0c00ca4a34"
            }
        },
        {
            "type": "paragraph",
            "attrs": {
                "uid": "bbe397c0-8088-4cb2-9851-ee32bebd3312"
            }
        }
    ]
}

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

I would have expected the ids to remain unchanged because setting the content with all nodes already have a unique id.
I'm also not sure to understand why id bbe397c0-8088-4cb2-9851-ee32bebd3312 is changing position in the document.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@arnaud-secondlayer arnaud-secondlayer added Category: Pro The issue or pull request is related to the pro packages of Tiptap. Triage: Open A new issue or pullrequest that requires triage (added by default) Type: Bug The issue or pullrequest is related to a bug labels Apr 18, 2023
@Jackesa
Copy link

Jackesa commented May 8, 2023

This is causing trouble for my team as well.

@joaopcm
Copy link

joaopcm commented Jun 19, 2023

Same here...

@shuyudao
Copy link

Same

If the paragraph is preceded by an empty paragraph, the empty paragraph generates a new uid even if the uid attribute has been set, and the first paragraph with content after the empty paragraph generates a new uid if there is a content change.

"@tiptap-pro/extension-unique-id": "^2.1.0",
"@tiptap/pm": "^2.0.3",
"@tiptap/react": "^2.0.3",
"@tiptap/starter-kit": "^2.0.3",

@lin52025iq
Copy link

A similar problem occurs when a line break is copied and pasted to the top of a paragraph. The uuid of the paragraph before pasting is updated.

2023-07-28.16.57.47.mov

@olavhaugen
Copy link

olavhaugen commented Jan 3, 2024

I have this issue as well. Any update on this?

Adding a filter to the UniqueID extension seems to filter out the transaction from the setContent command, and thus preventing the extension from generating new IDs.

UniqueID.configure({
  filterTransaction: transaction => !transaction.getMeta('preventUpdate')
})

Is this an acceptable workaround or am I missing something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Pro The issue or pull request is related to the pro packages of Tiptap. Triage: Open A new issue or pullrequest that requires triage (added by default) Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Triage open
Development

No branches or pull requests

8 participants