plate icon indicating copy to clipboard operation
plate copied to clipboard

createResetNodePlugin breaks createListPlugin

Open Feshchenko opened this issue 1 year ago • 5 comments

Description

After adding createResetNodePlugin with any valid config Backspace not removing list item

Steps to Reproduce

  1. go to sandbox here https://codesandbox.io/p/sandbox/plate-lists-bug-4tz5nx
  2. click any list button
  3. press Backspace
  4. list bullet is present (there is <li> component inside of <div> or <p>)
  5. press Enter and it will remove the <li>

Sandbox

https://codesandbox.io/p/sandbox/plate-lists-bug-4tz5nx

Expected Behavior

  • after these steps list should be removed

Environment

  • plate: latest
  • slate: latest
  • slate-react: latest

Bounty

Click here to add a bounty via Algora.

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar

Feshchenko avatar Nov 09 '23 15:11 Feshchenko

I see what you mean. It looks like one workaround for this issue is to place the list plugin after the reset node plugin.

@zbeyens Maybe this would be a good time to implement those plugin options I mentioned a few weeks ago that document dependencies, incompatibilities and ordering requirements between plugins, and throw warnings at runtime if these aren't met?

12joan avatar Nov 09 '23 15:11 12joan

@12joan Yeah, the workaround is working. But it is super weird that it affects some not related elements. What if I want to add some rules to the ELEMENT_LI, do I need to create an additional createResetNodePlugin? Should I place createBlockquotePlugin before createResetNodePlugin?

Feshchenko avatar Nov 09 '23 15:11 Feshchenko

Multiple instances of the same plugin aren't currently supported. But fortunately, they're not necessary in this case. You can add rules to the reset node plugin regardless of the position in the plugin order of the plugins those rules affect. (In the case of LI, however, the list plugin's own logic may conflict with any rules you try to add.)

I'm not aware of any reason that the relative order of the blockquote and reset node plugins would make a difference, so it should be fine.

12joan avatar Nov 09 '23 16:11 12joan

Moving createResetNodePlugin before createListPlugin doesn't work. Can @12joan explain what causes this issue

Amerr avatar Mar 09 '24 13:03 Amerr

@Amerr Can you create a code sandbox with the minimum plugins to reproduce the issue you're seeing?

12joan avatar Mar 10 '24 14:03 12joan