@harbour-enterprises/superdoc 0.23.0-next.10 → 0.23.0-next.12
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-CPZ7QD5u.es.js → PdfViewer-Def79WX8.es.js} +1 -1
- package/dist/chunks/{PdfViewer-BsnSIYxD.cjs → PdfViewer-UfEzsjC9.cjs} +1 -1
- package/dist/chunks/{index-Cd9h9gMj.es.js → index-B7bpeaOD.es.js} +46 -9
- package/dist/chunks/{index-DOd9uvCv.cjs → index-fDlOzGBY.cjs} +46 -9
- package/dist/chunks/{super-editor.es-l3dTZlZX.es.js → super-editor.es-GQtMEyYE.es.js} +92 -32
- package/dist/chunks/{super-editor.es-DAS3_Nt9.cjs → super-editor.es-MZFhQtfd.cjs} +92 -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 +2 -2
- package/dist/super-editor/chunks/{converter-ClnqoStR.js → converter-Cz6CE2gy.js} +13 -0
- package/dist/super-editor/chunks/{docx-zipper-DC28ucAi.js → docx-zipper-Cd2gZDQ5.js} +1 -1
- package/dist/super-editor/chunks/{editor-B2aHhS9B.js → editor-CdXDzlMp.js} +81 -34
- package/dist/super-editor/chunks/{toolbar-Cgyf_4bW.js → toolbar-Xfq2Jgfs.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/core/helpers/htmlSanitizer.d.ts +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 +6 -6
- 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 +136 -39
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -29137,6 +29137,13 @@
|
|
|
29137
29137
|
if (node.nodeType !== window.Node.ELEMENT_NODE) return;
|
|
29138
29138
|
[...node.attributes].forEach((attr) => {
|
|
29139
29139
|
const name = attr.name.toLowerCase();
|
|
29140
|
+
if (name === "style") {
|
|
29141
|
+
const cleanedStyle = cleanStyle(attr.value);
|
|
29142
|
+
if (!cleanedStyle) {
|
|
29143
|
+
node.removeAttribute(attr.name);
|
|
29144
|
+
} else node.setAttribute(attr.name, cleanedStyle);
|
|
29145
|
+
return;
|
|
29146
|
+
}
|
|
29140
29147
|
const shouldKeep = SUPPORTED_ATTRS.includes(name) || name.startsWith("data-");
|
|
29141
29148
|
if (!shouldKeep) {
|
|
29142
29149
|
node.removeAttribute(attr.name);
|
|
@@ -29147,6 +29154,12 @@
|
|
|
29147
29154
|
cleanNode(doc2.body);
|
|
29148
29155
|
return doc2.body.innerHTML;
|
|
29149
29156
|
}
|
|
29157
|
+
function cleanStyle(style2) {
|
|
29158
|
+
if (!style2) return "";
|
|
29159
|
+
const declarations = style2.split(";").map((s) => s.trim()).filter(Boolean);
|
|
29160
|
+
const textAlign = declarations.find((d2) => d2.startsWith("text-align"));
|
|
29161
|
+
return textAlign ? `${textAlign};` : "";
|
|
29162
|
+
}
|
|
29150
29163
|
function createDocFromHTML(content, schema, options = {}) {
|
|
29151
29164
|
const { isImport = false } = options;
|
|
29152
29165
|
let parsedContent;
|
|
@@ -56442,26 +56455,100 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56442
56455
|
const setEditorToolbar = ({ editor }, mainEditor) => {
|
|
56443
56456
|
editor.setToolbar(mainEditor.toolbar);
|
|
56444
56457
|
};
|
|
56458
|
+
const normalizeCommentEventPayload = ({ conversation, editorOptions, fallbackCommentId, fallbackInternal }) => {
|
|
56459
|
+
const { user, documentId } = editorOptions || {};
|
|
56460
|
+
const normalized = {
|
|
56461
|
+
...conversation,
|
|
56462
|
+
commentId: conversation?.commentId ?? fallbackCommentId,
|
|
56463
|
+
isInternal: conversation?.isInternal ?? fallbackInternal
|
|
56464
|
+
};
|
|
56465
|
+
if (!normalized.commentText && normalized.text) {
|
|
56466
|
+
normalized.commentText = normalized.text;
|
|
56467
|
+
delete normalized.text;
|
|
56468
|
+
}
|
|
56469
|
+
if ("skipEmit" in normalized) delete normalized.skipEmit;
|
|
56470
|
+
if (!normalized.creatorName && user?.name) {
|
|
56471
|
+
normalized.creatorName = user.name;
|
|
56472
|
+
}
|
|
56473
|
+
if (!normalized.creatorEmail && user?.email) {
|
|
56474
|
+
normalized.creatorEmail = user.email;
|
|
56475
|
+
}
|
|
56476
|
+
if (!normalized.createdTime) {
|
|
56477
|
+
normalized.createdTime = Date.now();
|
|
56478
|
+
}
|
|
56479
|
+
if (!normalized.fileId && documentId) {
|
|
56480
|
+
normalized.fileId = documentId;
|
|
56481
|
+
}
|
|
56482
|
+
if (!normalized.documentId && documentId) {
|
|
56483
|
+
normalized.documentId = documentId;
|
|
56484
|
+
}
|
|
56485
|
+
return normalized;
|
|
56486
|
+
};
|
|
56487
|
+
const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, node }) => {
|
|
56488
|
+
let bounds = {};
|
|
56489
|
+
if (currentBounds instanceof DOMRect) {
|
|
56490
|
+
bounds = {
|
|
56491
|
+
top: currentBounds.top,
|
|
56492
|
+
bottom: currentBounds.bottom,
|
|
56493
|
+
left: currentBounds.left,
|
|
56494
|
+
right: currentBounds.right
|
|
56495
|
+
};
|
|
56496
|
+
} else {
|
|
56497
|
+
bounds = { ...currentBounds };
|
|
56498
|
+
}
|
|
56499
|
+
if (!allCommentPositions[threadId]) {
|
|
56500
|
+
allCommentPositions[threadId] = {
|
|
56501
|
+
threadId,
|
|
56502
|
+
start: pos,
|
|
56503
|
+
end: pos + node.nodeSize,
|
|
56504
|
+
bounds
|
|
56505
|
+
};
|
|
56506
|
+
} else {
|
|
56507
|
+
const existing = allCommentPositions[threadId];
|
|
56508
|
+
existing.start = Math.min(existing.start, pos);
|
|
56509
|
+
existing.end = Math.max(existing.end, pos + node.nodeSize);
|
|
56510
|
+
existing.bounds.top = Math.min(existing.bounds.top, currentBounds.top);
|
|
56511
|
+
existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
|
|
56512
|
+
}
|
|
56513
|
+
};
|
|
56445
56514
|
const TRACK_CHANGE_MARKS = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
|
|
56446
56515
|
const CommentsPluginKey = new PluginKey("comments");
|
|
56447
56516
|
const CommentsPlugin = Extension.create({
|
|
56448
56517
|
name: "comments",
|
|
56449
56518
|
addCommands() {
|
|
56450
56519
|
return {
|
|
56451
|
-
insertComment: (conversation) => ({ tr, dispatch }) => {
|
|
56520
|
+
insertComment: (conversation = {}) => ({ tr, dispatch }) => {
|
|
56452
56521
|
const { selection } = tr;
|
|
56453
56522
|
const { $from, $to } = selection;
|
|
56454
|
-
const
|
|
56523
|
+
const skipEmit = conversation?.skipEmit;
|
|
56524
|
+
const resolvedCommentId = conversation?.commentId ?? v4$1();
|
|
56525
|
+
const resolvedInternal = conversation?.isInternal ?? false;
|
|
56455
56526
|
tr.setMeta(CommentsPluginKey, { event: "add" });
|
|
56456
56527
|
tr.addMark(
|
|
56457
56528
|
$from.pos,
|
|
56458
56529
|
$to.pos,
|
|
56459
56530
|
this.editor.schema.marks[CommentMarkName].create({
|
|
56460
|
-
commentId,
|
|
56461
|
-
internal:
|
|
56531
|
+
commentId: resolvedCommentId,
|
|
56532
|
+
internal: resolvedInternal
|
|
56462
56533
|
})
|
|
56463
56534
|
);
|
|
56464
|
-
dispatch(tr);
|
|
56535
|
+
if (dispatch) dispatch(tr);
|
|
56536
|
+
const shouldEmit = !skipEmit && resolvedCommentId !== "pending";
|
|
56537
|
+
if (shouldEmit) {
|
|
56538
|
+
const commentPayload = normalizeCommentEventPayload({
|
|
56539
|
+
conversation,
|
|
56540
|
+
editorOptions: this.editor.options,
|
|
56541
|
+
fallbackCommentId: resolvedCommentId,
|
|
56542
|
+
fallbackInternal: resolvedInternal
|
|
56543
|
+
});
|
|
56544
|
+
const activeCommentId = commentPayload.commentId || commentPayload.importedId || null;
|
|
56545
|
+
const event = {
|
|
56546
|
+
type: comments_module_events$1.ADD,
|
|
56547
|
+
comment: commentPayload,
|
|
56548
|
+
...activeCommentId && { activeCommentId }
|
|
56549
|
+
};
|
|
56550
|
+
this.editor.emit("commentsUpdate", event);
|
|
56551
|
+
}
|
|
56465
56552
|
return true;
|
|
56466
56553
|
},
|
|
56467
56554
|
removeComment: ({ commentId, importedId }) => ({ tr, dispatch, state: state2 }) => {
|
|
@@ -56697,33 +56784,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56697
56784
|
return [commentsPlugin];
|
|
56698
56785
|
}
|
|
56699
56786
|
});
|
|
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
56787
|
const getActiveCommentId = (doc2, selection) => {
|
|
56728
56788
|
if (!selection) return;
|
|
56729
56789
|
const { $from, $to } = selection;
|
|
@@ -97886,7 +97946,11 @@ ${reason}`);
|
|
|
97886
97946
|
pendingComment.value = getPendingComment({ selection, documentId: selection.documentId, parentCommentId: null });
|
|
97887
97947
|
if (!superdoc2.config.isInternal) pendingComment.value.isInternal = false;
|
|
97888
97948
|
if (superdoc2.activeEditor?.commands) {
|
|
97889
|
-
superdoc2.activeEditor.commands.insertComment({
|
|
97949
|
+
superdoc2.activeEditor.commands.insertComment({
|
|
97950
|
+
...pendingComment.value.getValues(),
|
|
97951
|
+
commentId: "pending",
|
|
97952
|
+
skipEmit: true
|
|
97953
|
+
});
|
|
97890
97954
|
}
|
|
97891
97955
|
if (pendingComment.value.selection.source === "super-editor" && superdocStore.selectionPosition) {
|
|
97892
97956
|
superdocStore.selectionPosition.source = "super-editor";
|
|
@@ -97958,7 +98022,7 @@ ${reason}`);
|
|
|
97958
98022
|
superdocStore.selectionPosition = null;
|
|
97959
98023
|
superdoc2.activeEditor?.commands.removeComment({ commentId: "pending" });
|
|
97960
98024
|
};
|
|
97961
|
-
const addComment = ({ superdoc: superdoc2, comment }) => {
|
|
98025
|
+
const addComment = ({ superdoc: superdoc2, comment, skipEditorUpdate = false }) => {
|
|
97962
98026
|
let parentComment = commentsList.value.find((c2) => c2.commentId === activeComment.value);
|
|
97963
98027
|
if (!parentComment) parentComment = comment;
|
|
97964
98028
|
const newComment = useComment(comment.getValues());
|
|
@@ -97972,8 +98036,8 @@ ${reason}`);
|
|
|
97972
98036
|
if (!superdoc2.config.isInternal) newComment.isInternal = false;
|
|
97973
98037
|
commentsList.value.push(newComment);
|
|
97974
98038
|
removePendingComment(superdoc2);
|
|
97975
|
-
if (!comment.trackedChange && superdoc2.activeEditor?.commands && !comment.parentCommentId) {
|
|
97976
|
-
superdoc2.activeEditor.commands.insertComment(newComment.getValues());
|
|
98039
|
+
if (!skipEditorUpdate && !comment.trackedChange && superdoc2.activeEditor?.commands && !comment.parentCommentId) {
|
|
98040
|
+
superdoc2.activeEditor.commands.insertComment({ ...newComment.getValues(), skipEmit: true });
|
|
97977
98041
|
}
|
|
97978
98042
|
const event = { type: COMMENT_EVENTS.ADD, comment: newComment.getValues() };
|
|
97979
98043
|
syncCommentsToClients(superdoc2, event);
|
|
@@ -111171,7 +111235,14 @@ ${style2}
|
|
|
111171
111235
|
hasInitializedLocations,
|
|
111172
111236
|
isCommentHighlighted
|
|
111173
111237
|
} = storeToRefs(commentsStore);
|
|
111174
|
-
const {
|
|
111238
|
+
const {
|
|
111239
|
+
showAddComment,
|
|
111240
|
+
handleEditorLocationsUpdate,
|
|
111241
|
+
handleTrackedChangeUpdate,
|
|
111242
|
+
addComment,
|
|
111243
|
+
getComment,
|
|
111244
|
+
COMMENT_EVENTS
|
|
111245
|
+
} = commentsStore;
|
|
111175
111246
|
const { proxy } = getCurrentInstance();
|
|
111176
111247
|
commentsStore.proxy = proxy;
|
|
111177
111248
|
const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
|
|
@@ -111363,7 +111434,33 @@ ${style2}
|
|
|
111363
111434
|
handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
|
|
111364
111435
|
};
|
|
111365
111436
|
const onEditorCommentsUpdate = (params2 = {}) => {
|
|
111366
|
-
|
|
111437
|
+
let { activeCommentId, type: type2, comment: commentPayload } = params2;
|
|
111438
|
+
if (COMMENT_EVENTS?.ADD && type2 === COMMENT_EVENTS.ADD && commentPayload) {
|
|
111439
|
+
if (!commentPayload.commentText && commentPayload.text) {
|
|
111440
|
+
commentPayload.commentText = commentPayload.text;
|
|
111441
|
+
}
|
|
111442
|
+
const currentUser = proxy.$superdoc?.user;
|
|
111443
|
+
if (currentUser) {
|
|
111444
|
+
if (!commentPayload.creatorName) commentPayload.creatorName = currentUser.name;
|
|
111445
|
+
if (!commentPayload.creatorEmail) commentPayload.creatorEmail = currentUser.email;
|
|
111446
|
+
}
|
|
111447
|
+
if (!commentPayload.createdTime) commentPayload.createdTime = Date.now();
|
|
111448
|
+
const primaryDocumentId = commentPayload.documentId || documents.value?.[0]?.id;
|
|
111449
|
+
if (!commentPayload.documentId && primaryDocumentId) {
|
|
111450
|
+
commentPayload.documentId = primaryDocumentId;
|
|
111451
|
+
}
|
|
111452
|
+
if (!commentPayload.fileId && primaryDocumentId) {
|
|
111453
|
+
commentPayload.fileId = primaryDocumentId;
|
|
111454
|
+
}
|
|
111455
|
+
const id = commentPayload.commentId || commentPayload.importedId;
|
|
111456
|
+
if (id && !getComment(id)) {
|
|
111457
|
+
const commentModel = useComment(commentPayload);
|
|
111458
|
+
addComment({ superdoc: proxy.$superdoc, comment: commentModel, skipEditorUpdate: true });
|
|
111459
|
+
}
|
|
111460
|
+
if (!activeCommentId && id) {
|
|
111461
|
+
activeCommentId = id;
|
|
111462
|
+
}
|
|
111463
|
+
}
|
|
111367
111464
|
if (type2 === "trackedChange") {
|
|
111368
111465
|
handleTrackedChangeUpdate({ superdoc: proxy.$superdoc, params: params2 });
|
|
111369
111466
|
}
|
|
@@ -111696,7 +111793,7 @@ ${style2}
|
|
|
111696
111793
|
};
|
|
111697
111794
|
}
|
|
111698
111795
|
};
|
|
111699
|
-
const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
111796
|
+
const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-96983cf9"]]);
|
|
111700
111797
|
const createSuperdocVueApp = () => {
|
|
111701
111798
|
const app = createApp(App);
|
|
111702
111799
|
const pinia = createPinia();
|