You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copying from the enabled editor, paste into the clipboard inspector will result in:
text/plain: A VALUE THAT WILL BE UPPERCASE WHEN COPIED.
text/html: <meta charset='utf-8'><span>A value that will be uppercase when copied.</span>
application/x-lexical-editor:
{"namespace":"MyEditor","nodes":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A value that will be uppercase when copied.","type":"shouting-text","version":1}]}
Copying from the editor with editable set to false will only copy the actual value from within the div box, no reformatting, no custom clipboard behaviour.
text/plain: But this will not be uppercase when copied.
text/html: <meta charset='utf-8'><div id="root" style="color: rgb(0, 0, 0); font-family: Times; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="App" style="font-family: sans-serif; line-height: 2rem;"><div aria-autocomplete="none" contenteditable="false" spellcheck="true" data-lexical-editor="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;"><p class="editor-paragraph ltr" dir="ltr" style="text-align: left; margin: 0px 0px 15px; position: relative;"><span data-lexical-text="true">But this will not be uppercase when copied.</span></p></div></div></div>
The expected behavior
Copying from the editor, regardless of setting, results in the appropriate formatting and custom clipboard behaviour:
text/plain: A VALUE THAT WILL BE UPPERCASE WHEN COPIED.
text/html: <meta charset='utf-8'><span>A value that will be uppercase when copied.</span>
application/x-lexical-editor:
{"namespace":"MyEditor","nodes":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A value that will be uppercase when copied.","type":"shouting-text","version":1}]}
It appears to be that the copy event is only dispatched when editing is enabled. While it probably makes sense that most events are disabled, I'd imagine that copy is a reasonably safe exception to that rule?
The text was updated successfully, but these errors were encountered:
Yea, I think it is a safe exception. Unfortunately there's not a pre-existing pattern for registering some of those events when editable is false, so we'll need to build that path.
As far as I can tell this is fixed, the isEditable condition is lifted to individual events. For example, it will stop a cut or paste but not a copy. #6232
Lexical version: 0.9.1
Steps To Reproduce
As per the codesandbox example below:
getTextContent()
overwritten so you can see plaintext changes.Link to code example:
https://codesandbox.io/s/quizzical-tristan-o459jr?file=/src/App.tsx
The current behavior
Copying from the enabled editor, paste into the clipboard inspector will result in:
Copying from the editor with editable set to false will only copy the actual value from within the div box, no reformatting, no custom clipboard behaviour.
The expected behavior
Copying from the editor, regardless of setting, results in the appropriate formatting and custom clipboard behaviour:
Exploration
According to:
lexical/packages/lexical/src/LexicalEvents.ts
Lines 1161 to 1166 in 970fba2
It appears to be that the copy event is only dispatched when editing is enabled. While it probably makes sense that most events are disabled, I'd imagine that copy is a reasonably safe exception to that rule?
The text was updated successfully, but these errors were encountered: