@tmagic/editor 1.5.9 → 1.5.11
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.js
CHANGED
|
@@ -13,7 +13,7 @@ import { throttle, isEmpty, isObject, cloneDeep, mergeWith, uniq, get, map, has,
|
|
|
13
13
|
import serialize from 'serialize-javascript';
|
|
14
14
|
import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
|
|
15
15
|
import * as monaco from 'monaco-editor';
|
|
16
|
-
import { HookCodeType, HookType, NODE_CONDS_KEY, Target, Watcher, NodeType, ActionType, DepTargetType,
|
|
16
|
+
import { HookCodeType, HookType, NODE_CONDS_KEY, Target, Watcher, NodeType, ActionType, DepTargetType, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/core';
|
|
17
17
|
export { DepTargetType } from '@tmagic/core';
|
|
18
18
|
import { isPage, isPageFragment, isPop, getNodePath, isNumber, getElById, calcValueByFontsize, isValueIncludeDataSource, toLine, guid, getValueByKeyPath, setValueByKeyPath, getNodeInfo, dataSourceTemplateRegExp, getKeysArray, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, convertToNumber, getIdFromEl, traverseNode, getDefaultValueFromFields, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, removeClassName, addClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
|
|
19
19
|
export * from '@tmagic/utils';
|
|
@@ -9651,6 +9651,14 @@ const useStylePanel = ({ uiService, storageService }, propsPanelWidth) => {
|
|
|
9651
9651
|
}
|
|
9652
9652
|
const showStylePanel = computed(() => showStylePanelToggleButton.value && (uiService.get("showStylePanel") ?? true));
|
|
9653
9653
|
const showStylePanelToggleButton = computed(() => uiService.get("frameworkRect").width >= 1280);
|
|
9654
|
+
watch(
|
|
9655
|
+
() => uiService.get("frameworkRect").width,
|
|
9656
|
+
() => {
|
|
9657
|
+
if (uiService.get("columnWidth").right < propsPanelWidth.value) {
|
|
9658
|
+
toggleStylePanel(false);
|
|
9659
|
+
}
|
|
9660
|
+
}
|
|
9661
|
+
);
|
|
9654
9662
|
const toggleStylePanel = (showStylePanel2) => {
|
|
9655
9663
|
uiService.set("showStylePanel", showStylePanel2);
|
|
9656
9664
|
storageService.setItem(showStylePanelStorageKey, showStylePanel2, { protocol: Protocol.BOOLEAN });
|
|
@@ -9760,7 +9768,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
9760
9768
|
storageService.getItem(PROPS_PANEL_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || 300
|
|
9761
9769
|
);
|
|
9762
9770
|
onMounted(() => {
|
|
9763
|
-
propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${propsPanelWidth.value}px`);
|
|
9771
|
+
propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${Math.max(propsPanelWidth.value, 0)}px`);
|
|
9764
9772
|
});
|
|
9765
9773
|
const widthChange = ({ deltaX }) => {
|
|
9766
9774
|
if (!propsPanelEl.value) {
|
|
@@ -9773,7 +9781,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
9773
9781
|
if (value > uiService.get("columnWidth").right) {
|
|
9774
9782
|
value = uiService.get("columnWidth").right - 40;
|
|
9775
9783
|
}
|
|
9776
|
-
propsPanelWidth.value = value;
|
|
9784
|
+
propsPanelWidth.value = Math.max(value, 0);
|
|
9777
9785
|
};
|
|
9778
9786
|
watch(propsPanelWidth, (value) => {
|
|
9779
9787
|
propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${value}px`);
|
|
@@ -14052,29 +14060,16 @@ class Events extends BaseService {
|
|
|
14052
14060
|
constructor() {
|
|
14053
14061
|
super([]);
|
|
14054
14062
|
}
|
|
14055
|
-
init(componentGroupList) {
|
|
14056
|
-
componentGroupList.forEach((group) => {
|
|
14057
|
-
group.items.forEach((element) => {
|
|
14058
|
-
const type = toLine(element.type);
|
|
14059
|
-
if (!this.getEvent(type)) {
|
|
14060
|
-
this.setEvent(type, DEFAULT_EVENTS);
|
|
14061
|
-
}
|
|
14062
|
-
if (!this.getMethod(type)) {
|
|
14063
|
-
this.setMethod(type, DEFAULT_METHODS);
|
|
14064
|
-
}
|
|
14065
|
-
});
|
|
14066
|
-
});
|
|
14067
|
-
}
|
|
14068
14063
|
setEvents(events) {
|
|
14069
14064
|
Object.keys(events).forEach((type) => {
|
|
14070
14065
|
this.setEvent(toLine(type), events[type] || []);
|
|
14071
14066
|
});
|
|
14072
14067
|
}
|
|
14073
14068
|
setEvent(type, events) {
|
|
14074
|
-
eventMap[toLine(type)] = [...
|
|
14069
|
+
eventMap[toLine(type)] = [...events];
|
|
14075
14070
|
}
|
|
14076
14071
|
getEvent(type) {
|
|
14077
|
-
return cloneDeep(eventMap[toLine(type)] ||
|
|
14072
|
+
return cloneDeep(eventMap[toLine(type)]) || [];
|
|
14078
14073
|
}
|
|
14079
14074
|
setMethods(methods) {
|
|
14080
14075
|
Object.keys(methods).forEach((type) => {
|
|
@@ -14082,10 +14077,10 @@ class Events extends BaseService {
|
|
|
14082
14077
|
});
|
|
14083
14078
|
}
|
|
14084
14079
|
setMethod(type, method) {
|
|
14085
|
-
methodMap[toLine(type)] = [...
|
|
14080
|
+
methodMap[toLine(type)] = [...method];
|
|
14086
14081
|
}
|
|
14087
14082
|
getMethod(type) {
|
|
14088
|
-
return cloneDeep(methodMap[toLine(type)]
|
|
14083
|
+
return cloneDeep(methodMap[toLine(type)]);
|
|
14089
14084
|
}
|
|
14090
14085
|
resetState() {
|
|
14091
14086
|
eventMap = reactive({});
|
|
@@ -14538,6 +14538,14 @@
|
|
|
14538
14538
|
}
|
|
14539
14539
|
const showStylePanel = vue.computed(() => showStylePanelToggleButton.value && (uiService.get("showStylePanel") ?? true));
|
|
14540
14540
|
const showStylePanelToggleButton = vue.computed(() => uiService.get("frameworkRect").width >= 1280);
|
|
14541
|
+
vue.watch(
|
|
14542
|
+
() => uiService.get("frameworkRect").width,
|
|
14543
|
+
() => {
|
|
14544
|
+
if (uiService.get("columnWidth").right < propsPanelWidth.value) {
|
|
14545
|
+
toggleStylePanel(false);
|
|
14546
|
+
}
|
|
14547
|
+
}
|
|
14548
|
+
);
|
|
14541
14549
|
const toggleStylePanel = (showStylePanel2) => {
|
|
14542
14550
|
uiService.set("showStylePanel", showStylePanel2);
|
|
14543
14551
|
storageService.setItem(showStylePanelStorageKey, showStylePanel2, { protocol: Protocol.BOOLEAN });
|
|
@@ -14647,7 +14655,7 @@
|
|
|
14647
14655
|
storageService.getItem(PROPS_PANEL_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || 300
|
|
14648
14656
|
);
|
|
14649
14657
|
vue.onMounted(() => {
|
|
14650
|
-
propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${propsPanelWidth.value}px`);
|
|
14658
|
+
propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${Math.max(propsPanelWidth.value, 0)}px`);
|
|
14651
14659
|
});
|
|
14652
14660
|
const widthChange = ({ deltaX }) => {
|
|
14653
14661
|
if (!propsPanelEl.value) {
|
|
@@ -14660,7 +14668,7 @@
|
|
|
14660
14668
|
if (value > uiService.get("columnWidth").right) {
|
|
14661
14669
|
value = uiService.get("columnWidth").right - 40;
|
|
14662
14670
|
}
|
|
14663
|
-
propsPanelWidth.value = value;
|
|
14671
|
+
propsPanelWidth.value = Math.max(value, 0);
|
|
14664
14672
|
};
|
|
14665
14673
|
vue.watch(propsPanelWidth, (value) => {
|
|
14666
14674
|
propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${value}px`);
|
|
@@ -18939,29 +18947,16 @@
|
|
|
18939
18947
|
constructor() {
|
|
18940
18948
|
super([]);
|
|
18941
18949
|
}
|
|
18942
|
-
init(componentGroupList) {
|
|
18943
|
-
componentGroupList.forEach((group) => {
|
|
18944
|
-
group.items.forEach((element) => {
|
|
18945
|
-
const type = utils.toLine(element.type);
|
|
18946
|
-
if (!this.getEvent(type)) {
|
|
18947
|
-
this.setEvent(type, core.DEFAULT_EVENTS);
|
|
18948
|
-
}
|
|
18949
|
-
if (!this.getMethod(type)) {
|
|
18950
|
-
this.setMethod(type, core.DEFAULT_METHODS);
|
|
18951
|
-
}
|
|
18952
|
-
});
|
|
18953
|
-
});
|
|
18954
|
-
}
|
|
18955
18950
|
setEvents(events) {
|
|
18956
18951
|
Object.keys(events).forEach((type) => {
|
|
18957
18952
|
this.setEvent(utils.toLine(type), events[type] || []);
|
|
18958
18953
|
});
|
|
18959
18954
|
}
|
|
18960
18955
|
setEvent(type, events) {
|
|
18961
|
-
eventMap[utils.toLine(type)] = [...
|
|
18956
|
+
eventMap[utils.toLine(type)] = [...events];
|
|
18962
18957
|
}
|
|
18963
18958
|
getEvent(type) {
|
|
18964
|
-
return cloneDeep(eventMap[utils.toLine(type)] ||
|
|
18959
|
+
return cloneDeep(eventMap[utils.toLine(type)]) || [];
|
|
18965
18960
|
}
|
|
18966
18961
|
setMethods(methods) {
|
|
18967
18962
|
Object.keys(methods).forEach((type) => {
|
|
@@ -18969,10 +18964,10 @@
|
|
|
18969
18964
|
});
|
|
18970
18965
|
}
|
|
18971
18966
|
setMethod(type, method) {
|
|
18972
|
-
methodMap[utils.toLine(type)] = [...
|
|
18967
|
+
methodMap[utils.toLine(type)] = [...method];
|
|
18973
18968
|
}
|
|
18974
18969
|
getMethod(type) {
|
|
18975
|
-
return cloneDeep(methodMap[utils.toLine(type)]
|
|
18970
|
+
return cloneDeep(methodMap[utils.toLine(type)]);
|
|
18976
18971
|
}
|
|
18977
18972
|
resetState() {
|
|
18978
18973
|
eventMap = vue.reactive({});
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.11",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^6.0.0",
|
|
60
60
|
"sortablejs": "^1.15.2",
|
|
61
|
-
"@tmagic/
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/table": "1.5.
|
|
61
|
+
"@tmagic/form": "1.5.11",
|
|
62
|
+
"@tmagic/design": "1.5.11",
|
|
63
|
+
"@tmagic/utils": "1.5.11",
|
|
64
|
+
"@tmagic/stage": "1.5.11",
|
|
65
|
+
"@tmagic/table": "1.5.11"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"monaco-editor": "^0.48.0",
|
|
77
77
|
"typescript": "*",
|
|
78
78
|
"vue": ">=3.5.0",
|
|
79
|
-
"@tmagic/core": "1.5.
|
|
79
|
+
"@tmagic/core": "1.5.11"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
|
@@ -171,7 +171,7 @@ const propsPanelWidth = ref(
|
|
|
171
171
|
);
|
|
172
172
|
|
|
173
173
|
onMounted(() => {
|
|
174
|
-
propsPanelEl.value?.style.setProperty('--props-style-panel-width', `${propsPanelWidth.value}px`);
|
|
174
|
+
propsPanelEl.value?.style.setProperty('--props-style-panel-width', `${Math.max(propsPanelWidth.value, 0)}px`);
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
const widthChange = ({ deltaX }: OnDrag) => {
|
|
@@ -187,7 +187,7 @@ const widthChange = ({ deltaX }: OnDrag) => {
|
|
|
187
187
|
if (value > uiService.get('columnWidth').right) {
|
|
188
188
|
value = uiService.get('columnWidth').right - 40;
|
|
189
189
|
}
|
|
190
|
-
propsPanelWidth.value = value;
|
|
190
|
+
propsPanelWidth.value = Math.max(value, 0);
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
watch(propsPanelWidth, (value) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, type Ref } from 'vue';
|
|
1
|
+
import { computed, type Ref, watch } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { Protocol } from '@editor/services/storage';
|
|
4
4
|
import { Services } from '@editor/type';
|
|
@@ -21,6 +21,15 @@ export const useStylePanel = (
|
|
|
21
21
|
|
|
22
22
|
const showStylePanelToggleButton = computed(() => uiService.get('frameworkRect').width >= 1280);
|
|
23
23
|
|
|
24
|
+
watch(
|
|
25
|
+
() => uiService.get('frameworkRect').width,
|
|
26
|
+
() => {
|
|
27
|
+
if (uiService.get('columnWidth').right < propsPanelWidth.value) {
|
|
28
|
+
toggleStylePanel(false);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
|
|
24
33
|
const toggleStylePanel = (showStylePanel: boolean) => {
|
|
25
34
|
uiService.set('showStylePanel', showStylePanel);
|
|
26
35
|
storageService.setItem(showStylePanelStorageKey, showStylePanel, { protocol: Protocol.BOOLEAN });
|
package/src/services/events.ts
CHANGED
|
@@ -19,11 +19,9 @@
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
20
|
import { cloneDeep } from 'lodash-es';
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import { type EventOption } from '@tmagic/core';
|
|
23
23
|
import { toLine } from '@tmagic/utils';
|
|
24
24
|
|
|
25
|
-
import type { ComponentGroup } from '@editor/type';
|
|
26
|
-
|
|
27
25
|
import BaseService from './BaseService';
|
|
28
26
|
|
|
29
27
|
let eventMap: Record<string, EventOption[]> = reactive({});
|
|
@@ -34,20 +32,6 @@ class Events extends BaseService {
|
|
|
34
32
|
super([]);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
public init(componentGroupList: ComponentGroup[]) {
|
|
38
|
-
componentGroupList.forEach((group) => {
|
|
39
|
-
group.items.forEach((element) => {
|
|
40
|
-
const type = toLine(element.type);
|
|
41
|
-
if (!this.getEvent(type)) {
|
|
42
|
-
this.setEvent(type, DEFAULT_EVENTS);
|
|
43
|
-
}
|
|
44
|
-
if (!this.getMethod(type)) {
|
|
45
|
-
this.setMethod(type, DEFAULT_METHODS);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
35
|
public setEvents(events: Record<string, EventOption[]>) {
|
|
52
36
|
Object.keys(events).forEach((type: string) => {
|
|
53
37
|
this.setEvent(toLine(type), events[type] || []);
|
|
@@ -55,11 +39,11 @@ class Events extends BaseService {
|
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
public setEvent(type: string, events: EventOption[]) {
|
|
58
|
-
eventMap[toLine(type)] = [...
|
|
42
|
+
eventMap[toLine(type)] = [...events];
|
|
59
43
|
}
|
|
60
44
|
|
|
61
45
|
public getEvent(type: string): EventOption[] {
|
|
62
|
-
return cloneDeep(eventMap[toLine(type)] ||
|
|
46
|
+
return cloneDeep(eventMap[toLine(type)]) || [];
|
|
63
47
|
}
|
|
64
48
|
|
|
65
49
|
public setMethods(methods: Record<string, EventOption[]>) {
|
|
@@ -69,11 +53,11 @@ class Events extends BaseService {
|
|
|
69
53
|
}
|
|
70
54
|
|
|
71
55
|
public setMethod(type: string, method: EventOption[]) {
|
|
72
|
-
methodMap[toLine(type)] = [...
|
|
56
|
+
methodMap[toLine(type)] = [...method];
|
|
73
57
|
}
|
|
74
58
|
|
|
75
59
|
public getMethod(type: string) {
|
|
76
|
-
return cloneDeep(methodMap[toLine(type)]
|
|
60
|
+
return cloneDeep(methodMap[toLine(type)]);
|
|
77
61
|
}
|
|
78
62
|
|
|
79
63
|
public resetState() {
|
package/types/index.d.ts
CHANGED
|
@@ -526,7 +526,6 @@ declare const _default$E: Editor;
|
|
|
526
526
|
|
|
527
527
|
declare class Events extends export_default {
|
|
528
528
|
constructor();
|
|
529
|
-
init(componentGroupList: ComponentGroup[]): void;
|
|
530
529
|
setEvents(events: Record<string, EventOption[]>): void;
|
|
531
530
|
setEvent(type: string, events: EventOption[]): void;
|
|
532
531
|
getEvent(type: string): EventOption[];
|