|
@@ -548,15 +548,33 @@ export class TldrawApp extends StateManager<TDSnapshot> {
|
548
|
548
|
this.useStore.setState((current) => {
|
549
|
549
|
const { hoveredId, editingId, bindingId, selectedIds } = current.document.pageStates[pageId]
|
550
|
550
|
|
551
|
|
- const next = {
|
|
551
|
+ const keepShapes: Record<string, TDShape> = {}
|
|
552
|
+ const keepBindings: Record<string, TDBinding> = {}
|
|
553
|
+
|
|
554
|
+ if (this.session) {
|
|
555
|
+ selectedIds.forEach((id) => (keepShapes[id] = this.getShape(id)))
|
|
556
|
+ Object.assign(keepBindings, this.bindings) // ROUGH
|
|
557
|
+ }
|
|
558
|
+
|
|
559
|
+ if (editingId) {
|
|
560
|
+ keepShapes[editingId] = this.getShape(editingId)
|
|
561
|
+ }
|
|
562
|
+
|
|
563
|
+ const next: TDSnapshot = {
|
552
|
564
|
...current,
|
553
|
565
|
document: {
|
554
|
566
|
...current.document,
|
555
|
567
|
pages: {
|
556
|
568
|
[pageId]: {
|
557
|
569
|
...current.document.pages[pageId],
|
558
|
|
- shapes,
|
559
|
|
- bindings,
|
|
570
|
+ shapes: {
|
|
571
|
+ ...shapes,
|
|
572
|
+ ...keepShapes,
|
|
573
|
+ },
|
|
574
|
+ bindings: {
|
|
575
|
+ ...bindings,
|
|
576
|
+ ...keepBindings,
|
|
577
|
+ },
|
560
|
578
|
},
|
561
|
579
|
},
|
562
|
580
|
pageStates: {
|
|
@@ -569,11 +587,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
|
569
|
587
|
? undefined
|
570
|
588
|
: hoveredId
|
571
|
589
|
: undefined,
|
572
|
|
- editingId: editingId
|
573
|
|
- ? shapes[editingId] === undefined
|
574
|
|
- ? undefined
|
575
|
|
- : hoveredId
|
576
|
|
- : undefined,
|
|
590
|
+ editingId: editingId,
|
577
|
591
|
bindingId: bindingId
|
578
|
592
|
? bindings[bindingId] === undefined
|
579
|
593
|
? undefined
|