@harbour-enterprises/superdoc 0.23.0-next.10 → 0.23.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-BsnSIYxD.cjs → PdfViewer-CxsRHFKK.cjs} +1 -1
- package/dist/chunks/{PdfViewer-CPZ7QD5u.es.js → PdfViewer-itEb8CY_.es.js} +1 -1
- package/dist/chunks/{index-Cd9h9gMj.es.js → index-CTFsQkQh.es.js} +46 -9
- package/dist/chunks/{index-DOd9uvCv.cjs → index-DO0hDjEd.cjs} +46 -9
- package/dist/chunks/{super-editor.es-DAS3_Nt9.cjs → super-editor.es-Ck_zDasU.cjs} +79 -32
- package/dist/chunks/{super-editor.es-l3dTZlZX.es.js → super-editor.es-D2K5zQwY.es.js} +79 -32
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/stores/comments-store.d.ts +3 -3
- package/dist/stores/comments-store.d.ts.map +1 -1
- package/dist/style.css +27 -27
- package/dist/super-editor/ai-writer.es.js +1 -1
- package/dist/super-editor/chunks/{editor-B2aHhS9B.js → editor-C3VH8Ia2.js} +79 -32
- package/dist/super-editor/chunks/{toolbar-Cgyf_4bW.js → toolbar-BG1F_1RK.js} +1 -1
- package/dist/super-editor/editor.es.js +1 -1
- package/dist/super-editor/src/extensions/comment/comments-plugin.d.ts +60 -0
- package/dist/super-editor/src/extensions/comment/helpers/index.d.ts +2 -0
- package/dist/super-editor/src/extensions/comment/helpers/normalize-comment-event-payload.d.ts +1 -0
- package/dist/super-editor/src/extensions/comment/helpers/update-position.d.ts +7 -0
- package/dist/super-editor/super-editor.es.js +3 -3
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +123 -39
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -56442,26 +56442,100 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56442
56442
|
const setEditorToolbar = ({ editor }, mainEditor) => {
|
|
56443
56443
|
editor.setToolbar(mainEditor.toolbar);
|
|
56444
56444
|
};
|
|
56445
|
+
const normalizeCommentEventPayload = ({ conversation, editorOptions, fallbackCommentId, fallbackInternal }) => {
|
|
56446
|
+
const { user, documentId } = editorOptions || {};
|
|
56447
|
+
const normalized = {
|
|
56448
|
+
...conversation,
|
|
56449
|
+
commentId: conversation?.commentId ?? fallbackCommentId,
|
|
56450
|
+
isInternal: conversation?.isInternal ?? fallbackInternal
|
|
56451
|
+
};
|
|
56452
|
+
if (!normalized.commentText && normalized.text) {
|
|
56453
|
+
normalized.commentText = normalized.text;
|
|
56454
|
+
delete normalized.text;
|
|
56455
|
+
}
|
|
56456
|
+
if ("skipEmit" in normalized) delete normalized.skipEmit;
|
|
56457
|
+
if (!normalized.creatorName && user?.name) {
|
|
56458
|
+
normalized.creatorName = user.name;
|
|
56459
|
+
}
|
|
56460
|
+
if (!normalized.creatorEmail && user?.email) {
|
|
56461
|
+
normalized.creatorEmail = user.email;
|
|
56462
|
+
}
|
|
56463
|
+
if (!normalized.createdTime) {
|
|
56464
|
+
normalized.createdTime = Date.now();
|
|
56465
|
+
}
|
|
56466
|
+
if (!normalized.fileId && documentId) {
|
|
56467
|
+
normalized.fileId = documentId;
|
|
56468
|
+
}
|
|
56469
|
+
if (!normalized.documentId && documentId) {
|
|
56470
|
+
normalized.documentId = documentId;
|
|
56471
|
+
}
|
|
56472
|
+
return normalized;
|
|
56473
|
+
};
|
|
56474
|
+
const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, node }) => {
|
|
56475
|
+
let bounds = {};
|
|
56476
|
+
if (currentBounds instanceof DOMRect) {
|
|
56477
|
+
bounds = {
|
|
56478
|
+
top: currentBounds.top,
|
|
56479
|
+
bottom: currentBounds.bottom,
|
|
56480
|
+
left: currentBounds.left,
|
|
56481
|
+
right: currentBounds.right
|
|
56482
|
+
};
|
|
56483
|
+
} else {
|
|
56484
|
+
bounds = { ...currentBounds };
|
|
56485
|
+
}
|
|
56486
|
+
if (!allCommentPositions[threadId]) {
|
|
56487
|
+
allCommentPositions[threadId] = {
|
|
56488
|
+
threadId,
|
|
56489
|
+
start: pos,
|
|
56490
|
+
end: pos + node.nodeSize,
|
|
56491
|
+
bounds
|
|
56492
|
+
};
|
|
56493
|
+
} else {
|
|
56494
|
+
const existing = allCommentPositions[threadId];
|
|
56495
|
+
existing.start = Math.min(existing.start, pos);
|
|
56496
|
+
existing.end = Math.max(existing.end, pos + node.nodeSize);
|
|
56497
|
+
existing.bounds.top = Math.min(existing.bounds.top, currentBounds.top);
|
|
56498
|
+
existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
|
|
56499
|
+
}
|
|
56500
|
+
};
|
|
56445
56501
|
const TRACK_CHANGE_MARKS = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
|
|
56446
56502
|
const CommentsPluginKey = new PluginKey("comments");
|
|
56447
56503
|
const CommentsPlugin = Extension.create({
|
|
56448
56504
|
name: "comments",
|
|
56449
56505
|
addCommands() {
|
|
56450
56506
|
return {
|
|
56451
|
-
insertComment: (conversation) => ({ tr, dispatch }) => {
|
|
56507
|
+
insertComment: (conversation = {}) => ({ tr, dispatch }) => {
|
|
56452
56508
|
const { selection } = tr;
|
|
56453
56509
|
const { $from, $to } = selection;
|
|
56454
|
-
const
|
|
56510
|
+
const skipEmit = conversation?.skipEmit;
|
|
56511
|
+
const resolvedCommentId = conversation?.commentId ?? v4$1();
|
|
56512
|
+
const resolvedInternal = conversation?.isInternal ?? false;
|
|
56455
56513
|
tr.setMeta(CommentsPluginKey, { event: "add" });
|
|
56456
56514
|
tr.addMark(
|
|
56457
56515
|
$from.pos,
|
|
56458
56516
|
$to.pos,
|
|
56459
56517
|
this.editor.schema.marks[CommentMarkName].create({
|
|
56460
|
-
commentId,
|
|
56461
|
-
internal:
|
|
56518
|
+
commentId: resolvedCommentId,
|
|
56519
|
+
internal: resolvedInternal
|
|
56462
56520
|
})
|
|
56463
56521
|
);
|
|
56464
|
-
dispatch(tr);
|
|
56522
|
+
if (dispatch) dispatch(tr);
|
|
56523
|
+
const shouldEmit = !skipEmit && resolvedCommentId !== "pending";
|
|
56524
|
+
if (shouldEmit) {
|
|
56525
|
+
const commentPayload = normalizeCommentEventPayload({
|
|
56526
|
+
conversation,
|
|
56527
|
+
editorOptions: this.editor.options,
|
|
56528
|
+
fallbackCommentId: resolvedCommentId,
|
|
56529
|
+
fallbackInternal: resolvedInternal
|
|
56530
|
+
});
|
|
56531
|
+
const activeCommentId = commentPayload.commentId || commentPayload.importedId || null;
|
|
56532
|
+
const event = {
|
|
56533
|
+
type: comments_module_events$1.ADD,
|
|
56534
|
+
comment: commentPayload,
|
|
56535
|
+
...activeCommentId && { activeCommentId }
|
|
56536
|
+
};
|
|
56537
|
+
this.editor.emit("commentsUpdate", event);
|
|
56538
|
+
}
|
|
56465
56539
|
return true;
|
|
56466
56540
|
},
|
|
56467
56541
|
removeComment: ({ commentId, importedId }) => ({ tr, dispatch, state: state2 }) => {
|
|
@@ -56697,33 +56771,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56697
56771
|
return [commentsPlugin];
|
|
56698
56772
|
}
|
|
56699
56773
|
});
|
|
56700
|
-
const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, node }) => {
|
|
56701
|
-
let bounds = {};
|
|
56702
|
-
if (currentBounds instanceof DOMRect) {
|
|
56703
|
-
bounds = {
|
|
56704
|
-
top: currentBounds.top,
|
|
56705
|
-
bottom: currentBounds.bottom,
|
|
56706
|
-
left: currentBounds.left,
|
|
56707
|
-
right: currentBounds.right
|
|
56708
|
-
};
|
|
56709
|
-
} else {
|
|
56710
|
-
bounds = { ...currentBounds };
|
|
56711
|
-
}
|
|
56712
|
-
if (!allCommentPositions[threadId]) {
|
|
56713
|
-
allCommentPositions[threadId] = {
|
|
56714
|
-
threadId,
|
|
56715
|
-
start: pos,
|
|
56716
|
-
end: pos + node.nodeSize,
|
|
56717
|
-
bounds
|
|
56718
|
-
};
|
|
56719
|
-
} else {
|
|
56720
|
-
const existing = allCommentPositions[threadId];
|
|
56721
|
-
existing.start = Math.min(existing.start, pos);
|
|
56722
|
-
existing.end = Math.max(existing.end, pos + node.nodeSize);
|
|
56723
|
-
existing.bounds.top = Math.min(existing.bounds.top, currentBounds.top);
|
|
56724
|
-
existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
|
|
56725
|
-
}
|
|
56726
|
-
};
|
|
56727
56774
|
const getActiveCommentId = (doc2, selection) => {
|
|
56728
56775
|
if (!selection) return;
|
|
56729
56776
|
const { $from, $to } = selection;
|
|
@@ -97886,7 +97933,11 @@ ${reason}`);
|
|
|
97886
97933
|
pendingComment.value = getPendingComment({ selection, documentId: selection.documentId, parentCommentId: null });
|
|
97887
97934
|
if (!superdoc2.config.isInternal) pendingComment.value.isInternal = false;
|
|
97888
97935
|
if (superdoc2.activeEditor?.commands) {
|
|
97889
|
-
superdoc2.activeEditor.commands.insertComment({
|
|
97936
|
+
superdoc2.activeEditor.commands.insertComment({
|
|
97937
|
+
...pendingComment.value.getValues(),
|
|
97938
|
+
commentId: "pending",
|
|
97939
|
+
skipEmit: true
|
|
97940
|
+
});
|
|
97890
97941
|
}
|
|
97891
97942
|
if (pendingComment.value.selection.source === "super-editor" && superdocStore.selectionPosition) {
|
|
97892
97943
|
superdocStore.selectionPosition.source = "super-editor";
|
|
@@ -97958,7 +98009,7 @@ ${reason}`);
|
|
|
97958
98009
|
superdocStore.selectionPosition = null;
|
|
97959
98010
|
superdoc2.activeEditor?.commands.removeComment({ commentId: "pending" });
|
|
97960
98011
|
};
|
|
97961
|
-
const addComment = ({ superdoc: superdoc2, comment }) => {
|
|
98012
|
+
const addComment = ({ superdoc: superdoc2, comment, skipEditorUpdate = false }) => {
|
|
97962
98013
|
let parentComment = commentsList.value.find((c2) => c2.commentId === activeComment.value);
|
|
97963
98014
|
if (!parentComment) parentComment = comment;
|
|
97964
98015
|
const newComment = useComment(comment.getValues());
|
|
@@ -97972,8 +98023,8 @@ ${reason}`);
|
|
|
97972
98023
|
if (!superdoc2.config.isInternal) newComment.isInternal = false;
|
|
97973
98024
|
commentsList.value.push(newComment);
|
|
97974
98025
|
removePendingComment(superdoc2);
|
|
97975
|
-
if (!comment.trackedChange && superdoc2.activeEditor?.commands && !comment.parentCommentId) {
|
|
97976
|
-
superdoc2.activeEditor.commands.insertComment(newComment.getValues());
|
|
98026
|
+
if (!skipEditorUpdate && !comment.trackedChange && superdoc2.activeEditor?.commands && !comment.parentCommentId) {
|
|
98027
|
+
superdoc2.activeEditor.commands.insertComment({ ...newComment.getValues(), skipEmit: true });
|
|
97977
98028
|
}
|
|
97978
98029
|
const event = { type: COMMENT_EVENTS.ADD, comment: newComment.getValues() };
|
|
97979
98030
|
syncCommentsToClients(superdoc2, event);
|
|
@@ -111171,7 +111222,14 @@ ${style2}
|
|
|
111171
111222
|
hasInitializedLocations,
|
|
111172
111223
|
isCommentHighlighted
|
|
111173
111224
|
} = storeToRefs(commentsStore);
|
|
111174
|
-
const {
|
|
111225
|
+
const {
|
|
111226
|
+
showAddComment,
|
|
111227
|
+
handleEditorLocationsUpdate,
|
|
111228
|
+
handleTrackedChangeUpdate,
|
|
111229
|
+
addComment,
|
|
111230
|
+
getComment,
|
|
111231
|
+
COMMENT_EVENTS
|
|
111232
|
+
} = commentsStore;
|
|
111175
111233
|
const { proxy } = getCurrentInstance();
|
|
111176
111234
|
commentsStore.proxy = proxy;
|
|
111177
111235
|
const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
|
|
@@ -111363,7 +111421,33 @@ ${style2}
|
|
|
111363
111421
|
handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
|
|
111364
111422
|
};
|
|
111365
111423
|
const onEditorCommentsUpdate = (params2 = {}) => {
|
|
111366
|
-
|
|
111424
|
+
let { activeCommentId, type: type2, comment: commentPayload } = params2;
|
|
111425
|
+
if (COMMENT_EVENTS?.ADD && type2 === COMMENT_EVENTS.ADD && commentPayload) {
|
|
111426
|
+
if (!commentPayload.commentText && commentPayload.text) {
|
|
111427
|
+
commentPayload.commentText = commentPayload.text;
|
|
111428
|
+
}
|
|
111429
|
+
const currentUser = proxy.$superdoc?.user;
|
|
111430
|
+
if (currentUser) {
|
|
111431
|
+
if (!commentPayload.creatorName) commentPayload.creatorName = currentUser.name;
|
|
111432
|
+
if (!commentPayload.creatorEmail) commentPayload.creatorEmail = currentUser.email;
|
|
111433
|
+
}
|
|
111434
|
+
if (!commentPayload.createdTime) commentPayload.createdTime = Date.now();
|
|
111435
|
+
const primaryDocumentId = commentPayload.documentId || documents.value?.[0]?.id;
|
|
111436
|
+
if (!commentPayload.documentId && primaryDocumentId) {
|
|
111437
|
+
commentPayload.documentId = primaryDocumentId;
|
|
111438
|
+
}
|
|
111439
|
+
if (!commentPayload.fileId && primaryDocumentId) {
|
|
111440
|
+
commentPayload.fileId = primaryDocumentId;
|
|
111441
|
+
}
|
|
111442
|
+
const id = commentPayload.commentId || commentPayload.importedId;
|
|
111443
|
+
if (id && !getComment(id)) {
|
|
111444
|
+
const commentModel = useComment(commentPayload);
|
|
111445
|
+
addComment({ superdoc: proxy.$superdoc, comment: commentModel, skipEditorUpdate: true });
|
|
111446
|
+
}
|
|
111447
|
+
if (!activeCommentId && id) {
|
|
111448
|
+
activeCommentId = id;
|
|
111449
|
+
}
|
|
111450
|
+
}
|
|
111367
111451
|
if (type2 === "trackedChange") {
|
|
111368
111452
|
handleTrackedChangeUpdate({ superdoc: proxy.$superdoc, params: params2 });
|
|
111369
111453
|
}
|
|
@@ -111696,7 +111780,7 @@ ${style2}
|
|
|
111696
111780
|
};
|
|
111697
111781
|
}
|
|
111698
111782
|
};
|
|
111699
|
-
const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
111783
|
+
const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-96983cf9"]]);
|
|
111700
111784
|
const createSuperdocVueApp = () => {
|
|
111701
111785
|
const app = createApp(App);
|
|
111702
111786
|
const pinia = createPinia();
|