@harbour-enterprises/superdoc 1.3.0-next.7 → 1.3.0-next.9

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,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-CmmcvSxn.cjs");
3
- require("./SuperConverter-BIrkxV37.cjs");
2
+ const index = require("./index-CqzJ4gdV.cjs");
3
+ require("./SuperConverter-BuhT_Z5G.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
6
6
  const provider = require("@hocuspocus/provider");
@@ -5495,6 +5495,9 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5495
5495
  const handleEditorLocationsUpdate = (allCommentPositions) => {
5496
5496
  editorCommentPositions.value = allCommentPositions || {};
5497
5497
  };
5498
+ const clearEditorCommentPositions = () => {
5499
+ editorCommentPositions.value = {};
5500
+ };
5498
5501
  const getFloatingComments = vue.computed(() => {
5499
5502
  const comments = getGroupedComments.value?.parentComments.filter((c) => !c.resolvedTime).filter((c) => {
5500
5503
  const keys = Object.keys(editorCommentPositions.value);
@@ -5597,6 +5600,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5597
5600
  processLoadedDocxComments,
5598
5601
  translateCommentsForExport,
5599
5602
  handleEditorLocationsUpdate,
5603
+ clearEditorCommentPositions,
5600
5604
  handleTrackedChangeUpdate
5601
5605
  };
5602
5606
  });
@@ -7461,7 +7465,7 @@ const _sfc_main = {
7461
7465
  __name: "SuperDoc",
7462
7466
  emits: ["selection-update"],
7463
7467
  setup(__props, { emit: __emit }) {
7464
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-BolWPjJ9.cjs")));
7468
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-D5wFkJWQ.cjs")));
7465
7469
  const superdocStore = useSuperdocStore();
7466
7470
  const commentsStore = useCommentsStore();
7467
7471
  const {
@@ -8367,7 +8371,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8367
8371
  this.config.colors = shuffleArray(this.config.colors);
8368
8372
  this.userColorMap = /* @__PURE__ */ new Map();
8369
8373
  this.colorIndex = 0;
8370
- this.version = "1.3.0-next.7";
8374
+ this.version = "1.3.0-next.9";
8371
8375
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8372
8376
  this.superdocId = config.superdocId || uuid.v4();
8373
8377
  this.colors = this.config.colors;
@@ -8884,7 +8888,8 @@ class SuperDoc extends eventemitter3.EventEmitter {
8884
8888
  }
8885
8889
  #setModeViewing() {
8886
8890
  this.toolbar.activeEditor = null;
8887
- this.setTrackedChangesPreferences({ mode: "original", enabled: false });
8891
+ this.setTrackedChangesPreferences({ mode: "original", enabled: true });
8892
+ this.commentsStore?.clearEditorCommentPositions?.();
8888
8893
  this.superdocStore.documents.forEach((doc) => {
8889
8894
  doc.removeComments();
8890
8895
  this.#applyDocumentMode(doc, "viewing");
@@ -1,6 +1,6 @@
1
1
  import { B as Buffer$2 } from "./jszip-B1fkPkPJ.es.js";
2
2
  import { t as twipsToInches, i as inchesToTwips, p as ptToTwips, l as linesToTwips, a as twipsToLines, b as pixelsToTwips, h as halfPointToPoints, c as twipsToPixels$2, d as convertSizeToCSS, e as inchesToPixels } from "./helpers-C8e9wR5l.es.js";
3
- import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as _getReferencedTableStyles, a4 as decodeRPrFromMarks, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString } from "./SuperConverter-Bc9dM-qO.es.js";
3
+ import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as _getReferencedTableStyles, a4 as decodeRPrFromMarks, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString } from "./SuperConverter-lLx4GqcF.es.js";
4
4
  import { p as process$1, r as ref, C as global$1, c as computed, E as createElementBlock, F as Fragment$1, S as renderList, O as withModifiers, G as openBlock, P as normalizeClass, M as createCommentVNode, H as toDisplayString, K as createBaseVNode, U as createApp, f as onMounted, X as onUnmounted, R as withDirectives, v as unref, Y as vModelText, y as nextTick, L as normalizeStyle, u as watch, Z as withKeys, _ as createTextVNode, I as createVNode, h, $ as readonly, s as getCurrentInstance, o as onBeforeUnmount, j as reactive, b as onBeforeMount, i as inject, a0 as onActivated, a1 as onDeactivated, a2 as Comment, d as defineComponent, a as provide, g as Teleport, t as toRef, a3 as renderSlot, a4 as isVNode, D as shallowRef, w as watchEffect, T as Transition, a5 as mergeProps, a6 as vShow, a7 as cloneVNode, a8 as Text$2, m as markRaw, N as createBlock, J as withCtx, a9 as useCssVars, V as resolveDynamicComponent, aa as normalizeProps, ab as guardReactiveProps } from "./vue-BnBKJwCW.es.js";
5
5
  import "./jszip.min-DCl8qkFO.es.js";
6
6
  import { E as EventEmitter$1 } from "./eventemitter3-CwrdEv8r.es.js";
@@ -13202,8 +13202,8 @@ const CommentsPlugin = Extension.create({
13202
13202
  }
13203
13203
  if (!onlyActiveThreadChanged) {
13204
13204
  const positionsChanged = hasPositionsChanged(prevAllCommentPositions, allCommentPositions);
13205
- const hasComments = Object.keys(allCommentPositions).length > 0;
13206
- const shouldEmitPositions = positionsChanged || !hasEverEmitted && hasComments;
13205
+ const hasComments2 = Object.keys(allCommentPositions).length > 0;
13206
+ const shouldEmitPositions = positionsChanged || !hasEverEmitted && hasComments2;
13207
13207
  if (shouldEmitPositions) {
13208
13208
  prevAllCommentPositions = allCommentPositions;
13209
13209
  hasEverEmitted = true;
@@ -15334,7 +15334,7 @@ const canUseDOM = () => {
15334
15334
  return false;
15335
15335
  }
15336
15336
  };
15337
- const summaryVersion = "1.3.0-next.7";
15337
+ const summaryVersion = "1.3.0-next.9";
15338
15338
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15339
15339
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15340
15340
  function mapAttributes(attrs) {
@@ -17967,7 +17967,7 @@ class Editor extends EventEmitter {
17967
17967
  * Process collaboration migrations
17968
17968
  */
17969
17969
  processCollaborationMigrations() {
17970
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.7");
17970
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.9");
17971
17971
  if (!this.options.ydoc) return;
17972
17972
  const metaMap = this.options.ydoc.getMap("meta");
17973
17973
  let docVersion = metaMap.get("version");
@@ -28198,7 +28198,9 @@ const deriveBlockVersion = (block) => {
28198
28198
  textRun.pmEnd ?? "",
28199
28199
  textRun.token ?? "",
28200
28200
  // Tracked changes - force re-render when added or removed tracked change
28201
- textRun.trackedChange ? 1 : 0
28201
+ textRun.trackedChange ? 1 : 0,
28202
+ // Comment annotations - force re-render when comments are enabled/disabled
28203
+ textRun.comments?.length ?? 0
28202
28204
  ].join(",");
28203
28205
  }).join("|");
28204
28206
  const attrs = block.attrs;
@@ -34070,6 +34072,9 @@ const hashCellBorders = (borders) => {
34070
34072
  if (borders.left) parts.push(`l:[${hashBorderSpec(borders.left)}]`);
34071
34073
  return parts.join(";");
34072
34074
  };
34075
+ function hasComments$1(run) {
34076
+ return "comments" in run && Array.isArray(run.comments) && run.comments.length > 0;
34077
+ }
34073
34078
  const MAX_CACHE_SIZE$1 = 1e4;
34074
34079
  const BYTES_PER_ENTRY_ESTIMATE = 5e3;
34075
34080
  const hashParagraphFrame = (frame) => {
@@ -34137,6 +34142,7 @@ const hashRuns = (block) => {
34137
34142
  fontFamily2 ? `ff:${fontFamily2}` : "",
34138
34143
  highlight ? `hl:${highlight}` : ""
34139
34144
  ].join("");
34145
+ const commentHash = hasComments$1(run) ? run.comments.map((c2) => `${c2.commentId ?? ""}:${c2.internal ? "1" : "0"}`).join("|") : "";
34140
34146
  let trackedKey = "";
34141
34147
  if (hasTrackedChange(run)) {
34142
34148
  const tc = run.trackedChange;
@@ -34144,7 +34150,8 @@ const hashRuns = (block) => {
34144
34150
  const afterHash = tc.after ? JSON.stringify(tc.after) : "";
34145
34151
  trackedKey = `|tc:${tc.kind ?? ""}:${tc.id ?? ""}:${tc.author ?? ""}:${tc.date ?? ""}:${beforeHash}:${afterHash}`;
34146
34152
  }
34147
- cellHashes.push(`${text}:${marks}${trackedKey}`);
34153
+ const commentKey = commentHash ? `|cm:${commentHash}` : "";
34154
+ cellHashes.push(`${text}:${marks}${trackedKey}${commentKey}`);
34148
34155
  }
34149
34156
  if (paragraphBlock.attrs) {
34150
34157
  const attrs = paragraphBlock.attrs;
@@ -35275,6 +35282,9 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
35275
35282
  const totalHeight = lines.reduce((s2, l) => s2 + l.lineHeight, 0);
35276
35283
  return { kind: "paragraph", lines, totalHeight };
35277
35284
  }
35285
+ function hasComments(run) {
35286
+ return "comments" in run && Array.isArray(run.comments) && run.comments.length > 0;
35287
+ }
35278
35288
  const computeDirtyRegions = (previous, next) => {
35279
35289
  const prevMap = new Map(previous.map((block, index2) => [block.id, { block, index: index2 }]));
35280
35290
  const nextMap = new Map(next.map((block, index2) => [block.id, { block, index: index2 }]));
@@ -35335,6 +35345,10 @@ const getTrackedChangeKey = (run) => {
35335
35345
  }
35336
35346
  return "";
35337
35347
  };
35348
+ const getCommentKey = (run) => {
35349
+ if (!hasComments(run)) return "";
35350
+ return run.comments.map((c2) => `${c2.commentId ?? ""}:${c2.internal ? "1" : "0"}`).join("|");
35351
+ };
35338
35352
  const paragraphSpacingEqual = (a, b) => {
35339
35353
  if (a === b) return true;
35340
35354
  if (!a || !b) return !a && !b;
@@ -35416,7 +35430,7 @@ const paragraphBlocksEqual = (a, b) => {
35416
35430
  for (let i = 0; i < a.runs.length; i += 1) {
35417
35431
  const runA = a.runs[i];
35418
35432
  const runB = b.runs[i];
35419
- if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || ("highlight" in runA ? runA.highlight : void 0) !== ("highlight" in runB ? runB.highlight : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
35433
+ if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || ("highlight" in runA ? runA.highlight : void 0) !== ("highlight" in runB ? runB.highlight : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB) || getCommentKey(runA) !== getCommentKey(runB)) {
35420
35434
  return false;
35421
35435
  }
35422
35436
  }
@@ -40166,7 +40180,7 @@ const resetRunFormatting = (run) => {
40166
40180
  delete run.link;
40167
40181
  delete run.letterSpacing;
40168
40182
  };
40169
- const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2, themeColors) => {
40183
+ const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments = true) => {
40170
40184
  const tracked = run.trackedChange;
40171
40185
  if (!tracked || tracked.kind !== "format") {
40172
40186
  return;
@@ -40191,7 +40205,7 @@ const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2,
40191
40205
  }
40192
40206
  resetRunFormatting(run);
40193
40207
  try {
40194
- applyMarksToRun2(run, beforeMarks, hyperlinkConfig, themeColors);
40208
+ applyMarksToRun2(run, beforeMarks, hyperlinkConfig, themeColors, void 0, enableComments);
40195
40209
  } catch (error) {
40196
40210
  if (process$1.env.NODE_ENV === "development") {
40197
40211
  console.warn("[PM-Adapter] Error applying format change marks, resetting formatting:", error);
@@ -40199,7 +40213,7 @@ const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2,
40199
40213
  resetRunFormatting(run);
40200
40214
  }
40201
40215
  };
40202
- const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarksToRun2, themeColors) => {
40216
+ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments = true) => {
40203
40217
  if (!config) {
40204
40218
  return runs;
40205
40219
  }
@@ -40212,7 +40226,7 @@ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarks
40212
40226
  } else {
40213
40227
  runs.forEach((run) => {
40214
40228
  if (isTextRun$1(run)) {
40215
- applyFormatChangeMarks(run, config, hyperlinkConfig, applyMarksToRun2, themeColors);
40229
+ applyFormatChangeMarks(run, config, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments);
40216
40230
  }
40217
40231
  });
40218
40232
  }
@@ -40242,7 +40256,14 @@ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarks
40242
40256
  } else {
40243
40257
  filtered.forEach((run) => {
40244
40258
  if (isTextRun$1(run)) {
40245
- applyFormatChangeMarks(run, config, hyperlinkConfig || DEFAULT_HYPERLINK_CONFIG$1, applyMarksToRun2, themeColors);
40259
+ applyFormatChangeMarks(
40260
+ run,
40261
+ config,
40262
+ hyperlinkConfig || DEFAULT_HYPERLINK_CONFIG$1,
40263
+ applyMarksToRun2,
40264
+ themeColors,
40265
+ enableComments
40266
+ );
40246
40267
  }
40247
40268
  });
40248
40269
  }
@@ -41186,7 +41207,10 @@ const applyTextStyleMark = (run, attrs, themeColors) => {
41186
41207
  const DEFAULT_HYPERLINK_CONFIG = {
41187
41208
  enableRichHyperlinks: false
41188
41209
  };
41189
- const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, backgroundColor) => {
41210
+ const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, backgroundColor, enableComments = true) => {
41211
+ if (!enableComments && "comments" in run && run.comments) {
41212
+ delete run.comments;
41213
+ }
41190
41214
  const isTabRun2 = run.kind === "tab";
41191
41215
  let markSetColor = false;
41192
41216
  marks.forEach((mark) => {
@@ -41233,7 +41257,7 @@ const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG,
41233
41257
  break;
41234
41258
  case "commentMark":
41235
41259
  case "comment": {
41236
- if (!isTabRun2) {
41260
+ if (!isTabRun2 && enableComments) {
41237
41261
  pushCommentAnnotation(run, mark.attrs ?? {});
41238
41262
  }
41239
41263
  break;
@@ -44853,7 +44877,13 @@ const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize
44853
44877
  run.letterSpacing = defaults.letterSpacing;
44854
44878
  }
44855
44879
  };
44856
- function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
44880
+ const applyInlineRunProperties = (run, runProperties) => {
44881
+ if (!runProperties) return;
44882
+ if (runProperties?.letterSpacing != null) {
44883
+ run.letterSpacing = twipsToPx$1(runProperties.letterSpacing);
44884
+ }
44885
+ };
44886
+ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext, enableComments = true) {
44857
44887
  const baseBlockId = nextBlockId("paragraph");
44858
44888
  const paragraphProps = typeof para.attrs?.paragraphProperties === "object" && para.attrs.paragraphProperties !== null ? para.attrs.paragraphProperties : {};
44859
44889
  const paragraphStyleId = typeof para.attrs?.styleId === "string" && para.attrs.styleId.trim() ? para.attrs.styleId : typeof paragraphProps.styleId === "string" && paragraphProps.styleId.trim() ? paragraphProps.styleId : null;
@@ -45005,7 +45035,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45005
45035
  runStyleId
45006
45036
  });
45007
45037
  };
45008
- const visitNode = (node, inheritedMarks = [], activeSdt, activeRunStyleId = null) => {
45038
+ const visitNode = (node, inheritedMarks = [], activeSdt, activeRunStyleId = null, activeRunProperties) => {
45009
45039
  if (node.type === "text" && node.text) {
45010
45040
  const run = textNodeToRun(
45011
45041
  node,
@@ -45021,26 +45051,30 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45021
45051
  const inlineStyleId = getInlineStyleId(inheritedMarks);
45022
45052
  applyRunStyles2(run, inlineStyleId, activeRunStyleId);
45023
45053
  applyBaseRunDefaults(run, baseRunDefaults, defaultFont, defaultSize);
45054
+ applyInlineRunProperties(run, activeRunProperties);
45024
45055
  applyMarksToRun(
45025
45056
  run,
45026
45057
  [...node.marks ?? [], ...inheritedMarks ?? []],
45027
45058
  hyperlinkConfig,
45028
45059
  themeColors,
45029
- converterContext?.backgroundColor
45060
+ converterContext?.backgroundColor,
45061
+ enableComments
45030
45062
  );
45031
45063
  currentRuns.push(run);
45032
45064
  return;
45033
45065
  }
45034
45066
  if (node.type === "run" && Array.isArray(node.content)) {
45035
45067
  const mergedMarks = [...node.marks ?? [], ...inheritedMarks ?? []];
45036
- const nextRunStyleId = extractRunStyleId(node.attrs?.runProperties) ?? activeRunStyleId;
45037
- node.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId));
45068
+ const runProperties = typeof node.attrs?.runProperties === "object" && node.attrs.runProperties !== null ? node.attrs.runProperties : null;
45069
+ const nextRunStyleId = extractRunStyleId(runProperties) ?? activeRunStyleId;
45070
+ const nextRunProperties = runProperties ?? activeRunProperties;
45071
+ node.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId, nextRunProperties));
45038
45072
  return;
45039
45073
  }
45040
45074
  if (node.type === "structuredContent" && Array.isArray(node.content)) {
45041
45075
  const inlineMetadata = resolveNodeSdtMetadata(node, "structuredContent");
45042
45076
  const nextSdt = inlineMetadata ?? activeSdt;
45043
- node.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId));
45077
+ node.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId, activeRunProperties));
45044
45078
  return;
45045
45079
  }
45046
45080
  if (node.type === "fieldAnnotation") {
@@ -45086,7 +45120,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45086
45120
  positions,
45087
45121
  defaultFont,
45088
45122
  defaultSize,
45089
- mergedMarks,
45123
+ [],
45124
+ // Empty marks - will be applied after linked styles
45090
45125
  activeSdt,
45091
45126
  hyperlinkConfig,
45092
45127
  themeColors
@@ -45094,6 +45129,15 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45094
45129
  const inlineStyleId = getInlineStyleId(mergedMarks);
45095
45130
  applyRunStyles2(tokenRun, inlineStyleId, activeRunStyleId);
45096
45131
  applyBaseRunDefaults(tokenRun, baseRunDefaults, defaultFont, defaultSize);
45132
+ applyInlineRunProperties(tokenRun, activeRunProperties);
45133
+ applyMarksToRun(
45134
+ tokenRun,
45135
+ mergedMarks,
45136
+ hyperlinkConfig,
45137
+ themeColors,
45138
+ converterContext?.backgroundColor,
45139
+ enableComments
45140
+ );
45097
45141
  if (pageRefPos) {
45098
45142
  tokenRun.pmStart = pageRefPos.start;
45099
45143
  tokenRun.pmEnd = pageRefPos.end;
@@ -45108,7 +45152,9 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45108
45152
  }
45109
45153
  currentRuns.push(tokenRun);
45110
45154
  } else if (Array.isArray(node.content)) {
45111
- node.content.forEach((child) => visitNode(child, mergedMarks, activeSdt));
45155
+ node.content.forEach(
45156
+ (child) => visitNode(child, mergedMarks, activeSdt, activeRunStyleId, activeRunProperties)
45157
+ );
45112
45158
  }
45113
45159
  return;
45114
45160
  }
@@ -45122,7 +45168,9 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45122
45168
  }
45123
45169
  }
45124
45170
  if (Array.isArray(node.content)) {
45125
- node.content.forEach((child) => visitNode(child, inheritedMarks, activeSdt));
45171
+ node.content.forEach(
45172
+ (child) => visitNode(child, inheritedMarks, activeSdt, activeRunStyleId, activeRunProperties)
45173
+ );
45126
45174
  }
45127
45175
  return;
45128
45176
  }
