@tmagic/editor 1.3.8 → 1.3.9
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 +19 -9
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +19 -10
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +12 -11
- package/src/layouts/CodeEditor.vue +1 -1
- package/src/services/editor.ts +13 -5
- package/src/services/props.ts +9 -4
- package/src/utils/monaco-editor.ts +8 -0
- package/types/layouts/CodeEditor.vue.d.ts +1 -1
- package/types/utils/monaco-editor.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.
|
|
2
|
+
"version": "1.3.9",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -42,16 +42,17 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@babel/core": "^7.18.0",
|
|
44
44
|
"@element-plus/icons-vue": "^2.3.1",
|
|
45
|
-
"@tmagic/core": "1.3.
|
|
46
|
-
"@tmagic/dep": "1.3.
|
|
47
|
-
"@tmagic/design": "1.3.
|
|
48
|
-
"@tmagic/form": "1.3.
|
|
49
|
-
"@tmagic/schema": "1.3.
|
|
50
|
-
"@tmagic/stage": "1.3.
|
|
51
|
-
"@tmagic/table": "1.3.
|
|
52
|
-
"@tmagic/utils": "1.3.
|
|
45
|
+
"@tmagic/core": "1.3.9",
|
|
46
|
+
"@tmagic/dep": "1.3.9",
|
|
47
|
+
"@tmagic/design": "1.3.9",
|
|
48
|
+
"@tmagic/form": "1.3.9",
|
|
49
|
+
"@tmagic/schema": "1.3.9",
|
|
50
|
+
"@tmagic/stage": "1.3.9",
|
|
51
|
+
"@tmagic/table": "1.3.9",
|
|
52
|
+
"@tmagic/utils": "1.3.9",
|
|
53
53
|
"buffer": "^6.0.3",
|
|
54
54
|
"color": "^3.1.3",
|
|
55
|
+
"emmet-monaco-es": "^5.3.0",
|
|
55
56
|
"events": "^3.3.0",
|
|
56
57
|
"gesto": "^1.19.1",
|
|
57
58
|
"keycon": "^1.4.0",
|
|
@@ -62,8 +63,8 @@
|
|
|
62
63
|
"vue": "^3.3.8"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
|
-
"@tmagic/design": "1.3.
|
|
66
|
-
"@tmagic/form": "1.3.
|
|
66
|
+
"@tmagic/design": "1.3.9",
|
|
67
|
+
"@tmagic/form": "1.3.9",
|
|
67
68
|
"monaco-editor": "^0.41.0",
|
|
68
69
|
"vue": "^3.3.8"
|
|
69
70
|
},
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
23
23
|
import { FullScreen } from '@element-plus/icons-vue';
|
|
24
24
|
import { throttle } from 'lodash-es';
|
|
25
|
-
import * as monaco from 'monaco-editor';
|
|
26
25
|
import serialize from 'serialize-javascript';
|
|
27
26
|
|
|
28
27
|
import { TMagicButton } from '@tmagic/design';
|
|
29
28
|
|
|
30
29
|
import { getConfig } from '@editor/utils/config';
|
|
30
|
+
import monaco from '@editor/utils/monaco-editor';
|
|
31
31
|
|
|
32
32
|
defineOptions({
|
|
33
33
|
name: 'MEditorCodeEditor',
|
package/src/services/editor.ts
CHANGED
|
@@ -775,17 +775,23 @@ class Editor extends BaseService {
|
|
|
775
775
|
const layout = await this.getLayout(parent, node);
|
|
776
776
|
const isRelative = layout === Layout.RELATIVE;
|
|
777
777
|
|
|
778
|
-
|
|
779
|
-
|
|
778
|
+
let offsetIndex: number;
|
|
780
779
|
if (offset === LayerOffset.TOP) {
|
|
781
|
-
|
|
780
|
+
offsetIndex = isRelative ? 0 : brothers.length;
|
|
782
781
|
} else if (offset === LayerOffset.BOTTOM) {
|
|
783
|
-
|
|
782
|
+
offsetIndex = isRelative ? brothers.length : 0;
|
|
784
783
|
} else {
|
|
785
|
-
|
|
784
|
+
offsetIndex = index + (isRelative ? -offset : offset);
|
|
786
785
|
}
|
|
787
786
|
|
|
787
|
+
if ((offsetIndex > 0 && offsetIndex > brothers.length) || offsetIndex < 0) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
brothers.splice(index, 1);
|
|
791
|
+
brothers.splice(offsetIndex, 0, node);
|
|
792
|
+
|
|
788
793
|
const grandparent = this.getParentById(parent.id);
|
|
794
|
+
|
|
789
795
|
this.get('stage')?.update({
|
|
790
796
|
config: cloneDeep(toRaw(parent)),
|
|
791
797
|
parentId: grandparent?.id,
|
|
@@ -794,6 +800,8 @@ class Editor extends BaseService {
|
|
|
794
800
|
|
|
795
801
|
this.addModifiedNodeId(parent.id);
|
|
796
802
|
this.pushHistoryState();
|
|
803
|
+
|
|
804
|
+
this.emit('move-layer', offset);
|
|
797
805
|
}
|
|
798
806
|
|
|
799
807
|
/**
|
package/src/services/props.ts
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
|
-
import { cloneDeep,
|
|
20
|
+
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
21
21
|
|
|
22
22
|
import { DepTargetType } from '@tmagic/dep';
|
|
23
23
|
import type { FormConfig } from '@tmagic/form';
|
|
24
24
|
import type { Id, MComponent, MNode } from '@tmagic/schema';
|
|
25
|
-
import { guid, toLine } from '@tmagic/utils';
|
|
25
|
+
import { getValueByKeyPath, guid, setValueByKeyPath, toLine } from '@tmagic/utils';
|
|
26
26
|
|
|
27
27
|
import depService from '@editor/services/dep';
|
|
28
28
|
import editorService from '@editor/services/editor';
|
|
@@ -194,17 +194,22 @@ class Props extends BaseService {
|
|
|
194
194
|
public replaceRelateId(originConfigs: MNode[], targetConfigs: MNode[]) {
|
|
195
195
|
const relateIdMap = this.getRelateIdMap();
|
|
196
196
|
if (Object.keys(relateIdMap).length === 0) return;
|
|
197
|
+
|
|
197
198
|
const target = depService.getTarget(DepTargetType.RELATED_COMP_WHEN_COPY, DepTargetType.RELATED_COMP_WHEN_COPY);
|
|
198
199
|
if (!target) return;
|
|
200
|
+
|
|
199
201
|
originConfigs.forEach((config: MNode) => {
|
|
200
202
|
const newId = relateIdMap[config.id];
|
|
201
203
|
const targetConfig = targetConfigs.find((targetConfig) => targetConfig.id === newId);
|
|
204
|
+
|
|
202
205
|
if (!targetConfig) return;
|
|
206
|
+
|
|
203
207
|
target.deps[config.id]?.keys?.forEach((fullKey) => {
|
|
204
|
-
const relateOriginId =
|
|
208
|
+
const relateOriginId = getValueByKeyPath(fullKey, config);
|
|
205
209
|
const relateTargetId = relateIdMap[relateOriginId];
|
|
206
210
|
if (!relateTargetId) return;
|
|
207
|
-
|
|
211
|
+
|
|
212
|
+
setValueByKeyPath(fullKey, relateTargetId, targetConfig);
|
|
208
213
|
});
|
|
209
214
|
});
|
|
210
215
|
}
|