plate icon indicating copy to clipboard operation
plate copied to clipboard

Unable to go to new line on list items

Open th1nkful opened this issue 9 months ago • 5 comments

Description

When hitting enter to go to a new line on UL or OL list items, it clears the line instead of adding a new line.

Does not happen in demos, does happen if i use the template and start from scratch

Steps to Reproduce

  • Install all the latest packages
  • add list items
  • try to hit enter on a list item to go to new line
  • line is cleared instead

Sandbox

I tried to make a sandbox, but they are really out of date

I ended up getting Codesandbox to spin a devbox of a repro

https://codesandbox.io/p/github/th1nkful/plate-issue/main?import=true

repro repo: https://github.com/th1nkful/plate-issue

Expected Behavior

When you hit "Enter" you are taken to a new line with another LI

Environment

  • slate: 0.102.0
  • slate-react: 0.102.0
  • browser: chrome

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

th1nkful avatar May 09 '24 13:05 th1nkful

Not sure if this needs to be updated into a documentation change or something but I found the cause:

In the playground installation guide it has the following:

    createExitBreakPlugin({
      options: {
        rules: [
          {
            hotkey: 'mod+enter',
          },
          {
            hotkey: 'mod+shift+enter',
            before: true,
          },
          {
            hotkey: 'enter',
            query: {
              start: true,
              end: true,
              // allow: KEYS_HEADING,
            },
            relative: true,
            level: 1,
          },
        ],
      },
    }),

However, when you use that, it was resetting the line item. Uncommenting and importing KEYS_HEADING causes this to behave as expected

th1nkful avatar May 10 '24 02:05 th1nkful

@th1nkful I think this issue seems related to https://github.com/udecode/plate/issues/2736

I tried what was mentioned in that thread (moving createListPlugin() to after createResetNodePlugin()) but I was unable to resolve the issue. Curious if it fixes it for you?

devonkcopeland avatar May 16 '24 21:05 devonkcopeland

passing KEYS_HEADING to the allow option in the above code worked for me.

Screenshot 2024-06-25 at 15 18 10

aliosmandev avatar Jun 25 '24 12:06 aliosmandev

It's going to a new line but the bullet point or number doesn't get appended. Have you encountered this issue?

MuhammadBilal1234 avatar Aug 29 '24 07:08 MuhammadBilal1234

With allow: KEYS_HEADING it does not clear the list item anymore, but it does not add a new bullet point, just a new line in the same bullet point. I can do a “Ctrl + enter” which add a new line after the bullet point, but I need to press again on list to add a new bullet point. Which is not very convenient.

If anyone know a solution, it would be amazing.

GuillaumeBordeau avatar Sep 02 '24 12:09 GuillaumeBordeau