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]: Cannot extend and configure a Table extension #4081

Open
1 of 2 tasks
rezaffm opened this issue May 26, 2023 · 6 comments
Open
1 of 2 tasks

[Bug]: Cannot extend and configure a Table extension #4081

rezaffm opened this issue May 26, 2023 · 6 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

@rezaffm
Copy link

rezaffm commented May 26, 2023

Which packages did you experience the bug in?

table

What Tiptap version are you using?

Latest (stable)

What’s the bug you are facing?

If doing something like

  const CustomTable = Table.extend({
      renderHTML({ HTMLAttributes }) {
          return ['div', { class: 'table-responsive' }, ['table', HTMLAttributes, ['tbody', 0]]];
      },
  });

will not work when doing:

          CustomTable.configure({
             cellMinWidth: 100,
             resizable: true
           }),

However, if works when you just do

  CustomTable

Obviously when setting the extensions of the editor.

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

n/a

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. 💖
@rezaffm rezaffm 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 May 26, 2023
@bdbch bdbch added this to Tiptap Aug 4, 2023
@github-project-automation github-project-automation bot moved this to Triage open in Tiptap Aug 4, 2023
@Mynraw
Copy link

Mynraw commented Feb 8, 2024

any updates on this? i have added alignment feature to the tables but it doesn't work when extending default table with addOptions.

@Nantris
Copy link
Contributor

Nantris commented Feb 8, 2024

Do you get any error?

When we try to both extend and configure an extension (not table) we face this issue: #4704

@Mynraw
Copy link

Mynraw commented Feb 22, 2024

Hi, I wasn't be able to get any errors. Having configure is just override the custom attributes or ignore them somehow. For instance, I wanted to keep resizable option while aligning the table attribute being implemented as well. In this scenario custom attr. didn't work and resizing was working as intended. I had to give up on resizing at the end.

addOptions() {
            return {
                ...this.parent?.(),
                resizable: true,
                allowTableNodeSelection: true,
            }
        },
addAttributes() {
            return {
                align: {
                    parseHTML: (element) => {
                        const tableStyle = element.getAttribute("align");
                        return tableStyle;
                    },
                    renderHTML: (attributes) => {

                        if (attributes.align === null) {
                            return { align: 'center' };
                        }

                        return { align: attributes.align };
                    }
                },

Tiptap version I've been using: 2.1.13

@Nantris
Copy link
Contributor

Nantris commented Feb 22, 2024

@Mynraw I'm not entirely clear on what you're saying, but if I'm reading it correctly it sounds like a limitation (of mixing align with resize) rather than a bug?

@Mynraw
Copy link

Mynraw commented Feb 27, 2024

Hey once again, sorry for the inconvenience. What I meant was I had to extend the table plugin so users could align tables, but when I also added the table's default features, such as resizing cells, the alignment was not working and the styling features were lost (e.g. a table copied from word)

It doesn't matter anymore since I've switched to a different rich text editor package. Thanks anyway.

@Nantris
Copy link
Contributor

Nantris commented Feb 27, 2024

@Mynraw I don't think this is a bug. I think you've overlooked including the default values in your custom renderHTML and parseHTML as well: https://github.com/ueberdosis/tiptap/blob/main/packages/extension-table/src/table.ts#L111-L133

If this resolves your issue, be sure to remember to close it! If not let me know.

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

No branches or pull requests

5 participants