@tmagic/editor 1.5.13 → 1.5.14
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 +124 -116
- package/dist/tmagic-editor.umd.cjs +124 -116
- package/package.json +7 -7
- package/src/Editor.vue +4 -20
- package/src/components/CodeBlockEditor.vue +1 -1
- package/src/components/FloatingBox.vue +1 -1
- package/src/components/ScrollBar.vue +9 -3
- package/src/components/SearchInput.vue +1 -1
- package/src/components/Tree.vue +3 -3
- package/src/components/TreeNode.vue +3 -3
- package/src/fields/CodeSelect.vue +5 -7
- package/src/fields/CodeSelectCol.vue +9 -5
- package/src/fields/DataSourceFields.vue +4 -2
- package/src/fields/DataSourceInput.vue +7 -3
- package/src/fields/DataSourceMethodSelect.vue +17 -6
- package/src/fields/DataSourceMethods.vue +3 -3
- package/src/fields/EventSelect.vue +3 -2
- package/src/fields/UISelect.vue +2 -2
- package/src/hooks/use-code-block-edit.ts +1 -1
- package/src/index.ts +0 -1
- package/src/initService.ts +75 -65
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/page-bar/PageBar.vue +1 -1
- package/src/layouts/props-panel/FormPanel.vue +2 -2
- package/src/layouts/props-panel/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +1 -1
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +4 -5
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +12 -13
- package/src/layouts/workspace/viewer/Stage.vue +1 -1
- package/src/services/BaseService.ts +1 -0
- package/src/services/editor.ts +4 -3
- package/src/type.ts +9 -0
- package/src/utils/props.ts +9 -7
- package/types/index.d.ts +57 -55
|
@@ -121,24 +121,28 @@ const selectConfig = {
|
|
|
121
121
|
}
|
|
122
122
|
return [];
|
|
123
123
|
},
|
|
124
|
-
onChange: (formState: any, codeId: Id, { model }: any) => {
|
|
124
|
+
onChange: (formState: any, codeId: Id, { setModel, model }: any) => {
|
|
125
125
|
// 通过下拉框选择的codeId变化后修正model的值,避免写入其他codeId的params
|
|
126
126
|
paramsConfig.value = getParamItemsConfig(codeId);
|
|
127
127
|
|
|
128
128
|
if (paramsConfig.value.length) {
|
|
129
|
-
|
|
129
|
+
setModel('params', createValues(formState, paramsConfig.value, {}, model.params));
|
|
130
130
|
} else {
|
|
131
|
-
|
|
131
|
+
setModel('params', {});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
return codeId;
|
|
135
135
|
},
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
const onCodeIdChangeHandler = (value: any) => {
|
|
138
|
+
const onCodeIdChangeHandler = (value: any, eventData: ContainerChangeEventData) => {
|
|
139
139
|
props.model.params = value.params;
|
|
140
|
+
|
|
140
141
|
emit('change', props.model, {
|
|
141
|
-
changeRecords:
|
|
142
|
+
changeRecords: eventData.changeRecords?.map((item) => ({
|
|
143
|
+
prop: `${props.prop.replace(props.name, '')}${item.propPath}`,
|
|
144
|
+
value: item.value,
|
|
145
|
+
})) || [
|
|
142
146
|
{
|
|
143
147
|
propPath: props.prop,
|
|
144
148
|
value: value[props.name],
|
|
@@ -65,6 +65,7 @@ import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
|
65
65
|
import { useEditorContentHeight } from '@editor/hooks';
|
|
66
66
|
import { useNextFloatBoxPosition } from '@editor/hooks/use-next-float-box-position';
|
|
67
67
|
import { useServices } from '@editor/hooks/use-services';
|
|
68
|
+
import { error } from '@editor/utils/logger';
|
|
68
69
|
|
|
69
70
|
defineOptions({
|
|
70
71
|
name: 'MFieldsDataSourceFields',
|
|
@@ -144,6 +145,7 @@ const fieldColumns: ColumnConfig[] = [
|
|
|
144
145
|
try {
|
|
145
146
|
return JSON.stringify(row.defaultValue);
|
|
146
147
|
} catch (e) {
|
|
148
|
+
error(e);
|
|
147
149
|
return row.defaultValue;
|
|
148
150
|
}
|
|
149
151
|
},
|
|
@@ -193,9 +195,9 @@ const dataSourceFieldsConfig: FormConfig = [
|
|
|
193
195
|
{ text: 'null', value: 'null' },
|
|
194
196
|
{ text: 'any', value: 'any' },
|
|
195
197
|
],
|
|
196
|
-
onChange: (
|
|
198
|
+
onChange: (_formState, v: string, { setModel }) => {
|
|
197
199
|
if (!['any', 'array', 'object'].includes(v)) {
|
|
198
|
-
|
|
200
|
+
setModel('fields', []);
|
|
199
201
|
}
|
|
200
202
|
return v;
|
|
201
203
|
},
|
|
@@ -179,7 +179,11 @@ const curCharIsDot = (dotIndex: number) => dotIndex > -1 && dotIndex === getSele
|
|
|
179
179
|
* @param leftCurlyBracketIndex 左大括号字符索引
|
|
180
180
|
* @param cb 建议的方法
|
|
181
181
|
*/
|
|
182
|
-
const dsQuerySearch = (
|
|
182
|
+
const dsQuerySearch = (
|
|
183
|
+
queryString: string,
|
|
184
|
+
leftCurlyBracketIndex: number,
|
|
185
|
+
cb: (_data: { value: string }[]) => void,
|
|
186
|
+
) => {
|
|
183
187
|
let result: DataSourceSchema[] = [];
|
|
184
188
|
|
|
185
189
|
if (curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
|
|
@@ -211,7 +215,7 @@ const fieldQuerySearch = (
|
|
|
211
215
|
queryString: string,
|
|
212
216
|
leftAngleIndex: number,
|
|
213
217
|
dotIndex: number,
|
|
214
|
-
cb: (
|
|
218
|
+
cb: (_data: { value: string }[]) => void,
|
|
215
219
|
) => {
|
|
216
220
|
let result: DataSchema[] = [];
|
|
217
221
|
|
|
@@ -272,7 +276,7 @@ const fieldQuerySearch = (
|
|
|
272
276
|
* @param queryString 当前输入框内的字符串
|
|
273
277
|
* @param cb 建议回调
|
|
274
278
|
*/
|
|
275
|
-
const querySearch = (queryString: string, cb: (
|
|
279
|
+
const querySearch = (queryString: string, cb: (_data: { value: string }[]) => void) => {
|
|
276
280
|
inputText = queryString;
|
|
277
281
|
|
|
278
282
|
const selectionStart = getSelectionStart();
|
|
@@ -37,7 +37,14 @@ import { Edit, View } from '@element-plus/icons-vue';
|
|
|
37
37
|
|
|
38
38
|
import type { Id } from '@tmagic/core';
|
|
39
39
|
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
createValues,
|
|
42
|
+
type FieldProps,
|
|
43
|
+
filterFunction,
|
|
44
|
+
type FormState,
|
|
45
|
+
MContainer,
|
|
46
|
+
type OnChangeHandlerData,
|
|
47
|
+
} from '@tmagic/form';
|
|
41
48
|
|
|
42
49
|
import CodeParams from '@editor/components/CodeParams.vue';
|
|
43
50
|
import MIcon from '@editor/components/Icon.vue';
|
|
@@ -92,14 +99,18 @@ const getParamItemsConfig = ([dataSourceId, methodName]: [Id, string] = ['', '']
|
|
|
92
99
|
|
|
93
100
|
const paramsConfig = ref<CodeParamStatement[]>(getParamItemsConfig(props.model[props.name || 'dataSourceMethod']));
|
|
94
101
|
|
|
95
|
-
const setParamsConfig = (
|
|
102
|
+
const setParamsConfig = (
|
|
103
|
+
dataSourceMethod: [Id, string],
|
|
104
|
+
formState: any = {},
|
|
105
|
+
setModel: OnChangeHandlerData['setModel'],
|
|
106
|
+
) => {
|
|
96
107
|
// 通过下拉框选择的codeId变化后修正model的值,避免写入其他codeId的params
|
|
97
108
|
paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
|
|
98
109
|
|
|
99
110
|
if (paramsConfig.value.length) {
|
|
100
|
-
|
|
111
|
+
setModel('params', createValues(formState, paramsConfig.value, {}, props.model.params));
|
|
101
112
|
} else {
|
|
102
|
-
|
|
113
|
+
setModel('params', {});
|
|
103
114
|
}
|
|
104
115
|
};
|
|
105
116
|
|
|
@@ -125,8 +136,8 @@ const cascaderConfig = computed(() => ({
|
|
|
125
136
|
name: props.name,
|
|
126
137
|
options: methodsOptions.value,
|
|
127
138
|
disable: props.disabled,
|
|
128
|
-
onChange: (formState: any, dataSourceMethod: [Id, string]) => {
|
|
129
|
-
setParamsConfig(dataSourceMethod, formState);
|
|
139
|
+
onChange: (formState: any, dataSourceMethod: [Id, string], { setModel }: OnChangeHandlerData) => {
|
|
140
|
+
setParamsConfig(dataSourceMethod, formState, setModel);
|
|
130
141
|
|
|
131
142
|
return dataSourceMethod;
|
|
132
143
|
},
|
|
@@ -80,7 +80,7 @@ const methodColumns: ColumnConfig[] = [
|
|
|
80
80
|
{
|
|
81
81
|
text: '编辑',
|
|
82
82
|
handler: (method: CodeBlockContent, index: number) => {
|
|
83
|
-
let codeContent = method.content ||
|
|
83
|
+
let codeContent = method.content || '({ params, dataSource, app }) => {\n // place your code here\n}';
|
|
84
84
|
|
|
85
85
|
if (typeof codeContent !== 'string') {
|
|
86
86
|
codeContent = codeContent.toString();
|
|
@@ -114,7 +114,7 @@ const methodColumns: ColumnConfig[] = [
|
|
|
114
114
|
const createCodeHandler = () => {
|
|
115
115
|
codeConfig.value = {
|
|
116
116
|
name: '',
|
|
117
|
-
content:
|
|
117
|
+
content: '({ params, dataSource, app, flowState }) => {\n // place your code here\n}',
|
|
118
118
|
params: [],
|
|
119
119
|
};
|
|
120
120
|
|
|
@@ -130,7 +130,7 @@ const submitCodeHandler = (value: CodeBlockContent, data: ContainerChangeEventDa
|
|
|
130
130
|
// 在保存的时候转换代码内容
|
|
131
131
|
const parseDSL = getEditorConfig('parseDSL');
|
|
132
132
|
if (typeof value.content === 'string') {
|
|
133
|
-
value.content = parseDSL<(...
|
|
133
|
+
value.content = parseDSL<(..._args: any[]) => any>(value.content);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
if (editIndex > -1) {
|
|
@@ -63,6 +63,7 @@ import type {
|
|
|
63
63
|
ContainerChangeEventData,
|
|
64
64
|
FieldProps,
|
|
65
65
|
FormState,
|
|
66
|
+
OnChangeHandlerData,
|
|
66
67
|
PanelConfig,
|
|
67
68
|
} from '@tmagic/form';
|
|
68
69
|
import { MContainer as MFormContainer, MPanel } from '@tmagic/form';
|
|
@@ -202,8 +203,8 @@ const targetCompConfig = computed(() => {
|
|
|
202
203
|
text: '联动组件',
|
|
203
204
|
type: 'ui-select',
|
|
204
205
|
display: (mForm: FormState, { model }: { model: Record<any, any> }) => model.actionType === ActionType.COMP,
|
|
205
|
-
onChange: (MForm: FormState, v: string, {
|
|
206
|
-
|
|
206
|
+
onChange: (MForm: FormState, v: string, { setModel }: OnChangeHandlerData) => {
|
|
207
|
+
setModel('method', '');
|
|
207
208
|
return v;
|
|
208
209
|
},
|
|
209
210
|
};
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -70,7 +70,7 @@ const uiSelectMode = ref(false);
|
|
|
70
70
|
const cancelHandler = () => {
|
|
71
71
|
uiService.set('uiSelectMode', false);
|
|
72
72
|
uiSelectMode.value = false;
|
|
73
|
-
globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler as
|
|
73
|
+
globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler as any);
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
const clickHandler = ({ detail }: Event & { detail: HTMLElement | MNode }) => {
|
|
@@ -97,7 +97,7 @@ const toName = computed(() => {
|
|
|
97
97
|
const startSelect = () => {
|
|
98
98
|
uiService.set('uiSelectMode', true);
|
|
99
99
|
uiSelectMode.value = true;
|
|
100
|
-
globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler as
|
|
100
|
+
globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler as any);
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
const deleteHandler = () => {
|
|
@@ -16,7 +16,7 @@ export const useCodeBlockEdit = (codeBlockService: Services['codeBlockService'])
|
|
|
16
16
|
const createCodeBlock = async () => {
|
|
17
17
|
codeConfig.value = {
|
|
18
18
|
name: '',
|
|
19
|
-
content:
|
|
19
|
+
content: '({app, params, flowState}) => {\n // place your code here\n}',
|
|
20
20
|
params: [],
|
|
21
21
|
};
|
|
22
22
|
|
package/src/index.ts
CHANGED
package/src/initService.ts
CHANGED
|
@@ -269,13 +269,13 @@ export const initServiceEvents = (
|
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
|
|
272
|
-
const dsDepCollectedHandler =
|
|
272
|
+
const dsDepCollectedHandler = () => {
|
|
273
273
|
const root = editorService.get('root');
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
274
|
+
getTMagicApp()?.then((app?: TMagicCore) => {
|
|
275
|
+
if (root && app?.dsl) {
|
|
276
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
279
|
};
|
|
280
280
|
|
|
281
281
|
const collectIdle = (nodes: MComponent[], deep: boolean, type?: DepTargetType) =>
|
|
@@ -317,7 +317,7 @@ export const initServiceEvents = (
|
|
|
317
317
|
depService.addTarget(createDataSourceCondTarget(ds, reactive({})));
|
|
318
318
|
};
|
|
319
319
|
|
|
320
|
-
const rootChangeHandler =
|
|
320
|
+
const rootChangeHandler = (value: MApp | null, preValue?: MApp | null) => {
|
|
321
321
|
if (!value) return;
|
|
322
322
|
|
|
323
323
|
value.codeBlocks = value.codeBlocks || {};
|
|
@@ -347,39 +347,40 @@ export const initServiceEvents = (
|
|
|
347
347
|
delete value.dataSourceCondDeps;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
350
|
+
const handler = async () => {
|
|
351
|
+
const nodeId = editorService.get('node')?.id || props.defaultSelected;
|
|
352
|
+
let node;
|
|
353
|
+
if (nodeId) {
|
|
354
|
+
node = editorService.getNodeById(nodeId);
|
|
355
|
+
}
|
|
356
|
+
if (node && node !== value) {
|
|
357
|
+
await editorService.select(node.id);
|
|
358
|
+
} else if (value.items?.length) {
|
|
359
|
+
await editorService.select(value.items[0]);
|
|
360
|
+
} else if (value.id) {
|
|
361
|
+
editorService.set('nodes', [value]);
|
|
362
|
+
editorService.set('parent', null);
|
|
363
|
+
editorService.set('page', null);
|
|
364
|
+
}
|
|
355
365
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
} else if (value.id) {
|
|
361
|
-
editorService.set('nodes', [value]);
|
|
362
|
-
editorService.set('parent', null);
|
|
363
|
-
editorService.set('page', null);
|
|
364
|
-
}
|
|
366
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
367
|
+
emit('update:modelValue', value);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
365
370
|
|
|
366
|
-
|
|
367
|
-
emit('update:modelValue', value);
|
|
368
|
-
}
|
|
371
|
+
handler();
|
|
369
372
|
};
|
|
370
373
|
|
|
371
374
|
// 新增节点,收集依赖
|
|
372
|
-
const nodeAddHandler =
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
const nodeAddHandler = (nodes: MComponent[]) => {
|
|
376
|
+
collectIdle(nodes, true).then(() => {
|
|
377
|
+
updateStageNodes(nodes);
|
|
378
|
+
});
|
|
376
379
|
};
|
|
377
380
|
|
|
378
381
|
// 节点更新,收集依赖
|
|
379
382
|
// 仅当修改到数据源相关的才收集
|
|
380
|
-
const nodeUpdateHandler =
|
|
381
|
-
data: { newNode: MComponent; oldNode: MComponent; changeRecords?: ChangeRecord[] }[],
|
|
382
|
-
) => {
|
|
383
|
+
const nodeUpdateHandler = (data: { newNode: MComponent; oldNode: MComponent; changeRecords?: ChangeRecord[] }[]) => {
|
|
383
384
|
const needRecollectNodes: MComponent[] = [];
|
|
384
385
|
const normalNodes: MComponent[] = [];
|
|
385
386
|
for (const { newNode, oldNode, changeRecords } of data) {
|
|
@@ -424,9 +425,12 @@ export const initServiceEvents = (
|
|
|
424
425
|
|
|
425
426
|
if (needRecollectNodes.length) {
|
|
426
427
|
// 有数据源依赖,需要等依赖重新收集完才更新stage
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
const handler = async () => {
|
|
429
|
+
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE);
|
|
430
|
+
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE_COND);
|
|
431
|
+
updateStageNodes(needRecollectNodes);
|
|
432
|
+
};
|
|
433
|
+
handler();
|
|
430
434
|
} else {
|
|
431
435
|
updateStageNodes(normalNodes);
|
|
432
436
|
// 在上面判断是否需要收集数据源依赖中已经更新stage
|
|
@@ -443,9 +447,10 @@ export const initServiceEvents = (
|
|
|
443
447
|
};
|
|
444
448
|
|
|
445
449
|
// 由于历史记录变化是更新整个page,所以历史记录变化时,需要重新收集依赖
|
|
446
|
-
const historyChangeHandler =
|
|
447
|
-
|
|
448
|
-
|
|
450
|
+
const historyChangeHandler = (page: MPage | MPageFragment) => {
|
|
451
|
+
collectIdle([page], true).then(() => {
|
|
452
|
+
updateStageNode(page);
|
|
453
|
+
});
|
|
449
454
|
};
|
|
450
455
|
|
|
451
456
|
editorService.on('history-change', historyChangeHandler);
|
|
@@ -454,27 +459,28 @@ export const initServiceEvents = (
|
|
|
454
459
|
editorService.on('remove', nodeRemoveHandler);
|
|
455
460
|
editorService.on('update', nodeUpdateHandler);
|
|
456
461
|
|
|
457
|
-
const dataSourceAddHandler =
|
|
458
|
-
|
|
459
|
-
|
|
462
|
+
const dataSourceAddHandler = (config: DataSourceSchema) => {
|
|
463
|
+
const handler = async () => {
|
|
464
|
+
initDataSourceDepTarget(config);
|
|
465
|
+
const app = await getTMagicApp();
|
|
460
466
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
467
|
+
if (!app?.dataSourceManager) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
464
470
|
|
|
465
|
-
|
|
471
|
+
app.dataSourceManager.addDataSource(config);
|
|
466
472
|
|
|
467
|
-
|
|
473
|
+
const newDs = app.dataSourceManager.get(config.id);
|
|
468
474
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
475
|
+
if (newDs) {
|
|
476
|
+
app.dataSourceManager.init(newDs);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
handler();
|
|
472
481
|
};
|
|
473
482
|
|
|
474
|
-
const dataSourceUpdateHandler =
|
|
475
|
-
config: DataSourceSchema,
|
|
476
|
-
{ changeRecords }: { changeRecords: ChangeRecord[] },
|
|
477
|
-
) => {
|
|
483
|
+
const dataSourceUpdateHandler = (config: DataSourceSchema, { changeRecords }: { changeRecords: ChangeRecord[] }) => {
|
|
478
484
|
const updateDsData = async () => {
|
|
479
485
|
const app = await getTMagicApp();
|
|
480
486
|
|
|
@@ -565,29 +571,33 @@ export const initServiceEvents = (
|
|
|
565
571
|
depService.removeTarget(id, DepTargetType.DATA_SOURCE_METHOD);
|
|
566
572
|
};
|
|
567
573
|
|
|
568
|
-
const dataSourceRemoveHandler =
|
|
574
|
+
const dataSourceRemoveHandler = (id: string) => {
|
|
569
575
|
const root = editorService.get('root');
|
|
570
576
|
|
|
571
577
|
if (!root) {
|
|
572
578
|
return;
|
|
573
579
|
}
|
|
574
580
|
|
|
575
|
-
const
|
|
576
|
-
|
|
581
|
+
const handler = async () => {
|
|
582
|
+
const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
|
|
583
|
+
const nodes = getNodes(nodeIds, root.items);
|
|
577
584
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
585
|
+
await Promise.all([
|
|
586
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE),
|
|
587
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_COND),
|
|
588
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_METHOD),
|
|
589
|
+
]);
|
|
583
590
|
|
|
584
|
-
|
|
591
|
+
updateDataSourceSchema();
|
|
585
592
|
|
|
586
|
-
|
|
587
|
-
|
|
593
|
+
const app = await getTMagicApp();
|
|
594
|
+
app?.dataSourceManager?.removeDataSource(id);
|
|
595
|
+
|
|
596
|
+
updateStageNodes(nodes);
|
|
597
|
+
removeDataSourceTarget(id);
|
|
598
|
+
};
|
|
588
599
|
|
|
589
|
-
|
|
590
|
-
removeDataSourceTarget(id);
|
|
600
|
+
handler();
|
|
591
601
|
};
|
|
592
602
|
|
|
593
603
|
dataSourceService.on('add', dataSourceAddHandler);
|
|
@@ -91,7 +91,7 @@ defineOptions({
|
|
|
91
91
|
defineProps<{
|
|
92
92
|
disabledPageFragment: boolean;
|
|
93
93
|
pageBarSortOptions?: PageBarSortOptions;
|
|
94
|
-
pageFilterFunction?: (
|
|
94
|
+
pageFilterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
|
|
95
95
|
}>();
|
|
96
96
|
|
|
97
97
|
const codeOptions = inject('codeOptions', {});
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -69,7 +69,7 @@ const getConfig = (item: MenuItem): (MenuButton | MenuComponent)[] => {
|
|
|
69
69
|
type: 'button',
|
|
70
70
|
className: 'delete',
|
|
71
71
|
icon: markRaw(Delete),
|
|
72
|
-
tooltip:
|
|
72
|
+
tooltip: '刪除(Delete)',
|
|
73
73
|
disabled: () => editorService.get('node')?.type === NodeType.PAGE,
|
|
74
74
|
handler: () => {
|
|
75
75
|
const node = editorService.get('node');
|
|
@@ -91,7 +91,7 @@ const props = withDefaults(
|
|
|
91
91
|
defineProps<{
|
|
92
92
|
disabledPageFragment: boolean;
|
|
93
93
|
pageBarSortOptions?: PageBarSortOptions;
|
|
94
|
-
filterFunction?: (
|
|
94
|
+
filterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
|
|
95
95
|
}>(),
|
|
96
96
|
{
|
|
97
97
|
filterFunction: (page, keyword) => page.name?.includes(keyword) || `${page.id}`.includes(keyword),
|
|
@@ -56,7 +56,7 @@ import { useServices } from '@editor/hooks/use-services';
|
|
|
56
56
|
import CodeEditor from '../CodeEditor.vue';
|
|
57
57
|
|
|
58
58
|
defineSlots<{
|
|
59
|
-
'props-form-panel-header'(
|
|
59
|
+
'props-form-panel-header'(_props: {}): any;
|
|
60
60
|
}>();
|
|
61
61
|
|
|
62
62
|
defineOptions({
|
|
@@ -70,7 +70,7 @@ const props = defineProps<{
|
|
|
70
70
|
labelWidth?: string;
|
|
71
71
|
codeValueKey?: string;
|
|
72
72
|
labelPosition?: string;
|
|
73
|
-
extendState?: (
|
|
73
|
+
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
74
74
|
}>();
|
|
75
75
|
|
|
76
76
|
const emit = defineEmits<{
|
|
@@ -82,7 +82,7 @@ defineOptions({
|
|
|
82
82
|
|
|
83
83
|
defineProps<{
|
|
84
84
|
disabledShowSrc?: boolean;
|
|
85
|
-
extendState?: (
|
|
85
|
+
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
86
86
|
}>();
|
|
87
87
|
|
|
88
88
|
const emit = defineEmits<{
|
|
@@ -55,7 +55,7 @@ defineOptions({
|
|
|
55
55
|
const props = defineProps<{
|
|
56
56
|
indent?: number;
|
|
57
57
|
nextLevelIndentIncrement?: number;
|
|
58
|
-
customError?: (
|
|
58
|
+
customError?: (_id: Id, _errorType: CodeDeleteErrorType) => any;
|
|
59
59
|
}>();
|
|
60
60
|
|
|
61
61
|
const emit = defineEmits<{
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
:content="codeConfig"
|
|
34
34
|
@submit="submitCodeBlockHandler"
|
|
35
35
|
@close="editDialogCloseHandler"
|
|
36
|
-
@open="editDialogOpenHandler"
|
|
37
36
|
></CodeBlockEditor>
|
|
38
37
|
|
|
39
38
|
<Teleport to="body">
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
</template>
|
|
49
48
|
|
|
50
49
|
<script setup lang="ts">
|
|
51
|
-
import { computed, inject, useTemplateRef } from 'vue';
|
|
50
|
+
import { computed, inject, useTemplateRef, watch } from 'vue';
|
|
52
51
|
|
|
53
52
|
import type { Id } from '@tmagic/core';
|
|
54
53
|
import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
|
|
@@ -79,7 +78,7 @@ defineOptions({
|
|
|
79
78
|
const props = defineProps<{
|
|
80
79
|
indent?: number;
|
|
81
80
|
nextLevelIndentIncrement?: number;
|
|
82
|
-
customError?: (
|
|
81
|
+
customError?: (_id: Id, _errorType: CodeDeleteErrorType) => any;
|
|
83
82
|
customContentMenu: CustomContentMenuFunction;
|
|
84
83
|
}>();
|
|
85
84
|
|
|
@@ -102,13 +101,13 @@ eventBus?.on('edit-code', (id: string) => {
|
|
|
102
101
|
editCode(id);
|
|
103
102
|
});
|
|
104
103
|
|
|
105
|
-
|
|
104
|
+
watch(codeId, () => {
|
|
106
105
|
if (codeBlockListRef.value) {
|
|
107
106
|
for (const [statusId, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
|
|
108
107
|
status.selected = statusId === codeId.value;
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
|
-
};
|
|
110
|
+
});
|
|
112
111
|
|
|
113
112
|
const editDialogCloseHandler = () => {
|
|
114
113
|
if (codeBlockListRef.value) {
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
:title="dialogTitle"
|
|
47
47
|
@submit="submitDataSourceHandler"
|
|
48
48
|
@close="editDialogCloseHandler"
|
|
49
|
-
@open="editDialogOpenHandler"
|
|
50
49
|
></DataSourceConfigPanel>
|
|
51
50
|
|
|
52
51
|
<Teleport to="body">
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
</template>
|
|
62
61
|
|
|
63
62
|
<script setup lang="ts">
|
|
64
|
-
import { computed, inject,
|
|
63
|
+
import { computed, inject, useTemplateRef, watch } from 'vue';
|
|
65
64
|
import { mergeWith } from 'lodash-es';
|
|
66
65
|
|
|
67
66
|
import { TMagicButton, tMagicMessageBox, TMagicPopover, TMagicScrollbar } from '@tmagic/design';
|
|
@@ -95,21 +94,21 @@ const { dataSourceService } = useServices();
|
|
|
95
94
|
const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } =
|
|
96
95
|
useDataSourceEdit(dataSourceService);
|
|
97
96
|
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
for (const [
|
|
101
|
-
status.selected =
|
|
97
|
+
const editDialogCloseHandler = () => {
|
|
98
|
+
if (dataSourceListRef.value) {
|
|
99
|
+
for (const [, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
100
|
+
status.selected = false;
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
};
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
for (const [, status] of
|
|
109
|
-
status.selected =
|
|
105
|
+
watch(dataSourceValues, (dataSourceValues) => {
|
|
106
|
+
if (dataSourceListRef.value && dataSourceValues.id) {
|
|
107
|
+
for (const [statusId, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
108
|
+
status.selected = statusId === dataSourceValues.id;
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
|
-
};
|
|
111
|
+
});
|
|
113
112
|
|
|
114
113
|
const datasourceTypeList = computed(() =>
|
|
115
114
|
[
|
|
@@ -148,10 +147,10 @@ const removeHandler = async (id: string) => {
|
|
|
148
147
|
dataSourceService.remove(id);
|
|
149
148
|
};
|
|
150
149
|
|
|
151
|
-
const
|
|
150
|
+
const dataSourceListRef = useTemplateRef<InstanceType<typeof DataSourceList>>('dataSourceList');
|
|
152
151
|
|
|
153
152
|
const filterTextChangeHandler = (val: string) => {
|
|
154
|
-
|
|
153
|
+
dataSourceListRef.value?.filter(val);
|
|
155
154
|
};
|
|
156
155
|
|
|
157
156
|
eventBus?.on('edit-data-source', (id: string) => {
|
|
@@ -149,7 +149,7 @@ watch(zoom, (zoom) => {
|
|
|
149
149
|
stage.setZoom(zoom);
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
let timeoutId:
|
|
152
|
+
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
153
153
|
watch(page, (page) => {
|
|
154
154
|
if (runtime && page) {
|
|
155
155
|
editorService.set('stageLoading', true);
|
package/src/services/editor.ts
CHANGED
|
@@ -1088,10 +1088,11 @@ class Editor extends BaseService {
|
|
|
1088
1088
|
this.isHistoryStateChange = true;
|
|
1089
1089
|
await this.update(value.data);
|
|
1090
1090
|
this.set('modifiedNodeIds', value.modifiedNodeIds);
|
|
1091
|
-
setTimeout(
|
|
1091
|
+
setTimeout(() => {
|
|
1092
1092
|
if (!value.nodeId) return;
|
|
1093
|
-
|
|
1094
|
-
|
|
1093
|
+
this.select(value.nodeId).then(() => {
|
|
1094
|
+
this.get('stage')?.select(value.nodeId);
|
|
1095
|
+
});
|
|
1095
1096
|
}, 0);
|
|
1096
1097
|
this.emit('history-change', value.data);
|
|
1097
1098
|
}
|