facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
17.5k stars 1.45k forks source link

Bug: failed to toggle link using TOGGLE_LINK_COMMAND #5963

Closed qaws5503 closed 3 weeks ago

qaws5503 commented 3 weeks ago

This is not working editor.dispatchCommand(TOGGLE_LINK_COMMAND, {url:"https://google.com"}).

Lexical version:

"@lexical/react": "0.14.5",
"lexical": "0.14.5",

Steps To Reproduce

  1. clone the project in here
  2. add link node, and add a new button to toggle the link
  3. open the console and add some dummy text
  4. select the text and click link button in the toolbar
  5. the console will log false, which I think is failed.

Link to code example:

StackBlitz here. https://stackblitz.com/edit/facebook-lexical-dkeq39?file=src%2FApp.tsx,src%2Fplugins%2FToolbarPlugin.tsx

The current behavior

Not toggle link.

The expected behavior

Toggle link.

StyleT commented 3 weeks ago

Hi!

I think you're missing to actually use '@lexical/react/LexicalLinkPlugin' in your example.

StyleT commented 3 weeks ago

Working example: https://stackblitz.com/edit/facebook-lexical-m1f8jq

qaws5503 commented 3 weeks ago

@StyleT It works!! Thank you for your help. This library is very awesome but due to the lack of documentation sometimes will encounter some missing import problem.