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

TableNode extension not working properly #66

Open
richardaum opened this issue Nov 19, 2024 · 0 comments
Open

TableNode extension not working properly #66

richardaum opened this issue Nov 19, 2024 · 0 comments

Comments

@richardaum
Copy link

richardaum commented Nov 19, 2024

Hi!

I'm trying to extend a TableNode by creating a CustomTable following the Lexical way of doing that:

export class CustomTableNode extends TableNode {
  static getType() {
    return 'custom-table-node';
  }
  
  //  ... other methods
}

initialConfig.nodes = [
  // ... other nodes
  CustomTableNode,
  {
    replace: TableNode,
    with: () => new CustomTableNode(),
    withKlass: CustomTableNode,
  },
];

After investigating I found that it doesn't work because the src/components/LexicalTablePlugin.vue uses $nodesOfType(TableNode) to get all TableNodes, but $nodesOfType doesn't work properly for replaced nodes because it uses klass.getType() on the comparison, which doens't work for replaced nodes.

Is there another function we could use to get the nodes from the exact class being provided or a replaced class properly? If yes, can we switch to them?`

Thanks!

Edit (thread from Lexical's discord)

Q: is there another function that could return all nodes of a given type considering the replacements?
A: registerMutationListener with the {skipInitialization: false} option (that should be the default by now, but hasn't changed yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant