浏览代码

fix bring forward fn

Konstantinos Kaloutas 1 年之前
父节点
当前提交
a5eadd8ce5

+ 4 - 1
packages/tldraw/packages/core/src/lib/TLApi/TLApi.ts

@@ -440,6 +440,8 @@ export class TLApi<S extends TLShape = TLShape, K extends TLEventMap = TLEventMa
   doGroup = (shapes: S[] = this.app.allSelectedShapesArray) => {
     if (this.app.readOnly) return
 
+    this.app.history.pause()
+
     const selectedGroups: S[] = [
       ...shapes.filter(s => s.type === 'group'),
       ...shapes.map(s => this.app.getParentGroup(s)),
@@ -460,8 +462,9 @@ export class TLApi<S extends TLShape = TLShape, K extends TLEventMap = TLEventMa
       this.app.currentPage.addShapes(group)
       this.app.setSelectedShapes([group])
       // the shapes in the group should also be moved to the bottom of the array (to be on top on the canvas)
-      this.app.bringForward(selectedShapes, true)
+      this.app.bringForward(selectedShapes)
     }
+    this.app.history.resume()
     this.app.persist()
   }
 

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

@@ -277,8 +277,8 @@ export class TLApp<
     return this.shapes.find(group => group.props.children?.includes(shape.id))
   }
 
-  bringForward = (shapes: S[] | string[] = this.selectedShapesArray, skipPersist: boolean): this => {
-    if (shapes.length > 0 && !this.readOnly) this.currentPage.bringForward(shapes, skipPersist)
+  bringForward = (shapes: S[] | string[] = this.selectedShapesArray): this => {
+    if (shapes.length > 0 && !this.readOnly) this.currentPage.bringForward(shapes)
     return this
   }
 

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

@@ -136,7 +136,7 @@ export class TLPage<S extends TLShape = TLShape, E extends TLEventMap = TLEventM
     return shapeInstances
   }
 
-  @action bringForward = (shapes: S[] | string[], skipPersist: boolean): this => {
+  @action bringForward = (shapes: S[] | string[]): this => {
     const shapesToMove = this.parseShapesArg(shapes)
     shapesToMove
       .sort((a, b) => this.shapes.indexOf(b) - this.shapes.indexOf(a))
@@ -149,7 +149,7 @@ export class TLPage<S extends TLShape = TLShape, E extends TLEventMap = TLEventM
         this.shapes[index] = this.shapes[index + 1]
         this.shapes[index + 1] = t
       })
-    if (!skipPersist) this.app.persist()
+    this.app.persist()
     return this
   }
 

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

@@ -133,7 +133,7 @@
                                              :fn      #(.sendToBack ^js (state/active-tldraw-app))}
 
    :whiteboard/bring-forward                {:binding "close-square-bracket"
-                                             :fn      #(.bringForward ^js (state/active-tldraw-app) false)}
+                                             :fn      #(.bringForward ^js (state/active-tldraw-app))}
 
    :whiteboard/bring-to-front               {:binding "shift+close-square-bracket"
                                              :fn      #(.bringToFront ^js (state/active-tldraw-app))}