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] @milkdown/plugin-trailing has a bug? If I config shouldAppend => return true, the browser crashes! #1699

Closed
2 tasks done
yswang0927 opened this issue Feb 22, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@yswang0927
Copy link

yswang0927 commented Feb 22, 2025

Initial checklist

  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected packages and versions

v7.6.3

Link to runnable example

No response

Steps to reproduce

When config @milkdown/plugin-trailing :

shouldAppend: (lastNode) => {
      if (!lastNode) return false;
      return true;
}

and then visit milkdown editor, my Chrome(v133) browser crashes.

But use default config, my Chrome browser is ok, why?

// default config
shouldAppend: (lastNode) => {
      if (!lastNode) return false
      if (['heading', 'paragraph'].includes(lastNode.type.name)) return false
      return true
}

Expected behavior

When config shouldAppend: ()=>return true , milkdown editor should be ok, and always append blank node at the end of the document.

Actual behavior

Browser crashes!

Runtime

Chrome

OS

Windows

Build and bundle tools

No response

@yswang0927 yswang0927 added the bug Something isn't working label Feb 22, 2025
@Saul-Mirone
Copy link
Member

It's not a bug. It's how prosemirror work. You shouldn't configure it to return true.

  1. Editor run a update event.
  2. Update event add a node at the end, which will trigger another update event.
  3. Another node added at the end, which will trigger more update events.

I don't know what you're implementing, but you shouldn't configure it to return true.

@Saul-Mirone Saul-Mirone closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2025
@yswang0927
Copy link
Author

yswang0927 commented Feb 22, 2025

It's not a bug. It's how prosemirror work. You shouldn't configure it to return true.

  1. Editor run a update event.
  2. Update event add a node at the end, which will trigger another update event.
  3. Another node added at the end, which will trigger more update events.

I don't know what you're implementing, but you shouldn't configure it to return true.

I want to always automatically append a blank line at the end of the document.

For example: https://milkdown.dev/playground , it doesn't have a blank line at the end, and I have to manually tap a newline when I need to continue typing.

@Saul-Mirone
Copy link
Member

you should return false when last line is an empty paragraph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants