@tmagic/editor 1.1.6 → 1.2.0-beta.2
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 +177 -0
- package/dist/tmagic-editor.mjs +1456 -524
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +1448 -510
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/Editor.vue +18 -1
- package/src/fields/Code.vue +4 -1
- package/src/fields/CodeLink.vue +19 -11
- package/src/fields/CodeSelect.vue +139 -0
- package/src/index.ts +6 -2
- package/src/layouts/AddPageBox.vue +11 -19
- package/src/layouts/CodeEditor.vue +106 -120
- package/src/layouts/Layout.vue +1 -1
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/LayerMenu.vue +86 -91
- package/src/layouts/sidebar/Sidebar.vue +30 -24
- package/src/layouts/sidebar/TabPane.vue +57 -40
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +164 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +267 -0
- package/src/services/codeBlock.ts +415 -0
- package/src/services/editor.ts +27 -1
- package/src/theme/code-block.scss +184 -0
- package/src/theme/index.scss +1 -13
- package/src/theme/layout.scss +5 -0
- package/src/theme/theme.scss +15 -0
- package/src/type.ts +87 -1
- package/src/utils/props.ts +9 -3
- package/types/fields/Code.vue.d.ts +8 -0
- package/types/fields/CodeLink.vue.d.ts +4 -0
- package/types/fields/CodeSelect.vue.d.ts +96 -0
- package/types/index.d.ts +3 -0
- package/types/layouts/AddPageBox.vue.d.ts +45 -3
- package/types/layouts/CodeEditor.vue.d.ts +160 -45
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +16 -64
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +8 -196
- package/types/layouts/sidebar/Sidebar.vue.d.ts +114 -17
- package/types/layouts/sidebar/TabPane.vue.d.ts +80 -12
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +50 -0
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +73 -0
- package/types/services/codeBlock.d.ts +155 -0
- package/types/services/editor.d.ts +12 -1
- package/types/services/props.d.ts +12 -0
- package/types/type.d.ts +77 -1
- package/types/utils/props.d.ts +12 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.
|
|
5
|
-
})(this, (function (exports, vue, serialize,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('element-plus'), require('lodash-es'), require('@element-plus/icons-vue'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('keycon')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'element-plus', 'lodash-es', '@element-plus/icons-vue', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'keycon'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.ElementPlus, global.lodashEs, global.iconsVue, global.monaco, global.StageCore, global.schema, global.utils, global.events, global.core, global.Gesto, global.KeyController));
|
|
5
|
+
})(this, (function (exports, vue, serialize, elementPlus, lodashEs, iconsVue, monaco, StageCore, schema, utils, events, core, Gesto, KeyController) { 'use strict';
|
|
6
6
|
|
|
7
7
|
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
|
8
8
|
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
|
|
31
31
|
const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
|
|
32
32
|
|
|
33
|
-
const _sfc_main$
|
|
33
|
+
const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
|
|
34
34
|
__name: "Code",
|
|
35
35
|
props: {
|
|
36
36
|
model: null,
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
setup(__props, { emit }) {
|
|
43
43
|
const props = __props;
|
|
44
44
|
const language = vue.computed(() => props.config.language || "javascript");
|
|
45
|
-
const height = vue.computed(() => `${document.body.clientHeight - 168}px`);
|
|
45
|
+
const height = vue.computed(() => props.config.height || `${document.body.clientHeight - 168}px`);
|
|
46
46
|
const save = (v) => {
|
|
47
47
|
props.model[props.name] = v;
|
|
48
48
|
emit("change", v);
|
|
@@ -53,13 +53,14 @@
|
|
|
53
53
|
style: vue.normalizeStyle(`height: ${vue.unref(height)}`),
|
|
54
54
|
"init-values": __props.model[__props.name],
|
|
55
55
|
language: vue.unref(language),
|
|
56
|
+
options: __props.config.options,
|
|
56
57
|
onSave: save
|
|
57
|
-
}, null, 8, ["style", "init-values", "language"]);
|
|
58
|
+
}, null, 8, ["style", "init-values", "language", "options"]);
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
const _sfc_main$
|
|
63
|
+
const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
|
|
63
64
|
__name: "CodeLink",
|
|
64
65
|
props: {
|
|
65
66
|
config: null,
|
|
@@ -70,17 +71,24 @@
|
|
|
70
71
|
emits: ["change"],
|
|
71
72
|
setup(__props, { emit }) {
|
|
72
73
|
const props = __props;
|
|
73
|
-
const formConfig = vue.computed(() =>
|
|
74
|
-
...props.config
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
const formConfig = vue.computed(() => {
|
|
75
|
+
const { codeOptions, ...config } = props.config;
|
|
76
|
+
return {
|
|
77
|
+
...config,
|
|
78
|
+
text: "",
|
|
79
|
+
type: "link",
|
|
80
|
+
form: [
|
|
81
|
+
{
|
|
82
|
+
name: props.name,
|
|
83
|
+
type: "vs-code",
|
|
84
|
+
options: {
|
|
85
|
+
tabSize: 2,
|
|
86
|
+
...codeOptions || {}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
};
|
|
91
|
+
});
|
|
84
92
|
const modelValue = vue.reactive({
|
|
85
93
|
form: {
|
|
86
94
|
[props.name]: ""
|
|
@@ -122,8 +130,186 @@
|
|
|
122
130
|
}
|
|
123
131
|
});
|
|
124
132
|
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
134
|
+
ColumnLayout2["LEFT"] = "left";
|
|
135
|
+
ColumnLayout2["CENTER"] = "center";
|
|
136
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
137
|
+
return ColumnLayout2;
|
|
138
|
+
})(ColumnLayout || {});
|
|
139
|
+
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
140
|
+
LayerOffset2["TOP"] = "top";
|
|
141
|
+
LayerOffset2["BOTTOM"] = "bottom";
|
|
142
|
+
return LayerOffset2;
|
|
143
|
+
})(LayerOffset || {});
|
|
144
|
+
var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
145
|
+
Layout2["FLEX"] = "flex";
|
|
146
|
+
Layout2["FIXED"] = "fixed";
|
|
147
|
+
Layout2["RELATIVE"] = "relative";
|
|
148
|
+
Layout2["ABSOLUTE"] = "absolute";
|
|
149
|
+
return Layout2;
|
|
150
|
+
})(Layout || {});
|
|
151
|
+
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
152
|
+
Keys2["ESCAPE"] = "Space";
|
|
153
|
+
return Keys2;
|
|
154
|
+
})(Keys || {});
|
|
155
|
+
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
156
|
+
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
157
|
+
var CodeEditorMode = /* @__PURE__ */ ((CodeEditorMode2) => {
|
|
158
|
+
CodeEditorMode2["LIST"] = "list";
|
|
159
|
+
CodeEditorMode2["EDITOR"] = "editor";
|
|
160
|
+
return CodeEditorMode2;
|
|
161
|
+
})(CodeEditorMode || {});
|
|
162
|
+
var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
|
|
163
|
+
CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
|
|
164
|
+
CodeDeleteErrorType2["BIND"] = "bind";
|
|
165
|
+
return CodeDeleteErrorType2;
|
|
166
|
+
})(CodeDeleteErrorType || {});
|
|
167
|
+
var CodeSelectOp = /* @__PURE__ */ ((CodeSelectOp2) => {
|
|
168
|
+
CodeSelectOp2["ADD"] = "add";
|
|
169
|
+
CodeSelectOp2["DELETE"] = "delete";
|
|
170
|
+
CodeSelectOp2["CHANGE"] = "change";
|
|
171
|
+
return CodeSelectOp2;
|
|
172
|
+
})(CodeSelectOp || {});
|
|
173
|
+
|
|
174
|
+
const _hoisted_1$d = { class: "tool-bar" };
|
|
175
|
+
const _hoisted_2$6 = /* @__PURE__ */ vue.createElementVNode("path", {
|
|
176
|
+
fill: "currentColor",
|
|
177
|
+
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"
|
|
178
|
+
}, null, -1);
|
|
179
|
+
const _hoisted_3$3 = [
|
|
180
|
+
_hoisted_2$6
|
|
181
|
+
];
|
|
182
|
+
const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
|
|
183
|
+
__name: "CodeSelect",
|
|
184
|
+
props: {
|
|
185
|
+
config: null,
|
|
186
|
+
model: null,
|
|
187
|
+
prop: null,
|
|
188
|
+
name: null,
|
|
189
|
+
size: null
|
|
190
|
+
},
|
|
191
|
+
emits: ["change"],
|
|
192
|
+
setup(__props, { emit }) {
|
|
193
|
+
const props = __props;
|
|
194
|
+
const services = vue.inject("services");
|
|
195
|
+
const selectConfig = vue.computed(() => {
|
|
196
|
+
const defaultConfig = {
|
|
197
|
+
multiple: true,
|
|
198
|
+
options: async () => {
|
|
199
|
+
const codeDsl = await services?.codeBlockService.getCodeDsl();
|
|
200
|
+
if (codeDsl) {
|
|
201
|
+
return lodashEs.map(codeDsl, (value, key) => ({
|
|
202
|
+
text: `${value.name}\uFF08${key}\uFF09`,
|
|
203
|
+
label: `${value.name}\uFF08${key}\uFF09`,
|
|
204
|
+
value: key
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
...defaultConfig,
|
|
212
|
+
...props.config.selectConfig
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
const fieldKey = vue.ref("");
|
|
216
|
+
const multiple = vue.ref(true);
|
|
217
|
+
const combineIds = vue.ref([]);
|
|
218
|
+
let lastTagSnapshot = lodashEs.cloneDeep(props.model[props.name]) || [];
|
|
219
|
+
vue.watchEffect(async () => {
|
|
220
|
+
const combineNames = await Promise.all(
|
|
221
|
+
combineIds.value.map(async (id) => {
|
|
222
|
+
const { name = "" } = await services?.codeBlockService.getCodeContentById(id) || {};
|
|
223
|
+
return name;
|
|
224
|
+
})
|
|
225
|
+
);
|
|
226
|
+
fieldKey.value = combineNames.join("-");
|
|
227
|
+
});
|
|
228
|
+
const changeHandler = async (value) => {
|
|
229
|
+
let codeIds = value;
|
|
230
|
+
if (typeof value === "string") {
|
|
231
|
+
multiple.value = false;
|
|
232
|
+
lastTagSnapshot = [lastTagSnapshot];
|
|
233
|
+
codeIds = value ? [value] : [];
|
|
234
|
+
}
|
|
235
|
+
await setCombineRelation(codeIds);
|
|
236
|
+
emit("change", value);
|
|
237
|
+
};
|
|
238
|
+
const setCombineRelation = async (codeIds) => {
|
|
239
|
+
const { id = "" } = services?.editorService.get("node") || {};
|
|
240
|
+
let opFlag = CodeSelectOp.CHANGE;
|
|
241
|
+
let diffValues = codeIds;
|
|
242
|
+
if (multiple.value) {
|
|
243
|
+
opFlag = codeIds.length < lastTagSnapshot.length ? CodeSelectOp.DELETE : CodeSelectOp.ADD;
|
|
244
|
+
diffValues = lodashEs.xor(codeIds, lastTagSnapshot);
|
|
245
|
+
}
|
|
246
|
+
await services?.codeBlockService.setCombineRelation(id, diffValues, opFlag, props.prop);
|
|
247
|
+
lastTagSnapshot = codeIds;
|
|
248
|
+
await setCombineIds(codeIds);
|
|
249
|
+
};
|
|
250
|
+
const setCombineIds = async (codeIds) => {
|
|
251
|
+
combineIds.value = codeIds;
|
|
252
|
+
await services?.codeBlockService.setCombineIds(codeIds);
|
|
253
|
+
};
|
|
254
|
+
const viewHandler = async () => {
|
|
255
|
+
if (props.model[props.name].length === 0) {
|
|
256
|
+
elementPlus.ElMessage.error("\u8BF7\u5148\u7ED1\u5B9A\u4EE3\u7801\u5757");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
await setCombineIds(props.model[props.name]);
|
|
260
|
+
await services?.codeBlockService.setMode(CodeEditorMode.LIST);
|
|
261
|
+
services?.codeBlockService.setCodeEditorContent(true, combineIds.value[0]);
|
|
262
|
+
};
|
|
263
|
+
return (_ctx, _cache) => {
|
|
264
|
+
const _component_m_fields_select = vue.resolveComponent("m-fields-select");
|
|
265
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
266
|
+
const _component_el_card = vue.resolveComponent("el-card");
|
|
267
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
268
|
+
class: "m-fields-code-select",
|
|
269
|
+
key: fieldKey.value
|
|
270
|
+
}, [
|
|
271
|
+
vue.createVNode(_component_el_card, { shadow: "never" }, {
|
|
272
|
+
header: vue.withCtx(() => [
|
|
273
|
+
vue.createVNode(_component_m_fields_select, {
|
|
274
|
+
config: vue.unref(selectConfig),
|
|
275
|
+
model: __props.model,
|
|
276
|
+
prop: __props.prop,
|
|
277
|
+
name: __props.name,
|
|
278
|
+
size: __props.size,
|
|
279
|
+
onChange: changeHandler
|
|
280
|
+
}, null, 8, ["config", "model", "prop", "name", "size"])
|
|
281
|
+
]),
|
|
282
|
+
default: vue.withCtx(() => [
|
|
283
|
+
vue.createElementVNode("div", _hoisted_1$d, [
|
|
284
|
+
vue.createVNode(_component_el_tooltip, {
|
|
285
|
+
class: "tool-item",
|
|
286
|
+
effect: "dark",
|
|
287
|
+
content: "\u67E5\u770B\u4EE3\u7801\u5757",
|
|
288
|
+
placement: "top"
|
|
289
|
+
}, {
|
|
290
|
+
default: vue.withCtx(() => [
|
|
291
|
+
(vue.openBlock(), vue.createElementBlock("svg", {
|
|
292
|
+
onClick: viewHandler,
|
|
293
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
294
|
+
viewBox: "0 0 24 24",
|
|
295
|
+
width: "15px",
|
|
296
|
+
height: "15px",
|
|
297
|
+
"data-v-65a7fb6c": ""
|
|
298
|
+
}, _hoisted_3$3))
|
|
299
|
+
]),
|
|
300
|
+
_: 1
|
|
301
|
+
})
|
|
302
|
+
])
|
|
303
|
+
]),
|
|
304
|
+
_: 1
|
|
305
|
+
})
|
|
306
|
+
]);
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const _hoisted_1$c = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
|
|
312
|
+
const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
|
|
127
313
|
__name: "UISelect",
|
|
128
314
|
props: {
|
|
129
315
|
config: null,
|
|
@@ -188,7 +374,7 @@
|
|
|
188
374
|
style: { "padding": "0" }
|
|
189
375
|
}, {
|
|
190
376
|
default: vue.withCtx(() => [
|
|
191
|
-
_hoisted_1$
|
|
377
|
+
_hoisted_1$c
|
|
192
378
|
]),
|
|
193
379
|
_: 1
|
|
194
380
|
}, 8, ["icon"])
|
|
@@ -236,45 +422,36 @@
|
|
|
236
422
|
|
|
237
423
|
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
238
424
|
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
if (typeof v !== "string") {
|
|
242
|
-
value = serialize__default.default(v, {
|
|
243
|
-
space: 2,
|
|
244
|
-
unsafe: true
|
|
245
|
-
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
246
|
-
} else {
|
|
247
|
-
value = v;
|
|
248
|
-
}
|
|
249
|
-
if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
|
|
250
|
-
value = `(${value})`;
|
|
251
|
-
}
|
|
252
|
-
return value;
|
|
253
|
-
};
|
|
254
|
-
const _sfc_main$m = vue.defineComponent({
|
|
255
|
-
name: "magic-code-editor",
|
|
425
|
+
const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
|
|
426
|
+
__name: "CodeEditor",
|
|
256
427
|
props: {
|
|
257
|
-
initValues:
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
default: () => ""
|
|
266
|
-
},
|
|
267
|
-
language: {
|
|
268
|
-
type: String,
|
|
269
|
-
default: () => "javascript"
|
|
270
|
-
},
|
|
271
|
-
options: {
|
|
272
|
-
type: Object,
|
|
273
|
-
default: () => ({})
|
|
274
|
-
}
|
|
428
|
+
initValues: null,
|
|
429
|
+
modifiedValues: null,
|
|
430
|
+
type: { default: "" },
|
|
431
|
+
language: { default: "javascript" },
|
|
432
|
+
options: { default: () => ({
|
|
433
|
+
tabSize: 2
|
|
434
|
+
}) },
|
|
435
|
+
autoSave: { type: Boolean, default: true }
|
|
275
436
|
},
|
|
276
437
|
emits: ["initd", "save"],
|
|
277
|
-
setup(
|
|
438
|
+
setup(__props, { expose, emit }) {
|
|
439
|
+
const props = __props;
|
|
440
|
+
const toString = (v, language) => {
|
|
441
|
+
let value = "";
|
|
442
|
+
if (typeof v !== "string") {
|
|
443
|
+
value = serialize__default.default(v, {
|
|
444
|
+
space: 2,
|
|
445
|
+
unsafe: true
|
|
446
|
+
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
447
|
+
} else {
|
|
448
|
+
value = v;
|
|
449
|
+
}
|
|
450
|
+
if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
|
|
451
|
+
value = `(${value})`;
|
|
452
|
+
}
|
|
453
|
+
return value;
|
|
454
|
+
};
|
|
278
455
|
let vsEditor = null;
|
|
279
456
|
let vsDiffEditor = null;
|
|
280
457
|
const values = vue.ref("");
|
|
@@ -323,7 +500,7 @@
|
|
|
323
500
|
emit("save", getEditorValue());
|
|
324
501
|
}
|
|
325
502
|
});
|
|
326
|
-
if (props.type !== "diff") {
|
|
503
|
+
if (props.type !== "diff" && props.autoSave) {
|
|
327
504
|
vsEditor?.onDidBlurEditorWidget(() => {
|
|
328
505
|
emit("save", getEditorValue());
|
|
329
506
|
});
|
|
@@ -349,10 +526,7 @@
|
|
|
349
526
|
vue.onUnmounted(() => {
|
|
350
527
|
resizeObserver.disconnect();
|
|
351
528
|
});
|
|
352
|
-
|
|
353
|
-
values,
|
|
354
|
-
loading,
|
|
355
|
-
codeEditor,
|
|
529
|
+
expose({
|
|
356
530
|
getEditor() {
|
|
357
531
|
return vsEditor || vsDiffEditor;
|
|
358
532
|
},
|
|
@@ -361,78 +535,48 @@
|
|
|
361
535
|
vsEditor?.focus();
|
|
362
536
|
vsDiffEditor?.focus();
|
|
363
537
|
}
|
|
538
|
+
});
|
|
539
|
+
return (_ctx, _cache) => {
|
|
540
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
541
|
+
ref_key: "codeEditor",
|
|
542
|
+
ref: codeEditor,
|
|
543
|
+
class: "magic-code-editor"
|
|
544
|
+
}, null, 512);
|
|
364
545
|
};
|
|
365
546
|
}
|
|
366
547
|
});
|
|
367
548
|
|
|
368
|
-
const _export_sfc = (sfc, props) => {
|
|
369
|
-
const target = sfc.__vccOpts || sfc;
|
|
370
|
-
for (const [key, val] of props) {
|
|
371
|
-
target[key] = val;
|
|
372
|
-
}
|
|
373
|
-
return target;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const _hoisted_1$a = {
|
|
377
|
-
ref: "codeEditor",
|
|
378
|
-
class: "magic-code-editor"
|
|
379
|
-
};
|
|
380
|
-
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
381
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, null, 512);
|
|
382
|
-
}
|
|
383
|
-
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$6]]);
|
|
384
|
-
|
|
385
549
|
let $TMAGIC_EDITOR = {};
|
|
386
550
|
const setConfig = (option) => {
|
|
387
551
|
$TMAGIC_EDITOR = option;
|
|
388
552
|
};
|
|
389
553
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
390
554
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
listMaxSize;
|
|
395
|
-
constructor(listMaxSize = 200) {
|
|
396
|
-
const minListMaxSize = 2;
|
|
397
|
-
this.elementList = [];
|
|
398
|
-
this.listCursor = 0;
|
|
399
|
-
this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
|
|
400
|
-
}
|
|
401
|
-
pushElement(element) {
|
|
402
|
-
this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, lodashEs.cloneDeep(element));
|
|
403
|
-
this.listCursor += 1;
|
|
404
|
-
if (this.elementList.length > this.listMaxSize) {
|
|
405
|
-
this.elementList.shift();
|
|
406
|
-
this.listCursor -= 1;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
canUndo() {
|
|
410
|
-
return this.listCursor > 1;
|
|
555
|
+
const log = (...args) => {
|
|
556
|
+
if (process.env.NODE_ENV === "development") {
|
|
557
|
+
console.log("magic editor: ", ...args);
|
|
411
558
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
this.listCursor -= 1;
|
|
417
|
-
return this.getCurrentElement();
|
|
559
|
+
};
|
|
560
|
+
const info = (...args) => {
|
|
561
|
+
if (process.env.NODE_ENV === "development") {
|
|
562
|
+
console.info("magic editor: ", ...args);
|
|
418
563
|
}
|
|
419
|
-
|
|
420
|
-
|
|
564
|
+
};
|
|
565
|
+
const warn = (...args) => {
|
|
566
|
+
if (process.env.NODE_ENV === "development") {
|
|
567
|
+
console.warn("magic editor: ", ...args);
|
|
421
568
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
this.listCursor += 1;
|
|
427
|
-
return this.getCurrentElement();
|
|
569
|
+
};
|
|
570
|
+
const debug = (...args) => {
|
|
571
|
+
if (process.env.NODE_ENV === "development") {
|
|
572
|
+
console.debug("magic editor: ", ...args);
|
|
428
573
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
return lodashEs.cloneDeep(this.elementList[this.listCursor - 1]);
|
|
574
|
+
};
|
|
575
|
+
const error = (...args) => {
|
|
576
|
+
if (process.env.NODE_ENV === "development") {
|
|
577
|
+
console.error("magic editor: ", ...args);
|
|
434
578
|
}
|
|
435
|
-
}
|
|
579
|
+
};
|
|
436
580
|
|
|
437
581
|
const compose = (middleware) => {
|
|
438
582
|
if (!Array.isArray(middleware))
|
|
@@ -548,6 +692,269 @@
|
|
|
548
692
|
}
|
|
549
693
|
}
|
|
550
694
|
|
|
695
|
+
class CodeBlock extends BaseService {
|
|
696
|
+
state = vue.reactive({
|
|
697
|
+
isShowCodeEditor: false,
|
|
698
|
+
codeDsl: null,
|
|
699
|
+
id: "",
|
|
700
|
+
editable: true,
|
|
701
|
+
mode: CodeEditorMode.EDITOR,
|
|
702
|
+
combineIds: [],
|
|
703
|
+
undeletableList: []
|
|
704
|
+
});
|
|
705
|
+
constructor() {
|
|
706
|
+
super([
|
|
707
|
+
"setCodeDsl",
|
|
708
|
+
"getCodeDsl",
|
|
709
|
+
"getCodeContentById",
|
|
710
|
+
"getCodeDslByIds",
|
|
711
|
+
"getCurrentDsl",
|
|
712
|
+
"setCodeDslById",
|
|
713
|
+
"setCodeEditorShowStatus",
|
|
714
|
+
"setEditStatus",
|
|
715
|
+
"setMode",
|
|
716
|
+
"setCombineIds",
|
|
717
|
+
"setUndeleteableList",
|
|
718
|
+
"deleteCodeDslByIds"
|
|
719
|
+
]);
|
|
720
|
+
}
|
|
721
|
+
async setCodeDsl(codeDsl) {
|
|
722
|
+
this.state.codeDsl = codeDsl;
|
|
723
|
+
await editorService.setCodeDsl(this.state.codeDsl);
|
|
724
|
+
info("[code-block]:code-dsl-change", this.state.codeDsl);
|
|
725
|
+
this.emit("code-dsl-change", this.state.codeDsl);
|
|
726
|
+
}
|
|
727
|
+
async getCodeDsl(forceRefresh = false) {
|
|
728
|
+
if (!this.state.codeDsl || forceRefresh) {
|
|
729
|
+
this.state.codeDsl = await editorService.getCodeDsl();
|
|
730
|
+
}
|
|
731
|
+
return this.state.codeDsl;
|
|
732
|
+
}
|
|
733
|
+
async getCodeContentById(id) {
|
|
734
|
+
if (!id)
|
|
735
|
+
return null;
|
|
736
|
+
const totalCodeDsl = await this.getCodeDsl();
|
|
737
|
+
if (!totalCodeDsl)
|
|
738
|
+
return null;
|
|
739
|
+
return totalCodeDsl[id] ?? null;
|
|
740
|
+
}
|
|
741
|
+
async setCodeDslById(id, codeConfig) {
|
|
742
|
+
let codeDsl = await this.getCodeDsl();
|
|
743
|
+
if (!codeDsl) {
|
|
744
|
+
codeDsl = {
|
|
745
|
+
[id]: codeConfig
|
|
746
|
+
};
|
|
747
|
+
} else {
|
|
748
|
+
const existContent = codeDsl[id] || {};
|
|
749
|
+
codeDsl = {
|
|
750
|
+
...codeDsl,
|
|
751
|
+
[id]: {
|
|
752
|
+
...existContent,
|
|
753
|
+
...codeConfig
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
await this.setCodeDsl(codeDsl);
|
|
758
|
+
}
|
|
759
|
+
async getCodeDslByIds(ids) {
|
|
760
|
+
const codeDsl = await this.getCodeDsl();
|
|
761
|
+
return lodashEs.pick(codeDsl, ids);
|
|
762
|
+
}
|
|
763
|
+
async setCodeEditorShowStatus(status) {
|
|
764
|
+
this.state.isShowCodeEditor = status;
|
|
765
|
+
}
|
|
766
|
+
getCodeEditorShowStatus() {
|
|
767
|
+
return this.state.isShowCodeEditor;
|
|
768
|
+
}
|
|
769
|
+
setCodeEditorContent(status, id) {
|
|
770
|
+
if (!id)
|
|
771
|
+
return;
|
|
772
|
+
this.setId(id);
|
|
773
|
+
this.state.isShowCodeEditor = status;
|
|
774
|
+
}
|
|
775
|
+
async getCurrentDsl() {
|
|
776
|
+
return await this.getCodeContentById(this.state.id);
|
|
777
|
+
}
|
|
778
|
+
getEditStatus() {
|
|
779
|
+
return this.state.editable;
|
|
780
|
+
}
|
|
781
|
+
async setEditStatus(status) {
|
|
782
|
+
this.state.editable = status;
|
|
783
|
+
}
|
|
784
|
+
setId(id) {
|
|
785
|
+
if (!id)
|
|
786
|
+
return;
|
|
787
|
+
this.state.id = id;
|
|
788
|
+
}
|
|
789
|
+
getId() {
|
|
790
|
+
return this.state.id;
|
|
791
|
+
}
|
|
792
|
+
getMode() {
|
|
793
|
+
return this.state.mode;
|
|
794
|
+
}
|
|
795
|
+
async setMode(mode) {
|
|
796
|
+
this.state.mode = mode;
|
|
797
|
+
}
|
|
798
|
+
async setCombineIds(ids) {
|
|
799
|
+
this.state.combineIds = ids;
|
|
800
|
+
}
|
|
801
|
+
getCombineIds() {
|
|
802
|
+
return this.state.combineIds;
|
|
803
|
+
}
|
|
804
|
+
async setCombineRelation(compId, diffCodeIds, opFlag, hook) {
|
|
805
|
+
const codeDsl = lodashEs.cloneDeep(await this.getCodeDsl());
|
|
806
|
+
if (!codeDsl)
|
|
807
|
+
return;
|
|
808
|
+
if (opFlag === CodeSelectOp.DELETE) {
|
|
809
|
+
try {
|
|
810
|
+
diffCodeIds.forEach((codeId) => {
|
|
811
|
+
const compsContent = codeDsl[codeId].comps;
|
|
812
|
+
const index = compsContent?.[compId].findIndex((item) => item === hook);
|
|
813
|
+
if (typeof index !== "undefined" && index !== -1) {
|
|
814
|
+
compsContent?.[compId].splice(index, 1);
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
} catch (e) {
|
|
818
|
+
error(e);
|
|
819
|
+
throw new Error("\u89E3\u7ED1\u4EE3\u7801\u5757\u5931\u8D25");
|
|
820
|
+
}
|
|
821
|
+
} else if (opFlag === CodeSelectOp.ADD) {
|
|
822
|
+
try {
|
|
823
|
+
diffCodeIds.forEach((codeId) => {
|
|
824
|
+
const compsContent = codeDsl[codeId].comps;
|
|
825
|
+
const existHooks = compsContent?.[compId];
|
|
826
|
+
if (lodashEs.isEmpty(existHooks)) {
|
|
827
|
+
codeDsl[codeId].comps = {
|
|
828
|
+
...codeDsl[codeId].comps || {},
|
|
829
|
+
[compId]: [hook]
|
|
830
|
+
};
|
|
831
|
+
} else {
|
|
832
|
+
existHooks?.push(hook);
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
} catch (e) {
|
|
836
|
+
error(e);
|
|
837
|
+
throw new Error("\u7ED1\u5B9A\u4EE3\u7801\u5757\u5931\u8D25");
|
|
838
|
+
}
|
|
839
|
+
} else if (opFlag === CodeSelectOp.CHANGE) {
|
|
840
|
+
lodashEs.forIn(codeDsl, (codeBlockContent, codeId) => {
|
|
841
|
+
if (codeId === diffCodeIds[0]) {
|
|
842
|
+
codeBlockContent.comps = {
|
|
843
|
+
...codeBlockContent?.comps || {},
|
|
844
|
+
[compId]: [hook]
|
|
845
|
+
};
|
|
846
|
+
} else if (lodashEs.isEmpty(diffCodeIds) || codeId !== diffCodeIds[0]) {
|
|
847
|
+
const compHooks = codeBlockContent?.comps?.[compId];
|
|
848
|
+
if (!compHooks)
|
|
849
|
+
return true;
|
|
850
|
+
const index = compHooks.findIndex((hookName) => hookName === hook);
|
|
851
|
+
if (index !== -1) {
|
|
852
|
+
compHooks.splice(index, 1);
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
this.setCodeDsl(codeDsl);
|
|
859
|
+
}
|
|
860
|
+
getUndeletableList() {
|
|
861
|
+
return this.state.undeletableList;
|
|
862
|
+
}
|
|
863
|
+
async setUndeleteableList(codeIds) {
|
|
864
|
+
this.state.undeletableList = codeIds;
|
|
865
|
+
}
|
|
866
|
+
async deleteCodeDslByIds(codeIds) {
|
|
867
|
+
const currentDsl = await this.getCodeDsl();
|
|
868
|
+
const newDsl = lodashEs.omit(currentDsl, codeIds);
|
|
869
|
+
await this.setCodeDsl(newDsl);
|
|
870
|
+
return newDsl;
|
|
871
|
+
}
|
|
872
|
+
async getUniqueId() {
|
|
873
|
+
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
874
|
+
const dsl = await this.getCodeDsl();
|
|
875
|
+
const existedIds = lodashEs.keys(dsl);
|
|
876
|
+
if (!existedIds.includes(newId))
|
|
877
|
+
return newId;
|
|
878
|
+
return await this.getUniqueId();
|
|
879
|
+
}
|
|
880
|
+
async deleteCompsInRelation(node) {
|
|
881
|
+
const codeDsl = lodashEs.cloneDeep(await this.getCodeDsl());
|
|
882
|
+
if (!codeDsl)
|
|
883
|
+
return;
|
|
884
|
+
this.recurseNodes(node, codeDsl);
|
|
885
|
+
this.setCodeDsl(codeDsl);
|
|
886
|
+
}
|
|
887
|
+
destroy() {
|
|
888
|
+
this.state.isShowCodeEditor = false;
|
|
889
|
+
this.state.codeDsl = null;
|
|
890
|
+
this.state.id = "";
|
|
891
|
+
this.state.editable = true;
|
|
892
|
+
this.state.mode = CodeEditorMode.EDITOR;
|
|
893
|
+
this.state.combineIds = [];
|
|
894
|
+
this.state.undeletableList = [];
|
|
895
|
+
}
|
|
896
|
+
recurseNodes(node, codeDsl) {
|
|
897
|
+
if (!node.id)
|
|
898
|
+
return;
|
|
899
|
+
lodashEs.forIn(codeDsl, (codeBlockContent) => {
|
|
900
|
+
const compsContent = codeBlockContent.comps || {};
|
|
901
|
+
codeBlockContent.comps = lodashEs.omit(compsContent, node.id);
|
|
902
|
+
});
|
|
903
|
+
if (!lodashEs.isEmpty(node.items)) {
|
|
904
|
+
node.items.forEach((item) => {
|
|
905
|
+
this.recurseNodes(item, codeDsl);
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
const codeBlockService = new CodeBlock();
|
|
911
|
+
|
|
912
|
+
class UndoRedo {
|
|
913
|
+
elementList;
|
|
914
|
+
listCursor;
|
|
915
|
+
listMaxSize;
|
|
916
|
+
constructor(listMaxSize = 200) {
|
|
917
|
+
const minListMaxSize = 2;
|
|
918
|
+
this.elementList = [];
|
|
919
|
+
this.listCursor = 0;
|
|
920
|
+
this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
|
|
921
|
+
}
|
|
922
|
+
pushElement(element) {
|
|
923
|
+
this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, lodashEs.cloneDeep(element));
|
|
924
|
+
this.listCursor += 1;
|
|
925
|
+
if (this.elementList.length > this.listMaxSize) {
|
|
926
|
+
this.elementList.shift();
|
|
927
|
+
this.listCursor -= 1;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
canUndo() {
|
|
931
|
+
return this.listCursor > 1;
|
|
932
|
+
}
|
|
933
|
+
undo() {
|
|
934
|
+
if (!this.canUndo()) {
|
|
935
|
+
return null;
|
|
936
|
+
}
|
|
937
|
+
this.listCursor -= 1;
|
|
938
|
+
return this.getCurrentElement();
|
|
939
|
+
}
|
|
940
|
+
canRedo() {
|
|
941
|
+
return this.elementList.length > this.listCursor;
|
|
942
|
+
}
|
|
943
|
+
redo() {
|
|
944
|
+
if (!this.canRedo()) {
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
this.listCursor += 1;
|
|
948
|
+
return this.getCurrentElement();
|
|
949
|
+
}
|
|
950
|
+
getCurrentElement() {
|
|
951
|
+
if (this.listCursor < 1) {
|
|
952
|
+
return null;
|
|
953
|
+
}
|
|
954
|
+
return lodashEs.cloneDeep(this.elementList[this.listCursor - 1]);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
551
958
|
class History extends BaseService {
|
|
552
959
|
state = vue.reactive({
|
|
553
960
|
pageSteps: {},
|
|
@@ -713,31 +1120,6 @@
|
|
|
713
1120
|
}
|
|
714
1121
|
const storageService = new WebStorage();
|
|
715
1122
|
|
|
716
|
-
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
717
|
-
ColumnLayout2["LEFT"] = "left";
|
|
718
|
-
ColumnLayout2["CENTER"] = "center";
|
|
719
|
-
ColumnLayout2["RIGHT"] = "right";
|
|
720
|
-
return ColumnLayout2;
|
|
721
|
-
})(ColumnLayout || {});
|
|
722
|
-
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
723
|
-
LayerOffset2["TOP"] = "top";
|
|
724
|
-
LayerOffset2["BOTTOM"] = "bottom";
|
|
725
|
-
return LayerOffset2;
|
|
726
|
-
})(LayerOffset || {});
|
|
727
|
-
var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
728
|
-
Layout2["FLEX"] = "flex";
|
|
729
|
-
Layout2["FIXED"] = "fixed";
|
|
730
|
-
Layout2["RELATIVE"] = "relative";
|
|
731
|
-
Layout2["ABSOLUTE"] = "absolute";
|
|
732
|
-
return Layout2;
|
|
733
|
-
})(Layout || {});
|
|
734
|
-
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
735
|
-
Keys2["ESCAPE"] = "Space";
|
|
736
|
-
return Keys2;
|
|
737
|
-
})(Keys || {});
|
|
738
|
-
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
739
|
-
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
740
|
-
|
|
741
1123
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
742
1124
|
const getPageList = (app) => {
|
|
743
1125
|
if (app.items && Array.isArray(app.items)) {
|
|
@@ -1098,7 +1480,9 @@
|
|
|
1098
1480
|
"move",
|
|
1099
1481
|
"undo",
|
|
1100
1482
|
"redo",
|
|
1101
|
-
"highlight"
|
|
1483
|
+
"highlight",
|
|
1484
|
+
"getCodeDsl",
|
|
1485
|
+
"setCodeDsl"
|
|
1102
1486
|
],
|
|
1103
1487
|
["select", "update", "moveLayer"]
|
|
1104
1488
|
);
|
|
@@ -1323,6 +1707,7 @@
|
|
|
1323
1707
|
stage?.select(parent.id);
|
|
1324
1708
|
}
|
|
1325
1709
|
this.addModifiedNodeId(parent.id);
|
|
1710
|
+
codeBlockService.deleteCompsInRelation(node);
|
|
1326
1711
|
}
|
|
1327
1712
|
async remove(nodeOrNodeList) {
|
|
1328
1713
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
@@ -1548,6 +1933,17 @@
|
|
|
1548
1933
|
resetModifiedNodeId() {
|
|
1549
1934
|
this.get("modifiedNodeIds").clear();
|
|
1550
1935
|
}
|
|
1936
|
+
async getCodeDsl() {
|
|
1937
|
+
const root = this.get("root");
|
|
1938
|
+
if (!root)
|
|
1939
|
+
return null;
|
|
1940
|
+
return root.codeBlocks || null;
|
|
1941
|
+
}
|
|
1942
|
+
async setCodeDsl(codeDsl) {
|
|
1943
|
+
if (!this.state.root)
|
|
1944
|
+
return;
|
|
1945
|
+
this.state.root.codeBlocks = codeDsl;
|
|
1946
|
+
}
|
|
1551
1947
|
addModifiedNodeId(id) {
|
|
1552
1948
|
if (!this.isHistoryStateChange) {
|
|
1553
1949
|
this.get("modifiedNodeIds").set(id, id);
|
|
@@ -1852,13 +2248,19 @@
|
|
|
1852
2248
|
},
|
|
1853
2249
|
{
|
|
1854
2250
|
title: "\u9AD8\u7EA7",
|
|
1855
|
-
|
|
2251
|
+
lazy: true,
|
|
1856
2252
|
items: [
|
|
1857
2253
|
{
|
|
1858
|
-
type: "code-link",
|
|
1859
2254
|
name: "created",
|
|
1860
2255
|
text: "created",
|
|
1861
|
-
|
|
2256
|
+
type: "code-select",
|
|
2257
|
+
labelWidth: "100px"
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
name: "mounted",
|
|
2261
|
+
text: "mounted",
|
|
2262
|
+
type: "code-select",
|
|
2263
|
+
labelWidth: "100px"
|
|
1862
2264
|
}
|
|
1863
2265
|
]
|
|
1864
2266
|
}
|
|
@@ -1866,32 +2268,6 @@
|
|
|
1866
2268
|
}
|
|
1867
2269
|
];
|
|
1868
2270
|
|
|
1869
|
-
const log = (...args) => {
|
|
1870
|
-
if (process.env.NODE_ENV === "development") {
|
|
1871
|
-
console.log("magic editor: ", ...args);
|
|
1872
|
-
}
|
|
1873
|
-
};
|
|
1874
|
-
const info = (...args) => {
|
|
1875
|
-
if (process.env.NODE_ENV === "development") {
|
|
1876
|
-
console.info("magic editor: ", ...args);
|
|
1877
|
-
}
|
|
1878
|
-
};
|
|
1879
|
-
const warn = (...args) => {
|
|
1880
|
-
if (process.env.NODE_ENV === "development") {
|
|
1881
|
-
console.warn("magic editor: ", ...args);
|
|
1882
|
-
}
|
|
1883
|
-
};
|
|
1884
|
-
const debug = (...args) => {
|
|
1885
|
-
if (process.env.NODE_ENV === "development") {
|
|
1886
|
-
console.debug("magic editor: ", ...args);
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1889
|
-
const error = (...args) => {
|
|
1890
|
-
if (process.env.NODE_ENV === "development") {
|
|
1891
|
-
console.error("magic editor: ", ...args);
|
|
1892
|
-
}
|
|
1893
|
-
};
|
|
1894
|
-
|
|
1895
2271
|
const state = vue.reactive({
|
|
1896
2272
|
uiSelectMode: false,
|
|
1897
2273
|
showSrc: false,
|
|
@@ -2032,52 +2408,47 @@
|
|
|
2032
2408
|
return stage;
|
|
2033
2409
|
};
|
|
2034
2410
|
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2037
|
-
|
|
2411
|
+
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
2412
|
+
const _hoisted_2$5 = { class: "m-editor-empty-content" };
|
|
2413
|
+
const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2414
|
+
const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
|
|
2415
|
+
__name: "AddPageBox",
|
|
2416
|
+
setup(__props) {
|
|
2038
2417
|
const services = vue.inject("services");
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2418
|
+
const clickHandler = () => {
|
|
2419
|
+
const { editorService } = services || {};
|
|
2420
|
+
if (!editorService)
|
|
2421
|
+
return;
|
|
2422
|
+
editorService.add({
|
|
2423
|
+
type: schema.NodeType.PAGE,
|
|
2424
|
+
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
2425
|
+
});
|
|
2426
|
+
};
|
|
2427
|
+
return (_ctx, _cache) => {
|
|
2428
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2429
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
2430
|
+
vue.createElementVNode("div", _hoisted_2$5, [
|
|
2431
|
+
vue.createElementVNode("div", {
|
|
2432
|
+
class: "m-editor-empty-button",
|
|
2433
|
+
onClick: clickHandler
|
|
2434
|
+
}, [
|
|
2435
|
+
vue.createElementVNode("div", null, [
|
|
2436
|
+
vue.createVNode(_component_el_icon, null, {
|
|
2437
|
+
default: vue.withCtx(() => [
|
|
2438
|
+
vue.createVNode(vue.unref(iconsVue.Plus))
|
|
2439
|
+
]),
|
|
2440
|
+
_: 1
|
|
2441
|
+
})
|
|
2442
|
+
]),
|
|
2443
|
+
_hoisted_3$2
|
|
2444
|
+
])
|
|
2445
|
+
])
|
|
2446
|
+
]);
|
|
2049
2447
|
};
|
|
2050
2448
|
}
|
|
2051
2449
|
});
|
|
2052
2450
|
|
|
2053
|
-
const
|
|
2054
|
-
const _hoisted_2$3 = { class: "m-editor-empty-content" };
|
|
2055
|
-
const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2056
|
-
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2057
|
-
const _component_plus = vue.resolveComponent("plus");
|
|
2058
|
-
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2059
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
|
|
2060
|
-
vue.createElementVNode("div", _hoisted_2$3, [
|
|
2061
|
-
vue.createElementVNode("div", {
|
|
2062
|
-
class: "m-editor-empty-button",
|
|
2063
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
2064
|
-
}, [
|
|
2065
|
-
vue.createElementVNode("div", null, [
|
|
2066
|
-
vue.createVNode(_component_el_icon, null, {
|
|
2067
|
-
default: vue.withCtx(() => [
|
|
2068
|
-
vue.createVNode(_component_plus)
|
|
2069
|
-
]),
|
|
2070
|
-
_: 1
|
|
2071
|
-
})
|
|
2072
|
-
]),
|
|
2073
|
-
_hoisted_3
|
|
2074
|
-
])
|
|
2075
|
-
])
|
|
2076
|
-
]);
|
|
2077
|
-
}
|
|
2078
|
-
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$5]]);
|
|
2079
|
-
|
|
2080
|
-
const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
|
|
2451
|
+
const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
|
|
2081
2452
|
__name: "Resizer",
|
|
2082
2453
|
emits: ["change"],
|
|
2083
2454
|
setup(__props, { emit }) {
|
|
@@ -2110,7 +2481,7 @@
|
|
|
2110
2481
|
}
|
|
2111
2482
|
});
|
|
2112
2483
|
|
|
2113
|
-
const _sfc_main$
|
|
2484
|
+
const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
|
|
2114
2485
|
__name: "Layout",
|
|
2115
2486
|
props: {
|
|
2116
2487
|
left: null,
|
|
@@ -2173,7 +2544,8 @@
|
|
|
2173
2544
|
return (_ctx, _cache) => {
|
|
2174
2545
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2175
2546
|
ref_key: "el",
|
|
2176
|
-
ref: el
|
|
2547
|
+
ref: el,
|
|
2548
|
+
class: "m-editor-layout"
|
|
2177
2549
|
}, [
|
|
2178
2550
|
typeof props.left !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
2179
2551
|
vue.createElementVNode("div", {
|
|
@@ -2182,7 +2554,7 @@
|
|
|
2182
2554
|
}, [
|
|
2183
2555
|
vue.renderSlot(_ctx.$slots, "left")
|
|
2184
2556
|
], 6),
|
|
2185
|
-
vue.createVNode(_sfc_main$
|
|
2557
|
+
vue.createVNode(_sfc_main$m, { onChange: changeLeft })
|
|
2186
2558
|
], 64)) : vue.createCommentVNode("", true),
|
|
2187
2559
|
vue.createElementVNode("div", {
|
|
2188
2560
|
class: vue.normalizeClass(["m-editor-layout-center", __props.centerClass]),
|
|
@@ -2191,7 +2563,7 @@
|
|
|
2191
2563
|
vue.renderSlot(_ctx.$slots, "center")
|
|
2192
2564
|
], 6),
|
|
2193
2565
|
typeof props.right !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
|
|
2194
|
-
vue.createVNode(_sfc_main$
|
|
2566
|
+
vue.createVNode(_sfc_main$m, { onChange: changeRight }),
|
|
2195
2567
|
vue.createElementVNode("div", {
|
|
2196
2568
|
class: vue.normalizeClass(["m-editor-layout-right", __props.rightClass]),
|
|
2197
2569
|
style: vue.normalizeStyle(`width: ${__props.right}px`)
|
|
@@ -2204,8 +2576,8 @@
|
|
|
2204
2576
|
}
|
|
2205
2577
|
});
|
|
2206
2578
|
|
|
2207
|
-
const _hoisted_1$
|
|
2208
|
-
const _sfc_main$
|
|
2579
|
+
const _hoisted_1$a = { class: "m-editor" };
|
|
2580
|
+
const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
|
|
2209
2581
|
__name: "Framework",
|
|
2210
2582
|
props: {
|
|
2211
2583
|
codeOptions: { default: () => ({}) }
|
|
@@ -2256,7 +2628,7 @@
|
|
|
2256
2628
|
return (_ctx, _cache) => {
|
|
2257
2629
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
2258
2630
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2259
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2631
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
|
|
2260
2632
|
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2261
2633
|
vue.unref(showSrc) ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
2262
2634
|
key: 0,
|
|
@@ -2264,7 +2636,7 @@
|
|
|
2264
2636
|
"init-values": vue.unref(root),
|
|
2265
2637
|
options: __props.codeOptions,
|
|
2266
2638
|
onSave: saveCode
|
|
2267
|
-
}, null, 8, ["init-values", "options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
2639
|
+
}, null, 8, ["init-values", "options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$l, {
|
|
2268
2640
|
key: 1,
|
|
2269
2641
|
class: "m-editor-content",
|
|
2270
2642
|
"left-class": "m-editor-framework-left",
|
|
@@ -2283,7 +2655,7 @@
|
|
|
2283
2655
|
]),
|
|
2284
2656
|
center: vue.withCtx(() => [
|
|
2285
2657
|
vue.unref(pageLength) > 0 ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2286
|
-
vue.createVNode(
|
|
2658
|
+
vue.createVNode(_sfc_main$n)
|
|
2287
2659
|
])
|
|
2288
2660
|
]),
|
|
2289
2661
|
_: 2
|
|
@@ -2305,8 +2677,8 @@
|
|
|
2305
2677
|
}
|
|
2306
2678
|
});
|
|
2307
2679
|
|
|
2308
|
-
const _hoisted_1$
|
|
2309
|
-
const _sfc_main$
|
|
2680
|
+
const _hoisted_1$9 = ["src"];
|
|
2681
|
+
const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
|
|
2310
2682
|
__name: "Icon",
|
|
2311
2683
|
props: {
|
|
2312
2684
|
icon: null
|
|
@@ -2327,7 +2699,7 @@
|
|
|
2327
2699
|
class: "magic-editor-icon"
|
|
2328
2700
|
}, {
|
|
2329
2701
|
default: vue.withCtx(() => [
|
|
2330
|
-
vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$
|
|
2702
|
+
vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$9)
|
|
2331
2703
|
]),
|
|
2332
2704
|
_: 1
|
|
2333
2705
|
})) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
@@ -2346,12 +2718,12 @@
|
|
|
2346
2718
|
}
|
|
2347
2719
|
});
|
|
2348
2720
|
|
|
2349
|
-
const _hoisted_1$
|
|
2721
|
+
const _hoisted_1$8 = {
|
|
2350
2722
|
key: 1,
|
|
2351
2723
|
class: "menu-item-text"
|
|
2352
2724
|
};
|
|
2353
|
-
const _hoisted_2$
|
|
2354
|
-
const _sfc_main$
|
|
2725
|
+
const _hoisted_2$4 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2726
|
+
const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
2355
2727
|
__name: "ToolButton",
|
|
2356
2728
|
props: {
|
|
2357
2729
|
data: { default: () => ({
|
|
@@ -2434,7 +2806,7 @@
|
|
|
2434
2806
|
__props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2435
2807
|
key: 0,
|
|
2436
2808
|
direction: __props.data.direction || "vertical"
|
|
2437
|
-
}, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2809
|
+
}, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
2438
2810
|
__props.data.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2439
2811
|
key: 0,
|
|
2440
2812
|
effect: "dark",
|
|
@@ -2448,7 +2820,7 @@
|
|
|
2448
2820
|
disabled: vue.unref(disabled)
|
|
2449
2821
|
}, {
|
|
2450
2822
|
default: vue.withCtx(() => [
|
|
2451
|
-
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
2823
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$j, {
|
|
2452
2824
|
key: 0,
|
|
2453
2825
|
icon: __props.data.icon
|
|
2454
2826
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -2465,7 +2837,7 @@
|
|
|
2465
2837
|
disabled: vue.unref(disabled)
|
|
2466
2838
|
}, {
|
|
2467
2839
|
default: vue.withCtx(() => [
|
|
2468
|
-
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
2840
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$j, {
|
|
2469
2841
|
key: 0,
|
|
2470
2842
|
icon: __props.data.icon
|
|
2471
2843
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -2498,7 +2870,7 @@
|
|
|
2498
2870
|
})) : vue.createCommentVNode("", true)
|
|
2499
2871
|
]),
|
|
2500
2872
|
default: vue.withCtx(() => [
|
|
2501
|
-
vue.createElementVNode("span", _hoisted_2$
|
|
2873
|
+
vue.createElementVNode("span", _hoisted_2$4, [
|
|
2502
2874
|
vue.createTextVNode(vue.toDisplayString(__props.data.text), 1),
|
|
2503
2875
|
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2504
2876
|
default: vue.withCtx(() => [
|
|
@@ -2515,7 +2887,7 @@
|
|
|
2515
2887
|
}
|
|
2516
2888
|
});
|
|
2517
2889
|
|
|
2518
|
-
const _sfc_main$
|
|
2890
|
+
const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
2519
2891
|
__name: "NavMenu",
|
|
2520
2892
|
props: {
|
|
2521
2893
|
data: { default: () => ({}) },
|
|
@@ -2671,7 +3043,7 @@
|
|
|
2671
3043
|
style: vue.normalizeStyle(`width: ${vue.unref(columnWidth)?.[key]}px`)
|
|
2672
3044
|
}, [
|
|
2673
3045
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(buttons)[key], (item, index) => {
|
|
2674
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3046
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$i, {
|
|
2675
3047
|
data: item,
|
|
2676
3048
|
key: index
|
|
2677
3049
|
}, null, 8, ["data"]);
|
|
@@ -2683,8 +3055,8 @@
|
|
|
2683
3055
|
}
|
|
2684
3056
|
});
|
|
2685
3057
|
|
|
2686
|
-
const _hoisted_1$
|
|
2687
|
-
const _sfc_main$
|
|
3058
|
+
const _hoisted_1$7 = { class: "m-editor-props-panel" };
|
|
3059
|
+
const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
2688
3060
|
__name: "PropsPanel",
|
|
2689
3061
|
emits: ["mounted"],
|
|
2690
3062
|
setup(__props, { expose, emit }) {
|
|
@@ -2701,50 +3073,545 @@
|
|
|
2701
3073
|
curFormConfig.value = [];
|
|
2702
3074
|
return;
|
|
2703
3075
|
}
|
|
2704
|
-
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2705
|
-
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
2706
|
-
values.value = node.value;
|
|
3076
|
+
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
3077
|
+
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
3078
|
+
values.value = node.value;
|
|
3079
|
+
};
|
|
3080
|
+
vue.watchEffect(init);
|
|
3081
|
+
services?.propsService.on("props-configs-change", init);
|
|
3082
|
+
vue.onMounted(() => {
|
|
3083
|
+
emit("mounted", internalInstance);
|
|
3084
|
+
});
|
|
3085
|
+
vue.watchEffect(() => {
|
|
3086
|
+
if (configForm.value && stage.value) {
|
|
3087
|
+
configForm.value.formState.stage = stage.value;
|
|
3088
|
+
}
|
|
3089
|
+
});
|
|
3090
|
+
const submit = async () => {
|
|
3091
|
+
try {
|
|
3092
|
+
const values2 = await configForm.value?.submitForm();
|
|
3093
|
+
services?.editorService.update(values2);
|
|
3094
|
+
} catch (e) {
|
|
3095
|
+
console.error(e);
|
|
3096
|
+
elementPlus.ElMessage.closeAll();
|
|
3097
|
+
elementPlus.ElMessage.error({
|
|
3098
|
+
duration: 1e4,
|
|
3099
|
+
showClose: true,
|
|
3100
|
+
message: e.message,
|
|
3101
|
+
dangerouslyUseHTMLString: true
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
expose({ submit });
|
|
3106
|
+
return (_ctx, _cache) => {
|
|
3107
|
+
const _component_m_form = vue.resolveComponent("m-form");
|
|
3108
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
|
|
3109
|
+
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
3110
|
+
vue.createVNode(_component_m_form, {
|
|
3111
|
+
ref_key: "configForm",
|
|
3112
|
+
ref: configForm,
|
|
3113
|
+
class: vue.normalizeClass(`m-editor-props-panel ${vue.unref(propsPanelSize)}`),
|
|
3114
|
+
"popper-class": `m-editor-props-panel-popper ${vue.unref(propsPanelSize)}`,
|
|
3115
|
+
size: vue.unref(propsPanelSize),
|
|
3116
|
+
"init-values": values.value,
|
|
3117
|
+
config: curFormConfig.value,
|
|
3118
|
+
onChange: submit
|
|
3119
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config"])
|
|
3120
|
+
]);
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
3123
|
+
});
|
|
3124
|
+
|
|
3125
|
+
const _hoisted_1$6 = ["id"];
|
|
3126
|
+
const _hoisted_2$3 = { class: "list-item" };
|
|
3127
|
+
const _hoisted_3$1 = { class: "code-name" };
|
|
3128
|
+
const _hoisted_4$1 = { class: "code-name-wrapper" };
|
|
3129
|
+
const _hoisted_5$1 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
|
|
3130
|
+
const _hoisted_6$1 = { class: "m-editor-wrapper" };
|
|
3131
|
+
const _hoisted_7$1 = {
|
|
3132
|
+
key: 1,
|
|
3133
|
+
class: "m-editor-content-bottom"
|
|
3134
|
+
};
|
|
3135
|
+
const _hoisted_8$1 = /* @__PURE__ */ vue.createTextVNode("\u4FDD\u5B58");
|
|
3136
|
+
const _hoisted_9$1 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
|
|
3137
|
+
const _hoisted_10 = {
|
|
3138
|
+
key: 2,
|
|
3139
|
+
class: "m-editor-content-bottom"
|
|
3140
|
+
};
|
|
3141
|
+
const _hoisted_11 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
|
|
3142
|
+
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
3143
|
+
__name: "CodeBlockEditor",
|
|
3144
|
+
setup(__props) {
|
|
3145
|
+
const services = vue.inject("services");
|
|
3146
|
+
const codeEditor = vue.ref();
|
|
3147
|
+
const left = vue.ref(200);
|
|
3148
|
+
const currentTitle = vue.ref("");
|
|
3149
|
+
const codeConfig = vue.ref(null);
|
|
3150
|
+
const state = vue.reactive({
|
|
3151
|
+
codeList: []
|
|
3152
|
+
});
|
|
3153
|
+
const isShowCodeBlockEditor = vue.computed(
|
|
3154
|
+
() => codeConfig.value && services?.codeBlockService.getCodeEditorShowStatus() || false
|
|
3155
|
+
);
|
|
3156
|
+
const mode = vue.computed(() => services?.codeBlockService.getMode());
|
|
3157
|
+
const id = vue.computed(() => services?.codeBlockService.getId() || "");
|
|
3158
|
+
const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
|
|
3159
|
+
const selectedIds = vue.computed(() => services?.codeBlockService.getCombineIds() || []);
|
|
3160
|
+
vue.watchEffect(async () => {
|
|
3161
|
+
codeConfig.value = await services?.codeBlockService.getCodeContentById(id.value) || null;
|
|
3162
|
+
});
|
|
3163
|
+
vue.watchEffect(async () => {
|
|
3164
|
+
const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
|
|
3165
|
+
if (!codeDsl)
|
|
3166
|
+
return;
|
|
3167
|
+
state.codeList = [];
|
|
3168
|
+
lodashEs.forIn(codeDsl, (value, key) => {
|
|
3169
|
+
state.codeList.push({
|
|
3170
|
+
id: key,
|
|
3171
|
+
name: value.name
|
|
3172
|
+
});
|
|
3173
|
+
});
|
|
3174
|
+
currentTitle.value = state.codeList[0]?.name || "";
|
|
3175
|
+
});
|
|
3176
|
+
const saveCode = async () => {
|
|
3177
|
+
if (!codeEditor.value || !codeConfig.value || !editable.value)
|
|
3178
|
+
return true;
|
|
3179
|
+
try {
|
|
3180
|
+
const codeContent = codeEditor.value.getEditor()?.getValue();
|
|
3181
|
+
codeConfig.value.content = eval(codeContent);
|
|
3182
|
+
} catch (e) {
|
|
3183
|
+
elementPlus.ElMessage.error(e.stack);
|
|
3184
|
+
return false;
|
|
3185
|
+
}
|
|
3186
|
+
await services?.codeBlockService.setCodeDslById(id.value, {
|
|
3187
|
+
name: codeConfig.value.name,
|
|
3188
|
+
content: codeConfig.value.content
|
|
3189
|
+
});
|
|
3190
|
+
elementPlus.ElMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
|
|
3191
|
+
return true;
|
|
3192
|
+
};
|
|
3193
|
+
const saveAndClose = async () => {
|
|
3194
|
+
const saveRes = await saveCode();
|
|
3195
|
+
if (saveRes) {
|
|
3196
|
+
await services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
3197
|
+
}
|
|
3198
|
+
};
|
|
3199
|
+
const selectHandler = (data) => {
|
|
3200
|
+
services?.codeBlockService.setId(data.id);
|
|
3201
|
+
currentTitle.value = data.name;
|
|
3202
|
+
};
|
|
3203
|
+
return (_ctx, _cache) => {
|
|
3204
|
+
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
3205
|
+
const _component_el_input = vue.resolveComponent("el-input");
|
|
3206
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
3207
|
+
const _component_el_card = vue.resolveComponent("el-card");
|
|
3208
|
+
const _component_el_dialog = vue.resolveComponent("el-dialog");
|
|
3209
|
+
return vue.openBlock(), vue.createBlock(_component_el_dialog, {
|
|
3210
|
+
modelValue: vue.unref(isShowCodeBlockEditor),
|
|
3211
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vue.isRef(isShowCodeBlockEditor) ? isShowCodeBlockEditor.value = $event : null),
|
|
3212
|
+
class: "code-editor-dialog",
|
|
3213
|
+
title: currentTitle.value,
|
|
3214
|
+
fullscreen: true,
|
|
3215
|
+
"before-close": saveAndClose,
|
|
3216
|
+
"append-to-body": true
|
|
3217
|
+
}, {
|
|
3218
|
+
default: vue.withCtx(() => [
|
|
3219
|
+
vue.createVNode(_sfc_main$l, {
|
|
3220
|
+
left: left.value,
|
|
3221
|
+
"onUpdate:left": _cache[1] || (_cache[1] = ($event) => left.value = $event),
|
|
3222
|
+
"min-left": 45,
|
|
3223
|
+
class: "code-editor-layout"
|
|
3224
|
+
}, vue.createSlots({
|
|
3225
|
+
center: vue.withCtx(() => [
|
|
3226
|
+
!vue.unref(lodashEs.isEmpty)(codeConfig.value) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3227
|
+
key: 0,
|
|
3228
|
+
class: vue.normalizeClass([
|
|
3229
|
+
vue.unref(mode) === vue.unref(CodeEditorMode).LIST ? "m-editor-code-block-editor-panel-list-mode" : "m-editor-code-block-editor-panel"
|
|
3230
|
+
])
|
|
3231
|
+
}, [
|
|
3232
|
+
vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: vue.unref(id) }),
|
|
3233
|
+
vue.createVNode(_component_el_card, { shadow: "never" }, {
|
|
3234
|
+
header: vue.withCtx(() => [
|
|
3235
|
+
vue.createElementVNode("div", _hoisted_4$1, [
|
|
3236
|
+
_hoisted_5$1,
|
|
3237
|
+
codeConfig.value ? (vue.openBlock(), vue.createBlock(_component_el_input, {
|
|
3238
|
+
key: 0,
|
|
3239
|
+
class: "code-name-input",
|
|
3240
|
+
modelValue: codeConfig.value.name,
|
|
3241
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeConfig.value.name = $event),
|
|
3242
|
+
disabled: !vue.unref(editable)
|
|
3243
|
+
}, null, 8, ["modelValue", "disabled"])) : vue.createCommentVNode("", true)
|
|
3244
|
+
])
|
|
3245
|
+
]),
|
|
3246
|
+
default: vue.withCtx(() => [
|
|
3247
|
+
vue.createElementVNode("div", _hoisted_6$1, [
|
|
3248
|
+
codeConfig.value ? (vue.openBlock(), vue.createBlock(_sfc_main$o, {
|
|
3249
|
+
key: 0,
|
|
3250
|
+
ref_key: "codeEditor",
|
|
3251
|
+
ref: codeEditor,
|
|
3252
|
+
class: "m-editor-container",
|
|
3253
|
+
"init-values": `${codeConfig.value.content}`,
|
|
3254
|
+
onSave: saveCode,
|
|
3255
|
+
options: {
|
|
3256
|
+
tabSize: 2,
|
|
3257
|
+
fontSize: 16,
|
|
3258
|
+
formatOnPaste: true,
|
|
3259
|
+
readOnly: !vue.unref(editable)
|
|
3260
|
+
}
|
|
3261
|
+
}, null, 8, ["init-values", "options"])) : vue.createCommentVNode("", true),
|
|
3262
|
+
vue.unref(editable) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7$1, [
|
|
3263
|
+
vue.createVNode(_component_el_button, {
|
|
3264
|
+
type: "primary",
|
|
3265
|
+
class: "button",
|
|
3266
|
+
onClick: saveCode
|
|
3267
|
+
}, {
|
|
3268
|
+
default: vue.withCtx(() => [
|
|
3269
|
+
_hoisted_8$1
|
|
3270
|
+
]),
|
|
3271
|
+
_: 1
|
|
3272
|
+
}),
|
|
3273
|
+
vue.createVNode(_component_el_button, {
|
|
3274
|
+
type: "primary",
|
|
3275
|
+
class: "button",
|
|
3276
|
+
onClick: saveAndClose
|
|
3277
|
+
}, {
|
|
3278
|
+
default: vue.withCtx(() => [
|
|
3279
|
+
_hoisted_9$1
|
|
3280
|
+
]),
|
|
3281
|
+
_: 1
|
|
3282
|
+
})
|
|
3283
|
+
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_10, [
|
|
3284
|
+
vue.createVNode(_component_el_button, {
|
|
3285
|
+
type: "primary",
|
|
3286
|
+
class: "button",
|
|
3287
|
+
onClick: saveAndClose
|
|
3288
|
+
}, {
|
|
3289
|
+
default: vue.withCtx(() => [
|
|
3290
|
+
_hoisted_11
|
|
3291
|
+
]),
|
|
3292
|
+
_: 1
|
|
3293
|
+
})
|
|
3294
|
+
]))
|
|
3295
|
+
])
|
|
3296
|
+
]),
|
|
3297
|
+
_: 1
|
|
3298
|
+
})
|
|
3299
|
+
], 2)) : vue.createCommentVNode("", true)
|
|
3300
|
+
]),
|
|
3301
|
+
_: 2
|
|
3302
|
+
}, [
|
|
3303
|
+
vue.unref(mode) === vue.unref(CodeEditorMode).LIST ? {
|
|
3304
|
+
name: "left",
|
|
3305
|
+
fn: vue.withCtx(() => [
|
|
3306
|
+
!vue.unref(lodashEs.isEmpty)(state.codeList) ? (vue.openBlock(), vue.createBlock(_component_el_tree, {
|
|
3307
|
+
key: 0,
|
|
3308
|
+
ref: "tree",
|
|
3309
|
+
"node-key": "id",
|
|
3310
|
+
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3311
|
+
data: state.codeList,
|
|
3312
|
+
"highlight-current": true,
|
|
3313
|
+
onNodeClick: selectHandler,
|
|
3314
|
+
"current-node-key": state.codeList[0].id,
|
|
3315
|
+
class: "side-tree"
|
|
3316
|
+
}, {
|
|
3317
|
+
default: vue.withCtx(({ data }) => [
|
|
3318
|
+
vue.createElementVNode("div", {
|
|
3319
|
+
id: data.id,
|
|
3320
|
+
class: "list-container"
|
|
3321
|
+
}, [
|
|
3322
|
+
vue.createElementVNode("div", _hoisted_2$3, [
|
|
3323
|
+
vue.createElementVNode("div", _hoisted_3$1, vue.toDisplayString(data.name) + "\uFF08" + vue.toDisplayString(data.id) + "\uFF09", 1)
|
|
3324
|
+
])
|
|
3325
|
+
], 8, _hoisted_1$6)
|
|
3326
|
+
]),
|
|
3327
|
+
_: 1
|
|
3328
|
+
}, 8, ["data", "current-node-key"])) : vue.createCommentVNode("", true)
|
|
3329
|
+
])
|
|
3330
|
+
} : void 0
|
|
3331
|
+
]), 1032, ["left"])
|
|
3332
|
+
]),
|
|
3333
|
+
_: 3
|
|
3334
|
+
}, 8, ["modelValue", "title"]);
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3337
|
+
});
|
|
3338
|
+
|
|
3339
|
+
const _hoisted_1$5 = { class: "m-editor-code-block-list" };
|
|
3340
|
+
const _hoisted_2$2 = { class: "code-header-wrapper" };
|
|
3341
|
+
const _hoisted_3 = /* @__PURE__ */ vue.createTextVNode("\u65B0\u589E");
|
|
3342
|
+
const _hoisted_4 = ["id"];
|
|
3343
|
+
const _hoisted_5 = { class: "list-item" };
|
|
3344
|
+
const _hoisted_6 = { class: "code-name" };
|
|
3345
|
+
const _hoisted_7 = { class: "right-tool" };
|
|
3346
|
+
const _hoisted_8 = {
|
|
3347
|
+
key: 0,
|
|
3348
|
+
class: "code-comp-map-wrapper"
|
|
3349
|
+
};
|
|
3350
|
+
const _hoisted_9 = /* @__PURE__ */ vue.createElementVNode("svg", {
|
|
3351
|
+
class: "arrow-left",
|
|
3352
|
+
viewBox: "0 0 1024 1024",
|
|
3353
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3354
|
+
"data-v-029747aa": ""
|
|
3355
|
+
}, [
|
|
3356
|
+
/* @__PURE__ */ vue.createElementVNode("path", {
|
|
3357
|
+
fill: "currentColor",
|
|
3358
|
+
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"
|
|
3359
|
+
})
|
|
3360
|
+
], -1);
|
|
3361
|
+
const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
|
|
3362
|
+
__name: "CodeBlockList",
|
|
3363
|
+
props: {
|
|
3364
|
+
customError: null
|
|
3365
|
+
},
|
|
3366
|
+
setup(__props) {
|
|
3367
|
+
const props = __props;
|
|
3368
|
+
const services = vue.inject("services");
|
|
3369
|
+
const state = vue.reactive({
|
|
3370
|
+
codeList: [],
|
|
3371
|
+
bindComps: {}
|
|
3372
|
+
});
|
|
3373
|
+
const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
|
|
3374
|
+
const getBindCompsByCodeId = (codeId, codeBlockContent) => {
|
|
3375
|
+
if (lodashEs.isEmpty(codeBlockContent) || lodashEs.isEmpty(codeBlockContent.comps)) {
|
|
3376
|
+
state.bindComps[codeId] = [];
|
|
3377
|
+
return;
|
|
3378
|
+
}
|
|
3379
|
+
const compsField = codeBlockContent.comps;
|
|
3380
|
+
const bindCompIds = Object.keys(compsField);
|
|
3381
|
+
const bindCompsFiltered = bindCompIds.filter((compId) => !lodashEs.isEmpty(compsField[compId]));
|
|
3382
|
+
const compsInfo = bindCompsFiltered.map((compId) => ({
|
|
3383
|
+
id: compId,
|
|
3384
|
+
name: getCompName(compId)
|
|
3385
|
+
}));
|
|
3386
|
+
state.bindComps[codeId] = compsInfo;
|
|
3387
|
+
};
|
|
3388
|
+
const initList = async () => {
|
|
3389
|
+
const codeDsl = await services?.codeBlockService.getCodeDsl() || null;
|
|
3390
|
+
if (!codeDsl)
|
|
3391
|
+
return;
|
|
3392
|
+
state.codeList = [];
|
|
3393
|
+
lodashEs.forIn(codeDsl, (value, codeId) => {
|
|
3394
|
+
getBindCompsByCodeId(codeId, value);
|
|
3395
|
+
state.codeList.push({
|
|
3396
|
+
id: codeId,
|
|
3397
|
+
name: value.name,
|
|
3398
|
+
codeBlockContent: value,
|
|
3399
|
+
showRelation: true
|
|
3400
|
+
});
|
|
3401
|
+
});
|
|
3402
|
+
};
|
|
3403
|
+
vue.watch(
|
|
3404
|
+
() => services?.codeBlockService.getCodeDsl(),
|
|
3405
|
+
() => {
|
|
3406
|
+
initList();
|
|
3407
|
+
},
|
|
3408
|
+
{
|
|
3409
|
+
immediate: true,
|
|
3410
|
+
deep: true
|
|
3411
|
+
}
|
|
3412
|
+
);
|
|
3413
|
+
vue.watch(
|
|
3414
|
+
() => services?.editorService.get("node"),
|
|
3415
|
+
(curNode) => {
|
|
3416
|
+
if (!curNode?.id)
|
|
3417
|
+
return;
|
|
3418
|
+
lodashEs.forIn(state.bindComps, (bindCompInfo) => {
|
|
3419
|
+
bindCompInfo.forEach((comp) => {
|
|
3420
|
+
if (comp.id === curNode.id) {
|
|
3421
|
+
comp.name = curNode.name;
|
|
3422
|
+
}
|
|
3423
|
+
});
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
);
|
|
3427
|
+
const createCodeBlock = async () => {
|
|
3428
|
+
const { codeBlockService } = services || {};
|
|
3429
|
+
if (!codeBlockService) {
|
|
3430
|
+
elementPlus.ElMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
const codeConfig = {
|
|
3434
|
+
name: "\u4EE3\u7801\u5757",
|
|
3435
|
+
content: `() => {
|
|
3436
|
+
// place your code here
|
|
3437
|
+
}`
|
|
3438
|
+
};
|
|
3439
|
+
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
3440
|
+
const id = await codeBlockService.getUniqueId();
|
|
3441
|
+
await codeBlockService.setCodeDslById(id, codeConfig);
|
|
3442
|
+
codeBlockService.setCodeEditorContent(true, id);
|
|
2707
3443
|
};
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
3444
|
+
const editCode = async (key) => {
|
|
3445
|
+
await services?.codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
3446
|
+
services?.codeBlockService.setCodeEditorContent(true, key);
|
|
3447
|
+
};
|
|
3448
|
+
const deleteCode = (key) => {
|
|
3449
|
+
const existBinds = !!(state.bindComps[key]?.length > 0);
|
|
3450
|
+
const undeleteableList = services?.codeBlockService.getUndeletableList() || [];
|
|
3451
|
+
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3452
|
+
services?.codeBlockService.deleteCodeDslByIds([key]);
|
|
3453
|
+
} else {
|
|
3454
|
+
if (typeof props.customError === "function") {
|
|
3455
|
+
props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
3456
|
+
} else {
|
|
3457
|
+
elementPlus.ElMessage.error("\u4EE3\u7801\u5757\u5220\u9664\u5931\u8D25");
|
|
3458
|
+
}
|
|
2716
3459
|
}
|
|
2717
|
-
}
|
|
2718
|
-
const
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
console.error(e);
|
|
2724
|
-
elementPlus.ElMessage.closeAll();
|
|
2725
|
-
elementPlus.ElMessage.error({
|
|
2726
|
-
duration: 1e4,
|
|
2727
|
-
showClose: true,
|
|
2728
|
-
message: e.message,
|
|
2729
|
-
dangerouslyUseHTMLString: true
|
|
2730
|
-
});
|
|
3460
|
+
};
|
|
3461
|
+
const filterText = vue.ref("");
|
|
3462
|
+
const tree = vue.ref();
|
|
3463
|
+
const filterNode = (value, data) => {
|
|
3464
|
+
if (!value) {
|
|
3465
|
+
return true;
|
|
2731
3466
|
}
|
|
3467
|
+
return `${data.name}${data.id}`.indexOf(value) !== -1;
|
|
3468
|
+
};
|
|
3469
|
+
const filterTextChangeHandler = (val) => {
|
|
3470
|
+
tree.value?.filter(val);
|
|
3471
|
+
};
|
|
3472
|
+
const toggleCombineRelation = (data) => {
|
|
3473
|
+
const { id } = data;
|
|
3474
|
+
const currentCode = state.codeList.find((item) => item.id === id);
|
|
3475
|
+
if (!currentCode)
|
|
3476
|
+
return;
|
|
3477
|
+
currentCode.showRelation = !currentCode?.showRelation;
|
|
3478
|
+
};
|
|
3479
|
+
const getCompName = (compId) => {
|
|
3480
|
+
const node = services?.editorService.getNodeById(compId);
|
|
3481
|
+
return node?.name || String(compId);
|
|
3482
|
+
};
|
|
3483
|
+
const selectComp = (compId) => {
|
|
3484
|
+
const stage = services?.editorService.get("stage");
|
|
3485
|
+
services?.editorService.select(compId);
|
|
3486
|
+
stage?.select(compId);
|
|
2732
3487
|
};
|
|
2733
|
-
expose({ submit });
|
|
2734
3488
|
return (_ctx, _cache) => {
|
|
2735
|
-
const
|
|
3489
|
+
const _component_el_input = vue.resolveComponent("el-input");
|
|
3490
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
3491
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3492
|
+
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
2736
3493
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
|
|
2737
|
-
vue.renderSlot(_ctx.$slots, "
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
3494
|
+
vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
3495
|
+
vue.createElementVNode("div", _hoisted_2$2, [
|
|
3496
|
+
vue.createVNode(_component_el_input, {
|
|
3497
|
+
class: vue.normalizeClass([vue.unref(editable) ? "code-filter-input" : "code-filter-input-no-btn"]),
|
|
3498
|
+
size: "small",
|
|
3499
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
3500
|
+
clearable: "",
|
|
3501
|
+
modelValue: filterText.value,
|
|
3502
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
|
|
3503
|
+
onInput: filterTextChangeHandler
|
|
3504
|
+
}, null, 8, ["class", "modelValue"]),
|
|
3505
|
+
vue.unref(editable) ? (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
3506
|
+
key: 0,
|
|
3507
|
+
class: "create-code-button",
|
|
3508
|
+
type: "primary",
|
|
3509
|
+
size: "small",
|
|
3510
|
+
onClick: createCodeBlock
|
|
3511
|
+
}, {
|
|
3512
|
+
default: vue.withCtx(() => [
|
|
3513
|
+
_hoisted_3
|
|
3514
|
+
]),
|
|
3515
|
+
_: 1
|
|
3516
|
+
})) : vue.createCommentVNode("", true)
|
|
3517
|
+
])
|
|
3518
|
+
]),
|
|
3519
|
+
!vue.unref(lodashEs.isEmpty)(state.codeList) ? (vue.openBlock(), vue.createBlock(_component_el_tree, {
|
|
3520
|
+
key: 0,
|
|
3521
|
+
ref_key: "tree",
|
|
3522
|
+
ref: tree,
|
|
3523
|
+
"node-key": "id",
|
|
3524
|
+
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3525
|
+
data: state.codeList,
|
|
3526
|
+
"highlight-current": true,
|
|
3527
|
+
"filter-node-method": filterNode,
|
|
3528
|
+
onNodeClick: toggleCombineRelation
|
|
3529
|
+
}, {
|
|
3530
|
+
default: vue.withCtx(({ data }) => [
|
|
3531
|
+
vue.createElementVNode("div", {
|
|
3532
|
+
id: data.id,
|
|
3533
|
+
class: "list-container"
|
|
3534
|
+
}, [
|
|
3535
|
+
vue.createElementVNode("div", _hoisted_5, [
|
|
3536
|
+
vue.createElementVNode("div", _hoisted_6, vue.toDisplayString(data.name) + "\uFF08" + vue.toDisplayString(data.id) + "\uFF09", 1),
|
|
3537
|
+
vue.createElementVNode("div", _hoisted_7, [
|
|
3538
|
+
vue.createVNode(_component_el_tooltip, {
|
|
3539
|
+
effect: "dark",
|
|
3540
|
+
content: vue.unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
|
|
3541
|
+
placement: "bottom"
|
|
3542
|
+
}, {
|
|
3543
|
+
default: vue.withCtx(() => [
|
|
3544
|
+
vue.createVNode(_sfc_main$j, {
|
|
3545
|
+
icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
3546
|
+
class: "edit-icon",
|
|
3547
|
+
onClick: vue.withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
3548
|
+
}, null, 8, ["icon", "onClick"])
|
|
3549
|
+
]),
|
|
3550
|
+
_: 2
|
|
3551
|
+
}, 1032, ["content"]),
|
|
3552
|
+
state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
3553
|
+
key: 0,
|
|
3554
|
+
effect: "dark",
|
|
3555
|
+
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3556
|
+
placement: "bottom"
|
|
3557
|
+
}, {
|
|
3558
|
+
default: vue.withCtx(() => [
|
|
3559
|
+
vue.createVNode(_sfc_main$j, {
|
|
3560
|
+
icon: vue.unref(iconsVue.Link),
|
|
3561
|
+
class: "edit-icon",
|
|
3562
|
+
onClick: vue.withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
3563
|
+
}, null, 8, ["icon", "onClick"])
|
|
3564
|
+
]),
|
|
3565
|
+
_: 2
|
|
3566
|
+
}, 1024)) : vue.createCommentVNode("", true),
|
|
3567
|
+
vue.unref(editable) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
3568
|
+
key: 1,
|
|
3569
|
+
effect: "dark",
|
|
3570
|
+
content: "\u5220\u9664",
|
|
3571
|
+
placement: "bottom"
|
|
3572
|
+
}, {
|
|
3573
|
+
default: vue.withCtx(() => [
|
|
3574
|
+
vue.createVNode(_sfc_main$j, {
|
|
3575
|
+
icon: vue.unref(iconsVue.Close),
|
|
3576
|
+
class: "edit-icon",
|
|
3577
|
+
onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
3578
|
+
}, null, 8, ["icon", "onClick"])
|
|
3579
|
+
]),
|
|
3580
|
+
_: 2
|
|
3581
|
+
}, 1024)) : vue.createCommentVNode("", true),
|
|
3582
|
+
vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
3583
|
+
id: data.id,
|
|
3584
|
+
data: data.codeBlockContent
|
|
3585
|
+
})
|
|
3586
|
+
])
|
|
3587
|
+
]),
|
|
3588
|
+
data.showRelation && state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
|
|
3589
|
+
_hoisted_9,
|
|
3590
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(state.bindComps[data.id], (comp, index) => {
|
|
3591
|
+
return vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
3592
|
+
key: index,
|
|
3593
|
+
class: "code-comp",
|
|
3594
|
+
size: "small",
|
|
3595
|
+
plain: true,
|
|
3596
|
+
onClick: vue.withModifiers(($event) => selectComp(comp.id), ["stop"])
|
|
3597
|
+
}, {
|
|
3598
|
+
default: vue.withCtx(() => [
|
|
3599
|
+
vue.createTextVNode(vue.toDisplayString(comp.name), 1)
|
|
3600
|
+
]),
|
|
3601
|
+
_: 2
|
|
3602
|
+
}, 1032, ["onClick"]);
|
|
3603
|
+
}), 128))
|
|
3604
|
+
])) : vue.createCommentVNode("", true)
|
|
3605
|
+
], 8, _hoisted_4)
|
|
3606
|
+
]),
|
|
3607
|
+
_: 3
|
|
3608
|
+
}, 8, ["data"])) : vue.createCommentVNode("", true),
|
|
3609
|
+
vue.createVNode(_sfc_main$f, null, {
|
|
3610
|
+
"code-block-edit-panel-header": vue.withCtx(({ id }) => [
|
|
3611
|
+
vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
3612
|
+
]),
|
|
3613
|
+
_: 3
|
|
3614
|
+
})
|
|
2748
3615
|
]);
|
|
2749
3616
|
};
|
|
2750
3617
|
}
|
|
@@ -2862,7 +3729,7 @@
|
|
|
2862
3729
|
onDrag: dragHandler
|
|
2863
3730
|
}, [
|
|
2864
3731
|
vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
2865
|
-
vue.createVNode(_sfc_main$
|
|
3732
|
+
vue.createVNode(_sfc_main$j, {
|
|
2866
3733
|
icon: item.icon
|
|
2867
3734
|
}, null, 8, ["icon"]),
|
|
2868
3735
|
vue.createVNode(_component_el_tooltip, {
|
|
@@ -2982,7 +3849,7 @@
|
|
|
2982
3849
|
}, [
|
|
2983
3850
|
vue.createElementVNode("div", null, [
|
|
2984
3851
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
|
|
2985
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3852
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$i, {
|
|
2986
3853
|
"event-type": "mouseup",
|
|
2987
3854
|
data: item,
|
|
2988
3855
|
key: index,
|
|
@@ -3006,9 +3873,9 @@
|
|
|
3006
3873
|
}
|
|
3007
3874
|
});
|
|
3008
3875
|
|
|
3009
|
-
const _sfc_main$b = vue.defineComponent({
|
|
3010
|
-
|
|
3011
|
-
setup() {
|
|
3876
|
+
const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
|
|
3877
|
+
__name: "LayerMenu",
|
|
3878
|
+
setup(__props, { expose }) {
|
|
3012
3879
|
const services = vue.inject("services");
|
|
3013
3880
|
const menu = vue.ref();
|
|
3014
3881
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
@@ -3059,53 +3926,51 @@
|
|
|
3059
3926
|
}
|
|
3060
3927
|
return [];
|
|
3061
3928
|
});
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3929
|
+
const menuData = vue.computed(() => [
|
|
3930
|
+
{
|
|
3931
|
+
type: "button",
|
|
3932
|
+
text: "\u65B0\u589E",
|
|
3933
|
+
icon: vue.markRaw(iconsVue.Plus),
|
|
3934
|
+
display: () => node.value?.items,
|
|
3935
|
+
items: getSubMenuData.value
|
|
3936
|
+
},
|
|
3937
|
+
{
|
|
3938
|
+
type: "button",
|
|
3939
|
+
text: "\u590D\u5236",
|
|
3940
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3941
|
+
display: () => !isRoot.value,
|
|
3942
|
+
handler: () => {
|
|
3943
|
+
node.value && services?.editorService.copy(node.value);
|
|
3944
|
+
}
|
|
3945
|
+
},
|
|
3946
|
+
{
|
|
3947
|
+
type: "button",
|
|
3948
|
+
text: "\u5220\u9664",
|
|
3949
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
3950
|
+
display: () => !isRoot.value && !isPage.value,
|
|
3951
|
+
handler: () => {
|
|
3952
|
+
node.value && services?.editorService.remove(node.value);
|
|
3953
|
+
}
|
|
3954
|
+
},
|
|
3955
|
+
...layerContentMenu
|
|
3956
|
+
]);
|
|
3957
|
+
const show = (e) => {
|
|
3958
|
+
menu.value?.show(e);
|
|
3959
|
+
};
|
|
3960
|
+
expose({
|
|
3961
|
+
show
|
|
3962
|
+
});
|
|
3963
|
+
return (_ctx, _cache) => {
|
|
3964
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$c, {
|
|
3965
|
+
"menu-data": vue.unref(menuData),
|
|
3966
|
+
ref_key: "menu",
|
|
3967
|
+
ref: menu,
|
|
3968
|
+
style: { "overflow": "initial" }
|
|
3969
|
+
}, null, 8, ["menu-data"]);
|
|
3095
3970
|
};
|
|
3096
3971
|
}
|
|
3097
3972
|
});
|
|
3098
3973
|
|
|
3099
|
-
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3100
|
-
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
3101
|
-
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
3102
|
-
"menu-data": _ctx.menuData,
|
|
3103
|
-
ref: "menu",
|
|
3104
|
-
style: { "overflow": "initial" }
|
|
3105
|
-
}, null, 8, ["menu-data"]);
|
|
3106
|
-
}
|
|
3107
|
-
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
|
|
3108
|
-
|
|
3109
3974
|
const throttleTime = 150;
|
|
3110
3975
|
const select = async (data, editorService) => {
|
|
3111
3976
|
if (!data.id) {
|
|
@@ -3233,7 +4098,7 @@
|
|
|
3233
4098
|
});
|
|
3234
4099
|
const _sfc_main$a = vue.defineComponent({
|
|
3235
4100
|
name: "magic-editor-layer-panel",
|
|
3236
|
-
components: { LayerMenu },
|
|
4101
|
+
components: { LayerMenu: _sfc_main$b },
|
|
3237
4102
|
setup() {
|
|
3238
4103
|
const services = vue.inject("services");
|
|
3239
4104
|
const tree = vue.ref();
|
|
@@ -3281,8 +4146,16 @@
|
|
|
3281
4146
|
}
|
|
3282
4147
|
});
|
|
3283
4148
|
|
|
4149
|
+
const _export_sfc = (sfc, props) => {
|
|
4150
|
+
const target = sfc.__vccOpts || sfc;
|
|
4151
|
+
for (const [key, val] of props) {
|
|
4152
|
+
target[key] = val;
|
|
4153
|
+
}
|
|
4154
|
+
return target;
|
|
4155
|
+
};
|
|
4156
|
+
|
|
3284
4157
|
const _hoisted_1$3 = ["id", "onMouseenter"];
|
|
3285
|
-
function _sfc_render$
|
|
4158
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3286
4159
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3287
4160
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
3288
4161
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -3346,190 +4219,232 @@
|
|
|
3346
4219
|
_: 3
|
|
3347
4220
|
});
|
|
3348
4221
|
}
|
|
3349
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$
|
|
3350
|
-
|
|
3351
|
-
const _sfc_main$9 = vue.defineComponent({
|
|
3352
|
-
components: { MIcon: _sfc_main$h },
|
|
3353
|
-
props: {
|
|
3354
|
-
data: {
|
|
3355
|
-
type: [Object, String]
|
|
3356
|
-
}
|
|
3357
|
-
},
|
|
3358
|
-
setup(props) {
|
|
3359
|
-
return {
|
|
3360
|
-
config: vue.computed(() => {
|
|
3361
|
-
if (typeof props.data !== "string") {
|
|
3362
|
-
return props.data;
|
|
3363
|
-
}
|
|
3364
|
-
switch (props.data) {
|
|
3365
|
-
case "component-list":
|
|
3366
|
-
return {
|
|
3367
|
-
type: "component",
|
|
3368
|
-
icon: iconsVue.Coin,
|
|
3369
|
-
text: "\u7EC4\u4EF6",
|
|
3370
|
-
component: _sfc_main$d,
|
|
3371
|
-
slots: {}
|
|
3372
|
-
};
|
|
3373
|
-
case "layer":
|
|
3374
|
-
return {
|
|
3375
|
-
type: "component",
|
|
3376
|
-
icon: iconsVue.Files,
|
|
3377
|
-
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
3378
|
-
component: LayerPanel,
|
|
3379
|
-
slots: {}
|
|
3380
|
-
};
|
|
3381
|
-
default:
|
|
3382
|
-
return void 0;
|
|
3383
|
-
}
|
|
3384
|
-
})
|
|
3385
|
-
};
|
|
3386
|
-
}
|
|
3387
|
-
});
|
|
4222
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$1]]);
|
|
3388
4223
|
|
|
3389
4224
|
const _hoisted_1$2 = {
|
|
3390
4225
|
key: 1,
|
|
3391
4226
|
class: "magic-editor-tab-panel-title"
|
|
3392
4227
|
};
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
(
|
|
3402
|
-
|
|
3403
|
-
}
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
4228
|
+
const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
4229
|
+
__name: "TabPane",
|
|
4230
|
+
props: {
|
|
4231
|
+
data: null
|
|
4232
|
+
},
|
|
4233
|
+
setup(__props) {
|
|
4234
|
+
const props = __props;
|
|
4235
|
+
const config = vue.computed(() => {
|
|
4236
|
+
if (typeof props.data !== "string") {
|
|
4237
|
+
return props.data;
|
|
4238
|
+
}
|
|
4239
|
+
switch (props.data) {
|
|
4240
|
+
case "component-list":
|
|
4241
|
+
return {
|
|
4242
|
+
type: "component",
|
|
4243
|
+
icon: iconsVue.Coin,
|
|
4244
|
+
text: "\u7EC4\u4EF6",
|
|
4245
|
+
component: _sfc_main$d,
|
|
4246
|
+
slots: {}
|
|
4247
|
+
};
|
|
4248
|
+
case "layer":
|
|
4249
|
+
return {
|
|
4250
|
+
type: "component",
|
|
4251
|
+
icon: iconsVue.Files,
|
|
4252
|
+
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
4253
|
+
component: LayerPanel,
|
|
4254
|
+
slots: {}
|
|
4255
|
+
};
|
|
4256
|
+
case "code-block":
|
|
4257
|
+
return {
|
|
4258
|
+
type: "component",
|
|
4259
|
+
icon: iconsVue.EditPen,
|
|
4260
|
+
text: "\u4EE3\u7801\u7F16\u8F91",
|
|
4261
|
+
component: _sfc_main$e,
|
|
4262
|
+
slots: {}
|
|
4263
|
+
};
|
|
4264
|
+
default:
|
|
4265
|
+
return void 0;
|
|
4266
|
+
}
|
|
4267
|
+
});
|
|
4268
|
+
return (_ctx, _cache) => {
|
|
4269
|
+
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
4270
|
+
return vue.unref(config) ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
|
|
4271
|
+
key: 0,
|
|
4272
|
+
name: vue.unref(config).text
|
|
4273
|
+
}, {
|
|
4274
|
+
label: vue.withCtx(() => [
|
|
4275
|
+
(vue.openBlock(), vue.createElementBlock("div", {
|
|
4276
|
+
key: vue.unref(config).text
|
|
4277
|
+
}, [
|
|
4278
|
+
vue.unref(config).icon ? (vue.openBlock(), vue.createBlock(_sfc_main$j, {
|
|
3441
4279
|
key: 0,
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
4280
|
+
icon: vue.unref(config).icon
|
|
4281
|
+
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
4282
|
+
vue.unref(config).text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, vue.toDisplayString(vue.unref(config).text), 1)) : vue.createCommentVNode("", true)
|
|
4283
|
+
]))
|
|
4284
|
+
]),
|
|
4285
|
+
default: vue.withCtx(() => [
|
|
4286
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).component), vue.mergeProps(vue.unref(config).props || {}, vue.toHandlers(vue.unref(config)?.listeners || {})), vue.createSlots({ _: 2 }, [
|
|
4287
|
+
__props.data === "component-list" || vue.unref(config).slots?.componentListPanelHeader ? {
|
|
4288
|
+
name: "component-list-panel-header",
|
|
4289
|
+
fn: vue.withCtx(() => [
|
|
4290
|
+
__props.data === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : vue.unref(config).slots?.componentListPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).slots.componentListPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
|
|
4291
|
+
])
|
|
4292
|
+
} : void 0,
|
|
4293
|
+
__props.data === "component-list" || vue.unref(config).slots?.componentListItem ? {
|
|
4294
|
+
name: "component-list-item",
|
|
4295
|
+
fn: vue.withCtx(({ component }) => [
|
|
4296
|
+
__props.data === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-item", {
|
|
4297
|
+
key: 0,
|
|
4298
|
+
component
|
|
4299
|
+
}) : vue.unref(config).slots?.componentListItem ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).slots.componentListItem), {
|
|
4300
|
+
key: 1,
|
|
4301
|
+
component
|
|
4302
|
+
}, null, 8, ["component"])) : vue.createCommentVNode("", true)
|
|
4303
|
+
])
|
|
4304
|
+
} : void 0,
|
|
4305
|
+
__props.data === "layer" || vue.unref(config).slots?.layerPanelHeader ? {
|
|
4306
|
+
name: "layer-panel-header",
|
|
4307
|
+
fn: vue.withCtx(() => [
|
|
4308
|
+
__props.data === "layer" ? vue.renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : vue.unref(config).slots?.layerPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).slots.layerPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
|
|
4309
|
+
])
|
|
4310
|
+
} : void 0,
|
|
4311
|
+
__props.data === "code-block" || vue.unref(config).slots?.codeBlockPanelHeader ? {
|
|
4312
|
+
name: "code-block-panel-header",
|
|
4313
|
+
fn: vue.withCtx(() => [
|
|
4314
|
+
__props.data === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : vue.unref(config).slots?.codeBlockPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).slots.codeBlockPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
|
|
4315
|
+
])
|
|
4316
|
+
} : void 0,
|
|
4317
|
+
__props.data === "code-block" || vue.unref(config).slots?.codeBlockPanelTool ? {
|
|
4318
|
+
name: "code-block-panel-tool",
|
|
4319
|
+
fn: vue.withCtx(({ id, data }) => [
|
|
4320
|
+
data === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4321
|
+
key: 0,
|
|
4322
|
+
id,
|
|
4323
|
+
data
|
|
4324
|
+
}) : vue.unref(config).slots?.codeBlockPanelTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).slots.codeBlockPanelTool), { key: 1 })) : vue.createCommentVNode("", true)
|
|
4325
|
+
])
|
|
4326
|
+
} : void 0,
|
|
4327
|
+
__props.data === "code-block" || vue.unref(config).slots?.codeBlockEditPanelHeader ? {
|
|
4328
|
+
name: "code-block-edit-panel-header",
|
|
4329
|
+
fn: vue.withCtx(({ id }) => [
|
|
4330
|
+
__props.data === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
|
|
4331
|
+
key: 0,
|
|
4332
|
+
id
|
|
4333
|
+
}) : vue.unref(config).slots?.codeBlockEditPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).slots.codeBlockEditPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
|
|
4334
|
+
])
|
|
4335
|
+
} : void 0,
|
|
4336
|
+
__props.data === "layer" || vue.unref(config).slots?.layerNodeContent ? {
|
|
4337
|
+
name: "layer-node-content",
|
|
4338
|
+
fn: vue.withCtx(({ data: nodeData, node }) => [
|
|
4339
|
+
__props.data === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4340
|
+
key: 0,
|
|
4341
|
+
data: nodeData,
|
|
4342
|
+
node
|
|
4343
|
+
}) : vue.unref(config).slots?.layerNodeContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(config).slots.layerNodeContent), {
|
|
4344
|
+
key: 1,
|
|
4345
|
+
data: nodeData,
|
|
4346
|
+
node
|
|
4347
|
+
}, null, 8, ["data", "node"])) : vue.createCommentVNode("", true)
|
|
4348
|
+
])
|
|
4349
|
+
} : void 0
|
|
4350
|
+
]), 1040))
|
|
4351
|
+
]),
|
|
4352
|
+
_: 3
|
|
4353
|
+
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
4354
|
+
};
|
|
4355
|
+
}
|
|
4356
|
+
});
|
|
3457
4357
|
|
|
3458
|
-
const _sfc_main$8 = vue.defineComponent({
|
|
3459
|
-
|
|
3460
|
-
name: "m-sidebar",
|
|
4358
|
+
const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
4359
|
+
__name: "Sidebar",
|
|
3461
4360
|
props: {
|
|
3462
|
-
data: {
|
|
3463
|
-
type: Object,
|
|
3464
|
-
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
3465
|
-
}
|
|
4361
|
+
data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) }
|
|
3466
4362
|
},
|
|
3467
|
-
setup(
|
|
4363
|
+
setup(__props, { expose }) {
|
|
4364
|
+
const props = __props;
|
|
3468
4365
|
const activeTabName = vue.ref(props.data?.status);
|
|
3469
4366
|
vue.watch(
|
|
3470
|
-
() => props.data
|
|
4367
|
+
() => props.data.status,
|
|
3471
4368
|
(status) => {
|
|
3472
4369
|
activeTabName.value = status || "0";
|
|
3473
4370
|
}
|
|
3474
4371
|
);
|
|
3475
|
-
|
|
4372
|
+
expose({
|
|
3476
4373
|
activeTabName
|
|
4374
|
+
});
|
|
4375
|
+
return (_ctx, _cache) => {
|
|
4376
|
+
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
4377
|
+
return __props.data.type === "tabs" && __props.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
4378
|
+
key: 0,
|
|
4379
|
+
class: "m-editor-sidebar",
|
|
4380
|
+
modelValue: activeTabName.value,
|
|
4381
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
|
|
4382
|
+
type: "card",
|
|
4383
|
+
"tab-position": "left"
|
|
4384
|
+
}, {
|
|
4385
|
+
default: vue.withCtx(() => [
|
|
4386
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.data.items, (item, index) => {
|
|
4387
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$9, {
|
|
4388
|
+
key: index,
|
|
4389
|
+
data: item
|
|
4390
|
+
}, vue.createSlots({ _: 2 }, [
|
|
4391
|
+
item === "layer" ? {
|
|
4392
|
+
name: "layer-panel-header",
|
|
4393
|
+
fn: vue.withCtx(() => [
|
|
4394
|
+
vue.renderSlot(_ctx.$slots, "layer-panel-header")
|
|
4395
|
+
])
|
|
4396
|
+
} : void 0,
|
|
4397
|
+
item === "layer" ? {
|
|
4398
|
+
name: "layer-node-content",
|
|
4399
|
+
fn: vue.withCtx(({ node, data }) => [
|
|
4400
|
+
vue.renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4401
|
+
data,
|
|
4402
|
+
node
|
|
4403
|
+
})
|
|
4404
|
+
])
|
|
4405
|
+
} : void 0,
|
|
4406
|
+
item === "component-list" ? {
|
|
4407
|
+
name: "component-list-panel-header",
|
|
4408
|
+
fn: vue.withCtx(() => [
|
|
4409
|
+
vue.renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
4410
|
+
])
|
|
4411
|
+
} : void 0,
|
|
4412
|
+
item === "component-list" ? {
|
|
4413
|
+
name: "component-list-item",
|
|
4414
|
+
fn: vue.withCtx(({ component }) => [
|
|
4415
|
+
vue.renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
4416
|
+
])
|
|
4417
|
+
} : void 0,
|
|
4418
|
+
item === "code-block" ? {
|
|
4419
|
+
name: "code-block-panel-header",
|
|
4420
|
+
fn: vue.withCtx(() => [
|
|
4421
|
+
vue.renderSlot(_ctx.$slots, "code-block-panel-header")
|
|
4422
|
+
])
|
|
4423
|
+
} : void 0,
|
|
4424
|
+
item === "code-block" ? {
|
|
4425
|
+
name: "code-block-panel-tool",
|
|
4426
|
+
fn: vue.withCtx(({ id, data }) => [
|
|
4427
|
+
vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4428
|
+
id,
|
|
4429
|
+
data
|
|
4430
|
+
})
|
|
4431
|
+
])
|
|
4432
|
+
} : void 0,
|
|
4433
|
+
item === "code-block" ? {
|
|
4434
|
+
name: "code-block-edit-panel-header",
|
|
4435
|
+
fn: vue.withCtx(({ id }) => [
|
|
4436
|
+
vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
4437
|
+
])
|
|
4438
|
+
} : void 0
|
|
4439
|
+
]), 1032, ["data"]);
|
|
4440
|
+
}), 128))
|
|
4441
|
+
]),
|
|
4442
|
+
_: 3
|
|
4443
|
+
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
3477
4444
|
};
|
|
3478
4445
|
}
|
|
3479
4446
|
});
|
|
3480
4447
|
|
|
3481
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3482
|
-
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
3483
|
-
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
3484
|
-
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
3485
|
-
key: 0,
|
|
3486
|
-
class: "m-editor-sidebar",
|
|
3487
|
-
modelValue: _ctx.activeTabName,
|
|
3488
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.activeTabName = $event),
|
|
3489
|
-
type: "card",
|
|
3490
|
-
"tab-position": "left"
|
|
3491
|
-
}, {
|
|
3492
|
-
default: vue.withCtx(() => [
|
|
3493
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data.items, (item, index) => {
|
|
3494
|
-
return vue.openBlock(), vue.createBlock(_component_tab_pane, {
|
|
3495
|
-
key: index,
|
|
3496
|
-
data: item
|
|
3497
|
-
}, vue.createSlots({ _: 2 }, [
|
|
3498
|
-
item === "layer" ? {
|
|
3499
|
-
name: "layer-panel-header",
|
|
3500
|
-
fn: vue.withCtx(() => [
|
|
3501
|
-
vue.renderSlot(_ctx.$slots, "layer-panel-header")
|
|
3502
|
-
])
|
|
3503
|
-
} : void 0,
|
|
3504
|
-
item === "layer" ? {
|
|
3505
|
-
name: "layer-node-content",
|
|
3506
|
-
fn: vue.withCtx(({ node, data }) => [
|
|
3507
|
-
vue.renderSlot(_ctx.$slots, "layer-node-content", {
|
|
3508
|
-
data,
|
|
3509
|
-
node
|
|
3510
|
-
})
|
|
3511
|
-
])
|
|
3512
|
-
} : void 0,
|
|
3513
|
-
item === "component-list" ? {
|
|
3514
|
-
name: "component-list-panel-header",
|
|
3515
|
-
fn: vue.withCtx(() => [
|
|
3516
|
-
vue.renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
3517
|
-
])
|
|
3518
|
-
} : void 0,
|
|
3519
|
-
item === "component-list" ? {
|
|
3520
|
-
name: "component-list-item",
|
|
3521
|
-
fn: vue.withCtx(({ component }) => [
|
|
3522
|
-
vue.renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
3523
|
-
])
|
|
3524
|
-
} : void 0
|
|
3525
|
-
]), 1032, ["data"]);
|
|
3526
|
-
}), 128))
|
|
3527
|
-
]),
|
|
3528
|
-
_: 3
|
|
3529
|
-
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
3530
|
-
}
|
|
3531
|
-
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
|
|
3532
|
-
|
|
3533
4448
|
const _hoisted_1$1 = {
|
|
3534
4449
|
key: 1,
|
|
3535
4450
|
style: { "width": "21px" }
|
|
@@ -3616,14 +4531,14 @@
|
|
|
3616
4531
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3617
4532
|
onClick: addPage
|
|
3618
4533
|
}, [
|
|
3619
|
-
vue.createVNode(_sfc_main$
|
|
4534
|
+
vue.createVNode(_sfc_main$j, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
3620
4535
|
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1)),
|
|
3621
4536
|
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3622
4537
|
key: 2,
|
|
3623
4538
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3624
4539
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3625
4540
|
}, [
|
|
3626
|
-
vue.createVNode(_sfc_main$
|
|
4541
|
+
vue.createVNode(_sfc_main$j, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
|
|
3627
4542
|
])) : vue.createCommentVNode("", true),
|
|
3628
4543
|
vue.unref(pageLength) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3629
4544
|
key: 3,
|
|
@@ -3639,7 +4554,7 @@
|
|
|
3639
4554
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3640
4555
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3641
4556
|
}, [
|
|
3642
|
-
vue.createVNode(_sfc_main$
|
|
4557
|
+
vue.createVNode(_sfc_main$j, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
|
|
3643
4558
|
])) : vue.createCommentVNode("", true)
|
|
3644
4559
|
], 512);
|
|
3645
4560
|
};
|
|
@@ -3711,7 +4626,7 @@
|
|
|
3711
4626
|
default: vue.withCtx(() => [
|
|
3712
4627
|
vue.createElementVNode("div", null, [
|
|
3713
4628
|
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3714
|
-
vue.createVNode(_sfc_main$
|
|
4629
|
+
vue.createVNode(_sfc_main$i, {
|
|
3715
4630
|
data: {
|
|
3716
4631
|
type: "button",
|
|
3717
4632
|
text: "\u590D\u5236",
|
|
@@ -3719,7 +4634,7 @@
|
|
|
3719
4634
|
handler: () => copy(item)
|
|
3720
4635
|
}
|
|
3721
4636
|
}, null, 8, ["data"]),
|
|
3722
|
-
vue.createVNode(_sfc_main$
|
|
4637
|
+
vue.createVNode(_sfc_main$i, {
|
|
3723
4638
|
data: {
|
|
3724
4639
|
type: "button",
|
|
3725
4640
|
text: "\u5220\u9664",
|
|
@@ -4493,11 +5408,11 @@
|
|
|
4493
5408
|
const _sfc_main = vue.defineComponent({
|
|
4494
5409
|
name: "m-editor",
|
|
4495
5410
|
components: {
|
|
4496
|
-
NavMenu: _sfc_main$
|
|
4497
|
-
Sidebar,
|
|
5411
|
+
NavMenu: _sfc_main$h,
|
|
5412
|
+
Sidebar: _sfc_main$8,
|
|
4498
5413
|
Workspace: _sfc_main$1,
|
|
4499
|
-
PropsPanel: _sfc_main$
|
|
4500
|
-
Framework: _sfc_main$
|
|
5414
|
+
PropsPanel: _sfc_main$g,
|
|
5415
|
+
Framework: _sfc_main$k
|
|
4501
5416
|
},
|
|
4502
5417
|
props: {
|
|
4503
5418
|
modelValue: {
|
|
@@ -4592,7 +5507,9 @@
|
|
|
4592
5507
|
});
|
|
4593
5508
|
vue.watch(
|
|
4594
5509
|
() => props.modelValue,
|
|
4595
|
-
(modelValue) =>
|
|
5510
|
+
(modelValue) => {
|
|
5511
|
+
editorService.set("root", modelValue);
|
|
5512
|
+
},
|
|
4596
5513
|
{
|
|
4597
5514
|
immediate: true
|
|
4598
5515
|
}
|
|
@@ -4655,6 +5572,7 @@
|
|
|
4655
5572
|
uiService.destroy();
|
|
4656
5573
|
componentListService.destroy();
|
|
4657
5574
|
storageService.destroy();
|
|
5575
|
+
codeBlockService.destroy();
|
|
4658
5576
|
});
|
|
4659
5577
|
const services = {
|
|
4660
5578
|
componentListService,
|
|
@@ -4663,7 +5581,8 @@
|
|
|
4663
5581
|
propsService,
|
|
4664
5582
|
editorService,
|
|
4665
5583
|
uiService,
|
|
4666
|
-
storageService
|
|
5584
|
+
storageService,
|
|
5585
|
+
codeBlockService
|
|
4667
5586
|
};
|
|
4668
5587
|
vue.provide("services", services);
|
|
4669
5588
|
vue.provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4717,6 +5636,18 @@
|
|
|
4717
5636
|
"component-list-item": vue.withCtx(({ component }) => [
|
|
4718
5637
|
vue.renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
4719
5638
|
]),
|
|
5639
|
+
"code-block-panel-header": vue.withCtx(() => [
|
|
5640
|
+
vue.renderSlot(_ctx.$slots, "code-block-panel-header")
|
|
5641
|
+
]),
|
|
5642
|
+
"code-block-panel-tool": vue.withCtx(({ id, data }) => [
|
|
5643
|
+
vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
5644
|
+
id,
|
|
5645
|
+
data
|
|
5646
|
+
})
|
|
5647
|
+
]),
|
|
5648
|
+
"code-block-edit-panel-header": vue.withCtx(({ id }) => [
|
|
5649
|
+
vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
5650
|
+
]),
|
|
4720
5651
|
_: 3
|
|
4721
5652
|
}, 8, ["data"])
|
|
4722
5653
|
])
|
|
@@ -4769,30 +5700,37 @@
|
|
|
4769
5700
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4770
5701
|
setConfig(option);
|
|
4771
5702
|
app.component(Editor.name, Editor);
|
|
4772
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
4773
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
4774
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
4775
|
-
app.component(
|
|
5703
|
+
app.component("m-fields-ui-select", _sfc_main$p);
|
|
5704
|
+
app.component("m-fields-code-link", _sfc_main$r);
|
|
5705
|
+
app.component("m-fields-vs-code", _sfc_main$s);
|
|
5706
|
+
app.component("magic-code-editor", _sfc_main$o);
|
|
5707
|
+
app.component("m-fields-code-select", _sfc_main$q);
|
|
4776
5708
|
}
|
|
4777
5709
|
};
|
|
4778
5710
|
|
|
4779
5711
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
5712
|
+
exports.CodeBlockList = _sfc_main$e;
|
|
5713
|
+
exports.CodeDeleteErrorType = CodeDeleteErrorType;
|
|
5714
|
+
exports.CodeEditorMode = CodeEditorMode;
|
|
5715
|
+
exports.CodeSelect = _sfc_main$q;
|
|
5716
|
+
exports.CodeSelectOp = CodeSelectOp;
|
|
4780
5717
|
exports.ColumnLayout = ColumnLayout;
|
|
4781
5718
|
exports.ComponentListPanel = _sfc_main$d;
|
|
4782
5719
|
exports.ContentMenu = _sfc_main$c;
|
|
4783
5720
|
exports.Fixed2Other = Fixed2Other;
|
|
4784
5721
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
4785
|
-
exports.Icon = _sfc_main$
|
|
5722
|
+
exports.Icon = _sfc_main$j;
|
|
4786
5723
|
exports.Keys = Keys;
|
|
4787
5724
|
exports.LayerOffset = LayerOffset;
|
|
4788
5725
|
exports.LayerPanel = LayerPanel;
|
|
4789
5726
|
exports.Layout = Layout;
|
|
4790
|
-
exports.PropsPanel = _sfc_main$
|
|
4791
|
-
exports.TMagicCodeEditor =
|
|
5727
|
+
exports.PropsPanel = _sfc_main$g;
|
|
5728
|
+
exports.TMagicCodeEditor = _sfc_main$o;
|
|
4792
5729
|
exports.TMagicEditor = Editor;
|
|
4793
|
-
exports.ToolButton = _sfc_main$
|
|
5730
|
+
exports.ToolButton = _sfc_main$i;
|
|
4794
5731
|
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4795
5732
|
exports.change2Fixed = change2Fixed;
|
|
5733
|
+
exports.codeBlockService = codeBlockService;
|
|
4796
5734
|
exports.debug = debug;
|
|
4797
5735
|
exports.default = index;
|
|
4798
5736
|
exports.editorService = editorService;
|