@tmagic/editor 1.3.0-alpha.21 → 1.3.0-alpha.22
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/style.css +7 -0
- package/dist/tmagic-editor.js +89 -54
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +88 -53
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/fields/DataSourceFields.vue +9 -2
- package/src/fields/DataSourceInput.vue +4 -1
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +1 -0
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +40 -6
- package/src/services/dataSource.ts +1 -1
- package/src/theme/data-source.scss +11 -0
- package/src/utils/data-source/formConfigs/base.ts +2 -9
- package/src/utils/data-source/index.ts +8 -14
- package/types/fields/DataSourceFields.vue.d.ts +1 -1
- package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +1 -0
- package/types/utils/data-source/formConfigs/base.d.ts +1 -2
- package/types/utils/data-source/index.d.ts +1 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.22",
|
|
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.22",
|
|
50
|
+
"@tmagic/design": "1.3.0-alpha.22",
|
|
51
|
+
"@tmagic/form": "1.3.0-alpha.22",
|
|
52
|
+
"@tmagic/schema": "1.3.0-alpha.22",
|
|
53
|
+
"@tmagic/stage": "1.3.0-alpha.22",
|
|
54
|
+
"@tmagic/table": "1.3.0-alpha.22",
|
|
55
|
+
"@tmagic/utils": "1.3.0-alpha.22",
|
|
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.22",
|
|
68
|
+
"@tmagic/form": "1.3.0-alpha.22",
|
|
69
69
|
"monaco-editor": "^0.41.0",
|
|
70
70
|
"vue": "^3.3.4"
|
|
71
71
|
},
|
|
@@ -14,18 +14,21 @@
|
|
|
14
14
|
:values="fieldValues"
|
|
15
15
|
:parentValues="model[name]"
|
|
16
16
|
:disabled="disabled"
|
|
17
|
+
:width="width"
|
|
17
18
|
@submit="fieldChange"
|
|
18
19
|
></MFormDrawer>
|
|
19
20
|
</div>
|
|
20
21
|
</template>
|
|
21
22
|
|
|
22
23
|
<script setup lang="ts">
|
|
23
|
-
import { ref } from 'vue';
|
|
24
|
+
import { computed, inject, ref } from 'vue';
|
|
24
25
|
|
|
25
26
|
import { TMagicButton, tMagicMessageBox } from '@tmagic/design';
|
|
26
|
-
import { FieldProps, FormConfig, FormState, MFormDrawer } from '@tmagic/form';
|
|
27
|
+
import { type FieldProps, type FormConfig, type FormState, MFormDrawer } from '@tmagic/form';
|
|
27
28
|
import { MagicTable } from '@tmagic/table';
|
|
28
29
|
|
|
30
|
+
import type { Services } from '@editor/type';
|
|
31
|
+
|
|
29
32
|
defineOptions({
|
|
30
33
|
name: 'MEditorDataSourceFields',
|
|
31
34
|
});
|
|
@@ -43,10 +46,14 @@ const props = withDefaults(
|
|
|
43
46
|
|
|
44
47
|
const emit = defineEmits(['change']);
|
|
45
48
|
|
|
49
|
+
const services = inject<Services>('services');
|
|
50
|
+
|
|
46
51
|
const addDialog = ref<InstanceType<typeof MFormDrawer>>();
|
|
47
52
|
const fieldValues = ref<Record<string, any>>({});
|
|
48
53
|
const filedTitle = ref('');
|
|
49
54
|
|
|
55
|
+
const width = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get('columnWidth').left || 0));
|
|
56
|
+
|
|
50
57
|
const newHandler = () => {
|
|
51
58
|
fieldValues.value = {};
|
|
52
59
|
filedTitle.value = '新增属性';
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"
|
|
17
17
|
style="width: 100%"
|
|
18
18
|
@blur="blurHandler"
|
|
19
|
-
@change="changeHandler"
|
|
20
19
|
@input="inputHandler"
|
|
21
20
|
@select="selectHandler"
|
|
22
21
|
>
|
|
@@ -111,6 +110,8 @@ const blurHandler = () => {
|
|
|
111
110
|
isFocused.value = false;
|
|
112
111
|
|
|
113
112
|
setDisplayState();
|
|
113
|
+
|
|
114
|
+
emit('change', state.value);
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
const changeHandler = (v: string) => {
|
|
@@ -314,5 +315,7 @@ const selectHandler = async ({ value, type }: { value: string; type: 'dataSource
|
|
|
314
315
|
newSelectionStart = dotIndex + suggestText.length + 1;
|
|
315
316
|
}
|
|
316
317
|
input.value?.setSelectionRange(newSelectionStart, newSelectionStart);
|
|
318
|
+
|
|
319
|
+
changeHandler(state.value);
|
|
317
320
|
};
|
|
318
321
|
</script>
|
|
@@ -2,7 +2,24 @@
|
|
|
2
2
|
<TMagicScrollbar class="data-source-list-panel m-editor-dep-list-panel">
|
|
3
3
|
<div class="search-wrapper">
|
|
4
4
|
<SearchInput @search="filterTextChangeHandler"></SearchInput>
|
|
5
|
-
<
|
|
5
|
+
<TMagicPopover v-if="editable" placement="right">
|
|
6
|
+
<template #reference>
|
|
7
|
+
<TMagicButton type="primary" size="small">新增</TMagicButton>
|
|
8
|
+
</template>
|
|
9
|
+
<div class="data-source-list-panel-add-menu">
|
|
10
|
+
<ToolButton
|
|
11
|
+
v-for="(item, index) in datasourceTypeList"
|
|
12
|
+
:data="{
|
|
13
|
+
type: 'button',
|
|
14
|
+
text: item.text,
|
|
15
|
+
handler: () => {
|
|
16
|
+
addHandler(item.type);
|
|
17
|
+
},
|
|
18
|
+
}"
|
|
19
|
+
:key="index"
|
|
20
|
+
></ToolButton>
|
|
21
|
+
</div>
|
|
22
|
+
</TMagicPopover>
|
|
6
23
|
</div>
|
|
7
24
|
|
|
8
25
|
<!-- 数据源列表 -->
|
|
@@ -12,7 +29,7 @@
|
|
|
12
29
|
ref="editDialog"
|
|
13
30
|
:disabled="!editable"
|
|
14
31
|
:values="dataSourceValues"
|
|
15
|
-
:title="
|
|
32
|
+
:title="dialogTitle"
|
|
16
33
|
@submit="submitDataSourceHandler"
|
|
17
34
|
></DataSourceConfigPanel>
|
|
18
35
|
</TMagicScrollbar>
|
|
@@ -21,10 +38,11 @@
|
|
|
21
38
|
<script setup lang="ts" name="MEditorDataSourceListPanel">
|
|
22
39
|
import { computed, inject, ref } from 'vue';
|
|
23
40
|
|
|
24
|
-
import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
|
|
41
|
+
import { TMagicButton, TMagicPopover, TMagicScrollbar } from '@tmagic/design';
|
|
25
42
|
import type { DataSourceSchema } from '@tmagic/schema';
|
|
26
43
|
|
|
27
44
|
import SearchInput from '@editor/components/SearchInput.vue';
|
|
45
|
+
import ToolButton from '@editor/components/ToolButton.vue';
|
|
28
46
|
import type { Services } from '@editor/type';
|
|
29
47
|
|
|
30
48
|
import DataSourceConfigPanel from './DataSourceConfigPanel.vue';
|
|
@@ -40,12 +58,26 @@ const editDialog = ref<InstanceType<typeof DataSourceConfigPanel>>();
|
|
|
40
58
|
|
|
41
59
|
const dataSourceValues = ref<Record<string, any>>({});
|
|
42
60
|
|
|
43
|
-
const
|
|
61
|
+
const dialogTitle = ref('');
|
|
44
62
|
|
|
45
|
-
const
|
|
63
|
+
const editable = computed(() => dataSourceService?.get('editable') ?? true);
|
|
64
|
+
const datasourceTypeList = computed(() =>
|
|
65
|
+
[
|
|
66
|
+
{ text: '基础', type: 'base' },
|
|
67
|
+
{ text: 'HTTP', type: 'http' },
|
|
68
|
+
].concat(dataSourceService?.get('datasourceTypeList') ?? []),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const addHandler = (type: string) => {
|
|
46
72
|
if (!editDialog.value) return;
|
|
47
73
|
|
|
48
|
-
dataSourceValues.value = {
|
|
74
|
+
dataSourceValues.value = {
|
|
75
|
+
type,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const datasourceType = datasourceTypeList.value.find((item) => item.type === type);
|
|
79
|
+
|
|
80
|
+
dialogTitle.value = `新增${datasourceType?.text || ''}`;
|
|
49
81
|
|
|
50
82
|
editDialog.value.show();
|
|
51
83
|
};
|
|
@@ -57,6 +89,8 @@ const editHandler = (id: string) => {
|
|
|
57
89
|
...dataSourceService?.getDataSourceById(id),
|
|
58
90
|
};
|
|
59
91
|
|
|
92
|
+
dialogTitle.value = `新增${dataSourceValues.value.title || ''}`;
|
|
93
|
+
|
|
60
94
|
editDialog.value.show();
|
|
61
95
|
};
|
|
62
96
|
|
|
@@ -37,7 +37,7 @@ class DataSource extends BaseService {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
public getFormConfig(type = 'base') {
|
|
40
|
-
return getFormConfig(type, this.get('
|
|
40
|
+
return getFormConfig(type, this.get('configs'));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
public setFormConfig(type: string, config: FormConfig) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { FormConfig } from '@tmagic/form';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default function (datasourceTypeList: DatasourceTypeOption[] = []): FormConfig {
|
|
3
|
+
export default function (): FormConfig {
|
|
6
4
|
return [
|
|
7
5
|
{
|
|
8
6
|
name: 'id',
|
|
@@ -11,12 +9,7 @@ export default function (datasourceTypeList: DatasourceTypeOption[] = []): FormC
|
|
|
11
9
|
{
|
|
12
10
|
name: 'type',
|
|
13
11
|
text: '类型',
|
|
14
|
-
type: '
|
|
15
|
-
options: [
|
|
16
|
-
{ text: '基础', value: 'base' },
|
|
17
|
-
{ text: 'HTTP', value: 'http' },
|
|
18
|
-
...datasourceTypeList.map((item) => ({ text: item.text, value: item.type })),
|
|
19
|
-
],
|
|
12
|
+
type: 'hidden',
|
|
20
13
|
defaultValue: 'base',
|
|
21
14
|
},
|
|
22
15
|
{
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { FormConfig } from '@tmagic/form';
|
|
2
2
|
import { DataSchema, DataSourceSchema } from '@tmagic/schema';
|
|
3
3
|
|
|
4
|
-
import { DatasourceTypeOption } from '@editor/type';
|
|
5
|
-
|
|
6
4
|
import BaseFormConfig from './formConfigs/base';
|
|
7
5
|
import HttpFormConfig from './formConfigs/http';
|
|
8
6
|
|
|
9
|
-
const fillConfig = (config: FormConfig
|
|
10
|
-
...BaseFormConfig(
|
|
7
|
+
const fillConfig = (config: FormConfig): FormConfig => [
|
|
8
|
+
...BaseFormConfig(),
|
|
11
9
|
...config,
|
|
12
10
|
{
|
|
13
11
|
type: 'panel',
|
|
@@ -16,7 +14,7 @@ const fillConfig = (config: FormConfig, datasourceTypeList: DatasourceTypeOption
|
|
|
16
14
|
{
|
|
17
15
|
name: 'fields',
|
|
18
16
|
type: 'data-source-fields',
|
|
19
|
-
defaultValue: [],
|
|
17
|
+
defaultValue: () => [],
|
|
20
18
|
},
|
|
21
19
|
],
|
|
22
20
|
},
|
|
@@ -27,24 +25,20 @@ const fillConfig = (config: FormConfig, datasourceTypeList: DatasourceTypeOption
|
|
|
27
25
|
{
|
|
28
26
|
name: 'methods',
|
|
29
27
|
type: 'data-source-methods',
|
|
30
|
-
defaultValue: [],
|
|
28
|
+
defaultValue: () => [],
|
|
31
29
|
},
|
|
32
30
|
],
|
|
33
31
|
},
|
|
34
32
|
];
|
|
35
33
|
|
|
36
|
-
export const getFormConfig = (
|
|
37
|
-
type: string,
|
|
38
|
-
datasourceTypeList: DatasourceTypeOption[],
|
|
39
|
-
configs: Record<string, FormConfig>,
|
|
40
|
-
): FormConfig => {
|
|
34
|
+
export const getFormConfig = (type: string, configs: Record<string, FormConfig>): FormConfig => {
|
|
41
35
|
switch (type) {
|
|
42
36
|
case 'base':
|
|
43
|
-
return fillConfig([]
|
|
37
|
+
return fillConfig([]);
|
|
44
38
|
case 'http':
|
|
45
|
-
return fillConfig(HttpFormConfig
|
|
39
|
+
return fillConfig(HttpFormConfig);
|
|
46
40
|
default:
|
|
47
|
-
return fillConfig(configs[type] || []
|
|
41
|
+
return fillConfig(configs[type] || []);
|
|
48
42
|
}
|
|
49
43
|
};
|
|
50
44
|
|
|
@@ -6,6 +6,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
6
6
|
customError?: ((id: Id, errorType: CodeDeleteErrorType) => any) | undefined;
|
|
7
7
|
}>>>, {}, {}>, {
|
|
8
8
|
"code-block-panel-header"?(_: {}): any;
|
|
9
|
+
"code-block-panel-search"?(_: {}): any;
|
|
9
10
|
"code-block-panel-tool"?(_: {
|
|
10
11
|
id: any;
|
|
11
12
|
data: any;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FormConfig } from '@tmagic/form';
|
|
2
2
|
import { DataSourceSchema } from '@tmagic/schema';
|
|
3
|
-
|
|
4
|
-
export declare const getFormConfig: (type: string, datasourceTypeList: DatasourceTypeOption[], configs: Record<string, FormConfig>) => FormConfig;
|
|
3
|
+
export declare const getFormConfig: (type: string, configs: Record<string, FormConfig>) => FormConfig;
|
|
5
4
|
export declare const getDisplayField: (dataSources: DataSourceSchema[], key: string) => {
|
|
6
5
|
value: string;
|
|
7
6
|
type: 'var' | 'text';
|