@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
|
@@ -761,22 +761,6 @@
|
|
|
761
761
|
}
|
|
762
762
|
return toRelative(node);
|
|
763
763
|
};
|
|
764
|
-
const defaults = (object, source) => {
|
|
765
|
-
let o = source;
|
|
766
|
-
if (Array.isArray(object)) {
|
|
767
|
-
o = object;
|
|
768
|
-
}
|
|
769
|
-
Object.entries(o).forEach(([key, value]) => {
|
|
770
|
-
if (typeof object[key] === "undefined") {
|
|
771
|
-
object[key] = value;
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
if (value && typeof value !== "string" && Object.keys(value).length) {
|
|
775
|
-
object[key] = defaults(lodashEs.cloneDeep(object[key]), value);
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
return object;
|
|
779
|
-
};
|
|
780
764
|
|
|
781
765
|
const log = (...args) => {
|
|
782
766
|
};
|
|
@@ -878,6 +862,9 @@
|
|
|
878
862
|
const { node, parent, page } = this.getNodeInfo(id);
|
|
879
863
|
if (!node)
|
|
880
864
|
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
865
|
+
if (node.id === this.state.root?.id) {
|
|
866
|
+
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
867
|
+
}
|
|
881
868
|
this.set("node", node);
|
|
882
869
|
this.set("page", page || null);
|
|
883
870
|
this.set("parent", parent || null);
|
|
@@ -945,7 +932,11 @@
|
|
|
945
932
|
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
|
|
946
933
|
const node = lodashEs.cloneDeep(vue.toRaw(info.node));
|
|
947
934
|
let newConfig = await this.toggleFixedPosition(vue.toRaw(config2), node, this.get("root"));
|
|
948
|
-
|
|
935
|
+
newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
936
|
+
if (Array.isArray(srcValue)) {
|
|
937
|
+
return srcValue;
|
|
938
|
+
}
|
|
939
|
+
});
|
|
949
940
|
if (!newConfig.type)
|
|
950
941
|
throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
|
|
951
942
|
if (newConfig.type === "app") {
|
|
@@ -2948,8 +2939,10 @@
|
|
|
2948
2939
|
}
|
|
2949
2940
|
},
|
|
2950
2941
|
setup(props) {
|
|
2942
|
+
const services = vue.inject("services");
|
|
2951
2943
|
return {
|
|
2952
|
-
keys: vue.computed(() => Object.keys(props.data))
|
|
2944
|
+
keys: vue.computed(() => Object.keys(props.data)),
|
|
2945
|
+
columnWidth: vue.computed(() => services?.uiService.get("columnWidth"))
|
|
2953
2946
|
};
|
|
2954
2947
|
}
|
|
2955
2948
|
});
|
|
@@ -2962,7 +2955,8 @@
|
|
|
2962
2955
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.keys, (key) => {
|
|
2963
2956
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2964
2957
|
class: vue.normalizeClass(`menu-${key}`),
|
|
2965
|
-
key
|
|
2958
|
+
key,
|
|
2959
|
+
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2966
2960
|
}, [
|
|
2967
2961
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data[key], (item, index) => {
|
|
2968
2962
|
return vue.openBlock(), vue.createBlock(_component_tool_button, {
|
|
@@ -2970,7 +2964,7 @@
|
|
|
2970
2964
|
key: index
|
|
2971
2965
|
}, null, 8, ["data"]);
|
|
2972
2966
|
}), 128))
|
|
2973
|
-
],
|
|
2967
|
+
], 6);
|
|
2974
2968
|
}), 128))
|
|
2975
2969
|
], 4);
|
|
2976
2970
|
}
|
|
@@ -2985,17 +2979,14 @@
|
|
|
2985
2979
|
const configForm = vue.ref();
|
|
2986
2980
|
const curFormConfig = vue.ref([]);
|
|
2987
2981
|
const services = vue.inject("services");
|
|
2982
|
+
const node = vue.computed(() => services?.editorService.get("node"));
|
|
2988
2983
|
const init = async () => {
|
|
2989
|
-
|
|
2990
|
-
if (!node) {
|
|
2984
|
+
if (!node.value) {
|
|
2991
2985
|
curFormConfig.value = [];
|
|
2992
2986
|
return;
|
|
2993
2987
|
}
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
}
|
|
2997
|
-
values.value = node;
|
|
2998
|
-
const type = node.type || (node.items ? "container" : "text");
|
|
2988
|
+
values.value = node.value;
|
|
2989
|
+
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2999
2990
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
3000
2991
|
};
|
|
3001
2992
|
vue.watchEffect(init);
|
|
@@ -3642,7 +3633,8 @@
|
|
|
3642
3633
|
const { width, height } = contentRect;
|
|
3643
3634
|
const targetRect = this.target.getBoundingClientRect();
|
|
3644
3635
|
const targetWidth = targetRect.width * this.zoom;
|
|
3645
|
-
const
|
|
3636
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3637
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3646
3638
|
if (targetWidth < width) {
|
|
3647
3639
|
this.target._left = 0;
|
|
3648
3640
|
}
|
|
@@ -3742,10 +3734,11 @@
|
|
|
3742
3734
|
event.preventDefault();
|
|
3743
3735
|
event.stopImmediatePropagation();
|
|
3744
3736
|
event.stopPropagation();
|
|
3745
|
-
}
|
|
3737
|
+
}
|
|
3738
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3746
3739
|
return;
|
|
3740
|
+
}
|
|
3747
3741
|
this.keydown = true;
|
|
3748
|
-
event.preventDefault();
|
|
3749
3742
|
this.target.style.cursor = "grab";
|
|
3750
3743
|
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3751
3744
|
};
|
|
@@ -3822,6 +3815,7 @@
|
|
|
3822
3815
|
width: ${props.width}px;
|
|
3823
3816
|
height: ${props.height}px;
|
|
3824
3817
|
position: absolute;
|
|
3818
|
+
margin-top: 30px;
|
|
3825
3819
|
`)
|
|
3826
3820
|
};
|
|
3827
3821
|
}
|
|
@@ -4498,7 +4492,6 @@
|
|
|
4498
4492
|
exports.change2Fixed = change2Fixed;
|
|
4499
4493
|
exports.debug = debug;
|
|
4500
4494
|
exports["default"] = index;
|
|
4501
|
-
exports.defaults = defaults;
|
|
4502
4495
|
exports.editorService = editorService;
|
|
4503
4496
|
exports.error = error;
|
|
4504
4497
|
exports.eventsService = eventsService;
|