Open MaxBrokhman opened 1 year ago
I guess that's because Enter
in the playground creates a new paragraph, still might be nice to only count as 1, if you press Shift+Enter
it inserts a line-break instead of new paragraph and counting works as you'd expect
Just copy pasted the CharacterLimitPlugin
and in my case, not creating new paragraphs on enter it works as expected.
More confusing problem I face, which also happens in the playground, is that having a line-break, so a 2nd paragraph causes it to fail to properly wrap letters in OverflowNodes, it only starts when the counter reaches -3
as shown in the screenshot, trying to debug this, I think the accumulatedLength
and or previousAccumulatedLength
are properly calculated, at least with more than 1 paragraph present. Just crashed my browser looking more into it after restarting 😅
update: Yea can't wrap my head around it currently 😇 still lot's to learn 🤓
The gap between the remaining characters and overflow nodes still happens with enter
Lexical version: 0.11.3
Steps To Reproduce
Link to code example: https://playground.lexical.dev/?isCharLimitUtf8=true
The current behavior
Pressing an enter counts as 2 characters
The expected behavior
Pressing an enter counts as 1 character