polarvo-layout 1.0.35 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polarvo-layout",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "type": "module",
5
5
  "author": "unigence <unigencelab@gmail.com>",
6
6
  "repository": {
@@ -77,6 +77,13 @@ const debouncedUpdate = debounce(() => {
77
77
  // gridRows 업데이트
78
78
  }, 10);
79
79
 
80
+ watch(
81
+ () => `${props.sectionData?.config?.gridColumns}-${props.sectionData?.config?.gridRows}`,
82
+ () => {
83
+ initData();
84
+ },
85
+ );
86
+
80
87
  function setMergedData() {
81
88
  const grid = Array.from({ length: gridRows.value + 1 }, () => Array(gridColumns.value + 1).fill(false));
82
89
  // const filled = elements.value.filter((el) => props.elementIds?.includes(el.id) && el.section === props.sectionKey);
@@ -129,7 +129,7 @@ class FreeDropEngine {
129
129
  });
130
130
 
131
131
  this._subscribe('system:restoredState', ({ domain, state: snapShot }) => {
132
- if (domain === 'all') {
132
+ if (domain === 'all' || domain === 'draft') {
133
133
  this._elements = snapShot.manager.elements || [];
134
134
  this._elementsUpdate = true;
135
135
  this.setActiveElement(null);
@@ -427,7 +427,6 @@ class FreeDropEngine {
427
427
  this._activeElement = element;
428
428
  this._alreadyExist = action === 'add' ? false : true;
429
429
  // this._elementsUpdate = true;
430
- console.log('setActiveElement', this._activeElement?.id, this.freeElements)
431
430
 
432
431
  this.eventBus.emit('freeDrop:setActiveElement', {
433
432
  $alreadyExist: this._alreadyExist,
@@ -109,7 +109,7 @@ class GridDropEngine {
109
109
  });
110
110
 
111
111
  this._subscribe('system:restoredState', ({ domain, state: snapShot }) => {
112
- if (domain === 'all') {
112
+ if (domain === 'all'|| domain === 'draft') {
113
113
  this._elements = snapShot.manager.elements || [];
114
114
  this._elementsUpdate = true;
115
115
 
@@ -72,6 +72,22 @@ class EngineManager {
72
72
 
73
73
  restoreState(domain, state) {
74
74
  switch (domain) {
75
+ case 'draft': {
76
+ // manager
77
+ this.setState(state.manager);
78
+
79
+ // layout
80
+ this.getEngine('layout').setState(state.layout);
81
+ this.state.layoutData = state.layout.layoutData;
82
+
83
+ // display
84
+ this.getEngine('display')?.setState(state.display);
85
+ this._displaySize = state.display.displaySize;
86
+
87
+ this.setActiveSection(state.manager?.activeSection, true);
88
+ break;
89
+ }
90
+
75
91
  // all
76
92
  case 'all': {
77
93
  // manager
@@ -625,6 +641,21 @@ class EngineManager {
625
641
  await this._createEngines();
626
642
  await this._setupEngineConnections();
627
643
  this._initialized = true;
644
+
645
+ // 세션 복원
646
+ const saved = sessionStorage.getItem('polarvo-session');
647
+ if (saved) {
648
+ this.restoreState('draft', JSON.parse(saved));
649
+
650
+ this.eventBus.emit('system:historyCheckpoint', {
651
+ domain: 'draft',
652
+ state: {
653
+ manager: this.getState() || null,
654
+ layout: this.getEngine('layout')?.getState() || null,
655
+ display: this.getEngine('display')?.getState() || null,
656
+ },
657
+ });
658
+ }
628
659
  }
629
660
  }
630
661
 
@@ -701,6 +732,16 @@ class EngineManager {
701
732
  }
702
733
  });
703
734
 
735
+ // 가장 최신 상태를 세션 스토리지에 저장 (새로고침 대비)
736
+ this.eventBus.subscribe('system:historyCheckpoint', () => {
737
+ const snapshot = {
738
+ manager: this.getState(),
739
+ layout: this.getEngine('layout')?.getState() || null,
740
+ display: this.getEngine('display')?.getState() || null,
741
+ };
742
+ sessionStorage.setItem('polarvo-session', JSON.stringify(snapshot));
743
+ });
744
+
704
745
  // 모든 연결 설정 완료 후 초기화 완료 이벤트 발행
705
746
  this.eventBus.emit('system:engineInitialized', {
706
747
  state: this.state,
@@ -61,7 +61,7 @@ function useDisplay(api) {
61
61
  });
62
62
 
63
63
  _subscribe('system:restoredState', ({ domain, state: snapShot }) => {
64
- if (domain === 'all') {
64
+ if (domain === 'all'|| domain === 'draft') {
65
65
  state.displayMode = snapShot.display.displayMode;
66
66
  state.displaySize = { ...snapShot.display.displaySize };
67
67
  }
@@ -117,7 +117,7 @@ function useLayout(api) {
117
117
  });
118
118
 
119
119
  _subscribe('system:restoredState', ({ domain, state: snapShot }) => {
120
- if (domain === 'all') {
120
+ if (domain === 'all'|| domain === 'draft') {
121
121
  state.elements = snapShot.manager.elements;
122
122
  // state.layoutData = snapShot.manager.layoutData
123
123