1
0
mirror of synced 2026-04-03 06:28:35 +08:00

feat(editor, core): 支持直接绑定整个数据源对象

This commit is contained in:
roymondchen
2023-06-28 16:39:47 +08:00
parent 649720079a
commit 74c9deaa29
11 changed files with 185 additions and 30 deletions

View File

@@ -11,6 +11,10 @@ export const createCodeBlockTarget = (id: Id, codeBlock: CodeBlockContent) =>
id,
name: codeBlock.name,
isTarget: (key: string | number, value: any) => {
if (id === value) {
return true;
}
if (value?.hookType === HookType.CODE && !isEmpty(value.hookData)) {
const index = value.hookData.findIndex((item: HookData) => item.codeId === id);
return Boolean(index > -1);
@@ -25,5 +29,7 @@ export const createDataSourceTarget = (id: Id, ds: DataSourceSchema) =>
type: 'data-source',
id,
name: ds.title || `${id}`,
isTarget: (key: string | number, value: any) => typeof value === 'string' && value.includes(`${id}`),
isTarget: (key: string | number, value: any) =>
// 关联数据源对象或者在模板在使用数据源
(value.isBindDataSource && value.dataSourceId) || (typeof value === 'string' && value.includes(`${id}`)),
});