diff --git a/packages/super-editor/src/core/super-converter/v2/exporter/commentsExporter.js b/packages/super-editor/src/core/super-converter/v2/exporter/commentsExporter.js index 7623d822ec..8425cf9924 100644 --- a/packages/super-editor/src/core/super-converter/v2/exporter/commentsExporter.js +++ b/packages/super-editor/src/core/super-converter/v2/exporter/commentsExporter.js @@ -90,7 +90,6 @@ export const prepareCommentParaIds = (comment) => { */ export const getCommentDefinition = (comment, commentId, allComments) => { const translatedText = translateParagraphNode({ node: comment.commentJSON }); - const attributes = { 'w:id': String(commentId), 'w:author': comment.creatorName || comment.importedAuthor?.name, @@ -100,6 +99,9 @@ export const getCommentDefinition = (comment, commentId, allComments) => { 'w:done': comment.resolvedTime ? '1' : '0', 'w15:paraId': comment.commentParaId, 'custom:internalId': comment.commentId || comment.internalId, + 'custom:trackedChange': comment.trackedChange, + 'custom:trackedChangeText': comment.trackedChangeText, + 'custom:trackedChangeType': comment.trackedChangeType, }; // Add the w15:paraIdParent attribute if the comment has a parent @@ -164,9 +166,13 @@ export const updateCommentsXml = (commentDefs = [], commentsXml) => { commentDef.attributes = { 'w:id': commentDef.attributes['w:id'], 'w:author': commentDef.attributes['w:author'], + 'w:email': commentDef.attributes['w:email'], 'w:date': commentDef.attributes['w:date'], 'w:initials': commentDef.attributes['w:initials'], 'custom:internalId': commentDef.attributes['custom:internalId'], + 'custom:trackedChange': commentDef.attributes['custom:trackedChange'], + 'custom:trackedChangeText': commentDef.attributes['custom:trackedChangeText'], + 'custom:trackedChangeType': commentDef.attributes['custom:trackedChangeType'], 'xmlns:custom': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', }; }); diff --git a/packages/super-editor/src/core/super-converter/v2/importer/documentCommentsImporter.js b/packages/super-editor/src/core/super-converter/v2/importer/documentCommentsImporter.js index 88c6885f82..89fe73d16b 100644 --- a/packages/super-editor/src/core/super-converter/v2/importer/documentCommentsImporter.js +++ b/packages/super-editor/src/core/super-converter/v2/importer/documentCommentsImporter.js @@ -22,7 +22,6 @@ export function importCommentData({ docx }) { const { elements: allComments = [] } = elements[0]; const extractedComments = allComments.map((el) => { - const { attributes } = el; const importedId = attributes['w:id']; const authorName = attributes['w:author']; @@ -30,6 +29,10 @@ export function importCommentData({ docx }) { const initials = attributes['w:initials']; const createdDate = attributes['w:date']; const internalId = attributes['custom:internalId']; + const trackedChange = attributes['custom:trackedChange'] === 'true'; + const trackedChangeText = attributes['custom:trackedChangeText']; + const trackedChangeType = attributes['custom:trackedChangeType']; + const date = new Date(createdDate); const unixTimestampMs = date.getTime(); @@ -53,6 +56,9 @@ export function importCommentData({ docx }) { textJson: parsedComment[0], initials, paraId, + trackedChange, + trackedChangeText, + trackedChangeType, }; }); diff --git a/packages/superdoc/src/stores/comments-store.js b/packages/superdoc/src/stores/comments-store.js index 1d282c2b48..1c60c02c4f 100644 --- a/packages/superdoc/src/stores/comments-store.js +++ b/packages/superdoc/src/stores/comments-store.js @@ -122,7 +122,7 @@ export const useCommentsStore = defineStore('comments', () => { trackedChangeType, deletedText, createdTime: date, - creatorNamne: authorName, + creatorName: authorName, creatorEmail: authorEmail, isInternal: false, selection: { @@ -448,15 +448,21 @@ export const useCommentsStore = defineStore('comments', () => { comments.forEach((comment) => { const htmlContent = getHTmlFromComment(comment.textJson); - if (!htmlContent) return; - const importedName = `${comment.creatorName.replace('(imported)', '')} (imported)` + if (!htmlContent && !comment.trackedChange) { + return; + } + + const creatorName = comment.creatorName.replace('(imported)', ''); + const importedName = `${creatorName} (imported)`; const newComment = useComment({ fileId: documentId, fileType: document.type, commentId: comment.commentId, isInternal: false, parentCommentId: comment.parentCommentId, + creatorName, + creatorEmail: comment.creatorEmail, importedAuthor: { name: importedName, email: comment.creatorEmail, @@ -465,6 +471,9 @@ export const useCommentsStore = defineStore('comments', () => { resolvedTime: comment.isDone ? Date.now() : null, resolvedByEmail: comment.isDone ? comment.creatorEmail : null, resolvedByName: comment.isDone ? importedName : null, + trackedChange: comment.trackedChange || false, + trackedChangeText: comment.trackedChangeText, + trackedChangeType: comment.trackedChangeType, }); addComment({ superdoc, comment: newComment });