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]: Attr 'id' is duplicated on split block. #5612

Open
1 task done
andyj2022 opened this issue Sep 12, 2024 · 4 comments
Open
1 task done

[Bug]: Attr 'id' is duplicated on split block. #5612

andyj2022 opened this issue Sep 12, 2024 · 4 comments
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

@andyj2022
Copy link

andyj2022 commented Sep 12, 2024

Affected Packages

core, paragraph, heading

Version(s)

2.6.6

Bug Description

The problem occurs when the 'ENTER' key is pressed within a paragraph or a heading that has established an 'ID' attribute.

Tiptap makes 'split' and places the same attribute in the two resulting blocks, which is always incorrect.

Browser Used

Firefox

Code Example URL

Expected Behavior

The expected thing is that if it is divided into two ('split') a block that has established an 'ID' attribute, the first block stays with the 'ID' attribute and the second block has no ID attribute.

Additional Context (Optional)

Anyway, Tiptap should never produce an HTML that has two blocks with the same 'ID' because it is invalid.

Dependency Updates

  • Yes, I've updated all my dependencies.
@andyj2022 andyj2022 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 12, 2024
@andyj2022 andyj2022 changed the title [Bug]: Attr ìd' is duplicated on split block. [Bug]: Attr 'id' is duplicated on split block. Sep 12, 2024
@litingyes
Copy link

litingyes commented Sep 13, 2024

I think when you define id attr, try setting keepOnSplit: false

@andyj2022
Copy link
Author

The problem is that I define the 'ID' attribute in two types of block elements (paragraph and heading), so keepOnSplit, keepMarks or keepAttributes are not accepted, which only work for "marks" and do not work for blocks.

@litingyes
Copy link

Nodes has the keepOnSplit field in attrs, but I just checked carefully and found that this only works when the cursor is at the end of the node.

After testing, I think you can override enter kepmap by addKeyboardShortcuts to achieve your needs.

source:

const handleEnter = () => this.editor.commands.first(({ commands }) => [

@andyj2022
Copy link
Author

Thank you. I have solved it by capturing the event with 'handleDOMEvents', but it seems to me that the keepOnSplit behavior for attributes is a bug.

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
Status: Triage open
Development

No branches or pull requests

2 participants