polarvo-layout 1.0.59 → 1.0.60

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.59",
3
+ "version": "1.0.60",
4
4
  "type": "module",
5
5
  "author": "unigence <unigencelab@gmail.com>",
6
6
  "repository": {
@@ -18,19 +18,11 @@
18
18
  {{ key }}
19
19
  </div>
20
20
  <template v-if="section.mode === 'grid'">
21
- <GridLayout
22
- :id="`grid-${key}`"
23
- :polarvo="polarvo"
24
- :preview="preview"
25
- :sectionKey="key"
26
- :sectionData="section"
27
- :elementIds="section.elementIds"
28
- />
21
+ <GridLayout :polarvo="polarvo" :preview="preview" :sectionKey="key" :sectionData="section" :elementIds="section.elementIds" />
29
22
  </template>
30
23
 
31
24
  <template v-else>
32
25
  <FreeLayout
33
- :id="`free-${key}`"
34
26
  :polarvo="polarvo"
35
27
  :preview="preview"
36
28
  :sectionKey="key"
@@ -156,14 +156,14 @@ class EngineManager {
156
156
  * @param {string} type - 설정 타입 (mode, config)
157
157
  * @param {object} updates - 업데이트할 설정 값 객체
158
158
  */
159
- _updateActiveSectionConfig(type, updates) {
160
- if (!this.state.layoutData || !this.state.activeSection) {
159
+ _updateActiveSectionConfig(type, updates, section = this.state.activeSection) {
160
+ if (!this.state.layoutData || !section) {
161
161
  console.error('[EngineManager] activeData를 업데이트할 수 없습니다.');
162
162
  return;
163
163
  }
164
164
 
165
165
  this.eventBus.emit('system:updateActiveSectionConfig', {
166
- $section: this.state.activeSection,
166
+ $section: section,
167
167
  changes: { type: type, ...updates },
168
168
  timestamp: Date.now(),
169
169
  });
@@ -534,7 +534,8 @@ class EngineManager {
534
534
  }
535
535
 
536
536
  this.state.elements.push(element);
537
- this._updateActiveSectionConfig('elementIds', { elementIds: [...(this.activeData?.elementIds || []), element.id] });
537
+ const targetSectionData = this.state.layoutData?.[element.section];
538
+ this._updateActiveSectionConfig('elementIds', { elementIds: [...(targetSectionData?.elementIds || []), element.id] }, element.section);
538
539
 
539
540
  this.eventBus.emit('system:requestUpdateElement', {
540
541
  action: 'add',
@@ -551,10 +552,12 @@ class EngineManager {
551
552
 
552
553
  // 배치요소 삭제 요청
553
554
  this._subscribe('freeDrop:requestDeleteElement', ({ elementId }) => {
555
+ const target = this.state.elements.find((el) => el.id === elementId);
554
556
  this.state.elements = this.state.elements.filter((el) => el.id !== elementId);
557
+ const targetSectionData = this.state.layoutData?.[target?.section];
555
558
  this._updateActiveSectionConfig('elementIds', {
556
- elementIds: (this.activeData?.elementIds || []).filter((elId) => elId !== elementId),
557
- });
559
+ elementIds: (targetSectionData?.elementIds || []).filter((elId) => elId !== elementId),
560
+ }, target?.section);
558
561
  // this._updateActiveElementIds(this.activeData.elementIds.filter((elId) => elId !== elementId));
559
562
 
560
563
  this.eventBus.emit('system:requestUpdateElement', {
@@ -566,11 +569,7 @@ class EngineManager {
566
569
 
567
570
  this.eventBus.emit('system:historyCheckpoint', {
568
571
  domain: 'manager',
569
- state: {
570
- manager: this.getState() || null,
571
- layout: this.getEngine('layout')?.getState() || null,
572
- display: this.getEngine('display')?.getState() || null,
573
- },
572
+ state: this.getState(),
574
573
  });
575
574
  });
576
575
 
@@ -609,7 +608,8 @@ class EngineManager {
609
608
  }
610
609
 
611
610
  this.state.elements.push(element);
612
- this._updateActiveSectionConfig('elementIds', { elementIds: [...(this.activeData?.elementIds || []), element.id] });
611
+ const targetSectionData = this.state.layoutData?.[element.section];
612
+ this._updateActiveSectionConfig('elementIds', { elementIds: [...(targetSectionData?.elementIds || []), element.id] }, element.section);
613
613
  // this._updateActiveElementIds([...this.activeData.elementIds, element.id]);
614
614
 
615
615
  this.eventBus.emit('system:requestUpdateElement', {
@@ -627,10 +627,12 @@ class EngineManager {
627
627
 
628
628
  // 배치요소 삭제 요청
629
629
  this._subscribe('gridDrop:requestDeleteElement', ({ elementId }) => {
630
+ const target = this.state.elements.find((el) => el.id === elementId);
630
631
  this.state.elements = this.state.elements.filter((el) => el.id !== elementId);
632
+ const targetSectionData = this.state.layoutData?.[target?.section];
631
633
  this._updateActiveSectionConfig('elementIds', {
632
- elementIds: (this.activeData?.elementIds || []).filter((elId) => elId !== elementId),
633
- });
634
+ elementIds: (targetSectionData?.elementIds || []).filter((elId) => elId !== elementId),
635
+ }, target?.section);
634
636
  // this._updateActiveElementIds(this.activeData.elementIds.filter((elId) => elId !== elementId));
635
637
 
636
638
  this.eventBus.emit('system:requestUpdateElement', {
@@ -120,11 +120,11 @@ function useLayout(api) {
120
120
 
121
121
  _subscribe('system:restoredState', ({ domain, state: snapShot }) => {
122
122
  if (domain === 'all'|| domain === 'draft') {
123
- state.elements = snapShot.manager.elements;
123
+ state.elements = cloneDeep(snapShot.manager.elements);
124
124
  // state.layoutData = snapShot.manager.layoutData
125
125
 
126
126
  state.layoutName = snapShot.layout.layoutName;
127
- state.layoutData = snapShot.layout.layoutData;
127
+ state.layoutData = cloneDeep(snapShot.layout.layoutData);
128
128
  state.gridNumber = { ...snapShot.layout.gridNumber };
129
129
  state.gridRatio = {
130
130
  column: [...snapShot.layout.gridRatio.column],
@@ -134,13 +134,13 @@ function useLayout(api) {
134
134
  }
135
135
 
136
136
  if (domain === 'manager') {
137
- state.elements = snapShot.elements;
138
- state.layoutData = snapShot.layoutData;
137
+ state.elements = cloneDeep(snapShot.elements);
138
+ state.layoutData = cloneDeep(snapShot.layoutData);
139
139
  }
140
140
 
141
141
  if (domain === 'layout') {
142
142
  state.layoutName = snapShot.layoutName;
143
- state.layoutData = snapShot.layoutData;
143
+ state.layoutData = cloneDeep(snapShot.layoutData);
144
144
  state.gridNumber = { ...snapShot.gridNumber };
145
145
  state.gridRatio = {
146
146
  column: [...snapShot.gridRatio.column],