Sfoglia il codice sorgente

Restore onPersist (#435)

main
Steve Ruiz 3 anni fa
parent
commit
0039dd2e66
Nessun account collegato all'indirizzo email del committer

+ 1
- 1
packages/tldraw/src/hooks/useKeyboardShortcuts.tsx Vedi File

23
   )
23
   )
24
 
24
 
25
   useHotkeys(
25
   useHotkeys(
26
-    'p,2',
26
+    'd,p,2',
27
     () => {
27
     () => {
28
       if (!canHandleEvent()) return
28
       if (!canHandleEvent()) return
29
       app.selectTool(TDShapeType.Draw)
29
       app.selectTool(TDShapeType.Draw)

+ 1
- 21
packages/tldraw/src/state/TldrawApp.ts Vedi File

473
     if (this.callbacks.onChangePage) {
473
     if (this.callbacks.onChangePage) {
474
       this.broadcastPageChanges()
474
       this.broadcastPageChanges()
475
     }
475
     }
476
+    this.callbacks.onPersist?.(this)
476
   }
477
   }
477
 
478
 
478
   private prevSelectedIds = this.selectedIds
479
   private prevSelectedIds = this.selectedIds
506
     const changedShapes: Record<string, TDShape | undefined> = {}
507
     const changedShapes: Record<string, TDShape | undefined> = {}
507
     const changedBindings: Record<string, TDBinding | undefined> = {}
508
     const changedBindings: Record<string, TDBinding | undefined> = {}
508
 
509
 
509
-    // const visitedIds = new Set<string>()
510
-    // const shapesToVisit = this.shapes
511
-
512
-    // while (shapesToVisit.length > 0) {
513
-    //   const shape = shapesToVisit.pop()
514
-    //   if (!shape) break
515
-    //   visitedIds.add(shape.id)
516
-    //   if (this.prevShapes[shape.id] !== shape) {
517
-    //     changedShapes[shape.id] = shape
518
-
519
-    //     if (shape.parentId !== this.currentPageId) {
520
-    //       shapesToVisit.push(this.page.shapes[shape.parentId])
521
-    //     }
522
-
523
-    //     if (shape.children) {
524
-
525
-    //     }
526
-    //   }
527
-    // }
528
-
529
     this.shapes.forEach((shape) => {
510
     this.shapes.forEach((shape) => {
530
       visited.add(shape.id)
511
       visited.add(shape.id)
531
       if (this.prevShapes[shape.id] !== shape) {
512
       if (this.prevShapes[shape.id] !== shape) {
558
 
539
 
559
     this.justSent = true
540
     this.justSent = true
560
     this.callbacks.onChangePage?.(this, changedShapes, changedBindings)
541
     this.callbacks.onChangePage?.(this, changedShapes, changedBindings)
561
-    this.callbacks.onPersist?.(this)
562
     this.prevShapes = this.page.shapes
542
     this.prevShapes = this.page.shapes
563
     this.prevBindings = this.page.bindings
543
     this.prevBindings = this.page.bindings
564
   }
544
   }

Loading…
Annulla
Salva