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]: Colgroup missing in JSON when using getJSON #5498

Closed
1 task done
liltechnomancer opened this issue Aug 15, 2024 · 5 comments
Closed
1 task done

[Bug]: Colgroup missing in JSON when using getJSON #5498

liltechnomancer opened this issue Aug 15, 2024 · 5 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

@liltechnomancer
Copy link

Affected Packages

extension-table

Version(s)

2.6.3

Bug Description

When using editor.getHTML() there is a colgroup used for resizing the columns. This is not present in the JSON returned from editor.getJson()

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

I would expect there to be some sort of JSON object for colgroups.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@liltechnomancer liltechnomancer 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 Aug 15, 2024
@nperez0111
Copy link
Contributor

The colgroup element is derived from the JSON:

const { colgroup, tableWidth, tableMinWidth } = createColGroup(
node,
this.options.cellMinWidth,
)
const table: DOMOutputSpec = [
'table',
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
style: tableWidth
? `width: ${tableWidth}`
: `min-width: ${tableMinWidth}`,
}),
colgroup,

Can you explain your usecase, why would you need it available in the JSON?

@liltechnomancer
Copy link
Author

Hey thanks so much for the quick reply.

I am using TipTap as an editor for HTML emails via the library Vue Email.

Currently I use a modified version of Gutentap, which is mostly a modified starter kit.
I then take the json and use a recursive function to turn it into Vue components.

Since email supports tables the transformation for them is just h('tag').

It would be ideal to have access to the colgroup info so I can do the same with it.

@nperez0111
Copy link
Contributor

Forgive me for my ignorance here. But my understanding would be that colgroup wouldn't really be necessary for your case since we already set the width on each table cell individually?

I'm just trying to help you at at this point, I don't think that there is any way to get that information into the JSON, it is explicitly tied to table cell widths and there is not a great way to communicate changes across different extensions (it would have to be implemented as it's own node type to actually show in the JSON since that is what the JSON is ultimately trying to represent).

If it is really necessary for your case, then I'm going to have to say that it is on you to implement that. I'd be willing to take a PR if it does not add too much complexity to how tables are implemented but I think that is just not really possible given what it does

@liltechnomancer
Copy link
Author

Thanks for the info, I will look into all the options you listed and make a pr if I think that is accomplishable. The width on the cells alone may be enough. I absolutely love this library thanks so much to you and all the maintainers.

@liltechnomancer
Copy link
Author

If anyone stumbles across this with the same issue, colwidth is an array, so it can't be passed straight to h("td") this is what made me miss it entirely. This can easily be fixed with a real component as the wrapper.

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: Done
Development

No branches or pull requests

2 participants