Browse Source

add shortcuts and fix naming

Konstantinos Kaloutas 1 năm trước cách đây
mục cha
commit
6e67df9e37

+ 17 - 1
src/main/frontend/modules/shortcut/config.cljs

@@ -150,6 +150,18 @@
    :whiteboard/toggle-grid                  {:binding "t g"
                                              :fn      #(.toggleGrid (.-api ^js (state/active-tldraw-app)))}
 
+   :whiteboard/clone-right                  {:binding (if mac? "ctrl+shift+right" "alt+right")
+                                             :fn      #(.clone (.-api ^js (state/active-tldraw-app)) "right")}
+
+   :whiteboard/clone-left                   {:binding (if mac? "ctrl+shift+left" "alt+left")
+                                             :fn      #(.clone (.-api ^js (state/active-tldraw-app)) "left")}
+
+   :whiteboard/clone-up                     {:binding (if mac? "ctrl+shift+up" "alt+up")
+                                             :fn      #(.clone (.-api ^js (state/active-tldraw-app)) "up")}
+
+   :whiteboard/clone-down                   {:binding (if mac? "ctrl+shift+down" "alt+down")
+                                             :fn      #(.clone (.-api ^js (state/active-tldraw-app)) "down")}
+
    :auto-complete/complete                  {:binding "enter"
                                              :fn      ui-handler/auto-complete-complete}
 
@@ -867,7 +879,11 @@
      :whiteboard/unlock
      :whiteboard/group
      :whiteboard/ungroup
-     :whiteboard/toggle-grid]
+     :whiteboard/toggle-grid
+     :whiteboard/clone-left
+     :whiteboard/clone-right
+     :whiteboard/clone-top
+     :whiteboard/clone-bottom]
 
     :shortcut.category/others
     [:pdf/previous-page

+ 4 - 0
src/resources/dicts/en.edn

@@ -780,6 +780,10 @@
   :whiteboard/group               "Group selection"
   :whiteboard/ungroup             "Ungroup selection"
   :whiteboard/toggle-grid         "Toggle the canvas grid"
+  :whiteboard/clone-right         "Clone right"
+  :whiteboard/clone-left          "Clone left"
+  :whiteboard/clone-up            "Clone up"
+  :whiteboard/clone-down          "Clone down"
   :ui/toggle-brackets             "Toggle whether to display brackets"
   :go/electron-find-in-page       "Find text in page"
   :go/electron-jump-to-the-next   "Jump to the next match to your Find bar search"

+ 3 - 3
tldraw/packages/core/src/lib/TLApi/TLApi.ts

@@ -231,7 +231,7 @@ export class TLApi<S extends TLShape = TLShape, K extends TLEventMap = TLEventMa
     return this.app.createNewLineBinding(source, target)
   }
 
-  cloneTo = (direction: TLCloneDirection) => {
+  clone = (direction: TLCloneDirection) => {
     const shape = this.app.allSelectedShapesArray[0]
     const ShapeClass = this.app.getShapeClass(shape.type)
 
@@ -240,11 +240,11 @@ export class TLApi<S extends TLShape = TLShape, K extends TLEventMap = TLEventMa
     let point = [0, 0]
 
     switch(direction) {
-      case TLCloneDirection.Bottom: {
+      case TLCloneDirection.Down: {
         point = [minX, maxY + spacing]
         break
       }
-      case TLCloneDirection.Top: {
+      case TLCloneDirection.Up: {
         point = [minX, minY - spacing  - height]
         break
       }

+ 2 - 2
tldraw/packages/core/src/types/types.ts

@@ -42,9 +42,9 @@ export enum TLResizeEdge {
 }
 
 export enum TLCloneDirection {
-  Top = 'top',
+  Up = 'up',
   Right = 'right',
-  Bottom = 'bottom',
+  Down = 'down',
   Left = 'left',
 }
 

+ 1 - 1
tldraw/packages/react/src/components/ui/SelectionForeground/SelectionForeground.tsx

@@ -128,7 +128,7 @@ export const SelectionForeground = observer(function SelectionForeground<S exten
             cx={width / 2}
             cy={height + clonePadding}
             size={cloneHandleSize}
-            direction={TLCloneDirection.Bottom}
+            direction={TLCloneDirection.Down}
             isHidden={!showCloneHandles}
           />
           {canResize?.every(r => r) && (

+ 1 - 1
tldraw/packages/react/src/components/ui/SelectionForeground/handles/CloneHandle.tsx

@@ -23,7 +23,7 @@ export const CloneHandle = observer(function CloneHandle({
             <circle
                 aria-label={`${direction} handle`}
                 pointerEvents="all"
-                onPointerDown={(e) => app.api.cloneTo(direction)}
+                onPointerDown={(e) => app.api.clone(direction)}
                 cx={cx}
                 cy={cy}
                 r={size}