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]: Table resizing #3993

Open
1 of 2 tasks
i0rdan opened this issue Apr 28, 2023 · 0 comments
Open
1 of 2 tasks

[Bug]: Table resizing #3993

i0rdan opened this issue Apr 28, 2023 · 0 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source 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

@i0rdan
Copy link

i0rdan commented Apr 28, 2023

Which packages did you experience the bug in?

extension-table-header, extension-table-cell

What Tiptap version are you using?

latest

What’s the bug you are facing?

Hi, all!

I faced with table resizing issue.
Steps:

  1. Create usual table in the tiptap.
    image
  2. Merge header cells.
    image
  3. Resize table, remember the size!
  4. Use editor.getHTML() for getting pure html string. The output: <table><tbody><tr><th colspan="2" rowspan="1" colwidth="83,100"><p></p></th><th colspan="1" rowspan="1" colwidth="84"><p></p></th></tr><tr><td colspan="1" rowspan="1" colwidth="83"><p></p></td><td colspan="1" rowspan="1" colwidth="100"><p></p></td><td colspan="1" rowspan="1" colwidth="84"><p></p></td></tr><tr><td colspan="1" rowspan="1" colwidth="83"><p></p></td><td colspan="1" rowspan="1" colwidth="100"><p></p></td><td colspan="1" rowspan="1" colwidth="84"><p></p></td></tr></tbody></table>;
  5. Create new editor with previous content.
  6. You could see that table lost size!

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

Table should save size.

Anything to add? (optional)

I finally fixed it by changing parseHTML function in extension-table-header, extension-table-cell. colwidth attribute could has values separated by comma, but in current implementation, only first value is parsed:
https://github.com/ueberdosis/tiptap/blob/develop/packages/extension-table-cell/src/table-cell.ts#L28-L34
https://github.com/ueberdosis/tiptap/blob/develop/packages/extension-table-header/src/table-header.ts#L27-L34

My solution for fixing:

colwidth: {
  default: null,
  parseHTML: element => {
    const colwidth = element.getAttribute('colwidth');
    const value = colwidth
      ? colwidth.split(',').map((w) => parseInt(w, 10))
      : null;
    return value
  },
}

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. 💖
@i0rdan i0rdan added Category: Open Source The issue or pull reuqest is related to the open source 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 28, 2023
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. 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

3 participants