polarvo-layout 1.0.19 → 1.0.21
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 +1 -1
- package/src/components/FastMenu/DesignFastmenu.vue +2 -2
- package/src/components/FastMenu/DisplayFastMenu.vue +2 -2
- package/src/components/FastMenu/LayoutFastMenu.vue +18 -10
- package/src/components/Layout/CanvasContainer.vue +30 -6
- package/src/components/SideBar/ElementSideBar.vue +2 -2
- package/src/components/SideBar/LayoutSettingSideBar.vue +18 -10
- package/src/components/SideBar/LayoutSideBar.vue +19 -8
- package/src/configs/index.js +1 -0
- package/src/core/engines/DisplayEngine.js +72 -64
- package/src/core/engines/FreeDropEngine.js +40 -42
- package/src/core/engines/GridDropEngine.js +33 -43
- package/src/core/engines/HistoryEngine.js +55 -51
- package/src/core/engines/LayoutEngine.js +89 -68
- package/src/core/engines/originals/FreeDropEngine_0402.js +786 -0
- package/src/core/engines/originals/GridDropEngine_0402.js +557 -0
- package/src/core/managers/EngineManager.js +93 -131
- package/src/core/managers/originals/EngineManager_0402.js +826 -0
- package/src/library/DisplayLibrary.js +14 -17
- package/src/library/FreeDropLibrary.js +6 -4
- package/src/library/GridDropLibrary.js +3 -5
- package/src/library/LayoutLibrary.js +45 -48
- package/src/library/originals/DisplayLibrary_0402.js +137 -0
- package/src/library/originals/FreeDropLibrary_0402.js +185 -0
- package/src/library/originals/GridDropLibrary_0402.js +202 -0
- package/src/library/originals/HistoryLibrary_0402.js +98 -0
- package/src/library/originals/LayoutLibrary_0402.js +264 -0
- package/src/utils/index.js +8 -3
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { reactive, readonly } from 'vue';
|
|
2
|
+
|
|
3
|
+
function useGridDrop(api) {
|
|
4
|
+
const state = reactive({
|
|
5
|
+
elements: [],
|
|
6
|
+
activeCell: null,
|
|
7
|
+
activeElement: null,
|
|
8
|
+
activeId: null,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const _subscriptions = [];
|
|
12
|
+
|
|
13
|
+
const syncState = () => {
|
|
14
|
+
try {
|
|
15
|
+
const gridDropState = api.getGridDropState();
|
|
16
|
+
Object.assign(state, gridDropState);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('[GridDropLibrary] 상태 동기화 중 오류 발생:', error);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const _subscribe = (name, handler) => {
|
|
23
|
+
const unsubscribe = api.eventBus.subscribe(name, handler);
|
|
24
|
+
_subscriptions.push(unsubscribe);
|
|
25
|
+
return unsubscribe;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 이벤트 구독
|
|
29
|
+
const _setupSubscriptions = () => {
|
|
30
|
+
// 다시 초기화 되는 경우를 대비
|
|
31
|
+
_subscribe('system:engineInitialized', () => {
|
|
32
|
+
syncState();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_subscribe('system:enginesReset', () => {
|
|
36
|
+
syncState();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
_subscribe('gridDrop:setElements', ({ elements }) => {
|
|
40
|
+
state.elements = elements;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
_subscribe('gridDrop:setActiveElement', ({ action, activeElement, elements }) => {
|
|
44
|
+
// state.elements = elements;
|
|
45
|
+
state.activeElement = activeElement;
|
|
46
|
+
state.activeId = activeElement?.id ?? null;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
_subscribe('gridDrop:requestUpdateActiveElement', ({ element }) => {
|
|
50
|
+
// state.elements = elements;
|
|
51
|
+
const index = state.elements.findIndex((el) => el.id === element.id);
|
|
52
|
+
if (index !== -1) {
|
|
53
|
+
state.elements[index] = element;
|
|
54
|
+
|
|
55
|
+
state.activeElement = element;
|
|
56
|
+
state.activeId = element?.id ?? null;
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
_subscribe('gridDrop:toggleLock', ({ elementId }) => {
|
|
62
|
+
const element = state.elements.find((el) => el.id === elementId);
|
|
63
|
+
if (element) {
|
|
64
|
+
element.isLocked = !element.isLocked;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
_subscribe('gridDrop:requestUpdateData', ({ elements }) => {
|
|
69
|
+
state.elements = elements;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
_subscribe('system:requestUpdateElements', ({ elements }) => {
|
|
73
|
+
state.elements = elements;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
_subscribe('gridDrop:requestUpdateLocalBounds', ({ elementId, position, size }) => {
|
|
77
|
+
const element = state.elements.find((el) => el.id === elementId);
|
|
78
|
+
|
|
79
|
+
if (element) {
|
|
80
|
+
state.elements = state.elements.map((element) =>
|
|
81
|
+
element.id === state.activeId ? { ...state.activeElement, position: { ...position }, size: { ...size } } : element,
|
|
82
|
+
);
|
|
83
|
+
} else {
|
|
84
|
+
state.elements.push(state.activeElement);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
_subscribe('gridDrop:restoredState', ({ elements }) => {
|
|
89
|
+
state.elements = elements;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (api.eventBus) {
|
|
94
|
+
_setupSubscriptions();
|
|
95
|
+
|
|
96
|
+
// 초기화가 이미 완료된 경우 즉시 동기화
|
|
97
|
+
if (api.isReady && api.isReady()) {
|
|
98
|
+
syncState();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 라이브러리 cleanup
|
|
103
|
+
const cleanup = () => {
|
|
104
|
+
_subscriptions.forEach((unsubscribe) => {
|
|
105
|
+
if (typeof unsubscribe === 'function') {
|
|
106
|
+
unsubscribe();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_subscriptions.length = 0;
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// 메서드
|
|
114
|
+
const getElementStyle = (type, cell) => {
|
|
115
|
+
try {
|
|
116
|
+
return api.gridDrop.getElementStyle(type, cell);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.warn('[GridDropLibrary] getElementStyle 호출 중 오류 발생:', error);
|
|
119
|
+
return {};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const setActiveElement = (element, type) => {
|
|
124
|
+
try {
|
|
125
|
+
api.gridDrop.setActiveElement(element, type);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn('[GridDropLibrary] setActiveElement 실행 중 오류 발생:', error);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// const setActiveCell = (type, cell) => {
|
|
132
|
+
// try {
|
|
133
|
+
// api.gridDrop.setActiveCell(type, cell);
|
|
134
|
+
// } catch (error) {
|
|
135
|
+
// console.warn('[GridDropLibrary] setActiveCell 호출 중 오류 발생:', error);
|
|
136
|
+
// }
|
|
137
|
+
// };
|
|
138
|
+
|
|
139
|
+
const addElement = (elName) => {
|
|
140
|
+
try {
|
|
141
|
+
api.gridDrop.addElement(elName);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.warn('[GridDropLibrary] addElement 호출 중 오류 발생:', error);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const toggleLock = () => {
|
|
148
|
+
try {
|
|
149
|
+
api.gridDrop.toggleLock();
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.warn('[GridDropLibrary] toggleLock 호출 중 오류 발생:', error);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const startDrag = (event, id) => {
|
|
156
|
+
try {
|
|
157
|
+
api.gridDrop.startDrag(event, id);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.warn('[GridDropLibrary] startDrag 호출 중 오류 발생:', error);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const handleMouseDown = (event, id) => {
|
|
164
|
+
try {
|
|
165
|
+
api.gridDrop.handleMouseDown(event, id);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.warn('[GridDropLibrary] handleMouseDown 실행 중 오류 발생:', error);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const detectHoverCell = (cell) => {
|
|
172
|
+
try {
|
|
173
|
+
api.gridDrop.detectHoverCell(cell);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.warn('[GridDropLibrary] detectHoverCell 호출 중 오류 발생:', error);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const startResize = (event, id) => {
|
|
180
|
+
try {
|
|
181
|
+
api.gridDrop.startResize(event, id);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.warn('[GridDropLibrary] startResize 호출 중 오류 발생:', error);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
state: readonly(state),
|
|
189
|
+
cleanup,
|
|
190
|
+
getElementStyle,
|
|
191
|
+
setActiveElement,
|
|
192
|
+
// setActiveCell,
|
|
193
|
+
addElement,
|
|
194
|
+
toggleLock,
|
|
195
|
+
startDrag,
|
|
196
|
+
handleMouseDown,
|
|
197
|
+
detectHoverCell,
|
|
198
|
+
startResize,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export default useGridDrop;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { reactive, readonly } from 'vue';
|
|
2
|
+
|
|
3
|
+
function useHistory(api) {
|
|
4
|
+
const state = reactive({
|
|
5
|
+
undoable: false,
|
|
6
|
+
redoable: false,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const _subscriptions = [];
|
|
10
|
+
|
|
11
|
+
const syncState = () => {
|
|
12
|
+
try {
|
|
13
|
+
const historyState = api.getHistoryState();
|
|
14
|
+
Object.assign(state, historyState);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('[HistoryLibrary] 상태 동기화 중 오류 발생:', error);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const _subscribe = (name, handler) => {
|
|
21
|
+
const unsubscribe = api.eventBus.subscribe(name, handler);
|
|
22
|
+
_subscriptions.push(unsubscribe);
|
|
23
|
+
return unsubscribe;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// 이벤트 구독
|
|
27
|
+
const _setupSubscriptions = () => {
|
|
28
|
+
// 다시 초기화 되는 경우를 대비
|
|
29
|
+
_subscribe('system:engineInitialized', () => {
|
|
30
|
+
syncState();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
_subscribe('system:enginesReset', () => {
|
|
34
|
+
syncState();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
_subscribe('history:requestAddHistory', ({ historyState }) => {
|
|
38
|
+
state.undoable = historyState.undoable;
|
|
39
|
+
state.redoable = historyState.redoable;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
_subscribe('history:undoAction', ({ historyState }) => {
|
|
43
|
+
state.undoable = historyState.undoable;
|
|
44
|
+
state.redoable = historyState.redoable;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
_subscribe('history:redoAction', ({ historyState }) => {
|
|
48
|
+
state.undoable = historyState.undoable;
|
|
49
|
+
state.redoable = historyState.redoable;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (api.eventBus) {
|
|
54
|
+
_setupSubscriptions();
|
|
55
|
+
|
|
56
|
+
// 초기화가 이미 완료된 경우 즉시 동기화
|
|
57
|
+
if (api.isReady && api.isReady()) {
|
|
58
|
+
syncState();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 라이브러리 cleanup
|
|
63
|
+
const cleanup = () => {
|
|
64
|
+
_subscriptions.forEach((unsubscribe) => {
|
|
65
|
+
if (typeof unsubscribe === 'function') {
|
|
66
|
+
unsubscribe();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_subscriptions.length = 0;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 메서드
|
|
74
|
+
const undo = () => {
|
|
75
|
+
try {
|
|
76
|
+
api.history.undo();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('[HistoryLibrary] undo 중 오류 발생:', error);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const redo = () => {
|
|
83
|
+
try {
|
|
84
|
+
api.history.redo();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error('[HistoryLibrary] redo 중 오류 발생:', error);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
state: readonly(state),
|
|
92
|
+
cleanup,
|
|
93
|
+
undo,
|
|
94
|
+
redo,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default useHistory;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash-es';
|
|
2
|
+
import { reactive, readonly } from 'vue';
|
|
3
|
+
|
|
4
|
+
function useLayout(api) {
|
|
5
|
+
const state = reactive({
|
|
6
|
+
layoutName: null,
|
|
7
|
+
layoutSource: {},
|
|
8
|
+
|
|
9
|
+
elements: null,
|
|
10
|
+
layoutData: null,
|
|
11
|
+
activeSection: null,
|
|
12
|
+
activeMode: null,
|
|
13
|
+
activeConfig: null,
|
|
14
|
+
|
|
15
|
+
activeData: null,
|
|
16
|
+
|
|
17
|
+
gapSize: null,
|
|
18
|
+
gridNumber: {},
|
|
19
|
+
gridRatio: {},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const _subscriptions = [];
|
|
23
|
+
|
|
24
|
+
const syncState = () => {
|
|
25
|
+
try {
|
|
26
|
+
const layoutState = api.getLayoutState();
|
|
27
|
+
Object.assign(state, layoutState);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('[LayoutLibrary] 상태 동기화 중 오류 발생:', error);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const _subscribe = (name, handler) => {
|
|
34
|
+
const unsubscribe = api.eventBus.subscribe(name, handler);
|
|
35
|
+
_subscriptions.push(unsubscribe);
|
|
36
|
+
return unsubscribe;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// 이벤트 구독
|
|
40
|
+
const _setupSubscriptions = () => {
|
|
41
|
+
// 다시 초기화 되는 경우를 대비
|
|
42
|
+
_subscribe('system:engineInitialized', () => {
|
|
43
|
+
syncState();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
_subscribe('system:enginesReset', () => {
|
|
47
|
+
syncState();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// layoutName 변경 감지 (layoutData, gridNumber, gridRatio가 함께 초기화됨)
|
|
51
|
+
_subscribe('layout:setLayoutName', ({ $screenConfig, $layoutData, $gridNumber, $gridRatio }) => {
|
|
52
|
+
state.layoutName = $screenConfig.layoutName;
|
|
53
|
+
state.layoutData = $layoutData;
|
|
54
|
+
state.gridNumber = $gridNumber;
|
|
55
|
+
state.gridRatio = $gridRatio;
|
|
56
|
+
state.gapSize = $screenConfig.gapSize;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
_subscribe('layout:updateLayoutName', ({ layoutName, layoutData, gridNumber, gridRatio, gapSize }) => {
|
|
60
|
+
state.layoutName = layoutName;
|
|
61
|
+
state.layoutData = layoutData;
|
|
62
|
+
state.gridNumber = gridNumber;
|
|
63
|
+
state.gridRatio = gridRatio;
|
|
64
|
+
if (gapSize) {
|
|
65
|
+
state.gapSize = gapSize;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// gapSize 변경 감지
|
|
70
|
+
_subscribe('layout:updateGapSize', ({ $gapSize }) => {
|
|
71
|
+
state.gapSize = $gapSize;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// gridRatio 변경 감지
|
|
75
|
+
_subscribe('layout:updateRatio', ({ $gridRatio }) => {
|
|
76
|
+
state.gridRatio = $gridRatio;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// activeSection 변경 감지 (activeData가 함께 초기화됨)
|
|
80
|
+
_subscribe('system:updateActiveSection', ({ activeSection, activeData }) => {
|
|
81
|
+
state.activeSection = activeSection;
|
|
82
|
+
state.activeData = activeData;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// elements 변경 감지
|
|
86
|
+
_subscribe('system:requestUpdateActiveElement', ({ elementId, element }) => {
|
|
87
|
+
const index = state.elements.findIndex((x) => x.id === elementId);
|
|
88
|
+
if (index !== -1) {
|
|
89
|
+
state.elements[index] = element; // 업데이트
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
_subscribe('system:setElements', ({ elements }) => {
|
|
94
|
+
state.elements = elements;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
_subscribe('system:updateLayoutData', ({ section, changes, $mode, $config }) => {
|
|
99
|
+
state.layoutData[section] = { ...state.layoutData[section], ...changes };
|
|
100
|
+
state.activeMode = $mode;
|
|
101
|
+
state.activeConfig = $config;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// _subscribe('system:updateActiveSectionConfig', ({ layoutData, activeData }) => {
|
|
105
|
+
// state.layoutData = layoutData;
|
|
106
|
+
// state.activeData = activeData;
|
|
107
|
+
// });
|
|
108
|
+
|
|
109
|
+
_subscribe('system:requestUpdateData', ({ layoutData, activeData, elements }) => {
|
|
110
|
+
state.layoutData = layoutData;
|
|
111
|
+
state.activeData = activeData;
|
|
112
|
+
state.elements = elements;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
_subscribe('system:requestUpdateElements', ({ elements }) => {
|
|
116
|
+
state.elements = elements;
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
_subscribe('system:restoredState', ({ stateData }) => {
|
|
120
|
+
state.elements = stateData.elements;
|
|
121
|
+
state.layoutData = stateData.layoutData;
|
|
122
|
+
state.activeSection = stateData.activeSection;
|
|
123
|
+
|
|
124
|
+
// state.layoutData = cloneDeep(api.layout.getLayoutData());
|
|
125
|
+
// state.activeData = cloneDeep(api.layout.getActiveData());
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
_subscribe('layout:restoredState', ({ stateData }) => {
|
|
129
|
+
state.layoutName = stateData.layoutName;
|
|
130
|
+
state.layoutData = cloneDeep(stateData.layoutData);
|
|
131
|
+
state.gridNumber = { ...stateData.gridNumber };
|
|
132
|
+
state.gridRatio = { ...stateData.gridRatio };
|
|
133
|
+
state.gapSize = stateData.gapSize;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
if (api.eventBus) {
|
|
138
|
+
_setupSubscriptions();
|
|
139
|
+
|
|
140
|
+
// 초기화가 이미 완료된 경우 즉시 동기화
|
|
141
|
+
if (api.isReady && api.isReady()) {
|
|
142
|
+
syncState();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 라이브러리 cleanup
|
|
147
|
+
const cleanup = () => {
|
|
148
|
+
_subscriptions.forEach((unsubscribe) => {
|
|
149
|
+
if (typeof unsubscribe === 'function') {
|
|
150
|
+
unsubscribe();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_subscriptions.length = 0;
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// 메서드
|
|
158
|
+
const getContainerSize = () => {
|
|
159
|
+
try {
|
|
160
|
+
return api.layout.getContainerSize();
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.warn('[FreeDropLibrary] getElementStyle 실행 중 오류 발생:', error);
|
|
163
|
+
return {};
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const setContainerSize = () => {
|
|
168
|
+
try {
|
|
169
|
+
api.layout.setContainerSize();
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error('[LayoutLibrary] setContainerSize 실행 중 오류 발생:', error);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const setLayoutName = (name, userData = null, setting = false) => {
|
|
176
|
+
try {
|
|
177
|
+
api.layout.setLayoutName(name, userData, setting);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('[LayoutLibrary] setLayoutName 실행 중 오류 발생:', error);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const setGapSize = (size) => {
|
|
184
|
+
try {
|
|
185
|
+
api.layout.setGapSize(size);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
console.error('[useLayout] setGapSize 실행 중 오류 발생:', error);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const setRatio = (type, index, ratio) => {
|
|
192
|
+
try {
|
|
193
|
+
api.layout.setRatio(type, index, ratio);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error('[useLayout] setRatio 실행 중 오류 발생:', error);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// const setUserLayoutData = (userData) => {
|
|
200
|
+
// try {
|
|
201
|
+
// api.layout.setUserLayoutData(userData);
|
|
202
|
+
// } catch (error) {
|
|
203
|
+
// console.error('[useLayout] setUserLayoutData 실행 중 오류 발생:', error);
|
|
204
|
+
// }
|
|
205
|
+
// };
|
|
206
|
+
|
|
207
|
+
const setActiveSection = (name) => {
|
|
208
|
+
try {
|
|
209
|
+
api.layout.setActiveSection(name);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
console.error('[useLayout] setActiveSection 실행 중 오류 발생:', error);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const setElements = (elements) => {
|
|
216
|
+
try {
|
|
217
|
+
api.layout.setElements(elements);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
console.error('[useLayout] setElements 실행 중 오류 발생:', error);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const updateActiveElement = (id, changes) => {
|
|
224
|
+
try {
|
|
225
|
+
api.layout.updateActiveElement(id, changes);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error('[useLayout] updateActiveElement 실행 중 오류 발생:', error);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const setSectionMode = (mode) => {
|
|
232
|
+
try {
|
|
233
|
+
api.layout.setSectionMode(mode);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.error('[useLayout] setSectionMode 실행 중 오류 발생:', error);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const setSectionConfig = (type, config) => {
|
|
240
|
+
try {
|
|
241
|
+
api.layout.setSectionConfig(type, config);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
console.error('[useLayout] setSectionConfig 실행 중 오류 발생:', error);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
state: readonly(state),
|
|
249
|
+
cleanup,
|
|
250
|
+
getContainerSize,
|
|
251
|
+
setContainerSize,
|
|
252
|
+
setLayoutName,
|
|
253
|
+
setGapSize,
|
|
254
|
+
setRatio,
|
|
255
|
+
// setUserLayoutData,
|
|
256
|
+
setActiveSection,
|
|
257
|
+
setElements,
|
|
258
|
+
updateActiveElement,
|
|
259
|
+
setSectionMode,
|
|
260
|
+
setSectionConfig,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default useLayout;
|
package/src/utils/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import directives from './directives/index.js';
|
|
2
2
|
import dataConverter from './data-converter.js';
|
|
3
3
|
|
|
4
|
+
const calculateAspectRatio = (aspectRatioString) => {
|
|
5
|
+
const [width, height] = aspectRatioString.split('/').map(Number);
|
|
6
|
+
return width / height;
|
|
7
|
+
};
|
|
4
8
|
const utils = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
directives,
|
|
10
|
+
dataConverter,
|
|
11
|
+
calculateAspectRatio,
|
|
12
|
+
};
|
|
8
13
|
export default utils;
|