facebook / lexical

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

Bug: use PASTE_COMMAND command lost some style #6720

Open SD-Gaming opened 1 week ago

SD-Gaming commented 1 week ago

use PASTE_COMMAND command lost some style

Lexical version: 0.18.0

Steps To Reproduce

  1. open lexical playground and open use lexical context menu
  2. clean all text, and input any text
  3. select the text, click the font-size plus button, and see the text is larger
  4. copy the larger text, and use the context menu to paste
  5. see the new paste text

The current behavior

The new text is small

The expected behavior

new text is equal to the copied text font size

Impact of fix

It can reproduce every time.

citruscai commented 5 days ago

i would like to take on this issue!! can i please be assigned to it? i will start on tackling it now

citruscai commented 5 days ago

update

realized this could be the main problem in why context menu isn't pasting the formatting. isTrusted is being marked as false. could it be a permission problem? when i do ctrl+v isTrusted is marked as true. think im getting closer to solving the problem image

etrepum commented 5 days ago

It's happening for two reasons, both of these issues can be fixed but fixing either of them would solve this particular issue:

  1. The async clipboard API, used by this paste command, does not support the lexical application/x-lexical-editor format because it's not on the clipboard as a web custom format
  2. Lexical does not properly import the style of the text that it exported when parsing the HTML (it can access the sanitized text/plain and text/html formats on the clipboard and chooses the text/html data)
citruscai commented 5 days ago

It's happening for two reasons, both of these issues can be fixed but fixing either of them would solve this particular issue:

  1. The async clipboard API, used by this paste command, does not support the lexical application/x-lexical-editor format because it's not on the clipboard as a web custom format
  2. Lexical does not properly import the style of the text that it exported when parsing the HTML (it can access the sanitized text/plain and text/html formats on the clipboard and chooses the text/html data)

ok i will try each of these and give you update! ty so much for help