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

Request: Expose ignoreMutation option in Node Views #1538

Closed
thatsjonsense opened this issue Jul 2, 2021 · 0 comments
Closed

Request: Expose ignoreMutation option in Node Views #1538

thatsjonsense opened this issue Jul 2, 2021 · 0 comments
Assignees
Labels
sponsor 💖 This issue or pull request was created by a Tiptap sponsor Type: Feature The issue or pullrequest is a new feature

Comments

@thatsjonsense
Copy link
Contributor

The problem I am facing
We're facing issues with nesting one Tiptap editor inside of a nodeview in another Tiptap editor. The problem is that when typing in the inner editor, we trigger selection changes on the parent editor. This leads to unnecessary rerenders on the parent views.

Marijn's suggestion was to use ignoreMutation in the nodeView config to block these selection changes.

Right now in NodeView.ts, all selections are being sent through:

    // ProseMirror should handle any selections
    if (mutation.type === 'selection') {
      return false
    }

The solution I would like
The option to send a custom ignoreMutation in Node Views, just like we can send a custom stopEvent.

I believe the change would be as simple as:

    if (typeof this.options.ignoreMutation === 'function') {
      return this.options.ignoreMutation(mutation)
    }

And the ability to pass ignoreMutation in ReactNodeViewRendererOptions.

Alternatives I have considered
We're currently hacking this by using a custom stopEvent and passing view.domObserver.suppressSelectionUpdates(), which seems to run before the mutation observer triggers. But this API is undocumented so we'd prefer to use Marijn's recommended approach.

@thatsjonsense thatsjonsense added Type: Feature The issue or pullrequest is a new feature v2 labels Jul 2, 2021
@hanspagel hanspagel added the sponsor 💖 This issue or pull request was created by a Tiptap sponsor label Jul 21, 2021
andrewlu0 pushed a commit to trybaseplate/tiptap that referenced this issue Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sponsor 💖 This issue or pull request was created by a Tiptap sponsor Type: Feature The issue or pullrequest is a new feature
Projects
None yet
Development

No branches or pull requests

3 participants