fix: shape parent id on duplicate page (#920)
This commit is contained in:
parent
ae4a1b6fbe
commit
49fc0a261e
1 changed files with 5 additions and 3 deletions
|
@ -3,13 +3,15 @@ import type { TldrawApp } from '~state/TldrawApp'
|
||||||
import type { TldrawCommand } from '~types'
|
import type { TldrawCommand } from '~types'
|
||||||
|
|
||||||
export function duplicatePage(app: TldrawApp, pageId: string): TldrawCommand {
|
export function duplicatePage(app: TldrawApp, pageId: string): TldrawCommand {
|
||||||
const newId = Utils.uniqueId()
|
|
||||||
const {
|
const {
|
||||||
currentPageId,
|
currentPageId,
|
||||||
page,
|
|
||||||
pageState: { camera },
|
pageState: { camera },
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
|
const page = app.document.pages[pageId]
|
||||||
|
|
||||||
|
const newId = Utils.uniqueId()
|
||||||
|
|
||||||
const nextPage = {
|
const nextPage = {
|
||||||
...page,
|
...page,
|
||||||
id: newId,
|
id: newId,
|
||||||
|
@ -20,7 +22,7 @@ export function duplicatePage(app: TldrawApp, pageId: string): TldrawCommand {
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
...shape,
|
...shape,
|
||||||
parentId: shape.parentId === pageId ? newId : shape.parentId,
|
parentId: shape.parentId === page.id ? newId : shape.parentId,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue