udecode / plate

Rich-text editor with shadcn/ui
https://platejs.org
Other
10.8k stars 664 forks source link

insertNodes api causing uncertain behaviour. #3178

Closed hkkvo closed 1 month ago

hkkvo commented 5 months ago

Description

When custom plugin component is tried to insert using insertNodes Api, editor behaves in uncertain way to key press. In this case when i try to press enter after node insert in to palte editor. I'm getting exception but i try to insert same plugin element using insertEmptyElement Api. I'm not getting exception . Is there any solution to resolve this issue.


   insertNodes<TElement>(
    editor,
    {
      type: key,
      children: [

        {
          type: ELEMENT_TEXTAREA,
          children: [{ text: "Place Holder text" }],
        },
      ],
      ...props,
    },
    { at: path, select: true, nextBlock: true, ...(options as any) }
  );

https://github.com/udecode/plate/assets/62047065/f10e8219-1ef6-423e-92d5-22680b8933e4

insertEmptyElement(editor, ELEMENT_TEXTAREA);

https://github.com/udecode/plate/assets/62047065/27ef7b5d-f696-4906-a801-7aec8a862cc6

Steps to Reproduce

Sandbox

Expected Behavior

Environment

Bounty

Click here to add a bounty via Algora.

Funding

Fund with Polar

hkkvo commented 4 months ago

Any update on this.

12joan commented 4 months ago

@hkkvo Please could you supply a full reproduction under the Sandbox heading in your issue?

hkkvo commented 4 months ago

Thank you for the response.

Things got resolved. Issue was happening because of the createExitBreakPlugin and not using createSoftBreakPlugin along with it. createExitBreakPlugin was interrupting the Enter key stroke and exiting current node block.

hkkvo commented 1 month ago

Issue got resolved