浏览代码

fix: copy & paste in whiteboard

Peng Xiao 3 年之前
父节点
当前提交
2ade950ea1

+ 0 - 1
resources/css/common.css

@@ -163,7 +163,6 @@ html:not(.is-native-android) {
 html {
   /* FIXME: rewrite revealjs.css ? */
   height: unset !important;
-  overflow: auto !important;
 }
 
 body {

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

@@ -362,11 +362,11 @@ export class TLApp<
   }
 
   paste = (e?: ClipboardEvent) => {
-    this.notify('paste', {
-      point: this.inputs.currentPoint,
-    })
-    // This callback may be over-written manually, see useSetup.ts in React.
-    return void null
+    if (this.editingShape) {
+      this.notify('paste', {
+        point: this.inputs.currentPoint,
+      })
+    }
   }
 
   dropFiles = (files: FileList, point?: number[]) => {

+ 8 - 4
tldraw/packages/react/src/hooks/useKeyboardEvents.ts

@@ -17,12 +17,16 @@ export function useKeyboardEvents() {
     window.addEventListener('keydown', onKeyDown)
     window.addEventListener('keyup', onKeyUp)
     document.addEventListener('paste', e => {
-      e.preventDefault()
-      app.paste(e)
+      if (!app.editingShape) {
+        e.preventDefault()
+        app.paste(e)
+      }
     })
     document.addEventListener('copy', e => {
-      e.preventDefault()
-      app.copy()
+      if (!app.editingShape) {
+        e.preventDefault()
+        app.copy()
+      }
     })
     return () => {
       window.removeEventListener('keydown', onKeyDown)