Skip to content

SD-1525 - comment export with empty array#1790

Closed
mattConnHarbour wants to merge 8 commits intomainfrom
SD-1525
Closed

SD-1525 - comment export with empty array#1790
mattConnHarbour wants to merge 8 commits intomainfrom
SD-1525

Conversation

@mattConnHarbour
Copy link
Copy Markdown
Contributor

  • Calling exportDocx with empty comments array should now export docx without any comments.
  • Previously, was exporting with previous list of comments.
    example:
const newFile = editor.exportDocx({ comments: [], commentsType: 'external'  });

@linear
Copy link
Copy Markdown

linear Bot commented Jan 20, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84a978b339

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/super-editor/src/core/super-converter/SuperConverter.js Outdated
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattConnHarbour looking good just a small comment + tests

Comment thread packages/super-editor/src/core/super-converter/v2/exporter/commentsExporter.js Outdated
luccas-harbour and others added 4 commits January 22, 2026 13:48
…587) (#1806)

* fix: remove dead code

* refactor: table and paragraph converters to avoid redirection

* test: adjust existing tests

* fix: remove unused imports and dead code

* fix: pass theme colors to node handlers

* refactor: simplify type definitions for converters

---------

Co-authored-by: Luccas Correa <luccas@superdoc.dev>
@mattConnHarbour mattConnHarbour force-pushed the SD-1525 branch 3 times, most recently from fbece02 to 7dfbad0 Compare January 27, 2026 02:41
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just 2 minor things - should be good after that

);

// Update content types and comments files as needed
// Empty array preserves existing comments unless preserveCommentsOnEmpty is true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is backwards.

Says "unless preserveCommentsOnEmpty is true" but should be "false".
true = preserve
false = remove


// Update content types and comments files as needed
// Empty array preserves existing comments unless preserveCommentsOnEmpty is true
let updatedXml = { ...this.convertedXml };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let updatedXml = { ...this.convertedXml } is immediately overwritten on line 1031

Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattConnHarbour the two items from last round are still open — backwards comment + dead init at SuperConverter.js:1023.

bigger issue: the remove-comments path cleans up the in-memory xml but doesn't touch the actual zip. DocxZipper keeps the original files unless you set updatedDocs[key] = null. so preserveCommentsOnEmpty: false doesn't actually remove comments from the exported file. should be a quick fix — DocxZipper already supports null sentinels (line 330).

tests are good for the flag logic but only check internal state, not the zip output. one test that exports + unzips and checks the file list would catch this (see sectionPropertiesExport.test.js for the pattern).

left inline comments.


if (preparedComments.length) {
const commentsXml = this.converter.schemaToXml(this.converter.convertedXml['word/comments.xml'].elements[0]);
// Check if comment files exist in convertedXml (they're removed when cleaning or empty array)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipping comment files in updatedDocs isn't enough — DocxZipper keeps the originals from the source file unless you explicitly set them to null. the old comments survive in the exported docx. fix: set updatedDocs['word/comments.xml'] = null (and the other 3) when they should be gone. DocxZipper already handles null as "remove from zip" (line 330).

);

// Update content types and comments files as needed
// Empty array preserves existing comments unless preserveCommentsOnEmpty is true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still open from last round — comment says "true" but means "false". and let updatedXml = { ...this.convertedXml } is overwritten two lines later, so the initial copy is wasted.

Suggested change
// Empty array preserves existing comments unless preserveCommentsOnEmpty is true
// Empty array preserves existing comments unless preserveCommentsOnEmpty is false
let updatedXml;

updatedXml = { ...documentXml };
commentsRels = relationships;

this.convertedXml = { ...this.convertedXml, ...updatedXml };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the spread here puts the old comment keys back — so the deletion that happened inside prepareCommentsXmlFilesForExport gets undone. only the delete loop below (lines 1041-1048) actually removes them. same logic in two places, one of them doesn't work — worth picking one owner?

@superdoc-dev superdoc-dev deleted a comment from github-actions Bot Mar 1, 2026
The previous implementation cleaned comment keys from in-memory XML but
didn't signal DocxZipper to strip them from the actual zip output. The
original files from the source document survived in the exported docx.

- Add null sentinel support to DocxZipper: null values in updatedDocs
  now call zip.remove() instead of zip.file()
- Editor.ts sets comment file entries to null when comments are removed
- Consolidate duplicate removal logic in SuperConverter — the spread
  merge was undoing deletions from prepareCommentsXmlFilesForExport,
  requiring a second delete loop. Now assigns documentXml directly.
- Fix backwards comment and dead variable init in SuperConverter
- Add zip-level test that exports + unzips to verify comment files
  are actually absent from the output
@caio-pizzol
Copy link
Copy Markdown
Contributor

hey @mattConnHarbour - this one's already been fixed on main in #2123. that PR made it so passing an empty comments array always removes comments, which is exactly what SD-1525 needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants