@tmagic/editor 1.0.4 → 1.1.0-beta.1
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/tmagic-editor.es.js +237 -98
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +269 -129
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +28 -1
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -0
- package/dist/types/src/services/editor.d.ts +6 -0
- package/dist/types/src/type.d.ts +3 -0
- package/dist/types/src/utils/editor.d.ts +8 -4
- package/package.json +8 -8
- package/src/Editor.vue +28 -6
- package/src/components/Icon.vue +1 -1
- package/src/components/ToolButton.vue +1 -1
- package/src/fields/UISelect.vue +1 -1
- package/src/layouts/AddPageBox.vue +1 -1
- package/src/layouts/PropsPanel.vue +12 -9
- package/src/layouts/sidebar/ComponentListPanel.vue +55 -2
- package/src/layouts/sidebar/LayerMenu.vue +1 -1
- package/src/layouts/sidebar/LayerPanel.vue +1 -1
- package/src/layouts/sidebar/Sidebar.vue +4 -4
- package/src/layouts/sidebar/TabPane.vue +7 -5
- package/src/layouts/workspace/PageBar.vue +1 -1
- package/src/layouts/workspace/Stage.vue +52 -11
- package/src/layouts/workspace/ViewerMenu.vue +1 -1
- package/src/services/editor.ts +74 -17
- package/src/type.ts +3 -0
- package/src/utils/editor.ts +45 -35
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons'), require('lodash-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons', 'lodash-es', 'monaco-editor', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'
|
|
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/icons-vue'), require('lodash-es'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.iconsVue, global.lodashEs, global.monaco, global.StageCore, global.schema, global.utils, global.events, global.core, global.Gesto, global.ElementPlus, global.KeyController));
|
|
5
|
+
})(this, (function (exports, vue, serialize, iconsVue, lodashEs, monaco, StageCore, schema, utils, events, core, Gesto, elementPlus, KeyController) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
|
|
27
27
|
var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
|
|
28
28
|
var monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
|
|
29
|
+
var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
29
30
|
var Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
|
|
30
31
|
var KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
|
|
31
|
-
var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
32
32
|
|
|
33
33
|
if (typeof global === "undefined") {
|
|
34
34
|
window.global = window;
|
|
@@ -179,9 +179,9 @@
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
return {
|
|
182
|
-
Delete: vue.markRaw(
|
|
183
|
-
Pointer: vue.markRaw(
|
|
184
|
-
Close: vue.markRaw(
|
|
182
|
+
Delete: vue.markRaw(iconsVue.Delete),
|
|
183
|
+
Pointer: vue.markRaw(iconsVue.Pointer),
|
|
184
|
+
Close: vue.markRaw(iconsVue.Close),
|
|
185
185
|
val,
|
|
186
186
|
uiSelectMode,
|
|
187
187
|
toName: vue.computed(() => {
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
|
-
const _hoisted_1$
|
|
209
|
+
const _hoisted_1$d = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
|
|
210
210
|
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
211
211
|
const _component_el_button = vue.resolveComponent("el-button");
|
|
212
212
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
style: { "padding": "0" }
|
|
223
223
|
}, {
|
|
224
224
|
default: vue.withCtx(() => [
|
|
225
|
-
_hoisted_1$
|
|
225
|
+
_hoisted_1$d
|
|
226
226
|
]),
|
|
227
227
|
_: 1
|
|
228
228
|
}, 8, ["icon"])
|
|
@@ -387,12 +387,12 @@
|
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
389
|
});
|
|
390
|
-
const _hoisted_1$
|
|
390
|
+
const _hoisted_1$c = {
|
|
391
391
|
ref: "codeEditor",
|
|
392
392
|
class: "magic-code-editor"
|
|
393
393
|
};
|
|
394
394
|
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
395
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
395
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
|
|
396
396
|
}
|
|
397
397
|
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
398
398
|
|
|
@@ -768,56 +768,50 @@
|
|
|
768
768
|
const items = parent?.items || [];
|
|
769
769
|
return items.findIndex((item) => `${item.id}` === `${node.id}`);
|
|
770
770
|
};
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
return node;
|
|
779
|
-
};
|
|
780
|
-
const setTop2Middle = (node, parentNode, stage) => {
|
|
781
|
-
const style = node.style || {};
|
|
771
|
+
const getRelativeStyle = (style = {}) => ({
|
|
772
|
+
...style,
|
|
773
|
+
position: "relative",
|
|
774
|
+
top: 0,
|
|
775
|
+
left: 0
|
|
776
|
+
});
|
|
777
|
+
const getMiddleTop = (style = {}, parentNode, stage) => {
|
|
782
778
|
let height = style.height || 0;
|
|
783
779
|
if (!stage || typeof style.top !== "undefined" || !parentNode.style)
|
|
784
|
-
return style;
|
|
780
|
+
return style.top;
|
|
785
781
|
if (!utils.isNumber(height)) {
|
|
786
782
|
height = 0;
|
|
787
783
|
}
|
|
788
784
|
const { height: parentHeight } = parentNode.style;
|
|
789
785
|
if (utils.isPage(parentNode)) {
|
|
790
786
|
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
791
|
-
|
|
792
|
-
} else {
|
|
793
|
-
style.top = (parentHeight - height) / 2;
|
|
787
|
+
return (wrapperHeight - height) / 2 + scrollTop;
|
|
794
788
|
}
|
|
795
|
-
return
|
|
789
|
+
return (parentHeight - height) / 2;
|
|
796
790
|
};
|
|
797
|
-
const
|
|
791
|
+
const getInitPositionStyle = (style = {}, layout, parentNode, stage) => {
|
|
798
792
|
if (layout === Layout.ABSOLUTE) {
|
|
799
|
-
|
|
793
|
+
return {
|
|
794
|
+
...style,
|
|
800
795
|
position: "absolute",
|
|
801
|
-
|
|
796
|
+
top: getMiddleTop(style, parentNode, stage)
|
|
802
797
|
};
|
|
803
|
-
return node;
|
|
804
798
|
}
|
|
805
799
|
if (layout === Layout.RELATIVE) {
|
|
806
|
-
return
|
|
800
|
+
return getRelativeStyle(style);
|
|
807
801
|
}
|
|
808
|
-
return
|
|
802
|
+
return style;
|
|
809
803
|
};
|
|
810
804
|
const setLayout = (node, layout) => {
|
|
811
805
|
node.items?.forEach((child) => {
|
|
812
806
|
if (utils.isPop(child))
|
|
813
807
|
return;
|
|
814
|
-
|
|
815
|
-
if (
|
|
808
|
+
const style = child.style || {};
|
|
809
|
+
if (style.position === "fixed")
|
|
816
810
|
return;
|
|
817
811
|
if (layout !== Layout.RELATIVE) {
|
|
818
|
-
|
|
812
|
+
style.position = "absolute";
|
|
819
813
|
} else {
|
|
820
|
-
|
|
814
|
+
child.style = getRelativeStyle(style);
|
|
821
815
|
child.style.right = "auto";
|
|
822
816
|
child.style.bottom = "auto";
|
|
823
817
|
}
|
|
@@ -834,11 +828,10 @@
|
|
|
834
828
|
offset.left = offset.left + globalThis.parseFloat(value.style?.left || 0);
|
|
835
829
|
offset.top = offset.top + globalThis.parseFloat(value.style?.top || 0);
|
|
836
830
|
});
|
|
837
|
-
|
|
831
|
+
return {
|
|
838
832
|
...node.style || {},
|
|
839
833
|
...offset
|
|
840
834
|
};
|
|
841
|
-
return node;
|
|
842
835
|
};
|
|
843
836
|
const Fixed2Other = async (node, root, getLayout) => {
|
|
844
837
|
const path = utils.getNodePath(node.id, root.items);
|
|
@@ -853,20 +846,20 @@
|
|
|
853
846
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
854
847
|
offset.top = offset.top - globalThis.parseFloat(value.style?.top || 0);
|
|
855
848
|
});
|
|
849
|
+
const style = node.style || {};
|
|
856
850
|
const parent = path.pop();
|
|
857
851
|
if (!parent) {
|
|
858
|
-
return
|
|
852
|
+
return getRelativeStyle(style);
|
|
859
853
|
}
|
|
860
854
|
const layout = await getLayout(parent);
|
|
861
855
|
if (layout !== Layout.RELATIVE) {
|
|
862
|
-
|
|
863
|
-
...
|
|
856
|
+
return {
|
|
857
|
+
...style,
|
|
864
858
|
...offset,
|
|
865
859
|
position: "absolute"
|
|
866
860
|
};
|
|
867
|
-
return node;
|
|
868
861
|
}
|
|
869
|
-
return
|
|
862
|
+
return getRelativeStyle(style);
|
|
870
863
|
};
|
|
871
864
|
const getGuideLineFromCache = (key) => {
|
|
872
865
|
if (!key)
|
|
@@ -881,6 +874,16 @@
|
|
|
881
874
|
}
|
|
882
875
|
return [];
|
|
883
876
|
};
|
|
877
|
+
const fixNodeLeft = (config, parent, doc) => {
|
|
878
|
+
if (!doc || !config.style || !utils.isNumber(config.style.left))
|
|
879
|
+
return config.style?.left;
|
|
880
|
+
const el = doc.getElementById(`${config.id}`);
|
|
881
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
882
|
+
if (el && parentEl && el.offsetWidth + config.style?.left > parentEl.offsetWidth) {
|
|
883
|
+
return parentEl.offsetWidth - el.offsetWidth;
|
|
884
|
+
}
|
|
885
|
+
return config.style.left;
|
|
886
|
+
};
|
|
884
887
|
|
|
885
888
|
const log = (...args) => {
|
|
886
889
|
};
|
|
@@ -906,6 +909,7 @@
|
|
|
906
909
|
"paste",
|
|
907
910
|
"alignCenter",
|
|
908
911
|
"moveLayer",
|
|
912
|
+
"moveToContainer",
|
|
909
913
|
"move",
|
|
910
914
|
"undo",
|
|
911
915
|
"redo",
|
|
@@ -1045,13 +1049,22 @@
|
|
|
1045
1049
|
if (!parentNode)
|
|
1046
1050
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1047
1051
|
const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
|
|
1048
|
-
const newNode =
|
|
1052
|
+
const newNode = { ...vue.toRaw(await propsService.getPropsValue(type, config2)) };
|
|
1053
|
+
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, this.get("stage"));
|
|
1049
1054
|
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
1050
1055
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1051
1056
|
}
|
|
1052
1057
|
parentNode?.items?.push(newNode);
|
|
1053
1058
|
const stage = this.get("stage");
|
|
1054
|
-
|
|
1059
|
+
const root = this.get("root");
|
|
1060
|
+
await stage?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(root) });
|
|
1061
|
+
if (layout === Layout.ABSOLUTE) {
|
|
1062
|
+
const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
|
|
1063
|
+
if (typeof fixedLeft !== "undefined") {
|
|
1064
|
+
newNode.style.left = fixedLeft;
|
|
1065
|
+
await stage?.update({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(root) });
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1055
1068
|
await this.select(newNode);
|
|
1056
1069
|
this.addModifiedNodeId(newNode.id);
|
|
1057
1070
|
if (!isPage2) {
|
|
@@ -1078,7 +1091,7 @@
|
|
|
1078
1091
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1079
1092
|
parent.items?.splice(index, 1);
|
|
1080
1093
|
const stage = this.get("stage");
|
|
1081
|
-
stage?.remove({ id: node.id, root: this.get("root") });
|
|
1094
|
+
stage?.remove({ id: node.id, root: lodashEs.cloneDeep(this.get("root")) });
|
|
1082
1095
|
if (node.type === schema.NodeType.PAGE) {
|
|
1083
1096
|
this.state.pageLength -= 1;
|
|
1084
1097
|
if (root.items[0]) {
|
|
@@ -1139,7 +1152,7 @@
|
|
|
1139
1152
|
if (`${newConfig.id}` === `${this.get("node").id}`) {
|
|
1140
1153
|
this.set("node", newConfig);
|
|
1141
1154
|
}
|
|
1142
|
-
this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: this.get("root") });
|
|
1155
|
+
this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: lodashEs.cloneDeep(this.get("root")) });
|
|
1143
1156
|
if (newConfig.type === schema.NodeType.PAGE) {
|
|
1144
1157
|
this.set("page", newConfig);
|
|
1145
1158
|
}
|
|
@@ -1158,7 +1171,7 @@
|
|
|
1158
1171
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1159
1172
|
await this.update(parent);
|
|
1160
1173
|
await this.select(node);
|
|
1161
|
-
this.get("stage")?.update({ config: lodashEs.cloneDeep(node), root: this.get("root") });
|
|
1174
|
+
this.get("stage")?.update({ config: lodashEs.cloneDeep(node), root: lodashEs.cloneDeep(this.get("root")) });
|
|
1162
1175
|
this.addModifiedNodeId(parent.id);
|
|
1163
1176
|
this.pushHistoryState();
|
|
1164
1177
|
}
|
|
@@ -1210,7 +1223,10 @@
|
|
|
1210
1223
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1211
1224
|
}
|
|
1212
1225
|
await this.update(node);
|
|
1213
|
-
this.get("stage")?.update({
|
|
1226
|
+
this.get("stage")?.update({
|
|
1227
|
+
config: lodashEs.cloneDeep(vue.toRaw(node)),
|
|
1228
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1229
|
+
});
|
|
1214
1230
|
this.addModifiedNodeId(config2.id);
|
|
1215
1231
|
this.pushHistoryState();
|
|
1216
1232
|
return config2;
|
|
@@ -1227,7 +1243,37 @@
|
|
|
1227
1243
|
} else {
|
|
1228
1244
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1229
1245
|
}
|
|
1230
|
-
this.get("stage")?.update({
|
|
1246
|
+
this.get("stage")?.update({
|
|
1247
|
+
config: lodashEs.cloneDeep(vue.toRaw(parent)),
|
|
1248
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
async moveToContainer(config2, targetId) {
|
|
1252
|
+
const { node, parent } = this.getNodeInfo(config2.id, false);
|
|
1253
|
+
const target = this.getNodeById(targetId, false);
|
|
1254
|
+
const stage = this.get("stage");
|
|
1255
|
+
if (node && parent && stage) {
|
|
1256
|
+
const root = lodashEs.cloneDeep(this.get("root"));
|
|
1257
|
+
const index = getNodeIndex(node, parent);
|
|
1258
|
+
parent.items?.splice(index, 1);
|
|
1259
|
+
await stage.remove({ id: node.id, root });
|
|
1260
|
+
const layout = await this.getLayout(target);
|
|
1261
|
+
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config2, (objValue, srcValue) => {
|
|
1262
|
+
if (Array.isArray(srcValue)) {
|
|
1263
|
+
return srcValue;
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout, target, stage);
|
|
1267
|
+
target.items.push(newConfig);
|
|
1268
|
+
await stage.select(targetId);
|
|
1269
|
+
await stage.update({ config: lodashEs.cloneDeep(target), root });
|
|
1270
|
+
await this.select(newConfig);
|
|
1271
|
+
stage.select(newConfig.id);
|
|
1272
|
+
this.addModifiedNodeId(target.id);
|
|
1273
|
+
this.addModifiedNodeId(parent.id);
|
|
1274
|
+
this.pushHistoryState();
|
|
1275
|
+
return newConfig;
|
|
1276
|
+
}
|
|
1231
1277
|
}
|
|
1232
1278
|
async undo() {
|
|
1233
1279
|
const value = historyService.undo();
|
|
@@ -1299,12 +1345,12 @@
|
|
|
1299
1345
|
}, 0);
|
|
1300
1346
|
}
|
|
1301
1347
|
async toggleFixedPosition(dist, src, root) {
|
|
1302
|
-
|
|
1348
|
+
const newConfig = lodashEs.cloneDeep(dist);
|
|
1303
1349
|
if (!utils.isPop(src) && newConfig.style?.position) {
|
|
1304
1350
|
if (isFixed(newConfig) && !isFixed(src)) {
|
|
1305
|
-
newConfig = change2Fixed(newConfig, root);
|
|
1351
|
+
newConfig.style = change2Fixed(newConfig, root);
|
|
1306
1352
|
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
1307
|
-
newConfig = await Fixed2Other(newConfig, root, this.getLayout);
|
|
1353
|
+
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
1308
1354
|
}
|
|
1309
1355
|
}
|
|
1310
1356
|
return newConfig;
|
|
@@ -1597,7 +1643,7 @@
|
|
|
1597
1643
|
};
|
|
1598
1644
|
|
|
1599
1645
|
const _sfc_main$i = vue.defineComponent({
|
|
1600
|
-
components: { Plus:
|
|
1646
|
+
components: { Plus: iconsVue.Plus },
|
|
1601
1647
|
setup() {
|
|
1602
1648
|
const services = vue.inject("services");
|
|
1603
1649
|
return {
|
|
@@ -1613,13 +1659,13 @@
|
|
|
1613
1659
|
};
|
|
1614
1660
|
}
|
|
1615
1661
|
});
|
|
1616
|
-
const _hoisted_1$
|
|
1662
|
+
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1617
1663
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1618
1664
|
const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1619
1665
|
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1620
1666
|
const _component_plus = vue.resolveComponent("plus");
|
|
1621
1667
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1622
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1668
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
1623
1669
|
vue.createElementVNode("div", _hoisted_2$4, [
|
|
1624
1670
|
vue.createElementVNode("div", {
|
|
1625
1671
|
class: "m-editor-empty-button",
|
|
@@ -1682,12 +1728,12 @@
|
|
|
1682
1728
|
};
|
|
1683
1729
|
}
|
|
1684
1730
|
});
|
|
1685
|
-
const _hoisted_1$
|
|
1731
|
+
const _hoisted_1$a = {
|
|
1686
1732
|
ref: "target",
|
|
1687
1733
|
class: "m-editor-resizer"
|
|
1688
1734
|
};
|
|
1689
1735
|
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1690
|
-
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$
|
|
1736
|
+
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
|
|
1691
1737
|
vue.renderSlot(_ctx.$slots, "default")
|
|
1692
1738
|
], 512);
|
|
1693
1739
|
}
|
|
@@ -1722,7 +1768,7 @@
|
|
|
1722
1768
|
};
|
|
1723
1769
|
}
|
|
1724
1770
|
});
|
|
1725
|
-
const _hoisted_1$
|
|
1771
|
+
const _hoisted_1$9 = { class: "m-editor" };
|
|
1726
1772
|
const _hoisted_2$3 = {
|
|
1727
1773
|
key: 1,
|
|
1728
1774
|
class: "m-editor-content"
|
|
@@ -1732,7 +1778,7 @@
|
|
|
1732
1778
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
1733
1779
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
1734
1780
|
const _component_add_page_box = vue.resolveComponent("add-page-box");
|
|
1735
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1781
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
|
|
1736
1782
|
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
1737
1783
|
_ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
1738
1784
|
key: 0,
|
|
@@ -1777,7 +1823,7 @@
|
|
|
1777
1823
|
|
|
1778
1824
|
const _sfc_main$f = vue.defineComponent({
|
|
1779
1825
|
name: "m-icon",
|
|
1780
|
-
components: { Edit:
|
|
1826
|
+
components: { Edit: iconsVue.Edit },
|
|
1781
1827
|
props: {
|
|
1782
1828
|
icon: {
|
|
1783
1829
|
type: [String, Object]
|
|
@@ -1789,7 +1835,7 @@
|
|
|
1789
1835
|
};
|
|
1790
1836
|
}
|
|
1791
1837
|
});
|
|
1792
|
-
const _hoisted_1$
|
|
1838
|
+
const _hoisted_1$8 = ["src"];
|
|
1793
1839
|
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1794
1840
|
const _component_edit = vue.resolveComponent("edit");
|
|
1795
1841
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
@@ -1801,7 +1847,7 @@
|
|
|
1801
1847
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
|
|
1802
1848
|
key: 1,
|
|
1803
1849
|
src: _ctx.icon
|
|
1804
|
-
}, null, 8, _hoisted_1$
|
|
1850
|
+
}, null, 8, _hoisted_1$8)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
1805
1851
|
key: 2,
|
|
1806
1852
|
class: vue.normalizeClass(_ctx.icon)
|
|
1807
1853
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -1814,7 +1860,7 @@
|
|
|
1814
1860
|
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
1815
1861
|
|
|
1816
1862
|
const _sfc_main$e = vue.defineComponent({
|
|
1817
|
-
components: { MIcon, ArrowDown:
|
|
1863
|
+
components: { MIcon, ArrowDown: iconsVue.ArrowDown },
|
|
1818
1864
|
props: {
|
|
1819
1865
|
data: {
|
|
1820
1866
|
type: [Object, String],
|
|
@@ -1853,7 +1899,7 @@
|
|
|
1853
1899
|
case "delete":
|
|
1854
1900
|
return {
|
|
1855
1901
|
type: "button",
|
|
1856
|
-
icon: vue.markRaw(
|
|
1902
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
1857
1903
|
tooltip: "\u522A\u9664",
|
|
1858
1904
|
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
1859
1905
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -1861,7 +1907,7 @@
|
|
|
1861
1907
|
case "undo":
|
|
1862
1908
|
return {
|
|
1863
1909
|
type: "button",
|
|
1864
|
-
icon: vue.markRaw(
|
|
1910
|
+
icon: vue.markRaw(iconsVue.Back),
|
|
1865
1911
|
tooltip: "\u540E\u9000",
|
|
1866
1912
|
disabled: () => !services?.historyService.state.canUndo,
|
|
1867
1913
|
handler: () => services?.editorService.undo()
|
|
@@ -1869,7 +1915,7 @@
|
|
|
1869
1915
|
case "redo":
|
|
1870
1916
|
return {
|
|
1871
1917
|
type: "button",
|
|
1872
|
-
icon: vue.markRaw(
|
|
1918
|
+
icon: vue.markRaw(iconsVue.Right),
|
|
1873
1919
|
tooltip: "\u524D\u8FDB",
|
|
1874
1920
|
disabled: () => !services?.historyService.state.canRedo,
|
|
1875
1921
|
handler: () => services?.editorService.redo()
|
|
@@ -1877,28 +1923,28 @@
|
|
|
1877
1923
|
case "zoom-in":
|
|
1878
1924
|
return {
|
|
1879
1925
|
type: "button",
|
|
1880
|
-
icon: vue.markRaw(
|
|
1926
|
+
icon: vue.markRaw(iconsVue.ZoomIn),
|
|
1881
1927
|
tooltip: "\u653E\u5927",
|
|
1882
1928
|
handler: zoomInHandler
|
|
1883
1929
|
};
|
|
1884
1930
|
case "zoom-out":
|
|
1885
1931
|
return {
|
|
1886
1932
|
type: "button",
|
|
1887
|
-
icon: vue.markRaw(
|
|
1933
|
+
icon: vue.markRaw(iconsVue.ZoomOut),
|
|
1888
1934
|
tooltip: "\u7E2E\u5C0F",
|
|
1889
1935
|
handler: zoomOutHandler
|
|
1890
1936
|
};
|
|
1891
1937
|
case "rule":
|
|
1892
1938
|
return {
|
|
1893
1939
|
type: "button",
|
|
1894
|
-
icon: vue.markRaw(
|
|
1940
|
+
icon: vue.markRaw(iconsVue.ScaleToOriginal),
|
|
1895
1941
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
1896
1942
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
1897
1943
|
};
|
|
1898
1944
|
case "guides":
|
|
1899
1945
|
return {
|
|
1900
1946
|
type: "button",
|
|
1901
|
-
icon: vue.markRaw(
|
|
1947
|
+
icon: vue.markRaw(iconsVue.Grid),
|
|
1902
1948
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
1903
1949
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
1904
1950
|
};
|
|
@@ -1927,8 +1973,8 @@
|
|
|
1927
1973
|
}
|
|
1928
1974
|
};
|
|
1929
1975
|
return {
|
|
1930
|
-
ZoomIn: vue.markRaw(
|
|
1931
|
-
ZoomOut: vue.markRaw(
|
|
1976
|
+
ZoomIn: vue.markRaw(iconsVue.ZoomIn),
|
|
1977
|
+
ZoomOut: vue.markRaw(iconsVue.ZoomOut),
|
|
1932
1978
|
item,
|
|
1933
1979
|
zoom,
|
|
1934
1980
|
disabled,
|
|
@@ -1973,7 +2019,7 @@
|
|
|
1973
2019
|
};
|
|
1974
2020
|
}
|
|
1975
2021
|
});
|
|
1976
|
-
const _hoisted_1$
|
|
2022
|
+
const _hoisted_1$7 = {
|
|
1977
2023
|
key: 1,
|
|
1978
2024
|
class: "menu-item-text"
|
|
1979
2025
|
};
|
|
@@ -2003,7 +2049,7 @@
|
|
|
2003
2049
|
_ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2004
2050
|
key: 0,
|
|
2005
2051
|
direction: _ctx.item.direction || "vertical"
|
|
2006
|
-
}, null, 8, ["direction"])) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2052
|
+
}, null, 8, ["direction"])) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
2007
2053
|
vue.createVNode(_component_tool_button, {
|
|
2008
2054
|
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2009
2055
|
"event-type": _ctx.eventType
|
|
@@ -2184,17 +2230,21 @@
|
|
|
2184
2230
|
};
|
|
2185
2231
|
}
|
|
2186
2232
|
});
|
|
2233
|
+
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2187
2234
|
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2188
2235
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
2189
|
-
return vue.openBlock(), vue.
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2236
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
2237
|
+
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2238
|
+
vue.createVNode(_component_m_form, {
|
|
2239
|
+
class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
2240
|
+
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
2241
|
+
ref: "configForm",
|
|
2242
|
+
size: _ctx.propsPanelSize,
|
|
2243
|
+
"init-values": _ctx.values,
|
|
2244
|
+
config: _ctx.curFormConfig,
|
|
2245
|
+
onChange: _ctx.submit
|
|
2246
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2247
|
+
]);
|
|
2198
2248
|
}
|
|
2199
2249
|
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
2200
2250
|
|
|
@@ -2204,11 +2254,16 @@
|
|
|
2204
2254
|
setup() {
|
|
2205
2255
|
const searchText = vue.ref("");
|
|
2206
2256
|
const services = vue.inject("services");
|
|
2257
|
+
const stageOptions = vue.inject("stageOptions");
|
|
2258
|
+
const stage = vue.computed(() => services?.editorService.get("stage"));
|
|
2207
2259
|
const list = vue.computed(() => services?.componentListService.getList().map((group) => ({
|
|
2208
2260
|
...group,
|
|
2209
2261
|
items: group.items.filter((item) => item.text.includes(searchText.value))
|
|
2210
2262
|
})));
|
|
2211
2263
|
const collapseValue = vue.computed(() => Array(list.value?.length).fill(1).map((x, i) => i));
|
|
2264
|
+
let timeout;
|
|
2265
|
+
let clientX;
|
|
2266
|
+
let clientY;
|
|
2212
2267
|
return {
|
|
2213
2268
|
searchText,
|
|
2214
2269
|
collapseValue,
|
|
@@ -2229,6 +2284,43 @@
|
|
|
2229
2284
|
...data
|
|
2230
2285
|
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
2231
2286
|
}
|
|
2287
|
+
},
|
|
2288
|
+
dragendHandler() {
|
|
2289
|
+
if (timeout) {
|
|
2290
|
+
globalThis.clearTimeout(timeout);
|
|
2291
|
+
timeout = void 0;
|
|
2292
|
+
}
|
|
2293
|
+
const doc = stage.value?.renderer.contentWindow?.document;
|
|
2294
|
+
if (doc && stageOptions) {
|
|
2295
|
+
utils.removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
2296
|
+
}
|
|
2297
|
+
clientX = 0;
|
|
2298
|
+
clientY = 0;
|
|
2299
|
+
},
|
|
2300
|
+
dragHandler(e) {
|
|
2301
|
+
if (e.clientX !== clientX || e.clientY !== clientY) {
|
|
2302
|
+
clientX = e.clientX;
|
|
2303
|
+
clientY = e.clientY;
|
|
2304
|
+
if (timeout) {
|
|
2305
|
+
globalThis.clearTimeout(timeout);
|
|
2306
|
+
timeout = void 0;
|
|
2307
|
+
}
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
if (timeout)
|
|
2311
|
+
return;
|
|
2312
|
+
timeout = globalThis.setTimeout(async () => {
|
|
2313
|
+
if (!stageOptions || !stage.value)
|
|
2314
|
+
return;
|
|
2315
|
+
const doc = stage.value.renderer.contentWindow?.document;
|
|
2316
|
+
const els = stage.value.getElementsFromPoint(e);
|
|
2317
|
+
for (const el of els) {
|
|
2318
|
+
if (doc && !el.id.startsWith(StageCore.GHOST_EL_ID_PREFIX) && await stageOptions.isContainer(el)) {
|
|
2319
|
+
utils.addClassName(el, doc, stageOptions?.containerHighlightClassName);
|
|
2320
|
+
break;
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
}, stageOptions?.containerHighlightDuration);
|
|
2232
2324
|
}
|
|
2233
2325
|
};
|
|
2234
2326
|
}
|
|
@@ -2244,7 +2336,7 @@
|
|
|
2244
2336
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2245
2337
|
return vue.openBlock(), vue.createBlock(_component_el_scrollbar, null, {
|
|
2246
2338
|
default: vue.withCtx(() => [
|
|
2247
|
-
vue.renderSlot(_ctx.$slots, "component-list-panel"),
|
|
2339
|
+
vue.renderSlot(_ctx.$slots, "component-list-panel-header"),
|
|
2248
2340
|
vue.createVNode(_component_el_collapse, {
|
|
2249
2341
|
class: "ui-component-panel",
|
|
2250
2342
|
"model-value": _ctx.collapseValue
|
|
@@ -2276,7 +2368,9 @@
|
|
|
2276
2368
|
draggable: "true",
|
|
2277
2369
|
key: item.type,
|
|
2278
2370
|
onClick: ($event) => _ctx.appendComponent(item),
|
|
2279
|
-
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
2371
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event),
|
|
2372
|
+
onDragend: _cache[1] || (_cache[1] = (...args) => _ctx.dragendHandler && _ctx.dragendHandler(...args)),
|
|
2373
|
+
onDrag: _cache[2] || (_cache[2] = (...args) => _ctx.dragHandler && _ctx.dragHandler(...args))
|
|
2280
2374
|
}, [
|
|
2281
2375
|
vue.createVNode(_component_m_icon, {
|
|
2282
2376
|
icon: item.icon
|
|
@@ -2457,7 +2551,7 @@
|
|
|
2457
2551
|
{
|
|
2458
2552
|
text: "\u6807\u7B7E\u9875",
|
|
2459
2553
|
type: "button",
|
|
2460
|
-
icon:
|
|
2554
|
+
icon: iconsVue.Files,
|
|
2461
2555
|
handler: () => {
|
|
2462
2556
|
services?.editorService.add({
|
|
2463
2557
|
type: "tab-pane"
|
|
@@ -2482,14 +2576,14 @@
|
|
|
2482
2576
|
{
|
|
2483
2577
|
type: "button",
|
|
2484
2578
|
text: "\u65B0\u589E",
|
|
2485
|
-
icon: vue.markRaw(
|
|
2579
|
+
icon: vue.markRaw(iconsVue.Plus),
|
|
2486
2580
|
display: () => node.value?.items,
|
|
2487
2581
|
items: getSubMenuData.value
|
|
2488
2582
|
},
|
|
2489
2583
|
{
|
|
2490
2584
|
type: "button",
|
|
2491
2585
|
text: "\u590D\u5236",
|
|
2492
|
-
icon: vue.markRaw(
|
|
2586
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
2493
2587
|
display: () => !isRoot.value,
|
|
2494
2588
|
handler: () => {
|
|
2495
2589
|
node.value && services?.editorService.copy(node.value);
|
|
@@ -2498,7 +2592,7 @@
|
|
|
2498
2592
|
{
|
|
2499
2593
|
type: "button",
|
|
2500
2594
|
text: "\u5220\u9664",
|
|
2501
|
-
icon: vue.markRaw(
|
|
2595
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
2502
2596
|
display: () => !isRoot.value && !isPage.value,
|
|
2503
2597
|
handler: () => {
|
|
2504
2598
|
node.value && services?.editorService.remove(node.value);
|
|
@@ -2667,7 +2761,7 @@
|
|
|
2667
2761
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2668
2762
|
return vue.openBlock(), vue.createBlock(_component_el_scrollbar, { class: "magic-editor-layer-panel" }, {
|
|
2669
2763
|
default: vue.withCtx(() => [
|
|
2670
|
-
vue.renderSlot(_ctx.$slots, "layer-panel"),
|
|
2764
|
+
vue.renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
2671
2765
|
vue.createVNode(_component_el_input, {
|
|
2672
2766
|
class: "filterInput",
|
|
2673
2767
|
size: "small",
|
|
@@ -2741,7 +2835,7 @@
|
|
|
2741
2835
|
case "component-list":
|
|
2742
2836
|
return {
|
|
2743
2837
|
type: "component",
|
|
2744
|
-
icon:
|
|
2838
|
+
icon: iconsVue.Coin,
|
|
2745
2839
|
text: "\u7EC4\u4EF6",
|
|
2746
2840
|
component: ComponentListPanel,
|
|
2747
2841
|
slots: {}
|
|
@@ -2749,7 +2843,7 @@
|
|
|
2749
2843
|
case "layer":
|
|
2750
2844
|
return {
|
|
2751
2845
|
type: "component",
|
|
2752
|
-
icon:
|
|
2846
|
+
icon: iconsVue.Files,
|
|
2753
2847
|
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
2754
2848
|
component: LayerPanel,
|
|
2755
2849
|
slots: {}
|
|
@@ -2785,16 +2879,16 @@
|
|
|
2785
2879
|
]),
|
|
2786
2880
|
default: vue.withCtx(() => [
|
|
2787
2881
|
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.component), vue.mergeProps(_ctx.config.props || {}, vue.toHandlers(_ctx.config?.listeners || {})), vue.createSlots({ _: 2 }, [
|
|
2788
|
-
_ctx.data === "
|
|
2789
|
-
name: "
|
|
2882
|
+
_ctx.data === "component-list" || _ctx.config.slots?.componentListPanelHeader ? {
|
|
2883
|
+
name: "component-list-panel-header",
|
|
2790
2884
|
fn: vue.withCtx(() => [
|
|
2791
|
-
vue.renderSlot(_ctx.$slots, "
|
|
2885
|
+
_ctx.data === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : _ctx.config.slots?.componentListPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.componentListPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
|
|
2792
2886
|
])
|
|
2793
2887
|
} : void 0,
|
|
2794
|
-
_ctx.data === "
|
|
2795
|
-
name: "
|
|
2888
|
+
_ctx.data === "layer" || _ctx.config.slots?.layerPanelHeader ? {
|
|
2889
|
+
name: "layer-panel-header",
|
|
2796
2890
|
fn: vue.withCtx(() => [
|
|
2797
|
-
vue.renderSlot(_ctx.$slots, "
|
|
2891
|
+
_ctx.data === "layer" ? vue.renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : _ctx.config.slots?.layerPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.layerPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
|
|
2798
2892
|
])
|
|
2799
2893
|
} : void 0,
|
|
2800
2894
|
_ctx.config.slots?.layerNodeContent ? {
|
|
@@ -2850,15 +2944,15 @@
|
|
|
2850
2944
|
data: item
|
|
2851
2945
|
}, vue.createSlots({ _: 2 }, [
|
|
2852
2946
|
item === "layer" ? {
|
|
2853
|
-
name: "layer-panel",
|
|
2947
|
+
name: "layer-panel-header",
|
|
2854
2948
|
fn: vue.withCtx(() => [
|
|
2855
|
-
vue.renderSlot(_ctx.$slots, "layer-panel")
|
|
2949
|
+
vue.renderSlot(_ctx.$slots, "layer-panel-header")
|
|
2856
2950
|
])
|
|
2857
2951
|
} : void 0,
|
|
2858
2952
|
item === "component-list" ? {
|
|
2859
|
-
name: "component-list-panel",
|
|
2953
|
+
name: "component-list-panel-header",
|
|
2860
2954
|
fn: vue.withCtx(() => [
|
|
2861
|
-
vue.renderSlot(_ctx.$slots, "component-list-panel")
|
|
2955
|
+
vue.renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
2862
2956
|
])
|
|
2863
2957
|
} : void 0
|
|
2864
2958
|
]), 1032, ["data"]);
|
|
@@ -2934,14 +3028,14 @@
|
|
|
2934
3028
|
};
|
|
2935
3029
|
};
|
|
2936
3030
|
const _sfc_main$5 = vue.defineComponent({
|
|
2937
|
-
components: { ArrowLeftBold:
|
|
3031
|
+
components: { ArrowLeftBold: iconsVue.ArrowLeftBold, ArrowRightBold: iconsVue.ArrowRightBold, CaretBottom: iconsVue.CaretBottom, Plus: iconsVue.Plus, ToolButton },
|
|
2938
3032
|
setup() {
|
|
2939
3033
|
const services = vue.inject("services");
|
|
2940
3034
|
const editorService = services?.editorService;
|
|
2941
3035
|
const root = vue.computed(() => editorService?.get("root"));
|
|
2942
3036
|
return {
|
|
2943
|
-
Delete: vue.markRaw(
|
|
2944
|
-
DocumentCopy: vue.markRaw(
|
|
3037
|
+
Delete: vue.markRaw(iconsVue.Delete),
|
|
3038
|
+
DocumentCopy: vue.markRaw(iconsVue.DocumentCopy),
|
|
2945
3039
|
...useScroll(root),
|
|
2946
3040
|
root,
|
|
2947
3041
|
page: vue.computed(() => editorService?.get("page")),
|
|
@@ -3346,7 +3440,7 @@
|
|
|
3346
3440
|
{
|
|
3347
3441
|
type: "button",
|
|
3348
3442
|
text: "\u590D\u5236",
|
|
3349
|
-
icon: vue.markRaw(
|
|
3443
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3350
3444
|
handler: () => {
|
|
3351
3445
|
node.value && editorService?.copy(node.value);
|
|
3352
3446
|
canPaste.value = true;
|
|
@@ -3379,7 +3473,7 @@
|
|
|
3379
3473
|
{
|
|
3380
3474
|
type: "button",
|
|
3381
3475
|
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3382
|
-
icon: vue.markRaw(
|
|
3476
|
+
icon: vue.markRaw(iconsVue.Top),
|
|
3383
3477
|
display: () => !isPage.value,
|
|
3384
3478
|
handler: () => {
|
|
3385
3479
|
editorService?.moveLayer(1);
|
|
@@ -3388,7 +3482,7 @@
|
|
|
3388
3482
|
{
|
|
3389
3483
|
type: "button",
|
|
3390
3484
|
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3391
|
-
icon: vue.markRaw(
|
|
3485
|
+
icon: vue.markRaw(iconsVue.Bottom),
|
|
3392
3486
|
display: () => !isPage.value,
|
|
3393
3487
|
handler: () => {
|
|
3394
3488
|
editorService?.moveLayer(-1);
|
|
@@ -3418,7 +3512,7 @@
|
|
|
3418
3512
|
{
|
|
3419
3513
|
type: "button",
|
|
3420
3514
|
text: "\u5220\u9664",
|
|
3421
|
-
icon:
|
|
3515
|
+
icon: iconsVue.Delete,
|
|
3422
3516
|
display: () => !isPage.value,
|
|
3423
3517
|
handler: () => {
|
|
3424
3518
|
node.value && editorService?.remove(node.value);
|
|
@@ -3485,6 +3579,9 @@
|
|
|
3485
3579
|
runtimeUrl: stageOptions.runtimeUrl,
|
|
3486
3580
|
zoom: zoom.value,
|
|
3487
3581
|
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3582
|
+
isContainer: stageOptions.isContainer,
|
|
3583
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3584
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3488
3585
|
canSelect: (el, event, stop) => {
|
|
3489
3586
|
const elCanSelect = stageOptions.canSelect(el);
|
|
3490
3587
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3509,6 +3606,10 @@
|
|
|
3509
3606
|
services?.editorService.highlight(el.id);
|
|
3510
3607
|
});
|
|
3511
3608
|
stage?.on("update", (ev) => {
|
|
3609
|
+
if (ev.parentEl) {
|
|
3610
|
+
services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3512
3613
|
services?.editorService.update({ id: ev.el.id, style: ev.style });
|
|
3513
3614
|
});
|
|
3514
3615
|
stage?.on("sort", (ev) => {
|
|
@@ -3580,20 +3681,38 @@
|
|
|
3580
3681
|
},
|
|
3581
3682
|
async dropHandler(e) {
|
|
3582
3683
|
e.preventDefault();
|
|
3583
|
-
|
|
3684
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3685
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3686
|
+
let parent = page.value;
|
|
3687
|
+
if (parentEl) {
|
|
3688
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3689
|
+
}
|
|
3690
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3584
3691
|
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3585
|
-
const layout = await services?.editorService.getLayout(
|
|
3692
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3586
3693
|
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3587
3694
|
const { scrollTop, scrollLeft } = stage.mask;
|
|
3695
|
+
const { style = {} } = config;
|
|
3696
|
+
let top = 0;
|
|
3697
|
+
let left = 0;
|
|
3698
|
+
let position = "relative";
|
|
3588
3699
|
if (layout === Layout.ABSOLUTE) {
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
left:
|
|
3594
|
-
|
|
3700
|
+
position = "absolute";
|
|
3701
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3702
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3703
|
+
if (parentEl && doc) {
|
|
3704
|
+
const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
|
|
3705
|
+
left = left - StageCore.calcValueByFontsize(doc, parentLeft);
|
|
3706
|
+
top = top - StageCore.calcValueByFontsize(doc, parentTop);
|
|
3707
|
+
}
|
|
3595
3708
|
}
|
|
3596
|
-
|
|
3709
|
+
config.style = {
|
|
3710
|
+
...style,
|
|
3711
|
+
position,
|
|
3712
|
+
top,
|
|
3713
|
+
left
|
|
3714
|
+
};
|
|
3715
|
+
services?.editorService.add(config, parent);
|
|
3597
3716
|
}
|
|
3598
3717
|
}
|
|
3599
3718
|
};
|
|
@@ -3954,6 +4073,18 @@
|
|
|
3954
4073
|
type: Function,
|
|
3955
4074
|
default: (el) => Boolean(el.id)
|
|
3956
4075
|
},
|
|
4076
|
+
isContainer: {
|
|
4077
|
+
type: Function,
|
|
4078
|
+
default: (el) => el.classList.contains("magic-ui-container")
|
|
4079
|
+
},
|
|
4080
|
+
containerHighlightClassName: {
|
|
4081
|
+
type: String,
|
|
4082
|
+
default: StageCore.CONTAINER_HIGHLIGHT_CLASS
|
|
4083
|
+
},
|
|
4084
|
+
containerHighlightDuration: {
|
|
4085
|
+
type: Number,
|
|
4086
|
+
default: 800
|
|
4087
|
+
},
|
|
3957
4088
|
stageRect: {
|
|
3958
4089
|
type: [String, Object]
|
|
3959
4090
|
},
|
|
@@ -4020,7 +4151,10 @@
|
|
|
4020
4151
|
render: props.render,
|
|
4021
4152
|
moveableOptions: props.moveableOptions,
|
|
4022
4153
|
canSelect: props.canSelect,
|
|
4023
|
-
updateDragEl: props.updateDragEl
|
|
4154
|
+
updateDragEl: props.updateDragEl,
|
|
4155
|
+
isContainer: props.isContainer,
|
|
4156
|
+
containerHighlightClassName: props.containerHighlightClassName,
|
|
4157
|
+
containerHighlightDuration: props.containerHighlightDuration
|
|
4024
4158
|
}));
|
|
4025
4159
|
return services;
|
|
4026
4160
|
}
|
|
@@ -4040,11 +4174,11 @@
|
|
|
4040
4174
|
sidebar: vue.withCtx(() => [
|
|
4041
4175
|
vue.renderSlot(_ctx.$slots, "sidebar", { editorService: _ctx.editorService }, () => [
|
|
4042
4176
|
vue.createVNode(_component_sidebar, { data: _ctx.sidebar }, {
|
|
4043
|
-
"layer-panel": vue.withCtx(() => [
|
|
4044
|
-
vue.renderSlot(_ctx.$slots, "layer-panel")
|
|
4177
|
+
"layer-panel-header": vue.withCtx(() => [
|
|
4178
|
+
vue.renderSlot(_ctx.$slots, "layer-panel-header")
|
|
4045
4179
|
]),
|
|
4046
|
-
"component-list-panel": vue.withCtx(() => [
|
|
4047
|
-
vue.renderSlot(_ctx.$slots, "component-list-panel")
|
|
4180
|
+
"component-list-panel-header": vue.withCtx(() => [
|
|
4181
|
+
vue.renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
4048
4182
|
]),
|
|
4049
4183
|
_: 3
|
|
4050
4184
|
}, 8, ["data"])
|
|
@@ -4071,7 +4205,12 @@
|
|
|
4071
4205
|
vue.createVNode(_component_props_panel, {
|
|
4072
4206
|
ref: "propsPanel",
|
|
4073
4207
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
4074
|
-
},
|
|
4208
|
+
}, {
|
|
4209
|
+
"props-panel-header": vue.withCtx(() => [
|
|
4210
|
+
vue.renderSlot(_ctx.$slots, "props-panel-header")
|
|
4211
|
+
]),
|
|
4212
|
+
_: 3
|
|
4213
|
+
}, 512)
|
|
4075
4214
|
])
|
|
4076
4215
|
]),
|
|
4077
4216
|
empty: vue.withCtx(() => [
|
|
@@ -4119,23 +4258,24 @@
|
|
|
4119
4258
|
exports.error = error;
|
|
4120
4259
|
exports.eventsService = eventsService;
|
|
4121
4260
|
exports.fillConfig = fillConfig;
|
|
4261
|
+
exports.fixNodeLeft = fixNodeLeft;
|
|
4122
4262
|
exports.generatePageName = generatePageName;
|
|
4123
4263
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
4124
4264
|
exports.getConfig = getConfig;
|
|
4125
4265
|
exports.getDefaultPropsValue = getDefaultPropsValue;
|
|
4126
4266
|
exports.getGuideLineFromCache = getGuideLineFromCache;
|
|
4267
|
+
exports.getInitPositionStyle = getInitPositionStyle;
|
|
4127
4268
|
exports.getNodeIndex = getNodeIndex;
|
|
4128
4269
|
exports.getPageList = getPageList;
|
|
4129
4270
|
exports.getPageNameList = getPageNameList;
|
|
4271
|
+
exports.getRelativeStyle = getRelativeStyle;
|
|
4130
4272
|
exports.historyService = historyService;
|
|
4131
4273
|
exports.info = info;
|
|
4132
|
-
exports.initPosition = initPosition;
|
|
4133
4274
|
exports.isFixed = isFixed;
|
|
4134
4275
|
exports.log = log;
|
|
4135
4276
|
exports.propsService = propsService;
|
|
4136
4277
|
exports.setConfig = setConfig;
|
|
4137
4278
|
exports.setLayout = setLayout;
|
|
4138
|
-
exports.toRelative = toRelative;
|
|
4139
4279
|
exports.uiService = uiService;
|
|
4140
4280
|
exports.warn = warn;
|
|
4141
4281
|
|