fix: issue with Markdown string templates not loading data of association variable (#5791)

* fix: issue with Markdown string templates not loading data of association variables

* fix: bug
This commit is contained in:
Katherine 2024-12-09 19:35:00 +08:00 committed by GitHub
parent df055e0b8e
commit bda94f9c1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 2 deletions

View File

@ -155,7 +155,7 @@ export const MarkdownVoid: any = withDynamicSchemaProps(
engine, engine,
content, content,
compile(variables), compile(variables),
compile(localVariables), compile(JSON.parse(JSON.stringify(localVariables))),
parseMarkdown, parseMarkdown,
); );
setHtml(replacedContent); setHtml(replacedContent);

View File

@ -190,6 +190,7 @@ export async function getRenderContent(templateEngine, content, variables, local
const html = await replaceVariableValue(content, variables, localVariables); const html = await replaceVariableValue(content, variables, localVariables);
return await defaultParse(html); return await defaultParse(html);
} catch (error) { } catch (error) {
console.log(error);
return content; return content;
} }
} }

View File

@ -117,7 +117,7 @@ const VariablesProvider = ({ children, filterVariables }: any) => {
const key = list[index]; const key = list[index];
const { fieldPath } = getFieldPath(list.slice(0, index + 1).join('.'), _variableToCollectionName); const { fieldPath } = getFieldPath(list.slice(0, index + 1).join('.'), _variableToCollectionName);
const associationField: CollectionFieldOptions_deprecated = getCollectionJoinField(fieldPath, dataSource); const associationField: CollectionFieldOptions_deprecated = getCollectionJoinField(fieldPath, dataSource);
const collectionPrimaryKey = getCollection(collectionName)?.getPrimaryKey(); const collectionPrimaryKey = getCollection(collectionName, dataSource)?.getPrimaryKey();
if (Array.isArray(current)) { if (Array.isArray(current)) {
const result = current.map((item) => { const result = current.map((item) => {
if (!options?.doNotRequest && shouldToRequest(item?.[key]) && item?.[collectionPrimaryKey] != null) { if (!options?.doNotRequest && shouldToRequest(item?.[key]) && item?.[collectionPrimaryKey] != null) {

View File

@ -96,6 +96,7 @@ const useLocalVariables = (props?: Props) => {
name: '$nRecord', name: '$nRecord',
ctx: currentRecordCtx, ctx: currentRecordCtx,
collectionName: collectionNameOfRecord, collectionName: collectionNameOfRecord,
dataSource: currentParentRecordDataSource,
}, },
{ {
name: '$nParentRecord', name: '$nParentRecord',