@@ -45163,7 +45211,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45163
45211
  mergedMarks,
45164
45212
  hyperlinkConfig,
45165
45213
  themeColors,
45166
- converterContext?.backgroundColor
45214
+ converterContext?.backgroundColor,
45215
+ enableComments
45167
45216
  );
45168
45217
  }
45169
45218
  console.debug("[token-debug] paragraph-token-run", {
@@ -45174,6 +45223,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45174
45223
  runStyleId: activeRunStyleId,
45175
45224
  mergedMarksCount: mergedMarks.length
45176
45225
  });
45226
+ applyInlineRunProperties(tokenRun, activeRunProperties);
45177
45227
  currentRuns.push(tokenRun);
45178
45228
  }
45179
45229
  return;
@@ -45361,7 +45411,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45361
45411
  trackedChanges,
45362
45412
  hyperlinkConfig,
45363
45413
  applyMarksToRun,
45364
- themeColors
45414
+ themeColors,
45415
+ enableComments
45365
45416
  );
45366
45417
  if (trackedChanges.enabled && filteredRuns.length === 0) {
45367
45418
  return;
@@ -46260,6 +46311,7 @@ function toFlowBlocks(pmDoc, options) {
46260
46311
  const hyperlinkConfig = {
46261
46312
  enableRichHyperlinks: options?.enableRichHyperlinks ?? false
46262
46313
  };
46314
+ const enableComments = options?.enableComments ?? true;
46263
46315
  const themeColors = options?.themeColors;
46264
46316
  const converterContext = options?.converterContext;
46265
46317
  if (!doc2.content) {
@@ -46309,7 +46361,8 @@ function toFlowBlocks(pmDoc, options) {
46309
46361
  bookmarks2,
46310
46362
  hyperlinkConfig2,
46311
46363
  themeColorsParam ?? themeColors,
46312
- converterCtx ?? converterContext
46364
+ converterCtx ?? converterContext,
46365
+ enableComments
46313
46366
  );
46314
46367
  const tableConverter = (node, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2, themeColorsParam, converterCtx) => tableNodeToBlock(
46315
46368
  node,
@@ -46348,6 +46401,7 @@ function toFlowBlocks(pmDoc, options) {
46348
46401
  listCounterContext: { getListCounter, incrementListCounter, resetListCounter },
46349
46402
  trackedChangesConfig,
46350
46403
  hyperlinkConfig,
46404
+ enableComments,
46351
46405
  bookmarks,
46352
46406
  sectionState: {
46353
46407
  ranges: sectionRanges,
@@ -46416,7 +46470,7 @@ function mergeDropCapParagraphs(blocks) {
46416
46470
  }
46417
46471
  return result;
46418
46472
  }
46419
- function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converterContext) {
46473
+ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converterContext, enableComments = true) {
46420
46474
  return paragraphToFlowBlocks$1(
46421
46475
  para,
46422
46476
  nextBlockId,
@@ -46463,7 +46517,8 @@ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaul
46463
46517
  }
46464
46518
  )
46465
46519
  },
46466
- converterContext
46520
+ converterContext,
46521
+ enableComments
46467
46522
  );
46468
46523
  }
46469
46524
  function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize, styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, _paragraphToFlowBlocksParam, converterContext, options) {
@@ -48350,6 +48405,7 @@ async function measureParagraphBlock(block, maxWidth) {
48350
48405
  let lastFontSize = 12;
48351
48406
  let tabStopCursor = 0;
48352
48407
  let pendingTabAlignment = null;
48408
+ let pendingRunSpacing = 0;
48353
48409
  let lastAppliedTabAlign = null;
48354
48410
  const warnedTabVals = /* @__PURE__ */ new Set();
48355
48411
  let activeTabGroup = null;
@@ -48360,6 +48416,10 @@ async function measureParagraphBlock(block, maxWidth) {
48360
48416
  }
48361
48417
  return true;
48362
48418
  };
48419
+ const resolveBoundarySpacing = (lineWidth, isRunStart, run) => {
48420
+ if (lineWidth <= 0) return 0;
48421
+ return isRunStart ? pendingRunSpacing : run.letterSpacing ?? 0;
48422
+ };
48363
48423
  const alignPendingTabForWidth = (segmentWidth, beforeDecimalWidth) => {
48364
48424
  if (!pendingTabAlignment || !currentLine) return void 0;
48365
48425
  if (segmentWidth < 0) {
@@ -48487,6 +48547,7 @@ async function measureParagraphBlock(block, maxWidth) {
48487
48547
  tabStopCursor = 0;
48488
48548
  pendingTabAlignment = null;
48489
48549
  lastAppliedTabAlign = null;
48550
+ pendingRunSpacing = 0;
48490
48551
  continue;
48491
48552
  }
48492
48553
  if (isLineBreakRun(run)) {
@@ -48529,6 +48590,7 @@ async function measureParagraphBlock(block, maxWidth) {
48529
48590
  tabStopCursor = 0;
48530
48591
  pendingTabAlignment = null;
48531
48592
  lastAppliedTabAlign = null;
48593
+ pendingRunSpacing = 0;
48532
48594
  continue;
48533
48595
  }
48534
48596
  if (isTabRun(run)) {
@@ -48594,6 +48656,7 @@ async function measureParagraphBlock(block, maxWidth) {
48594
48656
  } else {
48595
48657
  pendingTabAlignment = null;
48596
48658
  }
48659
+ pendingRunSpacing = 0;
48597
48660
  continue;
48598
48661
  }
48599
48662
  if (isImageRun(run)) {
@@ -48632,6 +48695,7 @@ async function measureParagraphBlock(block, maxWidth) {
48632
48695
  }
48633
48696
  ]
48634
48697
  };
48698
+ pendingRunSpacing = 0;
48635
48699
  if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex) {
48636
48700
  activeTabGroup = null;
48637
48701
  }
@@ -48693,6 +48757,7 @@ async function measureParagraphBlock(block, maxWidth) {
48693
48757
  currentLine.width = roundValue(tabAlign.target);
48694
48758
  }
48695
48759
  lastAppliedTabAlign = null;
48760
+ pendingRunSpacing = 0;
48696
48761
  continue;
48697
48762
  }
48698
48763
  if (isFieldAnnotationRun(run)) {
@@ -48732,6 +48797,7 @@ async function measureParagraphBlock(block, maxWidth) {
48732
48797
  }
48733
48798
  ]
48734
48799
  };
