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]: Custom Attributes for table in editor.getHTML() String but not in content component (ProseMirror) #5071

Open
1 of 2 tasks
hjerichen opened this issue Apr 16, 2024 · 0 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

@hjerichen
Copy link

Which packages did you experience the bug in?

core, vue-2, extension-table, ...

What Tiptap version are you using?

2.3.0

What’s the bug you are facing?

I have extended table with custom attributes:

import { Table } from '@tiptap/extension-table'
import { Attributes } from '@tiptap/vue-2'

export const HtmlEditorTableExtension = Table.extend({
  addAttributes (): Attributes {
    /* istanbul ignore next */
    const fromParent = this.parent?.()
    return {
      ...fromParent,
      border: {
        default: null,
        keepOnSplit: true
      },
      cellpadding: {
        default: null,
        keepOnSplit: true
      },
      width: {
        default: null,
        keepOnSplit: true,
        parseHTML: element => element.style.width.replace(/['"]+/g, ''),
        renderHTML: attributes => attributes.width ? { style: `width: ${attributes.width}` } : {}
      }
    }
  }
})

This attributes are present in the HTML content via editor.getHTML() but in the rendered editor content component (ProseMirror) they are not. Therefore the editor is not showing the table correctly.

editor.getHTML():
<table border="1px" cellpadding="1" style="width: 300px; minWidth: 75px">

html in the content component:
<table style="min-width: 75px">

You can argue that border and cellpadding attributes are depreceated (I did that because of compatibility reasons), but what about the style attributes like width and such.

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

The table in the editor content component is rendered correctly (with custom attributes)

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. 💖
@hjerichen hjerichen 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 Apr 16, 2024
@hjerichen hjerichen changed the title [Bug]: Custom Attributes for table in HTML Content but not in ProseMirror Content [Bug]: Custom Attributes for table in editor.getHTML() String but not in content component (ProseMirror) Apr 16, 2024
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

1 participant