@harbour-enterprises/superdoc 1.4.0 → 1.4.1-next.2

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-C4XfNZf6.cjs");
4
+ const superEditor_converter = require("./SuperConverter-Bukam51x.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -12638,11 +12638,15 @@ const resolveCommentMeta = ({ converter, importedId }) => {
12638
12638
  const matchingImportedComment = comments.find((c2) => c2.importedId == importedId);
12639
12639
  const resolvedCommentId = matchingImportedComment?.commentId ?? (importedId ? String(importedId) : uuid.v4());
12640
12640
  const internal = matchingImportedComment?.internal ?? matchingImportedComment?.isInternal ?? false;
12641
+ const parentCommentId = matchingImportedComment?.parentCommentId;
12642
+ const trackedChangeIds = converter?.trackedChangeIdMap ? new Set(Array.from(converter.trackedChangeIdMap.values()).map((id) => String(id))) : null;
12643
+ const isTrackedChangeParent = parentCommentId && trackedChangeIds ? trackedChangeIds.has(String(parentCommentId)) : false;
12641
12644
  return {
12642
12645
  resolvedCommentId,
12643
12646
  importedId,
12644
12647
  internal,
12645
- matchingImportedComment
12648
+ matchingImportedComment,
12649
+ trackedChange: matchingImportedComment?.trackedChange === true || isTrackedChangeParent
12646
12650
  };
12647
12651
  };
12648
12652
  const ensureFallbackComment = ({ converter, matchingImportedComment, commentId, importedId }) => {
@@ -12660,6 +12664,7 @@ const ensureFallbackComment = ({ converter, matchingImportedComment, commentId,
12660
12664
  isDone: false
12661
12665
  });
12662
12666
  };
12667
+ const TRACK_CHANGE_MARKS$1 = [superEditor_converter.TrackInsertMarkName, superEditor_converter.TrackDeleteMarkName, superEditor_converter.TrackFormatMarkName];
12663
12668
  const removeCommentsById = ({ commentId, state, tr, dispatch }) => {
12664
12669
  const positions = getCommentPositionsById(commentId, state.doc);
12665
12670
  positions.forEach(({ from: from3, to }) => {
@@ -12803,6 +12808,35 @@ const prepareCommentsForExport = (doc2, tr, schema, comments = []) => {
12803
12808
  });
12804
12809
  });
12805
12810
  });
12811
+ const trackedChangeMark = node.marks?.find((mark) => TRACK_CHANGE_MARKS$1.includes(mark.type.name));
12812
+ if (trackedChangeMark) {
12813
+ const trackedChangeId = trackedChangeMark.attrs?.id;
12814
+ if (trackedChangeId) {
12815
+ const childComments = comments.filter((c2) => c2.parentCommentId === trackedChangeId && !c2.trackedChange).sort((a, b) => a.createdTime - b.createdTime);
12816
+ childComments.forEach((c2) => {
12817
+ if (seen.has(c2.commentId)) return;
12818
+ seen.add(c2.commentId);
12819
+ const childMark = getPreparedComment({
12820
+ commentId: c2.commentId,
12821
+ internal: c2.isInternal
12822
+ });
12823
+ const childStartNode = schema.nodes.commentRangeStart.create(childMark);
12824
+ startNodes.push({
12825
+ pos,
12826
+ node: childStartNode,
12827
+ commentId: c2.commentId,
12828
+ parentCommentId: c2.parentCommentId
12829
+ });
12830
+ const childEndNode = schema.nodes.commentRangeEnd.create(childMark);
12831
+ endNodes.push({
12832
+ pos: pos + node.nodeSize,
12833
+ node: childEndNode,
12834
+ commentId: c2.commentId,
12835
+ parentCommentId: c2.parentCommentId
12836
+ });
12837
+ });
12838
+ }
12839
+ }
12806
12840
  });
