Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions packages/super-editor/src/core/super-converter/SuperConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class SuperConverter {
});
updatedXml = { ...documentXml };
commentsRels = relationships;
};
}

this.convertedXml = { ...this.convertedXml, ...updatedXml };

Expand Down Expand Up @@ -390,8 +390,10 @@ class SuperConverter {
const relsData = this.convertedXml['word/_rels/document.xml.rels'];
const relationships = relsData.elements.find((x) => x.name === 'Relationships');
const newRels = [];

let largestId = Math.max(...relationships.elements.map((el) => Number(el.attributes.Id.replace('rId', ''))));

const regex = /rId|mi/g;
Comment thread
harbournick marked this conversation as resolved.
let largestId = Math.max(...relationships.elements.map((el) => Number(el.attributes.Id.replace(regex, ''))));

rels.forEach((rel) => {
const existingId = rel.attributes.Id;
const existingTarget = relationships.elements.find((el) => el.attributes.Target === rel.attributes.Target);
Expand All @@ -400,7 +402,7 @@ class SuperConverter {
if (existingTarget && !isNewMedia) {
return;
}

// Update the target to escape ampersands
rel.attributes.Target = rel.attributes?.Target?.replace(/&/g, '&');

Expand Down
11 changes: 7 additions & 4 deletions packages/super-editor/src/core/super-converter/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1604,11 +1604,14 @@ function translateFieldAnnotation(params) {

export function translateHardBreak() {
return {
name: 'w:br',
type: 'element',
attributes: { 'w:type': 'page' }
name: 'w:r',
Copy link
Copy Markdown
Contributor Author

@VladaHarbour VladaHarbour Mar 24, 2025

Choose a reason for hiding this comment

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

@harbournick When Word recovers our documents it wraps hard breaks into run for some reason

elements: [{
name: 'w:br',
type: 'element',
attributes: { 'w:type': 'page' }
}]
};
};
}

export class DocxExporter {
constructor(converter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ export function translateCommentNode(params, type) {

let commentSchema = getCommentSchema(type, commentIndex);
if (type === 'End') {
const commentReference = { name: 'w:commentReference', attributes: { 'w:id': String(commentIndex) } };
const commentReference = {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@harbournick Same with wrapping here

name: 'w:r',
elements: [{ name: 'w:commentReference', attributes: { 'w:id': String(commentIndex) } }]
};
commentSchema = [commentSchema, commentReference];
};
}
return commentSchema;
};
}


/**
Expand Down Expand Up @@ -185,15 +188,14 @@ export const updateCommentsExtendedXml = (comments = [], commentsExtendedXml) =>
const attributes = {
'w15:paraId': comment.commentParaId,
'w15:done': comment.resolvedTime ? '1' : '0',
'w:rsid': comment.commentId || comment.importedId,
Comment thread
harbournick marked this conversation as resolved.
};

const parentId = comment.parentCommentId;
if (parentId) {
const parentComment = comments.find((c) => c.commentId === parentId);
const parentParaId = parentComment.commentParaId;
attributes['w15:paraIdParent'] = parentParaId;
};
}

return {
type: 'element',
Expand Down Expand Up @@ -240,7 +242,7 @@ export const updateCommentsIdsAndExtensible = (comments = [], commentsIds, exten
"name": "w16cex:commentExtensible",
"attributes": {
"w16cex:durableId": newDurableId,
"w16cex:dateUtc": "2025-03-06T23:32:00Z"
"w16cex:dateUtc": toIsoNoFractional()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure it has to be hardcoded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

oh yeah, that was my mistake. thanks for fixing!

}
};
extensibleUpdated.elements[0].elements.push(newExtensible);
Expand Down Expand Up @@ -353,8 +355,8 @@ export const prepareCommentsXmlFilesForExport = ({
if (exportType === 'clean') {
const documentXml = removeCommentsFilesFromConvertedXml(convertedXml);
return { documentXml, relationships };
};

}
// Initialize comments files with empty content
const updatedXml = generateConvertedXmlWithCommentFiles(convertedXml);

Expand Down
2 changes: 1 addition & 1 deletion packages/superdoc/src/core/SuperDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class SuperDoc extends EventEmitter {
const comments = [];
if (commentsType !== 'clean') {
comments.push(...this.commentsStore?.translateCommentsForExport());
};
}

const docxPromises = [];
this.superdocStore.documents.forEach((doc) => {
Expand Down