@tmagic/editor 1.3.0-alpha.12 → 1.3.0-alpha.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.js +80 -39
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +80 -39
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/fields/UISelect.vue +37 -6
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +15 -2
- package/src/services/codeBlock.ts +1 -1
- package/types/components/FunctionEditor.vue.d.ts +9 -9
- package/types/services/codeBlock.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.13",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/core": "^7.18.0",
|
|
48
48
|
"@element-plus/icons-vue": "^2.0.9",
|
|
49
|
-
"@tmagic/core": "1.3.0-alpha.
|
|
50
|
-
"@tmagic/design": "1.3.0-alpha.
|
|
51
|
-
"@tmagic/form": "1.3.0-alpha.
|
|
52
|
-
"@tmagic/schema": "1.3.0-alpha.
|
|
53
|
-
"@tmagic/stage": "1.3.0-alpha.
|
|
54
|
-
"@tmagic/table": "1.3.0-alpha.
|
|
55
|
-
"@tmagic/utils": "1.3.0-alpha.
|
|
49
|
+
"@tmagic/core": "1.3.0-alpha.13",
|
|
50
|
+
"@tmagic/design": "1.3.0-alpha.13",
|
|
51
|
+
"@tmagic/form": "1.3.0-alpha.13",
|
|
52
|
+
"@tmagic/schema": "1.3.0-alpha.13",
|
|
53
|
+
"@tmagic/stage": "1.3.0-alpha.13",
|
|
54
|
+
"@tmagic/table": "1.3.0-alpha.13",
|
|
55
|
+
"@tmagic/utils": "1.3.0-alpha.13",
|
|
56
56
|
"buffer": "^6.0.3",
|
|
57
57
|
"color": "^3.1.3",
|
|
58
58
|
"events": "^3.3.0",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"vue": "^3.3.4"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@tmagic/design": "1.3.0-alpha.
|
|
68
|
-
"@tmagic/form": "1.3.0-alpha.
|
|
67
|
+
"@tmagic/design": "1.3.0-alpha.13",
|
|
68
|
+
"@tmagic/form": "1.3.0-alpha.13",
|
|
69
69
|
"monaco-editor": "^0.39.0",
|
|
70
70
|
"vue": "^3.3.4"
|
|
71
71
|
},
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -2,12 +2,26 @@
|
|
|
2
2
|
<div class="m-fields-ui-select" v-if="uiSelectMode" @click="cancelHandler">
|
|
3
3
|
<TMagicButton type="danger" :icon="Delete" text style="padding: 0">取消</TMagicButton>
|
|
4
4
|
</div>
|
|
5
|
-
<div class="m-fields-ui-select" v-else
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
<div class="m-fields-ui-select" v-else style="display: flex">
|
|
6
|
+
<template v-if="val">
|
|
7
|
+
<TMagicTooltip content="清除" placement="top">
|
|
8
|
+
<TMagicButton style="padding: 0" type="danger" :icon="Close" text @click.stop="deleteHandler"></TMagicButton>
|
|
9
|
+
</TMagicTooltip>
|
|
10
|
+
|
|
11
|
+
<TMagicTooltip content="点击选中组件" placement="top">
|
|
12
|
+
<TMagicButton
|
|
13
|
+
text
|
|
14
|
+
style="padding: 0; margin: 0"
|
|
15
|
+
@click="selectNode(val)"
|
|
16
|
+
@mouseenter="highlight(val)"
|
|
17
|
+
@mouseleave="unhightlight"
|
|
18
|
+
>{{ `${toName}_${val}` }}</TMagicButton
|
|
19
|
+
>
|
|
20
|
+
</TMagicTooltip>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<TMagicTooltip v-else content="点击此处选择" placement="top">
|
|
24
|
+
<TMagicButton text style="padding: 0; margin: 0" @click="startSelect">点击此处选择</TMagicButton>
|
|
11
25
|
</TMagicTooltip>
|
|
12
26
|
</div>
|
|
13
27
|
</template>
|
|
@@ -15,9 +29,11 @@
|
|
|
15
29
|
<script lang="ts" setup>
|
|
16
30
|
import { computed, inject, ref } from 'vue';
|
|
17
31
|
import { Close, Delete } from '@element-plus/icons-vue';
|
|
32
|
+
import { throttle } from 'lodash-es';
|
|
18
33
|
|
|
19
34
|
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
20
35
|
import { FormState } from '@tmagic/form';
|
|
36
|
+
import type { Id } from '@tmagic/schema';
|
|
21
37
|
|
|
22
38
|
import type { Services } from '@editor/type';
|
|
23
39
|
|
|
@@ -77,6 +93,21 @@ const deleteHandler = () => {
|
|
|
77
93
|
mForm?.$emit('field-change', props.prop, '');
|
|
78
94
|
}
|
|
79
95
|
};
|
|
96
|
+
|
|
97
|
+
const selectNode = async (id: Id) => {
|
|
98
|
+
await services?.editorService.select(id);
|
|
99
|
+
services?.editorService.get('stage')?.select(id);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const highlight = throttle((id: Id) => {
|
|
103
|
+
services?.editorService.highlight(id);
|
|
104
|
+
services?.editorService.get('stage')?.highlight(id);
|
|
105
|
+
}, 150);
|
|
106
|
+
|
|
107
|
+
const unhightlight = () => {
|
|
108
|
+
services?.editorService.set('highlightNode', null);
|
|
109
|
+
services?.editorService.get('stage')?.clearHighlight();
|
|
110
|
+
};
|
|
80
111
|
</script>
|
|
81
112
|
|
|
82
113
|
<style lang="scss">
|
|
@@ -59,7 +59,14 @@
|
|
|
59
59
|
import { computed, inject, ref } from 'vue';
|
|
60
60
|
import { Close, Edit, View } from '@element-plus/icons-vue';
|
|
61
61
|
|
|
62
|
-
import {
|
|
62
|
+
import {
|
|
63
|
+
TMagicButton,
|
|
64
|
+
tMagicMessage,
|
|
65
|
+
tMagicMessageBox,
|
|
66
|
+
TMagicScrollbar,
|
|
67
|
+
TMagicTooltip,
|
|
68
|
+
TMagicTree,
|
|
69
|
+
} from '@tmagic/design';
|
|
63
70
|
import { ColumnConfig } from '@tmagic/form';
|
|
64
71
|
import { CodeBlockContent, Id } from '@tmagic/schema';
|
|
65
72
|
|
|
@@ -141,11 +148,17 @@ const editCode = async (key: Id) => {
|
|
|
141
148
|
};
|
|
142
149
|
|
|
143
150
|
// 删除代码块
|
|
144
|
-
const deleteCode = (key: Id) => {
|
|
151
|
+
const deleteCode = async (key: Id) => {
|
|
145
152
|
const currentCode = codeList.value.find((codeItem) => codeItem.id === key);
|
|
146
153
|
const existBinds = Boolean(currentCode?.children.length);
|
|
147
154
|
const undeleteableList = codeBlockService?.getUndeletableList() || [];
|
|
148
155
|
if (!existBinds && !undeleteableList.includes(key)) {
|
|
156
|
+
await tMagicMessageBox.confirm('确定删除该代码块吗?', '提示', {
|
|
157
|
+
confirmButtonText: '确定',
|
|
158
|
+
cancelButtonText: '取消',
|
|
159
|
+
type: 'warning',
|
|
160
|
+
});
|
|
161
|
+
|
|
149
162
|
// 无绑定关系,且不在不可删除列表中
|
|
150
163
|
codeBlockService?.deleteCodeDslByIds([key]);
|
|
151
164
|
} else {
|
|
@@ -86,7 +86,7 @@ class CodeBlock extends BaseService {
|
|
|
86
86
|
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
87
87
|
* @returns {void}
|
|
88
88
|
*/
|
|
89
|
-
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
|
89
|
+
public async setCodeDslById(id: Id, codeConfig: Partial<CodeBlockContent>): Promise<void> {
|
|
90
90
|
const codeDsl = this.getCodeDsl();
|
|
91
91
|
|
|
92
92
|
if (!codeDsl) {
|
|
@@ -70,9 +70,9 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
70
70
|
class?: unknown;
|
|
71
71
|
style?: unknown;
|
|
72
72
|
readonly id: Id;
|
|
73
|
+
readonly content: string;
|
|
73
74
|
readonly language?: string | undefined;
|
|
74
75
|
readonly codeOptions?: Object | undefined;
|
|
75
|
-
readonly content: string;
|
|
76
76
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
77
77
|
onSaveAndClose?: ((...args: any[]) => any) | undefined;
|
|
78
78
|
};
|
|
@@ -98,16 +98,16 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
98
98
|
type: import("vue").PropType<boolean>;
|
|
99
99
|
default: boolean;
|
|
100
100
|
};
|
|
101
|
+
content: {
|
|
102
|
+
type: import("vue").PropType<string>;
|
|
103
|
+
required: true;
|
|
104
|
+
};
|
|
101
105
|
language: {
|
|
102
106
|
type: import("vue").PropType<string>;
|
|
103
107
|
};
|
|
104
108
|
codeOptions: {
|
|
105
109
|
type: import("vue").PropType<Object>;
|
|
106
110
|
};
|
|
107
|
-
content: {
|
|
108
|
-
type: import("vue").PropType<string>;
|
|
109
|
-
required: true;
|
|
110
|
-
};
|
|
111
111
|
autoSaveDraft: {
|
|
112
112
|
type: import("vue").PropType<boolean>;
|
|
113
113
|
default: boolean;
|
|
@@ -151,16 +151,16 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
151
151
|
type: import("vue").PropType<boolean>;
|
|
152
152
|
default: boolean;
|
|
153
153
|
};
|
|
154
|
+
content: {
|
|
155
|
+
type: import("vue").PropType<string>;
|
|
156
|
+
required: true;
|
|
157
|
+
};
|
|
154
158
|
language: {
|
|
155
159
|
type: import("vue").PropType<string>;
|
|
156
160
|
};
|
|
157
161
|
codeOptions: {
|
|
158
162
|
type: import("vue").PropType<Object>;
|
|
159
163
|
};
|
|
160
|
-
content: {
|
|
161
|
-
type: import("vue").PropType<string>;
|
|
162
|
-
required: true;
|
|
163
|
-
};
|
|
164
164
|
autoSaveDraft: {
|
|
165
165
|
type: import("vue").PropType<boolean>;
|
|
166
166
|
default: boolean;
|
|
@@ -28,7 +28,7 @@ declare class CodeBlock extends BaseService {
|
|
|
28
28
|
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
29
29
|
* @returns {void}
|
|
30
30
|
*/
|
|
31
|
-
setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void>;
|
|
31
|
+
setCodeDslById(id: Id, codeConfig: Partial<CodeBlockContent>): Promise<void>;
|
|
32
32
|
/**
|
|
33
33
|
* 根据代码块id数组获取代码dsl
|
|
34
34
|
* @param {string[]} ids 代码块id数组
|