48800
+ pendingRunSpacing = 0;
48735
48801
  continue;
48736
48802
  }
48737
48803
  if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
@@ -48784,9 +48850,11 @@ async function measureParagraphBlock(block, maxWidth) {
48784
48850
  currentLine.width = roundValue(tabAlign.target);
48785
48851
  }
48786
48852
  lastAppliedTabAlign = null;
48853
+ pendingRunSpacing = 0;
48787
48854
  continue;
48788
48855
  }
48789
48856
  if (!("text" in run) || !("fontSize" in run)) {
48857
+ pendingRunSpacing = 0;
48790
48858
  continue;
48791
48859
  }
48792
48860
  lastFontSize = run.fontSize;
@@ -48797,6 +48865,7 @@ async function measureParagraphBlock(block, maxWidth) {
48797
48865
  const segment = tabSegments[segmentIndex];
48798
48866
  const isLastSegment = segmentIndex === tabSegments.length - 1;
48799
48867
  if (/^[ ]+$/.test(segment)) {
48868
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0;
48800
48869
  const spacesLength = segment.length;
48801
48870
  const spacesStartChar = charPosInRun;
48802
48871
  const spacesEndChar = charPosInRun + spacesLength;
@@ -48815,7 +48884,7 @@ async function measureParagraphBlock(block, maxWidth) {
48815
48884
  spaceCount: spacesLength
48816
48885
  };
48817
48886
  } else {
48818
- const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
48887
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run);
48819
48888
  if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
48820
48889
  trimTrailingWrapSpaces(currentLine);
48821
48890
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -48879,6 +48948,7 @@ async function measureParagraphBlock(block, maxWidth) {
48879
48948
  const spaceStartChar = charPosInRun;
48880
48949
  const spaceEndChar = charPosInRun + 1;
48881
48950
  const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run, spaceStartChar);
48951
+ const isRunStart2 = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
48882
48952
  if (!currentLine) {
48883
48953
  currentLine = {
48884
48954
  fromRun: runIndex,
@@ -48893,7 +48963,7 @@ async function measureParagraphBlock(block, maxWidth) {
48893
48963
  spaceCount: 1
48894
48964
  };
48895
48965
  } else {
48896
- const boundarySpacing2 = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
48966
+ const boundarySpacing2 = resolveBoundarySpacing(currentLine.width, isRunStart2, run);
48897
48967
  if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
48898
48968
  trimTrailingWrapSpaces(currentLine);
48899
48969
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -49078,7 +49148,8 @@ async function measureParagraphBlock(block, maxWidth) {
49078
49148
  continue;
49079
49149
  }
49080
49150
  const isTocEntry = block.attrs?.isTocEntry;
49081
- const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
49151
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
49152
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run);
49082
49153
  const justifyAlignment = block.attrs?.alignment === "justify";
49083
49154
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
49084
49155
  (shouldIncludeDelimiterSpace ? run.letterSpacing ?? 0 : 0);
@@ -49246,6 +49317,7 @@ async function measureParagraphBlock(block, maxWidth) {
49246
49317
  }
49247
49318
  }
49248
49319
  }
