@tmagic/editor 1.0.0-beta.4 → 1.0.0-beta.7
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 +4 -3
- package/dist/tmagic-editor.es.js +26 -32
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +24 -31
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/layouts/NavMenu.vue.d.ts +2 -1
- package/dist/types/src/utils/editor.d.ts +0 -1
- package/package.json +6 -6
- package/src/components/ScrollViewer.vue +1 -0
- package/src/layouts/NavMenu.vue +7 -3
- package/src/layouts/PropsPanel.vue +5 -10
- package/src/services/editor.ts +10 -3
- package/src/theme/nav-menu.scss +3 -3
- package/src/theme/stage.scss +1 -0
- package/src/utils/editor.ts +1 -20
- package/src/utils/scroll-viewer.ts +7 -4
package/dist/style.css
CHANGED
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
z-index: 1;
|
|
29
29
|
align-items: center;
|
|
30
30
|
}
|
|
31
|
-
.m-editor-nav-menu .menu-
|
|
32
|
-
|
|
31
|
+
.m-editor-nav-menu .menu-center {
|
|
32
|
+
justify-content: center;
|
|
33
33
|
}
|
|
34
34
|
.m-editor-nav-menu .menu-right {
|
|
35
|
-
|
|
35
|
+
justify-content: flex-end;
|
|
36
36
|
}
|
|
37
37
|
.m-editor-nav-menu .menu-item {
|
|
38
38
|
flex-direction: row;
|
|
@@ -493,6 +493,7 @@
|
|
|
493
493
|
position: relative;
|
|
494
494
|
border: 1px solid #d9dbdd;
|
|
495
495
|
transition: transform 0.3s;
|
|
496
|
+
box-sizing: content-box;
|
|
496
497
|
}
|
|
497
498
|
.m-editor-stage-container::-webkit-scrollbar {
|
|
498
499
|
width: 0 !important;
|
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import { defineComponent, computed, resolveComponent, openBlock, createBlock, no
|
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
3
|
import * as monaco from 'monaco-editor';
|
|
4
4
|
import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, Coin, CaretBottom } from '@element-plus/icons';
|
|
5
|
-
import { cloneDeep, random } from 'lodash-es';
|
|
5
|
+
import { cloneDeep, random, mergeWith } from 'lodash-es';
|
|
6
6
|
import { toLine, isPop, getNodePath } from '@tmagic/utils';
|
|
7
7
|
import { EventEmitter as EventEmitter$2 } from 'events';
|
|
8
8
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
@@ -742,22 +742,6 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
742
742
|
}
|
|
743
743
|
return toRelative(node);
|
|
744
744
|
};
|
|
745
|
-
const defaults = (object, source) => {
|
|
746
|
-
let o = source;
|
|
747
|
-
if (Array.isArray(object)) {
|
|
748
|
-
o = object;
|
|
749
|
-
}
|
|
750
|
-
Object.entries(o).forEach(([key, value]) => {
|
|
751
|
-
if (typeof object[key] === "undefined") {
|
|
752
|
-
object[key] = value;
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
if (value && typeof value !== "string" && Object.keys(value).length) {
|
|
756
|
-
object[key] = defaults(cloneDeep(object[key]), value);
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
return object;
|
|
760
|
-
};
|
|
761
745
|
|
|
762
746
|
const log = (...args) => {
|
|
763
747
|
};
|
|
@@ -859,6 +843,9 @@ class Editor$1 extends BaseService {
|
|
|
859
843
|
const { node, parent, page } = this.getNodeInfo(id);
|
|
860
844
|
if (!node)
|
|
861
845
|
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
846
|
+
if (node.id === this.state.root?.id) {
|
|
847
|
+
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
848
|
+
}
|
|
862
849
|
this.set("node", node);
|
|
863
850
|
this.set("page", page || null);
|
|
864
851
|
this.set("parent", parent || null);
|
|
@@ -926,7 +913,11 @@ class Editor$1 extends BaseService {
|
|
|
926
913
|
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
|
|
927
914
|
const node = cloneDeep(toRaw(info.node));
|
|
928
915
|
let newConfig = await this.toggleFixedPosition(toRaw(config2), node, this.get("root"));
|
|
929
|
-
|
|
916
|
+
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
917
|
+
if (Array.isArray(srcValue)) {
|
|
918
|
+
return srcValue;
|
|
919
|
+
}
|
|
920
|
+
});
|
|
930
921
|
if (!newConfig.type)
|
|
931
922
|
throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
|
|
932
923
|
if (newConfig.type === "app") {
|
|
@@ -2929,8 +2920,10 @@ const _sfc_main$b = defineComponent({
|
|
|
2929
2920
|
}
|
|
2930
2921
|
},
|
|
2931
2922
|
setup(props) {
|
|
2923
|
+
const services = inject("services");
|
|
2932
2924
|
return {
|
|
2933
|
-
keys: computed(() => Object.keys(props.data))
|
|
2925
|
+
keys: computed(() => Object.keys(props.data)),
|
|
2926
|
+
columnWidth: computed(() => services?.uiService.get("columnWidth"))
|
|
2934
2927
|
};
|
|
2935
2928
|
}
|
|
2936
2929
|
});
|
|
@@ -2943,7 +2936,8 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2943
2936
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.keys, (key) => {
|
|
2944
2937
|
return openBlock(), createElementBlock("div", {
|
|
2945
2938
|
class: normalizeClass(`menu-${key}`),
|
|
2946
|
-
key
|
|
2939
|
+
key,
|
|
2940
|
+
style: normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2947
2941
|
}, [
|
|
2948
2942
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data[key], (item, index) => {
|
|
2949
2943
|
return openBlock(), createBlock(_component_tool_button, {
|
|
@@ -2951,7 +2945,7 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2951
2945
|
key: index
|
|
2952
2946
|
}, null, 8, ["data"]);
|
|
2953
2947
|
}), 128))
|
|
2954
|
-
],
|
|
2948
|
+
], 6);
|
|
2955
2949
|
}), 128))
|
|
2956
2950
|
], 4);
|
|
2957
2951
|
}
|
|
@@ -2966,17 +2960,14 @@ const _sfc_main$a = defineComponent({
|
|
|
2966
2960
|
const configForm = ref();
|
|
2967
2961
|
const curFormConfig = ref([]);
|
|
2968
2962
|
const services = inject("services");
|
|
2963
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
2969
2964
|
const init = async () => {
|
|
2970
|
-
|
|
2971
|
-
if (!node) {
|
|
2965
|
+
if (!node.value) {
|
|
2972
2966
|
curFormConfig.value = [];
|
|
2973
2967
|
return;
|
|
2974
2968
|
}
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
}
|
|
2978
|
-
values.value = node;
|
|
2979
|
-
const type = node.type || (node.items ? "container" : "text");
|
|
2969
|
+
values.value = node.value;
|
|
2970
|
+
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2980
2971
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
2981
2972
|
};
|
|
2982
2973
|
watchEffect(init);
|
|
@@ -3623,7 +3614,8 @@ class ScrollViewer$1 {
|
|
|
3623
3614
|
const { width, height } = contentRect;
|
|
3624
3615
|
const targetRect = this.target.getBoundingClientRect();
|
|
3625
3616
|
const targetWidth = targetRect.width * this.zoom;
|
|
3626
|
-
const
|
|
3617
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3618
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3627
3619
|
if (targetWidth < width) {
|
|
3628
3620
|
this.target._left = 0;
|
|
3629
3621
|
}
|
|
@@ -3723,10 +3715,11 @@ class ScrollViewer$1 {
|
|
|
3723
3715
|
event.preventDefault();
|
|
3724
3716
|
event.stopImmediatePropagation();
|
|
3725
3717
|
event.stopPropagation();
|
|
3726
|
-
}
|
|
3718
|
+
}
|
|
3719
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3727
3720
|
return;
|
|
3721
|
+
}
|
|
3728
3722
|
this.keydown = true;
|
|
3729
|
-
event.preventDefault();
|
|
3730
3723
|
this.target.style.cursor = "grab";
|
|
3731
3724
|
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3732
3725
|
};
|
|
@@ -3803,6 +3796,7 @@ const _sfc_main$4 = defineComponent({
|
|
|
3803
3796
|
width: ${props.width}px;
|
|
3804
3797
|
height: ${props.height}px;
|
|
3805
3798
|
position: absolute;
|
|
3799
|
+
margin-top: 30px;
|
|
3806
3800
|
`)
|
|
3807
3801
|
};
|
|
3808
3802
|
}
|
|
@@ -4465,5 +4459,5 @@ var index = {
|
|
|
4465
4459
|
}
|
|
4466
4460
|
};
|
|
4467
4461
|
|
|
4468
|
-
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default,
|
|
4462
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
|
|
4469
4463
|
//# sourceMappingURL=tmagic-editor.es.js.map
|