Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/DomainServices/ProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,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')
Expand Down