Skip to content

Commit

Permalink
limit clone functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc authored and logseq-cldwalker committed Dec 14, 2023
1 parent 6e67df9 commit 81eab96
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tldraw/packages/core/src/lib/TLApi/TLApi.ts
@@ -1,6 +1,6 @@
import Vec from '@tldraw/vec'
import type { TLAsset, TLBinding, TLEventMap } from '../../types'
import { TLCloneDirection, TLTargetType } from '../../types'
import { TLCloneDirection, Geometry } from '../../types'
import { BoundsUtils, isNonNullable, uniqueId } from '../../utils'
import type { TLShape, TLShapeModel } from '../shapes'
import type { TLApp } from '../TLApp'
Expand Down Expand Up @@ -232,6 +232,12 @@ export class TLApi<S extends TLShape = TLShape, K extends TLEventMap = TLEventMa
}

clone = (direction: TLCloneDirection) => {
if (
this.app.readOnly ||
this.app.selectedShapesArray.length !== 1 ||
!Object.values(Geometry).some((geometry: string) => geometry === this.app.selectedShapesArray[0].type)
) return;

const shape = this.app.allSelectedShapesArray[0]
const ShapeClass = this.app.getShapeClass(shape.type)

Expand Down

0 comments on commit 81eab96

Please sign in to comment.