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

[Bug]: Dragging Only A Part Creates Duplicate Unique-ID #5578

Closed
1 task done
rosenbauerwillbacker opened this issue Sep 1, 2024 · 8 comments
Closed
1 task done
Assignees
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@rosenbauerwillbacker
Copy link

rosenbauerwillbacker commented Sep 1, 2024

Affected Packages

@tiptap-pro/extension-unique-id, @tiptap-react

Version(s)

2.10.11

Bug Description

Simple steps to reproduce:

  1. Visit the official Tiptap demo: https://tiptap.dev/docs/editor/extensions/functionality/uniqueid
  2. Select a small text part of the heading. (e.g. "very")
    image
  3. Drag it to an empty space, so that it creates a new node.
    image

As you can see we have now created two nodes with a duplicate id. I have also reproduced that locally with the latest packages.

Quick-Fix
We have fixed it by automatically forcing the user to select the whole heading.

addProseMirrorPlugins() {
    return [
      new Plugin({
        props: {
          // Select the entire heading nodes when they are dragged
          handleDOMEvents: {
            dragstart(view, event) {
              const { state, dispatch } = view;
              const { doc, selection } = view.state;
              const { from, to} = selection;

              let minFrom = from;
              let maxTo = to;
              doc.nodesBetween(from, to, (node, pos) => {
                if (node.type.name === 'heading') {
                  minFrom = Math.min(minFrom, pos);
                  maxTo = Math.max(maxTo, pos + node.nodeSize);
                }
              });
              if (minFrom !== from || maxTo !== to) {
                const tr = state.tr.setSelection(
                  TextSelection.create(state.doc, minFrom, maxTo)
                );
                dispatch(tr);
              }
            }
          }
        }
      })  
    ];
  },

Info
Our team would really like to use this pro extension in production. However, this is the third bug we have encountered after testing it for two days. Is this extension considered stable or is it experimental?

It would be great if some additional logic or automated tests would be added that ensures the stability of this great plugin. We have a business-critical application and having suddenly two nodes with duplicate ids poses a big threat to us.

Thank you very much in advance for your help.

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

Unique-ids should be unique as the name suggests.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@rosenbauerwillbacker rosenbauerwillbacker added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Sep 1, 2024
@github-project-automation github-project-automation bot moved this to Triage open in Tiptap Sep 1, 2024
@nperez0111
Copy link

Hm that is strange because it should be rewriting if there is every a duplicate ID valid bug on our side that @bdbch could help with

@marciaterzo
Copy link

Any updates on this one @bdbch @nperez0111? This is actually a huge problem, because I expect ids to be unique as they should.

Unfortunately, the Unique-ID is a pro plugin, so the code is obfuscated.

Thank you in advance!!

@bdbch
Copy link
Member

bdbch commented Oct 15, 2024

I'll take a look into this tomorrow

@marciaterzo
Copy link

Thank you @bdbch!

@guarmo guarmo self-assigned this Oct 16, 2024
@guarmo guarmo closed this as completed Oct 16, 2024
@github-project-automation github-project-automation bot moved this from Triage open to Done in Tiptap Oct 16, 2024
@bdbch
Copy link
Member

bdbch commented Oct 17, 2024

@guarmo looked into it and pushed a fix for this. :) Should hit live soon.

@marciaterzo
Copy link

Awesome @guarmo and @bdbch!! Thank you so much for your great support.

@markbulingit
Copy link

So for this bug to disappear we have to purchase PRO?

@nperez0111
Copy link

So for this bug to disappear we have to purchase PRO?

The bug is in the PRO extension so not sure what you are referencing here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
No open projects
Archived in project
Development

No branches or pull requests

6 participants