From 0d5ad2bcedc65ac04a1c5bebe6ed03a3c78b6635 Mon Sep 17 00:00:00 2001 From: Mohammad Betamony Date: Tue, 17 Jun 2025 14:21:23 +0300 Subject: [PATCH 1/3] LEAN-4643: add ability to change citation style --- src/DomainServices/ProjectService.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/DomainServices/ProjectService.ts b/src/DomainServices/ProjectService.ts index 85340f0e..195f4f57 100644 --- a/src/DomainServices/ProjectService.ts +++ b/src/DomainServices/ProjectService.ts @@ -95,11 +95,7 @@ export class ProjectService { const jats = await this.convert(file.path) const now = Math.round(Date.now() / 1000) - const { node, journal } = parseJATSArticle( - jats, - JSON.parse(template).sectionCategories, - templateID - ) + const { node, journal } = parseJATSArticle(jats, template) const manuscriptModel = { _id: node.attrs.id, @@ -370,18 +366,26 @@ export class ProjectService { : AuthorityService.removeSuggestions( (await this.documentClient.findDocument(manuscriptID)).doc as JSONProsemirrorNode ) - const options = await this.getExportJatsOptions(projectID, article.attrs.prototype) + const options = await this.getExportJatsOptions( + projectID, + article.attrs.prototype, + article.attrs.citationStyle + ) return new JATSExporter().serializeToJATS(schema.nodeFromJSON(article), options) } - private async getExportJatsOptions(projectID: string, templateID: string) { + private async getExportJatsOptions( + projectID: string, + templateID: string, + citationStyle?: string + ) { const projectModels = (await this.getProjectModels(projectID)) || [] const journal = projectModels.find((m) => m.objectType === ObjectTypes.Journal) const template = await this.configService.getDocument(templateID) if (!template) { throw new ValidationError('manuscript template is empty', templateID) } - const style = await this.citationStyleFromTemplate(template) + const style = citationStyle ?? (await this.citationStyleFromTemplate(template)) const locale = await this.configService.getDocument(DEFAULT_LOCALE) if (!locale || !style) { throw new RecordNotFoundError('locale or style not found') From 1c349c5ae63fc794fdd9582ee64d69b1a9fa8dfc Mon Sep 17 00:00:00 2001 From: Mohammad Betamony Date: Tue, 17 Jun 2025 14:23:36 +0300 Subject: [PATCH 2/3] LEAN-4643: add ability to change citation style --- src/DomainServices/ProjectService.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/DomainServices/ProjectService.ts b/src/DomainServices/ProjectService.ts index 195f4f57..6d4485f9 100644 --- a/src/DomainServices/ProjectService.ts +++ b/src/DomainServices/ProjectService.ts @@ -95,8 +95,11 @@ export class ProjectService { const jats = await this.convert(file.path) const now = Math.round(Date.now() / 1000) - const { node, journal } = parseJATSArticle(jats, template) - + const { node, journal } = parseJATSArticle( + jats, + JSON.parse(template).sectionCategories, + templateID + ) const manuscriptModel = { _id: node.attrs.id, objectType: ObjectTypes.Manuscript, From 3b3fc4cdcc9dd45858765c8cd68aa44ff97109b9 Mon Sep 17 00:00:00 2001 From: Mohammad Betamony Date: Tue, 17 Jun 2025 14:24:00 +0300 Subject: [PATCH 3/3] LEAN-4643: add ability to change citation style --- src/DomainServices/ProjectService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DomainServices/ProjectService.ts b/src/DomainServices/ProjectService.ts index 6d4485f9..4c6c42d4 100644 --- a/src/DomainServices/ProjectService.ts +++ b/src/DomainServices/ProjectService.ts @@ -100,6 +100,7 @@ export class ProjectService { JSON.parse(template).sectionCategories, templateID ) + const manuscriptModel = { _id: node.attrs.id, objectType: ObjectTypes.Manuscript,