浏览代码

fix: copy & paste fix again

Peng Xiao 3 年之前
父节点
当前提交
7dcb355ac4

+ 1 - 0
tldraw/demo/vite.config.js

@@ -22,6 +22,7 @@ export default defineConfig({
   ],
   ],
   server: {
   server: {
     port: '3031',
     port: '3031',
+    force: true,
     fs: {
     fs: {
       strict: false,
       strict: false,
     },
     },

+ 2 - 2
tldraw/packages/core/src/lib/TLApp/TLApp.ts

@@ -348,7 +348,7 @@ export class TLApp<
   }
   }
 
 
   copy = () => {
   copy = () => {
-    if (this.selectedShapesArray.length > 0) {
+    if (this.selectedShapesArray.length > 0 && !this.editingShape) {
       const tldrawString = JSON.stringify({
       const tldrawString = JSON.stringify({
         type: 'logseq/whiteboard-shapes',
         type: 'logseq/whiteboard-shapes',
         shapes: this.selectedShapesArray.map(shape => shape.serialized),
         shapes: this.selectedShapesArray.map(shape => shape.serialized),
@@ -362,7 +362,7 @@ export class TLApp<
   }
   }
 
 
   paste = (e?: ClipboardEvent) => {
   paste = (e?: ClipboardEvent) => {
-    if (this.editingShape) {
+    if (!this.editingShape) {
       this.notify('paste', {
       this.notify('paste', {
         point: this.inputs.currentPoint,
         point: this.inputs.currentPoint,
       })
       })

+ 1 - 1
tldraw/packages/core/src/lib/TLPage/TLPage.ts

@@ -64,7 +64,7 @@ export class TLPage<S extends TLShape = TLShape, E extends TLEventMap = TLEventM
       id: this.id,
       id: this.id,
       name: this.name,
       name: this.name,
       // @ts-expect-error maybe later
       // @ts-expect-error maybe later
-      shapes: this.shapes.map(shape => shape.serialized).filter(s => !!s).map(toJS),
+      shapes: this.shapes.map(shape => shape.serialized).filter(s => !!s).map(s => toJS(s)),
       bindings: deepCopy(this.bindings),
       bindings: deepCopy(this.bindings),
       nonce: this.nonce,
       nonce: this.nonce,
     }
     }

+ 1 - 1
tldraw/packages/react/src/components/Canvas/Canvas.tsx

@@ -137,7 +137,7 @@ export const Canvas = observer(function Renderer<S extends TLReactShape>({
                 isSelected={selectedShapesSet.has(shape)}
                 isSelected={selectedShapesSet.has(shape)}
                 isErasing={erasingShapesSet.has(shape)}
                 isErasing={erasingShapesSet.has(shape)}
                 meta={meta}
                 meta={meta}
-                zIndex={1000 + i}
+                zIndex={(selectedShapesSet.has(shape) ? 2000 : 1000) + i}
                 onEditingEnd={onEditingEnd}
                 onEditingEnd={onEditingEnd}
               />
               />
             ))}
             ))}

+ 1 - 1
tldraw/packages/react/src/hooks/useKeyboardEvents.ts

@@ -23,7 +23,7 @@ export function useKeyboardEvents() {
       }
       }
     })
     })
     document.addEventListener('copy', e => {
     document.addEventListener('copy', e => {
-      if (!app.editingShape) {
+      if (!app.editingShape && app.selectedShapes.size > 0) {
         e.preventDefault()
         e.preventDefault()
         app.copy()
         app.copy()
       }
       }