Skip to content

Commit 0626177

Browse files
authored
Merge pull request #522 from Harbour-Enterprises/nick/add-final-doc-flag-sd
Add isFinalDoc flag in SuperDoc export
2 parents ed94a8e + c13007f commit 0626177

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

examples/vue-fields-example/src/App.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ const addField = (field) => {
115115
}
116116
117117
const exportDocx = () => {
118-
superdoc.value?.export();
118+
superdoc.value?.export({ isFinalDoc: true });
119+
120+
// Or use superdoc.value?.export({ isFinalDoc: true });
121+
// If you want to fully remove all fields and replace them with their values
122+
119123
};
120124
121125
const onDragStart = (event) => {

packages/superdoc/src/core/SuperDoc.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,12 @@ export class SuperDoc extends EventEmitter {
567567
commentsType,
568568
exportedName,
569569
additionalFiles = [],
570-
additionalFileNames = []
570+
additionalFileNames = [],
571+
isFinalDoc = false,
571572
} = {}) {
572573
// Get the docx files first
573574
const baseFileName = exportedName ? cleanName(exportedName) : cleanName(this.config.title);
574-
const docxFiles = await this.exportEditorsToDOCX({ commentsType });
575+
const docxFiles = await this.exportEditorsToDOCX({ commentsType, isFinalDoc });
575576
const blobsToZip = [...additionalFiles];
576577
const filenames = [...additionalFileNames];
577578

@@ -592,7 +593,7 @@ export class SuperDoc extends EventEmitter {
592593
}
593594
};
594595

595-
async exportEditorsToDOCX({ commentsType } = {}) {
596+
async exportEditorsToDOCX({ commentsType, isFinalDoc } = {}) {
596597
const comments = [];
597598
if (commentsType !== 'clean') {
598599
comments.push(...this.commentsStore?.translateCommentsForExport());
@@ -602,7 +603,7 @@ export class SuperDoc extends EventEmitter {
602603
this.superdocStore.documents.forEach((doc) => {
603604
const editor = doc.getEditor();
604605
if (editor) {
605-
docxPromises.push(editor.exportDocx({ comments, commentsType }));
606+
docxPromises.push(editor.exportDocx({ isFinalDoc, comments, commentsType }));
606607
}
607608
});
608609
return await Promise.all(docxPromises);

0 commit comments

Comments
 (0)