Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix; Fix context menu pasting supporting lexical format to maintain style #6765

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/lexical-clipboard/src/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface LexicalClipboardData {
'text/html'?: string | undefined;
'application/x-lexical-editor'?: string | undefined;
'text/plain': string;
'web application/x-lexical-editor'?: string | undefined;
}

/**
Expand Down Expand Up @@ -133,8 +134,9 @@ export function $insertDataTransferForRichText(
selection: BaseSelection,
editor: LexicalEditor,
): void {
const lexicalString = dataTransfer.getData('application/x-lexical-editor');

const lexicalString =
dataTransfer.getData('application/x-lexical-editor') ||
dataTransfer.getData('web application/x-lexical-editor');
if (lexicalString) {
try {
const payload = JSON.parse(lexicalString);
Expand Down Expand Up @@ -500,13 +502,15 @@ function $copyToClipboardEvent(
if (clipboardData === null) {
return false;
}

setLexicalClipboardDataTransfer(clipboardData, data);
return true;
}

const clipboardDataFunctions = [
['text/html', $getHtmlContent],
['application/x-lexical-editor', $getLexicalContent],
['web application/x-lexical-editor', $getLexicalContent],
] as const;

/**
Expand Down
Loading