@tmagic/editor 1.2.0-beta.9 → 1.2.0
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 +59 -35
- package/dist/{tmagic-editor.mjs → tmagic-editor.js} +1473 -1154
- package/dist/tmagic-editor.js.map +1 -0
- package/dist/{tmagic-editor.umd.js → tmagic-editor.umd.cjs} +1483 -1159
- package/dist/tmagic-editor.umd.cjs.map +1 -0
- package/package.json +16 -14
- package/src/Editor.vue +66 -40
- package/src/components/CodeDraftEditor.vue +145 -0
- package/src/components/ContentMenu.vue +1 -1
- package/src/components/FunctionEditor.vue +145 -0
- package/src/components/Icon.vue +1 -1
- package/src/{layouts → components}/Layout.vue +54 -15
- package/src/components/ScrollBar.vue +1 -1
- package/src/components/ScrollViewer.vue +10 -1
- package/src/components/ToolButton.vue +1 -1
- package/src/fields/Code.vue +1 -1
- package/src/fields/CodeLink.vue +1 -1
- package/src/fields/CodeSelect.vue +89 -102
- package/src/fields/UISelect.vue +1 -1
- package/src/index.ts +1 -0
- package/src/layouts/AddPageBox.vue +1 -1
- package/src/layouts/CodeEditor.vue +2 -3
- package/src/layouts/Framework.vue +2 -2
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/PropsPanel.vue +13 -6
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
- package/src/layouts/sidebar/LayerMenu.vue +9 -7
- package/src/layouts/sidebar/LayerPanel.vue +127 -174
- package/src/layouts/sidebar/Sidebar.vue +110 -26
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +27 -83
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +90 -122
- package/src/layouts/workspace/Breadcrumb.vue +1 -1
- package/src/layouts/workspace/PageBar.vue +1 -1
- 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 +7 -3
- package/src/services/BaseService.ts +10 -1
- package/src/services/codeBlock.ts +124 -125
- package/src/services/componentList.ts +6 -1
- package/src/services/editor.ts +54 -18
- package/src/services/events.ts +6 -1
- package/src/services/history.ts +7 -16
- package/src/services/props.ts +7 -2
- package/src/services/storage.ts +1 -0
- package/src/services/ui.ts +12 -0
- package/src/theme/code-block.scss +43 -24
- package/src/theme/component-list-panel.scss +8 -5
- package/src/type.ts +77 -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 +4 -3
- package/types/Editor.vue.d.ts +47 -27
- package/types/components/CodeDraftEditor.vue.d.ts +56 -0
- package/types/components/ContentMenu.vue.d.ts +11 -87
- package/types/components/FunctionEditor.vue.d.ts +43 -0
- package/types/components/Icon.vue.d.ts +4 -50
- package/types/{layouts → components}/Layout.vue.d.ts +12 -1
- package/types/components/ScrollBar.vue.d.ts +7 -65
- package/types/components/ScrollViewer.vue.d.ts +45 -1
- package/types/components/ToolButton.vue.d.ts +12 -78
- package/types/fields/Code.vue.d.ts +11 -77
- package/types/fields/CodeLink.vue.d.ts +12 -82
- package/types/fields/CodeSelect.vue.d.ts +13 -77
- package/types/fields/UISelect.vue.d.ts +7 -65
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +1 -43
- package/types/layouts/CodeEditor.vue.d.ts +22 -130
- package/types/layouts/NavMenu.vue.d.ts +9 -69
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +16 -48
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +24 -7
- 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/workspace/Breadcrumb.vue.d.ts +1 -43
- package/types/layouts/workspace/Stage.vue.d.ts +15 -43
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +11 -66
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/BaseService.d.ts +2 -1
- package/types/services/codeBlock.d.ts +57 -36
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +5 -6
- package/types/services/events.d.ts +1 -0
- package/types/services/history.d.ts +5 -15
- package/types/services/props.d.ts +3 -2
- package/types/services/ui.d.ts +2 -1
- package/types/type.d.ts +65 -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/dist/tmagic-editor.mjs.map +0 -1
- package/dist/tmagic-editor.umd.js.map +0 -1
- package/src/layouts/sidebar/TabPane.vue +0 -118
- package/types/layouts/sidebar/TabPane.vue.d.ts +0 -82
|
@@ -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, difference, union } 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$t = /* @__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$s = /* @__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$e = { 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$r = /* @__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,119 +136,107 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
174
136
|
setup(__props, { emit }) {
|
|
175
137
|
const props = __props;
|
|
176
138
|
const services = inject("services");
|
|
177
|
-
const
|
|
178
|
-
const
|
|
139
|
+
const mForm = inject("mForm");
|
|
140
|
+
const codeDsl = computed(() => services?.codeBlockService.getCodeDslSync());
|
|
141
|
+
const tableConfig = computed(() => {
|
|
179
142
|
const defaultConfig = {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
189
179
|
}
|
|
190
|
-
|
|
191
|
-
}
|
|
180
|
+
]
|
|
192
181
|
};
|
|
193
182
|
return {
|
|
194
183
|
...defaultConfig,
|
|
195
|
-
...props.config.
|
|
184
|
+
...props.config.tableConfig
|
|
196
185
|
};
|
|
197
186
|
});
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
fieldKey.value = combineNames.join("-");
|
|
211
|
-
});
|
|
212
|
-
const changeHandler = async (value) => {
|
|
213
|
-
let codeIds = value;
|
|
214
|
-
if (typeof value === "string") {
|
|
215
|
-
multiple.value = false;
|
|
216
|
-
codeIds = value ? [value] : [];
|
|
217
|
-
}
|
|
218
|
-
await setCombineRelation(codeIds);
|
|
219
|
-
emit("change", value);
|
|
220
|
-
};
|
|
221
|
-
const setCombineRelation = async (codeIds) => {
|
|
222
|
-
const { id = "" } = services?.editorService.get("node") || {};
|
|
223
|
-
let opFlag = CodeSelectOp.CHANGE;
|
|
224
|
-
let diffValues = codeIds;
|
|
225
|
-
if (multiple.value) {
|
|
226
|
-
lastTagSnapshot.value = form?.initValues[props.name] || [];
|
|
227
|
-
opFlag = codeIds.length < lastTagSnapshot.value.length ? CodeSelectOp.DELETE : CodeSelectOp.ADD;
|
|
228
|
-
diffValues = xor(codeIds, lastTagSnapshot.value);
|
|
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
|
|
229
199
|
}
|
|
230
|
-
|
|
200
|
+
);
|
|
201
|
+
const changeHandler = async () => {
|
|
202
|
+
emit("change", props.model[props.name]);
|
|
231
203
|
};
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
+
}));
|
|
240
216
|
};
|
|
241
217
|
return (_ctx, _cache) => {
|
|
242
|
-
const
|
|
243
|
-
return openBlock(), createElementBlock("div",
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
name: __props.name,
|
|
254
|
-
size: __props.size,
|
|
255
|
-
onChange: changeHandler
|
|
256
|
-
}, null, 8, ["config", "model", "prop", "name", "size"])
|
|
257
|
-
]),
|
|
258
|
-
default: withCtx(() => [
|
|
259
|
-
createElementVNode("div", _hoisted_1$e, [
|
|
260
|
-
createVNode(unref(TMagicTooltip), {
|
|
261
|
-
class: "tool-item",
|
|
262
|
-
effect: "dark",
|
|
263
|
-
content: "\u67E5\u770B\u4EE3\u7801\u5757",
|
|
264
|
-
placement: "top"
|
|
265
|
-
}, {
|
|
266
|
-
default: withCtx(() => [
|
|
267
|
-
(openBlock(), createElementBlock("svg", {
|
|
268
|
-
onClick: viewHandler,
|
|
269
|
-
preserveAspectRatio: "xMidYMid meet",
|
|
270
|
-
viewBox: "0 0 24 24",
|
|
271
|
-
width: "15px",
|
|
272
|
-
height: "15px",
|
|
273
|
-
"data-v-65a7fb6c": ""
|
|
274
|
-
}, _hoisted_3$3))
|
|
275
|
-
]),
|
|
276
|
-
_: 1
|
|
277
|
-
})
|
|
278
|
-
])
|
|
279
|
-
]),
|
|
280
|
-
_: 1
|
|
281
|
-
})
|
|
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"])
|
|
282
229
|
]);
|
|
283
230
|
};
|
|
284
231
|
}
|
|
285
232
|
});
|
|
286
233
|
|
|
287
|
-
const _hoisted_1$
|
|
288
|
-
const
|
|
289
|
-
|
|
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,
|
|
290
240
|
props: {
|
|
291
241
|
config: null,
|
|
292
242
|
model: null,
|
|
@@ -348,7 +298,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
348
298
|
style: { "padding": "0" }
|
|
349
299
|
}, {
|
|
350
300
|
default: withCtx(() => [
|
|
351
|
-
_hoisted_1$
|
|
301
|
+
_hoisted_1$f
|
|
352
302
|
]),
|
|
353
303
|
_: 1
|
|
354
304
|
}, 8, ["icon"])
|
|
@@ -396,12 +346,15 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
396
346
|
|
|
397
347
|
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
398
348
|
|
|
399
|
-
const
|
|
400
|
-
|
|
349
|
+
const __default__$p = defineComponent({
|
|
350
|
+
name: "MEditorCodeEditor"
|
|
351
|
+
});
|
|
352
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
353
|
+
...__default__$p,
|
|
401
354
|
props: {
|
|
402
355
|
initValues: null,
|
|
403
356
|
modifiedValues: null,
|
|
404
|
-
type:
|
|
357
|
+
type: null,
|
|
405
358
|
language: { default: "javascript" },
|
|
406
359
|
options: { default: () => ({
|
|
407
360
|
tabSize: 2
|
|
@@ -526,9 +479,182 @@ const setConfig = (option) => {
|
|
|
526
479
|
};
|
|
527
480
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
528
481
|
|
|
529
|
-
const
|
|
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
|
+
});
|
|
530
521
|
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
531
|
-
|
|
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.right !== "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,
|
|
532
658
|
props: {
|
|
533
659
|
icon: null
|
|
534
660
|
},
|
|
@@ -547,7 +673,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
547
673
|
class: "magic-editor-icon"
|
|
548
674
|
}, {
|
|
549
675
|
default: withCtx(() => [
|
|
550
|
-
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$
|
|
676
|
+
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$e)
|
|
551
677
|
]),
|
|
552
678
|
_: 1
|
|
553
679
|
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
@@ -566,6 +692,42 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
566
692
|
}
|
|
567
693
|
});
|
|
568
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
|
+
|
|
569
731
|
const log = (...args) => {
|
|
570
732
|
if (process.env.NODE_ENV === "development") {
|
|
571
733
|
console.log("magic editor: ", ...args);
|
|
@@ -695,6 +857,14 @@ class BaseService extends EventEmitter {
|
|
|
695
857
|
this.pluginOptionsList[methodName2].push(method);
|
|
696
858
|
});
|
|
697
859
|
}
|
|
860
|
+
removeAllPlugins() {
|
|
861
|
+
Object.keys(this.pluginOptionsList).forEach((key) => {
|
|
862
|
+
this.pluginOptionsList[key] = [];
|
|
863
|
+
});
|
|
864
|
+
Object.keys(this.middleware).forEach((key) => {
|
|
865
|
+
this.middleware[key] = [];
|
|
866
|
+
});
|
|
867
|
+
}
|
|
698
868
|
async doTask() {
|
|
699
869
|
this.doingTask = true;
|
|
700
870
|
let task = this.taskList.shift();
|
|
@@ -714,7 +884,8 @@ class CodeBlock extends BaseService {
|
|
|
714
884
|
editable: true,
|
|
715
885
|
mode: CodeEditorMode.EDITOR,
|
|
716
886
|
combineIds: [],
|
|
717
|
-
undeletableList: []
|
|
887
|
+
undeletableList: [],
|
|
888
|
+
relations: {}
|
|
718
889
|
});
|
|
719
890
|
constructor() {
|
|
720
891
|
super([
|
|
@@ -732,31 +903,40 @@ class CodeBlock extends BaseService {
|
|
|
732
903
|
"deleteCodeDslByIds"
|
|
733
904
|
]);
|
|
734
905
|
}
|
|
735
|
-
async setCodeDsl(
|
|
736
|
-
this.state.codeDsl =
|
|
906
|
+
async setCodeDsl(codeDsl2) {
|
|
907
|
+
this.state.codeDsl = codeDsl2;
|
|
737
908
|
await editorService.setCodeDsl(this.state.codeDsl);
|
|
738
909
|
info("[code-block]:code-dsl-change", this.state.codeDsl);
|
|
739
910
|
this.emit("code-dsl-change", this.state.codeDsl);
|
|
740
911
|
}
|
|
741
912
|
async getCodeDsl(forceRefresh = false) {
|
|
913
|
+
return this.getCodeDslSync(forceRefresh);
|
|
914
|
+
}
|
|
915
|
+
getCodeDslSync(forceRefresh = false) {
|
|
742
916
|
if (!this.state.codeDsl || forceRefresh) {
|
|
743
|
-
this.state.codeDsl =
|
|
917
|
+
this.state.codeDsl = editorService.getCodeDslSync();
|
|
744
918
|
}
|
|
745
919
|
return this.state.codeDsl;
|
|
746
920
|
}
|
|
747
|
-
async getCodeContentById(
|
|
748
|
-
if (!
|
|
921
|
+
async getCodeContentById(id2) {
|
|
922
|
+
if (!id2)
|
|
749
923
|
return null;
|
|
750
924
|
const totalCodeDsl = await this.getCodeDsl();
|
|
751
925
|
if (!totalCodeDsl)
|
|
752
926
|
return null;
|
|
753
|
-
return totalCodeDsl[
|
|
927
|
+
return totalCodeDsl[id2] ?? null;
|
|
754
928
|
}
|
|
755
929
|
async setCodeDslById(id, codeConfig) {
|
|
756
930
|
let codeDsl = await this.getCodeDsl();
|
|
931
|
+
const codeConfigProcessed = codeConfig;
|
|
932
|
+
if (codeConfig.content) {
|
|
933
|
+
codeConfigProcessed.content = eval(codeConfig.content);
|
|
934
|
+
}
|
|
757
935
|
if (!codeDsl) {
|
|
758
936
|
codeDsl = {
|
|
759
|
-
[id]:
|
|
937
|
+
[id]: {
|
|
938
|
+
...codeConfigProcessed
|
|
939
|
+
}
|
|
760
940
|
};
|
|
761
941
|
} else {
|
|
762
942
|
const existContent = codeDsl[id] || {};
|
|
@@ -764,15 +944,15 @@ class CodeBlock extends BaseService {
|
|
|
764
944
|
...codeDsl,
|
|
765
945
|
[id]: {
|
|
766
946
|
...existContent,
|
|
767
|
-
...
|
|
947
|
+
...codeConfigProcessed
|
|
768
948
|
}
|
|
769
949
|
};
|
|
770
950
|
}
|
|
771
951
|
await this.setCodeDsl(codeDsl);
|
|
772
952
|
}
|
|
773
953
|
async getCodeDslByIds(ids) {
|
|
774
|
-
const
|
|
775
|
-
return pick(
|
|
954
|
+
const codeDsl2 = await this.getCodeDsl();
|
|
955
|
+
return pick(codeDsl2, ids);
|
|
776
956
|
}
|
|
777
957
|
async setCodeEditorShowStatus(status) {
|
|
778
958
|
this.state.isShowCodeEditor = status;
|
|
@@ -780,10 +960,10 @@ class CodeBlock extends BaseService {
|
|
|
780
960
|
getCodeEditorShowStatus() {
|
|
781
961
|
return this.state.isShowCodeEditor;
|
|
782
962
|
}
|
|
783
|
-
setCodeEditorContent(status,
|
|
784
|
-
if (!
|
|
963
|
+
setCodeEditorContent(status, id2) {
|
|
964
|
+
if (!id2)
|
|
785
965
|
return;
|
|
786
|
-
this.setId(
|
|
966
|
+
this.setId(id2);
|
|
787
967
|
this.state.isShowCodeEditor = status;
|
|
788
968
|
}
|
|
789
969
|
async getCurrentDsl() {
|
|
@@ -795,10 +975,10 @@ class CodeBlock extends BaseService {
|
|
|
795
975
|
async setEditStatus(status) {
|
|
796
976
|
this.state.editable = status;
|
|
797
977
|
}
|
|
798
|
-
setId(
|
|
799
|
-
if (!
|
|
978
|
+
setId(id2) {
|
|
979
|
+
if (!id2)
|
|
800
980
|
return;
|
|
801
|
-
this.state.id =
|
|
981
|
+
this.state.id = id2;
|
|
802
982
|
}
|
|
803
983
|
getId() {
|
|
804
984
|
return this.state.id;
|
|
@@ -815,61 +995,17 @@ class CodeBlock extends BaseService {
|
|
|
815
995
|
getCombineIds() {
|
|
816
996
|
return this.state.combineIds;
|
|
817
997
|
}
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
if (!
|
|
821
|
-
return;
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
} catch (e) {
|
|
832
|
-
error(e);
|
|
833
|
-
throw new Error("\u89E3\u7ED1\u4EE3\u7801\u5757\u5931\u8D25");
|
|
834
|
-
}
|
|
835
|
-
} else if (opFlag === CodeSelectOp.ADD) {
|
|
836
|
-
try {
|
|
837
|
-
diffCodeIds.forEach((codeId) => {
|
|
838
|
-
const compsContent = codeDsl[codeId].comps;
|
|
839
|
-
const existHooks = compsContent?.[compId];
|
|
840
|
-
if (isEmpty(existHooks)) {
|
|
841
|
-
codeDsl[codeId].comps = {
|
|
842
|
-
...codeDsl[codeId].comps || {},
|
|
843
|
-
[compId]: [hook]
|
|
844
|
-
};
|
|
845
|
-
} else {
|
|
846
|
-
existHooks?.push(hook);
|
|
847
|
-
}
|
|
848
|
-
});
|
|
849
|
-
} catch (e) {
|
|
850
|
-
error(e);
|
|
851
|
-
throw new Error("\u7ED1\u5B9A\u4EE3\u7801\u5757\u5931\u8D25");
|
|
852
|
-
}
|
|
853
|
-
} else if (opFlag === CodeSelectOp.CHANGE) {
|
|
854
|
-
forIn(codeDsl, (codeBlockContent, codeId) => {
|
|
855
|
-
if (codeId === diffCodeIds[0]) {
|
|
856
|
-
codeBlockContent.comps = {
|
|
857
|
-
...codeBlockContent?.comps || {},
|
|
858
|
-
[compId]: [hook]
|
|
859
|
-
};
|
|
860
|
-
} else if (isEmpty(diffCodeIds) || codeId !== diffCodeIds[0]) {
|
|
861
|
-
const compHooks = codeBlockContent?.comps?.[compId];
|
|
862
|
-
if (!compHooks)
|
|
863
|
-
return true;
|
|
864
|
-
const index = compHooks.findIndex((hookName) => hookName === hook);
|
|
865
|
-
if (index !== -1) {
|
|
866
|
-
compHooks.splice(index, 1);
|
|
867
|
-
return false;
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
this.setCodeDsl(codeDsl);
|
|
998
|
+
refreshCombineInfo() {
|
|
999
|
+
const root = editorService.get("root");
|
|
1000
|
+
if (!root)
|
|
1001
|
+
return null;
|
|
1002
|
+
const relations = {};
|
|
1003
|
+
this.recurseMNode(root, relations);
|
|
1004
|
+
this.state.relations = relations;
|
|
1005
|
+
return this.state.relations;
|
|
1006
|
+
}
|
|
1007
|
+
getCombineInfo() {
|
|
1008
|
+
return this.state.relations;
|
|
873
1009
|
}
|
|
874
1010
|
getUndeletableList() {
|
|
875
1011
|
return this.state.undeletableList;
|
|
@@ -877,6 +1013,15 @@ class CodeBlock extends BaseService {
|
|
|
877
1013
|
async setUndeleteableList(codeIds) {
|
|
878
1014
|
this.state.undeletableList = codeIds;
|
|
879
1015
|
}
|
|
1016
|
+
setCodeDraft(codeId, content) {
|
|
1017
|
+
globalThis.localStorage.setItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`, content);
|
|
1018
|
+
}
|
|
1019
|
+
getCodeDraft(codeId) {
|
|
1020
|
+
return globalThis.localStorage.getItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
|
|
1021
|
+
}
|
|
1022
|
+
removeCodeDraft(codeId) {
|
|
1023
|
+
globalThis.localStorage.removeItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
|
|
1024
|
+
}
|
|
880
1025
|
async deleteCodeDslByIds(codeIds) {
|
|
881
1026
|
const currentDsl = await this.getCodeDsl();
|
|
882
1027
|
const newDsl = omit(currentDsl, codeIds);
|
|
@@ -892,13 +1037,13 @@ class CodeBlock extends BaseService {
|
|
|
892
1037
|
return await this.getUniqueId();
|
|
893
1038
|
}
|
|
894
1039
|
async deleteCompsInRelation(node) {
|
|
895
|
-
const
|
|
896
|
-
if (!
|
|
1040
|
+
const codeDsl2 = cloneDeep(await this.getCodeDsl());
|
|
1041
|
+
if (!codeDsl2)
|
|
897
1042
|
return;
|
|
898
|
-
this.
|
|
899
|
-
this.setCodeDsl(
|
|
1043
|
+
this.refreshRelationDeep(node, codeDsl2);
|
|
1044
|
+
this.setCodeDsl(codeDsl2);
|
|
900
1045
|
}
|
|
901
|
-
|
|
1046
|
+
resetState() {
|
|
902
1047
|
this.state.isShowCodeEditor = false;
|
|
903
1048
|
this.state.codeDsl = null;
|
|
904
1049
|
this.state.id = "";
|
|
@@ -907,16 +1052,44 @@ class CodeBlock extends BaseService {
|
|
|
907
1052
|
this.state.combineIds = [];
|
|
908
1053
|
this.state.undeletableList = [];
|
|
909
1054
|
}
|
|
910
|
-
|
|
1055
|
+
destroy() {
|
|
1056
|
+
this.resetState();
|
|
1057
|
+
this.removeAllListeners();
|
|
1058
|
+
this.removeAllPlugins();
|
|
1059
|
+
}
|
|
1060
|
+
refreshRelationDeep(node, codeDsl2) {
|
|
911
1061
|
if (!node.id)
|
|
912
1062
|
return;
|
|
913
|
-
forIn(
|
|
1063
|
+
forIn(codeDsl2, (codeBlockContent) => {
|
|
914
1064
|
const compsContent = codeBlockContent.comps || {};
|
|
915
1065
|
codeBlockContent.comps = omit(compsContent, node.id);
|
|
916
1066
|
});
|
|
917
1067
|
if (!isEmpty(node.items)) {
|
|
918
1068
|
node.items.forEach((item) => {
|
|
919
|
-
this.
|
|
1069
|
+
this.refreshRelationDeep(item, codeDsl2);
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
recurseMNode(node, relations) {
|
|
1074
|
+
forIn(node, (value, key) => {
|
|
1075
|
+
if (value?.hookType === HookType.CODE && !isEmpty(value.hookData)) {
|
|
1076
|
+
value.hookData.forEach((relationItem) => {
|
|
1077
|
+
if (!relationItem.codeId)
|
|
1078
|
+
return;
|
|
1079
|
+
if (!relations[relationItem.codeId]) {
|
|
1080
|
+
relations[relationItem.codeId] = {};
|
|
1081
|
+
}
|
|
1082
|
+
const codeItem = relations[relationItem.codeId];
|
|
1083
|
+
if (isEmpty(codeItem[node.id])) {
|
|
1084
|
+
codeItem[node.id] = [];
|
|
1085
|
+
}
|
|
1086
|
+
codeItem[node.id].push(key);
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
if (!isEmpty(node.items)) {
|
|
1091
|
+
node.items.forEach((item) => {
|
|
1092
|
+
this.recurseMNode(item, relations);
|
|
920
1093
|
});
|
|
921
1094
|
}
|
|
922
1095
|
}
|
|
@@ -1000,8 +1173,9 @@ class History extends BaseService {
|
|
|
1000
1173
|
this.state.pageSteps[this.state.pageId] = undoRedo;
|
|
1001
1174
|
}
|
|
1002
1175
|
this.setCanUndoRedo();
|
|
1176
|
+
this.emit("page-change", this.state.pageSteps[this.state.pageId]);
|
|
1003
1177
|
}
|
|
1004
|
-
|
|
1178
|
+
resetState() {
|
|
1005
1179
|
this.state.pageId = void 0;
|
|
1006
1180
|
this.state.pageSteps = {};
|
|
1007
1181
|
this.state.canRedo = false;
|
|
@@ -1032,8 +1206,9 @@ class History extends BaseService {
|
|
|
1032
1206
|
return state;
|
|
1033
1207
|
}
|
|
1034
1208
|
destroy() {
|
|
1035
|
-
this.
|
|
1209
|
+
this.resetState();
|
|
1036
1210
|
this.removeAllListeners();
|
|
1211
|
+
this.removeAllPlugins();
|
|
1037
1212
|
}
|
|
1038
1213
|
getUndoRedo() {
|
|
1039
1214
|
if (!this.state.pageId)
|
|
@@ -1113,6 +1288,7 @@ class WebStorage extends BaseService {
|
|
|
1113
1288
|
}
|
|
1114
1289
|
destroy() {
|
|
1115
1290
|
this.removeAllListeners();
|
|
1291
|
+
this.removeAllPlugins();
|
|
1116
1292
|
}
|
|
1117
1293
|
getValueAndProtocol(value) {
|
|
1118
1294
|
let protocol2 = "";
|
|
@@ -1285,6 +1461,10 @@ const fixNodePosition = (config, parent, stage) => {
|
|
|
1285
1461
|
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
1286
1462
|
};
|
|
1287
1463
|
};
|
|
1464
|
+
const serializeConfig = (config) => serialize(config, {
|
|
1465
|
+
space: 2,
|
|
1466
|
+
unsafe: true
|
|
1467
|
+
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1288
1468
|
|
|
1289
1469
|
class Props extends BaseService {
|
|
1290
1470
|
state = reactive({
|
|
@@ -1326,7 +1506,7 @@ class Props extends BaseService {
|
|
|
1326
1506
|
this.setPropsValue(toLine(type), values[type]);
|
|
1327
1507
|
});
|
|
1328
1508
|
}
|
|
1329
|
-
setPropsValue(type, value) {
|
|
1509
|
+
async setPropsValue(type, value) {
|
|
1330
1510
|
this.state.propsValueMap[type] = value;
|
|
1331
1511
|
}
|
|
1332
1512
|
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
@@ -1380,10 +1560,14 @@ class Props extends BaseService {
|
|
|
1380
1560
|
name: type
|
|
1381
1561
|
};
|
|
1382
1562
|
}
|
|
1383
|
-
|
|
1563
|
+
resetState() {
|
|
1384
1564
|
this.state.propsConfigMap = {};
|
|
1385
1565
|
this.state.propsValueMap = {};
|
|
1566
|
+
}
|
|
1567
|
+
destroy() {
|
|
1568
|
+
this.resetState();
|
|
1386
1569
|
this.removeAllListeners();
|
|
1570
|
+
this.removeAllPlugins();
|
|
1387
1571
|
}
|
|
1388
1572
|
guid(digit = 8) {
|
|
1389
1573
|
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
@@ -1458,6 +1642,13 @@ const getAddParent = (node) => {
|
|
|
1458
1642
|
}
|
|
1459
1643
|
return parentNode;
|
|
1460
1644
|
};
|
|
1645
|
+
const getDefaultConfig = async (addNode, parentNode) => {
|
|
1646
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1647
|
+
const layout = await editorService.getLayout(toRaw(parentNode), addNode);
|
|
1648
|
+
const newNode = { ...toRaw(await propsService.getPropsValue(type, config)) };
|
|
1649
|
+
newNode.style = getInitPositionStyle(newNode.style, layout);
|
|
1650
|
+
return newNode;
|
|
1651
|
+
};
|
|
1461
1652
|
|
|
1462
1653
|
class Editor$1 extends BaseService {
|
|
1463
1654
|
state = reactive({
|
|
@@ -1487,7 +1678,7 @@ class Editor$1 extends BaseService {
|
|
|
1487
1678
|
"copy",
|
|
1488
1679
|
"paste",
|
|
1489
1680
|
"doPaste",
|
|
1490
|
-
"
|
|
1681
|
+
"doAlignCenter",
|
|
1491
1682
|
"alignCenter",
|
|
1492
1683
|
"moveLayer",
|
|
1493
1684
|
"moveToContainer",
|
|
@@ -1502,13 +1693,14 @@ class Editor$1 extends BaseService {
|
|
|
1502
1693
|
);
|
|
1503
1694
|
}
|
|
1504
1695
|
set(name, value) {
|
|
1696
|
+
const preValue = this.state[name];
|
|
1505
1697
|
this.state[name] = value;
|
|
1506
1698
|
if (name === "nodes") {
|
|
1507
1699
|
this.set("node", value[0]);
|
|
1508
1700
|
}
|
|
1509
1701
|
if (name === "root") {
|
|
1510
1702
|
this.state.pageLength = value?.items?.length || 0;
|
|
1511
|
-
this.emit("root-change", value);
|
|
1703
|
+
this.emit("root-change", value, preValue);
|
|
1512
1704
|
}
|
|
1513
1705
|
}
|
|
1514
1706
|
get(name) {
|
|
@@ -1568,7 +1760,7 @@ class Editor$1 extends BaseService {
|
|
|
1568
1760
|
if (page) {
|
|
1569
1761
|
historyService.changePage(toRaw(page));
|
|
1570
1762
|
} else {
|
|
1571
|
-
historyService.
|
|
1763
|
+
historyService.resetState();
|
|
1572
1764
|
}
|
|
1573
1765
|
if (node?.id) {
|
|
1574
1766
|
this.get("stage")?.renderer.runtime?.getApp?.()?.emit(
|
|
@@ -1666,6 +1858,9 @@ class Editor$1 extends BaseService {
|
|
|
1666
1858
|
}
|
|
1667
1859
|
const newNodes = await Promise.all(
|
|
1668
1860
|
addNodes.map((node) => {
|
|
1861
|
+
if (isPage(node)) {
|
|
1862
|
+
return this.doAdd(node, this.get("root"));
|
|
1863
|
+
}
|
|
1669
1864
|
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1670
1865
|
if (!parentNode)
|
|
1671
1866
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
@@ -1684,7 +1879,9 @@ class Editor$1 extends BaseService {
|
|
|
1684
1879
|
stage?.select(newNodes[0].id);
|
|
1685
1880
|
}
|
|
1686
1881
|
}
|
|
1687
|
-
|
|
1882
|
+
if (!isPage(newNodes[0])) {
|
|
1883
|
+
this.pushHistoryState();
|
|
1884
|
+
}
|
|
1688
1885
|
this.emit("add", newNodes);
|
|
1689
1886
|
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1690
1887
|
}
|
|
@@ -1726,7 +1923,9 @@ class Editor$1 extends BaseService {
|
|
|
1726
1923
|
async remove(nodeOrNodeList) {
|
|
1727
1924
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1728
1925
|
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1729
|
-
|
|
1926
|
+
if (!isPage(nodes[0])) {
|
|
1927
|
+
this.pushHistoryState();
|
|
1928
|
+
}
|
|
1730
1929
|
this.emit("remove", nodes);
|
|
1731
1930
|
}
|
|
1732
1931
|
async doUpdate(config) {
|
|
@@ -1738,6 +1937,9 @@ class Editor$1 extends BaseService {
|
|
|
1738
1937
|
const node = cloneDeep(toRaw(info.node));
|
|
1739
1938
|
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
|
|
1740
1939
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1940
|
+
if (isObject(srcValue) && Array.isArray(objValue)) {
|
|
1941
|
+
return srcValue;
|
|
1942
|
+
}
|
|
1741
1943
|
if (Array.isArray(srcValue)) {
|
|
1742
1944
|
return srcValue;
|
|
1743
1945
|
}
|
|
@@ -1781,6 +1983,7 @@ class Editor$1 extends BaseService {
|
|
|
1781
1983
|
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1782
1984
|
this.pushHistoryState();
|
|
1783
1985
|
this.emit("update", newNodes);
|
|
1986
|
+
codeBlockService.refreshCombineInfo();
|
|
1784
1987
|
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1785
1988
|
}
|
|
1786
1989
|
async sort(id1, id2) {
|
|
@@ -1810,8 +2013,16 @@ class Editor$1 extends BaseService {
|
|
|
1810
2013
|
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1811
2014
|
if (!Array.isArray(config))
|
|
1812
2015
|
return;
|
|
2016
|
+
const node = this.get("node");
|
|
2017
|
+
let parent = void 0;
|
|
2018
|
+
if (config.length === 1 && config[0].id === node.id) {
|
|
2019
|
+
parent = this.get("parent");
|
|
2020
|
+
if (parent.type === NodeType.ROOT) {
|
|
2021
|
+
parent = this.get("page");
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
1813
2024
|
const pasteConfigs = await this.doPaste(config, position);
|
|
1814
|
-
return this.add(pasteConfigs);
|
|
2025
|
+
return this.add(pasteConfigs, parent);
|
|
1815
2026
|
}
|
|
1816
2027
|
async doPaste(config, position = {}) {
|
|
1817
2028
|
const pasteConfigs = await beforePaste(position, cloneDeep(config));
|
|
@@ -1846,7 +2057,11 @@ class Editor$1 extends BaseService {
|
|
|
1846
2057
|
const stage = this.get("stage");
|
|
1847
2058
|
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1848
2059
|
const newNode = await this.update(newNodes);
|
|
1849
|
-
|
|
2060
|
+
if (newNodes.length > 1) {
|
|
2061
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
2062
|
+
} else {
|
|
2063
|
+
await stage?.select(newNodes[0].id);
|
|
2064
|
+
}
|
|
1850
2065
|
return newNode;
|
|
1851
2066
|
}
|
|
1852
2067
|
async moveLayer(offset) {
|
|
@@ -1932,8 +2147,7 @@ class Editor$1 extends BaseService {
|
|
|
1932
2147
|
}
|
|
1933
2148
|
});
|
|
1934
2149
|
}
|
|
1935
|
-
|
|
1936
|
-
this.removeAllListeners();
|
|
2150
|
+
resetState() {
|
|
1937
2151
|
this.set("root", null);
|
|
1938
2152
|
this.set("node", null);
|
|
1939
2153
|
this.set("nodes", []);
|
|
@@ -1944,6 +2158,11 @@ class Editor$1 extends BaseService {
|
|
|
1944
2158
|
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
1945
2159
|
this.set("pageLength", /* @__PURE__ */ new Map());
|
|
1946
2160
|
}
|
|
2161
|
+
destroy() {
|
|
2162
|
+
this.removeAllListeners();
|
|
2163
|
+
this.resetState();
|
|
2164
|
+
this.removeAllPlugins();
|
|
2165
|
+
}
|
|
1947
2166
|
resetModifiedNodeId() {
|
|
1948
2167
|
this.get("modifiedNodeIds").clear();
|
|
1949
2168
|
}
|
|
@@ -1953,6 +2172,12 @@ class Editor$1 extends BaseService {
|
|
|
1953
2172
|
return null;
|
|
1954
2173
|
return root.codeBlocks || null;
|
|
1955
2174
|
}
|
|
2175
|
+
getCodeDslSync() {
|
|
2176
|
+
const root = this.get("root");
|
|
2177
|
+
if (!root)
|
|
2178
|
+
return null;
|
|
2179
|
+
return root.codeBlocks || null;
|
|
2180
|
+
}
|
|
1956
2181
|
async setCodeDsl(codeDsl) {
|
|
1957
2182
|
if (!this.state.root)
|
|
1958
2183
|
return;
|
|
@@ -2064,10 +2289,14 @@ class Events extends BaseService {
|
|
|
2064
2289
|
getMethod(type) {
|
|
2065
2290
|
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
2066
2291
|
}
|
|
2067
|
-
|
|
2292
|
+
resetState() {
|
|
2068
2293
|
eventMap = reactive({});
|
|
2069
2294
|
methodMap = reactive({});
|
|
2295
|
+
}
|
|
2296
|
+
destroy() {
|
|
2297
|
+
this.resetState();
|
|
2070
2298
|
this.removeAllListeners();
|
|
2299
|
+
this.removeAllPlugins();
|
|
2071
2300
|
}
|
|
2072
2301
|
}
|
|
2073
2302
|
const eventsService = new Events();
|
|
@@ -2267,14 +2496,14 @@ const fillConfig = (config = []) => [
|
|
|
2267
2496
|
{
|
|
2268
2497
|
name: "created",
|
|
2269
2498
|
text: "created",
|
|
2270
|
-
|
|
2271
|
-
|
|
2499
|
+
labelWidth: "100px",
|
|
2500
|
+
type: "code-select"
|
|
2272
2501
|
},
|
|
2273
2502
|
{
|
|
2274
2503
|
name: "mounted",
|
|
2275
2504
|
text: "mounted",
|
|
2276
|
-
|
|
2277
|
-
|
|
2505
|
+
labelWidth: "100px",
|
|
2506
|
+
type: "code-select"
|
|
2278
2507
|
}
|
|
2279
2508
|
]
|
|
2280
2509
|
}
|
|
@@ -2342,8 +2571,19 @@ class Ui extends BaseService {
|
|
|
2342
2571
|
}
|
|
2343
2572
|
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
2344
2573
|
}
|
|
2574
|
+
resetState() {
|
|
2575
|
+
this.set("showSrc", false);
|
|
2576
|
+
this.set("uiSelectMode", false);
|
|
2577
|
+
this.set("zoom", 1);
|
|
2578
|
+
this.set("stageContainerRect", {
|
|
2579
|
+
width: 0,
|
|
2580
|
+
height: 0
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2345
2583
|
destroy() {
|
|
2584
|
+
this.resetState();
|
|
2346
2585
|
this.removeAllListeners();
|
|
2586
|
+
this.removeAllPlugins();
|
|
2347
2587
|
}
|
|
2348
2588
|
async setStageRect(value) {
|
|
2349
2589
|
state.stageRect = {
|
|
@@ -2370,6 +2610,7 @@ const useStage = (stageOptions) => {
|
|
|
2370
2610
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
2371
2611
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
2372
2612
|
containerHighlightType: stageOptions.containerHighlightType,
|
|
2613
|
+
disabledDragStart: stageOptions.disabledDragStart,
|
|
2373
2614
|
canSelect: (el, event, stop) => {
|
|
2374
2615
|
const elCanSelect = stageOptions.canSelect(el);
|
|
2375
2616
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -2381,225 +2622,97 @@ const useStage = (stageOptions) => {
|
|
|
2381
2622
|
moveableOptions: stageOptions.moveableOptions,
|
|
2382
2623
|
updateDragEl: stageOptions.updateDragEl
|
|
2383
2624
|
});
|
|
2384
|
-
stage.mask.setGuides([
|
|
2385
|
-
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
2386
|
-
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
2387
|
-
]);
|
|
2388
|
-
stage.on("select", (el) => {
|
|
2389
|
-
if (`${editorService.get("node")?.id}` === el.id)
|
|
2390
|
-
return;
|
|
2391
|
-
editorService.select(el.id);
|
|
2392
|
-
});
|
|
2393
|
-
stage.on("highlight", (el) => {
|
|
2394
|
-
editorService.highlight(el.id);
|
|
2395
|
-
});
|
|
2396
|
-
stage.on("
|
|
2397
|
-
editorService.multiSelect(els.map((el) => el.id));
|
|
2398
|
-
});
|
|
2399
|
-
stage.on("update", (ev) => {
|
|
2400
|
-
if (ev.parentEl) {
|
|
2401
|
-
for (const data of ev.data) {
|
|
2402
|
-
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
2403
|
-
}
|
|
2404
|
-
return;
|
|
2405
|
-
}
|
|
2406
|
-
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
2407
|
-
});
|
|
2408
|
-
stage.on("sort", (ev) => {
|
|
2409
|
-
editorService.sort(ev.src, ev.dist);
|
|
2410
|
-
});
|
|
2411
|
-
stage.on("select-parent", () => {
|
|
2412
|
-
const parent = editorService.get("parent");
|
|
2413
|
-
editorService.select(parent);
|
|
2414
|
-
editorService.get("stage").select(parent.id);
|
|
2415
|
-
});
|
|
2416
|
-
stage.on("changeGuides", (e) => {
|
|
2417
|
-
uiService.set("showGuides", true);
|
|
2418
|
-
if (!root.value || !page.value)
|
|
2419
|
-
return;
|
|
2420
|
-
const storageKey = getGuideLineKey(
|
|
2421
|
-
e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
2422
|
-
);
|
|
2423
|
-
if (e.guides.length) {
|
|
2424
|
-
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
2425
|
-
} else {
|
|
2426
|
-
globalThis.localStorage.removeItem(storageKey);
|
|
2427
|
-
}
|
|
2428
|
-
});
|
|
2429
|
-
return stage;
|
|
2430
|
-
};
|
|
2431
|
-
|
|
2432
|
-
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
2433
|
-
const _hoisted_2$5 = { class: "m-editor-empty-content" };
|
|
2434
|
-
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2435
|
-
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
2436
|
-
__name: "AddPageBox",
|
|
2437
|
-
setup(__props) {
|
|
2438
|
-
const services = inject("services");
|
|
2439
|
-
const clickHandler = () => {
|
|
2440
|
-
const { editorService } = services || {};
|
|
2441
|
-
if (!editorService)
|
|
2442
|
-
return;
|
|
2443
|
-
editorService.add({
|
|
2444
|
-
type: NodeType.PAGE,
|
|
2445
|
-
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
2446
|
-
});
|
|
2447
|
-
};
|
|
2448
|
-
return (_ctx, _cache) => {
|
|
2449
|
-
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
2450
|
-
createElementVNode("div", _hoisted_2$5, [
|
|
2451
|
-
createElementVNode("div", {
|
|
2452
|
-
class: "m-editor-empty-button",
|
|
2453
|
-
onClick: clickHandler
|
|
2454
|
-
}, [
|
|
2455
|
-
createElementVNode("div", null, [
|
|
2456
|
-
createVNode(_sfc_main$o, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
2457
|
-
]),
|
|
2458
|
-
_hoisted_3$2
|
|
2459
|
-
])
|
|
2460
|
-
])
|
|
2461
|
-
]);
|
|
2462
|
-
};
|
|
2463
|
-
}
|
|
2464
|
-
});
|
|
2465
|
-
|
|
2466
|
-
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
2467
|
-
__name: "Resizer",
|
|
2468
|
-
emits: ["change"],
|
|
2469
|
-
setup(__props, { emit }) {
|
|
2470
|
-
const target = ref();
|
|
2471
|
-
let getso;
|
|
2472
|
-
onMounted(() => {
|
|
2473
|
-
if (!target.value)
|
|
2474
|
-
return;
|
|
2475
|
-
getso = new Gesto(target.value, {
|
|
2476
|
-
container: window,
|
|
2477
|
-
pinchOutside: true
|
|
2478
|
-
}).on("drag", (e) => {
|
|
2479
|
-
if (!target.value)
|
|
2480
|
-
return;
|
|
2481
|
-
emit("change", e.deltaX);
|
|
2482
|
-
});
|
|
2483
|
-
});
|
|
2484
|
-
onUnmounted(() => {
|
|
2485
|
-
getso?.unset();
|
|
2486
|
-
});
|
|
2487
|
-
return (_ctx, _cache) => {
|
|
2488
|
-
return openBlock(), createElementBlock("span", {
|
|
2489
|
-
ref_key: "target",
|
|
2490
|
-
ref: target,
|
|
2491
|
-
class: "m-editor-resizer"
|
|
2492
|
-
}, [
|
|
2493
|
-
renderSlot(_ctx.$slots, "default")
|
|
2494
|
-
], 512);
|
|
2495
|
-
};
|
|
2496
|
-
}
|
|
2497
|
-
});
|
|
2498
|
-
|
|
2499
|
-
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
2500
|
-
__name: "Layout",
|
|
2501
|
-
props: {
|
|
2502
|
-
left: null,
|
|
2503
|
-
right: null,
|
|
2504
|
-
minLeft: { default: 1 },
|
|
2505
|
-
minRight: { default: 1 },
|
|
2506
|
-
leftClass: null,
|
|
2507
|
-
rightClass: null,
|
|
2508
|
-
centerClass: null
|
|
2509
|
-
},
|
|
2510
|
-
emits: ["update:left", "change", "update:right"],
|
|
2511
|
-
setup(__props, { emit }) {
|
|
2512
|
-
const props = __props;
|
|
2513
|
-
const el = ref();
|
|
2514
|
-
let clientWidth = 0;
|
|
2515
|
-
const resizerObserver = new ResizeObserver((entries) => {
|
|
2516
|
-
for (const { contentRect } of entries) {
|
|
2517
|
-
clientWidth = contentRect.width;
|
|
2518
|
-
center.value = clientWidth - (props.left || 0) - (props.right || 0);
|
|
2519
|
-
emit("change", {
|
|
2520
|
-
left: props.left,
|
|
2521
|
-
center: center.value,
|
|
2522
|
-
right: props.right
|
|
2523
|
-
});
|
|
2524
|
-
}
|
|
2525
|
-
});
|
|
2526
|
-
onMounted(() => {
|
|
2527
|
-
if (el.value) {
|
|
2528
|
-
resizerObserver.observe(el.value);
|
|
2529
|
-
}
|
|
2530
|
-
});
|
|
2531
|
-
onUnmounted(() => {
|
|
2532
|
-
resizerObserver.disconnect();
|
|
2533
|
-
});
|
|
2534
|
-
const center = ref(0);
|
|
2535
|
-
const changeLeft = (deltaX) => {
|
|
2536
|
-
if (typeof props.left === "undefined")
|
|
2537
|
-
return;
|
|
2538
|
-
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
2539
|
-
emit("update:left", left);
|
|
2540
|
-
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
2541
|
-
left = props.left;
|
|
2625
|
+
stage.mask.setGuides([
|
|
2626
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
2627
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
2628
|
+
]);
|
|
2629
|
+
stage.on("select", (el) => {
|
|
2630
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
2631
|
+
return;
|
|
2632
|
+
editorService.select(el.id);
|
|
2633
|
+
});
|
|
2634
|
+
stage.on("highlight", (el) => {
|
|
2635
|
+
editorService.highlight(el.id);
|
|
2636
|
+
});
|
|
2637
|
+
stage.on("multi-select", (els) => {
|
|
2638
|
+
editorService.multiSelect(els.map((el) => el.id));
|
|
2639
|
+
});
|
|
2640
|
+
stage.on("update", (ev) => {
|
|
2641
|
+
if (ev.parentEl) {
|
|
2642
|
+
for (const data of ev.data) {
|
|
2643
|
+
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
2542
2644
|
}
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2645
|
+
return;
|
|
2646
|
+
}
|
|
2647
|
+
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
2648
|
+
});
|
|
2649
|
+
stage.on("sort", (ev) => {
|
|
2650
|
+
editorService.sort(ev.src, ev.dist);
|
|
2651
|
+
});
|
|
2652
|
+
stage.on("select-parent", () => {
|
|
2653
|
+
const parent = editorService.get("parent");
|
|
2654
|
+
editorService.select(parent);
|
|
2655
|
+
editorService.get("stage").select(parent.id);
|
|
2656
|
+
});
|
|
2657
|
+
stage.on("change-guides", (e) => {
|
|
2658
|
+
uiService.set("showGuides", true);
|
|
2659
|
+
if (!root.value || !page.value)
|
|
2660
|
+
return;
|
|
2661
|
+
const storageKey = getGuideLineKey(
|
|
2662
|
+
e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
2663
|
+
);
|
|
2664
|
+
if (e.guides.length) {
|
|
2665
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
2666
|
+
} else {
|
|
2667
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
2668
|
+
}
|
|
2669
|
+
});
|
|
2670
|
+
return stage;
|
|
2671
|
+
};
|
|
2672
|
+
|
|
2673
|
+
const _hoisted_1$d = { class: "m-editor-empty-panel" };
|
|
2674
|
+
const _hoisted_2$7 = { class: "m-editor-empty-content" };
|
|
2675
|
+
const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2676
|
+
const __default__$l = defineComponent({
|
|
2677
|
+
name: "MEditorAddPageBox"
|
|
2678
|
+
});
|
|
2679
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
2680
|
+
...__default__$l,
|
|
2681
|
+
setup(__props) {
|
|
2682
|
+
const services = inject("services");
|
|
2683
|
+
const clickHandler = () => {
|
|
2684
|
+
const { editorService } = services || {};
|
|
2685
|
+
if (!editorService)
|
|
2552
2686
|
return;
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
right = props.right;
|
|
2557
|
-
}
|
|
2558
|
-
center.value = clientWidth - (props.left || 0) - right;
|
|
2559
|
-
emit("change", {
|
|
2560
|
-
left: props.left,
|
|
2561
|
-
center: center.value,
|
|
2562
|
-
right
|
|
2687
|
+
editorService.add({
|
|
2688
|
+
type: NodeType.PAGE,
|
|
2689
|
+
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
2563
2690
|
});
|
|
2564
2691
|
};
|
|
2565
2692
|
return (_ctx, _cache) => {
|
|
2566
|
-
return openBlock(), createElementBlock("div",
|
|
2567
|
-
|
|
2568
|
-
ref: el,
|
|
2569
|
-
class: "m-editor-layout"
|
|
2570
|
-
}, [
|
|
2571
|
-
typeof props.left !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2572
|
-
createElementVNode("div", {
|
|
2573
|
-
class: normalizeClass(["m-editor-layout-left", __props.leftClass]),
|
|
2574
|
-
style: normalizeStyle(`width: ${__props.left}px`)
|
|
2575
|
-
}, [
|
|
2576
|
-
renderSlot(_ctx.$slots, "left")
|
|
2577
|
-
], 6),
|
|
2578
|
-
createVNode(_sfc_main$m, { onChange: changeLeft })
|
|
2579
|
-
], 64)) : createCommentVNode("", true),
|
|
2580
|
-
createElementVNode("div", {
|
|
2581
|
-
class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
|
|
2582
|
-
style: normalizeStyle(`width: ${center.value}px`)
|
|
2583
|
-
}, [
|
|
2584
|
-
renderSlot(_ctx.$slots, "center")
|
|
2585
|
-
], 6),
|
|
2586
|
-
typeof props.right !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
2587
|
-
createVNode(_sfc_main$m, { onChange: changeRight }),
|
|
2693
|
+
return openBlock(), createElementBlock("div", _hoisted_1$d, [
|
|
2694
|
+
createElementVNode("div", _hoisted_2$7, [
|
|
2588
2695
|
createElementVNode("div", {
|
|
2589
|
-
class:
|
|
2590
|
-
|
|
2696
|
+
class: "m-editor-empty-button",
|
|
2697
|
+
onClick: clickHandler
|
|
2591
2698
|
}, [
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2699
|
+
createElementVNode("div", null, [
|
|
2700
|
+
createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
2701
|
+
]),
|
|
2702
|
+
_hoisted_3$4
|
|
2703
|
+
])
|
|
2704
|
+
])
|
|
2705
|
+
]);
|
|
2596
2706
|
};
|
|
2597
2707
|
}
|
|
2598
2708
|
});
|
|
2599
2709
|
|
|
2600
|
-
const _hoisted_1$
|
|
2601
|
-
const
|
|
2602
|
-
|
|
2710
|
+
const _hoisted_1$c = { class: "m-editor" };
|
|
2711
|
+
const __default__$k = defineComponent({
|
|
2712
|
+
name: "MEditorFramework"
|
|
2713
|
+
});
|
|
2714
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
2715
|
+
...__default__$k,
|
|
2603
2716
|
props: {
|
|
2604
2717
|
codeOptions: { default: () => ({}) }
|
|
2605
2718
|
},
|
|
@@ -2665,7 +2778,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2665
2778
|
};
|
|
2666
2779
|
return (_ctx, _cache) => {
|
|
2667
2780
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2668
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2781
|
+
return openBlock(), createElementBlock("div", _hoisted_1$c, [
|
|
2669
2782
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2670
2783
|
unref(showSrc) ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2671
2784
|
key: 0,
|
|
@@ -2673,7 +2786,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2673
2786
|
"init-values": unref(root),
|
|
2674
2787
|
options: __props.codeOptions,
|
|
2675
2788
|
onSave: saveCode
|
|
2676
|
-
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$
|
|
2789
|
+
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$o, {
|
|
2677
2790
|
key: 1,
|
|
2678
2791
|
class: "m-editor-content",
|
|
2679
2792
|
"left-class": "m-editor-framework-left",
|
|
@@ -2692,7 +2805,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2692
2805
|
]),
|
|
2693
2806
|
center: withCtx(() => [
|
|
2694
2807
|
unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2695
|
-
createVNode(_sfc_main$
|
|
2808
|
+
createVNode(_sfc_main$m)
|
|
2696
2809
|
])
|
|
2697
2810
|
]),
|
|
2698
2811
|
_: 2
|
|
@@ -2714,13 +2827,16 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2714
2827
|
}
|
|
2715
2828
|
});
|
|
2716
2829
|
|
|
2717
|
-
const _hoisted_1$
|
|
2830
|
+
const _hoisted_1$b = {
|
|
2718
2831
|
key: 1,
|
|
2719
2832
|
class: "menu-item-text"
|
|
2720
2833
|
};
|
|
2721
|
-
const _hoisted_2$
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2834
|
+
const _hoisted_2$6 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2835
|
+
const __default__$j = defineComponent({
|
|
2836
|
+
name: "MEditorToolButton"
|
|
2837
|
+
});
|
|
2838
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
2839
|
+
...__default__$j,
|
|
2724
2840
|
props: {
|
|
2725
2841
|
data: { default: () => ({
|
|
2726
2842
|
type: "text",
|
|
@@ -2795,7 +2911,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2795
2911
|
__props.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
|
|
2796
2912
|
key: 0,
|
|
2797
2913
|
direction: __props.data.direction || "vertical"
|
|
2798
|
-
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2914
|
+
}, 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 }, [
|
|
2799
2915
|
__props.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
2800
2916
|
key: 0,
|
|
2801
2917
|
effect: "dark",
|
|
@@ -2809,7 +2925,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2809
2925
|
disabled: unref(disabled)
|
|
2810
2926
|
}, {
|
|
2811
2927
|
default: withCtx(() => [
|
|
2812
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2928
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
2813
2929
|
key: 0,
|
|
2814
2930
|
icon: __props.data.icon
|
|
2815
2931
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2826,7 +2942,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2826
2942
|
disabled: unref(disabled)
|
|
2827
2943
|
}, {
|
|
2828
2944
|
default: withCtx(() => [
|
|
2829
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2945
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
2830
2946
|
key: 0,
|
|
2831
2947
|
icon: __props.data.icon
|
|
2832
2948
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2859,7 +2975,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2859
2975
|
})) : createCommentVNode("", true)
|
|
2860
2976
|
]),
|
|
2861
2977
|
default: withCtx(() => [
|
|
2862
|
-
createElementVNode("span", _hoisted_2$
|
|
2978
|
+
createElementVNode("span", _hoisted_2$6, [
|
|
2863
2979
|
createTextVNode(toDisplayString(__props.data.text), 1),
|
|
2864
2980
|
createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
|
|
2865
2981
|
default: withCtx(() => [
|
|
@@ -2876,8 +2992,11 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2876
2992
|
}
|
|
2877
2993
|
});
|
|
2878
2994
|
|
|
2879
|
-
const
|
|
2880
|
-
|
|
2995
|
+
const __default__$i = defineComponent({
|
|
2996
|
+
name: "MEditorNavMenu"
|
|
2997
|
+
});
|
|
2998
|
+
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
2999
|
+
...__default__$i,
|
|
2881
3000
|
props: {
|
|
2882
3001
|
data: { default: () => ({}) },
|
|
2883
3002
|
height: { default: 35 }
|
|
@@ -3032,7 +3151,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
3032
3151
|
style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
|
|
3033
3152
|
}, [
|
|
3034
3153
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
|
|
3035
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3154
|
+
return openBlock(), createBlock(_sfc_main$k, {
|
|
3036
3155
|
data: item,
|
|
3037
3156
|
key: index
|
|
3038
3157
|
}, null, 8, ["data"]);
|
|
@@ -3044,9 +3163,12 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
3044
3163
|
}
|
|
3045
3164
|
});
|
|
3046
3165
|
|
|
3047
|
-
const _hoisted_1$
|
|
3048
|
-
const
|
|
3049
|
-
|
|
3166
|
+
const _hoisted_1$a = { class: "m-editor-props-panel" };
|
|
3167
|
+
const __default__$h = defineComponent({
|
|
3168
|
+
name: "MEditorPropsPanel"
|
|
3169
|
+
});
|
|
3170
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
3171
|
+
...__default__$h,
|
|
3050
3172
|
emits: ["mounted"],
|
|
3051
3173
|
setup(__props, { expose, emit }) {
|
|
3052
3174
|
const internalInstance = getCurrentInstance();
|
|
@@ -3055,7 +3177,9 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3055
3177
|
const curFormConfig = ref([]);
|
|
3056
3178
|
const services = inject("services");
|
|
3057
3179
|
const node = computed(() => services?.editorService.get("node"));
|
|
3058
|
-
const propsPanelSize = computed(
|
|
3180
|
+
const propsPanelSize = computed(
|
|
3181
|
+
() => services?.uiService.get("propsPanelSize") || "small"
|
|
3182
|
+
);
|
|
3059
3183
|
const stage = computed(() => services?.editorService.get("stage"));
|
|
3060
3184
|
const init = async () => {
|
|
3061
3185
|
if (!node.value) {
|
|
@@ -3071,6 +3195,9 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3071
3195
|
onMounted(() => {
|
|
3072
3196
|
emit("mounted", internalInstance);
|
|
3073
3197
|
});
|
|
3198
|
+
onUnmounted(() => {
|
|
3199
|
+
services?.propsService.off("props-configs-change", init);
|
|
3200
|
+
});
|
|
3074
3201
|
watchEffect(() => {
|
|
3075
3202
|
if (configForm.value && stage.value) {
|
|
3076
3203
|
configForm.value.formState.stage = stage.value;
|
|
@@ -3088,10 +3215,9 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3088
3215
|
};
|
|
3089
3216
|
expose({ submit });
|
|
3090
3217
|
return (_ctx, _cache) => {
|
|
3091
|
-
|
|
3092
|
-
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
3218
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
3093
3219
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
3094
|
-
createVNode(
|
|
3220
|
+
createVNode(unref(MForm), {
|
|
3095
3221
|
ref_key: "configForm",
|
|
3096
3222
|
ref: configForm,
|
|
3097
3223
|
class: normalizeClass(`m-editor-props-panel ${unref(propsPanelSize)}`),
|
|
@@ -3106,43 +3232,328 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3106
3232
|
}
|
|
3107
3233
|
});
|
|
3108
3234
|
|
|
3109
|
-
const _hoisted_1$
|
|
3110
|
-
|
|
3111
|
-
const _hoisted_3$1 = { class: "code-name" };
|
|
3112
|
-
const _hoisted_4$1 = { class: "code-name-wrapper" };
|
|
3113
|
-
const _hoisted_5$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
|
|
3114
|
-
const _hoisted_6$1 = { class: "m-editor-wrapper" };
|
|
3115
|
-
const _hoisted_7$1 = {
|
|
3116
|
-
key: 1,
|
|
3235
|
+
const _hoisted_1$9 = {
|
|
3236
|
+
key: 0,
|
|
3117
3237
|
class: "m-editor-content-bottom"
|
|
3118
3238
|
};
|
|
3119
|
-
const
|
|
3120
|
-
const
|
|
3121
|
-
const
|
|
3122
|
-
key:
|
|
3239
|
+
const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
|
|
3240
|
+
const _hoisted_3$3 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3241
|
+
const _hoisted_4$2 = {
|
|
3242
|
+
key: 1,
|
|
3123
3243
|
class: "m-editor-content-bottom"
|
|
3124
3244
|
};
|
|
3125
|
-
const
|
|
3245
|
+
const _hoisted_5$1 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3246
|
+
const __default__$g = defineComponent({
|
|
3247
|
+
name: "MEditorCodeDraftEditor"
|
|
3248
|
+
});
|
|
3249
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
3250
|
+
...__default__$g,
|
|
3251
|
+
props: {
|
|
3252
|
+
id: null,
|
|
3253
|
+
content: null,
|
|
3254
|
+
editable: { type: Boolean, default: true },
|
|
3255
|
+
autoSaveDraft: { type: Boolean, default: true },
|
|
3256
|
+
codeOptions: null,
|
|
3257
|
+
language: null
|
|
3258
|
+
},
|
|
3259
|
+
emits: ["save", "close", "saveAndClose"],
|
|
3260
|
+
setup(__props, { emit }) {
|
|
3261
|
+
const props = __props;
|
|
3262
|
+
const services = inject("services");
|
|
3263
|
+
const codeContent = ref("");
|
|
3264
|
+
const editorContent = ref("");
|
|
3265
|
+
const codeEditor = ref();
|
|
3266
|
+
const originCodeContent = ref("");
|
|
3267
|
+
const isFullScreen = ref(false);
|
|
3268
|
+
const codeOptions = computed(() => ({
|
|
3269
|
+
...props.codeOptions,
|
|
3270
|
+
readOnly: !props.editable
|
|
3271
|
+
}));
|
|
3272
|
+
watchEffect(() => {
|
|
3273
|
+
codeContent.value = props.content;
|
|
3274
|
+
if (!originCodeContent.value) {
|
|
3275
|
+
originCodeContent.value = codeContent.value;
|
|
3276
|
+
}
|
|
3277
|
+
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3278
|
+
if (codeDraft) {
|
|
3279
|
+
codeContent.value = codeDraft;
|
|
3280
|
+
}
|
|
3281
|
+
});
|
|
3282
|
+
const saveCodeDraft = async (codeValue) => {
|
|
3283
|
+
if (!props.autoSaveDraft)
|
|
3284
|
+
return;
|
|
3285
|
+
if (originCodeContent.value === codeValue) {
|
|
3286
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3287
|
+
return;
|
|
3288
|
+
}
|
|
3289
|
+
services?.codeBlockService.setCodeDraft(props.id, codeValue);
|
|
3290
|
+
tMagicMessage.success(`\u4EE3\u7801\u8349\u7A3F\u4FDD\u5B58\u6210\u529F ${datetimeFormatter(new Date())}`);
|
|
3291
|
+
};
|
|
3292
|
+
const saveCode = () => {
|
|
3293
|
+
if (!codeEditor.value || !props.editable)
|
|
3294
|
+
return;
|
|
3295
|
+
editorContent.value = codeEditor.value.getEditor()?.getValue();
|
|
3296
|
+
emit("save", editorContent.value);
|
|
3297
|
+
};
|
|
3298
|
+
const saveAndClose = () => {
|
|
3299
|
+
if (!codeEditor.value || !props.editable)
|
|
3300
|
+
return;
|
|
3301
|
+
editorContent.value = codeEditor.value.getEditor()?.getValue();
|
|
3302
|
+
emit("saveAndClose", editorContent.value);
|
|
3303
|
+
};
|
|
3304
|
+
const close = async () => {
|
|
3305
|
+
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3306
|
+
if (codeDraft) {
|
|
3307
|
+
tMagicMessageBox.confirm("\u60A8\u6709\u4EE3\u7801\u4FEE\u6539\u672A\u4FDD\u5B58\uFF0C\u662F\u5426\u4FDD\u5B58\u540E\u518D\u5173\u95ED\uFF1F", "\u63D0\u793A", {
|
|
3308
|
+
confirmButtonText: "\u786E\u8BA4",
|
|
3309
|
+
cancelButtonText: "\u53D6\u6D88",
|
|
3310
|
+
type: "warning"
|
|
3311
|
+
}).then(async () => {
|
|
3312
|
+
saveAndClose();
|
|
3313
|
+
}).catch(() => {
|
|
3314
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3315
|
+
emit("close");
|
|
3316
|
+
});
|
|
3317
|
+
} else {
|
|
3318
|
+
emit("close");
|
|
3319
|
+
}
|
|
3320
|
+
};
|
|
3321
|
+
const toggleFullScreen = () => {
|
|
3322
|
+
isFullScreen.value = !isFullScreen.value;
|
|
3323
|
+
if (codeEditor.value) {
|
|
3324
|
+
codeEditor.value.focus();
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
return (_ctx, _cache) => {
|
|
3328
|
+
return openBlock(), createElementBlock("div", {
|
|
3329
|
+
class: normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
|
|
3330
|
+
}, [
|
|
3331
|
+
createVNode(_sfc_main$q, {
|
|
3332
|
+
ref_key: "codeEditor",
|
|
3333
|
+
ref: codeEditor,
|
|
3334
|
+
class: "m-editor-container",
|
|
3335
|
+
"init-values": `${codeContent.value}`,
|
|
3336
|
+
onSave: saveCodeDraft,
|
|
3337
|
+
language: __props.language,
|
|
3338
|
+
options: unref(codeOptions)
|
|
3339
|
+
}, null, 8, ["init-values", "language", "options"]),
|
|
3340
|
+
__props.editable ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
3341
|
+
createVNode(unref(TMagicButton), {
|
|
3342
|
+
type: "primary",
|
|
3343
|
+
class: "button",
|
|
3344
|
+
onClick: toggleFullScreen
|
|
3345
|
+
}, {
|
|
3346
|
+
default: withCtx(() => [
|
|
3347
|
+
createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
|
|
3348
|
+
]),
|
|
3349
|
+
_: 1
|
|
3350
|
+
}),
|
|
3351
|
+
createVNode(unref(TMagicButton), {
|
|
3352
|
+
type: "primary",
|
|
3353
|
+
class: "button",
|
|
3354
|
+
onClick: saveCode
|
|
3355
|
+
}, {
|
|
3356
|
+
default: withCtx(() => [
|
|
3357
|
+
_hoisted_2$5
|
|
3358
|
+
]),
|
|
3359
|
+
_: 1
|
|
3360
|
+
}),
|
|
3361
|
+
createVNode(unref(TMagicButton), {
|
|
3362
|
+
type: "primary",
|
|
3363
|
+
class: "button",
|
|
3364
|
+
onClick: close
|
|
3365
|
+
}, {
|
|
3366
|
+
default: withCtx(() => [
|
|
3367
|
+
_hoisted_3$3
|
|
3368
|
+
]),
|
|
3369
|
+
_: 1
|
|
3370
|
+
})
|
|
3371
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_4$2, [
|
|
3372
|
+
createVNode(unref(TMagicButton), {
|
|
3373
|
+
type: "primary",
|
|
3374
|
+
class: "button",
|
|
3375
|
+
onClick: toggleFullScreen
|
|
3376
|
+
}, {
|
|
3377
|
+
default: withCtx(() => [
|
|
3378
|
+
createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
|
|
3379
|
+
]),
|
|
3380
|
+
_: 1
|
|
3381
|
+
}),
|
|
3382
|
+
createVNode(unref(TMagicButton), {
|
|
3383
|
+
type: "primary",
|
|
3384
|
+
class: "button",
|
|
3385
|
+
onClick: close
|
|
3386
|
+
}, {
|
|
3387
|
+
default: withCtx(() => [
|
|
3388
|
+
_hoisted_5$1
|
|
3389
|
+
]),
|
|
3390
|
+
_: 1
|
|
3391
|
+
})
|
|
3392
|
+
]))
|
|
3393
|
+
], 2);
|
|
3394
|
+
};
|
|
3395
|
+
}
|
|
3396
|
+
});
|
|
3397
|
+
|
|
3398
|
+
const _hoisted_1$8 = { class: "code-name-wrapper" };
|
|
3399
|
+
const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
|
|
3400
|
+
const _hoisted_3$2 = { class: "code-name-wrapper" };
|
|
3401
|
+
const _hoisted_4$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u53C2\u6570\u5B9A\u4E49", -1);
|
|
3402
|
+
const __default__$f = defineComponent({
|
|
3403
|
+
name: "MEditorFunctionEditor"
|
|
3404
|
+
});
|
|
3126
3405
|
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
3127
|
-
|
|
3406
|
+
...__default__$f,
|
|
3407
|
+
props: {
|
|
3408
|
+
id: null,
|
|
3409
|
+
name: null,
|
|
3410
|
+
content: null,
|
|
3411
|
+
editable: { type: Boolean, default: true },
|
|
3412
|
+
autoSaveDraft: { type: Boolean, default: true },
|
|
3413
|
+
codeOptions: null
|
|
3414
|
+
},
|
|
3415
|
+
emits: ["change", "field-input"],
|
|
3416
|
+
setup(__props, { emit }) {
|
|
3417
|
+
const props = __props;
|
|
3418
|
+
const tableConfig = {
|
|
3419
|
+
border: true,
|
|
3420
|
+
enableFullscreen: false,
|
|
3421
|
+
name: "params",
|
|
3422
|
+
maxHeight: "150px",
|
|
3423
|
+
items: [
|
|
3424
|
+
{
|
|
3425
|
+
type: "text",
|
|
3426
|
+
label: "\u53C2\u6570\u540D",
|
|
3427
|
+
name: "name"
|
|
3428
|
+
}
|
|
3429
|
+
]
|
|
3430
|
+
};
|
|
3431
|
+
const services = inject("services");
|
|
3432
|
+
const codeName = ref("");
|
|
3433
|
+
const codeContent = ref("");
|
|
3434
|
+
const evalRes = ref(true);
|
|
3435
|
+
provide("mForm", {
|
|
3436
|
+
$emit: emit,
|
|
3437
|
+
setField: () => {
|
|
3438
|
+
}
|
|
3439
|
+
});
|
|
3440
|
+
const tableModel = ref();
|
|
3441
|
+
watchEffect(() => {
|
|
3442
|
+
codeName.value = props.name;
|
|
3443
|
+
codeContent.value = props.content;
|
|
3444
|
+
});
|
|
3445
|
+
const initTableModel = () => {
|
|
3446
|
+
const codeDsl = services?.codeBlockService.getCodeDslSync();
|
|
3447
|
+
if (!codeDsl)
|
|
3448
|
+
return;
|
|
3449
|
+
tableModel.value = {
|
|
3450
|
+
params: codeDsl[props.id]?.params || []
|
|
3451
|
+
};
|
|
3452
|
+
};
|
|
3453
|
+
initTableModel();
|
|
3454
|
+
const beforeSave = (codeValue) => {
|
|
3455
|
+
try {
|
|
3456
|
+
eval(codeValue);
|
|
3457
|
+
return true;
|
|
3458
|
+
} catch (e) {
|
|
3459
|
+
tMagicMessage.error(e.stack);
|
|
3460
|
+
return false;
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
const saveCode = async (codeValue2) => {
|
|
3464
|
+
if (!props.editable)
|
|
3465
|
+
return;
|
|
3466
|
+
evalRes.value = beforeSave(codeValue2);
|
|
3467
|
+
if (evalRes.value) {
|
|
3468
|
+
await services?.codeBlockService.setCodeDslById(props.id, {
|
|
3469
|
+
name: codeName.value,
|
|
3470
|
+
content: codeValue2,
|
|
3471
|
+
params: tableModel.value?.params || []
|
|
3472
|
+
});
|
|
3473
|
+
tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
|
|
3474
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3475
|
+
}
|
|
3476
|
+
};
|
|
3477
|
+
const saveAndClose = async (codeValue2) => {
|
|
3478
|
+
await saveCode(codeValue2);
|
|
3479
|
+
if (evalRes.value) {
|
|
3480
|
+
close();
|
|
3481
|
+
}
|
|
3482
|
+
};
|
|
3483
|
+
const close = () => {
|
|
3484
|
+
services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
3485
|
+
};
|
|
3486
|
+
return (_ctx, _cache) => {
|
|
3487
|
+
const _component_m_form_table = resolveComponent("m-form-table");
|
|
3488
|
+
return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
|
|
3489
|
+
header: withCtx(() => [
|
|
3490
|
+
createElementVNode("div", _hoisted_1$8, [
|
|
3491
|
+
_hoisted_2$4,
|
|
3492
|
+
createVNode(unref(TMagicInput), {
|
|
3493
|
+
class: "code-name-input",
|
|
3494
|
+
modelValue: codeName.value,
|
|
3495
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeName.value = $event),
|
|
3496
|
+
disabled: !__props.editable
|
|
3497
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
3498
|
+
]),
|
|
3499
|
+
createElementVNode("div", _hoisted_3$2, [
|
|
3500
|
+
_hoisted_4$1,
|
|
3501
|
+
createVNode(_component_m_form_table, {
|
|
3502
|
+
style: { "width": "320px" },
|
|
3503
|
+
config: tableConfig,
|
|
3504
|
+
model: tableModel.value,
|
|
3505
|
+
enableToggleMode: false,
|
|
3506
|
+
name: "params",
|
|
3507
|
+
prop: "params",
|
|
3508
|
+
size: "small"
|
|
3509
|
+
}, null, 8, ["model"])
|
|
3510
|
+
])
|
|
3511
|
+
]),
|
|
3512
|
+
default: withCtx(() => [
|
|
3513
|
+
createVNode(_sfc_main$h, {
|
|
3514
|
+
id: __props.id,
|
|
3515
|
+
content: codeContent.value,
|
|
3516
|
+
editable: __props.editable,
|
|
3517
|
+
autoSaveDraft: __props.autoSaveDraft,
|
|
3518
|
+
codeOptions: __props.codeOptions,
|
|
3519
|
+
language: "javascript",
|
|
3520
|
+
onSave: saveCode,
|
|
3521
|
+
onSaveAndClose: saveAndClose,
|
|
3522
|
+
onClose: close
|
|
3523
|
+
}, null, 8, ["id", "content", "editable", "autoSaveDraft", "codeOptions"])
|
|
3524
|
+
]),
|
|
3525
|
+
_: 1
|
|
3526
|
+
});
|
|
3527
|
+
};
|
|
3528
|
+
}
|
|
3529
|
+
});
|
|
3530
|
+
|
|
3531
|
+
const _hoisted_1$7 = ["id"];
|
|
3532
|
+
const _hoisted_2$3 = { class: "list-item" };
|
|
3533
|
+
const _hoisted_3$1 = { class: "code-name" };
|
|
3534
|
+
const __default__$e = defineComponent({
|
|
3535
|
+
name: "MEditorCodeBlockEditor"
|
|
3536
|
+
});
|
|
3537
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
3538
|
+
...__default__$e,
|
|
3128
3539
|
setup(__props) {
|
|
3129
3540
|
const services = inject("services");
|
|
3130
|
-
const
|
|
3541
|
+
const codeOptions = inject("codeOptions", {});
|
|
3131
3542
|
const left = ref(200);
|
|
3132
3543
|
const currentTitle = ref("");
|
|
3133
3544
|
const codeConfig = ref(null);
|
|
3134
3545
|
const state = reactive({
|
|
3135
3546
|
codeList: []
|
|
3136
3547
|
});
|
|
3137
|
-
const isShowCodeBlockEditor = computed(
|
|
3138
|
-
() => codeConfig.value && services?.codeBlockService.getCodeEditorShowStatus() || false
|
|
3139
|
-
);
|
|
3140
3548
|
const mode = computed(() => services?.codeBlockService.getMode());
|
|
3141
3549
|
const id = computed(() => services?.codeBlockService.getId() || "");
|
|
3142
3550
|
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3143
3551
|
const selectedIds = computed(() => services?.codeBlockService.getCombineIds() || []);
|
|
3144
3552
|
watchEffect(async () => {
|
|
3145
|
-
codeConfig.value = await services?.codeBlockService.getCodeContentById(id.value) || null;
|
|
3553
|
+
codeConfig.value = cloneDeep(await services?.codeBlockService.getCodeContentById(id.value)) || null;
|
|
3554
|
+
if (!codeConfig.value)
|
|
3555
|
+
return;
|
|
3556
|
+
codeConfig.value.content = serializeConfig(codeConfig.value.content);
|
|
3146
3557
|
});
|
|
3147
3558
|
watchEffect(async () => {
|
|
3148
3559
|
const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
|
|
@@ -3157,47 +3568,24 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3157
3568
|
});
|
|
3158
3569
|
currentTitle.value = state.codeList[0]?.name || "";
|
|
3159
3570
|
});
|
|
3160
|
-
const saveCode = async () => {
|
|
3161
|
-
if (!codeEditor.value || !codeConfig.value || !editable.value)
|
|
3162
|
-
return true;
|
|
3163
|
-
try {
|
|
3164
|
-
const codeContent = codeEditor.value.getEditor()?.getValue();
|
|
3165
|
-
codeConfig.value.content = eval(codeContent);
|
|
3166
|
-
} catch (e) {
|
|
3167
|
-
tMagicMessage.error(e.stack);
|
|
3168
|
-
return false;
|
|
3169
|
-
}
|
|
3170
|
-
await services?.codeBlockService.setCodeDslById(id.value, {
|
|
3171
|
-
name: codeConfig.value.name,
|
|
3172
|
-
content: codeConfig.value.content
|
|
3173
|
-
});
|
|
3174
|
-
tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
|
|
3175
|
-
return true;
|
|
3176
|
-
};
|
|
3177
|
-
const saveAndClose = async () => {
|
|
3178
|
-
const saveRes = await saveCode();
|
|
3179
|
-
if (saveRes) {
|
|
3180
|
-
await services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
3181
|
-
}
|
|
3182
|
-
};
|
|
3183
3571
|
const selectHandler = (data) => {
|
|
3184
3572
|
services?.codeBlockService.setId(data.id);
|
|
3185
3573
|
currentTitle.value = data.name;
|
|
3186
3574
|
};
|
|
3187
3575
|
return (_ctx, _cache) => {
|
|
3188
3576
|
return openBlock(), createBlock(unref(TMagicDialog), {
|
|
3189
|
-
|
|
3190
|
-
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(isShowCodeBlockEditor) ? isShowCodeBlockEditor.value = $event : null),
|
|
3577
|
+
"model-value": true,
|
|
3191
3578
|
class: "code-editor-dialog",
|
|
3192
3579
|
title: currentTitle.value,
|
|
3193
3580
|
fullscreen: true,
|
|
3194
|
-
"
|
|
3195
|
-
"append-to-body": true
|
|
3581
|
+
"close-on-press-escape": false,
|
|
3582
|
+
"append-to-body": true,
|
|
3583
|
+
"show-close": false
|
|
3196
3584
|
}, {
|
|
3197
3585
|
default: withCtx(() => [
|
|
3198
|
-
createVNode(_sfc_main$
|
|
3586
|
+
createVNode(_sfc_main$o, {
|
|
3199
3587
|
left: left.value,
|
|
3200
|
-
"onUpdate:left": _cache[
|
|
3588
|
+
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
|
|
3201
3589
|
"min-left": 45,
|
|
3202
3590
|
class: "code-editor-layout"
|
|
3203
3591
|
}, createSlots({
|
|
@@ -3209,72 +3597,15 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3209
3597
|
])
|
|
3210
3598
|
}, [
|
|
3211
3599
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: unref(id) }),
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
disabled: !unref(editable)
|
|
3222
|
-
}, null, 8, ["modelValue", "disabled"])) : createCommentVNode("", true)
|
|
3223
|
-
])
|
|
3224
|
-
]),
|
|
3225
|
-
default: withCtx(() => [
|
|
3226
|
-
createElementVNode("div", _hoisted_6$1, [
|
|
3227
|
-
codeConfig.value ? (openBlock(), createBlock(_sfc_main$p, {
|
|
3228
|
-
key: 0,
|
|
3229
|
-
ref_key: "codeEditor",
|
|
3230
|
-
ref: codeEditor,
|
|
3231
|
-
class: "m-editor-container",
|
|
3232
|
-
"init-values": `${codeConfig.value.content}`,
|
|
3233
|
-
onSave: saveCode,
|
|
3234
|
-
options: {
|
|
3235
|
-
tabSize: 2,
|
|
3236
|
-
fontSize: 16,
|
|
3237
|
-
formatOnPaste: true,
|
|
3238
|
-
readOnly: !unref(editable)
|
|
3239
|
-
}
|
|
3240
|
-
}, null, 8, ["init-values", "options"])) : createCommentVNode("", true),
|
|
3241
|
-
unref(editable) ? (openBlock(), createElementBlock("div", _hoisted_7$1, [
|
|
3242
|
-
createVNode(unref(TMagicButton), {
|
|
3243
|
-
type: "primary",
|
|
3244
|
-
class: "button",
|
|
3245
|
-
onClick: saveCode
|
|
3246
|
-
}, {
|
|
3247
|
-
default: withCtx(() => [
|
|
3248
|
-
_hoisted_8$1
|
|
3249
|
-
]),
|
|
3250
|
-
_: 1
|
|
3251
|
-
}),
|
|
3252
|
-
createVNode(unref(TMagicButton), {
|
|
3253
|
-
type: "primary",
|
|
3254
|
-
class: "button",
|
|
3255
|
-
onClick: saveAndClose
|
|
3256
|
-
}, {
|
|
3257
|
-
default: withCtx(() => [
|
|
3258
|
-
_hoisted_9$1
|
|
3259
|
-
]),
|
|
3260
|
-
_: 1
|
|
3261
|
-
})
|
|
3262
|
-
])) : (openBlock(), createElementBlock("div", _hoisted_10, [
|
|
3263
|
-
createVNode(unref(TMagicButton), {
|
|
3264
|
-
type: "primary",
|
|
3265
|
-
class: "button",
|
|
3266
|
-
onClick: saveAndClose
|
|
3267
|
-
}, {
|
|
3268
|
-
default: withCtx(() => [
|
|
3269
|
-
_hoisted_11
|
|
3270
|
-
]),
|
|
3271
|
-
_: 1
|
|
3272
|
-
})
|
|
3273
|
-
]))
|
|
3274
|
-
])
|
|
3275
|
-
]),
|
|
3276
|
-
_: 1
|
|
3277
|
-
})
|
|
3600
|
+
codeConfig.value ? (openBlock(), createBlock(_sfc_main$g, {
|
|
3601
|
+
key: 0,
|
|
3602
|
+
id: unref(id),
|
|
3603
|
+
name: codeConfig.value.name,
|
|
3604
|
+
content: codeConfig.value.content,
|
|
3605
|
+
editable: !!unref(editable),
|
|
3606
|
+
autoSaveDraft: unref(mode) === unref(CodeEditorMode).EDITOR,
|
|
3607
|
+
codeOptions: unref(codeOptions)
|
|
3608
|
+
}, null, 8, ["id", "name", "content", "editable", "autoSaveDraft", "codeOptions"])) : createCommentVNode("", true)
|
|
3278
3609
|
], 2)) : createCommentVNode("", true)
|
|
3279
3610
|
]),
|
|
3280
3611
|
_: 2
|
|
@@ -3309,7 +3640,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3309
3640
|
]), 1032, ["left"])
|
|
3310
3641
|
]),
|
|
3311
3642
|
_: 3
|
|
3312
|
-
}, 8, ["
|
|
3643
|
+
}, 8, ["title"]);
|
|
3313
3644
|
};
|
|
3314
3645
|
}
|
|
3315
3646
|
});
|
|
@@ -3336,8 +3667,11 @@ const _hoisted_9 = /* @__PURE__ */ createElementVNode("svg", {
|
|
|
3336
3667
|
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"
|
|
3337
3668
|
})
|
|
3338
3669
|
], -1);
|
|
3339
|
-
const
|
|
3340
|
-
|
|
3670
|
+
const __default__$d = defineComponent({
|
|
3671
|
+
name: "MEditorCodeBlockList"
|
|
3672
|
+
});
|
|
3673
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
3674
|
+
...__default__$d,
|
|
3341
3675
|
props: {
|
|
3342
3676
|
customError: null
|
|
3343
3677
|
},
|
|
@@ -3345,41 +3679,38 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3345
3679
|
const props = __props;
|
|
3346
3680
|
const services = inject("services");
|
|
3347
3681
|
const state = reactive({
|
|
3348
|
-
codeList: []
|
|
3349
|
-
bindComps: {}
|
|
3682
|
+
codeList: []
|
|
3350
3683
|
});
|
|
3351
3684
|
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3352
|
-
const
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
const
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
id: compId,
|
|
3362
|
-
name: getCompName(compId)
|
|
3685
|
+
const isShowCodeBlockEditor = computed(() => services?.codeBlockService.getCodeEditorShowStatus() || false);
|
|
3686
|
+
const codeCombineInfo = ref(null);
|
|
3687
|
+
const getBindCompsByCodeId = (codeId) => {
|
|
3688
|
+
if (!codeCombineInfo.value || !codeCombineInfo.value[codeId])
|
|
3689
|
+
return [];
|
|
3690
|
+
const bindCompsId = Object.keys(codeCombineInfo.value[codeId]);
|
|
3691
|
+
return bindCompsId.map((compId) => ({
|
|
3692
|
+
compId,
|
|
3693
|
+
compName: getCompName(compId)
|
|
3363
3694
|
}));
|
|
3364
|
-
state.bindComps[codeId] = compsInfo;
|
|
3365
3695
|
};
|
|
3366
3696
|
const initList = async () => {
|
|
3367
|
-
const codeDsl = await services?.codeBlockService.getCodeDsl() || null;
|
|
3368
|
-
|
|
3697
|
+
const codeDsl = cloneDeep(await services?.codeBlockService.getCodeDsl()) || null;
|
|
3698
|
+
codeCombineInfo.value = cloneDeep(services?.codeBlockService.getCombineInfo()) || null;
|
|
3699
|
+
if (!codeDsl || !codeCombineInfo.value)
|
|
3369
3700
|
return;
|
|
3370
3701
|
state.codeList = [];
|
|
3371
3702
|
forIn(codeDsl, (value, codeId) => {
|
|
3372
|
-
getBindCompsByCodeId(codeId, value);
|
|
3373
3703
|
state.codeList.push({
|
|
3374
3704
|
id: codeId,
|
|
3375
3705
|
name: value.name,
|
|
3376
3706
|
codeBlockContent: value,
|
|
3377
|
-
showRelation: true
|
|
3707
|
+
showRelation: true,
|
|
3708
|
+
combineInfo: getBindCompsByCodeId(codeId)
|
|
3378
3709
|
});
|
|
3379
3710
|
});
|
|
3380
3711
|
};
|
|
3381
3712
|
watch(
|
|
3382
|
-
() => services?.codeBlockService.
|
|
3713
|
+
[() => services?.codeBlockService.getCodeDslSync(), () => services?.codeBlockService.refreshCombineInfo()],
|
|
3383
3714
|
() => {
|
|
3384
3715
|
initList();
|
|
3385
3716
|
},
|
|
@@ -3388,20 +3719,6 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3388
3719
|
deep: true
|
|
3389
3720
|
}
|
|
3390
3721
|
);
|
|
3391
|
-
watch(
|
|
3392
|
-
() => services?.editorService.get("node"),
|
|
3393
|
-
(curNode) => {
|
|
3394
|
-
if (!curNode?.id)
|
|
3395
|
-
return;
|
|
3396
|
-
forIn(state.bindComps, (bindCompInfo) => {
|
|
3397
|
-
bindCompInfo.forEach((comp) => {
|
|
3398
|
-
if (comp.id === curNode.id) {
|
|
3399
|
-
comp.name = curNode.name;
|
|
3400
|
-
}
|
|
3401
|
-
});
|
|
3402
|
-
});
|
|
3403
|
-
}
|
|
3404
|
-
);
|
|
3405
3722
|
const createCodeBlock = async () => {
|
|
3406
3723
|
const { codeBlockService } = services || {};
|
|
3407
3724
|
if (!codeBlockService) {
|
|
@@ -3410,9 +3727,10 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3410
3727
|
}
|
|
3411
3728
|
const codeConfig = {
|
|
3412
3729
|
name: "\u4EE3\u7801\u5757",
|
|
3413
|
-
content: `() => {
|
|
3730
|
+
content: `({app, params}) => {
|
|
3414
3731
|
// place your code here
|
|
3415
|
-
}
|
|
3732
|
+
}`,
|
|
3733
|
+
params: []
|
|
3416
3734
|
};
|
|
3417
3735
|
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
3418
3736
|
const id = await codeBlockService.getUniqueId();
|
|
@@ -3424,7 +3742,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3424
3742
|
services?.codeBlockService.setCodeEditorContent(true, key);
|
|
3425
3743
|
};
|
|
3426
3744
|
const deleteCode = (key) => {
|
|
3427
|
-
const
|
|
3745
|
+
const currentCode = state.codeList.find((codeItem) => codeItem.id === key);
|
|
3746
|
+
const existBinds = !isEmpty(currentCode?.combineInfo);
|
|
3428
3747
|
const undeleteableList = services?.codeBlockService.getUndeletableList() || [];
|
|
3429
3748
|
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3430
3749
|
services?.codeBlockService.deleteCodeDslByIds([key]);
|
|
@@ -3490,110 +3809,118 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3490
3809
|
})) : createCommentVNode("", true)
|
|
3491
3810
|
])
|
|
3492
3811
|
]),
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3812
|
+
createVNode(unref(TMagicScrollbar), null, {
|
|
3813
|
+
default: withCtx(() => [
|
|
3814
|
+
!unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
3815
|
+
key: 0,
|
|
3816
|
+
ref_key: "tree",
|
|
3817
|
+
ref: tree,
|
|
3818
|
+
"node-key": "id",
|
|
3819
|
+
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3820
|
+
data: state.codeList,
|
|
3821
|
+
"highlight-current": true,
|
|
3822
|
+
"filter-node-method": filterNode,
|
|
3823
|
+
onNodeClick: toggleCombineRelation
|
|
3824
|
+
}, {
|
|
3825
|
+
default: withCtx(({ data }) => [
|
|
3826
|
+
createElementVNode("div", {
|
|
3827
|
+
id: data.id,
|
|
3828
|
+
class: "list-container"
|
|
3829
|
+
}, [
|
|
3830
|
+
createElementVNode("div", _hoisted_5, [
|
|
3831
|
+
createElementVNode("span", _hoisted_6, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1),
|
|
3832
|
+
createElementVNode("div", _hoisted_7, [
|
|
3833
|
+
createVNode(unref(TMagicTooltip), {
|
|
3834
|
+
effect: "dark",
|
|
3835
|
+
content: unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
|
|
3836
|
+
placement: "bottom"
|
|
3837
|
+
}, {
|
|
3838
|
+
default: withCtx(() => [
|
|
3839
|
+
createVNode(_sfc_main$n, {
|
|
3840
|
+
icon: unref(editable) ? unref(Edit) : unref(View),
|
|
3841
|
+
class: "edit-icon",
|
|
3842
|
+
onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
3843
|
+
}, null, 8, ["icon", "onClick"])
|
|
3844
|
+
]),
|
|
3845
|
+
_: 2
|
|
3846
|
+
}, 1032, ["content"]),
|
|
3847
|
+
data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3848
|
+
key: 0,
|
|
3849
|
+
effect: "dark",
|
|
3850
|
+
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3851
|
+
placement: "bottom"
|
|
3852
|
+
}, {
|
|
3853
|
+
default: withCtx(() => [
|
|
3854
|
+
createVNode(_sfc_main$n, {
|
|
3855
|
+
icon: unref(Link),
|
|
3856
|
+
class: "edit-icon",
|
|
3857
|
+
onClick: withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
3858
|
+
}, null, 8, ["icon", "onClick"])
|
|
3859
|
+
]),
|
|
3860
|
+
_: 2
|
|
3861
|
+
}, 1024)) : createCommentVNode("", true),
|
|
3862
|
+
unref(editable) ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3863
|
+
key: 1,
|
|
3864
|
+
effect: "dark",
|
|
3865
|
+
content: "\u5220\u9664",
|
|
3866
|
+
placement: "bottom"
|
|
3867
|
+
}, {
|
|
3868
|
+
default: withCtx(() => [
|
|
3869
|
+
createVNode(_sfc_main$n, {
|
|
3870
|
+
icon: unref(Close),
|
|
3871
|
+
class: "edit-icon",
|
|
3872
|
+
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
3873
|
+
}, null, 8, ["icon", "onClick"])
|
|
3874
|
+
]),
|
|
3875
|
+
_: 2
|
|
3876
|
+
}, 1024)) : createCommentVNode("", true),
|
|
3877
|
+
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
3878
|
+
id: data.id,
|
|
3879
|
+
data: data.codeBlockContent
|
|
3880
|
+
})
|
|
3881
|
+
])
|
|
3882
|
+
]),
|
|
3883
|
+
data.showRelation && data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
3884
|
+
_hoisted_9,
|
|
3885
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(data.combineInfo, (comp, index) => {
|
|
3886
|
+
return openBlock(), createBlock(unref(TMagicButton), {
|
|
3887
|
+
key: index,
|
|
3888
|
+
class: "code-comp",
|
|
3889
|
+
size: "small",
|
|
3890
|
+
plain: true,
|
|
3891
|
+
onClick: withModifiers(($event) => selectComp(comp.compId), ["stop"])
|
|
3892
|
+
}, {
|
|
3893
|
+
default: withCtx(() => [
|
|
3894
|
+
createTextVNode(toDisplayString(comp.compName), 1)
|
|
3895
|
+
]),
|
|
3896
|
+
_: 2
|
|
3897
|
+
}, 1032, ["onClick"]);
|
|
3898
|
+
}), 128))
|
|
3899
|
+
])) : createCommentVNode("", true)
|
|
3900
|
+
], 8, _hoisted_4)
|
|
3561
3901
|
]),
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(state.bindComps[data.id], (comp, index) => {
|
|
3565
|
-
return openBlock(), createBlock(unref(TMagicButton), {
|
|
3566
|
-
key: index,
|
|
3567
|
-
class: "code-comp",
|
|
3568
|
-
size: "small",
|
|
3569
|
-
plain: true,
|
|
3570
|
-
onClick: withModifiers(($event) => selectComp(comp.id), ["stop"])
|
|
3571
|
-
}, {
|
|
3572
|
-
default: withCtx(() => [
|
|
3573
|
-
createTextVNode(toDisplayString(comp.name), 1)
|
|
3574
|
-
]),
|
|
3575
|
-
_: 2
|
|
3576
|
-
}, 1032, ["onClick"]);
|
|
3577
|
-
}), 128))
|
|
3578
|
-
])) : createCommentVNode("", true)
|
|
3579
|
-
], 8, _hoisted_4)
|
|
3902
|
+
_: 3
|
|
3903
|
+
}, 8, ["data"])) : createCommentVNode("", true)
|
|
3580
3904
|
]),
|
|
3581
3905
|
_: 3
|
|
3582
|
-
}
|
|
3583
|
-
|
|
3906
|
+
}),
|
|
3907
|
+
unref(isShowCodeBlockEditor) ? (openBlock(), createBlock(_sfc_main$f, { key: 0 }, {
|
|
3584
3908
|
"code-block-edit-panel-header": withCtx(({ id }) => [
|
|
3585
3909
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
3586
3910
|
]),
|
|
3587
3911
|
_: 3
|
|
3588
|
-
})
|
|
3912
|
+
})) : createCommentVNode("", true)
|
|
3589
3913
|
]);
|
|
3590
3914
|
};
|
|
3591
3915
|
}
|
|
3592
3916
|
});
|
|
3593
3917
|
|
|
3594
3918
|
const _hoisted_1$5 = ["onClick", "onDragstart"];
|
|
3595
|
-
const
|
|
3596
|
-
|
|
3919
|
+
const __default__$c = defineComponent({
|
|
3920
|
+
name: "MEditorComponentListPanel"
|
|
3921
|
+
});
|
|
3922
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
3923
|
+
...__default__$c,
|
|
3597
3924
|
setup(__props) {
|
|
3598
3925
|
const searchText = ref("");
|
|
3599
3926
|
const services = inject("services");
|
|
@@ -3682,7 +4009,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3682
4009
|
name: `${index}`
|
|
3683
4010
|
}, {
|
|
3684
4011
|
title: withCtx(() => [
|
|
3685
|
-
createVNode(_sfc_main$
|
|
4012
|
+
createVNode(_sfc_main$n, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
3686
4013
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3687
4014
|
]),
|
|
3688
4015
|
default: withCtx(() => [
|
|
@@ -3697,7 +4024,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3697
4024
|
onDrag: dragHandler
|
|
3698
4025
|
}, [
|
|
3699
4026
|
renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
3700
|
-
createVNode(_sfc_main$
|
|
4027
|
+
createVNode(_sfc_main$n, {
|
|
3701
4028
|
icon: item.icon
|
|
3702
4029
|
}, null, 8, ["icon"]),
|
|
3703
4030
|
createVNode(unref(TMagicTooltip), {
|
|
@@ -3728,8 +4055,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3728
4055
|
}
|
|
3729
4056
|
});
|
|
3730
4057
|
|
|
3731
|
-
const
|
|
3732
|
-
|
|
4058
|
+
const __default__$b = defineComponent({
|
|
4059
|
+
name: "MEditorContentMenu"
|
|
4060
|
+
});
|
|
4061
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
4062
|
+
...__default__$b,
|
|
3733
4063
|
props: {
|
|
3734
4064
|
menuData: { default: () => [] },
|
|
3735
4065
|
isSubMenu: { type: Boolean, default: false }
|
|
@@ -3817,7 +4147,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3817
4147
|
}, [
|
|
3818
4148
|
createElementVNode("div", null, [
|
|
3819
4149
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
3820
|
-
return openBlock(), createBlock(_sfc_main$
|
|
4150
|
+
return openBlock(), createBlock(_sfc_main$k, {
|
|
3821
4151
|
"event-type": "mouseup",
|
|
3822
4152
|
data: item,
|
|
3823
4153
|
key: index,
|
|
@@ -3843,16 +4173,22 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3843
4173
|
}
|
|
3844
4174
|
});
|
|
3845
4175
|
|
|
3846
|
-
const
|
|
3847
|
-
|
|
4176
|
+
const __default__$a = defineComponent({
|
|
4177
|
+
name: "MEditorLayerMenu"
|
|
4178
|
+
});
|
|
4179
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
4180
|
+
...__default__$a,
|
|
4181
|
+
props: {
|
|
4182
|
+
layerContentMenu: null
|
|
4183
|
+
},
|
|
3848
4184
|
setup(__props, { expose }) {
|
|
4185
|
+
const props = __props;
|
|
3849
4186
|
const services = inject("services");
|
|
3850
4187
|
const menu = ref();
|
|
3851
4188
|
const node = computed(() => services?.editorService.get("node"));
|
|
3852
4189
|
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
3853
4190
|
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3854
4191
|
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
3855
|
-
const layerContentMenu = inject("layerContentMenu", []);
|
|
3856
4192
|
const createMenuItems = (group) => group.items.map((component) => ({
|
|
3857
4193
|
text: component.text,
|
|
3858
4194
|
type: "button",
|
|
@@ -3907,7 +4243,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3907
4243
|
{
|
|
3908
4244
|
type: "button",
|
|
3909
4245
|
text: "\u590D\u5236",
|
|
3910
|
-
icon: markRaw(
|
|
4246
|
+
icon: markRaw(CopyDocument),
|
|
3911
4247
|
display: () => !isRoot.value,
|
|
3912
4248
|
handler: () => {
|
|
3913
4249
|
node.value && services?.editorService.copy(node.value);
|
|
@@ -3922,7 +4258,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3922
4258
|
node.value && services?.editorService.remove(node.value);
|
|
3923
4259
|
}
|
|
3924
4260
|
},
|
|
3925
|
-
...layerContentMenu
|
|
4261
|
+
...props.layerContentMenu
|
|
3926
4262
|
]);
|
|
3927
4263
|
const show = (e) => {
|
|
3928
4264
|
menu.value?.show(e);
|
|
@@ -3931,7 +4267,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3931
4267
|
show
|
|
3932
4268
|
});
|
|
3933
4269
|
return (_ctx, _cache) => {
|
|
3934
|
-
return openBlock(), createBlock(_sfc_main$
|
|
4270
|
+
return openBlock(), createBlock(_sfc_main$c, {
|
|
3935
4271
|
"menu-data": unref(menuData),
|
|
3936
4272
|
ref_key: "menu",
|
|
3937
4273
|
ref: menu,
|
|
@@ -3942,27 +4278,42 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3942
4278
|
});
|
|
3943
4279
|
|
|
3944
4280
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
3945
|
-
const
|
|
3946
|
-
|
|
4281
|
+
const __default__$9 = defineComponent({
|
|
4282
|
+
name: "MEditorLayerPanel"
|
|
4283
|
+
});
|
|
4284
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
4285
|
+
...__default__$9,
|
|
4286
|
+
props: {
|
|
4287
|
+
layerContentMenu: null
|
|
4288
|
+
},
|
|
3947
4289
|
setup(__props) {
|
|
3948
4290
|
const throttleTime = 150;
|
|
3949
4291
|
const services = inject("services");
|
|
4292
|
+
const editorService = services?.editorService;
|
|
3950
4293
|
const tree = ref();
|
|
3951
4294
|
const menu = ref();
|
|
3952
|
-
const
|
|
4295
|
+
const checkedKeys = ref([]);
|
|
4296
|
+
const isCtrlKeyDown = ref(false);
|
|
4297
|
+
const filterText = ref("");
|
|
4298
|
+
const expandedKeys = ref([]);
|
|
4299
|
+
const currentNodeKey = ref();
|
|
4300
|
+
const clicked = ref(false);
|
|
4301
|
+
const treeProps = {
|
|
4302
|
+
children: "items",
|
|
4303
|
+
disabled: (data) => Boolean(data.items?.length),
|
|
4304
|
+
class: (data) => {
|
|
4305
|
+
if (clicked.value || isPage(data))
|
|
4306
|
+
return "";
|
|
4307
|
+
if (data.id === highlightNode?.value?.id && !checkedKeys.value.includes(data.id)) {
|
|
4308
|
+
return "cus-tree-node-hover";
|
|
4309
|
+
}
|
|
4310
|
+
}
|
|
4311
|
+
};
|
|
4312
|
+
const isMultiSelect = computed(() => isCtrlKeyDown.value || checkedKeys.value.length > 1);
|
|
4313
|
+
const nodes = computed(() => editorService?.get("nodes") || []);
|
|
3953
4314
|
const page = computed(() => editorService?.get("page"));
|
|
3954
4315
|
const values = computed(() => page.value ? [page.value] : []);
|
|
3955
|
-
const
|
|
3956
|
-
const selectedIds = computed(() => selectedNodes.value.map((node) => node.id));
|
|
3957
|
-
const isMultiSelectStatus = ref(false);
|
|
3958
|
-
const spliceNodeKey = ref();
|
|
3959
|
-
const filterText = ref("");
|
|
3960
|
-
const defaultExpandedKeys = computed(() => selectedIds.value.length > 0 ? selectedIds.value : []);
|
|
3961
|
-
editorService?.on("remove", () => {
|
|
3962
|
-
setTimeout(() => {
|
|
3963
|
-
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
3964
|
-
}, 0);
|
|
3965
|
-
});
|
|
4316
|
+
const highlightNode = computed(() => editorService?.get("highlightNode"));
|
|
3966
4317
|
const select = async (data) => {
|
|
3967
4318
|
if (!data.id) {
|
|
3968
4319
|
throw new Error("\u6CA1\u6709id");
|
|
@@ -3981,7 +4332,6 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
3981
4332
|
editorService?.highlight(data);
|
|
3982
4333
|
editorService?.get("stage")?.highlight(data.id);
|
|
3983
4334
|
};
|
|
3984
|
-
const expandedKeys = /* @__PURE__ */ new Map();
|
|
3985
4335
|
const allowDrop = (draggingNode, dropNode, type) => {
|
|
3986
4336
|
const { data } = dropNode || {};
|
|
3987
4337
|
const { data: ingData } = draggingNode;
|
|
@@ -4013,23 +4363,18 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
4013
4363
|
const [page2] = data;
|
|
4014
4364
|
editorService?.update(page2);
|
|
4015
4365
|
};
|
|
4016
|
-
const loadItems = (node, resolve) => {
|
|
4017
|
-
if (Array.isArray(node.data)) {
|
|
4018
|
-
return resolve(node.data);
|
|
4019
|
-
}
|
|
4020
|
-
if (Array.isArray(node.data?.items)) {
|
|
4021
|
-
return resolve(node.data?.items);
|
|
4022
|
-
}
|
|
4023
|
-
resolve([]);
|
|
4024
|
-
};
|
|
4025
4366
|
const handleCollapse = (data) => {
|
|
4026
|
-
expandedKeys.
|
|
4367
|
+
expandedKeys.value = expandedKeys.value.filter((id) => id !== data.id);
|
|
4027
4368
|
};
|
|
4028
4369
|
const handleExpand = (data) => {
|
|
4029
|
-
|
|
4030
|
-
|
|
4370
|
+
if (!page.value) {
|
|
4371
|
+
expandedKeys.value = [];
|
|
4031
4372
|
return;
|
|
4032
|
-
|
|
4373
|
+
}
|
|
4374
|
+
expandedKeys.value = union(
|
|
4375
|
+
expandedKeys.value,
|
|
4376
|
+
getNodePath(data.id, [page.value]).map((node) => node.id)
|
|
4377
|
+
);
|
|
4033
4378
|
};
|
|
4034
4379
|
const filterNode = (value, data) => {
|
|
4035
4380
|
if (!value) {
|
|
@@ -4046,121 +4391,78 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
4046
4391
|
const filterTextChangeHandler = (val) => {
|
|
4047
4392
|
tree.value?.filter(val);
|
|
4048
4393
|
};
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
tree.value.getNode(key)?.expand();
|
|
4062
|
-
});
|
|
4063
|
-
};
|
|
4064
|
-
watch(
|
|
4065
|
-
() => editorService?.get("nodes"),
|
|
4066
|
-
(nodes) => {
|
|
4067
|
-
selectedNodes.value = nodes ?? [];
|
|
4394
|
+
watch(nodes, (nodes2) => {
|
|
4395
|
+
const ids = nodes2?.map((node) => node.id) || [];
|
|
4396
|
+
const idsLength = ids.length;
|
|
4397
|
+
const checkedKeysLength = checkedKeys.value.length;
|
|
4398
|
+
if (difference(
|
|
4399
|
+
idsLength > checkedKeysLength ? ids : checkedKeys.value,
|
|
4400
|
+
idsLength > checkedKeysLength ? checkedKeys.value : ids
|
|
4401
|
+
).length) {
|
|
4402
|
+
tree.value?.setCheckedKeys([], false);
|
|
4403
|
+
[currentNodeKey.value] = ids;
|
|
4404
|
+
checkedKeys.value = ids.filter((id) => id !== page.value?.id);
|
|
4405
|
+
expandedKeys.value = union(expandedKeys.value, ids);
|
|
4068
4406
|
}
|
|
4069
|
-
);
|
|
4070
|
-
|
|
4071
|
-
if (!
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
tree.value.setCheckedKeys([]);
|
|
4075
|
-
tree.value.setCurrentKey();
|
|
4076
|
-
} else if (selectedIds.value.length === 1 && !isMultiSelectStatus.value) {
|
|
4077
|
-
tree.value.setCurrentKey(selectedIds.value[0], true);
|
|
4078
|
-
tree.value.setCheckedKeys([]);
|
|
4079
|
-
} else {
|
|
4080
|
-
tree.value.setCheckedKeys(selectedIds.value);
|
|
4081
|
-
tree.value.setCurrentKey();
|
|
4407
|
+
});
|
|
4408
|
+
watch(isMultiSelect, (isMultiSelect2) => {
|
|
4409
|
+
if (!isMultiSelect2) {
|
|
4410
|
+
currentNodeKey.value = editorService?.get("node").id;
|
|
4411
|
+
tree.value?.setCurrentKey(currentNodeKey.value);
|
|
4082
4412
|
}
|
|
4083
|
-
};
|
|
4084
|
-
watch([selectedIds, tree], async () => {
|
|
4085
|
-
if (!tree.value || !editorService)
|
|
4086
|
-
return;
|
|
4087
|
-
const parent = editorService.get("parent");
|
|
4088
|
-
if (!parent?.id)
|
|
4089
|
-
return;
|
|
4090
|
-
const treeNode = tree.value.getNode(parent.id);
|
|
4091
|
-
treeNode?.updateChildren();
|
|
4092
|
-
await expandNodes();
|
|
4093
|
-
setTreeKeyStatus();
|
|
4094
4413
|
});
|
|
4095
|
-
const
|
|
4096
|
-
|
|
4414
|
+
const editorServiceRemoveHandler = () => {
|
|
4415
|
+
setTimeout(() => {
|
|
4416
|
+
tree.value?.getNode(editorService?.get("node").id)?.updateChildren();
|
|
4417
|
+
}, 0);
|
|
4418
|
+
};
|
|
4419
|
+
const windowBlurHandler = () => {
|
|
4420
|
+
isCtrlKeyDown.value = false;
|
|
4421
|
+
};
|
|
4422
|
+
let keycon;
|
|
4423
|
+
onMounted(() => {
|
|
4424
|
+
editorService?.on("remove", editorServiceRemoveHandler);
|
|
4425
|
+
keycon = new KeyController();
|
|
4097
4426
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4098
4427
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
4099
|
-
keycon.
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
})
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
keycon.value.keyup(ctrl, (e) => {
|
|
4108
|
-
e.inputEvent.preventDefault();
|
|
4109
|
-
isMultiSelectStatus.value = false;
|
|
4428
|
+
keycon.keydown((e) => {
|
|
4429
|
+
if (e.key !== ctrl) {
|
|
4430
|
+
isCtrlKeyDown.value = false;
|
|
4431
|
+
}
|
|
4432
|
+
}).keydown(ctrl, () => {
|
|
4433
|
+
isCtrlKeyDown.value = true;
|
|
4434
|
+
}).keyup(ctrl, () => {
|
|
4435
|
+
isCtrlKeyDown.value = false;
|
|
4110
4436
|
});
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
const highlightNode = computed(() => editorService?.get("highlightNode"));
|
|
4437
|
+
globalThis.addEventListener("blur", windowBlurHandler);
|
|
4438
|
+
});
|
|
4439
|
+
onUnmounted(() => {
|
|
4440
|
+
keycon.destroy();
|
|
4441
|
+
editorService?.off("remove", editorServiceRemoveHandler);
|
|
4442
|
+
globalThis.removeEventListener("blur", windowBlurHandler);
|
|
4443
|
+
});
|
|
4119
4444
|
const highlightHandler = throttle((data) => {
|
|
4120
4445
|
highlight(data);
|
|
4121
4446
|
}, throttleTime);
|
|
4122
4447
|
const toggleClickFlag = () => {
|
|
4123
4448
|
clicked.value = !clicked.value;
|
|
4124
4449
|
};
|
|
4125
|
-
const
|
|
4126
|
-
if (
|
|
4127
|
-
|
|
4128
|
-
return data.id === highlightNode?.value?.id && !selectedIds.value.includes(data.id) && spliceNodeKey.value !== data.id;
|
|
4129
|
-
};
|
|
4130
|
-
watch(isMultiSelectStatus, () => {
|
|
4131
|
-
if (isMultiSelectStatus.value && selectedNodes.value.length === 1 && selectedNodes.value[0].type === NodeType.PAGE) {
|
|
4132
|
-
selectedNodes.value = [];
|
|
4133
|
-
}
|
|
4134
|
-
});
|
|
4135
|
-
const multiClickHandler = (data) => {
|
|
4136
|
-
if (!data?.id) {
|
|
4137
|
-
throw new Error("\u6CA1\u6709id");
|
|
4138
|
-
}
|
|
4139
|
-
if (data.type === NodeType.PAGE) {
|
|
4140
|
-
tree.value?.setCheckedKeys([]);
|
|
4141
|
-
return;
|
|
4142
|
-
}
|
|
4143
|
-
const index = selectedNodes.value.findIndex((node) => node.id === data.id);
|
|
4144
|
-
if (index !== -1) {
|
|
4145
|
-
selectedNodes.value.splice(index, 1);
|
|
4146
|
-
spliceNodeKey.value = data.id;
|
|
4450
|
+
const checkHandler = (data, { checkedNodes }) => {
|
|
4451
|
+
if (checkedNodes.length > 0) {
|
|
4452
|
+
multiSelect(checkedNodes.map((node) => node.id));
|
|
4147
4453
|
} else {
|
|
4148
|
-
|
|
4454
|
+
multiSelect(nodes.value.map((node) => node.id));
|
|
4149
4455
|
}
|
|
4150
|
-
tree.value?.setCheckedKeys(selectedIds.value);
|
|
4151
|
-
multiSelect(selectedIds.value);
|
|
4152
4456
|
};
|
|
4153
4457
|
const clickHandler = (data) => {
|
|
4154
|
-
if (
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
}
|
|
4159
|
-
|
|
4160
|
-
select(data);
|
|
4161
|
-
} else {
|
|
4162
|
-
multiClickHandler(data);
|
|
4458
|
+
if (isCtrlKeyDown.value) {
|
|
4459
|
+
return;
|
|
4460
|
+
}
|
|
4461
|
+
if (services?.uiService.get("uiSelectMode")) {
|
|
4462
|
+
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
4463
|
+
return;
|
|
4163
4464
|
}
|
|
4465
|
+
select(data);
|
|
4164
4466
|
};
|
|
4165
4467
|
const contextmenu = async (event, data) => {
|
|
4166
4468
|
event.preventDefault();
|
|
@@ -4168,11 +4470,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
4168
4470
|
menu.value?.show(event);
|
|
4169
4471
|
};
|
|
4170
4472
|
return (_ctx, _cache) => {
|
|
4171
|
-
return openBlock(), createBlock(unref(TMagicScrollbar), {
|
|
4172
|
-
class: "magic-editor-layer-panel",
|
|
4173
|
-
onMouseenter: addSelectModeListener,
|
|
4174
|
-
onMouseleave: removeSelectModeListener
|
|
4175
|
-
}, {
|
|
4473
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
|
|
4176
4474
|
default: withCtx(() => [
|
|
4177
4475
|
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
4178
4476
|
createVNode(unref(TMagicInput), {
|
|
@@ -4193,30 +4491,30 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
4193
4491
|
"node-key": "id",
|
|
4194
4492
|
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
4195
4493
|
draggable: "",
|
|
4196
|
-
"default-expanded-keys":
|
|
4197
|
-
|
|
4494
|
+
"default-expanded-keys": expandedKeys.value,
|
|
4495
|
+
"default-checked-keys": checkedKeys.value,
|
|
4496
|
+
"current-node-key": currentNodeKey.value,
|
|
4198
4497
|
data: unref(values),
|
|
4199
4498
|
"expand-on-click-node": false,
|
|
4200
|
-
"highlight-current":
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
},
|
|
4499
|
+
"highlight-current": !unref(isMultiSelect),
|
|
4500
|
+
"check-on-click-node": true,
|
|
4501
|
+
props: treeProps,
|
|
4204
4502
|
"filter-node-method": filterNode,
|
|
4205
4503
|
"allow-drop": allowDrop,
|
|
4206
|
-
"show-checkbox":
|
|
4504
|
+
"show-checkbox": unref(isMultiSelect),
|
|
4207
4505
|
onNodeClick: clickHandler,
|
|
4208
4506
|
onNodeContextmenu: contextmenu,
|
|
4209
4507
|
onNodeDragEnd: handleDragEnd,
|
|
4210
4508
|
onNodeCollapse: handleCollapse,
|
|
4211
4509
|
onNodeExpand: handleExpand,
|
|
4212
|
-
onCheck:
|
|
4510
|
+
onCheck: checkHandler,
|
|
4213
4511
|
onMousedown: toggleClickFlag,
|
|
4214
4512
|
onMouseup: toggleClickFlag
|
|
4215
4513
|
}, {
|
|
4216
4514
|
default: withCtx(({ node, data }) => [
|
|
4217
4515
|
createElementVNode("div", {
|
|
4516
|
+
class: "cus-tree-node",
|
|
4218
4517
|
id: data.id,
|
|
4219
|
-
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": canHighlight(data) }]),
|
|
4220
4518
|
onMouseenter: ($event) => unref(highlightHandler)(data)
|
|
4221
4519
|
}, [
|
|
4222
4520
|
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
@@ -4225,15 +4523,16 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
4225
4523
|
}, () => [
|
|
4226
4524
|
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
4227
4525
|
])
|
|
4228
|
-
],
|
|
4526
|
+
], 40, _hoisted_1$4)
|
|
4229
4527
|
]),
|
|
4230
4528
|
_: 3
|
|
4231
|
-
}, 8, ["default-expanded-keys", "data", "show-checkbox"])) : createCommentVNode("", true),
|
|
4529
|
+
}, 8, ["default-expanded-keys", "default-checked-keys", "current-node-key", "data", "highlight-current", "show-checkbox"])) : createCommentVNode("", true),
|
|
4232
4530
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4233
|
-
createVNode(_sfc_main$
|
|
4531
|
+
createVNode(_sfc_main$b, {
|
|
4234
4532
|
ref_key: "menu",
|
|
4235
|
-
ref: menu
|
|
4236
|
-
|
|
4533
|
+
ref: menu,
|
|
4534
|
+
"layer-content-menu": __props.layerContentMenu
|
|
4535
|
+
}, null, 8, ["layer-content-menu"])
|
|
4237
4536
|
]))
|
|
4238
4537
|
]),
|
|
4239
4538
|
_: 3
|
|
@@ -4246,143 +4545,52 @@ const _hoisted_1$3 = {
|
|
|
4246
4545
|
key: 1,
|
|
4247
4546
|
class: "magic-editor-tab-panel-title"
|
|
4248
4547
|
};
|
|
4249
|
-
const
|
|
4250
|
-
|
|
4251
|
-
props: {
|
|
4252
|
-
data: null
|
|
4253
|
-
},
|
|
4254
|
-
setup(__props) {
|
|
4255
|
-
const props = __props;
|
|
4256
|
-
const config = computed(() => {
|
|
4257
|
-
if (typeof props.data !== "string") {
|
|
4258
|
-
return props.data;
|
|
4259
|
-
}
|
|
4260
|
-
switch (props.data) {
|
|
4261
|
-
case "component-list":
|
|
4262
|
-
return {
|
|
4263
|
-
type: "component",
|
|
4264
|
-
icon: Coin,
|
|
4265
|
-
text: "\u7EC4\u4EF6",
|
|
4266
|
-
component: _sfc_main$e,
|
|
4267
|
-
slots: {}
|
|
4268
|
-
};
|
|
4269
|
-
case "layer":
|
|
4270
|
-
return {
|
|
4271
|
-
type: "component",
|
|
4272
|
-
icon: Files,
|
|
4273
|
-
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
4274
|
-
component: _sfc_main$b,
|
|
4275
|
-
slots: {}
|
|
4276
|
-
};
|
|
4277
|
-
case "code-block":
|
|
4278
|
-
return {
|
|
4279
|
-
type: "component",
|
|
4280
|
-
icon: EditPen,
|
|
4281
|
-
text: "\u4EE3\u7801\u7F16\u8F91",
|
|
4282
|
-
component: _sfc_main$f,
|
|
4283
|
-
slots: {}
|
|
4284
|
-
};
|
|
4285
|
-
default:
|
|
4286
|
-
return void 0;
|
|
4287
|
-
}
|
|
4288
|
-
});
|
|
4289
|
-
return (_ctx, _cache) => {
|
|
4290
|
-
return unref(config) ? (openBlock(), createBlock(unref(TMagicTabPane), {
|
|
4291
|
-
key: 0,
|
|
4292
|
-
name: unref(config).text
|
|
4293
|
-
}, {
|
|
4294
|
-
label: withCtx(() => [
|
|
4295
|
-
(openBlock(), createElementBlock("div", {
|
|
4296
|
-
key: unref(config).text
|
|
4297
|
-
}, [
|
|
4298
|
-
unref(config).icon ? (openBlock(), createBlock(_sfc_main$o, {
|
|
4299
|
-
key: 0,
|
|
4300
|
-
icon: unref(config).icon
|
|
4301
|
-
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
4302
|
-
unref(config).text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(unref(config).text), 1)) : createCommentVNode("", true)
|
|
4303
|
-
]))
|
|
4304
|
-
]),
|
|
4305
|
-
default: withCtx(() => [
|
|
4306
|
-
(openBlock(), createBlock(resolveDynamicComponent(unref(config).component), mergeProps(unref(config).props || {}, toHandlers(unref(config)?.listeners || {})), createSlots({ _: 2 }, [
|
|
4307
|
-
__props.data === "component-list" || unref(config).slots?.componentListPanelHeader ? {
|
|
4308
|
-
name: "component-list-panel-header",
|
|
4309
|
-
fn: withCtx(() => [
|
|
4310
|
-
__props.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : unref(config).slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4311
|
-
])
|
|
4312
|
-
} : void 0,
|
|
4313
|
-
__props.data === "component-list" || unref(config).slots?.componentListItem ? {
|
|
4314
|
-
name: "component-list-item",
|
|
4315
|
-
fn: withCtx(({ component }) => [
|
|
4316
|
-
__props.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
|
|
4317
|
-
key: 0,
|
|
4318
|
-
component
|
|
4319
|
-
}) : unref(config).slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.componentListItem), {
|
|
4320
|
-
key: 1,
|
|
4321
|
-
component
|
|
4322
|
-
}, null, 8, ["component"])) : createCommentVNode("", true)
|
|
4323
|
-
])
|
|
4324
|
-
} : void 0,
|
|
4325
|
-
__props.data === "layer" || unref(config).slots?.layerPanelHeader ? {
|
|
4326
|
-
name: "layer-panel-header",
|
|
4327
|
-
fn: withCtx(() => [
|
|
4328
|
-
__props.data === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : unref(config).slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4329
|
-
])
|
|
4330
|
-
} : void 0,
|
|
4331
|
-
__props.data === "code-block" || unref(config).slots?.codeBlockPanelHeader ? {
|
|
4332
|
-
name: "code-block-panel-header",
|
|
4333
|
-
fn: withCtx(() => [
|
|
4334
|
-
__props.data === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : unref(config).slots?.codeBlockPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.codeBlockPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4335
|
-
])
|
|
4336
|
-
} : void 0,
|
|
4337
|
-
__props.data === "code-block" || unref(config).slots?.codeBlockPanelTool ? {
|
|
4338
|
-
name: "code-block-panel-tool",
|
|
4339
|
-
fn: withCtx(({ id, data }) => [
|
|
4340
|
-
data === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4341
|
-
key: 0,
|
|
4342
|
-
id,
|
|
4343
|
-
data
|
|
4344
|
-
}) : unref(config).slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("", true)
|
|
4345
|
-
])
|
|
4346
|
-
} : void 0,
|
|
4347
|
-
__props.data === "code-block" || unref(config).slots?.codeBlockEditPanelHeader ? {
|
|
4348
|
-
name: "code-block-edit-panel-header",
|
|
4349
|
-
fn: withCtx(({ id }) => [
|
|
4350
|
-
__props.data === "code-block" ? renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
|
|
4351
|
-
key: 0,
|
|
4352
|
-
id
|
|
4353
|
-
}) : unref(config).slots?.codeBlockEditPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.codeBlockEditPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4354
|
-
])
|
|
4355
|
-
} : void 0,
|
|
4356
|
-
__props.data === "layer" || unref(config).slots?.layerNodeContent ? {
|
|
4357
|
-
name: "layer-node-content",
|
|
4358
|
-
fn: withCtx(({ data: nodeData, node }) => [
|
|
4359
|
-
__props.data === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4360
|
-
key: 0,
|
|
4361
|
-
data: nodeData,
|
|
4362
|
-
node
|
|
4363
|
-
}) : unref(config).slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.layerNodeContent), {
|
|
4364
|
-
key: 1,
|
|
4365
|
-
data: nodeData,
|
|
4366
|
-
node
|
|
4367
|
-
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
4368
|
-
])
|
|
4369
|
-
} : void 0
|
|
4370
|
-
]), 1040))
|
|
4371
|
-
]),
|
|
4372
|
-
_: 3
|
|
4373
|
-
}, 8, ["name"])) : createCommentVNode("", true);
|
|
4374
|
-
};
|
|
4375
|
-
}
|
|
4548
|
+
const __default__$8 = defineComponent({
|
|
4549
|
+
name: "MEditorSidebar"
|
|
4376
4550
|
});
|
|
4377
|
-
|
|
4378
4551
|
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
4379
|
-
|
|
4552
|
+
...__default__$8,
|
|
4380
4553
|
props: {
|
|
4381
|
-
data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) }
|
|
4554
|
+
data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) },
|
|
4555
|
+
layerContentMenu: null
|
|
4382
4556
|
},
|
|
4383
4557
|
setup(__props, { expose }) {
|
|
4384
4558
|
const props = __props;
|
|
4559
|
+
const uiComponent = getConfig$1("components").tabPane;
|
|
4385
4560
|
const activeTabName = ref(props.data?.status);
|
|
4561
|
+
const getItemConfig = (data) => {
|
|
4562
|
+
const map = {
|
|
4563
|
+
"component-list": {
|
|
4564
|
+
$key: "component-list",
|
|
4565
|
+
type: "component",
|
|
4566
|
+
icon: Coin,
|
|
4567
|
+
text: "\u7EC4\u4EF6",
|
|
4568
|
+
component: _sfc_main$d,
|
|
4569
|
+
slots: {}
|
|
4570
|
+
},
|
|
4571
|
+
layer: {
|
|
4572
|
+
$key: "layer",
|
|
4573
|
+
type: "component",
|
|
4574
|
+
icon: Files,
|
|
4575
|
+
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
4576
|
+
props: {
|
|
4577
|
+
layerContentMenu: props.layerContentMenu
|
|
4578
|
+
},
|
|
4579
|
+
component: _sfc_main$a,
|
|
4580
|
+
slots: {}
|
|
4581
|
+
},
|
|
4582
|
+
"code-block": {
|
|
4583
|
+
$key: "code-block",
|
|
4584
|
+
type: "component",
|
|
4585
|
+
icon: EditPen,
|
|
4586
|
+
text: "\u4EE3\u7801\u7F16\u8F91",
|
|
4587
|
+
component: _sfc_main$e,
|
|
4588
|
+
slots: {}
|
|
4589
|
+
}
|
|
4590
|
+
};
|
|
4591
|
+
return typeof data === "string" ? map[data] : data;
|
|
4592
|
+
};
|
|
4593
|
+
const sideBarItems = computed(() => props.data.items.map((item) => getItemConfig(item)));
|
|
4386
4594
|
watch(
|
|
4387
4595
|
() => props.data.status,
|
|
4388
4596
|
(status) => {
|
|
@@ -4402,60 +4610,91 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4402
4610
|
"tab-position": "left"
|
|
4403
4611
|
}, {
|
|
4404
4612
|
default: withCtx(() => [
|
|
4405
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
4406
|
-
return openBlock(), createBlock(
|
|
4613
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(sideBarItems), (config, index) => {
|
|
4614
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(uiComponent).component), {
|
|
4407
4615
|
key: index,
|
|
4408
|
-
|
|
4409
|
-
},
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4616
|
+
name: config.text
|
|
4617
|
+
}, {
|
|
4618
|
+
label: withCtx(() => [
|
|
4619
|
+
(openBlock(), createElementBlock("div", {
|
|
4620
|
+
key: config.text
|
|
4621
|
+
}, [
|
|
4622
|
+
config.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
4623
|
+
key: 0,
|
|
4624
|
+
icon: config.icon
|
|
4625
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
4626
|
+
config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(config.text), 1)) : createCommentVNode("", true)
|
|
4627
|
+
]))
|
|
4628
|
+
]),
|
|
4629
|
+
default: withCtx(() => [
|
|
4630
|
+
config ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({ key: 0 }, config.props || {}, toHandlers(config?.listeners || {})), createSlots({ _: 2 }, [
|
|
4631
|
+
config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
|
|
4632
|
+
name: "component-list-panel-header",
|
|
4633
|
+
fn: withCtx(() => [
|
|
4634
|
+
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)
|
|
4635
|
+
])
|
|
4636
|
+
} : void 0,
|
|
4637
|
+
config.$key === "component-list" || config.slots?.componentListItem ? {
|
|
4638
|
+
name: "component-list-item",
|
|
4639
|
+
fn: withCtx(({ component }) => [
|
|
4640
|
+
config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
|
|
4641
|
+
key: 0,
|
|
4642
|
+
component
|
|
4643
|
+
}) : config.slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentListItem), {
|
|
4644
|
+
key: 1,
|
|
4645
|
+
component
|
|
4646
|
+
}, null, 8, ["component"])) : createCommentVNode("", true)
|
|
4647
|
+
])
|
|
4648
|
+
} : void 0,
|
|
4649
|
+
config.$key === "layer" || config.slots?.layerPanelHeader ? {
|
|
4650
|
+
name: "layer-panel-header",
|
|
4651
|
+
fn: withCtx(() => [
|
|
4652
|
+
config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4653
|
+
])
|
|
4654
|
+
} : void 0,
|
|
4655
|
+
config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
|
|
4656
|
+
name: "code-block-panel-header",
|
|
4657
|
+
fn: withCtx(() => [
|
|
4658
|
+
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)
|
|
4659
|
+
])
|
|
4660
|
+
} : void 0,
|
|
4661
|
+
config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
|
|
4662
|
+
name: "code-block-panel-tool",
|
|
4663
|
+
fn: withCtx(({ id, data }) => [
|
|
4664
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4665
|
+
key: 0,
|
|
4666
|
+
id,
|
|
4667
|
+
data
|
|
4668
|
+
}) : config.slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("", true)
|
|
4669
|
+
])
|
|
4670
|
+
} : void 0,
|
|
4671
|
+
config.$key === "code-block" || config.slots?.codeBlockEditPanelHeader ? {
|
|
4672
|
+
name: "code-block-edit-panel-header",
|
|
4673
|
+
fn: withCtx(({ id }) => [
|
|
4674
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
|
|
4675
|
+
key: 0,
|
|
4676
|
+
id
|
|
4677
|
+
}) : config.slots?.codeBlockEditPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockEditPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4678
|
+
])
|
|
4679
|
+
} : void 0,
|
|
4680
|
+
config.$key === "layer" || config.slots?.layerNodeContent ? {
|
|
4681
|
+
name: "layer-node-content",
|
|
4682
|
+
fn: withCtx(({ data: nodeData, node }) => [
|
|
4683
|
+
config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4684
|
+
key: 0,
|
|
4685
|
+
data: nodeData,
|
|
4686
|
+
node
|
|
4687
|
+
}) : config.slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerNodeContent), {
|
|
4688
|
+
key: 1,
|
|
4689
|
+
data: nodeData,
|
|
4690
|
+
node
|
|
4691
|
+
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
4692
|
+
])
|
|
4693
|
+
} : void 0
|
|
4694
|
+
]), 1040)) : createCommentVNode("", true)
|
|
4695
|
+
]),
|
|
4696
|
+
_: 2
|
|
4697
|
+
}, 1032, ["name"]);
|
|
4459
4698
|
}), 128))
|
|
4460
4699
|
]),
|
|
4461
4700
|
_: 3
|
|
@@ -4469,8 +4708,11 @@ const _hoisted_1$2 = {
|
|
|
4469
4708
|
class: "m-editor-breadcrumb"
|
|
4470
4709
|
};
|
|
4471
4710
|
const _hoisted_2$1 = { key: 0 };
|
|
4711
|
+
const __default__$7 = defineComponent({
|
|
4712
|
+
name: "MEditorBreadcrumb"
|
|
4713
|
+
});
|
|
4472
4714
|
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
4473
|
-
|
|
4715
|
+
...__default__$7,
|
|
4474
4716
|
setup(__props) {
|
|
4475
4717
|
const services = inject("services");
|
|
4476
4718
|
const editorService = services?.editorService;
|
|
@@ -4510,8 +4752,11 @@ const _hoisted_1$1 = {
|
|
|
4510
4752
|
key: 1,
|
|
4511
4753
|
style: { "width": "21px" }
|
|
4512
4754
|
};
|
|
4755
|
+
const __default__$6 = defineComponent({
|
|
4756
|
+
name: "MEditorPageBarScrollContainer"
|
|
4757
|
+
});
|
|
4513
4758
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
4514
|
-
|
|
4759
|
+
...__default__$6,
|
|
4515
4760
|
setup(__props) {
|
|
4516
4761
|
const services = inject("services");
|
|
4517
4762
|
const editorService = services?.editorService;
|
|
@@ -4592,14 +4837,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4592
4837
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4593
4838
|
onClick: addPage
|
|
4594
4839
|
}, [
|
|
4595
|
-
createVNode(_sfc_main$
|
|
4840
|
+
createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
4596
4841
|
])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
|
|
4597
4842
|
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
4598
4843
|
key: 2,
|
|
4599
4844
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4600
4845
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
4601
4846
|
}, [
|
|
4602
|
-
createVNode(_sfc_main$
|
|
4847
|
+
createVNode(_sfc_main$n, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
|
|
4603
4848
|
])) : createCommentVNode("", true),
|
|
4604
4849
|
unref(pageLength) ? (openBlock(), createElementBlock("div", {
|
|
4605
4850
|
key: 3,
|
|
@@ -4615,7 +4860,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4615
4860
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4616
4861
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
4617
4862
|
}, [
|
|
4618
|
-
createVNode(_sfc_main$
|
|
4863
|
+
createVNode(_sfc_main$n, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
|
|
4619
4864
|
])) : createCommentVNode("", true)
|
|
4620
4865
|
], 512);
|
|
4621
4866
|
};
|
|
@@ -4624,8 +4869,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4624
4869
|
|
|
4625
4870
|
const _hoisted_1 = ["onClick"];
|
|
4626
4871
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
4872
|
+
const __default__$5 = defineComponent({
|
|
4873
|
+
name: "MEditorPageBar"
|
|
4874
|
+
});
|
|
4627
4875
|
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
4628
|
-
|
|
4876
|
+
...__default__$5,
|
|
4629
4877
|
setup(__props) {
|
|
4630
4878
|
const services = inject("services");
|
|
4631
4879
|
const editorService = services?.editorService;
|
|
@@ -4684,7 +4932,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4684
4932
|
default: withCtx(() => [
|
|
4685
4933
|
createElementVNode("div", null, [
|
|
4686
4934
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
4687
|
-
createVNode(_sfc_main$
|
|
4935
|
+
createVNode(_sfc_main$k, {
|
|
4688
4936
|
data: {
|
|
4689
4937
|
type: "button",
|
|
4690
4938
|
text: "\u590D\u5236",
|
|
@@ -4692,7 +4940,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4692
4940
|
handler: () => copy(item)
|
|
4693
4941
|
}
|
|
4694
4942
|
}, null, 8, ["data"]),
|
|
4695
|
-
createVNode(_sfc_main$
|
|
4943
|
+
createVNode(_sfc_main$k, {
|
|
4696
4944
|
data: {
|
|
4697
4945
|
type: "button",
|
|
4698
4946
|
text: "\u5220\u9664",
|
|
@@ -4726,6 +4974,10 @@ class ScrollViewer extends EventEmitter {
|
|
|
4726
4974
|
height = 0;
|
|
4727
4975
|
translateXCorrectionValue = 0;
|
|
4728
4976
|
translateYCorrectionValue = 0;
|
|
4977
|
+
correctionScrollSize = {
|
|
4978
|
+
width: 0,
|
|
4979
|
+
height: 0
|
|
4980
|
+
};
|
|
4729
4981
|
resizeObserver = new ResizeObserver(() => {
|
|
4730
4982
|
this.setSize();
|
|
4731
4983
|
this.setScrollSize();
|
|
@@ -4735,6 +4987,12 @@ class ScrollViewer extends EventEmitter {
|
|
|
4735
4987
|
this.container = options.container;
|
|
4736
4988
|
this.target = options.target;
|
|
4737
4989
|
this.zoom = options.zoom;
|
|
4990
|
+
if (this.correctionScrollSize) {
|
|
4991
|
+
this.correctionScrollSize = {
|
|
4992
|
+
...this.correctionScrollSize,
|
|
4993
|
+
...options.correctionScrollSize
|
|
4994
|
+
};
|
|
4995
|
+
}
|
|
4738
4996
|
this.container.addEventListener("wheel", this.wheelHandler, false);
|
|
4739
4997
|
this.setSize();
|
|
4740
4998
|
this.setScrollSize();
|
|
@@ -4797,9 +5055,9 @@ class ScrollViewer extends EventEmitter {
|
|
|
4797
5055
|
}
|
|
4798
5056
|
setScrollSize = () => {
|
|
4799
5057
|
const targetRect = this.target.getBoundingClientRect();
|
|
4800
|
-
this.scrollWidth = targetRect.width * this.zoom +
|
|
5058
|
+
this.scrollWidth = targetRect.width * this.zoom + this.correctionScrollSize.width;
|
|
4801
5059
|
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
4802
|
-
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom +
|
|
5060
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + this.correctionScrollSize.height;
|
|
4803
5061
|
let left;
|
|
4804
5062
|
let top;
|
|
4805
5063
|
if (this.scrollWidth < this.width) {
|
|
@@ -4832,8 +5090,11 @@ class ScrollViewer extends EventEmitter {
|
|
|
4832
5090
|
};
|
|
4833
5091
|
}
|
|
4834
5092
|
|
|
5093
|
+
const __default__$4 = defineComponent({
|
|
5094
|
+
name: "MEditorScrollBar"
|
|
5095
|
+
});
|
|
4835
5096
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
4836
|
-
|
|
5097
|
+
...__default__$4,
|
|
4837
5098
|
props: {
|
|
4838
5099
|
size: null,
|
|
4839
5100
|
scrollSize: null,
|
|
@@ -4918,14 +5179,21 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
4918
5179
|
|
|
4919
5180
|
const ScrollBar_vue_vue_type_style_index_0_lang = '';
|
|
4920
5181
|
|
|
5182
|
+
const __default__$3 = defineComponent({
|
|
5183
|
+
name: "MEditorScrollViewer"
|
|
5184
|
+
});
|
|
4921
5185
|
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
4922
|
-
|
|
5186
|
+
...__default__$3,
|
|
4923
5187
|
props: {
|
|
4924
5188
|
width: { default: 0 },
|
|
4925
5189
|
height: { default: 0 },
|
|
4926
5190
|
wrapWidth: { default: 0 },
|
|
4927
5191
|
wrapHeight: { default: 0 },
|
|
4928
|
-
zoom: { default: 1 }
|
|
5192
|
+
zoom: { default: 1 },
|
|
5193
|
+
correctionScrollSize: { default: () => ({
|
|
5194
|
+
width: 0,
|
|
5195
|
+
height: 0
|
|
5196
|
+
}) }
|
|
4929
5197
|
},
|
|
4930
5198
|
setup(__props, { expose }) {
|
|
4931
5199
|
const props = __props;
|
|
@@ -4948,7 +5216,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
4948
5216
|
scrollViewer = new ScrollViewer({
|
|
4949
5217
|
container: container.value,
|
|
4950
5218
|
target: el.value,
|
|
4951
|
-
zoom: props.zoom
|
|
5219
|
+
zoom: props.zoom,
|
|
5220
|
+
correctionScrollSize: props.correctionScrollSize
|
|
4952
5221
|
});
|
|
4953
5222
|
scrollViewer.on("scroll", (data) => {
|
|
4954
5223
|
hOffset.value = data.scrollLeft;
|
|
@@ -5016,10 +5285,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
5016
5285
|
}
|
|
5017
5286
|
});
|
|
5018
5287
|
|
|
5288
|
+
const __default__$2 = defineComponent({
|
|
5289
|
+
name: "MEditorViewerMenu"
|
|
5290
|
+
});
|
|
5019
5291
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
5020
|
-
|
|
5292
|
+
...__default__$2,
|
|
5021
5293
|
props: {
|
|
5022
|
-
isMultiSelect: { type: Boolean, default: false }
|
|
5294
|
+
isMultiSelect: { type: Boolean, default: false },
|
|
5295
|
+
stageContentMenu: null
|
|
5023
5296
|
},
|
|
5024
5297
|
setup(__props, { expose }) {
|
|
5025
5298
|
const props = __props;
|
|
@@ -5032,8 +5305,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5032
5305
|
const nodes = computed(() => editorService?.get("nodes"));
|
|
5033
5306
|
const parent = computed(() => editorService?.get("parent"));
|
|
5034
5307
|
const stage = computed(() => editorService?.get("stage"));
|
|
5035
|
-
const
|
|
5036
|
-
const menuData = reactive([
|
|
5308
|
+
const menuData = computed(() => [
|
|
5037
5309
|
{
|
|
5038
5310
|
type: "button",
|
|
5039
5311
|
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
@@ -5047,7 +5319,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5047
5319
|
{
|
|
5048
5320
|
type: "button",
|
|
5049
5321
|
text: "\u590D\u5236",
|
|
5050
|
-
icon: markRaw(
|
|
5322
|
+
icon: markRaw(CopyDocument),
|
|
5051
5323
|
handler: () => {
|
|
5052
5324
|
nodes.value && editorService?.copy(nodes.value);
|
|
5053
5325
|
canPaste.value = true;
|
|
@@ -5056,6 +5328,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5056
5328
|
{
|
|
5057
5329
|
type: "button",
|
|
5058
5330
|
text: "\u7C98\u8D34",
|
|
5331
|
+
icon: markRaw(DocumentCopy),
|
|
5059
5332
|
display: () => canPaste.value,
|
|
5060
5333
|
handler: () => {
|
|
5061
5334
|
const rect = menu.value?.$el.getBoundingClientRect();
|
|
@@ -5135,7 +5408,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5135
5408
|
editorService?.get("stage").clearGuides();
|
|
5136
5409
|
}
|
|
5137
5410
|
},
|
|
5138
|
-
...stageContentMenu
|
|
5411
|
+
...props.stageContentMenu
|
|
5139
5412
|
]);
|
|
5140
5413
|
watch(
|
|
5141
5414
|
parent,
|
|
@@ -5158,8 +5431,8 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5158
5431
|
};
|
|
5159
5432
|
expose({ show });
|
|
5160
5433
|
return (_ctx, _cache) => {
|
|
5161
|
-
return openBlock(), createBlock(_sfc_main$
|
|
5162
|
-
"menu-data": menuData,
|
|
5434
|
+
return openBlock(), createBlock(_sfc_main$c, {
|
|
5435
|
+
"menu-data": unref(menuData),
|
|
5163
5436
|
ref_key: "menu",
|
|
5164
5437
|
ref: menu
|
|
5165
5438
|
}, null, 8, ["menu-data"]);
|
|
@@ -5167,8 +5440,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5167
5440
|
}
|
|
5168
5441
|
});
|
|
5169
5442
|
|
|
5443
|
+
const __default__$1 = defineComponent({
|
|
5444
|
+
name: "MEditorStage"
|
|
5445
|
+
});
|
|
5170
5446
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
5171
|
-
|
|
5447
|
+
...__default__$1,
|
|
5448
|
+
props: {
|
|
5449
|
+
stageContentMenu: null
|
|
5450
|
+
},
|
|
5172
5451
|
setup(__props) {
|
|
5173
5452
|
let stage = null;
|
|
5174
5453
|
let runtime = null;
|
|
@@ -5185,7 +5464,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5185
5464
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
5186
5465
|
const node = computed(() => services?.editorService.get("node"));
|
|
5187
5466
|
watchEffect(() => {
|
|
5188
|
-
if (stage)
|
|
5467
|
+
if (stage || !page.value)
|
|
5189
5468
|
return;
|
|
5190
5469
|
if (!stageContainer.value)
|
|
5191
5470
|
return;
|
|
@@ -5215,6 +5494,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5215
5494
|
runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
|
|
5216
5495
|
}
|
|
5217
5496
|
});
|
|
5497
|
+
watch(page, (page2) => {
|
|
5498
|
+
if (runtime && page2) {
|
|
5499
|
+
runtime.updatePageId?.(page2.id);
|
|
5500
|
+
nextTick(() => {
|
|
5501
|
+
stage?.select(page2.id);
|
|
5502
|
+
});
|
|
5503
|
+
}
|
|
5504
|
+
});
|
|
5218
5505
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
5219
5506
|
for (const { contentRect } of entries) {
|
|
5220
5507
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -5287,7 +5574,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5287
5574
|
height: unref(stageRect)?.height,
|
|
5288
5575
|
"wrap-width": unref(stageContainerRect)?.width,
|
|
5289
5576
|
"wrap-height": unref(stageContainerRect)?.height,
|
|
5290
|
-
zoom: unref(zoom)
|
|
5577
|
+
zoom: unref(zoom),
|
|
5578
|
+
"correction-scroll-size": {
|
|
5579
|
+
width: 60,
|
|
5580
|
+
height: 50
|
|
5581
|
+
}
|
|
5291
5582
|
}, {
|
|
5292
5583
|
default: withCtx(() => [
|
|
5293
5584
|
createElementVNode("div", {
|
|
@@ -5303,8 +5594,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5303
5594
|
createVNode(_sfc_main$3, {
|
|
5304
5595
|
ref_key: "menu",
|
|
5305
5596
|
ref: menu,
|
|
5306
|
-
"is-multi-select": unref(isMultiSelect)
|
|
5307
|
-
|
|
5597
|
+
"is-multi-select": unref(isMultiSelect),
|
|
5598
|
+
"stage-content-menu": __props.stageContentMenu
|
|
5599
|
+
}, null, 8, ["is-multi-select", "stage-content-menu"])
|
|
5308
5600
|
]))
|
|
5309
5601
|
]),
|
|
5310
5602
|
_: 1
|
|
@@ -5313,8 +5605,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
5313
5605
|
}
|
|
5314
5606
|
});
|
|
5315
5607
|
|
|
5608
|
+
const __default__ = defineComponent({
|
|
5609
|
+
name: "MEditorWorkspace"
|
|
5610
|
+
});
|
|
5316
5611
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
5317
|
-
|
|
5612
|
+
...__default__,
|
|
5613
|
+
props: {
|
|
5614
|
+
stageContentMenu: null
|
|
5615
|
+
},
|
|
5318
5616
|
setup(__props) {
|
|
5319
5617
|
const services = inject("services");
|
|
5320
5618
|
const workspace = ref();
|
|
@@ -5425,9 +5723,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
5425
5723
|
}, [
|
|
5426
5724
|
createVNode(_sfc_main$8),
|
|
5427
5725
|
renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
5428
|
-
(openBlock(), createBlock(_sfc_main$2, {
|
|
5429
|
-
key:
|
|
5430
|
-
|
|
5726
|
+
unref(page) ? (openBlock(), createBlock(_sfc_main$2, {
|
|
5727
|
+
key: 0,
|
|
5728
|
+
"stage-content-menu": __props.stageContentMenu
|
|
5729
|
+
}, null, 8, ["stage-content-menu"])) : createCommentVNode("", true)
|
|
5431
5730
|
]),
|
|
5432
5731
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
5433
5732
|
createVNode(_sfc_main$6, null, {
|
|
@@ -5457,9 +5756,13 @@ class ComponentList extends BaseService {
|
|
|
5457
5756
|
getList() {
|
|
5458
5757
|
return this.state.list;
|
|
5459
5758
|
}
|
|
5460
|
-
|
|
5759
|
+
resetState() {
|
|
5461
5760
|
this.state.list = [];
|
|
5761
|
+
}
|
|
5762
|
+
destroy() {
|
|
5763
|
+
this.resetState();
|
|
5462
5764
|
this.removeAllListeners();
|
|
5765
|
+
this.removeAllPlugins();
|
|
5463
5766
|
}
|
|
5464
5767
|
}
|
|
5465
5768
|
const componentListService = new ComponentList();
|
|
@@ -5467,11 +5770,11 @@ const componentListService = new ComponentList();
|
|
|
5467
5770
|
const _sfc_main = defineComponent({
|
|
5468
5771
|
name: "m-editor",
|
|
5469
5772
|
components: {
|
|
5470
|
-
|
|
5773
|
+
TMagicNavMenu: _sfc_main$j,
|
|
5471
5774
|
Sidebar: _sfc_main$9,
|
|
5472
5775
|
Workspace: _sfc_main$1,
|
|
5473
|
-
PropsPanel: _sfc_main$
|
|
5474
|
-
Framework: _sfc_main$
|
|
5776
|
+
PropsPanel: _sfc_main$i,
|
|
5777
|
+
Framework: _sfc_main$l
|
|
5475
5778
|
},
|
|
5476
5779
|
props: {
|
|
5477
5780
|
modelValue: {
|
|
@@ -5486,6 +5789,10 @@ const _sfc_main = defineComponent({
|
|
|
5486
5789
|
sidebar: {
|
|
5487
5790
|
type: Object
|
|
5488
5791
|
},
|
|
5792
|
+
menu: {
|
|
5793
|
+
type: Object,
|
|
5794
|
+
default: () => ({ left: [], right: [] })
|
|
5795
|
+
},
|
|
5489
5796
|
layerContentMenu: {
|
|
5490
5797
|
type: Array,
|
|
5491
5798
|
default: () => []
|
|
@@ -5494,10 +5801,6 @@ const _sfc_main = defineComponent({
|
|
|
5494
5801
|
type: Array,
|
|
5495
5802
|
default: () => []
|
|
5496
5803
|
},
|
|
5497
|
-
menu: {
|
|
5498
|
-
type: Object,
|
|
5499
|
-
default: () => ({ left: [], right: [] })
|
|
5500
|
-
},
|
|
5501
5804
|
render: {
|
|
5502
5805
|
type: Function
|
|
5503
5806
|
},
|
|
@@ -5531,7 +5834,7 @@ const _sfc_main = defineComponent({
|
|
|
5531
5834
|
},
|
|
5532
5835
|
containerHighlightClassName: {
|
|
5533
5836
|
type: String,
|
|
5534
|
-
default:
|
|
5837
|
+
default: CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
5535
5838
|
},
|
|
5536
5839
|
containerHighlightDuration: {
|
|
5537
5840
|
type: Number,
|
|
@@ -5550,20 +5853,33 @@ const _sfc_main = defineComponent({
|
|
|
5550
5853
|
},
|
|
5551
5854
|
updateDragEl: {
|
|
5552
5855
|
type: Function
|
|
5856
|
+
},
|
|
5857
|
+
disabledDragStart: {
|
|
5858
|
+
type: Boolean
|
|
5553
5859
|
}
|
|
5554
5860
|
},
|
|
5555
5861
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
5556
5862
|
setup(props, { emit }) {
|
|
5557
|
-
|
|
5558
|
-
const
|
|
5559
|
-
|
|
5560
|
-
if (nodeId
|
|
5561
|
-
editorService.
|
|
5562
|
-
}
|
|
5863
|
+
const rootChangeHandler = (value, preValue) => {
|
|
5864
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
5865
|
+
let node;
|
|
5866
|
+
if (nodeId) {
|
|
5867
|
+
node = editorService.getNodeById(nodeId);
|
|
5868
|
+
}
|
|
5869
|
+
if (node && node !== value) {
|
|
5870
|
+
editorService.select(node.id);
|
|
5871
|
+
} else if (value?.items?.length) {
|
|
5872
|
+
editorService.select(value.items[0]);
|
|
5873
|
+
} else if (value?.id) {
|
|
5563
5874
|
editorService.set("nodes", [value]);
|
|
5875
|
+
editorService.set("parent", null);
|
|
5876
|
+
editorService.set("page", null);
|
|
5564
5877
|
}
|
|
5565
|
-
|
|
5566
|
-
|
|
5878
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
5879
|
+
emit("update:modelValue", value);
|
|
5880
|
+
}
|
|
5881
|
+
};
|
|
5882
|
+
editorService.on("root-change", rootChangeHandler);
|
|
5567
5883
|
watch(
|
|
5568
5884
|
() => props.modelValue,
|
|
5569
5885
|
(modelValue) => {
|
|
@@ -5625,13 +5941,13 @@ const _sfc_main = defineComponent({
|
|
|
5625
5941
|
}
|
|
5626
5942
|
);
|
|
5627
5943
|
onUnmounted(() => {
|
|
5628
|
-
editorService.
|
|
5629
|
-
historyService.
|
|
5630
|
-
propsService.
|
|
5631
|
-
uiService.
|
|
5632
|
-
componentListService.
|
|
5633
|
-
|
|
5634
|
-
|
|
5944
|
+
editorService.resetState();
|
|
5945
|
+
historyService.resetState();
|
|
5946
|
+
propsService.resetState();
|
|
5947
|
+
uiService.resetState();
|
|
5948
|
+
componentListService.resetState();
|
|
5949
|
+
codeBlockService.resetState();
|
|
5950
|
+
editorService.off("root-change", rootChangeHandler);
|
|
5635
5951
|
});
|
|
5636
5952
|
const services = {
|
|
5637
5953
|
componentListService,
|
|
@@ -5644,8 +5960,7 @@ const _sfc_main = defineComponent({
|
|
|
5644
5960
|
codeBlockService
|
|
5645
5961
|
};
|
|
5646
5962
|
provide("services", services);
|
|
5647
|
-
provide("
|
|
5648
|
-
provide("stageContentMenu", props.stageContentMenu);
|
|
5963
|
+
provide("codeOptions", props.codeOptions);
|
|
5649
5964
|
provide(
|
|
5650
5965
|
"stageOptions",
|
|
5651
5966
|
reactive({
|
|
@@ -5658,7 +5973,8 @@ const _sfc_main = defineComponent({
|
|
|
5658
5973
|
isContainer: props.isContainer,
|
|
5659
5974
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
5660
5975
|
containerHighlightDuration: props.containerHighlightDuration,
|
|
5661
|
-
containerHighlightType: props.containerHighlightType
|
|
5976
|
+
containerHighlightType: props.containerHighlightType,
|
|
5977
|
+
disabledDragStart: props.disabledDragStart
|
|
5662
5978
|
})
|
|
5663
5979
|
);
|
|
5664
5980
|
return services;
|
|
@@ -5674,20 +5990,23 @@ const _export_sfc = (sfc, props) => {
|
|
|
5674
5990
|
};
|
|
5675
5991
|
|
|
5676
5992
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
5677
|
-
const
|
|
5678
|
-
const
|
|
5679
|
-
const
|
|
5680
|
-
const
|
|
5681
|
-
const
|
|
5682
|
-
return openBlock(), createBlock(
|
|
5993
|
+
const _component_TMagicNavMenu = resolveComponent("TMagicNavMenu");
|
|
5994
|
+
const _component_Sidebar = resolveComponent("Sidebar");
|
|
5995
|
+
const _component_Workspace = resolveComponent("Workspace");
|
|
5996
|
+
const _component_PropsPanel = resolveComponent("PropsPanel");
|
|
5997
|
+
const _component_Framework = resolveComponent("Framework");
|
|
5998
|
+
return openBlock(), createBlock(_component_Framework, { "code-options": _ctx.codeOptions }, {
|
|
5683
5999
|
nav: withCtx(() => [
|
|
5684
6000
|
renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
5685
|
-
createVNode(
|
|
6001
|
+
createVNode(_component_TMagicNavMenu, { data: _ctx.menu }, null, 8, ["data"])
|
|
5686
6002
|
])
|
|
5687
6003
|
]),
|
|
5688
6004
|
sidebar: withCtx(() => [
|
|
5689
6005
|
renderSlot(_ctx.$slots, "sidebar", { editorService: _ctx.editorService }, () => [
|
|
5690
|
-
createVNode(
|
|
6006
|
+
createVNode(_component_Sidebar, {
|
|
6007
|
+
data: _ctx.sidebar,
|
|
6008
|
+
"layer-content-menu": _ctx.layerContentMenu
|
|
6009
|
+
}, {
|
|
5691
6010
|
"layer-panel-header": withCtx(() => [
|
|
5692
6011
|
renderSlot(_ctx.$slots, "layer-panel-header")
|
|
5693
6012
|
]),
|
|
@@ -5716,12 +6035,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
5716
6035
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
5717
6036
|
]),
|
|
5718
6037
|
_: 3
|
|
5719
|
-
}, 8, ["data"])
|
|
6038
|
+
}, 8, ["data", "layer-content-menu"])
|
|
5720
6039
|
])
|
|
5721
6040
|
]),
|
|
5722
6041
|
workspace: withCtx(() => [
|
|
5723
6042
|
renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
5724
|
-
createVNode(
|
|
6043
|
+
createVNode(_component_Workspace, { "stage-content-menu": _ctx.stageContentMenu }, {
|
|
5725
6044
|
stage: withCtx(() => [
|
|
5726
6045
|
renderSlot(_ctx.$slots, "stage")
|
|
5727
6046
|
]),
|
|
@@ -5735,12 +6054,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
5735
6054
|
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
5736
6055
|
]),
|
|
5737
6056
|
_: 3
|
|
5738
|
-
})
|
|
6057
|
+
}, 8, ["stage-content-menu"])
|
|
5739
6058
|
])
|
|
5740
6059
|
]),
|
|
5741
6060
|
"props-panel": withCtx(() => [
|
|
5742
6061
|
renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
5743
|
-
createVNode(
|
|
6062
|
+
createVNode(_component_PropsPanel, {
|
|
5744
6063
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
5745
6064
|
}, {
|
|
5746
6065
|
"props-panel-header": withCtx(() => [
|
|
@@ -5767,13 +6086,13 @@ const index = {
|
|
|
5767
6086
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
5768
6087
|
setConfig(option);
|
|
5769
6088
|
app.component(Editor.name, Editor);
|
|
5770
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
5771
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
5772
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
5773
|
-
app.component("magic-code-editor", _sfc_main$
|
|
5774
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
6089
|
+
app.component("m-fields-ui-select", _sfc_main$r);
|
|
6090
|
+
app.component("m-fields-code-link", _sfc_main$t);
|
|
6091
|
+
app.component("m-fields-vs-code", _sfc_main$u);
|
|
6092
|
+
app.component("magic-code-editor", _sfc_main$q);
|
|
6093
|
+
app.component("m-fields-code-select", _sfc_main$s);
|
|
5775
6094
|
}
|
|
5776
6095
|
};
|
|
5777
6096
|
|
|
5778
|
-
export { COPY_STORAGE_KEY, _sfc_main$
|
|
5779
|
-
//# sourceMappingURL=tmagic-editor.
|
|
6097
|
+
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 };
|
|
6098
|
+
//# sourceMappingURL=tmagic-editor.js.map
|