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

Fix issue that paste will remove cache #2900

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export function cloneModelForPaste(model: ReadonlyContentModelDocument) {
/**
* @internal
*/
export function mergePasteContent(editor: IEditor, eventResult: BeforePasteEvent) {
export function mergePasteContent(
editor: IEditor,
eventResult: BeforePasteEvent,
isFirstPaste: boolean
) {
const {
fragment,
domToModelOption,
Expand All @@ -48,7 +52,7 @@ export function mergePasteContent(editor: IEditor, eventResult: BeforePasteEvent

editor.formatContentModel(
(model, context) => {
if (clipboardData.modelBeforePaste) {
if (!isFirstPaste && clipboardData.modelBeforePaste) {
const clonedModel = cloneModelForPaste(clipboardData.modelBeforePaste);
model.blocks = clonedModel.blocks;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ export function paste(
editor.focus();

const trustedHTMLHandler = editor.getTrustedHTMLHandler();
let isFirstPaste = false;

if (!clipboardData.modelBeforePaste) {
isFirstPaste = true;

editor.formatContentModel(model => {
clipboardData.modelBeforePaste = cloneModelForPaste(model);

Expand Down Expand Up @@ -67,7 +70,7 @@ export function paste(
convertInlineCss(eventResult.fragment, htmlFromClipboard.globalCssRules);

// 6. Merge pasted content into main Content Model
mergePasteContent(editor, eventResult);
mergePasteContent(editor, eventResult, isFirstPaste);
}

function createDOMFromHtml(
Expand Down
Loading
Loading