facebook / lexical

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

Bug: useCharacterLimit autolink infinite loop bug #6662

Open redstar08 opened 3 weeks ago

redstar08 commented 3 weeks ago

copy text and paste to Editor, type any link in overflow node, infinite loop (eg.[https://x.com])

useCharacterLimit autolink infinite loop bug
type a link in overflow node
http://x.
image

Lexical version: 0.17.1

Steps To Reproduce

  1. add CharacterLimitPlugin and AutoLinkPlugin or LinkPlugin
  2. type a link in overflow node

Link to code example: https://playground.lexical.dev/?isCharLimit=true

The current behavior

infinite loop in useCharacterLimit -> $wrapOverflowedNodes

The expected behavior

$wrapOverflowedNodes can deal autolink node or link node

Impact of fix

Can I fix it by modify $wrapOverflowedNodes ?

see the comment below

redstar08 commented 3 weeks ago

There is a way to fixed

import {$isAutoLinkNode, $isLinkNode} from '@lexical/link';

modify function $wrapOverflowedNodes

Judge by the $isAutoLinkNode and $isLinkNode to avoid infinite loop

image

Expected effect after modification

image
redstar08 commented 3 weeks ago

Please refer to PR #6668 for discussion