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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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',
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ 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'];
const authorEmail = attributes['w:email'];
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();

Expand All @@ -53,6 +56,9 @@ export function importCommentData({ docx }) {
textJson: parsedComment[0],
initials,
paraId,
trackedChange,
trackedChangeText,
trackedChangeType,
};
});

Expand Down
15 changes: 12 additions & 3 deletions packages/superdoc/src/stores/comments-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const useCommentsStore = defineStore('comments', () => {
trackedChangeType,
deletedText,
createdTime: date,
creatorNamne: authorName,
creatorName: authorName,
creatorEmail: authorEmail,
isInternal: false,
selection: {
Expand Down Expand Up @@ -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,
Expand All @@ -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 });
Expand Down