Skip to content

Commit

Permalink
bugfix clipboard edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdess committed Jun 4, 2024
1 parent 14ae2ee commit 21e8f1d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/Lexical/plugins/utils/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export function $insertDataTransferForRichText(
const cleanups = [] as Array<any>;

if (lexicalString) {

try {
const payload = JSON.parse(lexicalString);
if (
Expand Down Expand Up @@ -220,6 +221,7 @@ export function $insertDataTransferForRichText(
// Multi-line plain text in rich text mode pasted as separate paragraphs
// instead of single paragraph with linebreaks.
// Webkit-specific: Supports read 'text/uri-list' in clipboard.

const text =
dataTransfer.getData('text/plain') || dataTransfer.getData('text/uri-list');
if (text != null) {
Expand All @@ -235,11 +237,13 @@ export function $insertDataTransferForRichText(
} else if (part === '\t') {
selection.insertNodes([$createTabNode()]);
} else {
selection.insertText(part);
const _part = cleanupHTML(part, cleanups);
selection.insertText(_part);
}
}
} else {
selection.insertRawText(text);
const _text = cleanupHTML(text, cleanups);
selection.insertRawText(_text);
}
}

Expand Down

0 comments on commit 21e8f1d

Please sign in to comment.