diff --git a/.changeset/tidy-weeks-provide.md b/.changeset/tidy-weeks-provide.md new file mode 100644 index 000000000..6d1b269bb --- /dev/null +++ b/.changeset/tidy-weeks-provide.md @@ -0,0 +1,5 @@ +--- +'@plait/core': patch +--- + +clone the duplicated content before inserting to resolve console error diff --git a/packages/core/src/utils/fragment.ts b/packages/core/src/utils/fragment.ts index 0487dd06f..055ef7d99 100644 --- a/packages/core/src/utils/fragment.ts +++ b/packages/core/src/utils/fragment.ts @@ -20,10 +20,12 @@ export const duplicateElements = (board: PlaitBoard, elements?: PlaitElement[]) const selectedElements = elements || getSelectedElements(board); const rectangle = getRectangleByElements(board, selectedElements, false); const clipboardContext = board.buildFragment(null, rectangle, 'copy'); - clipboardContext && + const stringifiedContext = clipboardContext && JSON.stringify(clipboardContext); + const clonedContext = stringifiedContext && JSON.parse(stringifiedContext); + clonedContext && board.insertFragment( { - ...clipboardContext, + ...clonedContext, text: undefined }, [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2]