Bug: Inconsistent behavior of `trimTextContentFromAnchor` on paste
Lexical version: 0.7.6
Steps To Reproduce
- Open Lexical Playground with the "Max Length" setting on: https://playground.lexical.dev/?isMaxLength=true
- Clear the editor
- Paste some text longer than 30 character (the max length enforced with
MaxLengthPluginin Lexical Playground) - Clear the editor
- Type any character, then repeat step 3.
At step 3. the pasted text is truncated at the maximum length.
At step 5. no text is pasted. trimTextContentFromAnchor reverts to the previous editor state.
My intuition is that the behavior at step 3. is correct.
Hello, I'm facing the same issue, it looks like there's a special logic to revert state instead of actually perform a trim. And that's definitely not what you expect when calling this method, I'd like my text to trim instead of just not being pasted.

Are there any plans to fix this? Pasted text should trimmed to max length instead of doing nothing.
I opened #9423 to fix this: when a paste goes over the max length, $trimTextContentFromAnchor now keeps the part that fits instead of dropping the whole paste, and never cuts a grapheme in half.
— Ved Thakar