@tmagic/editor 1.2.0-beta.20 → 1.2.0-beta.21
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.mjs → tmagic-editor.js} +55 -18
- package/dist/tmagic-editor.js.map +1 -0
- package/dist/{tmagic-editor.umd.js → tmagic-editor.umd.cjs} +55 -18
- package/dist/tmagic-editor.umd.cjs.map +1 -0
- package/package.json +14 -13
- package/src/Editor.vue +6 -7
- package/src/components/Layout.vue +1 -1
- package/src/services/BaseService.ts +5 -0
- package/src/services/codeBlock.ts +7 -1
- package/src/services/componentList.ts +6 -1
- package/src/services/editor.ts +8 -3
- package/src/services/events.ts +6 -1
- package/src/services/history.ts +3 -2
- package/src/services/props.ts +6 -1
- package/src/services/storage.ts +1 -0
- package/src/services/ui.ts +12 -0
- package/types/services/BaseService.d.ts +1 -0
- package/types/services/codeBlock.d.ts +1 -0
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +1 -0
- package/types/services/events.d.ts +1 -0
- package/types/services/history.d.ts +1 -1
- package/types/services/props.d.ts +1 -0
- package/types/services/ui.d.ts +1 -0
- package/dist/tmagic-editor.mjs.map +0 -1
- package/dist/tmagic-editor.umd.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.0-beta.
|
|
2
|
+
"version": "1.2.0-beta.21",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"sideEffects": [
|
|
5
6
|
"dist/*",
|
|
6
7
|
"src/theme/*"
|
|
7
8
|
],
|
|
8
|
-
"main": "dist/tmagic-editor.umd.
|
|
9
|
-
"module": "dist/tmagic-editor.
|
|
9
|
+
"main": "dist/tmagic-editor.umd.cjs",
|
|
10
|
+
"module": "dist/tmagic-editor.js",
|
|
10
11
|
"style": "dist/style.css",
|
|
11
12
|
"types": "types/index.d.ts",
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
14
|
-
"import": "./dist/tmagic-editor.
|
|
15
|
-
"require": "./dist/tmagic-editor.umd.
|
|
15
|
+
"import": "./dist/tmagic-editor.js",
|
|
16
|
+
"require": "./dist/tmagic-editor.umd.cjs"
|
|
16
17
|
},
|
|
17
18
|
"./dist/style.css": {
|
|
18
19
|
"import": "./dist/style.css",
|
|
@@ -45,12 +46,12 @@
|
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@babel/core": "^7.18.0",
|
|
47
48
|
"@element-plus/icons-vue": "^2.0.9",
|
|
48
|
-
"@tmagic/core": "1.2.0-beta.
|
|
49
|
-
"@tmagic/design": "1.2.0-beta.
|
|
50
|
-
"@tmagic/form": "1.2.0-beta.
|
|
51
|
-
"@tmagic/schema": "1.2.0-beta.
|
|
52
|
-
"@tmagic/stage": "1.2.0-beta.
|
|
53
|
-
"@tmagic/utils": "1.2.0-beta.
|
|
49
|
+
"@tmagic/core": "1.2.0-beta.21",
|
|
50
|
+
"@tmagic/design": "1.2.0-beta.21",
|
|
51
|
+
"@tmagic/form": "1.2.0-beta.21",
|
|
52
|
+
"@tmagic/schema": "1.2.0-beta.21",
|
|
53
|
+
"@tmagic/stage": "1.2.0-beta.21",
|
|
54
|
+
"@tmagic/utils": "1.2.0-beta.21",
|
|
54
55
|
"buffer": "^6.0.3",
|
|
55
56
|
"color": "^3.1.3",
|
|
56
57
|
"events": "^3.3.0",
|
|
@@ -62,8 +63,8 @@
|
|
|
62
63
|
"vue": "^3.2.37"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
|
-
"@tmagic/design": "1.2.0-beta.
|
|
66
|
-
"@tmagic/form": "1.2.0-beta.
|
|
66
|
+
"@tmagic/design": "1.2.0-beta.21",
|
|
67
|
+
"@tmagic/form": "1.2.0-beta.21",
|
|
67
68
|
"monaco-editor": "^0.34.0",
|
|
68
69
|
"vue": "^3.2.37"
|
|
69
70
|
},
|
package/src/Editor.vue
CHANGED
|
@@ -316,13 +316,12 @@ export default defineComponent({
|
|
|
316
316
|
);
|
|
317
317
|
|
|
318
318
|
onUnmounted(() => {
|
|
319
|
-
editorService.
|
|
320
|
-
historyService.
|
|
321
|
-
propsService.
|
|
322
|
-
uiService.
|
|
323
|
-
componentListService.
|
|
324
|
-
|
|
325
|
-
codeBlockService.destroy();
|
|
319
|
+
editorService.resetState();
|
|
320
|
+
historyService.resetState();
|
|
321
|
+
propsService.resetState();
|
|
322
|
+
uiService.resetState();
|
|
323
|
+
componentListService.resetState();
|
|
324
|
+
codeBlockService.resetState();
|
|
326
325
|
});
|
|
327
326
|
|
|
328
327
|
const services: Services = {
|
|
@@ -48,7 +48,7 @@ const props = withDefaults(
|
|
|
48
48
|
const el = ref<HTMLElement>();
|
|
49
49
|
|
|
50
50
|
const hasLeft = computed(() => typeof props.left !== 'undefined');
|
|
51
|
-
const hasRight = computed(() => typeof props.
|
|
51
|
+
const hasRight = computed(() => typeof props.right !== 'undefined');
|
|
52
52
|
|
|
53
53
|
const getCenterWidth = (clientWidth: number, left: number, right: number) => {
|
|
54
54
|
let center = clientWidth - left - right;
|
|
@@ -169,6 +169,11 @@ export default class extends EventEmitter {
|
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
public removeAllPlugins() {
|
|
173
|
+
this.pluginOptionsList = {};
|
|
174
|
+
this.middleware = {};
|
|
175
|
+
}
|
|
176
|
+
|
|
172
177
|
private async doTask() {
|
|
173
178
|
this.doingTask = true;
|
|
174
179
|
let task = this.taskList.shift();
|
|
@@ -344,7 +344,7 @@ class CodeBlock extends BaseService {
|
|
|
344
344
|
this.setCodeDsl(codeDsl);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
public
|
|
347
|
+
public resetState() {
|
|
348
348
|
this.state.isShowCodeEditor = false;
|
|
349
349
|
this.state.codeDsl = null;
|
|
350
350
|
this.state.id = '';
|
|
@@ -354,6 +354,12 @@ class CodeBlock extends BaseService {
|
|
|
354
354
|
this.state.undeletableList = [];
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
public destroy(): void {
|
|
358
|
+
this.resetState();
|
|
359
|
+
this.removeAllListeners();
|
|
360
|
+
this.removeAllPlugins();
|
|
361
|
+
}
|
|
362
|
+
|
|
357
363
|
/**
|
|
358
364
|
* 删除组件时 如果是容器 需要遍历删除其包含节点的绑定信息
|
|
359
365
|
* @param {MNode} node 节点信息
|
|
@@ -42,9 +42,14 @@ class ComponentList extends BaseService {
|
|
|
42
42
|
return this.state.list;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
public
|
|
45
|
+
public resetState() {
|
|
46
46
|
this.state.list = [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public destroy() {
|
|
50
|
+
this.resetState();
|
|
47
51
|
this.removeAllListeners();
|
|
52
|
+
this.removeAllPlugins();
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
|
package/src/services/editor.ts
CHANGED
|
@@ -207,7 +207,7 @@ class Editor extends BaseService {
|
|
|
207
207
|
if (page) {
|
|
208
208
|
historyService.changePage(toRaw(page));
|
|
209
209
|
} else {
|
|
210
|
-
historyService.
|
|
210
|
+
historyService.resetState();
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
if (node?.id) {
|
|
@@ -762,8 +762,7 @@ class Editor extends BaseService {
|
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
764
|
|
|
765
|
-
public
|
|
766
|
-
this.removeAllListeners();
|
|
765
|
+
public resetState() {
|
|
767
766
|
this.set('root', null);
|
|
768
767
|
this.set('node', null);
|
|
769
768
|
this.set('nodes', []);
|
|
@@ -775,6 +774,12 @@ class Editor extends BaseService {
|
|
|
775
774
|
this.set('pageLength', new Map());
|
|
776
775
|
}
|
|
777
776
|
|
|
777
|
+
public destroy() {
|
|
778
|
+
this.removeAllListeners();
|
|
779
|
+
this.resetState();
|
|
780
|
+
this.removeAllPlugins();
|
|
781
|
+
}
|
|
782
|
+
|
|
778
783
|
public resetModifiedNodeId() {
|
|
779
784
|
this.get<Map<Id, Id>>('modifiedNodeIds').clear();
|
|
780
785
|
}
|
package/src/services/events.ts
CHANGED
|
@@ -76,10 +76,15 @@ class Events extends BaseService {
|
|
|
76
76
|
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
public
|
|
79
|
+
public resetState() {
|
|
80
80
|
eventMap = reactive({});
|
|
81
81
|
methodMap = reactive({});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public destroy() {
|
|
85
|
+
this.resetState();
|
|
82
86
|
this.removeAllListeners();
|
|
87
|
+
this.removeAllPlugins();
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
|
package/src/services/history.ts
CHANGED
|
@@ -68,7 +68,7 @@ class History extends BaseService {
|
|
|
68
68
|
this.emit('page-change', this.state.pageSteps[this.state.pageId]);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
public
|
|
71
|
+
public resetState(): void {
|
|
72
72
|
this.state.pageId = undefined;
|
|
73
73
|
this.state.pageSteps = {};
|
|
74
74
|
this.state.canRedo = false;
|
|
@@ -100,8 +100,9 @@ class History extends BaseService {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
public destroy(): void {
|
|
103
|
-
this.
|
|
103
|
+
this.resetState();
|
|
104
104
|
this.removeAllListeners();
|
|
105
|
+
this.removeAllPlugins();
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
private getUndoRedo() {
|
package/src/services/props.ts
CHANGED
|
@@ -171,10 +171,15 @@ class Props extends BaseService {
|
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
public
|
|
174
|
+
public resetState() {
|
|
175
175
|
this.state.propsConfigMap = {};
|
|
176
176
|
this.state.propsValueMap = {};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public destroy() {
|
|
180
|
+
this.resetState();
|
|
177
181
|
this.removeAllListeners();
|
|
182
|
+
this.removeAllPlugins();
|
|
178
183
|
}
|
|
179
184
|
|
|
180
185
|
/**
|
package/src/services/storage.ts
CHANGED
package/src/services/ui.ts
CHANGED
|
@@ -97,8 +97,20 @@ class Ui extends BaseService {
|
|
|
97
97
|
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
public resetState() {
|
|
101
|
+
this.set('showSrc', false);
|
|
102
|
+
this.set('uiSelectMode', false);
|
|
103
|
+
this.set('zoom', 1);
|
|
104
|
+
this.set('stageContainerRect', {
|
|
105
|
+
width: 0,
|
|
106
|
+
height: 0,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
100
110
|
public destroy() {
|
|
111
|
+
this.resetState();
|
|
101
112
|
this.removeAllListeners();
|
|
113
|
+
this.removeAllPlugins();
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
private async setStageRect(value: StageRect) {
|
|
@@ -10,6 +10,7 @@ declare class Events extends BaseService {
|
|
|
10
10
|
setMethods(methods: Record<string, EventOption[]>): void;
|
|
11
11
|
setMethod(type: string, method: EventOption[]): void;
|
|
12
12
|
getMethod(type: string): EventOption[];
|
|
13
|
+
resetState(): void;
|
|
13
14
|
destroy(): void;
|
|
14
15
|
}
|
|
15
16
|
export declare type EventsService = Events;
|