@tmagic/editor 1.5.0-beta.9 → 1.5.1
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 → tmagic-editor.css} +228 -22
- package/dist/tmagic-editor.js +1670 -1012
- package/dist/tmagic-editor.umd.cjs +1705 -1048
- package/package.json +14 -12
- package/src/Editor.vue +24 -6
- package/src/components/CodeBlockEditor.vue +14 -8
- package/src/components/CodeParams.vue +5 -5
- package/src/components/ContentMenu.vue +18 -18
- package/src/components/FloatingBox.vue +3 -3
- package/src/components/Resizer.vue +4 -4
- package/src/components/ScrollBar.vue +3 -3
- package/src/components/ScrollViewer.vue +3 -3
- package/src/components/SplitView.vue +2 -2
- package/src/components/ToolButton.vue +2 -1
- package/src/editorProps.ts +6 -2
- package/src/fields/Code.vue +1 -2
- package/src/fields/CodeSelect.vue +13 -11
- package/src/fields/CodeSelectCol.vue +32 -5
- package/src/fields/CondOpSelect.vue +5 -2
- package/src/fields/DataSourceFields.vue +31 -12
- package/src/fields/DataSourceInput.vue +2 -2
- package/src/fields/DataSourceMethods.vue +72 -14
- package/src/fields/DataSourceMocks.vue +0 -1
- package/src/fields/DisplayConds.vue +8 -3
- package/src/fields/EventSelect.vue +28 -12
- package/src/fields/KeyValue.vue +17 -12
- package/src/fields/UISelect.vue +6 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-code-block-edit.ts +3 -3
- package/src/hooks/use-data-source-edit.ts +3 -2
- package/src/hooks/use-filter.ts +1 -1
- package/src/hooks/use-getso.ts +7 -7
- package/src/hooks/use-node-status.ts +2 -2
- package/src/index.ts +2 -1
- package/src/initService.ts +177 -74
- package/src/layouts/CodeEditor.vue +2 -2
- package/src/layouts/Framework.vue +13 -12
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/page-bar/AddButton.vue +29 -9
- package/src/layouts/page-bar/PageBar.vue +79 -66
- package/src/layouts/page-bar/PageBarScrollContainer.vue +84 -98
- package/src/layouts/page-bar/PageList.vue +5 -3
- package/src/layouts/page-bar/Search.vue +67 -0
- package/src/layouts/props-panel/FormPanel.vue +123 -0
- package/src/layouts/props-panel/PropsPanel.vue +146 -0
- package/src/layouts/props-panel/use-style-panel.ts +29 -0
- package/src/layouts/sidebar/Sidebar.vue +7 -1
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +18 -2
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +35 -4
- package/src/layouts/sidebar/code-block/useContentMenu.ts +83 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +7 -5
- package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -8
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +40 -4
- package/src/layouts/sidebar/data-source/useContentMenu.ts +81 -0
- package/src/layouts/sidebar/layer/LayerMenu.vue +7 -13
- package/src/layouts/sidebar/layer/LayerPanel.vue +11 -4
- package/src/layouts/sidebar/layer/use-click.ts +2 -2
- package/src/layouts/sidebar/layer/use-keybinding.ts +2 -2
- package/src/layouts/sidebar/layer/use-node-status.ts +2 -3
- package/src/layouts/workspace/Workspace.vue +13 -3
- package/src/layouts/workspace/viewer/NodeListMenu.vue +3 -3
- package/src/layouts/workspace/viewer/Stage.vue +41 -11
- package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
- package/src/layouts/workspace/viewer/ViewerMenu.vue +4 -6
- package/src/services/dataSource.ts +12 -5
- package/src/services/dep.ts +61 -13
- package/src/services/editor.ts +46 -51
- package/src/services/storage.ts +2 -1
- package/src/services/ui.ts +1 -0
- package/src/theme/common/var.scss +12 -10
- package/src/theme/component-list-panel.scss +9 -7
- package/src/theme/content-menu.scss +7 -5
- package/src/theme/data-source.scss +3 -1
- package/src/theme/floating-box.scss +4 -2
- package/src/theme/framework.scss +7 -5
- package/src/theme/index.scss +4 -5
- package/src/theme/key-value.scss +2 -2
- package/src/theme/layer-panel.scss +3 -1
- package/src/theme/layout.scss +1 -1
- package/src/theme/nav-menu.scss +7 -5
- package/src/theme/page-bar.scss +51 -27
- package/src/theme/props-panel.scss +81 -1
- package/src/theme/resizer.scss +1 -1
- package/src/theme/search-input.scss +1 -0
- package/src/theme/sidebar.scss +4 -2
- package/src/theme/stage.scss +3 -1
- package/src/theme/theme.scss +28 -28
- package/src/theme/tree.scss +14 -12
- package/src/type.ts +10 -1
- package/src/utils/content-menu.ts +2 -2
- package/src/utils/data-source/formConfigs/http.ts +2 -0
- package/src/utils/data-source/index.ts +2 -2
- package/src/utils/editor.ts +78 -22
- package/src/utils/idle-task.ts +36 -4
- package/src/utils/props.ts +48 -6
- package/types/index.d.ts +2312 -2080
- package/src/hooks/use-data-source-method.ts +0 -100
- package/src/layouts/PropsPanel.vue +0 -131
- package/src/layouts/page-bar/SwitchTypeButton.vue +0 -45
|
@@ -51,7 +51,13 @@ import { inject, Ref, ref } from 'vue';
|
|
|
51
51
|
|
|
52
52
|
import type { DataSchema } from '@tmagic/core';
|
|
53
53
|
import { TMagicButton, tMagicMessage, tMagicMessageBox } from '@tmagic/design';
|
|
54
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
type ContainerChangeEventData,
|
|
56
|
+
type FieldProps,
|
|
57
|
+
type FormConfig,
|
|
58
|
+
type FormState,
|
|
59
|
+
MFormBox,
|
|
60
|
+
} from '@tmagic/form';
|
|
55
61
|
import { type ColumnConfig, MagicTable } from '@tmagic/table';
|
|
56
62
|
import { getDefaultValueFromFields } from '@tmagic/utils';
|
|
57
63
|
|
|
@@ -75,7 +81,9 @@ const props = withDefaults(
|
|
|
75
81
|
},
|
|
76
82
|
);
|
|
77
83
|
|
|
78
|
-
const emit = defineEmits
|
|
84
|
+
const emit = defineEmits<{
|
|
85
|
+
change: [v: any, eventData?: ContainerChangeEventData];
|
|
86
|
+
}>();
|
|
79
87
|
|
|
80
88
|
const services = inject<Services>('services');
|
|
81
89
|
|
|
@@ -91,16 +99,29 @@ const newHandler = () => {
|
|
|
91
99
|
addDialogVisible.value = true;
|
|
92
100
|
};
|
|
93
101
|
|
|
94
|
-
const fieldChange = ({ index, ...value }: Record<string, any
|
|
102
|
+
const fieldChange = ({ index, ...value }: Record<string, any>, data: ContainerChangeEventData) => {
|
|
103
|
+
addDialogVisible.value = false;
|
|
104
|
+
|
|
95
105
|
if (index > -1) {
|
|
96
|
-
|
|
106
|
+
emit('change', value, {
|
|
107
|
+
modifyKey: index,
|
|
108
|
+
changeRecords: (data.changeRecords || []).map((item) => ({
|
|
109
|
+
propPath: `${props.prop}.${index}.${item.propPath}`,
|
|
110
|
+
value: item.value,
|
|
111
|
+
})),
|
|
112
|
+
});
|
|
97
113
|
} else {
|
|
98
|
-
props.model[props.name].
|
|
114
|
+
const modifyKey = props.model[props.name].length;
|
|
115
|
+
emit('change', value, {
|
|
116
|
+
modifyKey,
|
|
117
|
+
changeRecords: [
|
|
118
|
+
{
|
|
119
|
+
propPath: `${props.prop}.${modifyKey}`,
|
|
120
|
+
value,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
});
|
|
99
124
|
}
|
|
100
|
-
|
|
101
|
-
addDialogVisible.value = false;
|
|
102
|
-
|
|
103
|
-
emit('change', props.model[props.name]);
|
|
104
125
|
};
|
|
105
126
|
|
|
106
127
|
const fieldColumns: ColumnConfig[] = [
|
|
@@ -310,11 +331,9 @@ const addFromJsonFromChange = ({ data }: { data: string }) => {
|
|
|
310
331
|
try {
|
|
311
332
|
const value = JSON.parse(data);
|
|
312
333
|
|
|
313
|
-
props.model[props.name] = getFieldsConfig(value, props.model[props.name]);
|
|
314
|
-
|
|
315
334
|
addFromJsonDialogVisible.value = false;
|
|
316
335
|
|
|
317
|
-
emit('change', props.model[props.name]);
|
|
336
|
+
emit('change', getFieldsConfig(value, props.model[props.name]));
|
|
318
337
|
} catch (e: any) {
|
|
319
338
|
tMagicMessage.error(e.message);
|
|
320
339
|
}
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</template>
|
|
49
49
|
|
|
50
50
|
<script setup lang="ts">
|
|
51
|
-
import { computed, inject, nextTick, ref, watch } from 'vue';
|
|
51
|
+
import { computed, inject, nextTick, ref, useTemplateRef, watch } from 'vue';
|
|
52
52
|
import { Coin } from '@element-plus/icons-vue';
|
|
53
53
|
|
|
54
54
|
import type { DataSchema, DataSourceSchema } from '@tmagic/core';
|
|
@@ -83,7 +83,7 @@ const emit = defineEmits<{
|
|
|
83
83
|
|
|
84
84
|
const { dataSourceService } = inject<Services>('services') || {};
|
|
85
85
|
|
|
86
|
-
const autocomplete =
|
|
86
|
+
const autocomplete = useTemplateRef<InstanceType<typeof TMagicAutocomplete>>('autocomplete');
|
|
87
87
|
const isFocused = ref(false);
|
|
88
88
|
const state = ref('');
|
|
89
89
|
const displayState = ref<{ value: string; type: 'var' | 'text' }[]>([]);
|
|
@@ -21,14 +21,17 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup lang="ts">
|
|
24
|
+
import { nextTick, ref, useTemplateRef } from 'vue';
|
|
25
|
+
import { cloneDeep } from 'lodash-es';
|
|
26
|
+
|
|
24
27
|
import type { CodeBlockContent } from '@tmagic/core';
|
|
25
|
-
import { TMagicButton } from '@tmagic/design';
|
|
26
|
-
import type { FieldProps } from '@tmagic/form';
|
|
28
|
+
import { TMagicButton, tMagicMessageBox } from '@tmagic/design';
|
|
29
|
+
import type { ContainerChangeEventData, FieldProps } from '@tmagic/form';
|
|
27
30
|
import { type ColumnConfig, MagicTable } from '@tmagic/table';
|
|
28
31
|
|
|
29
32
|
import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
|
|
30
|
-
import { useDataSourceMethod } from '@editor/hooks/use-data-source-method';
|
|
31
33
|
import type { CodeParamStatement } from '@editor/type';
|
|
34
|
+
import { getEditorConfig } from '@editor/utils/config';
|
|
32
35
|
|
|
33
36
|
defineOptions({
|
|
34
37
|
name: 'MFieldsDataSourceMethods',
|
|
@@ -47,7 +50,10 @@ const props = withDefaults(
|
|
|
47
50
|
|
|
48
51
|
const emit = defineEmits(['change']);
|
|
49
52
|
|
|
50
|
-
const
|
|
53
|
+
const codeConfig = ref<CodeBlockContent>();
|
|
54
|
+
const codeBlockEditor = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
|
55
|
+
|
|
56
|
+
let editIndex = -1;
|
|
51
57
|
|
|
52
58
|
const methodColumns: ColumnConfig[] = [
|
|
53
59
|
{
|
|
@@ -73,16 +79,31 @@ const methodColumns: ColumnConfig[] = [
|
|
|
73
79
|
actions: [
|
|
74
80
|
{
|
|
75
81
|
text: '编辑',
|
|
76
|
-
handler: (
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
handler: (method: CodeBlockContent, index: number) => {
|
|
83
|
+
let codeContent = method.content || `({ params, dataSource, app }) => {\n // place your code here\n}`;
|
|
84
|
+
|
|
85
|
+
if (typeof codeContent !== 'string') {
|
|
86
|
+
codeContent = codeContent.toString();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
codeConfig.value = {
|
|
90
|
+
...cloneDeep(method),
|
|
91
|
+
content: codeContent,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
editIndex = index;
|
|
95
|
+
|
|
96
|
+
nextTick(() => {
|
|
97
|
+
codeBlockEditor.value?.show();
|
|
98
|
+
});
|
|
79
99
|
},
|
|
80
100
|
},
|
|
81
101
|
{
|
|
82
102
|
text: '删除',
|
|
83
103
|
buttonType: 'danger',
|
|
84
|
-
handler: (row: CodeBlockContent) => {
|
|
85
|
-
|
|
104
|
+
handler: async (row: CodeBlockContent, index: number) => {
|
|
105
|
+
await tMagicMessageBox.confirm(`确定删除${row.name}?`, '提示');
|
|
106
|
+
props.model[props.name].splice(index, 1);
|
|
86
107
|
emit('change', props.model[props.name]);
|
|
87
108
|
},
|
|
88
109
|
},
|
|
@@ -91,14 +112,51 @@ const methodColumns: ColumnConfig[] = [
|
|
|
91
112
|
];
|
|
92
113
|
|
|
93
114
|
const createCodeHandler = () => {
|
|
94
|
-
|
|
115
|
+
codeConfig.value = {
|
|
116
|
+
name: '',
|
|
117
|
+
content: `({ params, dataSource, app, flowState }) => {\n // place your code here\n}`,
|
|
118
|
+
params: [],
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
editIndex = -1;
|
|
95
122
|
|
|
96
|
-
|
|
123
|
+
nextTick(() => {
|
|
124
|
+
codeBlockEditor.value?.show();
|
|
125
|
+
});
|
|
97
126
|
};
|
|
98
127
|
|
|
99
|
-
const submitCodeHandler = (
|
|
100
|
-
|
|
128
|
+
const submitCodeHandler = (value: CodeBlockContent, data: ContainerChangeEventData) => {
|
|
129
|
+
if (value.content) {
|
|
130
|
+
// 在保存的时候转换代码内容
|
|
131
|
+
const parseDSL = getEditorConfig('parseDSL');
|
|
132
|
+
if (typeof value.content === 'string') {
|
|
133
|
+
value.content = parseDSL<(...args: any[]) => any>(value.content);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (editIndex > -1) {
|
|
137
|
+
emit('change', value, {
|
|
138
|
+
modifyKey: editIndex,
|
|
139
|
+
changeRecords: (data.changeRecords || []).map((item) => ({
|
|
140
|
+
propPath: `${props.prop}.${editIndex}.${item.propPath}`,
|
|
141
|
+
value: item.value,
|
|
142
|
+
})),
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
const modifyKey = props.model[props.name].length;
|
|
146
|
+
emit('change', value, {
|
|
147
|
+
modifyKey,
|
|
148
|
+
changeRecords: [
|
|
149
|
+
{
|
|
150
|
+
propPath: `${props.prop}.${modifyKey}`,
|
|
151
|
+
value,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
editIndex = -1;
|
|
158
|
+
codeConfig.value = void 0;
|
|
101
159
|
|
|
102
|
-
|
|
160
|
+
codeBlockEditor.value?.hide();
|
|
103
161
|
};
|
|
104
162
|
</script>
|
|
@@ -17,6 +17,7 @@ import { computed, inject } from 'vue';
|
|
|
17
17
|
|
|
18
18
|
import type { DisplayCond } from '@tmagic/core';
|
|
19
19
|
import {
|
|
20
|
+
type ContainerChangeEventData,
|
|
20
21
|
type FieldProps,
|
|
21
22
|
type FilterFunction,
|
|
22
23
|
filterFunction,
|
|
@@ -33,7 +34,7 @@ defineOptions({
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
const emit = defineEmits<{
|
|
36
|
-
change: [value: DisplayCond[]];
|
|
37
|
+
change: [value: DisplayCond[], eventData?: ContainerChangeEventData];
|
|
37
38
|
}>();
|
|
38
39
|
|
|
39
40
|
const props = withDefaults(
|
|
@@ -149,7 +150,11 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
149
150
|
],
|
|
150
151
|
}));
|
|
151
152
|
|
|
152
|
-
const changeHandler = (v: DisplayCond[]) => {
|
|
153
|
-
|
|
153
|
+
const changeHandler = (v: DisplayCond[], eventData?: ContainerChangeEventData) => {
|
|
154
|
+
if (!Array.isArray(props.model[props.name])) {
|
|
155
|
+
props.model[props.name] = [];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
emit('change', v, eventData);
|
|
154
159
|
};
|
|
155
160
|
</script>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
<div class="m-fields-event-select">
|
|
3
3
|
<m-form-table
|
|
4
4
|
v-if="isOldVersion"
|
|
5
|
-
ref="eventForm"
|
|
6
5
|
name="events"
|
|
7
6
|
:size="size"
|
|
8
7
|
:disabled="disabled"
|
|
@@ -20,6 +19,7 @@
|
|
|
20
19
|
:key="index"
|
|
21
20
|
:disabled="disabled"
|
|
22
21
|
:size="size"
|
|
22
|
+
:prop="`${prop}.${index}`"
|
|
23
23
|
:config="actionsConfig"
|
|
24
24
|
:model="cardItem"
|
|
25
25
|
:label-width="config.labelWidth || '100px'"
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
:model="cardItem"
|
|
33
33
|
:disabled="disabled"
|
|
34
34
|
:size="size"
|
|
35
|
-
|
|
35
|
+
:prop="`${prop}.${index}`"
|
|
36
|
+
@change="eventNameChangeHandler"
|
|
36
37
|
></MFormContainer>
|
|
37
38
|
<TMagicButton
|
|
38
39
|
style="color: #f56c6c"
|
|
@@ -56,12 +57,19 @@ import { has } from 'lodash-es';
|
|
|
56
57
|
import type { EventOption, MComponent, MContainer } from '@tmagic/core';
|
|
57
58
|
import { ActionType } from '@tmagic/core';
|
|
58
59
|
import { TMagicButton } from '@tmagic/design';
|
|
59
|
-
import type {
|
|
60
|
+
import type {
|
|
61
|
+
CascaderOption,
|
|
62
|
+
ChildConfig,
|
|
63
|
+
ContainerChangeEventData,
|
|
64
|
+
FieldProps,
|
|
65
|
+
FormState,
|
|
66
|
+
PanelConfig,
|
|
67
|
+
} from '@tmagic/form';
|
|
60
68
|
import { MContainer as MFormContainer, MPanel } from '@tmagic/form';
|
|
61
|
-
import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX } from '@tmagic/utils';
|
|
69
|
+
import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, traverseNode } from '@tmagic/utils';
|
|
62
70
|
|
|
63
71
|
import type { CodeSelectColConfig, DataSourceMethodSelectConfig, EventSelectConfig, Services } from '@editor/type';
|
|
64
|
-
import { getCascaderOptionsFromFields
|
|
72
|
+
import { getCascaderOptionsFromFields } from '@editor/utils';
|
|
65
73
|
|
|
66
74
|
defineOptions({
|
|
67
75
|
name: 'MFieldsEventSelect',
|
|
@@ -69,7 +77,9 @@ defineOptions({
|
|
|
69
77
|
|
|
70
78
|
const props = defineProps<FieldProps<EventSelectConfig>>();
|
|
71
79
|
|
|
72
|
-
const emit = defineEmits
|
|
80
|
+
const emit = defineEmits<{
|
|
81
|
+
change: [v: any, eventData?: ContainerChangeEventData];
|
|
82
|
+
}>();
|
|
73
83
|
|
|
74
84
|
const services = inject<Services>('services');
|
|
75
85
|
|
|
@@ -108,7 +118,7 @@ const eventNameConfig = computed(() => {
|
|
|
108
118
|
if (pageFragment) {
|
|
109
119
|
events = [
|
|
110
120
|
{
|
|
111
|
-
label: pageFragment.name || '
|
|
121
|
+
label: pageFragment.name || '页面片容器',
|
|
112
122
|
value: pageFragment.id,
|
|
113
123
|
children: events,
|
|
114
124
|
},
|
|
@@ -355,21 +365,27 @@ const addEvent = () => {
|
|
|
355
365
|
name: '',
|
|
356
366
|
actions: [],
|
|
357
367
|
};
|
|
368
|
+
|
|
358
369
|
if (!props.model[props.name]) {
|
|
359
370
|
props.model[props.name] = [];
|
|
360
371
|
}
|
|
361
|
-
|
|
362
|
-
|
|
372
|
+
|
|
373
|
+
emit('change', defaultEvent, {
|
|
374
|
+
modifyKey: props.model[props.name].length,
|
|
375
|
+
});
|
|
363
376
|
};
|
|
364
377
|
|
|
365
378
|
// 删除事件
|
|
366
379
|
const removeEvent = (index: number) => {
|
|
367
380
|
if (!props.name) return;
|
|
368
381
|
props.model[props.name].splice(index, 1);
|
|
369
|
-
|
|
382
|
+
emit('change', props.model[props.name]);
|
|
370
383
|
};
|
|
371
384
|
|
|
372
|
-
const
|
|
373
|
-
emit('change', props.model);
|
|
385
|
+
const eventNameChangeHandler = (v: any, eventData: ContainerChangeEventData) => {
|
|
386
|
+
emit('change', props.model[props.name], eventData);
|
|
374
387
|
};
|
|
388
|
+
|
|
389
|
+
const onChangeHandler = (v: any, eventData: ContainerChangeEventData) =>
|
|
390
|
+
emit('change', props.model[props.name], eventData);
|
|
375
391
|
</script>
|
package/src/fields/KeyValue.vue
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
:size="size"
|
|
10
10
|
@change="keyChangeHandler"
|
|
11
11
|
></TMagicInput>
|
|
12
|
-
<span class="m-
|
|
12
|
+
<span class="m-fields-key-value-delimiter">:</span>
|
|
13
13
|
<TMagicInput
|
|
14
14
|
placeholder="value"
|
|
15
15
|
v-model="records[index][1]"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
></TMagicInput>
|
|
20
20
|
|
|
21
21
|
<TMagicButton
|
|
22
|
-
class="m-
|
|
22
|
+
class="m-fields-key-value-delete"
|
|
23
23
|
type="danger"
|
|
24
24
|
:size="size"
|
|
25
25
|
:disabled="disabled"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
v-if="config.advanced && showCode"
|
|
40
40
|
height="200px"
|
|
41
41
|
:init-values="model[name]"
|
|
42
|
-
language="
|
|
42
|
+
language="javascript"
|
|
43
43
|
:options="{
|
|
44
44
|
readOnly: disabled,
|
|
45
45
|
}"
|
|
@@ -86,22 +86,27 @@ const props = withDefaults(
|
|
|
86
86
|
},
|
|
87
87
|
);
|
|
88
88
|
|
|
89
|
-
const emit = defineEmits<
|
|
89
|
+
const emit = defineEmits<{
|
|
90
|
+
change: [value: Record<string, any>];
|
|
91
|
+
}>();
|
|
90
92
|
|
|
91
93
|
const records = ref<[string, string][]>([]);
|
|
92
94
|
const showCode = ref(false);
|
|
93
95
|
|
|
94
96
|
watchEffect(() => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
if (typeof props.model[props.name] === 'function') {
|
|
98
|
+
showCode.value = true;
|
|
99
|
+
} else {
|
|
100
|
+
const initValues: [string, any][] = Object.entries(props.model[props.name] || {});
|
|
101
|
+
|
|
102
|
+
for (const [, value] of initValues) {
|
|
103
|
+
if (typeof value !== 'string') {
|
|
104
|
+
showCode.value = true;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
101
107
|
}
|
|
108
|
+
records.value = initValues;
|
|
102
109
|
}
|
|
103
|
-
|
|
104
|
-
records.value = initValues;
|
|
105
110
|
});
|
|
106
111
|
|
|
107
112
|
const getValue = () => {
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -45,7 +45,7 @@ import { computed, inject, ref } from 'vue';
|
|
|
45
45
|
import { Close, Delete } from '@element-plus/icons-vue';
|
|
46
46
|
import { throttle } from 'lodash-es';
|
|
47
47
|
|
|
48
|
-
import type { Id } from '@tmagic/core';
|
|
48
|
+
import type { Id, MNode } from '@tmagic/core';
|
|
49
49
|
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
50
50
|
import type { FieldProps, FormItem, FormState } from '@tmagic/form';
|
|
51
51
|
import { getIdFromEl } from '@tmagic/utils';
|
|
@@ -72,8 +72,11 @@ const cancelHandler = () => {
|
|
|
72
72
|
globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler as EventListener);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
const clickHandler = ({ detail }: Event & { detail: HTMLElement }) => {
|
|
76
|
-
|
|
75
|
+
const clickHandler = ({ detail }: Event & { detail: HTMLElement | MNode }) => {
|
|
76
|
+
let { id } = detail;
|
|
77
|
+
if (detail.nodeType) {
|
|
78
|
+
id = getIdFromEl()(detail as HTMLElement) || id;
|
|
79
|
+
}
|
|
77
80
|
if (id) {
|
|
78
81
|
props.model[props.name] = id;
|
|
79
82
|
emit('change', id);
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nextTick, ref } from 'vue';
|
|
1
|
+
import { nextTick, ref, useTemplateRef } from 'vue';
|
|
2
2
|
import { cloneDeep } from 'lodash-es';
|
|
3
3
|
|
|
4
4
|
import type { CodeBlockContent } from '@tmagic/core';
|
|
@@ -10,7 +10,7 @@ import type { CodeBlockService } from '@editor/services/codeBlock';
|
|
|
10
10
|
export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
11
11
|
const codeConfig = ref<CodeBlockContent>();
|
|
12
12
|
const codeId = ref<string>();
|
|
13
|
-
const codeBlockEditor =
|
|
13
|
+
const codeBlockEditor = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
|
14
14
|
|
|
15
15
|
// 新增代码块
|
|
16
16
|
const createCodeBlock = async () => {
|
|
@@ -21,7 +21,7 @@ export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
|
21
21
|
|
|
22
22
|
codeConfig.value = {
|
|
23
23
|
name: '',
|
|
24
|
-
content: `({app, params}) => {\n // place your code here\n}`,
|
|
24
|
+
content: `({app, params, flowState}) => {\n // place your code here\n}`,
|
|
25
25
|
params: [],
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed, ref } from 'vue';
|
|
2
2
|
|
|
3
3
|
import type { DataSourceSchema } from '@tmagic/core';
|
|
4
|
+
import type { ContainerChangeEventData } from '@tmagic/form';
|
|
4
5
|
|
|
5
6
|
import DataSourceConfigPanel from '@editor/layouts/sidebar/data-source/DataSourceConfigPanel.vue';
|
|
6
7
|
import type { DataSourceService } from '@editor/services/dataSource';
|
|
@@ -24,9 +25,9 @@ export const useDataSourceEdit = (dataSourceService?: DataSourceService) => {
|
|
|
24
25
|
editDialog.value.show();
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
const submitDataSourceHandler = (value: DataSourceSchema) => {
|
|
28
|
+
const submitDataSourceHandler = (value: DataSourceSchema, eventData: ContainerChangeEventData) => {
|
|
28
29
|
if (value.id) {
|
|
29
|
-
dataSourceService?.update(value);
|
|
30
|
+
dataSourceService?.update(value, { changeRecords: eventData.changeRecords });
|
|
30
31
|
} else {
|
|
31
32
|
dataSourceService?.add(value);
|
|
32
33
|
}
|
package/src/hooks/use-filter.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Ref, ref } from 'vue';
|
|
2
2
|
|
|
3
3
|
import type { Id, MNode } from '@tmagic/core';
|
|
4
|
+
import { traverseNode } from '@tmagic/utils';
|
|
4
5
|
|
|
5
6
|
import type { LayerNodeStatus, TreeNodeData } from '@editor/type';
|
|
6
|
-
import { traverseNode } from '@editor/utils';
|
|
7
7
|
import { updateStatus } from '@editor/utils/tree';
|
|
8
8
|
|
|
9
9
|
export const useFilter = (
|
package/src/hooks/use-getso.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { onBeforeUnmount, onMounted, type
|
|
1
|
+
import { onBeforeUnmount, onMounted, ref, type ShallowRef } from 'vue';
|
|
2
2
|
import Gesto, { type OnDrag } from 'gesto';
|
|
3
3
|
|
|
4
|
-
export const useGetSo = (target:
|
|
4
|
+
export const useGetSo = (target: ShallowRef<HTMLElement | null>, emit: (evt: 'change', e: OnDrag<Gesto>) => void) => {
|
|
5
5
|
let getso: Gesto;
|
|
6
|
-
const
|
|
6
|
+
const isDragging = ref(false);
|
|
7
7
|
|
|
8
8
|
onMounted(() => {
|
|
9
9
|
if (!target.value) return;
|
|
@@ -17,19 +17,19 @@ export const useGetSo = (target: Ref<HTMLElement | undefined>, emit: (evt: 'chan
|
|
|
17
17
|
emit('change', e);
|
|
18
18
|
})
|
|
19
19
|
.on('dragStart', () => {
|
|
20
|
-
|
|
20
|
+
isDragging.value = true;
|
|
21
21
|
})
|
|
22
22
|
.on('dragEnd', () => {
|
|
23
|
-
|
|
23
|
+
isDragging.value = false;
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
onBeforeUnmount(() => {
|
|
28
28
|
getso?.unset();
|
|
29
|
-
|
|
29
|
+
isDragging.value = false;
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
|
-
|
|
33
|
+
isDragging,
|
|
34
34
|
};
|
|
35
35
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ComputedRef, ref, watch } from 'vue';
|
|
1
|
+
import { type ComputedRef, ref, watch } from 'vue';
|
|
2
2
|
|
|
3
3
|
import type { Id, MNode } from '@tmagic/core';
|
|
4
|
+
import { traverseNode } from '@tmagic/utils';
|
|
4
5
|
|
|
5
6
|
import { LayerNodeStatus, TreeNodeData } from '@editor/type';
|
|
6
|
-
import { traverseNode } from '@editor/utils';
|
|
7
7
|
|
|
8
8
|
const createPageNodeStatus = (nodeData: TreeNodeData[], initialLayerNodeStatus?: Map<Id, LayerNodeStatus>) => {
|
|
9
9
|
const map = new Map<Id, LayerNodeStatus>();
|
package/src/index.ts
CHANGED
|
@@ -91,7 +91,8 @@ export { default as KeyValue } from './fields/KeyValue.vue';
|
|
|
91
91
|
export { default as CodeBlockList } from './layouts/sidebar/code-block/CodeBlockList.vue';
|
|
92
92
|
export { default as CodeBlockListPanel } from './layouts/sidebar/code-block/CodeBlockListPanel.vue';
|
|
93
93
|
export { default as DataSourceConfigPanel } from './layouts/sidebar/data-source/DataSourceConfigPanel.vue';
|
|
94
|
-
export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
94
|
+
export { default as PropsPanel } from './layouts/props-panel/PropsPanel.vue';
|
|
95
|
+
export { default as PropsFormPanel } from './layouts/props-panel/FormPanel.vue';
|
|
95
96
|
export { default as ToolButton } from './components/ToolButton.vue';
|
|
96
97
|
export { default as ContentMenu } from './components/ContentMenu.vue';
|
|
97
98
|
export { default as Icon } from './components/Icon.vue';
|