ソースを参照

limit clone functionality

Konstantinos Kaloutas 1 年間 前
コミット
81eab963e6
1 ファイル変更7 行追加1 行削除
  1. 7 1
      tldraw/packages/core/src/lib/TLApi/TLApi.ts

+ 7 - 1
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'
@@ -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)