12807
12841
  startNodes.sort((a, b) => {
12808
12842
  if (a.pos !== b.pos) return a.pos - b.pos;
@@ -12857,17 +12891,18 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
12857
12891
  const { type } = node;
12858
12892
  const commentNodes = ["commentRangeStart", "commentRangeEnd", "commentReference"];
12859
12893
  if (!commentNodes.includes(type.name)) return;
12860
- const { resolvedCommentId, importedId, internal, matchingImportedComment } = resolveCommentMeta({
12894
+ const { resolvedCommentId, importedId, internal, matchingImportedComment, trackedChange } = resolveCommentMeta({
12861
12895
  converter,
12862
12896
  importedId: node.attrs["w:id"]
12863
12897
  });
12864
12898
  const isDone = !!matchingImportedComment?.isDone;
12865
12899
  if (type.name === "commentRangeStart") {
12866
- if (!isDone) {
12900
+ if (!matchingImportedComment || !matchingImportedComment.isDone) {
12867
12901
  toMark.push({
12868
12902
  commentId: resolvedCommentId,
12869
12903
  importedId,
12870
12904
  internal,
12905
+ trackedChange,
12871
12906
  start: pos
12872
12907
  });
12873
12908
  }
@@ -12906,7 +12941,8 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
12906
12941
  const markAttrs = {
12907
12942
  commentId: itemToMark.commentId,
12908
12943
  importedId,
12909
- internal: itemToMark.internal
12944
+ internal: itemToMark.internal,
12945
+ trackedChange: itemToMark.trackedChange
12910
12946
  };
12911
12947
  tr.addMark(start2, pos + 1, schema.marks[CommentMarkName$1].create(markAttrs));
12912
12948
  toDelete.push({ start: pos, end: pos + 1 });
@@ -13468,26 +13504,30 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
13468
13504
  if (emitParams) editor.emit("commentsUpdate", emitParams);
13469
13505
  return newTrackedChanges;
13470
13506
  };
13471
- const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion }) => {
13507
+ const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion, marks }) => {
13472
13508
  let trackedChangeText = "";
13473
13509
  let deletionText = "";
13474
- if (trackedChangeType === superEditor_converter.TrackInsertMarkName) {
13510
+ if (trackedChangeType === superEditor_converter.TrackDeleteMarkName || isDeletionInsertion) {
13511
+ deletionText = nodes.reduce((acc, node) => {
13512
+ const hasDeleteMark = node.marks.find((nodeMark) => nodeMark.type.name === superEditor_converter.TrackDeleteMarkName);
13513
+ if (!hasDeleteMark) return acc;
13514
+ const nodeText = node?.text || node?.textContent || "";
13515
+ acc += nodeText;
13516
+ return acc;
13517
+ }, "");
13518
+ }
13519
+ if (trackedChangeType === superEditor_converter.TrackInsertMarkName || isDeletionInsertion) {
13475
13520
  trackedChangeText = nodes.reduce((acc, node) => {
13476
- if (!node.marks.find((nodeMark) => nodeMark.type.name === mark.type.name)) return acc;
13477
- acc += node?.text || node?.textContent || "";
13521
+ const hasInsertMark = node.marks.find((nodeMark) => nodeMark.type.name === superEditor_converter.TrackInsertMarkName);
13522
+ if (!hasInsertMark) return acc;
13523
+ const nodeText = node?.text || node?.textContent || "";
13524
+ acc += nodeText;
13478
13525
  return acc;
13479
13526
  }, "");
13480
13527
  }
13481
13528
  if (trackedChangeType === superEditor_converter.TrackFormatMarkName) {
13482
13529
  trackedChangeText = translateFormatChangesToEnglish(mark.attrs);
13483
13530
  }
13484
- if (trackedChangeType === superEditor_converter.TrackDeleteMarkName || isDeletionInsertion) {
13485
- deletionText = nodes.reduce((acc, node) => {
13486
- if (!node.marks.find((nodeMark) => nodeMark.type.name === superEditor_converter.TrackDeleteMarkName)) return acc;
13487
- acc += node?.text || node?.textContent || "";
13488
- return acc;
13489
- }, "");
13490
- }
13491
13531
  return {
13492
13532
  deletionText,
13493
13533
  trackedChangeText
@@ -13500,22 +13540,41 @@ const createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes
13500
13540
  const { author, authorEmail, authorImage, date, importedAuthor } = attrs;
13501
13541
  const id = attrs.id;
13502
13542
  const node = nodes[0];
13503
- const isDeletionInsertion = !!(marks.insertedMark && marks.deletionMark);
13543
+ const trackedChangesWithId = getTrackChanges(newEditorState, id);
13544
+ let isDeletionInsertion = !!(marks.insertedMark && marks.deletionMark);
13545
+ if (!isDeletionInsertion) {
13546
+ const hasInsertMark = trackedChangesWithId.some(({ mark }) => mark.type.name === superEditor_converter.TrackInsertMarkName);
13547
+ const hasDeleteMark = trackedChangesWithId.some(({ mark }) => mark.type.name === superEditor_converter.TrackDeleteMarkName);
13548
+ isDeletionInsertion = hasInsertMark && hasDeleteMark;
13549
+ }
13504
13550
  let nodesWithMark = [];
13505
- newEditorState.doc.descendants((node2) => {
13506
- const { marks: marks2 = [] } = node2;
13507
- const changeMarks = marks2.filter((mark) => TRACK_CHANGE_MARKS.includes(mark.type.name));
13508
- if (!changeMarks.length) return;
13509
- const hasMatchingId = changeMarks.find((mark) => mark.attrs.id === id);
13510
- if (hasMatchingId) nodesWithMark.push(node2);
13551
+ trackedChangesWithId.forEach(({ from: from3, to, mark }) => {
13552
+ newEditorState.doc.nodesBetween(from3, to, (node2, pos) => {
13553
+ if (node2.isText) {
13554
+ const hasMatchingMark = node2.marks?.some((m) => TRACK_CHANGE_MARKS.includes(m.type.name) && m.attrs.id === id);
13555
+ if (hasMatchingMark) {
13556
+ const alreadyAdded = nodesWithMark.some((n) => n === node2);
13557
+ if (!alreadyAdded) {
13558
+ nodesWithMark.push(node2);
13559
+ }
13560
+ }
13561
+ }
13562
+ });
13511
13563
  });
13512
- const nodesToProcess = nodesWithMark.length ? nodesWithMark : node ? [node] : [];
13513
- if (!nodesToProcess.length) {
13564
+ let nodesToUse;
13565
+ if (isDeletionInsertion) {
13566
+ const allNodes = [...nodesWithMark, ...nodes, ...deletionNodes || []];
13567
+ nodesToUse = Array.from(new Set(allNodes));
13568
+ } else {
13569
+ nodesToUse = nodesWithMark.length ? nodesWithMark : node ? [node] : [];
13570
+ }
13571
+ if (!nodesToUse.length) {
13514
13572
  return;
13515
13573
  }
13516
13574
  const { deletionText, trackedChangeText } = getTrackedChangeText({
13517
- nodes: nodesToProcess,
13575
+ nodes: nodesToUse,
13518
13576
  mark: trackedMark,
13577
+ marks,
13519
13578
  trackedChangeType,
13520
13579
  isDeletionInsertion
13521
13580
  });
@@ -15457,7 +15516,7 @@ const canUseDOM = () => {
15457
15516
  return false;
15458
15517
  }
15459
15518
  };
15460
- const summaryVersion = "1.4.0";
15519
+ const summaryVersion = "1.4.1-next.2";
15461
15520
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15462
15521
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15463
15522
  function mapAttributes(attrs) {
@@ -18089,7 +18148,7 @@ class Editor extends EventEmitter {
18089
18148
  * Process collaboration migrations
18090
18149
  */
18091
18150
  processCollaborationMigrations() {
18092
- console.debug("[checkVersionMigrations] Current editor version", "1.4.0");
18151
+ console.debug("[checkVersionMigrations] Current editor version", "1.4.1-next.2");
18093
18152
  if (!this.options.ydoc) return;
18094
18153
  const metaMap = this.options.ydoc.getMap("meta");
18095
18154
  let docVersion = metaMap.get("version");
@@ -23272,7 +23331,6 @@ const SDT_CONTAINER_STYLES = `
23272
23331
  const FIELD_ANNOTATION_STYLES = `
23273
23332
  /* Field annotation draggable styles */
23274
23333
  .superdoc-layout .annotation[data-draggable="true"] {
23275
- cursor: grab;
23276
23334
  user-select: none;
23277
23335
  -webkit-user-select: none;
23278
23336
  }
@@ -27197,12 +27255,15 @@ class DomPainter {
27197
27255
  }
27198
27256
  }
27199
27257
  applyRunStyles(elem, run, isActiveLink);
27200
- const commentColor = getCommentHighlight(run);
27201
- if (commentColor && !run.highlight) {
27258
+ const textRun = run;
27259
+ const commentAnnotations = textRun.comments;
27260
+ const hasAnyComment = !!commentAnnotations?.length;
27261
+ const hasHighlightableComment = !!commentAnnotations?.some((c2) => !c2.trackedChange);
27262
+ const commentColor = getCommentHighlight(textRun);
27263
+ if (commentColor && !textRun.highlight && hasHighlightableComment) {
27202
27264
  elem.style.backgroundColor = commentColor;
27203
27265
  }
27204
- const commentAnnotations = run.comments;
27205
- if (commentAnnotations?.length) {
27266
+ if (hasAnyComment) {
27206
27267
  elem.dataset.commentIds = commentAnnotations.map((c2) => c2.commentId).join(",");
27207
27268
  if (commentAnnotations.some((c2) => c2.internal)) {
27208
27269
  elem.dataset.commentInternal = "true";
@@ -41182,6 +41243,7 @@ const pushCommentAnnotation = (run, attrs) => {
41182
41243
  const commentId = typeof attrs?.commentId === "string" ? attrs.commentId : void 0;
41183
41244
  const importedId = typeof attrs?.importedId === "string" ? attrs.importedId : void 0;
41184
41245
  const internal = attrs?.internal === true;
41246
+ const trackedChange = attrs?.trackedChange === true;
41185
41247
  if (!commentId && !importedId) return;
41186
41248
  const annotations = run.comments ? [...run.comments] : [];
41187
41249
  const key2 = `${commentId ?? ""}::${importedId ?? ""}`;
@@ -41190,7 +41252,8 @@ const pushCommentAnnotation = (run, attrs) => {
41190
41252
  annotations.push({
41191
41253
  commentId: commentId ?? importedId,
41192
41254
  importedId,
41193
- internal
41255
+ internal,
41256
+ trackedChange
41194
41257
  });
41195
41258
  }
41196
41259
  run.comments = annotations;
@@ -52469,6 +52532,40 @@ class PresentationEditor extends EventEmitter {
52469
52532
  this.#editor.view?.focus();
52470
52533
  }
52471
52534
  }
52535
+ #resolveFieldAnnotationSelectionFromElement(annotationEl) {
52536
+ const pmStartRaw = annotationEl.dataset?.pmStart;
52537
+ if (pmStartRaw == null) {
52538
+ return null;
52539
+ }
52540
+ const pmStart = Number(pmStartRaw);
52541
+ if (!Number.isFinite(pmStart)) {
52542
+ return null;
52543
+ }
52544
+ const doc2 = this.#editor.state?.doc;
52545
+ if (!doc2) {
52546
+ return null;
52547
+ }
52548
+ const layoutEpochRaw = annotationEl.dataset?.layoutEpoch;
52549
+ const layoutEpoch = layoutEpochRaw != null ? Number(layoutEpochRaw) : NaN;
52550
+ const effectiveEpoch = Number.isFinite(layoutEpoch) ? layoutEpoch : this.#epochMapper.getCurrentEpoch();
52551
+ const mapped = this.#epochMapper.mapPosFromLayoutToCurrentDetailed(pmStart, effectiveEpoch, 1);
52552
+ if (!mapped.ok) {
52553
+ const fallbackPos = Math.max(0, Math.min(pmStart, doc2.content.size));
52554
+ const fallbackNode = doc2.nodeAt(fallbackPos);
52555
+ if (fallbackNode?.type?.name === "fieldAnnotation") {
52556
+ return { node: fallbackNode, pos: fallbackPos };
52557
+ }
52558
+ this.#pendingDocChange = true;
52559
+ this.#scheduleRerender();
52560
+ return null;
52561
+ }
52562
+ const clampedPos = Math.max(0, Math.min(mapped.pos, doc2.content.size));
52563
+ const node = doc2.nodeAt(clampedPos);
52564
+ if (!node || node.type.name !== "fieldAnnotation") {
52565
+ return null;
52566
+ }
52567
+ return { node, pos: clampedPos };
52568
+ }
52472
52569
  #setupInputBridge() {
52473
52570
  this.#inputBridge?.destroy();
52474
52571
  const win = this.#visibleHost.ownerDocument?.defaultView ?? window;
@@ -52559,8 +52656,30 @@ class PresentationEditor extends EventEmitter {
52559
52656
  linkEl.dispatchEvent(linkClickEvent);
52560
52657
  return;
52561
52658
  }
52659
+ const annotationEl = target?.closest?.(".annotation[data-pm-start]");
52562
52660
  const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
52563
52661
  this.#suppressFocusInFromDraggable = isDraggableAnnotation;
52662
+ if (annotationEl) {
52663
+ if (!this.#editor.isEditable) {
52664
+ return;
52665
+ }
52666
+ const resolved = this.#resolveFieldAnnotationSelectionFromElement(annotationEl);
52667
+ if (resolved) {
52668
+ try {
52669
+ const tr = this.#editor.state.tr.setSelection(superEditor_converter.NodeSelection.create(this.#editor.state.doc, resolved.pos));
52670
+ this.#editor.view?.dispatch(tr);
52671
+ } catch {
52672
+ }
52673
+ this.#editor.emit("fieldAnnotationClicked", {
52674
+ editor: this.#editor,
52675
+ node: resolved.node,
52676
+ nodePos: resolved.pos,
52677
+ event,
52678
+ currentTarget: annotationEl
52679
+ });
52680
+ }
52681
+ return;
52682
+ }
52564
52683
  if (!this.#layoutState.layout) {
52565
52684
  if (!isDraggableAnnotation) {
52566
52685
  event.preventDefault();
@@ -60175,6 +60294,10 @@ const CommentsMark = Mark.create({
60175
60294
  internal: {
60176
60295
  default: true,
60177
60296
  rendered: false
60297
+ },
60298
+ trackedChange: {
60299
+ default: false,
60300
+ rendered: false
60178
60301
  }
60179
60302
  };
60180
60303
  },
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-B6VX2S0H.es.js";
2
- import "./SuperConverter-DAO7c_d4.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-BQPLVzyQ.es.js";
2
+ import "./SuperConverter-BJi_tRyc.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -5113,11 +5113,14 @@ const groupChanges = (changes) => {
5113
5113
  trackFormat: "formatMark"
5114
5114
  };
5115
5115
  const grouped = [];
5116
+ const processed = /* @__PURE__ */ new Set();
5116
5117
  for (let i = 0; i < changes.length; i++) {
5118
+ if (processed.has(i)) continue;
5117
5119
  const c1 = changes[i];
5118
- const c2 = changes[i + 1];
5119
5120
  const c1Key = markMetaKeys[c1.mark.type.name];
5120
- if (c1 && c2 && c1.to === c2.from && c1.mark.attrs.id === c2.mark.attrs.id) {
5121
+ const c1Id = c1.mark.attrs.id;
5122
+ const c2 = changes[i + 1];
5123
+ if (c2 && c1.to === c2.from && c1Id === c2.mark.attrs.id) {
5121
5124
  const c2Key = markMetaKeys[c2.mark.type.name];
5122
5125
  grouped.push({
5123
5126
  from: c1.from,
@@ -5125,13 +5128,35 @@ const groupChanges = (changes) => {
5125
5128
  [c1Key]: c1,
5126
5129
  [c2Key]: c2
5127
5130
  });
5128
- i++;
5129
- } else {
5131
+ processed.add(i);
5132
+ processed.add(i + 1);
5133
+ continue;
5134
+ }
5135
+ let foundMatch = false;
5136
+ for (let j = i + 1; j < changes.length; j++) {
5137
+ if (processed.has(j)) continue;
5138
+ const c22 = changes[j];
5139
+ if (c1Id === c22.mark.attrs.id && c1.mark.type.name !== c22.mark.type.name) {
5140
+ const c2Key = markMetaKeys[c22.mark.type.name];
5141
+ grouped.push({
5142
+ from: Math.min(c1.from, c22.from),
5143
+ to: Math.max(c1.to, c22.to),
5144
+ [c1Key]: c1,
5145
+ [c2Key]: c22
5146
+ });
5147
+ processed.add(i);
5148
+ processed.add(j);
5149
+ foundMatch = true;
5150
+ break;
5151
+ }
5152
+ }
5153
+ if (!foundMatch) {
5130
5154
  grouped.push({
5131
5155
  from: c1.from,
5132
5156
  to: c1.to,
5133
5157
  [c1Key]: c1
5134
5158
  });
5159
+ processed.add(i);
5135
5160
  }
5136
5161
  }
5137
5162
  return grouped;
@@ -5433,7 +5458,12 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5433
5458
  trackedChange: comment.trackedChange || false,
5434
5459
  trackedChangeText: comment.trackedChangeText,
5435
5460
  trackedChangeType: comment.trackedChangeType,
5436
- deletedText: comment.trackedDeletedText
5461
+ deletedText: comment.trackedDeletedText,
5462
+ // Preserve origin metadata for export
5463
+ origin: comment.origin || "word",
5464
+ // Default to 'word' for backward compatibility
5465
+ threadingMethod: comment.threadingMethod,
5466
+ originalXmlStructure: comment.originalXmlStructure
5437
5467
  });
5438
5468
  addComment({ superdoc, comment: newComment });
5439
5469
  });
@@ -6213,7 +6243,11 @@ const _sfc_main$c = {
6213
6243
  const isThreadedComment = c2.parentCommentId === parentComment.commentId;
6214
6244
  const isThisComment = c2.commentId === props.comment.commentId;
6215
6245
  return isThreadedComment || isThisComment;
6216
- }).sort((a, b) => a.commentId === props.comment.commentId && a.createdTime - b.createdTime);
6246
+ }).sort((a, b) => {
6247
+ if (a.commentId === props.comment.commentId) return -1;
6248
+ if (b.commentId === props.comment.commentId) return 1;
6249
+ return a.createdTime - b.createdTime;
6250
+ });
6217
6251
  });
6218
6252
  const isInternalDropdownDisabled = computed(() => {
6219
6253
  if (props.comment.resolvedTime) return true;
@@ -6472,7 +6506,7 @@ const _sfc_main$c = {
6472
6506
  };
6473
6507
  }
6474
6508
  };
6475
- const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-d50fd675"]]);
6509
+ const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-f9956635"]]);
6476
6510
  const _hoisted_1$a = { class: "comments-list" };
6477
6511
  const _hoisted_2$5 = { key: 0 };
6478
6512
  const _hoisted_3$3 = { class: "comment-item" };
@@ -7479,7 +7513,7 @@ const _sfc_main = {
7479
7513
  __name: "SuperDoc",
7480
7514
  emits: ["selection-update"],
7481
7515
  setup(__props, { emit: __emit }) {
7482
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CihMmpz1.es.js"));
7516
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-JG6s_6rr.es.js"));
7483
7517
  const superdocStore = useSuperdocStore();
7484
7518
  const commentsStore = useCommentsStore();
7485
7519
  const {
@@ -8433,7 +8467,7 @@ class SuperDoc extends EventEmitter {
8433
8467
  this.config.colors = shuffleArray(this.config.colors);
8434
8468
  this.userColorMap = /* @__PURE__ */ new Map();
8435
8469
  this.colorIndex = 0;
8436
- this.version = "1.4.0";
8470
+ this.version = "1.4.1-next.2";
8437
8471
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8438
8472
  this.superdocId = config.superdocId || v4();
8439
8473
  this.colors = this.config.colors;
package/dist/style.css CHANGED
@@ -2299,32 +2299,32 @@ span[data-v-53e13009] {
2299
2299
  display: inline-block;
2300
2300
  }
2301
2301
 
2302
- .change-type[data-v-d50fd675] {
2302
+ .change-type[data-v-f9956635] {
2303
2303
  font-style: italic;
2304
2304
  font-weight: 600;
2305
2305
  font-size: 10px;
2306
2306
  color: #555;
2307
2307
  }
2308
- .tracked-change[data-v-d50fd675] {
2308
+ .tracked-change[data-v-f9956635] {
2309
2309
  font-size: 12px;
2310
2310
  }
2311
- .tracked-change-text[data-v-d50fd675] {
2311
+ .tracked-change-text[data-v-f9956635] {
2312
2312
  color: #111;
2313
2313
  }
2314
- .comment-separator[data-v-d50fd675] {
2314
+ .comment-separator[data-v-f9956635] {
2315
2315
  background-color: #dbdbdb;
2316
2316
  height: 1px;
2317
2317
  width: 100%;
2318
2318
  margin: 10px 0;
2319
2319
  font-weight: 400;
2320
2320
  }
2321
- .existing-internal-input[data-v-d50fd675] {
2321
+ .existing-internal-input[data-v-f9956635] {
2322
2322
  margin-bottom: 10px;
2323
2323
  }
2324
- .initial-internal-dropdown[data-v-d50fd675] {
2324
+ .initial-internal-dropdown[data-v-f9956635] {
2325
2325
  margin-top: 10px;
2326
2326
  }
2327
- .comments-dialog[data-v-d50fd675] {
2327
+ .comments-dialog[data-v-f9956635] {
2328
2328
  display: flex;
2329
2329
  flex-direction: column;
2330
2330
  padding: 10px 15px;
@@ -2340,39 +2340,39 @@ span[data-v-53e13009] {
2340
2340
  min-width: 200px;
2341
2341
  width: 100%;
2342
2342
  }
2343
- .is-active[data-v-d50fd675] {
2343
+ .is-active[data-v-f9956635] {
2344
2344
  z-index: 10;
2345
2345
  }
2346
- .input-section[data-v-d50fd675] {
2346
+ .input-section[data-v-f9956635] {
2347
2347
  margin-top: 10px;
2348
2348
  }
2349
- .sd-button[data-v-d50fd675] {
2349
+ .sd-button[data-v-f9956635] {
2350
2350
  font-size: 12px;
2351
2351
  margin-left: 5px;
2352
2352
  }
2353
- .comment[data-v-d50fd675] {
2353
+ .comment[data-v-f9956635] {
2354
2354
  font-size: 13px;
2355
2355
  margin: 10px 0;
2356
2356
  }
2357
- .is-resolved[data-v-d50fd675] {
2357
+ .is-resolved[data-v-f9956635] {
2358
2358
  background-color: #f0f0f0;
2359
2359
  }
2360
- .comment-footer[data-v-d50fd675] {
2360
+ .comment-footer[data-v-f9956635] {
2361
2361
  margin: 5px 0 5px;
2362
2362
  display: flex;
2363
2363
  justify-content: flex-end;
2364
2364
  width: 100%;
2365
2365
  }
2366
- .internal-dropdown[data-v-d50fd675] {
2366
+ .internal-dropdown[data-v-f9956635] {
2367
2367
  display: inline-block;
2368
2368
  }
2369
- .comment-editing[data-v-d50fd675] {
2369
+ .comment-editing[data-v-f9956635] {
2370
2370
  padding-bottom: 10px;
2371
2371
  }
2372
- .comment-editing button[data-v-d50fd675] {
2372
+ .comment-editing button[data-v-f9956635] {
2373
2373
  margin-left: 5px;
2374
2374
  }
2375
- .tracked-change[data-v-d50fd675] {
2375
+ .tracked-change[data-v-f9956635] {
2376
2376
  margin: 0;
2377
2377
  }
2378
2378
 
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../chunks/jszip-C8_CqJxM.cjs");
4
4
  require("../chunks/helpers-nOdwpmwb.cjs");
5
- const superEditor_converter = require("../chunks/SuperConverter-C4XfNZf6.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-Bukam51x.cjs");
6
6
  require("../chunks/uuid-R7L08bOx.cjs");
7
7
  exports.SuperConverter = superEditor_converter.SuperConverter;
@@ -1,6 +1,6 @@
1
1
  import "../chunks/jszip-B1fkPkPJ.es.js";
2
2
  import "../chunks/helpers-C8e9wR5l.es.js";
3
- import { S } from "../chunks/SuperConverter-DAO7c_d4.es.js";
3
+ import { S } from "../chunks/SuperConverter-BJi_tRyc.es.js";
4
4
  import "../chunks/uuid-CjlX8hrF.es.js";
5
5
  export {
6
6
  S as SuperConverter
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-BKXWekME.cjs");
3
+ const index = require("./chunks/index-DS7Ttafb.cjs");
4
4
  const superEditor_docxZipper = require("./super-editor/docx-zipper.cjs");
5
5
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
6
6
  const vue = require("./chunks/vue-De9wkgLl.cjs");
7
- const superEditor_converter = require("./chunks/SuperConverter-C4XfNZf6.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-Bukam51x.cjs");
8
8
  function isNodeType(node, name) {
9
9
  return node.type.name === name;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { ax as Node, ay as Mark } from "./chunks/index-B6VX2S0H.es.js";
2
- import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-B6VX2S0H.es.js";
1
+ import { ax as Node, ay as Mark } from "./chunks/index-BQPLVzyQ.es.js";
2
+ import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-BQPLVzyQ.es.js";
3
3
  import { default as default2 } from "./super-editor/docx-zipper.es.js";
4
4
  import { createZip } from "./super-editor/file-zipper.es.js";
5
5
  import { d as defineComponent, E as createElementBlock, G as openBlock, K as createBaseVNode } from "./chunks/vue-BnBKJwCW.es.js";
6
- import { S, r } from "./chunks/SuperConverter-DAO7c_d4.es.js";
6
+ import { S, r } from "./chunks/SuperConverter-BJi_tRyc.es.js";
7
7
  function isNodeType(node, name) {
8
8
  return node.type.name === name;
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-comment.d.ts","sourceRoot":"","sources":["../../../../../src/components/CommentsLayer/use-comment.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,2CAHW,MAAM,GACJ,MAAM,CA0RlB"}
1
+ {"version":3,"file":"use-comment.d.ts","sourceRoot":"","sources":["../../../../../src/components/CommentsLayer/use-comment.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,2CAHW,MAAM,GACJ,MAAM,CAuRlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"group-changes.d.ts","sourceRoot":"","sources":["../../../../src/helpers/group-changes.js"],"names":[],"mappings":"AAQO,oDA+BN"}
1
+ {"version":3,"file":"group-changes.d.ts","sourceRoot":"","sources":["../../../../src/helpers/group-changes.js"],"names":[],"mappings":"AAQO,oDA+DN"}
@@ -1 +1 @@
1
- {"version":3,"file":"comments-store.d.ts","sourceRoot":"","sources":["../../../../src/stores/comments-store.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAiDa,MAAM,KACJ,IAAI;;qBAiBN,MAAM,KACJ,MAAM;0CAuBR,MAAM,GAAG,SAAS,GAAG,IAAI,KACvB,IAAI;;;;;;gFA+Ld;QAAuB,SAAS,EAAxB,MAAM;QACS,UAAU;QACV,eAAe;KACtC,KAAU,MAAM;;0DAqDhB;QAAuB,QAAQ,EAAvB,MAAM;KACd,KAAU,IAAI;sCAyEJ,IAAI;;;;;6CAzFJ,IAAI;4EAsGd;QAAsB,QAAQ;QACP,UAAU;KACjC,KAAU,IAAI;;+DA0HJ,IAAI;;sDAlbd;QAAuB,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;KACd,KAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBArEN,MAAM,KACJ,IAAI;;qBAiBN,MAAM,KACJ,MAAM;0CAuBR,MAAM,GAAG,SAAS,GAAG,IAAI,KACvB,IAAI;;;;;;gFA+Ld;QAAuB,SAAS,EAAxB,MAAM;QACS,UAAU;QACV,eAAe;KACtC,KAAU,MAAM;;0DAqDhB;QAAuB,QAAQ,EAAvB,MAAM;KACd,KAAU,IAAI;sCAyEJ,IAAI;;;;;6CAzFJ,IAAI;4EAsGd;QAAsB,QAAQ;QACP,UAAU;KACjC,KAAU,IAAI;;+DA0HJ,IAAI;;sDAlbd;QAAuB,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;KACd,KAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBArEN,MAAM,KACJ,IAAI;;qBAiBN,MAAM,KACJ,MAAM;0CAuBR,MAAM,GAAG,SAAS,GAAG,IAAI,KACvB,IAAI;;;;;;gFA+Ld;QAAuB,SAAS,EAAxB,MAAM;QACS,UAAU;QACV,eAAe;KACtC,KAAU,MAAM;;0DAqDhB;QAAuB,QAAQ,EAAvB,MAAM;KACd,KAAU,IAAI;sCAyEJ,IAAI;;;;;6CAzFJ,IAAI;4EAsGd;QAAsB,QAAQ;QACP,UAAU;KACjC,KAAU,IAAI;;+DA0HJ,IAAI;;sDAlbd;QAAuB,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;KACd,KAAU,IAAI;iYA+kBhB"}
1
+ {"version":3,"file":"comments-store.d.ts","sourceRoot":"","sources":["../../../../src/stores/comments-store.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAiDa,MAAM,KACJ,IAAI;;qBAiBN,MAAM,KACJ,MAAM;0CAuBR,MAAM,GAAG,SAAS,GAAG,IAAI,KACvB,IAAI;;;;;;gFA+Ld;QAAuB,SAAS,EAAxB,MAAM;QACS,UAAU;QACV,eAAe;KACtC,KAAU,MAAM;;0DAqDhB;QAAuB,QAAQ,EAAvB,MAAM;KACd,KAAU,IAAI;sCAyEJ,IAAI;;;;;6CAzFJ,IAAI;4EAsGd;QAAsB,QAAQ;QACP,UAAU;KACjC,KAAU,IAAI;;+DA8HJ,IAAI;;sDAtbd;QAAuB,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;KACd,KAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBArEN,MAAM,KACJ,IAAI;;qBAiBN,MAAM,KACJ,MAAM;0CAuBR,MAAM,GAAG,SAAS,GAAG,IAAI,KACvB,IAAI;;;;;;gFA+Ld;QAAuB,SAAS,EAAxB,MAAM;QACS,UAAU;QACV,eAAe;KACtC,KAAU,MAAM;;0DAqDhB;QAAuB,QAAQ,EAAvB,MAAM;KACd,KAAU,IAAI;sCAyEJ,IAAI;;;;;6CAzFJ,IAAI;4EAsGd;QAAsB,QAAQ;QACP,UAAU;KACjC,KAAU,IAAI;;+DA8HJ,IAAI;;sDAtbd;QAAuB,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;KACd,KAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBArEN,MAAM,KACJ,IAAI;;qBAiBN,MAAM,KACJ,MAAM;0CAuBR,MAAM,GAAG,SAAS,GAAG,IAAI,KACvB,IAAI;;;;;;gFA+Ld;QAAuB,SAAS,EAAxB,MAAM;QACS,UAAU;QACV,eAAe;KACtC,KAAU,MAAM;;0DAqDhB;QAAuB,QAAQ,EAAvB,MAAM;KACd,KAAU,IAAI;sCAyEJ,IAAI;;;;;6CAzFJ,IAAI;4EAsGd;QAAsB,QAAQ;QACP,UAAU;KACjC,KAAU,IAAI;;+DA8HJ,IAAI;;sDAtbd;QAAuB,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;KACd,KAAU,IAAI;iYAmlBhB"}
package/dist/superdoc.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-BKXWekME.cjs");
4
- const superdoc = require("./chunks/index-CZ5yJPHg.cjs");
5
- const superEditor_converter = require("./chunks/SuperConverter-C4XfNZf6.cjs");
3
+ const index = require("./chunks/index-DS7Ttafb.cjs");
4
+ const superdoc = require("./chunks/index-CZMyxx0v.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-Bukam51x.cjs");
6
6
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
7
7
  require("./chunks/jszip-C8_CqJxM.cjs");
8
8
  require("./chunks/helpers-nOdwpmwb.cjs");
@@ -1,6 +1,6 @@
1
- import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-B6VX2S0H.es.js";
2
- import { D, H, P, S, c } from "./chunks/index-DbSiW7hc.es.js";
3
- import { S as S2, r } from "./chunks/SuperConverter-DAO7c_d4.es.js";
1
+ import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-BQPLVzyQ.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-QUPzhiU8.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-BJi_tRyc.es.js";
4
4
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
5
5
  import "./chunks/jszip-B1fkPkPJ.es.js";
6
6
  import "./chunks/helpers-C8e9wR5l.es.js";