Skip to content

Commit

Permalink
Clean up wonky logic (facebook#3768)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Jan 24, 2023
1 parent 3e8231f commit 1f7804a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/lexical-clipboard/src/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function $getHtmlContent(editor: LexicalEditor): string {
const selection = $getSelection();

if (selection == null) {
throw new Error('Expected valid LexicalSelection');
invariant(false, 'Expected valid LexicalSelection');
}

// If we haven't selected anything
Expand All @@ -68,7 +68,7 @@ export function $getLexicalContent(editor: LexicalEditor): null | string {
const selection = $getSelection();

if (selection == null) {
throw new Error('Expected valid LexicalSelection');
invariant(false, 'Expected valid LexicalSelection');
}

// If we haven't selected anything
Expand Down Expand Up @@ -588,10 +588,10 @@ function $copyToClipboardEvent(
}
event.preventDefault();
const clipboardData = event.clipboardData;
if (clipboardData === null) {
const selection = $getSelection();
if (clipboardData === null || selection === null) {
return false;
}
const selection = $getSelection();
const htmlString = $getHtmlContent(editor);
const lexicalString = $getLexicalContent(editor);
let plainString = '';
Expand Down

0 comments on commit 1f7804a

Please sign in to comment.