@tmagic/editor 1.2.0-beta.2 → 1.2.0-beta.20
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/dist/style.css +41 -28
- package/dist/tmagic-editor.mjs +1641 -1257
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +1648 -1259
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +11 -10
- package/src/Editor.vue +48 -30
- package/src/components/CodeDraftEditor.vue +145 -0
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/FunctionEditor.vue +145 -0
- package/src/components/Icon.vue +7 -5
- package/src/components/Layout.vue +149 -0
- package/src/components/ScrollBar.vue +1 -1
- package/src/components/ScrollViewer.vue +10 -1
- package/src/components/ToolButton.vue +30 -15
- package/src/fields/Code.vue +1 -1
- package/src/fields/CodeLink.vue +1 -1
- package/src/fields/CodeSelect.vue +89 -110
- package/src/fields/UISelect.vue +9 -8
- package/src/index.ts +1 -0
- package/src/layouts/AddPageBox.vue +3 -2
- package/src/layouts/CodeEditor.vue +2 -3
- package/src/layouts/Framework.vue +62 -40
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +11 -13
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
- package/src/layouts/sidebar/LayerMenu.vue +9 -7
- package/src/layouts/sidebar/LayerPanel.vue +277 -177
- package/src/layouts/sidebar/Sidebar.vue +113 -27
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +34 -85
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +55 -89
- package/src/layouts/workspace/Breadcrumb.vue +32 -0
- package/src/layouts/workspace/PageBar.vue +12 -11
- package/src/layouts/workspace/PageBarScrollContainer.vue +1 -1
- package/src/layouts/workspace/Stage.vue +26 -9
- package/src/layouts/workspace/ViewerMenu.vue +11 -9
- package/src/layouts/workspace/Workspace.vue +10 -3
- package/src/services/BaseService.ts +1 -1
- package/src/services/codeBlock.ts +118 -125
- package/src/services/editor.ts +35 -16
- package/src/services/history.ts +4 -14
- package/src/services/props.ts +1 -1
- package/src/theme/breadcrumb.scss +6 -0
- package/src/theme/code-block.scss +30 -21
- package/src/theme/component-list-panel.scss +3 -7
- package/src/theme/layer-panel.scss +7 -2
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +76 -50
- package/src/utils/editor.ts +9 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/props.ts +2 -2
- package/src/utils/scroll-viewer.ts +18 -2
- package/src/utils/stage.ts +9 -2
- package/types/Editor.vue.d.ts +42 -29
- package/types/components/CodeDraftEditor.vue.d.ts +148 -0
- package/types/components/ContentMenu.vue.d.ts +1 -3
- package/types/components/FunctionEditor.vue.d.ts +120 -0
- package/types/components/Icon.vue.d.ts +1 -3
- package/types/{layouts → components}/Layout.vue.d.ts +12 -1
- package/types/components/ScrollBar.vue.d.ts +1 -3
- package/types/components/ScrollViewer.vue.d.ts +45 -1
- package/types/components/ToolButton.vue.d.ts +1 -3
- package/types/fields/Code.vue.d.ts +1 -3
- package/types/fields/CodeLink.vue.d.ts +1 -3
- package/types/fields/CodeSelect.vue.d.ts +10 -12
- package/types/fields/UISelect.vue.d.ts +1 -3
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +1 -3
- package/types/layouts/CodeEditor.vue.d.ts +6 -15
- package/types/layouts/NavMenu.vue.d.ts +1 -3
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +25 -9
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -886
- package/types/layouts/sidebar/Sidebar.vue.d.ts +10 -5
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +1 -1
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +6 -5
- package/types/layouts/{sidebar/TabPane.vue.d.ts → workspace/Breadcrumb.vue.d.ts} +5 -43
- package/types/layouts/workspace/Stage.vue.d.ts +25 -8
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/BaseService.d.ts +1 -1
- package/types/services/codeBlock.d.ts +56 -36
- package/types/services/editor.d.ts +4 -6
- package/types/services/history.d.ts +4 -14
- package/types/services/props.d.ts +2 -2
- package/types/services/ui.d.ts +1 -1
- package/types/type.d.ts +64 -48
- package/types/utils/editor.d.ts +1 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/props.d.ts +1 -1
- package/types/utils/scroll-viewer.d.ts +5 -0
- package/src/layouts/Layout.vue +0 -100
- package/src/layouts/sidebar/TabPane.vue +0 -116
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, createElementBlock, createVNode, ref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, renderSlot, Fragment, createElementVNode, normalizeClass, resolveDynamicComponent, toRaw, createSlots, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, watchEffect, provide, withDirectives, Teleport, vShow, nextTick, toHandlers } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { isEmpty, map, throttle, pick, omit, keys, cloneDeep, forIn, mergeWith, uniq, isObject } from 'lodash-es';
|
|
4
|
+
import { createValues, MForm } from '@tmagic/form';
|
|
5
|
+
import { HookType, NodeType } from '@tmagic/schema';
|
|
6
|
+
import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, CopyDocument, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
|
|
7
|
+
import { TMagicButton, TMagicTooltip, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, tMagicMessageBox, TMagicCard, TMagicInput, TMagicDialog, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
|
|
6
8
|
import * as monaco from 'monaco-editor';
|
|
7
|
-
import StageCore, { GuidesType, getOffset, calcValueByFontsize,
|
|
8
|
-
import
|
|
9
|
-
import { isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName } from '@tmagic/utils';
|
|
9
|
+
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
10
|
+
import Gesto from 'gesto';
|
|
11
|
+
import { isPop, getNodePath, isNumber, isPage, toLine, datetimeFormatter, removeClassNameByClassName } from '@tmagic/utils';
|
|
10
12
|
import { EventEmitter } from 'events';
|
|
11
13
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
12
|
-
import Gesto from 'gesto';
|
|
13
14
|
import KeyController from 'keycon';
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
const __default__$t = defineComponent({
|
|
17
|
+
name: "MEditorCode"
|
|
18
|
+
});
|
|
19
|
+
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
20
|
+
...__default__$t,
|
|
17
21
|
props: {
|
|
18
22
|
model: null,
|
|
19
23
|
name: null,
|
|
@@ -42,8 +46,11 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
42
46
|
}
|
|
43
47
|
});
|
|
44
48
|
|
|
45
|
-
const
|
|
46
|
-
|
|
49
|
+
const __default__$s = defineComponent({
|
|
50
|
+
name: "MEditorCodeLink"
|
|
51
|
+
});
|
|
52
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
53
|
+
...__default__$s,
|
|
47
54
|
props: {
|
|
48
55
|
config: null,
|
|
49
56
|
model: null,
|
|
@@ -112,57 +119,12 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
112
119
|
}
|
|
113
120
|
});
|
|
114
121
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
122
|
-
LayerOffset2["TOP"] = "top";
|
|
123
|
-
LayerOffset2["BOTTOM"] = "bottom";
|
|
124
|
-
return LayerOffset2;
|
|
125
|
-
})(LayerOffset || {});
|
|
126
|
-
var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
127
|
-
Layout2["FLEX"] = "flex";
|
|
128
|
-
Layout2["FIXED"] = "fixed";
|
|
129
|
-
Layout2["RELATIVE"] = "relative";
|
|
130
|
-
Layout2["ABSOLUTE"] = "absolute";
|
|
131
|
-
return Layout2;
|
|
132
|
-
})(Layout || {});
|
|
133
|
-
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
134
|
-
Keys2["ESCAPE"] = "Space";
|
|
135
|
-
return Keys2;
|
|
136
|
-
})(Keys || {});
|
|
137
|
-
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
138
|
-
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
139
|
-
var CodeEditorMode = /* @__PURE__ */ ((CodeEditorMode2) => {
|
|
140
|
-
CodeEditorMode2["LIST"] = "list";
|
|
141
|
-
CodeEditorMode2["EDITOR"] = "editor";
|
|
142
|
-
return CodeEditorMode2;
|
|
143
|
-
})(CodeEditorMode || {});
|
|
144
|
-
var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
|
|
145
|
-
CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
|
|
146
|
-
CodeDeleteErrorType2["BIND"] = "bind";
|
|
147
|
-
return CodeDeleteErrorType2;
|
|
148
|
-
})(CodeDeleteErrorType || {});
|
|
149
|
-
var CodeSelectOp = /* @__PURE__ */ ((CodeSelectOp2) => {
|
|
150
|
-
CodeSelectOp2["ADD"] = "add";
|
|
151
|
-
CodeSelectOp2["DELETE"] = "delete";
|
|
152
|
-
CodeSelectOp2["CHANGE"] = "change";
|
|
153
|
-
return CodeSelectOp2;
|
|
154
|
-
})(CodeSelectOp || {});
|
|
155
|
-
|
|
156
|
-
const _hoisted_1$d = { class: "tool-bar" };
|
|
157
|
-
const _hoisted_2$6 = /* @__PURE__ */ createElementVNode("path", {
|
|
158
|
-
fill: "currentColor",
|
|
159
|
-
d: "m23 12l-7.071 7.071l-1.414-1.414L20.172 12l-5.657-5.657l1.414-1.414L23 12zM3.828 12l5.657 5.657l-1.414 1.414L1 12l7.071-7.071l1.414 1.414L3.828 12z"
|
|
160
|
-
}, null, -1);
|
|
161
|
-
const _hoisted_3$3 = [
|
|
162
|
-
_hoisted_2$6
|
|
163
|
-
];
|
|
164
|
-
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
165
|
-
__name: "CodeSelect",
|
|
122
|
+
const _hoisted_1$g = { class: "m-fields-code-select" };
|
|
123
|
+
const __default__$r = defineComponent({
|
|
124
|
+
name: "MEditorCodeSelect"
|
|
125
|
+
});
|
|
126
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
127
|
+
...__default__$r,
|
|
166
128
|
props: {
|
|
167
129
|
config: null,
|
|
168
130
|
model: null,
|
|
@@ -174,125 +136,107 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
174
136
|
setup(__props, { emit }) {
|
|
175
137
|
const props = __props;
|
|
176
138
|
const services = inject("services");
|
|
177
|
-
const
|
|
139
|
+
const mForm = inject("mForm");
|
|
140
|
+
const codeDsl = computed(() => services?.codeBlockService.getCodeDslSync());
|
|
141
|
+
const tableConfig = computed(() => {
|
|
178
142
|
const defaultConfig = {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
143
|
+
dropSort: true,
|
|
144
|
+
enableFullscreen: false,
|
|
145
|
+
border: true,
|
|
146
|
+
items: [
|
|
147
|
+
{
|
|
148
|
+
type: "select",
|
|
149
|
+
label: "\u4EE3\u7801\u5757",
|
|
150
|
+
name: "codeId",
|
|
151
|
+
width: "200px",
|
|
152
|
+
options: () => {
|
|
153
|
+
if (codeDsl.value) {
|
|
154
|
+
return map(codeDsl.value, (value, key) => ({
|
|
155
|
+
text: `${value.name}\uFF08${key}\uFF09`,
|
|
156
|
+
label: `${value.name}\uFF08${key}\uFF09`,
|
|
157
|
+
value: key
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
return [];
|
|
161
|
+
},
|
|
162
|
+
onChange: (formState, codeId, { model }) => {
|
|
163
|
+
model.params = {};
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "params",
|
|
168
|
+
label: "\u53C2\u6570",
|
|
169
|
+
defaultValue: {},
|
|
170
|
+
itemsFunction: (row) => {
|
|
171
|
+
const paramsConfig = getParamsConfig(row.codeId);
|
|
172
|
+
if (!row.params)
|
|
173
|
+
row.params = {};
|
|
174
|
+
if (isEmpty(row.params)) {
|
|
175
|
+
createValues(mForm, paramsConfig, {}, row.params);
|
|
176
|
+
}
|
|
177
|
+
return paramsConfig;
|
|
178
|
+
}
|
|
188
179
|
}
|
|
189
|
-
|
|
190
|
-
}
|
|
180
|
+
]
|
|
191
181
|
};
|
|
192
182
|
return {
|
|
193
183
|
...defaultConfig,
|
|
194
|
-
...props.config.
|
|
184
|
+
...props.config.tableConfig
|
|
195
185
|
};
|
|
196
186
|
});
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
});
|
|
210
|
-
const changeHandler = async (value) => {
|
|
211
|
-
let codeIds = value;
|
|
212
|
-
if (typeof value === "string") {
|
|
213
|
-
multiple.value = false;
|
|
214
|
-
lastTagSnapshot = [lastTagSnapshot];
|
|
215
|
-
codeIds = value ? [value] : [];
|
|
216
|
-
}
|
|
217
|
-
await setCombineRelation(codeIds);
|
|
218
|
-
emit("change", value);
|
|
219
|
-
};
|
|
220
|
-
const setCombineRelation = async (codeIds) => {
|
|
221
|
-
const { id = "" } = services?.editorService.get("node") || {};
|
|
222
|
-
let opFlag = CodeSelectOp.CHANGE;
|
|
223
|
-
let diffValues = codeIds;
|
|
224
|
-
if (multiple.value) {
|
|
225
|
-
opFlag = codeIds.length < lastTagSnapshot.length ? CodeSelectOp.DELETE : CodeSelectOp.ADD;
|
|
226
|
-
diffValues = xor(codeIds, lastTagSnapshot);
|
|
187
|
+
watch(
|
|
188
|
+
() => props.model[props.name],
|
|
189
|
+
(value) => {
|
|
190
|
+
if (isEmpty(value)) {
|
|
191
|
+
props.model[props.name] = {
|
|
192
|
+
hookType: HookType.CODE,
|
|
193
|
+
hookData: []
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
immediate: true
|
|
227
199
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
};
|
|
232
|
-
const setCombineIds = async (codeIds) => {
|
|
233
|
-
combineIds.value = codeIds;
|
|
234
|
-
await services?.codeBlockService.setCombineIds(codeIds);
|
|
200
|
+
);
|
|
201
|
+
const changeHandler = async () => {
|
|
202
|
+
emit("change", props.model[props.name]);
|
|
235
203
|
};
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
204
|
+
const getParamsConfig = (codeId) => {
|
|
205
|
+
if (!codeDsl.value)
|
|
206
|
+
return [];
|
|
207
|
+
const paramStatements = codeDsl.value[codeId]?.params;
|
|
208
|
+
if (isEmpty(paramStatements))
|
|
209
|
+
return [];
|
|
210
|
+
return paramStatements.map((paramState) => ({
|
|
211
|
+
name: paramState.name,
|
|
212
|
+
text: paramState.name,
|
|
213
|
+
labelWidth: "100px",
|
|
214
|
+
type: "text"
|
|
215
|
+
}));
|
|
244
216
|
};
|
|
245
217
|
return (_ctx, _cache) => {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
model: __props.model,
|
|
258
|
-
prop: __props.prop,
|
|
259
|
-
name: __props.name,
|
|
260
|
-
size: __props.size,
|
|
261
|
-
onChange: changeHandler
|
|
262
|
-
}, null, 8, ["config", "model", "prop", "name", "size"])
|
|
263
|
-
]),
|
|
264
|
-
default: withCtx(() => [
|
|
265
|
-
createElementVNode("div", _hoisted_1$d, [
|
|
266
|
-
createVNode(_component_el_tooltip, {
|
|
267
|
-
class: "tool-item",
|
|
268
|
-
effect: "dark",
|
|
269
|
-
content: "\u67E5\u770B\u4EE3\u7801\u5757",
|
|
270
|
-
placement: "top"
|
|
271
|
-
}, {
|
|
272
|
-
default: withCtx(() => [
|
|
273
|
-
(openBlock(), createElementBlock("svg", {
|
|
274
|
-
onClick: viewHandler,
|
|
275
|
-
preserveAspectRatio: "xMidYMid meet",
|
|
276
|
-
viewBox: "0 0 24 24",
|
|
277
|
-
width: "15px",
|
|
278
|
-
height: "15px",
|
|
279
|
-
"data-v-65a7fb6c": ""
|
|
280
|
-
}, _hoisted_3$3))
|
|
281
|
-
]),
|
|
282
|
-
_: 1
|
|
283
|
-
})
|
|
284
|
-
])
|
|
285
|
-
]),
|
|
286
|
-
_: 1
|
|
287
|
-
})
|
|
218
|
+
const _component_m_form_table = resolveComponent("m-form-table");
|
|
219
|
+
return openBlock(), createElementBlock("div", _hoisted_1$g, [
|
|
220
|
+
createVNode(_component_m_form_table, {
|
|
221
|
+
config: unref(tableConfig),
|
|
222
|
+
model: __props.model[__props.name],
|
|
223
|
+
name: "hookData",
|
|
224
|
+
enableToggleMode: false,
|
|
225
|
+
prop: __props.prop,
|
|
226
|
+
size: __props.size,
|
|
227
|
+
onChange: changeHandler
|
|
228
|
+
}, null, 8, ["config", "model", "prop", "size"])
|
|
288
229
|
]);
|
|
289
230
|
};
|
|
290
231
|
}
|
|
291
232
|
});
|
|
292
233
|
|
|
293
|
-
const _hoisted_1$
|
|
294
|
-
const
|
|
295
|
-
|
|
234
|
+
const _hoisted_1$f = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
235
|
+
const __default__$q = defineComponent({
|
|
236
|
+
name: "MEditorUISelect"
|
|
237
|
+
});
|
|
238
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
239
|
+
...__default__$q,
|
|
296
240
|
props: {
|
|
297
241
|
config: null,
|
|
298
242
|
model: null,
|
|
@@ -342,21 +286,19 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
342
286
|
}
|
|
343
287
|
};
|
|
344
288
|
return (_ctx, _cache) => {
|
|
345
|
-
const _component_el_button = resolveComponent("el-button");
|
|
346
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
347
289
|
return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
|
|
348
290
|
key: 0,
|
|
349
291
|
class: "m-fields-ui-select",
|
|
350
292
|
onClick: cancelHandler
|
|
351
293
|
}, [
|
|
352
|
-
createVNode(
|
|
294
|
+
createVNode(unref(TMagicButton), {
|
|
353
295
|
type: "danger",
|
|
354
296
|
icon: unref(Delete),
|
|
355
297
|
text: "",
|
|
356
298
|
style: { "padding": "0" }
|
|
357
299
|
}, {
|
|
358
300
|
default: withCtx(() => [
|
|
359
|
-
_hoisted_1$
|
|
301
|
+
_hoisted_1$f
|
|
360
302
|
]),
|
|
361
303
|
_: 1
|
|
362
304
|
}, 8, ["icon"])
|
|
@@ -366,12 +308,12 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
366
308
|
onClick: startSelect,
|
|
367
309
|
style: { "display": "flex" }
|
|
368
310
|
}, [
|
|
369
|
-
unref(val) ? (openBlock(), createBlock(
|
|
311
|
+
unref(val) ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
370
312
|
key: 0,
|
|
371
313
|
content: "\u6E05\u9664"
|
|
372
314
|
}, {
|
|
373
315
|
default: withCtx(() => [
|
|
374
|
-
createVNode(
|
|
316
|
+
createVNode(unref(TMagicButton), {
|
|
375
317
|
style: { "padding": "0" },
|
|
376
318
|
type: "danger",
|
|
377
319
|
icon: unref(Close),
|
|
@@ -381,11 +323,11 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
381
323
|
]),
|
|
382
324
|
_: 1
|
|
383
325
|
})) : createCommentVNode("", true),
|
|
384
|
-
createVNode(
|
|
326
|
+
createVNode(unref(TMagicTooltip), {
|
|
385
327
|
content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
386
328
|
}, {
|
|
387
329
|
default: withCtx(() => [
|
|
388
|
-
createVNode(
|
|
330
|
+
createVNode(unref(TMagicButton), {
|
|
389
331
|
text: "",
|
|
390
332
|
style: { "padding": "0", "margin": "0" }
|
|
391
333
|
}, {
|
|
@@ -404,12 +346,15 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
404
346
|
|
|
405
347
|
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
406
348
|
|
|
407
|
-
const
|
|
408
|
-
|
|
349
|
+
const __default__$p = defineComponent({
|
|
350
|
+
name: "MEditorCodeEditor"
|
|
351
|
+
});
|
|
352
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
353
|
+
...__default__$p,
|
|
409
354
|
props: {
|
|
410
355
|
initValues: null,
|
|
411
356
|
modifiedValues: null,
|
|
412
|
-
type:
|
|
357
|
+
type: null,
|
|
413
358
|
language: { default: "javascript" },
|
|
414
359
|
options: { default: () => ({
|
|
415
360
|
tabSize: 2
|
|
@@ -534,6 +479,255 @@ const setConfig = (option) => {
|
|
|
534
479
|
};
|
|
535
480
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
536
481
|
|
|
482
|
+
const __default__$o = defineComponent({
|
|
483
|
+
name: "MEditorResizer"
|
|
484
|
+
});
|
|
485
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
486
|
+
...__default__$o,
|
|
487
|
+
emits: ["change"],
|
|
488
|
+
setup(__props, { emit }) {
|
|
489
|
+
const target = ref();
|
|
490
|
+
let getso;
|
|
491
|
+
onMounted(() => {
|
|
492
|
+
if (!target.value)
|
|
493
|
+
return;
|
|
494
|
+
getso = new Gesto(target.value, {
|
|
495
|
+
container: window,
|
|
496
|
+
pinchOutside: true
|
|
497
|
+
}).on("drag", (e) => {
|
|
498
|
+
if (!target.value)
|
|
499
|
+
return;
|
|
500
|
+
emit("change", e.deltaX);
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
onUnmounted(() => {
|
|
504
|
+
getso?.unset();
|
|
505
|
+
});
|
|
506
|
+
return (_ctx, _cache) => {
|
|
507
|
+
return openBlock(), createElementBlock("span", {
|
|
508
|
+
ref_key: "target",
|
|
509
|
+
ref: target,
|
|
510
|
+
class: "m-editor-resizer"
|
|
511
|
+
}, [
|
|
512
|
+
renderSlot(_ctx.$slots, "default")
|
|
513
|
+
], 512);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
const __default__$n = defineComponent({
|
|
519
|
+
name: "MEditorLayout"
|
|
520
|
+
});
|
|
521
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
522
|
+
...__default__$n,
|
|
523
|
+
props: {
|
|
524
|
+
left: null,
|
|
525
|
+
right: null,
|
|
526
|
+
minLeft: { default: 46 },
|
|
527
|
+
minRight: { default: 1 },
|
|
528
|
+
minCenter: { default: 1 },
|
|
529
|
+
leftClass: null,
|
|
530
|
+
rightClass: null,
|
|
531
|
+
centerClass: null
|
|
532
|
+
},
|
|
533
|
+
emits: ["update:left", "change", "update:right"],
|
|
534
|
+
setup(__props, { emit }) {
|
|
535
|
+
const props = __props;
|
|
536
|
+
const el = ref();
|
|
537
|
+
const hasLeft = computed(() => typeof props.left !== "undefined");
|
|
538
|
+
const hasRight = computed(() => typeof props.left !== "undefined");
|
|
539
|
+
const getCenterWidth = (clientWidth2, left, right) => {
|
|
540
|
+
let center2 = clientWidth2 - left - right;
|
|
541
|
+
if (center2 < props.minCenter) {
|
|
542
|
+
center2 = props.minCenter;
|
|
543
|
+
if (left < right) {
|
|
544
|
+
right = clientWidth2 - left - props.minCenter;
|
|
545
|
+
} else {
|
|
546
|
+
left = clientWidth2 - right - props.minCenter;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
center: center2,
|
|
551
|
+
left,
|
|
552
|
+
right
|
|
553
|
+
};
|
|
554
|
+
};
|
|
555
|
+
let clientWidth = 0;
|
|
556
|
+
const resizerObserver = new ResizeObserver((entries) => {
|
|
557
|
+
for (const { contentRect } of entries) {
|
|
558
|
+
clientWidth = contentRect.width;
|
|
559
|
+
let left = props.left || 0;
|
|
560
|
+
let right = props.right || 0;
|
|
561
|
+
if (left > clientWidth) {
|
|
562
|
+
left = clientWidth / 3;
|
|
563
|
+
}
|
|
564
|
+
if (right > clientWidth) {
|
|
565
|
+
right = clientWidth / 3;
|
|
566
|
+
}
|
|
567
|
+
const columnWidth = getCenterWidth(clientWidth, left, right);
|
|
568
|
+
center.value = columnWidth.center;
|
|
569
|
+
emit("change", {
|
|
570
|
+
left: columnWidth.left,
|
|
571
|
+
center: center.value,
|
|
572
|
+
right: columnWidth.right
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
onMounted(() => {
|
|
577
|
+
if (el.value) {
|
|
578
|
+
resizerObserver.observe(el.value);
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
onUnmounted(() => {
|
|
582
|
+
resizerObserver.disconnect();
|
|
583
|
+
});
|
|
584
|
+
const center = ref(0);
|
|
585
|
+
const changeLeft = (deltaX) => {
|
|
586
|
+
if (typeof props.left === "undefined")
|
|
587
|
+
return;
|
|
588
|
+
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
589
|
+
emit("update:left", left);
|
|
590
|
+
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
591
|
+
left = props.left;
|
|
592
|
+
}
|
|
593
|
+
const columnWidth = getCenterWidth(clientWidth, left, props.right || 0);
|
|
594
|
+
center.value = columnWidth.center;
|
|
595
|
+
emit("change", {
|
|
596
|
+
left: columnWidth.left,
|
|
597
|
+
center: center.value,
|
|
598
|
+
right: columnWidth.right
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
const changeRight = (deltaX) => {
|
|
602
|
+
if (typeof props.right === "undefined")
|
|
603
|
+
return;
|
|
604
|
+
let right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
605
|
+
emit("update:right", right);
|
|
606
|
+
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
607
|
+
right = props.right;
|
|
608
|
+
}
|
|
609
|
+
const columnWidth = getCenterWidth(clientWidth, props.left || 0, right);
|
|
610
|
+
center.value = columnWidth.center;
|
|
611
|
+
emit("change", {
|
|
612
|
+
left: columnWidth.left,
|
|
613
|
+
center: center.value,
|
|
614
|
+
right: columnWidth.right
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
return (_ctx, _cache) => {
|
|
618
|
+
return openBlock(), createElementBlock("div", {
|
|
619
|
+
ref_key: "el",
|
|
620
|
+
ref: el,
|
|
621
|
+
class: "m-editor-layout"
|
|
622
|
+
}, [
|
|
623
|
+
unref(hasLeft) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
624
|
+
createElementVNode("div", {
|
|
625
|
+
class: normalizeClass(["m-editor-layout-left", __props.leftClass]),
|
|
626
|
+
style: normalizeStyle(`width: ${__props.left}px`)
|
|
627
|
+
}, [
|
|
628
|
+
renderSlot(_ctx.$slots, "left")
|
|
629
|
+
], 6),
|
|
630
|
+
createVNode(_sfc_main$p, { onChange: changeLeft })
|
|
631
|
+
], 64)) : createCommentVNode("", true),
|
|
632
|
+
createElementVNode("div", {
|
|
633
|
+
class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
|
|
634
|
+
style: normalizeStyle(`width: ${center.value}px`)
|
|
635
|
+
}, [
|
|
636
|
+
renderSlot(_ctx.$slots, "center")
|
|
637
|
+
], 6),
|
|
638
|
+
unref(hasRight) ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
639
|
+
createVNode(_sfc_main$p, { onChange: changeRight }),
|
|
640
|
+
createElementVNode("div", {
|
|
641
|
+
class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
|
|
642
|
+
style: normalizeStyle(`width: ${__props.right}px`)
|
|
643
|
+
}, [
|
|
644
|
+
renderSlot(_ctx.$slots, "right")
|
|
645
|
+
], 6)
|
|
646
|
+
], 64)) : createCommentVNode("", true)
|
|
647
|
+
], 512);
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
const _hoisted_1$e = ["src"];
|
|
653
|
+
const __default__$m = defineComponent({
|
|
654
|
+
name: "MEditorIcon"
|
|
655
|
+
});
|
|
656
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
657
|
+
...__default__$m,
|
|
658
|
+
props: {
|
|
659
|
+
icon: null
|
|
660
|
+
},
|
|
661
|
+
setup(__props) {
|
|
662
|
+
return (_ctx, _cache) => {
|
|
663
|
+
return !__props.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
664
|
+
key: 0,
|
|
665
|
+
class: "magic-editor-icon"
|
|
666
|
+
}, {
|
|
667
|
+
default: withCtx(() => [
|
|
668
|
+
createVNode(unref(Edit))
|
|
669
|
+
]),
|
|
670
|
+
_: 1
|
|
671
|
+
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
672
|
+
key: 1,
|
|
673
|
+
class: "magic-editor-icon"
|
|
674
|
+
}, {
|
|
675
|
+
default: withCtx(() => [
|
|
676
|
+
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$e)
|
|
677
|
+
]),
|
|
678
|
+
_: 1
|
|
679
|
+
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
680
|
+
key: 2,
|
|
681
|
+
class: normalizeClass(["magic-editor-icon", __props.icon])
|
|
682
|
+
}, null, 2)) : (openBlock(), createBlock(unref(TMagicIcon), {
|
|
683
|
+
key: 3,
|
|
684
|
+
class: "magic-editor-icon"
|
|
685
|
+
}, {
|
|
686
|
+
default: withCtx(() => [
|
|
687
|
+
(openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
|
|
688
|
+
]),
|
|
689
|
+
_: 1
|
|
690
|
+
}));
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
696
|
+
ColumnLayout2["LEFT"] = "left";
|
|
697
|
+
ColumnLayout2["CENTER"] = "center";
|
|
698
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
699
|
+
return ColumnLayout2;
|
|
700
|
+
})(ColumnLayout || {});
|
|
701
|
+
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
702
|
+
LayerOffset2["TOP"] = "top";
|
|
703
|
+
LayerOffset2["BOTTOM"] = "bottom";
|
|
704
|
+
return LayerOffset2;
|
|
705
|
+
})(LayerOffset || {});
|
|
706
|
+
var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
707
|
+
Layout2["FLEX"] = "flex";
|
|
708
|
+
Layout2["FIXED"] = "fixed";
|
|
709
|
+
Layout2["RELATIVE"] = "relative";
|
|
710
|
+
Layout2["ABSOLUTE"] = "absolute";
|
|
711
|
+
return Layout2;
|
|
712
|
+
})(Layout || {});
|
|
713
|
+
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
714
|
+
Keys2["ESCAPE"] = "Space";
|
|
715
|
+
return Keys2;
|
|
716
|
+
})(Keys || {});
|
|
717
|
+
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
718
|
+
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
719
|
+
var CodeEditorMode = /* @__PURE__ */ ((CodeEditorMode2) => {
|
|
720
|
+
CodeEditorMode2["LIST"] = "list";
|
|
721
|
+
CodeEditorMode2["EDITOR"] = "editor";
|
|
722
|
+
return CodeEditorMode2;
|
|
723
|
+
})(CodeEditorMode || {});
|
|
724
|
+
var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
|
|
725
|
+
CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
|
|
726
|
+
CodeDeleteErrorType2["BIND"] = "bind";
|
|
727
|
+
return CodeDeleteErrorType2;
|
|
728
|
+
})(CodeDeleteErrorType || {});
|
|
729
|
+
const CODE_DRAFT_STORAGE_KEY = "magicCodeDraft";
|
|
730
|
+
|
|
537
731
|
const log = (...args) => {
|
|
538
732
|
if (process.env.NODE_ENV === "development") {
|
|
539
733
|
console.log("magic editor: ", ...args);
|
|
@@ -682,7 +876,8 @@ class CodeBlock extends BaseService {
|
|
|
682
876
|
editable: true,
|
|
683
877
|
mode: CodeEditorMode.EDITOR,
|
|
684
878
|
combineIds: [],
|
|
685
|
-
undeletableList: []
|
|
879
|
+
undeletableList: [],
|
|
880
|
+
relations: {}
|
|
686
881
|
});
|
|
687
882
|
constructor() {
|
|
688
883
|
super([
|
|
@@ -700,31 +895,40 @@ class CodeBlock extends BaseService {
|
|
|
700
895
|
"deleteCodeDslByIds"
|
|
701
896
|
]);
|
|
702
897
|
}
|
|
703
|
-
async setCodeDsl(
|
|
704
|
-
this.state.codeDsl =
|
|
898
|
+
async setCodeDsl(codeDsl2) {
|
|
899
|
+
this.state.codeDsl = codeDsl2;
|
|
705
900
|
await editorService.setCodeDsl(this.state.codeDsl);
|
|
706
901
|
info("[code-block]:code-dsl-change", this.state.codeDsl);
|
|
707
902
|
this.emit("code-dsl-change", this.state.codeDsl);
|
|
708
903
|
}
|
|
709
904
|
async getCodeDsl(forceRefresh = false) {
|
|
905
|
+
return this.getCodeDslSync(forceRefresh);
|
|
906
|
+
}
|
|
907
|
+
getCodeDslSync(forceRefresh = false) {
|
|
710
908
|
if (!this.state.codeDsl || forceRefresh) {
|
|
711
|
-
this.state.codeDsl =
|
|
909
|
+
this.state.codeDsl = editorService.getCodeDslSync();
|
|
712
910
|
}
|
|
713
911
|
return this.state.codeDsl;
|
|
714
912
|
}
|
|
715
|
-
async getCodeContentById(
|
|
716
|
-
if (!
|
|
913
|
+
async getCodeContentById(id2) {
|
|
914
|
+
if (!id2)
|
|
717
915
|
return null;
|
|
718
916
|
const totalCodeDsl = await this.getCodeDsl();
|
|
719
917
|
if (!totalCodeDsl)
|
|
720
918
|
return null;
|
|
721
|
-
return totalCodeDsl[
|
|
919
|
+
return totalCodeDsl[id2] ?? null;
|
|
722
920
|
}
|
|
723
921
|
async setCodeDslById(id, codeConfig) {
|
|
724
922
|
let codeDsl = await this.getCodeDsl();
|
|
923
|
+
const codeConfigProcessed = codeConfig;
|
|
924
|
+
if (codeConfig.content) {
|
|
925
|
+
codeConfigProcessed.content = eval(codeConfig.content);
|
|
926
|
+
}
|
|
725
927
|
if (!codeDsl) {
|
|
726
928
|
codeDsl = {
|
|
727
|
-
[id]:
|
|
929
|
+
[id]: {
|
|
930
|
+
...codeConfigProcessed
|
|
931
|
+
}
|
|
728
932
|
};
|
|
729
933
|
} else {
|
|
730
934
|
const existContent = codeDsl[id] || {};
|
|
@@ -732,15 +936,15 @@ class CodeBlock extends BaseService {
|
|
|
732
936
|
...codeDsl,
|
|
733
937
|
[id]: {
|
|
734
938
|
...existContent,
|
|
735
|
-
...
|
|
939
|
+
...codeConfigProcessed
|
|
736
940
|
}
|
|
737
941
|
};
|
|
738
942
|
}
|
|
739
943
|
await this.setCodeDsl(codeDsl);
|
|
740
944
|
}
|
|
741
945
|
async getCodeDslByIds(ids) {
|
|
742
|
-
const
|
|
743
|
-
return pick(
|
|
946
|
+
const codeDsl2 = await this.getCodeDsl();
|
|
947
|
+
return pick(codeDsl2, ids);
|
|
744
948
|
}
|
|
745
949
|
async setCodeEditorShowStatus(status) {
|
|
746
950
|
this.state.isShowCodeEditor = status;
|
|
@@ -748,10 +952,10 @@ class CodeBlock extends BaseService {
|
|
|
748
952
|
getCodeEditorShowStatus() {
|
|
749
953
|
return this.state.isShowCodeEditor;
|
|
750
954
|
}
|
|
751
|
-
setCodeEditorContent(status,
|
|
752
|
-
if (!
|
|
955
|
+
setCodeEditorContent(status, id2) {
|
|
956
|
+
if (!id2)
|
|
753
957
|
return;
|
|
754
|
-
this.setId(
|
|
958
|
+
this.setId(id2);
|
|
755
959
|
this.state.isShowCodeEditor = status;
|
|
756
960
|
}
|
|
757
961
|
async getCurrentDsl() {
|
|
@@ -763,10 +967,10 @@ class CodeBlock extends BaseService {
|
|
|
763
967
|
async setEditStatus(status) {
|
|
764
968
|
this.state.editable = status;
|
|
765
969
|
}
|
|
766
|
-
setId(
|
|
767
|
-
if (!
|
|
970
|
+
setId(id2) {
|
|
971
|
+
if (!id2)
|
|
768
972
|
return;
|
|
769
|
-
this.state.id =
|
|
973
|
+
this.state.id = id2;
|
|
770
974
|
}
|
|
771
975
|
getId() {
|
|
772
976
|
return this.state.id;
|
|
@@ -780,64 +984,20 @@ class CodeBlock extends BaseService {
|
|
|
780
984
|
async setCombineIds(ids) {
|
|
781
985
|
this.state.combineIds = ids;
|
|
782
986
|
}
|
|
783
|
-
getCombineIds() {
|
|
784
|
-
return this.state.combineIds;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
const
|
|
788
|
-
if (!
|
|
789
|
-
return;
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
} catch (e) {
|
|
800
|
-
error(e);
|
|
801
|
-
throw new Error("\u89E3\u7ED1\u4EE3\u7801\u5757\u5931\u8D25");
|
|
802
|
-
}
|
|
803
|
-
} else if (opFlag === CodeSelectOp.ADD) {
|
|
804
|
-
try {
|
|
805
|
-
diffCodeIds.forEach((codeId) => {
|
|
806
|
-
const compsContent = codeDsl[codeId].comps;
|
|
807
|
-
const existHooks = compsContent?.[compId];
|
|
808
|
-
if (isEmpty(existHooks)) {
|
|
809
|
-
codeDsl[codeId].comps = {
|
|
810
|
-
...codeDsl[codeId].comps || {},
|
|
811
|
-
[compId]: [hook]
|
|
812
|
-
};
|
|
813
|
-
} else {
|
|
814
|
-
existHooks?.push(hook);
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
|
-
} catch (e) {
|
|
818
|
-
error(e);
|
|
819
|
-
throw new Error("\u7ED1\u5B9A\u4EE3\u7801\u5757\u5931\u8D25");
|
|
820
|
-
}
|
|
821
|
-
} else if (opFlag === CodeSelectOp.CHANGE) {
|
|
822
|
-
forIn(codeDsl, (codeBlockContent, codeId) => {
|
|
823
|
-
if (codeId === diffCodeIds[0]) {
|
|
824
|
-
codeBlockContent.comps = {
|
|
825
|
-
...codeBlockContent?.comps || {},
|
|
826
|
-
[compId]: [hook]
|
|
827
|
-
};
|
|
828
|
-
} else if (isEmpty(diffCodeIds) || codeId !== diffCodeIds[0]) {
|
|
829
|
-
const compHooks = codeBlockContent?.comps?.[compId];
|
|
830
|
-
if (!compHooks)
|
|
831
|
-
return true;
|
|
832
|
-
const index = compHooks.findIndex((hookName) => hookName === hook);
|
|
833
|
-
if (index !== -1) {
|
|
834
|
-
compHooks.splice(index, 1);
|
|
835
|
-
return false;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
this.setCodeDsl(codeDsl);
|
|
987
|
+
getCombineIds() {
|
|
988
|
+
return this.state.combineIds;
|
|
989
|
+
}
|
|
990
|
+
refreshCombineInfo() {
|
|
991
|
+
const root = editorService.get("root");
|
|
992
|
+
if (!root)
|
|
993
|
+
return null;
|
|
994
|
+
const relations = {};
|
|
995
|
+
this.recurseMNode(root, relations);
|
|
996
|
+
this.state.relations = relations;
|
|
997
|
+
return this.state.relations;
|
|
998
|
+
}
|
|
999
|
+
getCombineInfo() {
|
|
1000
|
+
return this.state.relations;
|
|
841
1001
|
}
|
|
842
1002
|
getUndeletableList() {
|
|
843
1003
|
return this.state.undeletableList;
|
|
@@ -845,6 +1005,15 @@ class CodeBlock extends BaseService {
|
|
|
845
1005
|
async setUndeleteableList(codeIds) {
|
|
846
1006
|
this.state.undeletableList = codeIds;
|
|
847
1007
|
}
|
|
1008
|
+
setCodeDraft(codeId, content) {
|
|
1009
|
+
globalThis.localStorage.setItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`, content);
|
|
1010
|
+
}
|
|
1011
|
+
getCodeDraft(codeId) {
|
|
1012
|
+
return globalThis.localStorage.getItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
|
|
1013
|
+
}
|
|
1014
|
+
removeCodeDraft(codeId) {
|
|
1015
|
+
globalThis.localStorage.removeItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
|
|
1016
|
+
}
|
|
848
1017
|
async deleteCodeDslByIds(codeIds) {
|
|
849
1018
|
const currentDsl = await this.getCodeDsl();
|
|
850
1019
|
const newDsl = omit(currentDsl, codeIds);
|
|
@@ -860,11 +1029,11 @@ class CodeBlock extends BaseService {
|
|
|
860
1029
|
return await this.getUniqueId();
|
|
861
1030
|
}
|
|
862
1031
|
async deleteCompsInRelation(node) {
|
|
863
|
-
const
|
|
864
|
-
if (!
|
|
1032
|
+
const codeDsl2 = cloneDeep(await this.getCodeDsl());
|
|
1033
|
+
if (!codeDsl2)
|
|
865
1034
|
return;
|
|
866
|
-
this.
|
|
867
|
-
this.setCodeDsl(
|
|
1035
|
+
this.refreshRelationDeep(node, codeDsl2);
|
|
1036
|
+
this.setCodeDsl(codeDsl2);
|
|
868
1037
|
}
|
|
869
1038
|
destroy() {
|
|
870
1039
|
this.state.isShowCodeEditor = false;
|
|
@@ -875,16 +1044,39 @@ class CodeBlock extends BaseService {
|
|
|
875
1044
|
this.state.combineIds = [];
|
|
876
1045
|
this.state.undeletableList = [];
|
|
877
1046
|
}
|
|
878
|
-
|
|
1047
|
+
refreshRelationDeep(node, codeDsl2) {
|
|
879
1048
|
if (!node.id)
|
|
880
1049
|
return;
|
|
881
|
-
forIn(
|
|
1050
|
+
forIn(codeDsl2, (codeBlockContent) => {
|
|
882
1051
|
const compsContent = codeBlockContent.comps || {};
|
|
883
1052
|
codeBlockContent.comps = omit(compsContent, node.id);
|
|
884
1053
|
});
|
|
885
1054
|
if (!isEmpty(node.items)) {
|
|
886
1055
|
node.items.forEach((item) => {
|
|
887
|
-
this.
|
|
1056
|
+
this.refreshRelationDeep(item, codeDsl2);
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
recurseMNode(node, relations) {
|
|
1061
|
+
forIn(node, (value, key) => {
|
|
1062
|
+
if (value?.hookType === HookType.CODE && !isEmpty(value.hookData)) {
|
|
1063
|
+
value.hookData.forEach((relationItem) => {
|
|
1064
|
+
if (!relationItem.codeId)
|
|
1065
|
+
return;
|
|
1066
|
+
if (!relations[relationItem.codeId]) {
|
|
1067
|
+
relations[relationItem.codeId] = {};
|
|
1068
|
+
}
|
|
1069
|
+
const codeItem = relations[relationItem.codeId];
|
|
1070
|
+
if (isEmpty(codeItem[node.id])) {
|
|
1071
|
+
codeItem[node.id] = [];
|
|
1072
|
+
}
|
|
1073
|
+
codeItem[node.id].push(key);
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
if (!isEmpty(node.items)) {
|
|
1078
|
+
node.items.forEach((item) => {
|
|
1079
|
+
this.recurseMNode(item, relations);
|
|
888
1080
|
});
|
|
889
1081
|
}
|
|
890
1082
|
}
|
|
@@ -968,6 +1160,7 @@ class History extends BaseService {
|
|
|
968
1160
|
this.state.pageSteps[this.state.pageId] = undoRedo;
|
|
969
1161
|
}
|
|
970
1162
|
this.setCanUndoRedo();
|
|
1163
|
+
this.emit("page-change", this.state.pageSteps[this.state.pageId]);
|
|
971
1164
|
}
|
|
972
1165
|
empty() {
|
|
973
1166
|
this.state.pageId = void 0;
|
|
@@ -1253,6 +1446,10 @@ const fixNodePosition = (config, parent, stage) => {
|
|
|
1253
1446
|
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
1254
1447
|
};
|
|
1255
1448
|
};
|
|
1449
|
+
const serializeConfig = (config) => serialize(config, {
|
|
1450
|
+
space: 2,
|
|
1451
|
+
unsafe: true
|
|
1452
|
+
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1256
1453
|
|
|
1257
1454
|
class Props extends BaseService {
|
|
1258
1455
|
state = reactive({
|
|
@@ -1294,7 +1491,7 @@ class Props extends BaseService {
|
|
|
1294
1491
|
this.setPropsValue(toLine(type), values[type]);
|
|
1295
1492
|
});
|
|
1296
1493
|
}
|
|
1297
|
-
setPropsValue(type, value) {
|
|
1494
|
+
async setPropsValue(type, value) {
|
|
1298
1495
|
this.state.propsValueMap[type] = value;
|
|
1299
1496
|
}
|
|
1300
1497
|
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
@@ -1426,6 +1623,13 @@ const getAddParent = (node) => {
|
|
|
1426
1623
|
}
|
|
1427
1624
|
return parentNode;
|
|
1428
1625
|
};
|
|
1626
|
+
const getDefaultConfig = async (addNode, parentNode) => {
|
|
1627
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1628
|
+
const layout = await editorService.getLayout(toRaw(parentNode), addNode);
|
|
1629
|
+
const newNode = { ...toRaw(await propsService.getPropsValue(type, config)) };
|
|
1630
|
+
newNode.style = getInitPositionStyle(newNode.style, layout);
|
|
1631
|
+
return newNode;
|
|
1632
|
+
};
|
|
1429
1633
|
|
|
1430
1634
|
class Editor$1 extends BaseService {
|
|
1431
1635
|
state = reactive({
|
|
@@ -1455,7 +1659,7 @@ class Editor$1 extends BaseService {
|
|
|
1455
1659
|
"copy",
|
|
1456
1660
|
"paste",
|
|
1457
1661
|
"doPaste",
|
|
1458
|
-
"
|
|
1662
|
+
"doAlignCenter",
|
|
1459
1663
|
"alignCenter",
|
|
1460
1664
|
"moveLayer",
|
|
1461
1665
|
"moveToContainer",
|
|
@@ -1634,6 +1838,9 @@ class Editor$1 extends BaseService {
|
|
|
1634
1838
|
}
|
|
1635
1839
|
const newNodes = await Promise.all(
|
|
1636
1840
|
addNodes.map((node) => {
|
|
1841
|
+
if (isPage(node)) {
|
|
1842
|
+
return this.doAdd(node, this.get("root"));
|
|
1843
|
+
}
|
|
1637
1844
|
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1638
1845
|
if (!parentNode)
|
|
1639
1846
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
@@ -1652,7 +1859,9 @@ class Editor$1 extends BaseService {
|
|
|
1652
1859
|
stage?.select(newNodes[0].id);
|
|
1653
1860
|
}
|
|
1654
1861
|
}
|
|
1655
|
-
|
|
1862
|
+
if (!isPage(newNodes[0])) {
|
|
1863
|
+
this.pushHistoryState();
|
|
1864
|
+
}
|
|
1656
1865
|
this.emit("add", newNodes);
|
|
1657
1866
|
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1658
1867
|
}
|
|
@@ -1694,7 +1903,9 @@ class Editor$1 extends BaseService {
|
|
|
1694
1903
|
async remove(nodeOrNodeList) {
|
|
1695
1904
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1696
1905
|
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1697
|
-
|
|
1906
|
+
if (!isPage(nodes[0])) {
|
|
1907
|
+
this.pushHistoryState();
|
|
1908
|
+
}
|
|
1698
1909
|
this.emit("remove", nodes);
|
|
1699
1910
|
}
|
|
1700
1911
|
async doUpdate(config) {
|
|
@@ -1706,6 +1917,9 @@ class Editor$1 extends BaseService {
|
|
|
1706
1917
|
const node = cloneDeep(toRaw(info.node));
|
|
1707
1918
|
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
|
|
1708
1919
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1920
|
+
if (isObject(srcValue) && Array.isArray(objValue)) {
|
|
1921
|
+
return srcValue;
|
|
1922
|
+
}
|
|
1709
1923
|
if (Array.isArray(srcValue)) {
|
|
1710
1924
|
return srcValue;
|
|
1711
1925
|
}
|
|
@@ -1729,10 +1943,10 @@ class Editor$1 extends BaseService {
|
|
|
1729
1943
|
newConfig = setLayout(newConfig, newLayout);
|
|
1730
1944
|
}
|
|
1731
1945
|
parentNodeItems[index] = newConfig;
|
|
1732
|
-
const nodes = this.get("nodes");
|
|
1946
|
+
const nodes = this.get("nodes") || [];
|
|
1733
1947
|
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1734
1948
|
nodes.splice(targetIndex, 1, newConfig);
|
|
1735
|
-
this.set("nodes", nodes);
|
|
1949
|
+
this.set("nodes", [...nodes]);
|
|
1736
1950
|
this.get("stage")?.update({
|
|
1737
1951
|
config: cloneDeep(newConfig),
|
|
1738
1952
|
parentId: parent.id,
|
|
@@ -1749,6 +1963,7 @@ class Editor$1 extends BaseService {
|
|
|
1749
1963
|
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1750
1964
|
this.pushHistoryState();
|
|
1751
1965
|
this.emit("update", newNodes);
|
|
1966
|
+
codeBlockService.refreshCombineInfo();
|
|
1752
1967
|
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1753
1968
|
}
|
|
1754
1969
|
async sort(id1, id2) {
|
|
@@ -1779,7 +1994,7 @@ class Editor$1 extends BaseService {
|
|
|
1779
1994
|
if (!Array.isArray(config))
|
|
1780
1995
|
return;
|
|
1781
1996
|
const pasteConfigs = await this.doPaste(config, position);
|
|
1782
|
-
return this.add(pasteConfigs);
|
|
1997
|
+
return this.add(pasteConfigs, this.get("parent"));
|
|
1783
1998
|
}
|
|
1784
1999
|
async doPaste(config, position = {}) {
|
|
1785
2000
|
const pasteConfigs = await beforePaste(position, cloneDeep(config));
|
|
@@ -1814,7 +2029,11 @@ class Editor$1 extends BaseService {
|
|
|
1814
2029
|
const stage = this.get("stage");
|
|
1815
2030
|
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1816
2031
|
const newNode = await this.update(newNodes);
|
|
1817
|
-
|
|
2032
|
+
if (newNodes.length > 1) {
|
|
2033
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
2034
|
+
} else {
|
|
2035
|
+
await stage?.select(newNodes[0].id);
|
|
2036
|
+
}
|
|
1818
2037
|
return newNode;
|
|
1819
2038
|
}
|
|
1820
2039
|
async moveLayer(offset) {
|
|
@@ -1921,6 +2140,12 @@ class Editor$1 extends BaseService {
|
|
|
1921
2140
|
return null;
|
|
1922
2141
|
return root.codeBlocks || null;
|
|
1923
2142
|
}
|
|
2143
|
+
getCodeDslSync() {
|
|
2144
|
+
const root = this.get("root");
|
|
2145
|
+
if (!root)
|
|
2146
|
+
return null;
|
|
2147
|
+
return root.codeBlocks || null;
|
|
2148
|
+
}
|
|
1924
2149
|
async setCodeDsl(codeDsl) {
|
|
1925
2150
|
if (!this.state.root)
|
|
1926
2151
|
return;
|
|
@@ -2235,14 +2460,14 @@ const fillConfig = (config = []) => [
|
|
|
2235
2460
|
{
|
|
2236
2461
|
name: "created",
|
|
2237
2462
|
text: "created",
|
|
2238
|
-
|
|
2239
|
-
|
|
2463
|
+
labelWidth: "100px",
|
|
2464
|
+
type: "code-select"
|
|
2240
2465
|
},
|
|
2241
2466
|
{
|
|
2242
2467
|
name: "mounted",
|
|
2243
2468
|
text: "mounted",
|
|
2244
|
-
|
|
2245
|
-
|
|
2469
|
+
labelWidth: "100px",
|
|
2470
|
+
type: "code-select"
|
|
2246
2471
|
}
|
|
2247
2472
|
]
|
|
2248
2473
|
}
|
|
@@ -2354,12 +2579,14 @@ const useStage = (stageOptions) => {
|
|
|
2354
2579
|
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
2355
2580
|
]);
|
|
2356
2581
|
stage.on("select", (el) => {
|
|
2582
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
2583
|
+
return;
|
|
2357
2584
|
editorService.select(el.id);
|
|
2358
2585
|
});
|
|
2359
2586
|
stage.on("highlight", (el) => {
|
|
2360
2587
|
editorService.highlight(el.id);
|
|
2361
2588
|
});
|
|
2362
|
-
stage.on("
|
|
2589
|
+
stage.on("multi-select", (els) => {
|
|
2363
2590
|
editorService.multiSelect(els.map((el) => el.id));
|
|
2364
2591
|
});
|
|
2365
2592
|
stage.on("update", (ev) => {
|
|
@@ -2374,7 +2601,12 @@ const useStage = (stageOptions) => {
|
|
|
2374
2601
|
stage.on("sort", (ev) => {
|
|
2375
2602
|
editorService.sort(ev.src, ev.dist);
|
|
2376
2603
|
});
|
|
2377
|
-
stage.on("
|
|
2604
|
+
stage.on("select-parent", () => {
|
|
2605
|
+
const parent = editorService.get("parent");
|
|
2606
|
+
editorService.select(parent);
|
|
2607
|
+
editorService.get("stage").select(parent.id);
|
|
2608
|
+
});
|
|
2609
|
+
stage.on("change-guides", (e) => {
|
|
2378
2610
|
uiService.set("showGuides", true);
|
|
2379
2611
|
if (!root.value || !page.value)
|
|
2380
2612
|
return;
|
|
@@ -2390,11 +2622,14 @@ const useStage = (stageOptions) => {
|
|
|
2390
2622
|
return stage;
|
|
2391
2623
|
};
|
|
2392
2624
|
|
|
2393
|
-
const _hoisted_1$
|
|
2394
|
-
const _hoisted_2$
|
|
2395
|
-
const _hoisted_3$
|
|
2396
|
-
const
|
|
2397
|
-
|
|
2625
|
+
const _hoisted_1$d = { class: "m-editor-empty-panel" };
|
|
2626
|
+
const _hoisted_2$7 = { class: "m-editor-empty-content" };
|
|
2627
|
+
const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2628
|
+
const __default__$l = defineComponent({
|
|
2629
|
+
name: "MEditorAddPageBox"
|
|
2630
|
+
});
|
|
2631
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
2632
|
+
...__default__$l,
|
|
2398
2633
|
setup(__props) {
|
|
2399
2634
|
const services = inject("services");
|
|
2400
2635
|
const clickHandler = () => {
|
|
@@ -2407,22 +2642,16 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
2407
2642
|
});
|
|
2408
2643
|
};
|
|
2409
2644
|
return (_ctx, _cache) => {
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
createElementVNode("div", _hoisted_2$5, [
|
|
2645
|
+
return openBlock(), createElementBlock("div", _hoisted_1$d, [
|
|
2646
|
+
createElementVNode("div", _hoisted_2$7, [
|
|
2413
2647
|
createElementVNode("div", {
|
|
2414
2648
|
class: "m-editor-empty-button",
|
|
2415
2649
|
onClick: clickHandler
|
|
2416
2650
|
}, [
|
|
2417
2651
|
createElementVNode("div", null, [
|
|
2418
|
-
createVNode(
|
|
2419
|
-
default: withCtx(() => [
|
|
2420
|
-
createVNode(unref(Plus))
|
|
2421
|
-
]),
|
|
2422
|
-
_: 1
|
|
2423
|
-
})
|
|
2652
|
+
createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
2424
2653
|
]),
|
|
2425
|
-
_hoisted_3$
|
|
2654
|
+
_hoisted_3$4
|
|
2426
2655
|
])
|
|
2427
2656
|
])
|
|
2428
2657
|
]);
|
|
@@ -2430,137 +2659,12 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
2430
2659
|
}
|
|
2431
2660
|
});
|
|
2432
2661
|
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
setup(__props, { emit }) {
|
|
2437
|
-
const target = ref();
|
|
2438
|
-
let getso;
|
|
2439
|
-
onMounted(() => {
|
|
2440
|
-
if (!target.value)
|
|
2441
|
-
return;
|
|
2442
|
-
getso = new Gesto(target.value, {
|
|
2443
|
-
container: window,
|
|
2444
|
-
pinchOutside: true
|
|
2445
|
-
}).on("drag", (e) => {
|
|
2446
|
-
if (!target.value)
|
|
2447
|
-
return;
|
|
2448
|
-
emit("change", e.deltaX);
|
|
2449
|
-
});
|
|
2450
|
-
});
|
|
2451
|
-
onUnmounted(() => {
|
|
2452
|
-
getso?.unset();
|
|
2453
|
-
});
|
|
2454
|
-
return (_ctx, _cache) => {
|
|
2455
|
-
return openBlock(), createElementBlock("span", {
|
|
2456
|
-
ref_key: "target",
|
|
2457
|
-
ref: target,
|
|
2458
|
-
class: "m-editor-resizer"
|
|
2459
|
-
}, [
|
|
2460
|
-
renderSlot(_ctx.$slots, "default")
|
|
2461
|
-
], 512);
|
|
2462
|
-
};
|
|
2463
|
-
}
|
|
2662
|
+
const _hoisted_1$c = { class: "m-editor" };
|
|
2663
|
+
const __default__$k = defineComponent({
|
|
2664
|
+
name: "MEditorFramework"
|
|
2464
2665
|
});
|
|
2465
|
-
|
|
2466
2666
|
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
2467
|
-
|
|
2468
|
-
props: {
|
|
2469
|
-
left: null,
|
|
2470
|
-
right: null,
|
|
2471
|
-
minLeft: { default: 1 },
|
|
2472
|
-
minRight: { default: 1 },
|
|
2473
|
-
leftClass: null,
|
|
2474
|
-
rightClass: null,
|
|
2475
|
-
centerClass: null
|
|
2476
|
-
},
|
|
2477
|
-
emits: ["update:left", "change", "update:right"],
|
|
2478
|
-
setup(__props, { emit }) {
|
|
2479
|
-
const props = __props;
|
|
2480
|
-
const el = ref();
|
|
2481
|
-
let clientWidth = 0;
|
|
2482
|
-
const resizerObserver = new ResizeObserver((entries) => {
|
|
2483
|
-
for (const { contentRect } of entries) {
|
|
2484
|
-
clientWidth = contentRect.width;
|
|
2485
|
-
center.value = clientWidth - (props.left || 0) - (props.right || 0);
|
|
2486
|
-
emit("change", {
|
|
2487
|
-
left: props.left,
|
|
2488
|
-
center: center.value,
|
|
2489
|
-
right: props.right
|
|
2490
|
-
});
|
|
2491
|
-
}
|
|
2492
|
-
});
|
|
2493
|
-
onMounted(() => {
|
|
2494
|
-
if (el.value) {
|
|
2495
|
-
resizerObserver.observe(el.value);
|
|
2496
|
-
}
|
|
2497
|
-
});
|
|
2498
|
-
onUnmounted(() => {
|
|
2499
|
-
resizerObserver.disconnect();
|
|
2500
|
-
});
|
|
2501
|
-
const center = ref(0);
|
|
2502
|
-
const changeLeft = (deltaX) => {
|
|
2503
|
-
if (typeof props.left === "undefined")
|
|
2504
|
-
return;
|
|
2505
|
-
const left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
2506
|
-
emit("update:left", left);
|
|
2507
|
-
center.value = clientWidth - left - (props.right || 0);
|
|
2508
|
-
emit("change", {
|
|
2509
|
-
left,
|
|
2510
|
-
center: center.value,
|
|
2511
|
-
right: props.right
|
|
2512
|
-
});
|
|
2513
|
-
};
|
|
2514
|
-
const changeRight = (deltaX) => {
|
|
2515
|
-
if (typeof props.right === "undefined")
|
|
2516
|
-
return;
|
|
2517
|
-
const right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
2518
|
-
emit("update:right", right);
|
|
2519
|
-
center.value = clientWidth - (props.left || 0) - right;
|
|
2520
|
-
emit("change", {
|
|
2521
|
-
left: props.left,
|
|
2522
|
-
center: center.value,
|
|
2523
|
-
right
|
|
2524
|
-
});
|
|
2525
|
-
};
|
|
2526
|
-
return (_ctx, _cache) => {
|
|
2527
|
-
return openBlock(), createElementBlock("div", {
|
|
2528
|
-
ref_key: "el",
|
|
2529
|
-
ref: el,
|
|
2530
|
-
class: "m-editor-layout"
|
|
2531
|
-
}, [
|
|
2532
|
-
typeof props.left !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2533
|
-
createElementVNode("div", {
|
|
2534
|
-
class: normalizeClass(["m-editor-layout-left", __props.leftClass]),
|
|
2535
|
-
style: normalizeStyle(`width: ${__props.left}px`)
|
|
2536
|
-
}, [
|
|
2537
|
-
renderSlot(_ctx.$slots, "left")
|
|
2538
|
-
], 6),
|
|
2539
|
-
createVNode(_sfc_main$m, { onChange: changeLeft })
|
|
2540
|
-
], 64)) : createCommentVNode("", true),
|
|
2541
|
-
createElementVNode("div", {
|
|
2542
|
-
class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
|
|
2543
|
-
style: normalizeStyle(`width: ${center.value}px`)
|
|
2544
|
-
}, [
|
|
2545
|
-
renderSlot(_ctx.$slots, "center")
|
|
2546
|
-
], 6),
|
|
2547
|
-
typeof props.right !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
2548
|
-
createVNode(_sfc_main$m, { onChange: changeRight }),
|
|
2549
|
-
createElementVNode("div", {
|
|
2550
|
-
class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
|
|
2551
|
-
style: normalizeStyle(`width: ${__props.right}px`)
|
|
2552
|
-
}, [
|
|
2553
|
-
renderSlot(_ctx.$slots, "right")
|
|
2554
|
-
], 6)
|
|
2555
|
-
], 64)) : createCommentVNode("", true)
|
|
2556
|
-
], 512);
|
|
2557
|
-
};
|
|
2558
|
-
}
|
|
2559
|
-
});
|
|
2560
|
-
|
|
2561
|
-
const _hoisted_1$a = { class: "m-editor" };
|
|
2562
|
-
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
2563
|
-
__name: "Framework",
|
|
2667
|
+
...__default__$k,
|
|
2564
2668
|
props: {
|
|
2565
2669
|
codeOptions: { default: () => ({}) }
|
|
2566
2670
|
},
|
|
@@ -2569,48 +2673,64 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2569
2673
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
2570
2674
|
const { editorService, uiService } = inject("services") || {};
|
|
2571
2675
|
const root = computed(() => editorService?.get("root"));
|
|
2676
|
+
const nodes = computed(() => editorService?.get("nodes") || []);
|
|
2572
2677
|
const pageLength = computed(() => editorService?.get("pageLength") || 0);
|
|
2573
2678
|
const showSrc = computed(() => uiService?.get("showSrc"));
|
|
2679
|
+
const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
|
|
2680
|
+
const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
|
|
2681
|
+
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
|
|
2682
|
+
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
|
|
2574
2683
|
const columnWidth = ref({
|
|
2575
|
-
left:
|
|
2684
|
+
left: leftColumnWidthCacheData,
|
|
2576
2685
|
center: 0,
|
|
2577
|
-
right:
|
|
2686
|
+
right: RightColumnWidthCacheData
|
|
2578
2687
|
});
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
columnWidth.value.
|
|
2583
|
-
columnWidth.value.
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2688
|
+
watch(
|
|
2689
|
+
pageLength,
|
|
2690
|
+
(length) => {
|
|
2691
|
+
const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
2692
|
+
columnWidth.value.left = left;
|
|
2693
|
+
if (length <= 0) {
|
|
2694
|
+
columnWidth.value.right = void 0;
|
|
2695
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left;
|
|
2696
|
+
} else {
|
|
2697
|
+
const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
2698
|
+
columnWidth.value.right = right;
|
|
2699
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left - right;
|
|
2700
|
+
}
|
|
2701
|
+
uiService?.set("columnWidth", columnWidth);
|
|
2702
|
+
},
|
|
2703
|
+
{
|
|
2704
|
+
immediate: true
|
|
2587
2705
|
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2706
|
+
);
|
|
2707
|
+
watch(
|
|
2708
|
+
() => columnWidth.value.right,
|
|
2709
|
+
(right) => {
|
|
2710
|
+
if (typeof right === "undefined")
|
|
2711
|
+
return;
|
|
2712
|
+
globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
|
|
2713
|
+
}
|
|
2714
|
+
);
|
|
2715
|
+
watch(
|
|
2716
|
+
() => columnWidth.value.left,
|
|
2717
|
+
(left) => {
|
|
2718
|
+
globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
|
|
2594
2719
|
}
|
|
2720
|
+
);
|
|
2721
|
+
const columnWidthChange = (columnWidth2) => {
|
|
2722
|
+
uiService?.set("columnWidth", columnWidth2);
|
|
2595
2723
|
};
|
|
2596
|
-
const
|
|
2597
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
2598
|
-
if (columnWidthCacheData) {
|
|
2724
|
+
const saveCode = (value) => {
|
|
2599
2725
|
try {
|
|
2600
|
-
|
|
2601
|
-
columnWidth.value = columnWidthCache;
|
|
2726
|
+
editorService?.set("root", eval(value));
|
|
2602
2727
|
} catch (e) {
|
|
2603
2728
|
console.error(e);
|
|
2604
2729
|
}
|
|
2605
|
-
}
|
|
2606
|
-
const columnWidthChange = (columnWidth2) => {
|
|
2607
|
-
uiService?.set("columnWidth", columnWidth2);
|
|
2608
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth2));
|
|
2609
2730
|
};
|
|
2610
2731
|
return (_ctx, _cache) => {
|
|
2611
2732
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2612
|
-
|
|
2613
|
-
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
2733
|
+
return openBlock(), createElementBlock("div", _hoisted_1$c, [
|
|
2614
2734
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2615
2735
|
unref(showSrc) ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2616
2736
|
key: 0,
|
|
@@ -2618,95 +2738,57 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2618
2738
|
"init-values": unref(root),
|
|
2619
2739
|
options: __props.codeOptions,
|
|
2620
2740
|
onSave: saveCode
|
|
2621
|
-
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$
|
|
2622
|
-
key: 1,
|
|
2623
|
-
class: "m-editor-content",
|
|
2624
|
-
"left-class": "m-editor-framework-left",
|
|
2625
|
-
"center-class": "m-editor-framework-center",
|
|
2626
|
-
"right-class": "m-editor-framework-right",
|
|
2627
|
-
left: columnWidth.value.left,
|
|
2628
|
-
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
|
|
2629
|
-
right: columnWidth.value.right,
|
|
2630
|
-
"onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
|
|
2631
|
-
"min-left": 45,
|
|
2632
|
-
"min-right": 1,
|
|
2633
|
-
onChange: columnWidthChange
|
|
2634
|
-
}, createSlots({
|
|
2635
|
-
left: withCtx(() => [
|
|
2636
|
-
renderSlot(_ctx.$slots, "sidebar")
|
|
2637
|
-
]),
|
|
2638
|
-
center: withCtx(() => [
|
|
2639
|
-
unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2640
|
-
createVNode(_sfc_main$
|
|
2641
|
-
])
|
|
2642
|
-
]),
|
|
2643
|
-
_: 2
|
|
2644
|
-
}, [
|
|
2645
|
-
unref(pageLength) > 0 ? {
|
|
2646
|
-
name: "right",
|
|
2647
|
-
fn: withCtx(() => [
|
|
2648
|
-
createVNode(
|
|
2649
|
-
default: withCtx(() => [
|
|
2650
|
-
renderSlot(_ctx.$slots, "props-panel")
|
|
2651
|
-
]),
|
|
2652
|
-
_: 3
|
|
2653
|
-
})
|
|
2654
|
-
])
|
|
2655
|
-
} : void 0
|
|
2656
|
-
]), 1032, ["left", "right"]))
|
|
2657
|
-
]);
|
|
2658
|
-
};
|
|
2659
|
-
}
|
|
2660
|
-
});
|
|
2661
|
-
|
|
2662
|
-
const _hoisted_1$9 = ["src"];
|
|
2663
|
-
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
2664
|
-
__name: "Icon",
|
|
2665
|
-
props: {
|
|
2666
|
-
icon: null
|
|
2667
|
-
},
|
|
2668
|
-
setup(__props) {
|
|
2669
|
-
return (_ctx, _cache) => {
|
|
2670
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
2671
|
-
return !__props.icon ? (openBlock(), createBlock(_component_el_icon, {
|
|
2672
|
-
key: 0,
|
|
2673
|
-
class: "magic-editor-icon"
|
|
2674
|
-
}, {
|
|
2675
|
-
default: withCtx(() => [
|
|
2676
|
-
createVNode(unref(Edit))
|
|
2677
|
-
]),
|
|
2678
|
-
_: 1
|
|
2679
|
-
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, {
|
|
2680
|
-
key: 1,
|
|
2681
|
-
class: "magic-editor-icon"
|
|
2682
|
-
}, {
|
|
2683
|
-
default: withCtx(() => [
|
|
2684
|
-
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$9)
|
|
2685
|
-
]),
|
|
2686
|
-
_: 1
|
|
2687
|
-
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2688
|
-
key: 2,
|
|
2689
|
-
class: normalizeClass(["magic-editor-icon", __props.icon])
|
|
2690
|
-
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, {
|
|
2691
|
-
key: 3,
|
|
2692
|
-
class: "magic-editor-icon"
|
|
2693
|
-
}, {
|
|
2694
|
-
default: withCtx(() => [
|
|
2695
|
-
(openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
|
|
2696
|
-
]),
|
|
2697
|
-
_: 1
|
|
2698
|
-
}));
|
|
2741
|
+
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$o, {
|
|
2742
|
+
key: 1,
|
|
2743
|
+
class: "m-editor-content",
|
|
2744
|
+
"left-class": "m-editor-framework-left",
|
|
2745
|
+
"center-class": "m-editor-framework-center",
|
|
2746
|
+
"right-class": "m-editor-framework-right",
|
|
2747
|
+
left: columnWidth.value.left,
|
|
2748
|
+
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
|
|
2749
|
+
right: columnWidth.value.right,
|
|
2750
|
+
"onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
|
|
2751
|
+
"min-left": 45,
|
|
2752
|
+
"min-right": 1,
|
|
2753
|
+
onChange: columnWidthChange
|
|
2754
|
+
}, createSlots({
|
|
2755
|
+
left: withCtx(() => [
|
|
2756
|
+
renderSlot(_ctx.$slots, "sidebar")
|
|
2757
|
+
]),
|
|
2758
|
+
center: withCtx(() => [
|
|
2759
|
+
unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2760
|
+
createVNode(_sfc_main$m)
|
|
2761
|
+
])
|
|
2762
|
+
]),
|
|
2763
|
+
_: 2
|
|
2764
|
+
}, [
|
|
2765
|
+
unref(pageLength) > 0 && unref(nodes).length === 1 ? {
|
|
2766
|
+
name: "right",
|
|
2767
|
+
fn: withCtx(() => [
|
|
2768
|
+
createVNode(unref(TMagicScrollbar), null, {
|
|
2769
|
+
default: withCtx(() => [
|
|
2770
|
+
renderSlot(_ctx.$slots, "props-panel")
|
|
2771
|
+
]),
|
|
2772
|
+
_: 3
|
|
2773
|
+
})
|
|
2774
|
+
])
|
|
2775
|
+
} : void 0
|
|
2776
|
+
]), 1032, ["left", "right"]))
|
|
2777
|
+
]);
|
|
2699
2778
|
};
|
|
2700
2779
|
}
|
|
2701
2780
|
});
|
|
2702
2781
|
|
|
2703
|
-
const _hoisted_1$
|
|
2782
|
+
const _hoisted_1$b = {
|
|
2704
2783
|
key: 1,
|
|
2705
2784
|
class: "menu-item-text"
|
|
2706
2785
|
};
|
|
2707
|
-
const _hoisted_2$
|
|
2708
|
-
const
|
|
2709
|
-
|
|
2786
|
+
const _hoisted_2$6 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2787
|
+
const __default__$j = defineComponent({
|
|
2788
|
+
name: "MEditorToolButton"
|
|
2789
|
+
});
|
|
2790
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
2791
|
+
...__default__$j,
|
|
2710
2792
|
props: {
|
|
2711
2793
|
data: { default: () => ({
|
|
2712
2794
|
type: "text",
|
|
@@ -2771,13 +2853,6 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2771
2853
|
}
|
|
2772
2854
|
};
|
|
2773
2855
|
return (_ctx, _cache) => {
|
|
2774
|
-
const _component_el_divider = resolveComponent("el-divider");
|
|
2775
|
-
const _component_el_button = resolveComponent("el-button");
|
|
2776
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2777
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
2778
|
-
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2779
|
-
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2780
|
-
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2781
2856
|
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2782
2857
|
key: 0,
|
|
2783
2858
|
class: normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
|
|
@@ -2785,24 +2860,24 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2785
2860
|
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
|
|
2786
2861
|
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
|
|
2787
2862
|
}, [
|
|
2788
|
-
__props.data.type === "divider" ? (openBlock(), createBlock(
|
|
2863
|
+
__props.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
|
|
2789
2864
|
key: 0,
|
|
2790
2865
|
direction: __props.data.direction || "vertical"
|
|
2791
|
-
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2792
|
-
__props.data.tooltip ? (openBlock(), createBlock(
|
|
2866
|
+
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$b, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2867
|
+
__props.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
2793
2868
|
key: 0,
|
|
2794
2869
|
effect: "dark",
|
|
2795
2870
|
placement: "bottom-start",
|
|
2796
2871
|
content: __props.data.tooltip
|
|
2797
2872
|
}, {
|
|
2798
2873
|
default: withCtx(() => [
|
|
2799
|
-
createVNode(
|
|
2874
|
+
createVNode(unref(TMagicButton), {
|
|
2800
2875
|
size: "small",
|
|
2801
2876
|
text: "",
|
|
2802
2877
|
disabled: unref(disabled)
|
|
2803
2878
|
}, {
|
|
2804
2879
|
default: withCtx(() => [
|
|
2805
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2880
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
2806
2881
|
key: 0,
|
|
2807
2882
|
icon: __props.data.icon
|
|
2808
2883
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2812,14 +2887,14 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2812
2887
|
}, 8, ["disabled"])
|
|
2813
2888
|
]),
|
|
2814
2889
|
_: 1
|
|
2815
|
-
}, 8, ["content"])) : (openBlock(), createBlock(
|
|
2890
|
+
}, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), {
|
|
2816
2891
|
key: 1,
|
|
2817
2892
|
size: "small",
|
|
2818
2893
|
text: "",
|
|
2819
2894
|
disabled: unref(disabled)
|
|
2820
2895
|
}, {
|
|
2821
2896
|
default: withCtx(() => [
|
|
2822
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2897
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
2823
2898
|
key: 0,
|
|
2824
2899
|
icon: __props.data.icon
|
|
2825
2900
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2827,17 +2902,17 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2827
2902
|
]),
|
|
2828
2903
|
_: 1
|
|
2829
2904
|
}, 8, ["disabled"]))
|
|
2830
|
-
], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(
|
|
2905
|
+
], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(unref(TMagicDropdown), {
|
|
2831
2906
|
key: 3,
|
|
2832
2907
|
trigger: "click",
|
|
2833
2908
|
disabled: unref(disabled),
|
|
2834
2909
|
onCommand: dropdownHandler
|
|
2835
2910
|
}, {
|
|
2836
2911
|
dropdown: withCtx(() => [
|
|
2837
|
-
__props.data.items && __props.data.items.length ? (openBlock(), createBlock(
|
|
2912
|
+
__props.data.items && __props.data.items.length ? (openBlock(), createBlock(unref(TMagicDropdownMenu), { key: 0 }, {
|
|
2838
2913
|
default: withCtx(() => [
|
|
2839
2914
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (subItem, index) => {
|
|
2840
|
-
return openBlock(), createBlock(
|
|
2915
|
+
return openBlock(), createBlock(unref(TMagicDropdownItem), {
|
|
2841
2916
|
key: index,
|
|
2842
2917
|
command: { data: __props.data, subItem }
|
|
2843
2918
|
}, {
|
|
@@ -2852,9 +2927,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2852
2927
|
})) : createCommentVNode("", true)
|
|
2853
2928
|
]),
|
|
2854
2929
|
default: withCtx(() => [
|
|
2855
|
-
createElementVNode("span", _hoisted_2$
|
|
2930
|
+
createElementVNode("span", _hoisted_2$6, [
|
|
2856
2931
|
createTextVNode(toDisplayString(__props.data.text), 1),
|
|
2857
|
-
createVNode(
|
|
2932
|
+
createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
|
|
2858
2933
|
default: withCtx(() => [
|
|
2859
2934
|
createVNode(unref(ArrowDown))
|
|
2860
2935
|
]),
|
|
@@ -2869,8 +2944,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2869
2944
|
}
|
|
2870
2945
|
});
|
|
2871
2946
|
|
|
2872
|
-
const
|
|
2873
|
-
|
|
2947
|
+
const __default__$i = defineComponent({
|
|
2948
|
+
name: "MEditorNavMenu"
|
|
2949
|
+
});
|
|
2950
|
+
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
2951
|
+
...__default__$i,
|
|
2874
2952
|
props: {
|
|
2875
2953
|
data: { default: () => ({}) },
|
|
2876
2954
|
height: { default: 35 }
|
|
@@ -3025,7 +3103,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3025
3103
|
style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
|
|
3026
3104
|
}, [
|
|
3027
3105
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
|
|
3028
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3106
|
+
return openBlock(), createBlock(_sfc_main$k, {
|
|
3029
3107
|
data: item,
|
|
3030
3108
|
key: index
|
|
3031
3109
|
}, null, 8, ["data"]);
|
|
@@ -3037,9 +3115,12 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3037
3115
|
}
|
|
3038
3116
|
});
|
|
3039
3117
|
|
|
3040
|
-
const _hoisted_1$
|
|
3041
|
-
const
|
|
3042
|
-
|
|
3118
|
+
const _hoisted_1$a = { class: "m-editor-props-panel" };
|
|
3119
|
+
const __default__$h = defineComponent({
|
|
3120
|
+
name: "MEditorPropsPanel"
|
|
3121
|
+
});
|
|
3122
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
3123
|
+
...__default__$h,
|
|
3043
3124
|
emits: ["mounted"],
|
|
3044
3125
|
setup(__props, { expose, emit }) {
|
|
3045
3126
|
const internalInstance = getCurrentInstance();
|
|
@@ -3048,7 +3129,9 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3048
3129
|
const curFormConfig = ref([]);
|
|
3049
3130
|
const services = inject("services");
|
|
3050
3131
|
const node = computed(() => services?.editorService.get("node"));
|
|
3051
|
-
const propsPanelSize = computed(
|
|
3132
|
+
const propsPanelSize = computed(
|
|
3133
|
+
() => services?.uiService.get("propsPanelSize") || "small"
|
|
3134
|
+
);
|
|
3052
3135
|
const stage = computed(() => services?.editorService.get("stage"));
|
|
3053
3136
|
const init = async () => {
|
|
3054
3137
|
if (!node.value) {
|
|
@@ -3075,21 +3158,15 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3075
3158
|
services?.editorService.update(values2);
|
|
3076
3159
|
} catch (e) {
|
|
3077
3160
|
console.error(e);
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
duration: 1e4,
|
|
3081
|
-
showClose: true,
|
|
3082
|
-
message: e.message,
|
|
3083
|
-
dangerouslyUseHTMLString: true
|
|
3084
|
-
});
|
|
3161
|
+
tMagicMessage.closeAll();
|
|
3162
|
+
tMagicMessage.error(e.message);
|
|
3085
3163
|
}
|
|
3086
3164
|
};
|
|
3087
3165
|
expose({ submit });
|
|
3088
3166
|
return (_ctx, _cache) => {
|
|
3089
|
-
|
|
3090
|
-
return openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
3167
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
3091
3168
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
3092
|
-
createVNode(
|
|
3169
|
+
createVNode(unref(MForm), {
|
|
3093
3170
|
ref_key: "configForm",
|
|
3094
3171
|
ref: configForm,
|
|
3095
3172
|
class: normalizeClass(`m-editor-props-panel ${unref(propsPanelSize)}`),
|
|
@@ -3104,43 +3181,328 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3104
3181
|
}
|
|
3105
3182
|
});
|
|
3106
3183
|
|
|
3107
|
-
const _hoisted_1$
|
|
3108
|
-
|
|
3109
|
-
const _hoisted_3$1 = { class: "code-name" };
|
|
3110
|
-
const _hoisted_4$1 = { class: "code-name-wrapper" };
|
|
3111
|
-
const _hoisted_5$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
|
|
3112
|
-
const _hoisted_6$1 = { class: "m-editor-wrapper" };
|
|
3113
|
-
const _hoisted_7$1 = {
|
|
3114
|
-
key: 1,
|
|
3184
|
+
const _hoisted_1$9 = {
|
|
3185
|
+
key: 0,
|
|
3115
3186
|
class: "m-editor-content-bottom"
|
|
3116
3187
|
};
|
|
3117
|
-
const
|
|
3118
|
-
const
|
|
3119
|
-
const
|
|
3120
|
-
key:
|
|
3188
|
+
const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
|
|
3189
|
+
const _hoisted_3$3 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3190
|
+
const _hoisted_4$2 = {
|
|
3191
|
+
key: 1,
|
|
3121
3192
|
class: "m-editor-content-bottom"
|
|
3122
3193
|
};
|
|
3123
|
-
const
|
|
3194
|
+
const _hoisted_5$1 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3195
|
+
const __default__$g = defineComponent({
|
|
3196
|
+
name: "MEditorCodeDraftEditor"
|
|
3197
|
+
});
|
|
3198
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
3199
|
+
...__default__$g,
|
|
3200
|
+
props: {
|
|
3201
|
+
id: null,
|
|
3202
|
+
content: null,
|
|
3203
|
+
editable: { type: Boolean, default: true },
|
|
3204
|
+
autoSaveDraft: { type: Boolean, default: true },
|
|
3205
|
+
codeOptions: null,
|
|
3206
|
+
language: null
|
|
3207
|
+
},
|
|
3208
|
+
emits: ["save", "close", "saveAndClose"],
|
|
3209
|
+
setup(__props, { emit }) {
|
|
3210
|
+
const props = __props;
|
|
3211
|
+
const services = inject("services");
|
|
3212
|
+
const codeContent = ref("");
|
|
3213
|
+
const editorContent = ref("");
|
|
3214
|
+
const codeEditor = ref();
|
|
3215
|
+
const originCodeContent = ref("");
|
|
3216
|
+
const isFullScreen = ref(false);
|
|
3217
|
+
const codeOptions = computed(() => ({
|
|
3218
|
+
...props.codeOptions,
|
|
3219
|
+
readOnly: !props.editable
|
|
3220
|
+
}));
|
|
3221
|
+
watchEffect(() => {
|
|
3222
|
+
codeContent.value = props.content;
|
|
3223
|
+
if (!originCodeContent.value) {
|
|
3224
|
+
originCodeContent.value = codeContent.value;
|
|
3225
|
+
}
|
|
3226
|
+
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3227
|
+
if (codeDraft) {
|
|
3228
|
+
codeContent.value = codeDraft;
|
|
3229
|
+
}
|
|
3230
|
+
});
|
|
3231
|
+
const saveCodeDraft = async (codeValue) => {
|
|
3232
|
+
if (!props.autoSaveDraft)
|
|
3233
|
+
return;
|
|
3234
|
+
if (originCodeContent.value === codeValue) {
|
|
3235
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3236
|
+
return;
|
|
3237
|
+
}
|
|
3238
|
+
services?.codeBlockService.setCodeDraft(props.id, codeValue);
|
|
3239
|
+
tMagicMessage.success(`\u4EE3\u7801\u8349\u7A3F\u4FDD\u5B58\u6210\u529F ${datetimeFormatter(new Date())}`);
|
|
3240
|
+
};
|
|
3241
|
+
const saveCode = () => {
|
|
3242
|
+
if (!codeEditor.value || !props.editable)
|
|
3243
|
+
return;
|
|
3244
|
+
editorContent.value = codeEditor.value.getEditor()?.getValue();
|
|
3245
|
+
emit("save", editorContent.value);
|
|
3246
|
+
};
|
|
3247
|
+
const saveAndClose = () => {
|
|
3248
|
+
if (!codeEditor.value || !props.editable)
|
|
3249
|
+
return;
|
|
3250
|
+
editorContent.value = codeEditor.value.getEditor()?.getValue();
|
|
3251
|
+
emit("saveAndClose", editorContent.value);
|
|
3252
|
+
};
|
|
3253
|
+
const close = async () => {
|
|
3254
|
+
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3255
|
+
if (codeDraft) {
|
|
3256
|
+
tMagicMessageBox.confirm("\u60A8\u6709\u4EE3\u7801\u4FEE\u6539\u672A\u4FDD\u5B58\uFF0C\u662F\u5426\u4FDD\u5B58\u540E\u518D\u5173\u95ED\uFF1F", "\u63D0\u793A", {
|
|
3257
|
+
confirmButtonText: "\u786E\u8BA4",
|
|
3258
|
+
cancelButtonText: "\u53D6\u6D88",
|
|
3259
|
+
type: "warning"
|
|
3260
|
+
}).then(async () => {
|
|
3261
|
+
saveAndClose();
|
|
3262
|
+
}).catch(() => {
|
|
3263
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3264
|
+
emit("close");
|
|
3265
|
+
});
|
|
3266
|
+
} else {
|
|
3267
|
+
emit("close");
|
|
3268
|
+
}
|
|
3269
|
+
};
|
|
3270
|
+
const toggleFullScreen = () => {
|
|
3271
|
+
isFullScreen.value = !isFullScreen.value;
|
|
3272
|
+
if (codeEditor.value) {
|
|
3273
|
+
codeEditor.value.focus();
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
return (_ctx, _cache) => {
|
|
3277
|
+
return openBlock(), createElementBlock("div", {
|
|
3278
|
+
class: normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
|
|
3279
|
+
}, [
|
|
3280
|
+
createVNode(_sfc_main$q, {
|
|
3281
|
+
ref_key: "codeEditor",
|
|
3282
|
+
ref: codeEditor,
|
|
3283
|
+
class: "m-editor-container",
|
|
3284
|
+
"init-values": `${codeContent.value}`,
|
|
3285
|
+
onSave: saveCodeDraft,
|
|
3286
|
+
language: __props.language,
|
|
3287
|
+
options: unref(codeOptions)
|
|
3288
|
+
}, null, 8, ["init-values", "language", "options"]),
|
|
3289
|
+
__props.editable ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
3290
|
+
createVNode(unref(TMagicButton), {
|
|
3291
|
+
type: "primary",
|
|
3292
|
+
class: "button",
|
|
3293
|
+
onClick: toggleFullScreen
|
|
3294
|
+
}, {
|
|
3295
|
+
default: withCtx(() => [
|
|
3296
|
+
createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
|
|
3297
|
+
]),
|
|
3298
|
+
_: 1
|
|
3299
|
+
}),
|
|
3300
|
+
createVNode(unref(TMagicButton), {
|
|
3301
|
+
type: "primary",
|
|
3302
|
+
class: "button",
|
|
3303
|
+
onClick: saveCode
|
|
3304
|
+
}, {
|
|
3305
|
+
default: withCtx(() => [
|
|
3306
|
+
_hoisted_2$5
|
|
3307
|
+
]),
|
|
3308
|
+
_: 1
|
|
3309
|
+
}),
|
|
3310
|
+
createVNode(unref(TMagicButton), {
|
|
3311
|
+
type: "primary",
|
|
3312
|
+
class: "button",
|
|
3313
|
+
onClick: close
|
|
3314
|
+
}, {
|
|
3315
|
+
default: withCtx(() => [
|
|
3316
|
+
_hoisted_3$3
|
|
3317
|
+
]),
|
|
3318
|
+
_: 1
|
|
3319
|
+
})
|
|
3320
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_4$2, [
|
|
3321
|
+
createVNode(unref(TMagicButton), {
|
|
3322
|
+
type: "primary",
|
|
3323
|
+
class: "button",
|
|
3324
|
+
onClick: toggleFullScreen
|
|
3325
|
+
}, {
|
|
3326
|
+
default: withCtx(() => [
|
|
3327
|
+
createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
|
|
3328
|
+
]),
|
|
3329
|
+
_: 1
|
|
3330
|
+
}),
|
|
3331
|
+
createVNode(unref(TMagicButton), {
|
|
3332
|
+
type: "primary",
|
|
3333
|
+
class: "button",
|
|
3334
|
+
onClick: close
|
|
3335
|
+
}, {
|
|
3336
|
+
default: withCtx(() => [
|
|
3337
|
+
_hoisted_5$1
|
|
3338
|
+
]),
|
|
3339
|
+
_: 1
|
|
3340
|
+
})
|
|
3341
|
+
]))
|
|
3342
|
+
], 2);
|
|
3343
|
+
};
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3346
|
+
|
|
3347
|
+
const _hoisted_1$8 = { class: "code-name-wrapper" };
|
|
3348
|
+
const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
|
|
3349
|
+
const _hoisted_3$2 = { class: "code-name-wrapper" };
|
|
3350
|
+
const _hoisted_4$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u53C2\u6570\u5B9A\u4E49", -1);
|
|
3351
|
+
const __default__$f = defineComponent({
|
|
3352
|
+
name: "MEditorFunctionEditor"
|
|
3353
|
+
});
|
|
3354
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
3355
|
+
...__default__$f,
|
|
3356
|
+
props: {
|
|
3357
|
+
id: null,
|
|
3358
|
+
name: null,
|
|
3359
|
+
content: null,
|
|
3360
|
+
editable: { type: Boolean, default: true },
|
|
3361
|
+
autoSaveDraft: { type: Boolean, default: true },
|
|
3362
|
+
codeOptions: null
|
|
3363
|
+
},
|
|
3364
|
+
emits: ["change", "field-input"],
|
|
3365
|
+
setup(__props, { emit }) {
|
|
3366
|
+
const props = __props;
|
|
3367
|
+
const tableConfig = {
|
|
3368
|
+
border: true,
|
|
3369
|
+
enableFullscreen: false,
|
|
3370
|
+
name: "params",
|
|
3371
|
+
maxHeight: "150px",
|
|
3372
|
+
items: [
|
|
3373
|
+
{
|
|
3374
|
+
type: "text",
|
|
3375
|
+
label: "\u53C2\u6570\u540D",
|
|
3376
|
+
name: "name"
|
|
3377
|
+
}
|
|
3378
|
+
]
|
|
3379
|
+
};
|
|
3380
|
+
const services = inject("services");
|
|
3381
|
+
const codeName = ref("");
|
|
3382
|
+
const codeContent = ref("");
|
|
3383
|
+
const evalRes = ref(true);
|
|
3384
|
+
provide("mForm", {
|
|
3385
|
+
$emit: emit,
|
|
3386
|
+
setField: () => {
|
|
3387
|
+
}
|
|
3388
|
+
});
|
|
3389
|
+
const tableModel = ref();
|
|
3390
|
+
watchEffect(() => {
|
|
3391
|
+
codeName.value = props.name;
|
|
3392
|
+
codeContent.value = props.content;
|
|
3393
|
+
});
|
|
3394
|
+
const initTableModel = () => {
|
|
3395
|
+
const codeDsl = services?.codeBlockService.getCodeDslSync();
|
|
3396
|
+
if (!codeDsl)
|
|
3397
|
+
return;
|
|
3398
|
+
tableModel.value = {
|
|
3399
|
+
params: codeDsl[props.id]?.params || []
|
|
3400
|
+
};
|
|
3401
|
+
};
|
|
3402
|
+
initTableModel();
|
|
3403
|
+
const beforeSave = (codeValue) => {
|
|
3404
|
+
try {
|
|
3405
|
+
eval(codeValue);
|
|
3406
|
+
return true;
|
|
3407
|
+
} catch (e) {
|
|
3408
|
+
tMagicMessage.error(e.stack);
|
|
3409
|
+
return false;
|
|
3410
|
+
}
|
|
3411
|
+
};
|
|
3412
|
+
const saveCode = async (codeValue2) => {
|
|
3413
|
+
if (!props.editable)
|
|
3414
|
+
return;
|
|
3415
|
+
evalRes.value = beforeSave(codeValue2);
|
|
3416
|
+
if (evalRes.value) {
|
|
3417
|
+
await services?.codeBlockService.setCodeDslById(props.id, {
|
|
3418
|
+
name: codeName.value,
|
|
3419
|
+
content: codeValue2,
|
|
3420
|
+
params: tableModel.value?.params || []
|
|
3421
|
+
});
|
|
3422
|
+
tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
|
|
3423
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3424
|
+
}
|
|
3425
|
+
};
|
|
3426
|
+
const saveAndClose = async (codeValue2) => {
|
|
3427
|
+
await saveCode(codeValue2);
|
|
3428
|
+
if (evalRes.value) {
|
|
3429
|
+
close();
|
|
3430
|
+
}
|
|
3431
|
+
};
|
|
3432
|
+
const close = () => {
|
|
3433
|
+
services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
3434
|
+
};
|
|
3435
|
+
return (_ctx, _cache) => {
|
|
3436
|
+
const _component_m_form_table = resolveComponent("m-form-table");
|
|
3437
|
+
return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
|
|
3438
|
+
header: withCtx(() => [
|
|
3439
|
+
createElementVNode("div", _hoisted_1$8, [
|
|
3440
|
+
_hoisted_2$4,
|
|
3441
|
+
createVNode(unref(TMagicInput), {
|
|
3442
|
+
class: "code-name-input",
|
|
3443
|
+
modelValue: codeName.value,
|
|
3444
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeName.value = $event),
|
|
3445
|
+
disabled: !__props.editable
|
|
3446
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
3447
|
+
]),
|
|
3448
|
+
createElementVNode("div", _hoisted_3$2, [
|
|
3449
|
+
_hoisted_4$1,
|
|
3450
|
+
createVNode(_component_m_form_table, {
|
|
3451
|
+
style: { "width": "320px" },
|
|
3452
|
+
config: tableConfig,
|
|
3453
|
+
model: tableModel.value,
|
|
3454
|
+
enableToggleMode: false,
|
|
3455
|
+
name: "params",
|
|
3456
|
+
prop: "params",
|
|
3457
|
+
size: "small"
|
|
3458
|
+
}, null, 8, ["model"])
|
|
3459
|
+
])
|
|
3460
|
+
]),
|
|
3461
|
+
default: withCtx(() => [
|
|
3462
|
+
createVNode(_sfc_main$h, {
|
|
3463
|
+
id: __props.id,
|
|
3464
|
+
content: codeContent.value,
|
|
3465
|
+
editable: __props.editable,
|
|
3466
|
+
autoSaveDraft: __props.autoSaveDraft,
|
|
3467
|
+
codeOptions: __props.codeOptions,
|
|
3468
|
+
language: "javascript",
|
|
3469
|
+
onSave: saveCode,
|
|
3470
|
+
onSaveAndClose: saveAndClose,
|
|
3471
|
+
onClose: close
|
|
3472
|
+
}, null, 8, ["id", "content", "editable", "autoSaveDraft", "codeOptions"])
|
|
3473
|
+
]),
|
|
3474
|
+
_: 1
|
|
3475
|
+
});
|
|
3476
|
+
};
|
|
3477
|
+
}
|
|
3478
|
+
});
|
|
3479
|
+
|
|
3480
|
+
const _hoisted_1$7 = ["id"];
|
|
3481
|
+
const _hoisted_2$3 = { class: "list-item" };
|
|
3482
|
+
const _hoisted_3$1 = { class: "code-name" };
|
|
3483
|
+
const __default__$e = defineComponent({
|
|
3484
|
+
name: "MEditorCodeBlockEditor"
|
|
3485
|
+
});
|
|
3124
3486
|
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
3125
|
-
|
|
3487
|
+
...__default__$e,
|
|
3126
3488
|
setup(__props) {
|
|
3127
3489
|
const services = inject("services");
|
|
3128
|
-
const
|
|
3490
|
+
const codeOptions = inject("codeOptions", {});
|
|
3129
3491
|
const left = ref(200);
|
|
3130
3492
|
const currentTitle = ref("");
|
|
3131
3493
|
const codeConfig = ref(null);
|
|
3132
3494
|
const state = reactive({
|
|
3133
3495
|
codeList: []
|
|
3134
3496
|
});
|
|
3135
|
-
const isShowCodeBlockEditor = computed(
|
|
3136
|
-
() => codeConfig.value && services?.codeBlockService.getCodeEditorShowStatus() || false
|
|
3137
|
-
);
|
|
3138
3497
|
const mode = computed(() => services?.codeBlockService.getMode());
|
|
3139
3498
|
const id = computed(() => services?.codeBlockService.getId() || "");
|
|
3140
3499
|
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3141
3500
|
const selectedIds = computed(() => services?.codeBlockService.getCombineIds() || []);
|
|
3142
3501
|
watchEffect(async () => {
|
|
3143
|
-
codeConfig.value = await services?.codeBlockService.getCodeContentById(id.value) || null;
|
|
3502
|
+
codeConfig.value = cloneDeep(await services?.codeBlockService.getCodeContentById(id.value)) || null;
|
|
3503
|
+
if (!codeConfig.value)
|
|
3504
|
+
return;
|
|
3505
|
+
codeConfig.value.content = serializeConfig(codeConfig.value.content);
|
|
3144
3506
|
});
|
|
3145
3507
|
watchEffect(async () => {
|
|
3146
3508
|
const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
|
|
@@ -3155,52 +3517,24 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3155
3517
|
});
|
|
3156
3518
|
currentTitle.value = state.codeList[0]?.name || "";
|
|
3157
3519
|
});
|
|
3158
|
-
const saveCode = async () => {
|
|
3159
|
-
if (!codeEditor.value || !codeConfig.value || !editable.value)
|
|
3160
|
-
return true;
|
|
3161
|
-
try {
|
|
3162
|
-
const codeContent = codeEditor.value.getEditor()?.getValue();
|
|
3163
|
-
codeConfig.value.content = eval(codeContent);
|
|
3164
|
-
} catch (e) {
|
|
3165
|
-
ElMessage.error(e.stack);
|
|
3166
|
-
return false;
|
|
3167
|
-
}
|
|
3168
|
-
await services?.codeBlockService.setCodeDslById(id.value, {
|
|
3169
|
-
name: codeConfig.value.name,
|
|
3170
|
-
content: codeConfig.value.content
|
|
3171
|
-
});
|
|
3172
|
-
ElMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
|
|
3173
|
-
return true;
|
|
3174
|
-
};
|
|
3175
|
-
const saveAndClose = async () => {
|
|
3176
|
-
const saveRes = await saveCode();
|
|
3177
|
-
if (saveRes) {
|
|
3178
|
-
await services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
3179
|
-
}
|
|
3180
|
-
};
|
|
3181
3520
|
const selectHandler = (data) => {
|
|
3182
3521
|
services?.codeBlockService.setId(data.id);
|
|
3183
3522
|
currentTitle.value = data.name;
|
|
3184
3523
|
};
|
|
3185
3524
|
return (_ctx, _cache) => {
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
const _component_el_button = resolveComponent("el-button");
|
|
3189
|
-
const _component_el_card = resolveComponent("el-card");
|
|
3190
|
-
const _component_el_dialog = resolveComponent("el-dialog");
|
|
3191
|
-
return openBlock(), createBlock(_component_el_dialog, {
|
|
3192
|
-
modelValue: unref(isShowCodeBlockEditor),
|
|
3193
|
-
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(isShowCodeBlockEditor) ? isShowCodeBlockEditor.value = $event : null),
|
|
3525
|
+
return openBlock(), createBlock(unref(TMagicDialog), {
|
|
3526
|
+
"model-value": true,
|
|
3194
3527
|
class: "code-editor-dialog",
|
|
3195
3528
|
title: currentTitle.value,
|
|
3196
3529
|
fullscreen: true,
|
|
3197
|
-
"
|
|
3198
|
-
"append-to-body": true
|
|
3530
|
+
"close-on-press-escape": false,
|
|
3531
|
+
"append-to-body": true,
|
|
3532
|
+
"show-close": false
|
|
3199
3533
|
}, {
|
|
3200
3534
|
default: withCtx(() => [
|
|
3201
|
-
createVNode(_sfc_main$
|
|
3535
|
+
createVNode(_sfc_main$o, {
|
|
3202
3536
|
left: left.value,
|
|
3203
|
-
"onUpdate:left": _cache[
|
|
3537
|
+
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
|
|
3204
3538
|
"min-left": 45,
|
|
3205
3539
|
class: "code-editor-layout"
|
|
3206
3540
|
}, createSlots({
|
|
@@ -3212,72 +3546,15 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3212
3546
|
])
|
|
3213
3547
|
}, [
|
|
3214
3548
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: unref(id) }),
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
disabled: !unref(editable)
|
|
3225
|
-
}, null, 8, ["modelValue", "disabled"])) : createCommentVNode("", true)
|
|
3226
|
-
])
|
|
3227
|
-
]),
|
|
3228
|
-
default: withCtx(() => [
|
|
3229
|
-
createElementVNode("div", _hoisted_6$1, [
|
|
3230
|
-
codeConfig.value ? (openBlock(), createBlock(_sfc_main$o, {
|
|
3231
|
-
key: 0,
|
|
3232
|
-
ref_key: "codeEditor",
|
|
3233
|
-
ref: codeEditor,
|
|
3234
|
-
class: "m-editor-container",
|
|
3235
|
-
"init-values": `${codeConfig.value.content}`,
|
|
3236
|
-
onSave: saveCode,
|
|
3237
|
-
options: {
|
|
3238
|
-
tabSize: 2,
|
|
3239
|
-
fontSize: 16,
|
|
3240
|
-
formatOnPaste: true,
|
|
3241
|
-
readOnly: !unref(editable)
|
|
3242
|
-
}
|
|
3243
|
-
}, null, 8, ["init-values", "options"])) : createCommentVNode("", true),
|
|
3244
|
-
unref(editable) ? (openBlock(), createElementBlock("div", _hoisted_7$1, [
|
|
3245
|
-
createVNode(_component_el_button, {
|
|
3246
|
-
type: "primary",
|
|
3247
|
-
class: "button",
|
|
3248
|
-
onClick: saveCode
|
|
3249
|
-
}, {
|
|
3250
|
-
default: withCtx(() => [
|
|
3251
|
-
_hoisted_8$1
|
|
3252
|
-
]),
|
|
3253
|
-
_: 1
|
|
3254
|
-
}),
|
|
3255
|
-
createVNode(_component_el_button, {
|
|
3256
|
-
type: "primary",
|
|
3257
|
-
class: "button",
|
|
3258
|
-
onClick: saveAndClose
|
|
3259
|
-
}, {
|
|
3260
|
-
default: withCtx(() => [
|
|
3261
|
-
_hoisted_9$1
|
|
3262
|
-
]),
|
|
3263
|
-
_: 1
|
|
3264
|
-
})
|
|
3265
|
-
])) : (openBlock(), createElementBlock("div", _hoisted_10, [
|
|
3266
|
-
createVNode(_component_el_button, {
|
|
3267
|
-
type: "primary",
|
|
3268
|
-
class: "button",
|
|
3269
|
-
onClick: saveAndClose
|
|
3270
|
-
}, {
|
|
3271
|
-
default: withCtx(() => [
|
|
3272
|
-
_hoisted_11
|
|
3273
|
-
]),
|
|
3274
|
-
_: 1
|
|
3275
|
-
})
|
|
3276
|
-
]))
|
|
3277
|
-
])
|
|
3278
|
-
]),
|
|
3279
|
-
_: 1
|
|
3280
|
-
})
|
|
3549
|
+
codeConfig.value ? (openBlock(), createBlock(_sfc_main$g, {
|
|
3550
|
+
key: 0,
|
|
3551
|
+
id: unref(id),
|
|
3552
|
+
name: codeConfig.value.name,
|
|
3553
|
+
content: codeConfig.value.content,
|
|
3554
|
+
editable: !!unref(editable),
|
|
3555
|
+
autoSaveDraft: unref(mode) === unref(CodeEditorMode).EDITOR,
|
|
3556
|
+
codeOptions: unref(codeOptions)
|
|
3557
|
+
}, null, 8, ["id", "name", "content", "editable", "autoSaveDraft", "codeOptions"])) : createCommentVNode("", true)
|
|
3281
3558
|
], 2)) : createCommentVNode("", true)
|
|
3282
3559
|
]),
|
|
3283
3560
|
_: 2
|
|
@@ -3285,16 +3562,15 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3285
3562
|
unref(mode) === unref(CodeEditorMode).LIST ? {
|
|
3286
3563
|
name: "left",
|
|
3287
3564
|
fn: withCtx(() => [
|
|
3288
|
-
!unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(
|
|
3565
|
+
!unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
3289
3566
|
key: 0,
|
|
3290
|
-
|
|
3567
|
+
class: "side-tree",
|
|
3291
3568
|
"node-key": "id",
|
|
3292
3569
|
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3293
3570
|
data: state.codeList,
|
|
3294
3571
|
"highlight-current": true,
|
|
3295
|
-
onNodeClick: selectHandler,
|
|
3296
3572
|
"current-node-key": state.codeList[0].id,
|
|
3297
|
-
|
|
3573
|
+
onNodeClick: selectHandler
|
|
3298
3574
|
}, {
|
|
3299
3575
|
default: withCtx(({ data }) => [
|
|
3300
3576
|
createElementVNode("div", {
|
|
@@ -3304,7 +3580,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3304
3580
|
createElementVNode("div", _hoisted_2$3, [
|
|
3305
3581
|
createElementVNode("div", _hoisted_3$1, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1)
|
|
3306
3582
|
])
|
|
3307
|
-
], 8, _hoisted_1$
|
|
3583
|
+
], 8, _hoisted_1$7)
|
|
3308
3584
|
]),
|
|
3309
3585
|
_: 1
|
|
3310
3586
|
}, 8, ["data", "current-node-key"])) : createCommentVNode("", true)
|
|
@@ -3313,12 +3589,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3313
3589
|
]), 1032, ["left"])
|
|
3314
3590
|
]),
|
|
3315
3591
|
_: 3
|
|
3316
|
-
}, 8, ["
|
|
3592
|
+
}, 8, ["title"]);
|
|
3317
3593
|
};
|
|
3318
3594
|
}
|
|
3319
3595
|
});
|
|
3320
3596
|
|
|
3321
|
-
const _hoisted_1$
|
|
3597
|
+
const _hoisted_1$6 = { class: "m-editor-code-block-list" };
|
|
3322
3598
|
const _hoisted_2$2 = { class: "code-header-wrapper" };
|
|
3323
3599
|
const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u65B0\u589E");
|
|
3324
3600
|
const _hoisted_4 = ["id"];
|
|
@@ -3340,8 +3616,11 @@ const _hoisted_9 = /* @__PURE__ */ createElementVNode("svg", {
|
|
|
3340
3616
|
d: "M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"
|
|
3341
3617
|
})
|
|
3342
3618
|
], -1);
|
|
3619
|
+
const __default__$d = defineComponent({
|
|
3620
|
+
name: "MEditorCodeBlockList"
|
|
3621
|
+
});
|
|
3343
3622
|
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
3344
|
-
|
|
3623
|
+
...__default__$d,
|
|
3345
3624
|
props: {
|
|
3346
3625
|
customError: null
|
|
3347
3626
|
},
|
|
@@ -3349,41 +3628,38 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3349
3628
|
const props = __props;
|
|
3350
3629
|
const services = inject("services");
|
|
3351
3630
|
const state = reactive({
|
|
3352
|
-
codeList: []
|
|
3353
|
-
bindComps: {}
|
|
3631
|
+
codeList: []
|
|
3354
3632
|
});
|
|
3355
3633
|
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3356
|
-
const
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
const
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
id: compId,
|
|
3366
|
-
name: getCompName(compId)
|
|
3634
|
+
const isShowCodeBlockEditor = computed(() => services?.codeBlockService.getCodeEditorShowStatus() || false);
|
|
3635
|
+
const codeCombineInfo = ref(null);
|
|
3636
|
+
const getBindCompsByCodeId = (codeId) => {
|
|
3637
|
+
if (!codeCombineInfo.value || !codeCombineInfo.value[codeId])
|
|
3638
|
+
return [];
|
|
3639
|
+
const bindCompsId = Object.keys(codeCombineInfo.value[codeId]);
|
|
3640
|
+
return bindCompsId.map((compId) => ({
|
|
3641
|
+
compId,
|
|
3642
|
+
compName: getCompName(compId)
|
|
3367
3643
|
}));
|
|
3368
|
-
state.bindComps[codeId] = compsInfo;
|
|
3369
3644
|
};
|
|
3370
3645
|
const initList = async () => {
|
|
3371
|
-
const codeDsl = await services?.codeBlockService.getCodeDsl() || null;
|
|
3372
|
-
|
|
3646
|
+
const codeDsl = cloneDeep(await services?.codeBlockService.getCodeDsl()) || null;
|
|
3647
|
+
codeCombineInfo.value = cloneDeep(services?.codeBlockService.getCombineInfo()) || null;
|
|
3648
|
+
if (!codeDsl || !codeCombineInfo.value)
|
|
3373
3649
|
return;
|
|
3374
3650
|
state.codeList = [];
|
|
3375
3651
|
forIn(codeDsl, (value, codeId) => {
|
|
3376
|
-
getBindCompsByCodeId(codeId, value);
|
|
3377
3652
|
state.codeList.push({
|
|
3378
3653
|
id: codeId,
|
|
3379
3654
|
name: value.name,
|
|
3380
3655
|
codeBlockContent: value,
|
|
3381
|
-
showRelation: true
|
|
3656
|
+
showRelation: true,
|
|
3657
|
+
combineInfo: getBindCompsByCodeId(codeId)
|
|
3382
3658
|
});
|
|
3383
3659
|
});
|
|
3384
3660
|
};
|
|
3385
3661
|
watch(
|
|
3386
|
-
() => services?.codeBlockService.
|
|
3662
|
+
[() => services?.codeBlockService.getCodeDslSync(), () => services?.codeBlockService.refreshCombineInfo()],
|
|
3387
3663
|
() => {
|
|
3388
3664
|
initList();
|
|
3389
3665
|
},
|
|
@@ -3392,31 +3668,18 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3392
3668
|
deep: true
|
|
3393
3669
|
}
|
|
3394
3670
|
);
|
|
3395
|
-
watch(
|
|
3396
|
-
() => services?.editorService.get("node"),
|
|
3397
|
-
(curNode) => {
|
|
3398
|
-
if (!curNode?.id)
|
|
3399
|
-
return;
|
|
3400
|
-
forIn(state.bindComps, (bindCompInfo) => {
|
|
3401
|
-
bindCompInfo.forEach((comp) => {
|
|
3402
|
-
if (comp.id === curNode.id) {
|
|
3403
|
-
comp.name = curNode.name;
|
|
3404
|
-
}
|
|
3405
|
-
});
|
|
3406
|
-
});
|
|
3407
|
-
}
|
|
3408
|
-
);
|
|
3409
3671
|
const createCodeBlock = async () => {
|
|
3410
3672
|
const { codeBlockService } = services || {};
|
|
3411
3673
|
if (!codeBlockService) {
|
|
3412
|
-
|
|
3674
|
+
tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
|
|
3413
3675
|
return;
|
|
3414
3676
|
}
|
|
3415
3677
|
const codeConfig = {
|
|
3416
3678
|
name: "\u4EE3\u7801\u5757",
|
|
3417
|
-
content: `() => {
|
|
3679
|
+
content: `({app, params}) => {
|
|
3418
3680
|
// place your code here
|
|
3419
|
-
}
|
|
3681
|
+
}`,
|
|
3682
|
+
params: []
|
|
3420
3683
|
};
|
|
3421
3684
|
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
3422
3685
|
const id = await codeBlockService.getUniqueId();
|
|
@@ -3428,7 +3691,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3428
3691
|
services?.codeBlockService.setCodeEditorContent(true, key);
|
|
3429
3692
|
};
|
|
3430
3693
|
const deleteCode = (key) => {
|
|
3431
|
-
const
|
|
3694
|
+
const currentCode = state.codeList.find((codeItem) => codeItem.id === key);
|
|
3695
|
+
const existBinds = !isEmpty(currentCode?.combineInfo);
|
|
3432
3696
|
const undeleteableList = services?.codeBlockService.getUndeletableList() || [];
|
|
3433
3697
|
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3434
3698
|
services?.codeBlockService.deleteCodeDslByIds([key]);
|
|
@@ -3436,7 +3700,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3436
3700
|
if (typeof props.customError === "function") {
|
|
3437
3701
|
props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
3438
3702
|
} else {
|
|
3439
|
-
|
|
3703
|
+
tMagicMessage.error("\u4EE3\u7801\u5757\u5220\u9664\u5931\u8D25");
|
|
3440
3704
|
}
|
|
3441
3705
|
}
|
|
3442
3706
|
};
|
|
@@ -3468,14 +3732,10 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3468
3732
|
stage?.select(compId);
|
|
3469
3733
|
};
|
|
3470
3734
|
return (_ctx, _cache) => {
|
|
3471
|
-
|
|
3472
|
-
const _component_el_button = resolveComponent("el-button");
|
|
3473
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3474
|
-
const _component_el_tree = resolveComponent("el-tree");
|
|
3475
|
-
return openBlock(), createElementBlock("div", _hoisted_1$5, [
|
|
3735
|
+
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
3476
3736
|
renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
3477
3737
|
createElementVNode("div", _hoisted_2$2, [
|
|
3478
|
-
createVNode(
|
|
3738
|
+
createVNode(unref(TMagicInput), {
|
|
3479
3739
|
class: normalizeClass([unref(editable) ? "code-filter-input" : "code-filter-input-no-btn"]),
|
|
3480
3740
|
size: "small",
|
|
3481
3741
|
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
@@ -3484,7 +3744,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3484
3744
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
|
|
3485
3745
|
onInput: filterTextChangeHandler
|
|
3486
3746
|
}, null, 8, ["class", "modelValue"]),
|
|
3487
|
-
unref(editable) ? (openBlock(), createBlock(
|
|
3747
|
+
unref(editable) ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
3488
3748
|
key: 0,
|
|
3489
3749
|
class: "create-code-button",
|
|
3490
3750
|
type: "primary",
|
|
@@ -3498,7 +3758,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3498
3758
|
})) : createCommentVNode("", true)
|
|
3499
3759
|
])
|
|
3500
3760
|
]),
|
|
3501
|
-
!unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(
|
|
3761
|
+
!unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
3502
3762
|
key: 0,
|
|
3503
3763
|
ref_key: "tree",
|
|
3504
3764
|
ref: tree,
|
|
@@ -3515,15 +3775,15 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3515
3775
|
class: "list-container"
|
|
3516
3776
|
}, [
|
|
3517
3777
|
createElementVNode("div", _hoisted_5, [
|
|
3518
|
-
createElementVNode("
|
|
3778
|
+
createElementVNode("span", _hoisted_6, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1),
|
|
3519
3779
|
createElementVNode("div", _hoisted_7, [
|
|
3520
|
-
createVNode(
|
|
3780
|
+
createVNode(unref(TMagicTooltip), {
|
|
3521
3781
|
effect: "dark",
|
|
3522
3782
|
content: unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
|
|
3523
3783
|
placement: "bottom"
|
|
3524
3784
|
}, {
|
|
3525
3785
|
default: withCtx(() => [
|
|
3526
|
-
createVNode(_sfc_main$
|
|
3786
|
+
createVNode(_sfc_main$n, {
|
|
3527
3787
|
icon: unref(editable) ? unref(Edit) : unref(View),
|
|
3528
3788
|
class: "edit-icon",
|
|
3529
3789
|
onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
@@ -3531,14 +3791,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3531
3791
|
]),
|
|
3532
3792
|
_: 2
|
|
3533
3793
|
}, 1032, ["content"]),
|
|
3534
|
-
|
|
3794
|
+
data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3535
3795
|
key: 0,
|
|
3536
3796
|
effect: "dark",
|
|
3537
3797
|
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3538
3798
|
placement: "bottom"
|
|
3539
3799
|
}, {
|
|
3540
3800
|
default: withCtx(() => [
|
|
3541
|
-
createVNode(_sfc_main$
|
|
3801
|
+
createVNode(_sfc_main$n, {
|
|
3542
3802
|
icon: unref(Link),
|
|
3543
3803
|
class: "edit-icon",
|
|
3544
3804
|
onClick: withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
@@ -3546,14 +3806,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3546
3806
|
]),
|
|
3547
3807
|
_: 2
|
|
3548
3808
|
}, 1024)) : createCommentVNode("", true),
|
|
3549
|
-
unref(editable) ? (openBlock(), createBlock(
|
|
3809
|
+
unref(editable) ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3550
3810
|
key: 1,
|
|
3551
3811
|
effect: "dark",
|
|
3552
3812
|
content: "\u5220\u9664",
|
|
3553
3813
|
placement: "bottom"
|
|
3554
3814
|
}, {
|
|
3555
3815
|
default: withCtx(() => [
|
|
3556
|
-
createVNode(_sfc_main$
|
|
3816
|
+
createVNode(_sfc_main$n, {
|
|
3557
3817
|
icon: unref(Close),
|
|
3558
3818
|
class: "edit-icon",
|
|
3559
3819
|
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
@@ -3567,18 +3827,18 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3567
3827
|
})
|
|
3568
3828
|
])
|
|
3569
3829
|
]),
|
|
3570
|
-
data.showRelation &&
|
|
3830
|
+
data.showRelation && data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
3571
3831
|
_hoisted_9,
|
|
3572
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
3573
|
-
return openBlock(), createBlock(
|
|
3832
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(data.combineInfo, (comp, index) => {
|
|
3833
|
+
return openBlock(), createBlock(unref(TMagicButton), {
|
|
3574
3834
|
key: index,
|
|
3575
3835
|
class: "code-comp",
|
|
3576
3836
|
size: "small",
|
|
3577
3837
|
plain: true,
|
|
3578
|
-
onClick: withModifiers(($event) => selectComp(comp.
|
|
3838
|
+
onClick: withModifiers(($event) => selectComp(comp.compId), ["stop"])
|
|
3579
3839
|
}, {
|
|
3580
3840
|
default: withCtx(() => [
|
|
3581
|
-
createTextVNode(toDisplayString(comp.
|
|
3841
|
+
createTextVNode(toDisplayString(comp.compName), 1)
|
|
3582
3842
|
]),
|
|
3583
3843
|
_: 2
|
|
3584
3844
|
}, 1032, ["onClick"]);
|
|
@@ -3588,21 +3848,23 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3588
3848
|
]),
|
|
3589
3849
|
_: 3
|
|
3590
3850
|
}, 8, ["data"])) : createCommentVNode("", true),
|
|
3591
|
-
|
|
3851
|
+
unref(isShowCodeBlockEditor) ? (openBlock(), createBlock(_sfc_main$f, { key: 1 }, {
|
|
3592
3852
|
"code-block-edit-panel-header": withCtx(({ id }) => [
|
|
3593
3853
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
3594
3854
|
]),
|
|
3595
3855
|
_: 3
|
|
3596
|
-
})
|
|
3856
|
+
})) : createCommentVNode("", true)
|
|
3597
3857
|
]);
|
|
3598
3858
|
};
|
|
3599
3859
|
}
|
|
3600
3860
|
});
|
|
3601
3861
|
|
|
3602
|
-
const _hoisted_1$
|
|
3603
|
-
const
|
|
3862
|
+
const _hoisted_1$5 = ["onClick", "onDragstart"];
|
|
3863
|
+
const __default__$c = defineComponent({
|
|
3864
|
+
name: "MEditorComponentListPanel"
|
|
3865
|
+
});
|
|
3604
3866
|
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
3605
|
-
|
|
3867
|
+
...__default__$c,
|
|
3606
3868
|
setup(__props) {
|
|
3607
3869
|
const searchText = ref("");
|
|
3608
3870
|
const services = inject("services");
|
|
@@ -3615,7 +3877,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3615
3877
|
}))
|
|
3616
3878
|
);
|
|
3617
3879
|
const collapseValue = computed(
|
|
3618
|
-
() => Array(list.value?.length).fill(1).map((x, i) => i)
|
|
3880
|
+
() => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
|
|
3619
3881
|
);
|
|
3620
3882
|
let timeout;
|
|
3621
3883
|
let clientX;
|
|
@@ -3667,36 +3929,31 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3667
3929
|
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
3668
3930
|
};
|
|
3669
3931
|
return (_ctx, _cache) => {
|
|
3670
|
-
|
|
3671
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3672
|
-
const _component_el_collapse_item = resolveComponent("el-collapse-item");
|
|
3673
|
-
const _component_el_collapse = resolveComponent("el-collapse");
|
|
3674
|
-
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
3675
|
-
return openBlock(), createBlock(_component_el_scrollbar, null, {
|
|
3932
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), null, {
|
|
3676
3933
|
default: withCtx(() => [
|
|
3677
3934
|
renderSlot(_ctx.$slots, "component-list-panel-header"),
|
|
3678
|
-
createVNode(
|
|
3935
|
+
createVNode(unref(TMagicCollapse), {
|
|
3679
3936
|
class: "ui-component-panel",
|
|
3680
3937
|
"model-value": unref(collapseValue)
|
|
3681
3938
|
}, {
|
|
3682
3939
|
default: withCtx(() => [
|
|
3683
|
-
createVNode(
|
|
3684
|
-
"prefix-icon": "el-icon-search",
|
|
3940
|
+
createVNode(unref(TMagicInput), {
|
|
3685
3941
|
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
3686
3942
|
class: "search-input",
|
|
3687
3943
|
size: "small",
|
|
3688
3944
|
clearable: "",
|
|
3945
|
+
"prefix-icon": unref(Search),
|
|
3689
3946
|
modelValue: searchText.value,
|
|
3690
3947
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
|
|
3691
|
-
}, null, 8, ["modelValue"]),
|
|
3948
|
+
}, null, 8, ["prefix-icon", "modelValue"]),
|
|
3692
3949
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (group, index) => {
|
|
3693
3950
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
3694
|
-
group.items && group.items.length ? (openBlock(), createBlock(
|
|
3951
|
+
group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
|
|
3695
3952
|
key: index,
|
|
3696
|
-
name: index
|
|
3953
|
+
name: `${index}`
|
|
3697
3954
|
}, {
|
|
3698
3955
|
title: withCtx(() => [
|
|
3699
|
-
|
|
3956
|
+
createVNode(_sfc_main$n, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
3700
3957
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3701
3958
|
]),
|
|
3702
3959
|
default: withCtx(() => [
|
|
@@ -3711,10 +3968,10 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3711
3968
|
onDrag: dragHandler
|
|
3712
3969
|
}, [
|
|
3713
3970
|
renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
3714
|
-
createVNode(_sfc_main$
|
|
3971
|
+
createVNode(_sfc_main$n, {
|
|
3715
3972
|
icon: item.icon
|
|
3716
3973
|
}, null, 8, ["icon"]),
|
|
3717
|
-
createVNode(
|
|
3974
|
+
createVNode(unref(TMagicTooltip), {
|
|
3718
3975
|
effect: "dark",
|
|
3719
3976
|
placement: "bottom",
|
|
3720
3977
|
content: item.text
|
|
@@ -3725,7 +3982,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3725
3982
|
_: 2
|
|
3726
3983
|
}, 1032, ["content"])
|
|
3727
3984
|
])
|
|
3728
|
-
], 40,
|
|
3985
|
+
], 40, _hoisted_1$5);
|
|
3729
3986
|
}), 128))
|
|
3730
3987
|
]),
|
|
3731
3988
|
_: 2
|
|
@@ -3742,8 +3999,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3742
3999
|
}
|
|
3743
4000
|
});
|
|
3744
4001
|
|
|
4002
|
+
const __default__$b = defineComponent({
|
|
4003
|
+
name: "MEditorContentMenu"
|
|
4004
|
+
});
|
|
3745
4005
|
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
3746
|
-
|
|
4006
|
+
...__default__$b,
|
|
3747
4007
|
props: {
|
|
3748
4008
|
menuData: { default: () => [] },
|
|
3749
4009
|
isSubMenu: { type: Boolean, default: false }
|
|
@@ -3822,7 +4082,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3822
4082
|
});
|
|
3823
4083
|
return (_ctx, _cache) => {
|
|
3824
4084
|
const _component_content_menu = resolveComponent("content-menu", true);
|
|
3825
|
-
return __props.menuData.length
|
|
4085
|
+
return __props.menuData.length ? withDirectives((openBlock(), createElementBlock("div", {
|
|
3826
4086
|
key: 0,
|
|
3827
4087
|
class: "magic-editor-content-menu",
|
|
3828
4088
|
ref_key: "menu",
|
|
@@ -3831,7 +4091,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3831
4091
|
}, [
|
|
3832
4092
|
createElementVNode("div", null, [
|
|
3833
4093
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
3834
|
-
return openBlock(), createBlock(_sfc_main$
|
|
4094
|
+
return openBlock(), createBlock(_sfc_main$k, {
|
|
3835
4095
|
"event-type": "mouseup",
|
|
3836
4096
|
data: item,
|
|
3837
4097
|
key: index,
|
|
@@ -3850,21 +4110,29 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3850
4110
|
onHide: hide
|
|
3851
4111
|
}, null, 8, ["menu-data"])
|
|
3852
4112
|
]))
|
|
3853
|
-
], 4))
|
|
4113
|
+
], 4)), [
|
|
4114
|
+
[vShow, visible.value]
|
|
4115
|
+
]) : createCommentVNode("", true);
|
|
3854
4116
|
};
|
|
3855
4117
|
}
|
|
3856
4118
|
});
|
|
3857
4119
|
|
|
4120
|
+
const __default__$a = defineComponent({
|
|
4121
|
+
name: "MEditorLayerMenu"
|
|
4122
|
+
});
|
|
3858
4123
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
3859
|
-
|
|
4124
|
+
...__default__$a,
|
|
4125
|
+
props: {
|
|
4126
|
+
layerContentMenu: null
|
|
4127
|
+
},
|
|
3860
4128
|
setup(__props, { expose }) {
|
|
4129
|
+
const props = __props;
|
|
3861
4130
|
const services = inject("services");
|
|
3862
4131
|
const menu = ref();
|
|
3863
4132
|
const node = computed(() => services?.editorService.get("node"));
|
|
3864
4133
|
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
3865
4134
|
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3866
4135
|
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
3867
|
-
const layerContentMenu = inject("layerContentMenu", []);
|
|
3868
4136
|
const createMenuItems = (group) => group.items.map((component) => ({
|
|
3869
4137
|
text: component.text,
|
|
3870
4138
|
type: "button",
|
|
@@ -3919,7 +4187,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
3919
4187
|
{
|
|
3920
4188
|
type: "button",
|
|
3921
4189
|
text: "\u590D\u5236",
|
|
3922
|
-
icon: markRaw(
|
|
4190
|
+
icon: markRaw(CopyDocument),
|
|
3923
4191
|
display: () => !isRoot.value,
|
|
3924
4192
|
handler: () => {
|
|
3925
4193
|
node.value && services?.editorService.copy(node.value);
|
|
@@ -3934,7 +4202,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
3934
4202
|
node.value && services?.editorService.remove(node.value);
|
|
3935
4203
|
}
|
|
3936
4204
|
},
|
|
3937
|
-
...layerContentMenu
|
|
4205
|
+
...props.layerContentMenu
|
|
3938
4206
|
]);
|
|
3939
4207
|
const show = (e) => {
|
|
3940
4208
|
menu.value?.show(e);
|
|
@@ -3953,398 +4221,365 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
3953
4221
|
}
|
|
3954
4222
|
});
|
|
3955
4223
|
|
|
3956
|
-
const
|
|
3957
|
-
const
|
|
3958
|
-
|
|
3959
|
-
throw new Error("\u6CA1\u6709id");
|
|
3960
|
-
}
|
|
3961
|
-
await editorService?.select(data);
|
|
3962
|
-
editorService?.get("stage")?.select(data.id);
|
|
3963
|
-
};
|
|
3964
|
-
const highlight = (data, editorService) => {
|
|
3965
|
-
if (!data?.id) {
|
|
3966
|
-
throw new Error("\u6CA1\u6709id");
|
|
3967
|
-
}
|
|
3968
|
-
editorService?.highlight(data);
|
|
3969
|
-
editorService?.get("stage")?.highlight(data.id);
|
|
3970
|
-
};
|
|
3971
|
-
const useDrop = (tree, editorService) => ({
|
|
3972
|
-
allowDrop: (draggingNode, dropNode, type) => {
|
|
3973
|
-
const { data } = dropNode || {};
|
|
3974
|
-
const { data: ingData } = draggingNode;
|
|
3975
|
-
const { type: ingType } = ingData;
|
|
3976
|
-
if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
|
|
3977
|
-
return false;
|
|
3978
|
-
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
|
|
3979
|
-
return false;
|
|
3980
|
-
if (!data || !data.type)
|
|
3981
|
-
return false;
|
|
3982
|
-
if (["prev", "next"].includes(type))
|
|
3983
|
-
return true;
|
|
3984
|
-
if (data.items || data.type === "container")
|
|
3985
|
-
return true;
|
|
3986
|
-
return false;
|
|
3987
|
-
},
|
|
3988
|
-
async handleDragEnd(e) {
|
|
3989
|
-
if (!tree.value)
|
|
3990
|
-
return;
|
|
3991
|
-
const { data: node } = e;
|
|
3992
|
-
const parent = editorService?.getParentById(node.id, false);
|
|
3993
|
-
const layout = await editorService?.getLayout(parent);
|
|
3994
|
-
node.style.position = layout;
|
|
3995
|
-
if (layout === Layout.RELATIVE) {
|
|
3996
|
-
node.style.top = 0;
|
|
3997
|
-
node.style.left = 0;
|
|
3998
|
-
}
|
|
3999
|
-
const { data } = tree.value;
|
|
4000
|
-
const [page] = data;
|
|
4001
|
-
editorService?.update(page);
|
|
4002
|
-
}
|
|
4224
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
4225
|
+
const __default__$9 = defineComponent({
|
|
4226
|
+
name: "MEditorLayerPanel"
|
|
4003
4227
|
});
|
|
4004
|
-
const
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4228
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
4229
|
+
...__default__$9,
|
|
4230
|
+
props: {
|
|
4231
|
+
layerContentMenu: null
|
|
4232
|
+
},
|
|
4233
|
+
setup(__props) {
|
|
4234
|
+
const throttleTime = 150;
|
|
4235
|
+
const services = inject("services");
|
|
4236
|
+
const tree = ref();
|
|
4237
|
+
const menu = ref();
|
|
4238
|
+
const editorService = services?.editorService;
|
|
4239
|
+
const page = computed(() => editorService?.get("page"));
|
|
4240
|
+
const values = computed(() => page.value ? [page.value] : []);
|
|
4241
|
+
const selectedNodes = ref([]);
|
|
4242
|
+
const selectedIds = computed(() => selectedNodes.value.map((node) => node.id));
|
|
4243
|
+
const isMultiSelectStatus = ref(false);
|
|
4244
|
+
const spliceNodeKey = ref();
|
|
4245
|
+
const filterText = ref("");
|
|
4246
|
+
const defaultExpandedKeys = computed(() => selectedIds.value.length > 0 ? selectedIds.value : []);
|
|
4247
|
+
editorService?.on("remove", () => {
|
|
4248
|
+
setTimeout(() => {
|
|
4249
|
+
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
4250
|
+
}, 0);
|
|
4251
|
+
});
|
|
4252
|
+
const select = async (data) => {
|
|
4253
|
+
if (!data.id) {
|
|
4254
|
+
throw new Error("\u6CA1\u6709id");
|
|
4255
|
+
}
|
|
4256
|
+
await editorService?.select(data);
|
|
4257
|
+
editorService?.get("stage")?.select(data.id);
|
|
4258
|
+
};
|
|
4259
|
+
const multiSelect = async (data) => {
|
|
4260
|
+
await editorService?.multiSelect(data);
|
|
4261
|
+
editorService?.get("stage")?.multiSelect(data);
|
|
4262
|
+
};
|
|
4263
|
+
const highlight = (data) => {
|
|
4264
|
+
if (!data?.id) {
|
|
4265
|
+
throw new Error("\u6CA1\u6709id");
|
|
4266
|
+
}
|
|
4267
|
+
editorService?.highlight(data);
|
|
4268
|
+
editorService?.get("stage")?.highlight(data.id);
|
|
4269
|
+
};
|
|
4270
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
4271
|
+
const allowDrop = (draggingNode, dropNode, type) => {
|
|
4272
|
+
const { data } = dropNode || {};
|
|
4273
|
+
const { data: ingData } = draggingNode;
|
|
4274
|
+
const { type: ingType } = ingData;
|
|
4275
|
+
if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
|
|
4276
|
+
return false;
|
|
4277
|
+
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
|
|
4278
|
+
return false;
|
|
4279
|
+
if (!data || !data.type)
|
|
4280
|
+
return false;
|
|
4281
|
+
if (["prev", "next"].includes(type))
|
|
4282
|
+
return true;
|
|
4283
|
+
if (data.items || data.type === "container")
|
|
4284
|
+
return true;
|
|
4285
|
+
return false;
|
|
4286
|
+
};
|
|
4287
|
+
const handleDragEnd = async (e) => {
|
|
4288
|
+
if (!tree.value)
|
|
4289
|
+
return;
|
|
4290
|
+
const { data: node } = e;
|
|
4291
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
4292
|
+
const layout = await editorService?.getLayout(parent);
|
|
4293
|
+
node.style.position = layout;
|
|
4294
|
+
if (layout === Layout.RELATIVE) {
|
|
4295
|
+
node.style.top = 0;
|
|
4296
|
+
node.style.left = 0;
|
|
4297
|
+
}
|
|
4298
|
+
const data = tree.value.getData();
|
|
4299
|
+
const [page2] = data;
|
|
4300
|
+
editorService?.update(page2);
|
|
4301
|
+
};
|
|
4302
|
+
const loadItems = (node, resolve) => {
|
|
4303
|
+
if (Array.isArray(node.data)) {
|
|
4304
|
+
return resolve(node.data);
|
|
4305
|
+
}
|
|
4306
|
+
if (Array.isArray(node.data?.items)) {
|
|
4307
|
+
return resolve(node.data?.items);
|
|
4308
|
+
}
|
|
4309
|
+
resolve([]);
|
|
4310
|
+
};
|
|
4311
|
+
const handleCollapse = (data) => {
|
|
4312
|
+
expandedKeys.delete(data.id);
|
|
4313
|
+
};
|
|
4314
|
+
const handleExpand = (data) => {
|
|
4315
|
+
const parent = editorService?.getParentById(data.id);
|
|
4316
|
+
if (!parent?.id)
|
|
4317
|
+
return;
|
|
4318
|
+
expandedKeys.set(parent.id, parent.id);
|
|
4319
|
+
};
|
|
4320
|
+
const filterNode = (value, data) => {
|
|
4321
|
+
if (!value) {
|
|
4322
|
+
return true;
|
|
4323
|
+
}
|
|
4324
|
+
let name = "";
|
|
4325
|
+
if (data.name) {
|
|
4326
|
+
name = data.name;
|
|
4327
|
+
} else if (data.items) {
|
|
4328
|
+
name = "container";
|
|
4329
|
+
}
|
|
4330
|
+
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
4331
|
+
};
|
|
4332
|
+
const filterTextChangeHandler = (val) => {
|
|
4333
|
+
tree.value?.filter(val);
|
|
4334
|
+
};
|
|
4335
|
+
const expandNodes = async () => {
|
|
4010
4336
|
if (!tree.value)
|
|
4011
4337
|
return;
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
watchEffect(() => {
|
|
4016
|
-
if (!tree.value)
|
|
4017
|
-
return;
|
|
4018
|
-
if (!editorService)
|
|
4019
|
-
return;
|
|
4020
|
-
node.value = editorService.get("node");
|
|
4021
|
-
if (!node.value)
|
|
4022
|
-
return;
|
|
4023
|
-
tree.value.setCurrentKey(node.value.id, true);
|
|
4024
|
-
const parent = editorService.get("parent");
|
|
4025
|
-
if (!parent?.id)
|
|
4026
|
-
return;
|
|
4027
|
-
const treeNode = tree.value.getNode(parent.id);
|
|
4028
|
-
treeNode?.updateChildren();
|
|
4029
|
-
setTimeout(() => {
|
|
4030
|
-
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
4031
|
-
if (node2.expanded && node2.data.items) {
|
|
4338
|
+
await nextTick();
|
|
4339
|
+
tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
|
|
4340
|
+
if (node.expanded && node.data.items) {
|
|
4032
4341
|
expandedKeys.set(id, id);
|
|
4033
4342
|
}
|
|
4034
4343
|
});
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4344
|
+
expandedKeys.forEach((key) => {
|
|
4345
|
+
if (!tree.value)
|
|
4346
|
+
return;
|
|
4347
|
+
tree.value.getNode(key)?.expand();
|
|
4348
|
+
});
|
|
4349
|
+
};
|
|
4350
|
+
watch(
|
|
4351
|
+
() => editorService?.get("nodes"),
|
|
4352
|
+
(nodes) => {
|
|
4353
|
+
selectedNodes.value = nodes ?? [];
|
|
4043
4354
|
}
|
|
4044
|
-
|
|
4045
|
-
|
|
4355
|
+
);
|
|
4356
|
+
const setTreeKeyStatus = () => {
|
|
4357
|
+
if (!tree.value)
|
|
4358
|
+
return;
|
|
4359
|
+
if (selectedIds.value.length === 0) {
|
|
4360
|
+
tree.value.setCheckedKeys([]);
|
|
4361
|
+
tree.value.setCurrentKey();
|
|
4362
|
+
} else if (selectedIds.value.length === 1 && !isMultiSelectStatus.value) {
|
|
4363
|
+
tree.value.setCurrentKey(selectedIds.value[0], true);
|
|
4364
|
+
tree.value.setCheckedKeys([]);
|
|
4365
|
+
} else {
|
|
4366
|
+
tree.value.setCheckedKeys(selectedIds.value);
|
|
4367
|
+
tree.value.setCurrentKey();
|
|
4046
4368
|
}
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
handleCollapse: (data) => {
|
|
4053
|
-
expandedKeys.delete(data.id);
|
|
4054
|
-
},
|
|
4055
|
-
handleExpand: (data) => {
|
|
4056
|
-
const parent = editorService?.getParentById(data.id);
|
|
4369
|
+
};
|
|
4370
|
+
watch([selectedIds, tree], async () => {
|
|
4371
|
+
if (!tree.value || !editorService)
|
|
4372
|
+
return;
|
|
4373
|
+
const parent = editorService.get("parent");
|
|
4057
4374
|
if (!parent?.id)
|
|
4058
4375
|
return;
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
const menu = ref();
|
|
4376
|
+
const treeNode = tree.value.getNode(parent.id);
|
|
4377
|
+
treeNode?.updateChildren();
|
|
4378
|
+
await expandNodes();
|
|
4379
|
+
setTreeKeyStatus();
|
|
4380
|
+
});
|
|
4381
|
+
const mouseenterHandler = () => {
|
|
4382
|
+
tree.value?.$el.focus();
|
|
4383
|
+
};
|
|
4384
|
+
const mouseleaveHandler = () => {
|
|
4385
|
+
tree.value?.$el.blur();
|
|
4386
|
+
isMultiSelectStatus.value = false;
|
|
4387
|
+
};
|
|
4388
|
+
let keycon;
|
|
4389
|
+
onMounted(() => {
|
|
4390
|
+
keycon = new KeyController(tree.value?.$el);
|
|
4391
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4392
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
4393
|
+
keycon.keydown(ctrl, (e) => {
|
|
4394
|
+
e.inputEvent.preventDefault();
|
|
4395
|
+
isMultiSelectStatus.value = true;
|
|
4396
|
+
}).keyup(ctrl, (e) => {
|
|
4397
|
+
e.inputEvent.preventDefault();
|
|
4398
|
+
isMultiSelectStatus.value = false;
|
|
4399
|
+
});
|
|
4400
|
+
});
|
|
4401
|
+
onUnmounted(() => {
|
|
4402
|
+
keycon.destroy();
|
|
4403
|
+
});
|
|
4088
4404
|
const clicked = ref(false);
|
|
4089
|
-
const
|
|
4405
|
+
const highlightNode = computed(() => editorService?.get("highlightNode"));
|
|
4090
4406
|
const highlightHandler = throttle((data) => {
|
|
4091
|
-
highlight(data
|
|
4407
|
+
highlight(data);
|
|
4092
4408
|
}, throttleTime);
|
|
4093
4409
|
const toggleClickFlag = () => {
|
|
4094
4410
|
clicked.value = !clicked.value;
|
|
4095
4411
|
};
|
|
4096
|
-
const
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4412
|
+
const canHighlight = (data) => {
|
|
4413
|
+
if (clicked.value)
|
|
4414
|
+
return false;
|
|
4415
|
+
return data.id === highlightNode?.value?.id && !selectedIds.value.includes(data.id) && spliceNodeKey.value !== data.id;
|
|
4416
|
+
};
|
|
4417
|
+
watch(isMultiSelectStatus, () => {
|
|
4418
|
+
if (isMultiSelectStatus.value && selectedNodes.value.length === 1 && selectedNodes.value[0].type === NodeType.PAGE) {
|
|
4419
|
+
selectedNodes.value = [];
|
|
4420
|
+
}
|
|
4104
4421
|
});
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4422
|
+
const multiClickHandler = (data) => {
|
|
4423
|
+
if (!data?.id) {
|
|
4424
|
+
throw new Error("\u6CA1\u6709id");
|
|
4425
|
+
}
|
|
4426
|
+
if (data.type === NodeType.PAGE) {
|
|
4427
|
+
tree.value?.setCheckedKeys([]);
|
|
4428
|
+
return;
|
|
4429
|
+
}
|
|
4430
|
+
const index = selectedNodes.value.findIndex((node) => node.id === data.id);
|
|
4431
|
+
if (index !== -1) {
|
|
4432
|
+
selectedNodes.value.splice(index, 1);
|
|
4433
|
+
spliceNodeKey.value = data.id;
|
|
4434
|
+
} else {
|
|
4435
|
+
selectedNodes.value = [...selectedNodes.value, data];
|
|
4436
|
+
}
|
|
4437
|
+
tree.value?.setCheckedKeys(selectedIds.value);
|
|
4438
|
+
multiSelect(selectedIds.value);
|
|
4439
|
+
};
|
|
4440
|
+
const clickHandler = (data) => {
|
|
4441
|
+
if (!isMultiSelectStatus.value) {
|
|
4115
4442
|
if (services?.uiService.get("uiSelectMode")) {
|
|
4116
4443
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
4117
4444
|
return;
|
|
4118
4445
|
}
|
|
4119
4446
|
tree.value?.setCurrentKey(data.id);
|
|
4120
|
-
select(data
|
|
4121
|
-
}
|
|
4122
|
-
|
|
4123
|
-
event.preventDefault();
|
|
4124
|
-
await select(data, editorService);
|
|
4125
|
-
menu.value?.show(event);
|
|
4447
|
+
select(data);
|
|
4448
|
+
} else {
|
|
4449
|
+
multiClickHandler(data);
|
|
4126
4450
|
}
|
|
4127
4451
|
};
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
for (const [key, val] of props) {
|
|
4134
|
-
target[key] = val;
|
|
4135
|
-
}
|
|
4136
|
-
return target;
|
|
4137
|
-
};
|
|
4138
|
-
|
|
4139
|
-
const _hoisted_1$3 = ["id", "onMouseenter"];
|
|
4140
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4141
|
-
const _component_el_input = resolveComponent("el-input");
|
|
4142
|
-
const _component_el_tree = resolveComponent("el-tree");
|
|
4143
|
-
const _component_layer_menu = resolveComponent("layer-menu");
|
|
4144
|
-
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
4145
|
-
return openBlock(), createBlock(_component_el_scrollbar, { class: "magic-editor-layer-panel" }, {
|
|
4146
|
-
default: withCtx(() => [
|
|
4147
|
-
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
4148
|
-
createVNode(_component_el_input, {
|
|
4149
|
-
class: "filterInput",
|
|
4150
|
-
size: "small",
|
|
4151
|
-
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
4152
|
-
clearable: "",
|
|
4153
|
-
modelValue: _ctx.filterText,
|
|
4154
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.filterText = $event),
|
|
4155
|
-
onChange: _ctx.filterTextChangeHandler
|
|
4156
|
-
}, null, 8, ["modelValue", "onChange"]),
|
|
4157
|
-
_ctx.values.length ? (openBlock(), createBlock(_component_el_tree, {
|
|
4158
|
-
key: 0,
|
|
4159
|
-
ref: "tree",
|
|
4160
|
-
"node-key": "id",
|
|
4161
|
-
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
4162
|
-
draggable: "",
|
|
4163
|
-
"default-expanded-keys": _ctx.expandedKeys,
|
|
4164
|
-
load: _ctx.loadItems,
|
|
4165
|
-
data: _ctx.values,
|
|
4166
|
-
"expand-on-click-node": false,
|
|
4167
|
-
"highlight-current": true,
|
|
4168
|
-
props: {
|
|
4169
|
-
children: "items"
|
|
4170
|
-
},
|
|
4171
|
-
"filter-node-method": _ctx.filterNode,
|
|
4172
|
-
"allow-drop": _ctx.allowDrop,
|
|
4173
|
-
onNodeClick: _ctx.clickHandler,
|
|
4174
|
-
onNodeContextmenu: _ctx.contextmenu,
|
|
4175
|
-
onNodeDragEnd: _ctx.handleDragEnd,
|
|
4176
|
-
onNodeCollapse: _ctx.handleCollapse,
|
|
4177
|
-
onNodeExpand: _ctx.handleExpand
|
|
4178
|
-
}, {
|
|
4179
|
-
default: withCtx(({ node, data }) => [
|
|
4180
|
-
createElementVNode("div", {
|
|
4181
|
-
id: data.id,
|
|
4182
|
-
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
4183
|
-
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
4184
|
-
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
4185
|
-
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
4186
|
-
}, [
|
|
4187
|
-
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4188
|
-
node,
|
|
4189
|
-
data
|
|
4190
|
-
}, () => [
|
|
4191
|
-
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
4192
|
-
])
|
|
4193
|
-
], 42, _hoisted_1$3)
|
|
4194
|
-
]),
|
|
4195
|
-
_: 3
|
|
4196
|
-
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
|
|
4197
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4198
|
-
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
4199
|
-
]))
|
|
4200
|
-
]),
|
|
4201
|
-
_: 3
|
|
4202
|
-
});
|
|
4203
|
-
}
|
|
4204
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$1]]);
|
|
4205
|
-
|
|
4206
|
-
const _hoisted_1$2 = {
|
|
4207
|
-
key: 1,
|
|
4208
|
-
class: "magic-editor-tab-panel-title"
|
|
4209
|
-
};
|
|
4210
|
-
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
4211
|
-
__name: "TabPane",
|
|
4212
|
-
props: {
|
|
4213
|
-
data: null
|
|
4214
|
-
},
|
|
4215
|
-
setup(__props) {
|
|
4216
|
-
const props = __props;
|
|
4217
|
-
const config = computed(() => {
|
|
4218
|
-
if (typeof props.data !== "string") {
|
|
4219
|
-
return props.data;
|
|
4220
|
-
}
|
|
4221
|
-
switch (props.data) {
|
|
4222
|
-
case "component-list":
|
|
4223
|
-
return {
|
|
4224
|
-
type: "component",
|
|
4225
|
-
icon: Coin,
|
|
4226
|
-
text: "\u7EC4\u4EF6",
|
|
4227
|
-
component: _sfc_main$d,
|
|
4228
|
-
slots: {}
|
|
4229
|
-
};
|
|
4230
|
-
case "layer":
|
|
4231
|
-
return {
|
|
4232
|
-
type: "component",
|
|
4233
|
-
icon: Files,
|
|
4234
|
-
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
4235
|
-
component: LayerPanel,
|
|
4236
|
-
slots: {}
|
|
4237
|
-
};
|
|
4238
|
-
case "code-block":
|
|
4239
|
-
return {
|
|
4240
|
-
type: "component",
|
|
4241
|
-
icon: EditPen,
|
|
4242
|
-
text: "\u4EE3\u7801\u7F16\u8F91",
|
|
4243
|
-
component: _sfc_main$e,
|
|
4244
|
-
slots: {}
|
|
4245
|
-
};
|
|
4246
|
-
default:
|
|
4247
|
-
return void 0;
|
|
4248
|
-
}
|
|
4249
|
-
});
|
|
4452
|
+
const contextmenu = async (event, data) => {
|
|
4453
|
+
event.preventDefault();
|
|
4454
|
+
await select(data);
|
|
4455
|
+
menu.value?.show(event);
|
|
4456
|
+
};
|
|
4250
4457
|
return (_ctx, _cache) => {
|
|
4251
|
-
|
|
4252
|
-
return unref(config) ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
4253
|
-
key: 0,
|
|
4254
|
-
name: unref(config).text
|
|
4255
|
-
}, {
|
|
4256
|
-
label: withCtx(() => [
|
|
4257
|
-
(openBlock(), createElementBlock("div", {
|
|
4258
|
-
key: unref(config).text
|
|
4259
|
-
}, [
|
|
4260
|
-
unref(config).icon ? (openBlock(), createBlock(_sfc_main$j, {
|
|
4261
|
-
key: 0,
|
|
4262
|
-
icon: unref(config).icon
|
|
4263
|
-
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
4264
|
-
unref(config).text ? (openBlock(), createElementBlock("div", _hoisted_1$2, toDisplayString(unref(config).text), 1)) : createCommentVNode("", true)
|
|
4265
|
-
]))
|
|
4266
|
-
]),
|
|
4458
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
|
|
4267
4459
|
default: withCtx(() => [
|
|
4268
|
-
(
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4460
|
+
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
4461
|
+
createVNode(unref(TMagicInput), {
|
|
4462
|
+
modelValue: filterText.value,
|
|
4463
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
|
|
4464
|
+
class: "search-input",
|
|
4465
|
+
size: "small",
|
|
4466
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
4467
|
+
clearable: "",
|
|
4468
|
+
"prefix-icon": unref(Search),
|
|
4469
|
+
onChange: filterTextChangeHandler
|
|
4470
|
+
}, null, 8, ["modelValue", "prefix-icon"]),
|
|
4471
|
+
unref(values).length ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
4472
|
+
key: 0,
|
|
4473
|
+
tabindex: "-1",
|
|
4474
|
+
class: "magic-editor-layer-tree",
|
|
4475
|
+
ref_key: "tree",
|
|
4476
|
+
ref: tree,
|
|
4477
|
+
"node-key": "id",
|
|
4478
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
4479
|
+
draggable: "",
|
|
4480
|
+
"default-expanded-keys": unref(defaultExpandedKeys),
|
|
4481
|
+
load: loadItems,
|
|
4482
|
+
data: unref(values),
|
|
4483
|
+
"default-expand-all": true,
|
|
4484
|
+
"expand-on-click-node": false,
|
|
4485
|
+
"highlight-current": true,
|
|
4486
|
+
props: {
|
|
4487
|
+
children: "items"
|
|
4488
|
+
},
|
|
4489
|
+
"filter-node-method": filterNode,
|
|
4490
|
+
"allow-drop": allowDrop,
|
|
4491
|
+
"show-checkbox": isMultiSelectStatus.value || unref(selectedIds).length > 1,
|
|
4492
|
+
onNodeClick: clickHandler,
|
|
4493
|
+
onNodeContextmenu: contextmenu,
|
|
4494
|
+
onNodeDragEnd: handleDragEnd,
|
|
4495
|
+
onNodeCollapse: handleCollapse,
|
|
4496
|
+
onNodeExpand: handleExpand,
|
|
4497
|
+
onCheck: multiClickHandler,
|
|
4498
|
+
onMousedown: toggleClickFlag,
|
|
4499
|
+
onMouseup: toggleClickFlag,
|
|
4500
|
+
onMouseenter: mouseenterHandler,
|
|
4501
|
+
onMouseleave: mouseleaveHandler
|
|
4502
|
+
}, {
|
|
4503
|
+
default: withCtx(({ node, data }) => [
|
|
4504
|
+
createElementVNode("div", {
|
|
4505
|
+
id: data.id,
|
|
4506
|
+
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": canHighlight(data) }]),
|
|
4507
|
+
onMouseenter: ($event) => unref(highlightHandler)(data)
|
|
4508
|
+
}, [
|
|
4509
|
+
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4510
|
+
node,
|
|
4305
4511
|
data
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
fn: withCtx(({ data: nodeData, node }) => [
|
|
4321
|
-
__props.data === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4322
|
-
key: 0,
|
|
4323
|
-
data: nodeData,
|
|
4324
|
-
node
|
|
4325
|
-
}) : unref(config).slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.layerNodeContent), {
|
|
4326
|
-
key: 1,
|
|
4327
|
-
data: nodeData,
|
|
4328
|
-
node
|
|
4329
|
-
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
4330
|
-
])
|
|
4331
|
-
} : void 0
|
|
4332
|
-
]), 1040))
|
|
4512
|
+
}, () => [
|
|
4513
|
+
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
4514
|
+
])
|
|
4515
|
+
], 42, _hoisted_1$4)
|
|
4516
|
+
]),
|
|
4517
|
+
_: 3
|
|
4518
|
+
}, 8, ["default-expanded-keys", "data", "show-checkbox"])) : createCommentVNode("", true),
|
|
4519
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4520
|
+
createVNode(_sfc_main$b, {
|
|
4521
|
+
ref_key: "menu",
|
|
4522
|
+
ref: menu,
|
|
4523
|
+
"layer-content-menu": __props.layerContentMenu
|
|
4524
|
+
}, null, 8, ["layer-content-menu"])
|
|
4525
|
+
]))
|
|
4333
4526
|
]),
|
|
4334
4527
|
_: 3
|
|
4335
|
-
}
|
|
4528
|
+
});
|
|
4336
4529
|
};
|
|
4337
4530
|
}
|
|
4338
4531
|
});
|
|
4339
4532
|
|
|
4340
|
-
const
|
|
4341
|
-
|
|
4533
|
+
const _hoisted_1$3 = {
|
|
4534
|
+
key: 1,
|
|
4535
|
+
class: "magic-editor-tab-panel-title"
|
|
4536
|
+
};
|
|
4537
|
+
const __default__$8 = defineComponent({
|
|
4538
|
+
name: "MEditorSidebar"
|
|
4539
|
+
});
|
|
4540
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
4541
|
+
...__default__$8,
|
|
4342
4542
|
props: {
|
|
4343
|
-
data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) }
|
|
4543
|
+
data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) },
|
|
4544
|
+
layerContentMenu: null
|
|
4344
4545
|
},
|
|
4345
4546
|
setup(__props, { expose }) {
|
|
4346
4547
|
const props = __props;
|
|
4548
|
+
const uiComponent = getConfig$1("components").tabPane;
|
|
4347
4549
|
const activeTabName = ref(props.data?.status);
|
|
4550
|
+
const getItemConfig = (data) => {
|
|
4551
|
+
const map = {
|
|
4552
|
+
"component-list": {
|
|
4553
|
+
$key: "component-list",
|
|
4554
|
+
type: "component",
|
|
4555
|
+
icon: Coin,
|
|
4556
|
+
text: "\u7EC4\u4EF6",
|
|
4557
|
+
component: _sfc_main$d,
|
|
4558
|
+
slots: {}
|
|
4559
|
+
},
|
|
4560
|
+
layer: {
|
|
4561
|
+
$key: "layer",
|
|
4562
|
+
type: "component",
|
|
4563
|
+
icon: Files,
|
|
4564
|
+
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
4565
|
+
props: {
|
|
4566
|
+
layerContentMenu: props.layerContentMenu
|
|
4567
|
+
},
|
|
4568
|
+
component: _sfc_main$a,
|
|
4569
|
+
slots: {}
|
|
4570
|
+
},
|
|
4571
|
+
"code-block": {
|
|
4572
|
+
$key: "code-block",
|
|
4573
|
+
type: "component",
|
|
4574
|
+
icon: EditPen,
|
|
4575
|
+
text: "\u4EE3\u7801\u7F16\u8F91",
|
|
4576
|
+
component: _sfc_main$e,
|
|
4577
|
+
slots: {}
|
|
4578
|
+
}
|
|
4579
|
+
};
|
|
4580
|
+
return typeof data === "string" ? map[data] : data;
|
|
4581
|
+
};
|
|
4582
|
+
const sideBarItems = computed(() => props.data.items.map((item) => getItemConfig(item)));
|
|
4348
4583
|
watch(
|
|
4349
4584
|
() => props.data.status,
|
|
4350
4585
|
(status) => {
|
|
@@ -4355,8 +4590,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
4355
4590
|
activeTabName
|
|
4356
4591
|
});
|
|
4357
4592
|
return (_ctx, _cache) => {
|
|
4358
|
-
|
|
4359
|
-
return __props.data.type === "tabs" && __props.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
4593
|
+
return __props.data.type === "tabs" && __props.data.items.length ? (openBlock(), createBlock(unref(TMagicTabs), {
|
|
4360
4594
|
key: 0,
|
|
4361
4595
|
class: "m-editor-sidebar",
|
|
4362
4596
|
modelValue: activeTabName.value,
|
|
@@ -4365,60 +4599,91 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
4365
4599
|
"tab-position": "left"
|
|
4366
4600
|
}, {
|
|
4367
4601
|
default: withCtx(() => [
|
|
4368
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
4369
|
-
return openBlock(), createBlock(
|
|
4602
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(sideBarItems), (config, index) => {
|
|
4603
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(uiComponent).component), {
|
|
4370
4604
|
key: index,
|
|
4371
|
-
|
|
4372
|
-
},
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4605
|
+
name: config.text
|
|
4606
|
+
}, {
|
|
4607
|
+
label: withCtx(() => [
|
|
4608
|
+
(openBlock(), createElementBlock("div", {
|
|
4609
|
+
key: config.text
|
|
4610
|
+
}, [
|
|
4611
|
+
config.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
4612
|
+
key: 0,
|
|
4613
|
+
icon: config.icon
|
|
4614
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
4615
|
+
config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(config.text), 1)) : createCommentVNode("", true)
|
|
4616
|
+
]))
|
|
4617
|
+
]),
|
|
4618
|
+
default: withCtx(() => [
|
|
4619
|
+
config ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({ key: 0 }, config.props || {}, toHandlers(config?.listeners || {})), createSlots({ _: 2 }, [
|
|
4620
|
+
config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
|
|
4621
|
+
name: "component-list-panel-header",
|
|
4622
|
+
fn: withCtx(() => [
|
|
4623
|
+
config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4624
|
+
])
|
|
4625
|
+
} : void 0,
|
|
4626
|
+
config.$key === "component-list" || config.slots?.componentListItem ? {
|
|
4627
|
+
name: "component-list-item",
|
|
4628
|
+
fn: withCtx(({ component }) => [
|
|
4629
|
+
config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
|
|
4630
|
+
key: 0,
|
|
4631
|
+
component
|
|
4632
|
+
}) : config.slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentListItem), {
|
|
4633
|
+
key: 1,
|
|
4634
|
+
component
|
|
4635
|
+
}, null, 8, ["component"])) : createCommentVNode("", true)
|
|
4636
|
+
])
|
|
4637
|
+
} : void 0,
|
|
4638
|
+
config.$key === "layer" || config.slots?.layerPanelHeader ? {
|
|
4639
|
+
name: "layer-panel-header",
|
|
4640
|
+
fn: withCtx(() => [
|
|
4641
|
+
config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4642
|
+
])
|
|
4643
|
+
} : void 0,
|
|
4644
|
+
config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
|
|
4645
|
+
name: "code-block-panel-header",
|
|
4646
|
+
fn: withCtx(() => [
|
|
4647
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : config.slots?.codeBlockPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4648
|
+
])
|
|
4649
|
+
} : void 0,
|
|
4650
|
+
config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
|
|
4651
|
+
name: "code-block-panel-tool",
|
|
4652
|
+
fn: withCtx(({ id, data }) => [
|
|
4653
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4654
|
+
key: 0,
|
|
4655
|
+
id,
|
|
4656
|
+
data
|
|
4657
|
+
}) : config.slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("", true)
|
|
4658
|
+
])
|
|
4659
|
+
} : void 0,
|
|
4660
|
+
config.$key === "code-block" || config.slots?.codeBlockEditPanelHeader ? {
|
|
4661
|
+
name: "code-block-edit-panel-header",
|
|
4662
|
+
fn: withCtx(({ id }) => [
|
|
4663
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
|
|
4664
|
+
key: 0,
|
|
4665
|
+
id
|
|
4666
|
+
}) : config.slots?.codeBlockEditPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockEditPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4667
|
+
])
|
|
4668
|
+
} : void 0,
|
|
4669
|
+
config.$key === "layer" || config.slots?.layerNodeContent ? {
|
|
4670
|
+
name: "layer-node-content",
|
|
4671
|
+
fn: withCtx(({ data: nodeData, node }) => [
|
|
4672
|
+
config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4673
|
+
key: 0,
|
|
4674
|
+
data: nodeData,
|
|
4675
|
+
node
|
|
4676
|
+
}) : config.slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerNodeContent), {
|
|
4677
|
+
key: 1,
|
|
4678
|
+
data: nodeData,
|
|
4679
|
+
node
|
|
4680
|
+
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
4681
|
+
])
|
|
4682
|
+
} : void 0
|
|
4683
|
+
]), 1040)) : createCommentVNode("", true)
|
|
4684
|
+
]),
|
|
4685
|
+
_: 2
|
|
4686
|
+
}, 1032, ["name"]);
|
|
4422
4687
|
}), 128))
|
|
4423
4688
|
]),
|
|
4424
4689
|
_: 3
|
|
@@ -4427,12 +4692,60 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
4427
4692
|
}
|
|
4428
4693
|
});
|
|
4429
4694
|
|
|
4695
|
+
const _hoisted_1$2 = {
|
|
4696
|
+
key: 0,
|
|
4697
|
+
class: "m-editor-breadcrumb"
|
|
4698
|
+
};
|
|
4699
|
+
const _hoisted_2$1 = { key: 0 };
|
|
4700
|
+
const __default__$7 = defineComponent({
|
|
4701
|
+
name: "MEditorBreadcrumb"
|
|
4702
|
+
});
|
|
4703
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
4704
|
+
...__default__$7,
|
|
4705
|
+
setup(__props) {
|
|
4706
|
+
const services = inject("services");
|
|
4707
|
+
const editorService = services?.editorService;
|
|
4708
|
+
const node = computed(() => editorService?.get("node"));
|
|
4709
|
+
const nodes = computed(() => editorService?.get("nodes") || []);
|
|
4710
|
+
const root = computed(() => editorService?.get("root"));
|
|
4711
|
+
const path = computed(() => getNodePath(node.value?.id || "", root.value?.items || []));
|
|
4712
|
+
const select = async (node2) => {
|
|
4713
|
+
await editorService?.select(node2);
|
|
4714
|
+
editorService?.get("stage")?.select(node2.id);
|
|
4715
|
+
};
|
|
4716
|
+
return (_ctx, _cache) => {
|
|
4717
|
+
return unref(nodes).length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
4718
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(path), (item, index) => {
|
|
4719
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
4720
|
+
key: item.id
|
|
4721
|
+
}, [
|
|
4722
|
+
createVNode(unref(TMagicButton), {
|
|
4723
|
+
text: "",
|
|
4724
|
+
disabled: item.id === unref(node)?.id,
|
|
4725
|
+
onClick: ($event) => select(item)
|
|
4726
|
+
}, {
|
|
4727
|
+
default: withCtx(() => [
|
|
4728
|
+
createTextVNode(toDisplayString(item.name), 1)
|
|
4729
|
+
]),
|
|
4730
|
+
_: 2
|
|
4731
|
+
}, 1032, ["disabled", "onClick"]),
|
|
4732
|
+
index < unref(path).length - 1 ? (openBlock(), createElementBlock("span", _hoisted_2$1, "/")) : createCommentVNode("", true)
|
|
4733
|
+
], 64);
|
|
4734
|
+
}), 128))
|
|
4735
|
+
])) : createCommentVNode("", true);
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
});
|
|
4739
|
+
|
|
4430
4740
|
const _hoisted_1$1 = {
|
|
4431
4741
|
key: 1,
|
|
4432
4742
|
style: { "width": "21px" }
|
|
4433
4743
|
};
|
|
4744
|
+
const __default__$6 = defineComponent({
|
|
4745
|
+
name: "MEditorPageBarScrollContainer"
|
|
4746
|
+
});
|
|
4434
4747
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
4435
|
-
|
|
4748
|
+
...__default__$6,
|
|
4436
4749
|
setup(__props) {
|
|
4437
4750
|
const services = inject("services");
|
|
4438
4751
|
const editorService = services?.editorService;
|
|
@@ -4513,14 +4826,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4513
4826
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4514
4827
|
onClick: addPage
|
|
4515
4828
|
}, [
|
|
4516
|
-
createVNode(_sfc_main$
|
|
4829
|
+
createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
4517
4830
|
])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
|
|
4518
4831
|
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
4519
4832
|
key: 2,
|
|
4520
4833
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4521
4834
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
4522
4835
|
}, [
|
|
4523
|
-
createVNode(_sfc_main$
|
|
4836
|
+
createVNode(_sfc_main$n, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
|
|
4524
4837
|
])) : createCommentVNode("", true),
|
|
4525
4838
|
unref(pageLength) ? (openBlock(), createElementBlock("div", {
|
|
4526
4839
|
key: 3,
|
|
@@ -4536,7 +4849,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4536
4849
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4537
4850
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
4538
4851
|
}, [
|
|
4539
|
-
createVNode(_sfc_main$
|
|
4852
|
+
createVNode(_sfc_main$n, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
|
|
4540
4853
|
])) : createCommentVNode("", true)
|
|
4541
4854
|
], 512);
|
|
4542
4855
|
};
|
|
@@ -4545,8 +4858,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4545
4858
|
|
|
4546
4859
|
const _hoisted_1 = ["onClick"];
|
|
4547
4860
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
4861
|
+
const __default__$5 = defineComponent({
|
|
4862
|
+
name: "MEditorPageBar"
|
|
4863
|
+
});
|
|
4548
4864
|
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
4549
|
-
|
|
4865
|
+
...__default__$5,
|
|
4550
4866
|
setup(__props) {
|
|
4551
4867
|
const services = inject("services");
|
|
4552
4868
|
const editorService = services?.editorService;
|
|
@@ -4566,9 +4882,6 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4566
4882
|
editorService?.remove(node);
|
|
4567
4883
|
};
|
|
4568
4884
|
return (_ctx, _cache) => {
|
|
4569
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
4570
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
4571
|
-
const _component_el_popover = resolveComponent("el-popover");
|
|
4572
4885
|
return openBlock(), createBlock(_sfc_main$7, null, {
|
|
4573
4886
|
default: withCtx(() => [
|
|
4574
4887
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
|
|
@@ -4579,7 +4892,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4579
4892
|
}, [
|
|
4580
4893
|
createElementVNode("div", _hoisted_2, [
|
|
4581
4894
|
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
4582
|
-
createVNode(
|
|
4895
|
+
createVNode(unref(TMagicTooltip), {
|
|
4583
4896
|
effect: "dark",
|
|
4584
4897
|
placement: "top-start",
|
|
4585
4898
|
content: item.name
|
|
@@ -4591,14 +4904,14 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4591
4904
|
}, 1032, ["content"])
|
|
4592
4905
|
])
|
|
4593
4906
|
]),
|
|
4594
|
-
createVNode(
|
|
4907
|
+
createVNode(unref(TMagicPopover), {
|
|
4595
4908
|
"popper-class": "page-bar-popover",
|
|
4596
4909
|
placement: "top",
|
|
4597
4910
|
width: 160,
|
|
4598
4911
|
trigger: "hover"
|
|
4599
4912
|
}, {
|
|
4600
4913
|
reference: withCtx(() => [
|
|
4601
|
-
createVNode(
|
|
4914
|
+
createVNode(unref(TMagicIcon), { class: "m-editor-page-bar-menu-icon" }, {
|
|
4602
4915
|
default: withCtx(() => [
|
|
4603
4916
|
createVNode(unref(CaretBottom))
|
|
4604
4917
|
]),
|
|
@@ -4608,7 +4921,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4608
4921
|
default: withCtx(() => [
|
|
4609
4922
|
createElementVNode("div", null, [
|
|
4610
4923
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
4611
|
-
createVNode(_sfc_main$
|
|
4924
|
+
createVNode(_sfc_main$k, {
|
|
4612
4925
|
data: {
|
|
4613
4926
|
type: "button",
|
|
4614
4927
|
text: "\u590D\u5236",
|
|
@@ -4616,7 +4929,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4616
4929
|
handler: () => copy(item)
|
|
4617
4930
|
}
|
|
4618
4931
|
}, null, 8, ["data"]),
|
|
4619
|
-
createVNode(_sfc_main$
|
|
4932
|
+
createVNode(_sfc_main$k, {
|
|
4620
4933
|
data: {
|
|
4621
4934
|
type: "button",
|
|
4622
4935
|
text: "\u5220\u9664",
|
|
@@ -4650,6 +4963,10 @@ class ScrollViewer extends EventEmitter {
|
|
|
4650
4963
|
height = 0;
|
|
4651
4964
|
translateXCorrectionValue = 0;
|
|
4652
4965
|
translateYCorrectionValue = 0;
|
|
4966
|
+
correctionScrollSize = {
|
|
4967
|
+
width: 0,
|
|
4968
|
+
height: 0
|
|
4969
|
+
};
|
|
4653
4970
|
resizeObserver = new ResizeObserver(() => {
|
|
4654
4971
|
this.setSize();
|
|
4655
4972
|
this.setScrollSize();
|
|
@@ -4659,6 +4976,12 @@ class ScrollViewer extends EventEmitter {
|
|
|
4659
4976
|
this.container = options.container;
|
|
4660
4977
|
this.target = options.target;
|
|
4661
4978
|
this.zoom = options.zoom;
|
|
4979
|
+
if (this.correctionScrollSize) {
|
|
4980
|
+
this.correctionScrollSize = {
|
|
4981
|
+
...this.correctionScrollSize,
|
|
4982
|
+
...options.correctionScrollSize
|
|
4983
|
+
};
|
|
4984
|
+
}
|
|
4662
4985
|
this.container.addEventListener("wheel", this.wheelHandler, false);
|
|
4663
4986
|
this.setSize();
|
|
4664
4987
|
this.setScrollSize();
|
|
@@ -4721,9 +5044,9 @@ class ScrollViewer extends EventEmitter {
|
|
|
4721
5044
|
}
|
|
4722
5045
|
setScrollSize = () => {
|
|
4723
5046
|
const targetRect = this.target.getBoundingClientRect();
|
|
4724
|
-
this.scrollWidth = targetRect.width * this.zoom +
|
|
5047
|
+
this.scrollWidth = targetRect.width * this.zoom + this.correctionScrollSize.width;
|
|
4725
5048
|
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
4726
|
-
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom +
|
|
5049
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + this.correctionScrollSize.height;
|
|
4727
5050
|
let left;
|
|
4728
5051
|
let top;
|
|
4729
5052
|
if (this.scrollWidth < this.width) {
|
|
@@ -4756,8 +5079,11 @@ class ScrollViewer extends EventEmitter {
|
|
|
4756
5079
|
};
|
|
4757
5080
|
}
|
|
4758
5081
|
|
|
5082
|
+
const __default__$4 = defineComponent({
|
|
5083
|
+
name: "MEditorScrollBar"
|
|
5084
|
+
});
|
|
4759
5085
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
4760
|
-
|
|
5086
|
+
...__default__$4,
|
|
4761
5087
|
props: {
|
|
4762
5088
|
size: null,
|
|
4763
5089
|
scrollSize: null,
|
|
@@ -4842,14 +5168,21 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
4842
5168
|
|
|
4843
5169
|
const ScrollBar_vue_vue_type_style_index_0_lang = '';
|
|
4844
5170
|
|
|
5171
|
+
const __default__$3 = defineComponent({
|
|
5172
|
+
name: "MEditorScrollViewer"
|
|
5173
|
+
});
|
|
4845
5174
|
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
4846
|
-
|
|
5175
|
+
...__default__$3,
|
|
4847
5176
|
props: {
|
|
4848
5177
|
width: { default: 0 },
|
|
4849
5178
|
height: { default: 0 },
|
|
4850
5179
|
wrapWidth: { default: 0 },
|
|
4851
5180
|
wrapHeight: { default: 0 },
|
|
4852
|
-
zoom: { default: 1 }
|
|
5181
|
+
zoom: { default: 1 },
|
|
5182
|
+
correctionScrollSize: { default: () => ({
|
|
5183
|
+
width: 0,
|
|
5184
|
+
height: 0
|
|
5185
|
+
}) }
|
|
4853
5186
|
},
|
|
4854
5187
|
setup(__props, { expose }) {
|
|
4855
5188
|
const props = __props;
|
|
@@ -4872,7 +5205,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
4872
5205
|
scrollViewer = new ScrollViewer({
|
|
4873
5206
|
container: container.value,
|
|
4874
5207
|
target: el.value,
|
|
4875
|
-
zoom: props.zoom
|
|
5208
|
+
zoom: props.zoom,
|
|
5209
|
+
correctionScrollSize: props.correctionScrollSize
|
|
4876
5210
|
});
|
|
4877
5211
|
scrollViewer.on("scroll", (data) => {
|
|
4878
5212
|
hOffset.value = data.scrollLeft;
|
|
@@ -4940,10 +5274,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
4940
5274
|
}
|
|
4941
5275
|
});
|
|
4942
5276
|
|
|
5277
|
+
const __default__$2 = defineComponent({
|
|
5278
|
+
name: "MEditorViewerMenu"
|
|
5279
|
+
});
|
|
4943
5280
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
4944
|
-
|
|
5281
|
+
...__default__$2,
|
|
4945
5282
|
props: {
|
|
4946
|
-
isMultiSelect: { type: Boolean, default: false }
|
|
5283
|
+
isMultiSelect: { type: Boolean, default: false },
|
|
5284
|
+
stageContentMenu: null
|
|
4947
5285
|
},
|
|
4948
5286
|
setup(__props, { expose }) {
|
|
4949
5287
|
const props = __props;
|
|
@@ -4956,8 +5294,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
4956
5294
|
const nodes = computed(() => editorService?.get("nodes"));
|
|
4957
5295
|
const parent = computed(() => editorService?.get("parent"));
|
|
4958
5296
|
const stage = computed(() => editorService?.get("stage"));
|
|
4959
|
-
const
|
|
4960
|
-
const menuData = reactive([
|
|
5297
|
+
const menuData = computed(() => [
|
|
4961
5298
|
{
|
|
4962
5299
|
type: "button",
|
|
4963
5300
|
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
@@ -4971,7 +5308,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
4971
5308
|
{
|
|
4972
5309
|
type: "button",
|
|
4973
5310
|
text: "\u590D\u5236",
|
|
4974
|
-
icon: markRaw(
|
|
5311
|
+
icon: markRaw(CopyDocument),
|
|
4975
5312
|
handler: () => {
|
|
4976
5313
|
nodes.value && editorService?.copy(nodes.value);
|
|
4977
5314
|
canPaste.value = true;
|
|
@@ -4980,6 +5317,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
4980
5317
|
{
|
|
4981
5318
|
type: "button",
|
|
4982
5319
|
text: "\u7C98\u8D34",
|
|
5320
|
+
icon: markRaw(DocumentCopy),
|
|
4983
5321
|
display: () => canPaste.value,
|
|
4984
5322
|
handler: () => {
|
|
4985
5323
|
const rect = menu.value?.$el.getBoundingClientRect();
|
|
@@ -5059,7 +5397,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5059
5397
|
editorService?.get("stage").clearGuides();
|
|
5060
5398
|
}
|
|
5061
5399
|
},
|
|
5062
|
-
...stageContentMenu
|
|
5400
|
+
...props.stageContentMenu
|
|
5063
5401
|
]);
|
|
5064
5402
|
watch(
|
|
5065
5403
|
parent,
|
|
@@ -5083,7 +5421,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5083
5421
|
expose({ show });
|
|
5084
5422
|
return (_ctx, _cache) => {
|
|
5085
5423
|
return openBlock(), createBlock(_sfc_main$c, {
|
|
5086
|
-
"menu-data": menuData,
|
|
5424
|
+
"menu-data": unref(menuData),
|
|
5087
5425
|
ref_key: "menu",
|
|
5088
5426
|
ref: menu
|
|
5089
5427
|
}, null, 8, ["menu-data"]);
|
|
@@ -5091,8 +5429,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5091
5429
|
}
|
|
5092
5430
|
});
|
|
5093
5431
|
|
|
5432
|
+
const __default__$1 = defineComponent({
|
|
5433
|
+
name: "MEditorStage"
|
|
5434
|
+
});
|
|
5094
5435
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
5095
|
-
|
|
5436
|
+
...__default__$1,
|
|
5437
|
+
props: {
|
|
5438
|
+
stageContentMenu: null
|
|
5439
|
+
},
|
|
5096
5440
|
setup(__props) {
|
|
5097
5441
|
let stage = null;
|
|
5098
5442
|
let runtime = null;
|
|
@@ -5109,7 +5453,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5109
5453
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
5110
5454
|
const node = computed(() => services?.editorService.get("node"));
|
|
5111
5455
|
watchEffect(() => {
|
|
5112
|
-
if (stage)
|
|
5456
|
+
if (stage || !page.value)
|
|
5113
5457
|
return;
|
|
5114
5458
|
if (!stageContainer.value)
|
|
5115
5459
|
return;
|
|
@@ -5139,6 +5483,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5139
5483
|
runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
|
|
5140
5484
|
}
|
|
5141
5485
|
});
|
|
5486
|
+
watch(page, (page2) => {
|
|
5487
|
+
if (runtime && page2) {
|
|
5488
|
+
runtime.updatePageId?.(page2.id);
|
|
5489
|
+
nextTick(() => {
|
|
5490
|
+
stage?.select(page2.id);
|
|
5491
|
+
});
|
|
5492
|
+
}
|
|
5493
|
+
});
|
|
5142
5494
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
5143
5495
|
for (const { contentRect } of entries) {
|
|
5144
5496
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -5211,7 +5563,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5211
5563
|
height: unref(stageRect)?.height,
|
|
5212
5564
|
"wrap-width": unref(stageContainerRect)?.width,
|
|
5213
5565
|
"wrap-height": unref(stageContainerRect)?.height,
|
|
5214
|
-
zoom: unref(zoom)
|
|
5566
|
+
zoom: unref(zoom),
|
|
5567
|
+
"correction-scroll-size": {
|
|
5568
|
+
width: 60,
|
|
5569
|
+
height: 50
|
|
5570
|
+
}
|
|
5215
5571
|
}, {
|
|
5216
5572
|
default: withCtx(() => [
|
|
5217
5573
|
createElementVNode("div", {
|
|
@@ -5227,8 +5583,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5227
5583
|
createVNode(_sfc_main$3, {
|
|
5228
5584
|
ref_key: "menu",
|
|
5229
5585
|
ref: menu,
|
|
5230
|
-
"is-multi-select": unref(isMultiSelect)
|
|
5231
|
-
|
|
5586
|
+
"is-multi-select": unref(isMultiSelect),
|
|
5587
|
+
"stage-content-menu": __props.stageContentMenu
|
|
5588
|
+
}, null, 8, ["is-multi-select", "stage-content-menu"])
|
|
5232
5589
|
]))
|
|
5233
5590
|
]),
|
|
5234
5591
|
_: 1
|
|
@@ -5237,8 +5594,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5237
5594
|
}
|
|
5238
5595
|
});
|
|
5239
5596
|
|
|
5597
|
+
const __default__ = defineComponent({
|
|
5598
|
+
name: "MEditorWorkspace"
|
|
5599
|
+
});
|
|
5240
5600
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
5241
|
-
|
|
5601
|
+
...__default__,
|
|
5602
|
+
props: {
|
|
5603
|
+
stageContentMenu: null
|
|
5604
|
+
},
|
|
5242
5605
|
setup(__props) {
|
|
5243
5606
|
const services = inject("services");
|
|
5244
5607
|
const workspace = ref();
|
|
@@ -5347,10 +5710,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
5347
5710
|
ref_key: "workspace",
|
|
5348
5711
|
ref: workspace
|
|
5349
5712
|
}, [
|
|
5713
|
+
createVNode(_sfc_main$8),
|
|
5350
5714
|
renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
5351
|
-
(openBlock(), createBlock(_sfc_main$2, {
|
|
5352
|
-
key:
|
|
5353
|
-
|
|
5715
|
+
unref(page) ? (openBlock(), createBlock(_sfc_main$2, {
|
|
5716
|
+
key: 0,
|
|
5717
|
+
"stage-content-menu": __props.stageContentMenu
|
|
5718
|
+
}, null, 8, ["stage-content-menu"])) : createCommentVNode("", true)
|
|
5354
5719
|
]),
|
|
5355
5720
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
5356
5721
|
createVNode(_sfc_main$6, null, {
|
|
@@ -5390,11 +5755,11 @@ const componentListService = new ComponentList();
|
|
|
5390
5755
|
const _sfc_main = defineComponent({
|
|
5391
5756
|
name: "m-editor",
|
|
5392
5757
|
components: {
|
|
5393
|
-
NavMenu: _sfc_main$
|
|
5394
|
-
Sidebar: _sfc_main$
|
|
5758
|
+
NavMenu: _sfc_main$j,
|
|
5759
|
+
Sidebar: _sfc_main$9,
|
|
5395
5760
|
Workspace: _sfc_main$1,
|
|
5396
|
-
PropsPanel: _sfc_main$
|
|
5397
|
-
Framework: _sfc_main$
|
|
5761
|
+
PropsPanel: _sfc_main$i,
|
|
5762
|
+
Framework: _sfc_main$l
|
|
5398
5763
|
},
|
|
5399
5764
|
props: {
|
|
5400
5765
|
modelValue: {
|
|
@@ -5409,6 +5774,10 @@ const _sfc_main = defineComponent({
|
|
|
5409
5774
|
sidebar: {
|
|
5410
5775
|
type: Object
|
|
5411
5776
|
},
|
|
5777
|
+
menu: {
|
|
5778
|
+
type: Object,
|
|
5779
|
+
default: () => ({ left: [], right: [] })
|
|
5780
|
+
},
|
|
5412
5781
|
layerContentMenu: {
|
|
5413
5782
|
type: Array,
|
|
5414
5783
|
default: () => []
|
|
@@ -5417,10 +5786,6 @@ const _sfc_main = defineComponent({
|
|
|
5417
5786
|
type: Array,
|
|
5418
5787
|
default: () => []
|
|
5419
5788
|
},
|
|
5420
|
-
menu: {
|
|
5421
|
-
type: Object,
|
|
5422
|
-
default: () => ({ left: [], right: [] })
|
|
5423
|
-
},
|
|
5424
5789
|
render: {
|
|
5425
5790
|
type: Function
|
|
5426
5791
|
},
|
|
@@ -5454,7 +5819,7 @@ const _sfc_main = defineComponent({
|
|
|
5454
5819
|
},
|
|
5455
5820
|
containerHighlightClassName: {
|
|
5456
5821
|
type: String,
|
|
5457
|
-
default:
|
|
5822
|
+
default: CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
5458
5823
|
},
|
|
5459
5824
|
containerHighlightDuration: {
|
|
5460
5825
|
type: Number,
|
|
@@ -5478,14 +5843,23 @@ const _sfc_main = defineComponent({
|
|
|
5478
5843
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
5479
5844
|
setup(props, { emit }) {
|
|
5480
5845
|
editorService.on("root-change", (value) => {
|
|
5481
|
-
const
|
|
5482
|
-
|
|
5483
|
-
if (nodeId
|
|
5484
|
-
editorService.
|
|
5485
|
-
}
|
|
5846
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
5847
|
+
let node;
|
|
5848
|
+
if (nodeId) {
|
|
5849
|
+
node = editorService.getNodeById(nodeId);
|
|
5850
|
+
}
|
|
5851
|
+
if (node && node !== value) {
|
|
5852
|
+
editorService.select(node.id);
|
|
5853
|
+
} else if (value?.items?.length) {
|
|
5854
|
+
editorService.select(value.items[0]);
|
|
5855
|
+
} else if (value?.id) {
|
|
5486
5856
|
editorService.set("nodes", [value]);
|
|
5857
|
+
editorService.set("parent", null);
|
|
5858
|
+
editorService.set("page", null);
|
|
5859
|
+
}
|
|
5860
|
+
if (toRaw(value) !== toRaw(editorService.get("root"))) {
|
|
5861
|
+
emit("update:modelValue", value);
|
|
5487
5862
|
}
|
|
5488
|
-
emit("update:modelValue", toRaw(editorService.get("root")));
|
|
5489
5863
|
});
|
|
5490
5864
|
watch(
|
|
5491
5865
|
() => props.modelValue,
|
|
@@ -5567,8 +5941,7 @@ const _sfc_main = defineComponent({
|
|
|
5567
5941
|
codeBlockService
|
|
5568
5942
|
};
|
|
5569
5943
|
provide("services", services);
|
|
5570
|
-
provide("
|
|
5571
|
-
provide("stageContentMenu", props.stageContentMenu);
|
|
5944
|
+
provide("codeOptions", props.codeOptions);
|
|
5572
5945
|
provide(
|
|
5573
5946
|
"stageOptions",
|
|
5574
5947
|
reactive({
|
|
@@ -5588,21 +5961,32 @@ const _sfc_main = defineComponent({
|
|
|
5588
5961
|
}
|
|
5589
5962
|
});
|
|
5590
5963
|
|
|
5964
|
+
const _export_sfc = (sfc, props) => {
|
|
5965
|
+
const target = sfc.__vccOpts || sfc;
|
|
5966
|
+
for (const [key, val] of props) {
|
|
5967
|
+
target[key] = val;
|
|
5968
|
+
}
|
|
5969
|
+
return target;
|
|
5970
|
+
};
|
|
5971
|
+
|
|
5591
5972
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
5592
|
-
const
|
|
5593
|
-
const
|
|
5594
|
-
const
|
|
5595
|
-
const
|
|
5596
|
-
const
|
|
5597
|
-
return openBlock(), createBlock(
|
|
5973
|
+
const _component_NavMenu = resolveComponent("NavMenu");
|
|
5974
|
+
const _component_Sidebar = resolveComponent("Sidebar");
|
|
5975
|
+
const _component_Workspace = resolveComponent("Workspace");
|
|
5976
|
+
const _component_PropsPanel = resolveComponent("PropsPanel");
|
|
5977
|
+
const _component_Framework = resolveComponent("Framework");
|
|
5978
|
+
return openBlock(), createBlock(_component_Framework, { "code-options": _ctx.codeOptions }, {
|
|
5598
5979
|
nav: withCtx(() => [
|
|
5599
5980
|
renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
5600
|
-
createVNode(
|
|
5981
|
+
createVNode(_component_NavMenu, { data: _ctx.menu }, null, 8, ["data"])
|
|
5601
5982
|
])
|
|
5602
5983
|
]),
|
|
5603
5984
|
sidebar: withCtx(() => [
|
|
5604
5985
|
renderSlot(_ctx.$slots, "sidebar", { editorService: _ctx.editorService }, () => [
|
|
5605
|
-
createVNode(
|
|
5986
|
+
createVNode(_component_Sidebar, {
|
|
5987
|
+
data: _ctx.sidebar,
|
|
5988
|
+
"layer-content-menu": _ctx.layerContentMenu
|
|
5989
|
+
}, {
|
|
5606
5990
|
"layer-panel-header": withCtx(() => [
|
|
5607
5991
|
renderSlot(_ctx.$slots, "layer-panel-header")
|
|
5608
5992
|
]),
|
|
@@ -5631,12 +6015,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
5631
6015
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
5632
6016
|
]),
|
|
5633
6017
|
_: 3
|
|
5634
|
-
}, 8, ["data"])
|
|
6018
|
+
}, 8, ["data", "layer-content-menu"])
|
|
5635
6019
|
])
|
|
5636
6020
|
]),
|
|
5637
6021
|
workspace: withCtx(() => [
|
|
5638
6022
|
renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
5639
|
-
createVNode(
|
|
6023
|
+
createVNode(_component_Workspace, { "stage-content-menu": _ctx.stageContentMenu }, {
|
|
5640
6024
|
stage: withCtx(() => [
|
|
5641
6025
|
renderSlot(_ctx.$slots, "stage")
|
|
5642
6026
|
]),
|
|
@@ -5650,12 +6034,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
5650
6034
|
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
5651
6035
|
]),
|
|
5652
6036
|
_: 3
|
|
5653
|
-
})
|
|
6037
|
+
}, 8, ["stage-content-menu"])
|
|
5654
6038
|
])
|
|
5655
6039
|
]),
|
|
5656
6040
|
"props-panel": withCtx(() => [
|
|
5657
6041
|
renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
5658
|
-
createVNode(
|
|
6042
|
+
createVNode(_component_PropsPanel, {
|
|
5659
6043
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
5660
6044
|
}, {
|
|
5661
6045
|
"props-panel-header": withCtx(() => [
|
|
@@ -5682,13 +6066,13 @@ const index = {
|
|
|
5682
6066
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
5683
6067
|
setConfig(option);
|
|
5684
6068
|
app.component(Editor.name, Editor);
|
|
5685
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
5686
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
5687
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
5688
|
-
app.component("magic-code-editor", _sfc_main$
|
|
5689
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
6069
|
+
app.component("m-fields-ui-select", _sfc_main$r);
|
|
6070
|
+
app.component("m-fields-code-link", _sfc_main$t);
|
|
6071
|
+
app.component("m-fields-vs-code", _sfc_main$u);
|
|
6072
|
+
app.component("magic-code-editor", _sfc_main$q);
|
|
6073
|
+
app.component("m-fields-code-select", _sfc_main$s);
|
|
5690
6074
|
}
|
|
5691
6075
|
};
|
|
5692
6076
|
|
|
5693
|
-
export { COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, CodeEditorMode, _sfc_main$
|
|
6077
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, CodeEditorMode, _sfc_main$s as CodeSelect, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$n as Icon, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$o as LayoutContainer, _sfc_main$i as PropsPanel, _sfc_main$q as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$k as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
5694
6078
|
//# sourceMappingURL=tmagic-editor.mjs.map
|