49320
+ pendingRunSpacing = run.letterSpacing ?? 0;
49249
49321
  }
49250
49322
  if (!currentLine && lines.length === 0) {
49251
49323
  const uiDisplayFallbackFontSize = (block.runs[0]?.kind === "text" ? block.runs[0].fontSize : void 0) ?? 12;
@@ -50049,6 +50121,7 @@ class PresentationEditor extends EventEmitter {
50049
50121
  #dragLastPointer = null;
50050
50122
  #dragLastRawHit = null;
50051
50123
  #dragUsedPageNotMountedFallback = false;
50124
+ #suppressFocusInFromDraggable = false;
50052
50125
  // Cell selection drag state
50053
50126
  // Tracks cell-specific context when drag starts in a table for multi-cell selection
50054
50127
  #cellAnchor = null;
@@ -50654,12 +50727,13 @@ class PresentationEditor extends EventEmitter {
50654
50727
  if (!validModes.includes(mode)) {
50655
50728
  throw new TypeError(`[PresentationEditor] Invalid mode "${mode}". Must be one of: ${validModes.join(", ")}`);
50656
50729
  }
50730
+ const modeChanged = this.#documentMode !== mode;
50657
50731
  this.#documentMode = mode;
50658
50732
  this.#editor.setDocumentMode(mode);
50659
50733
  this.#syncDocumentModeClass();
50660
50734
  this.#syncHiddenEditorA11yAttributes();
50661
50735
  const trackedChangesChanged = this.#syncTrackedChangesPreferences();
50662
- if (trackedChangesChanged) {
50736
+ if (modeChanged || trackedChangesChanged) {
50663
50737
  this.#pendingDocChange = true;
50664
50738
  this.#scheduleRerender();
50665
50739
  }
@@ -52032,6 +52106,7 @@ class PresentationEditor extends EventEmitter {
52032
52106
  return;
52033
52107
  }
52034
52108
  const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
52109
+ this.#suppressFocusInFromDraggable = isDraggableAnnotation;
52035
52110
  if (!this.#layoutState.layout) {
52036
52111
  if (!isDraggableAnnotation) {
52037
52112
  event.preventDefault();
@@ -52788,6 +52863,10 @@ class PresentationEditor extends EventEmitter {
52788
52863
  if (isInRegisteredSurface(event)) {
52789
52864
  return;
52790
52865
  }
52866
+ if (this.#suppressFocusInFromDraggable) {
52867
+ this.#suppressFocusInFromDraggable = false;
52868
+ return;
52869
+ }
52791
52870
  const target = event.target;
52792
52871
  const activeTarget = this.#getActiveDomTarget();
52793
52872
  if (!activeTarget) {
@@ -52814,6 +52893,7 @@ class PresentationEditor extends EventEmitter {
52814
52893
  }
52815
52894
  };
52816
52895
  #handlePointerUp = (event) => {
52896
+ this.#suppressFocusInFromDraggable = false;
52817
52897
  if (!this.#isDragging) return;
52818
52898
  if (typeof this.#viewportHost.hasPointerCapture === "function" && typeof this.#viewportHost.releasePointerCapture === "function" && this.#viewportHost.hasPointerCapture(event.pointerId)) {
52819
52899
  this.#viewportHost.releasePointerCapture(event.pointerId);
@@ -53058,12 +53138,14 @@ class PresentationEditor extends EventEmitter {
53058
53138
  } : void 0;
53059
53139
  const atomNodeTypes = getAtomNodeTypes(this.#editor?.schema ?? null);
53060
53140
  const positionMap = this.#editor?.state?.doc && docJson ? buildPositionMapFromPmDoc(this.#editor.state.doc, docJson) : null;
53141
+ const commentsEnabled = this.#documentMode !== "viewing";
53061
53142
  const result = toFlowBlocks(docJson, {
53062
53143
  mediaFiles: this.#editor?.storage?.image?.media,
53063
53144
  emitSectionBreaks: true,
53064
53145
  sectionMetadata,
53065
53146
  trackedChangesMode: this.#trackedChangesMode,
53066
53147
  enableTrackedChanges: this.#trackedChangesEnabled,
53148
+ enableComments: commentsEnabled,
53067
53149
  enableRichHyperlinks: true,
53068
53150
  themeColors: this.#editor?.converter?.themeColors ?? void 0,
53069
53151
  converterContext,
@@ -53194,10 +53276,12 @@ class PresentationEditor extends EventEmitter {
53194
53276
  const payload = { layout, blocks, measures, metrics };
53195
53277
  this.emit("layoutUpdated", payload);
53196
53278
  this.emit("paginationUpdate", payload);
53197
- const commentPositions = this.#collectCommentPositions();
53198
- const positionKeys = Object.keys(commentPositions);
53199
- if (positionKeys.length > 0) {
53200
- this.emit("commentPositions", { positions: commentPositions });
53279
+ if (this.#documentMode !== "viewing") {
53280
+ const commentPositions = this.#collectCommentPositions();
53281
+ const positionKeys = Object.keys(commentPositions);
53282
+ if (positionKeys.length > 0) {
53283
+ this.emit("commentPositions", { positions: commentPositions });
53284
+ }
53201
53285
  }
53202
53286
  if (this.#telemetryEmitter && metrics) {
53203
53287
  this.#telemetryEmitter({ type: "layout", data: { layout, blocks, measures, metrics } });
@@ -60561,16 +60645,7 @@ const Table = Node$1.create({
60561
60645
  * @param {import("./tableHelpers/createTableBorders.js").TableBorders} [borders] - Border styling for this table
60562
60646
  */
60563
60647
  borders: {
60564
- default: {},
60565
- renderDOM({ borders }) {
60566
- if (!borders) return {};
60567
- const style2 = Object.entries(borders).reduce((acc, [key2, { size: size2, color }]) => {
60568
- return `${acc}border-${key2}: ${Math.ceil(size2)}px solid ${color || "black"};`;
60569
- }, "");
60570
- return {
60571
- style: style2
60572
- };
60573
- }
60648
+ default: {}
60574
60649
  },
60575
60650
  /**
60576
60651
  * @category Attribute
package/dist/style.css CHANGED
@@ -7,7 +7,7 @@
7
7
  * SVG has its own rendering model and doesn't need CSS isolation the same way text content does.
8
8
  */
9
9
  .sd-editor-scoped,
10
- .sd-editor-scoped :where(*:not(svg):not(svg *)),
10
+ .sd-editor-scoped :where(*:not(svg):not(svg *):not(.annotation):not([data-drag-handle])),
11
11
  .sd-editor-scoped :where(*:not(svg):not(svg *)::before),
12
12
  .sd-editor-scoped :where(*:not(svg):not(svg *)::after) {
13
13
  all: revert;
@@ -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-BIrkxV37.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-BuhT_Z5G.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-Bc9dM-qO.es.js";
3
+ import { S } from "../chunks/SuperConverter-lLx4GqcF.es.js";
4
4
  import "../chunks/uuid-CjlX8hrF.es.js";
5
5
  export {
6
6
  S as SuperConverter