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]: nodeInputRules not functioning correctly #5085

Open
1 of 2 tasks
spencerjsmall opened this issue Apr 20, 2024 · 0 comments
Open
1 of 2 tasks

[Bug]: nodeInputRules not functioning correctly #5085

spencerjsmall opened this issue Apr 20, 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

@spencerjsmall
Copy link

Which packages did you experience the bug in?

core, vue-3

What Tiptap version are you using?

2.3.0

What’s the bug you are facing?

I've created a custom node for my editor with nodeInputRules to match an injected variable pattern:

  addInputRules() {
    return [
      nodeInputRule({
        find: variableRegex,
        type: this.type,
        getAttributes: (match) => {
          console.log('match', match);
          const [fullMatch, stepSlug, variableName] = match;
          return {
            id: fullMatch,
            label: variableName,
          };
        },
      }),
    ];
  },

The matching works as expected, however the node is spliced in at incorrect places, and the matching is often overreactive (it will match one occurrence, I'll keep typing, then try to match the same occurrence, resulting in multiple nodes injected). I tried the fix from #3859 , which solved the first problem of the node being inserted at the incorrect index and span, but the second issue is still present.

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

I expect nodeInputRules to correctly match plaintext patterns and render the custom node in place of that text.

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. 💖
@spencerjsmall spencerjsmall 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 20, 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