@tmagic/editor 1.0.0-rc.12 → 1.0.0-rc.13
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 +35 -5
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +36 -3
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/type.d.ts +2 -0
- package/dist/types/src/utils/editor.d.ts +1 -0
- package/package.json +7 -7
- package/src/layouts/workspace/Stage.vue +29 -4
- package/src/services/ui.ts +4 -2
- package/src/type.ts +3 -0
- package/src/utils/editor.ts +15 -0
|
@@ -740,6 +740,8 @@
|
|
|
740
740
|
Keys2["ESCAPE"] = "Space";
|
|
741
741
|
return Keys2;
|
|
742
742
|
})(Keys || {});
|
|
743
|
+
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
744
|
+
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
743
745
|
|
|
744
746
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
745
747
|
const getPageList = (app) => {
|
|
@@ -866,6 +868,19 @@
|
|
|
866
868
|
}
|
|
867
869
|
return toRelative(node);
|
|
868
870
|
};
|
|
871
|
+
const getGuideLineFromCache = (key) => {
|
|
872
|
+
if (!key)
|
|
873
|
+
return [];
|
|
874
|
+
const guideLineCacheData = globalThis.localStorage.getItem(key);
|
|
875
|
+
if (guideLineCacheData) {
|
|
876
|
+
try {
|
|
877
|
+
return JSON.parse(guideLineCacheData) || [];
|
|
878
|
+
} catch (e) {
|
|
879
|
+
console.error(e);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return [];
|
|
883
|
+
};
|
|
869
884
|
|
|
870
885
|
const log = (...args) => {
|
|
871
886
|
};
|
|
@@ -3430,6 +3445,7 @@
|
|
|
3430
3445
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3431
3446
|
let stage = null;
|
|
3432
3447
|
let runtime = null;
|
|
3448
|
+
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3433
3449
|
vue.watchEffect(() => {
|
|
3434
3450
|
if (stage)
|
|
3435
3451
|
return;
|
|
@@ -3455,6 +3471,10 @@
|
|
|
3455
3471
|
});
|
|
3456
3472
|
services?.editorService.set("stage", vue.markRaw(stage));
|
|
3457
3473
|
stage?.mount(stageContainer.value);
|
|
3474
|
+
stage.mask.setGuides([
|
|
3475
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
3476
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
3477
|
+
]);
|
|
3458
3478
|
stage?.on("select", (el) => {
|
|
3459
3479
|
services?.editorService.select(el.id);
|
|
3460
3480
|
});
|
|
@@ -3467,8 +3487,16 @@
|
|
|
3467
3487
|
stage?.on("sort", (ev) => {
|
|
3468
3488
|
services?.editorService.sort(ev.src, ev.dist);
|
|
3469
3489
|
});
|
|
3470
|
-
stage?.on("changeGuides", () => {
|
|
3490
|
+
stage?.on("changeGuides", (e2) => {
|
|
3471
3491
|
services?.uiService.set("showGuides", true);
|
|
3492
|
+
if (!root.value || !page.value)
|
|
3493
|
+
return;
|
|
3494
|
+
const storageKey = getGuideLineKey(e2.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
3495
|
+
if (e2.guides.length) {
|
|
3496
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
|
|
3497
|
+
} else {
|
|
3498
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
3499
|
+
}
|
|
3472
3500
|
});
|
|
3473
3501
|
if (!node.value?.id)
|
|
3474
3502
|
return;
|
|
@@ -3721,7 +3749,9 @@
|
|
|
3721
3749
|
var componentListService = new ComponentList();
|
|
3722
3750
|
|
|
3723
3751
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3752
|
+
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
3724
3753
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
3754
|
+
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
3725
3755
|
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
3726
3756
|
const defaultColumnWidth = {
|
|
3727
3757
|
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
@@ -3797,10 +3827,10 @@
|
|
|
3797
3827
|
...vue.toRaw(this.get("columnWidth"))
|
|
3798
3828
|
};
|
|
3799
3829
|
if (left) {
|
|
3800
|
-
columnWidth.left = left;
|
|
3830
|
+
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
3801
3831
|
}
|
|
3802
3832
|
if (right) {
|
|
3803
|
-
columnWidth.right = right;
|
|
3833
|
+
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
3804
3834
|
}
|
|
3805
3835
|
if (!center || center === "auto") {
|
|
3806
3836
|
const bodyWidth = globalThis.document.body.clientWidth;
|
|
@@ -4037,6 +4067,7 @@
|
|
|
4037
4067
|
exports.ComponentListPanel = ComponentListPanel;
|
|
4038
4068
|
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
4039
4069
|
exports.Fixed2Other = Fixed2Other;
|
|
4070
|
+
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
4040
4071
|
exports.Keys = Keys;
|
|
4041
4072
|
exports.LayerOffset = LayerOffset;
|
|
4042
4073
|
exports.LayerPanel = LayerPanel;
|
|
@@ -4045,6 +4076,7 @@
|
|
|
4045
4076
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4046
4077
|
exports.TMagicEditor = Editor;
|
|
4047
4078
|
exports.ToolButton = ToolButton;
|
|
4079
|
+
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4048
4080
|
exports.change2Fixed = change2Fixed;
|
|
4049
4081
|
exports.debug = debug;
|
|
4050
4082
|
exports["default"] = index;
|
|
@@ -4056,6 +4088,7 @@
|
|
|
4056
4088
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
4057
4089
|
exports.getConfig = getConfig;
|
|
4058
4090
|
exports.getDefaultPropsValue = getDefaultPropsValue;
|
|
4091
|
+
exports.getGuideLineFromCache = getGuideLineFromCache;
|
|
4059
4092
|
exports.getNodeIndex = getNodeIndex;
|
|
4060
4093
|
exports.getPageList = getPageList;
|
|
4061
4094
|
exports.getPageNameList = getPageNameList;
|