From f73759fdd75119fdff113d4ec914d5cc20de6dae Mon Sep 17 00:00:00 2001 From: baseWalker <104012756+baseWalker@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:53:09 +0800 Subject: [PATCH] fix: clone the values set to the editor #369 (#371) --- src/editor/core/draw/Draw.ts | 2 +- src/editor/index.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index 4ccbfd6..a5fd194 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -955,7 +955,7 @@ export class Draw { } public setValue(payload: Partial) { - const { header, main, footer } = payload + const { header, main, footer } = deepClone(payload) if (!header && !main && !footer) return const pageComponentData = [header, main, footer] pageComponentData.forEach(data => { diff --git a/src/editor/index.ts b/src/editor/index.ts index 7b69106..7871a30 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -72,7 +72,7 @@ import { IPageBreak } from './interface/PageBreak' import { LETTER_CLASS } from './dataset/constant/Common' import { INTERNAL_CONTEXT_MENU_KEY } from './dataset/constant/ContextMenu' import { IRange } from './interface/Range' -import { splitText } from './utils' +import { deepClone, splitText } from './utils' export default class Editor { public command: Command @@ -190,6 +190,7 @@ export default class Editor { pageBreak: pageBreakOptions } // 数据处理 + data = deepClone(data) let headerElementList: IElement[] = [] let mainElementList: IElement[] = [] let footerElementList: IElement[] = []