@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,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-BuT4cwmK.es.js";
2
- import "./SuperConverter-Bc9dM-qO.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-s5ZqooQe.es.js";
2
+ import "./SuperConverter-lLx4GqcF.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";
@@ -5478,6 +5478,9 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5478
5478
  const handleEditorLocationsUpdate = (allCommentPositions) => {
5479
5479
  editorCommentPositions.value = allCommentPositions || {};
5480
5480
  };
5481
+ const clearEditorCommentPositions = () => {
5482
+ editorCommentPositions.value = {};
5483
+ };
5481
5484
  const getFloatingComments = computed(() => {
5482
5485
  const comments = getGroupedComments.value?.parentComments.filter((c2) => !c2.resolvedTime).filter((c2) => {
5483
5486
  const keys = Object.keys(editorCommentPositions.value);
@@ -5580,6 +5583,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5580
5583
  processLoadedDocxComments,
5581
5584
  translateCommentsForExport,
5582
5585
  handleEditorLocationsUpdate,
5586
+ clearEditorCommentPositions,
5583
5587
  handleTrackedChangeUpdate
5584
5588
  };
5585
5589
  });
@@ -7444,7 +7448,7 @@ const _sfc_main = {
7444
7448
  __name: "SuperDoc",
7445
7449
  emits: ["selection-update"],
7446
7450
  setup(__props, { emit: __emit }) {
7447
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CnKGOFjP.es.js"));
7451
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-GBLnj5Yg.es.js"));
7448
7452
  const superdocStore = useSuperdocStore();
7449
7453
  const commentsStore = useCommentsStore();
7450
7454
  const {
@@ -8350,7 +8354,7 @@ class SuperDoc extends EventEmitter {
8350
8354
  this.config.colors = shuffleArray(this.config.colors);
8351
8355
  this.userColorMap = /* @__PURE__ */ new Map();
8352
8356
  this.colorIndex = 0;
8353
- this.version = "1.3.0-next.7";
8357
+ this.version = "1.3.0-next.9";
8354
8358
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8355
8359
  this.superdocId = config.superdocId || v4();
8356
8360
  this.colors = this.config.colors;
@@ -8867,7 +8871,8 @@ class SuperDoc extends EventEmitter {
8867
8871
  }
8868
8872
  #setModeViewing() {
8869
8873
  this.toolbar.activeEditor = null;
8870
- this.setTrackedChangesPreferences({ mode: "original", enabled: false });
8874
+ this.setTrackedChangesPreferences({ mode: "original", enabled: true });
8875
+ this.commentsStore?.clearEditorCommentPositions?.();
8871
8876
  this.superdocStore.documents.forEach((doc) => {
8872
8877
  doc.removeComments();
8873
8878
  this.#applyDocumentMode(doc, "viewing");
@@ -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-BIrkxV37.cjs");
4
+ const superEditor_converter = require("./SuperConverter-BuhT_Z5G.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -13219,8 +13219,8 @@ const CommentsPlugin = Extension.create({
13219
13219
  }
13220
13220
  if (!onlyActiveThreadChanged) {
13221
13221
  const positionsChanged = hasPositionsChanged(prevAllCommentPositions, allCommentPositions);
13222
- const hasComments = Object.keys(allCommentPositions).length > 0;
13223
- const shouldEmitPositions = positionsChanged || !hasEverEmitted && hasComments;
13222
+ const hasComments2 = Object.keys(allCommentPositions).length > 0;
13223
+ const shouldEmitPositions = positionsChanged || !hasEverEmitted && hasComments2;
13224
13224
  if (shouldEmitPositions) {
13225
13225
  prevAllCommentPositions = allCommentPositions;
13226
13226
  hasEverEmitted = true;
@@ -15351,7 +15351,7 @@ const canUseDOM = () => {
15351
15351
  return false;
15352
15352
  }
15353
15353
  };
15354
- const summaryVersion = "1.3.0-next.7";
15354
+ const summaryVersion = "1.3.0-next.9";
15355
15355
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15356
15356
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15357
15357
  function mapAttributes(attrs) {
@@ -17984,7 +17984,7 @@ class Editor extends EventEmitter {
17984
17984
  * Process collaboration migrations
17985
17985
  */
17986
17986
  processCollaborationMigrations() {
17987
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.7");
17987
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.9");
17988
17988
  if (!this.options.ydoc) return;
17989
17989
  const metaMap = this.options.ydoc.getMap("meta");
17990
17990
  let docVersion = metaMap.get("version");
@@ -28215,7 +28215,9 @@ const deriveBlockVersion = (block) => {
28215
28215
  textRun.pmEnd ?? "",
28216
28216
  textRun.token ?? "",
28217
28217
  // Tracked changes - force re-render when added or removed tracked change
28218
- textRun.trackedChange ? 1 : 0
28218
+ textRun.trackedChange ? 1 : 0,
28219
+ // Comment annotations - force re-render when comments are enabled/disabled
28220
+ textRun.comments?.length ?? 0
28219
28221
  ].join(",");
28220
28222
  }).join("|");
28221
28223
  const attrs = block.attrs;
@@ -34087,6 +34089,9 @@ const hashCellBorders = (borders) => {
34087
34089
  if (borders.left) parts.push(`l:[${hashBorderSpec(borders.left)}]`);
34088
34090
  return parts.join(";");
34089
34091
  };
34092
+ function hasComments$1(run) {
34093
+ return "comments" in run && Array.isArray(run.comments) && run.comments.length > 0;
34094
+ }
34090
34095
  const MAX_CACHE_SIZE$1 = 1e4;
34091
34096
  const BYTES_PER_ENTRY_ESTIMATE = 5e3;
34092
34097
  const hashParagraphFrame = (frame) => {
@@ -34154,6 +34159,7 @@ const hashRuns = (block) => {
34154
34159
  fontFamily2 ? `ff:${fontFamily2}` : "",
34155
34160
  highlight ? `hl:${highlight}` : ""
34156
34161
  ].join("");
34162
+ const commentHash = hasComments$1(run) ? run.comments.map((c2) => `${c2.commentId ?? ""}:${c2.internal ? "1" : "0"}`).join("|") : "";
34157
34163
  let trackedKey = "";
34158
34164
  if (hasTrackedChange(run)) {
34159
34165
  const tc = run.trackedChange;
@@ -34161,7 +34167,8 @@ const hashRuns = (block) => {
34161
34167
  const afterHash = tc.after ? JSON.stringify(tc.after) : "";
34162
34168
  trackedKey = `|tc:${tc.kind ?? ""}:${tc.id ?? ""}:${tc.author ?? ""}:${tc.date ?? ""}:${beforeHash}:${afterHash}`;
34163
34169
  }
34164
- cellHashes.push(`${text}:${marks}${trackedKey}`);
34170
+ const commentKey = commentHash ? `|cm:${commentHash}` : "";
34171
+ cellHashes.push(`${text}:${marks}${trackedKey}${commentKey}`);
34165
34172
  }
34166
34173
  if (paragraphBlock.attrs) {
34167
34174
  const attrs = paragraphBlock.attrs;
@@ -35292,6 +35299,9 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
35292
35299
  const totalHeight = lines.reduce((s2, l) => s2 + l.lineHeight, 0);
35293
35300
  return { kind: "paragraph", lines, totalHeight };
35294
35301
  }
35302
+ function hasComments(run) {
35303
+ return "comments" in run && Array.isArray(run.comments) && run.comments.length > 0;
35304
+ }
35295
35305
  const computeDirtyRegions = (previous, next) => {
35296
35306
  const prevMap = new Map(previous.map((block, index2) => [block.id, { block, index: index2 }]));
35297
35307
  const nextMap = new Map(next.map((block, index2) => [block.id, { block, index: index2 }]));
@@ -35352,6 +35362,10 @@ const getTrackedChangeKey = (run) => {
35352
35362
  }
35353
35363
  return "";
35354
35364
  };
35365
+ const getCommentKey = (run) => {
35366
+ if (!hasComments(run)) return "";
35367
+ return run.comments.map((c2) => `${c2.commentId ?? ""}:${c2.internal ? "1" : "0"}`).join("|");
35368
+ };
35355
35369
  const paragraphSpacingEqual = (a, b) => {
35356
35370
  if (a === b) return true;
35357
35371
  if (!a || !b) return !a && !b;
@@ -35433,7 +35447,7 @@ const paragraphBlocksEqual = (a, b) => {
35433
35447
  for (let i = 0; i < a.runs.length; i += 1) {
35434
35448
  const runA = a.runs[i];
35435
35449
  const runB = b.runs[i];
35436
- 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)) {
35450
+ 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)) {
35437
35451
  return false;
35438
35452
  }
35439
35453
  }
@@ -40183,7 +40197,7 @@ const resetRunFormatting = (run) => {
40183
40197
  delete run.link;
40184
40198
  delete run.letterSpacing;
40185
40199
  };
40186
- const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2, themeColors) => {
40200
+ const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments = true) => {
40187
40201
  const tracked = run.trackedChange;
40188
40202
  if (!tracked || tracked.kind !== "format") {
40189
40203
  return;
@@ -40208,7 +40222,7 @@ const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2,
40208
40222
  }
40209
40223
  resetRunFormatting(run);
40210
40224
  try {
40211
- applyMarksToRun2(run, beforeMarks, hyperlinkConfig, themeColors);
40225
+ applyMarksToRun2(run, beforeMarks, hyperlinkConfig, themeColors, void 0, enableComments);
40212
40226
  } catch (error) {
40213
40227
  if (vue.process$1.env.NODE_ENV === "development") {
40214
40228
  console.warn("[PM-Adapter] Error applying format change marks, resetting formatting:", error);
@@ -40216,7 +40230,7 @@ const applyFormatChangeMarks = (run, config, hyperlinkConfig, applyMarksToRun2,
40216
40230
  resetRunFormatting(run);
40217
40231
  }
40218
40232
  };
40219
- const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarksToRun2, themeColors) => {
40233
+ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments = true) => {
40220
40234
  if (!config) {
40221
40235
  return runs;
40222
40236
  }
@@ -40229,7 +40243,7 @@ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarks
40229
40243
  } else {
40230
40244
  runs.forEach((run) => {
40231
40245
  if (isTextRun$1(run)) {
40232
- applyFormatChangeMarks(run, config, hyperlinkConfig, applyMarksToRun2, themeColors);
40246
+ applyFormatChangeMarks(run, config, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments);
40233
40247
  }
40234
40248
  });
40235
40249
  }
@@ -40259,7 +40273,14 @@ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarks
40259
40273
  } else {
40260
40274
  filtered.forEach((run) => {
40261
40275
  if (isTextRun$1(run)) {
40262
- applyFormatChangeMarks(run, config, hyperlinkConfig || DEFAULT_HYPERLINK_CONFIG$1, applyMarksToRun2, themeColors);
40276
+ applyFormatChangeMarks(
40277
+ run,
40278
+ config,
40279
+ hyperlinkConfig || DEFAULT_HYPERLINK_CONFIG$1,
40280
+ applyMarksToRun2,
40281
+ themeColors,
40282
+ enableComments
40283
+ );
40263
40284
  }
40264
40285
  });
40265
40286
  }
@@ -41203,7 +41224,10 @@ const applyTextStyleMark = (run, attrs, themeColors) => {
41203
41224
  const DEFAULT_HYPERLINK_CONFIG = {
41204
41225
  enableRichHyperlinks: false
41205
41226
  };
41206
- const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, backgroundColor) => {
41227
+ const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, backgroundColor, enableComments = true) => {
41228
+ if (!enableComments && "comments" in run && run.comments) {
41229
+ delete run.comments;
41230
+ }
41207
41231
  const isTabRun2 = run.kind === "tab";
41208
41232
  let markSetColor = false;
41209
41233
  marks.forEach((mark) => {
@@ -41250,7 +41274,7 @@ const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG,
41250
41274
  break;
41251
41275
  case "commentMark":
41252
41276
  case "comment": {
41253
- if (!isTabRun2) {
41277
+ if (!isTabRun2 && enableComments) {
41254
41278
  pushCommentAnnotation(run, mark.attrs ?? {});
41255
41279
  }
41256
41280
  break;
@@ -44870,7 +44894,13 @@ const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize
44870
44894
  run.letterSpacing = defaults.letterSpacing;
44871
44895
  }
44872
44896
  };
44873
- function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
44897
+ const applyInlineRunProperties = (run, runProperties) => {
44898
+ if (!runProperties) return;
44899
+ if (runProperties?.letterSpacing != null) {
44900
+ run.letterSpacing = twipsToPx$1(runProperties.letterSpacing);
44901
+ }
44902
+ };
44903
+ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext, enableComments = true) {
44874
44904
  const baseBlockId = nextBlockId("paragraph");
44875
44905
  const paragraphProps = typeof para.attrs?.paragraphProperties === "object" && para.attrs.paragraphProperties !== null ? para.attrs.paragraphProperties : {};
44876
44906
  const paragraphStyleId = typeof para.attrs?.styleId === "string" && para.attrs.styleId.trim() ? para.attrs.styleId : typeof paragraphProps.styleId === "string" && paragraphProps.styleId.trim() ? paragraphProps.styleId : null;
@@ -45022,7 +45052,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45022
45052
  runStyleId
45023
45053
  });
45024
45054
  };
45025
- const visitNode = (node, inheritedMarks = [], activeSdt, activeRunStyleId = null) => {
45055
+ const visitNode = (node, inheritedMarks = [], activeSdt, activeRunStyleId = null, activeRunProperties) => {
45026
45056
  if (node.type === "text" && node.text) {
45027
45057
  const run = textNodeToRun(
45028
45058
  node,
@@ -45038,26 +45068,30 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45038
45068
  const inlineStyleId = getInlineStyleId(inheritedMarks);
45039
45069
  applyRunStyles2(run, inlineStyleId, activeRunStyleId);
45040
45070
  applyBaseRunDefaults(run, baseRunDefaults, defaultFont, defaultSize);
45071
+ applyInlineRunProperties(run, activeRunProperties);
45041
45072
  applyMarksToRun(
45042
45073
  run,
45043
45074
  [...node.marks ?? [], ...inheritedMarks ?? []],
45044
45075
  hyperlinkConfig,
45045
45076
  themeColors,
45046
- converterContext?.backgroundColor
45077
+ converterContext?.backgroundColor,
45078
+ enableComments
45047
45079
  );
45048
45080
  currentRuns.push(run);
45049
45081
  return;
45050
45082
  }
45051
45083
  if (node.type === "run" && Array.isArray(node.content)) {
45052
45084
  const mergedMarks = [...node.marks ?? [], ...inheritedMarks ?? []];
45053
- const nextRunStyleId = extractRunStyleId(node.attrs?.runProperties) ?? activeRunStyleId;
45054
- node.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId));
45085
+ const runProperties = typeof node.attrs?.runProperties === "object" && node.attrs.runProperties !== null ? node.attrs.runProperties : null;
45086
+ const nextRunStyleId = extractRunStyleId(runProperties) ?? activeRunStyleId;
45087
+ const nextRunProperties = runProperties ?? activeRunProperties;
45088
+ node.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId, nextRunProperties));
45055
45089
  return;
45056
45090
  }
45057
45091
  if (node.type === "structuredContent" && Array.isArray(node.content)) {
45058
45092
  const inlineMetadata = resolveNodeSdtMetadata(node, "structuredContent");
45059
45093
  const nextSdt = inlineMetadata ?? activeSdt;
45060
- node.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId));
45094
+ node.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId, activeRunProperties));
45061
45095
  return;
45062
45096
  }
45063
45097
  if (node.type === "fieldAnnotation") {
@@ -45103,7 +45137,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45103
45137
  positions,
45104
45138
  defaultFont,
45105
45139
  defaultSize,
45106
- mergedMarks,
45140
+ [],
45141
+ // Empty marks - will be applied after linked styles
45107
45142
  activeSdt,
45108
45143
  hyperlinkConfig,
45109
45144
  themeColors
@@ -45111,6 +45146,15 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45111
45146
  const inlineStyleId = getInlineStyleId(mergedMarks);
45112
45147
  applyRunStyles2(tokenRun, inlineStyleId, activeRunStyleId);
45113
45148
  applyBaseRunDefaults(tokenRun, baseRunDefaults, defaultFont, defaultSize);
45149
+ applyInlineRunProperties(tokenRun, activeRunProperties);
45150
+ applyMarksToRun(
45151
+ tokenRun,
45152
+ mergedMarks,
45153
+ hyperlinkConfig,
45154
+ themeColors,
45155
+ converterContext?.backgroundColor,
45156
+ enableComments
45157
+ );
45114
45158
  if (pageRefPos) {
45115
45159
  tokenRun.pmStart = pageRefPos.start;
45116
45160
  tokenRun.pmEnd = pageRefPos.end;
@@ -45125,7 +45169,9 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45125
45169
  }
45126
45170
  currentRuns.push(tokenRun);
45127
45171
  } else if (Array.isArray(node.content)) {
45128
- node.content.forEach((child) => visitNode(child, mergedMarks, activeSdt));
45172
+ node.content.forEach(
45173
+ (child) => visitNode(child, mergedMarks, activeSdt, activeRunStyleId, activeRunProperties)
45174
+ );
45129
45175
  }
45130
45176
  return;
45131
45177
  }
@@ -45139,7 +45185,9 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45139
45185
  }
45140
45186
  }
45141
45187
  if (Array.isArray(node.content)) {
45142
- node.content.forEach((child) => visitNode(child, inheritedMarks, activeSdt));
45188
+ node.content.forEach(
45189
+ (child) => visitNode(child, inheritedMarks, activeSdt, activeRunStyleId, activeRunProperties)
45190
+ );
45143
45191
  }
45144
45192
  return;
45145
45193
  }
@@ -45180,7 +45228,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45180
45228
  mergedMarks,
45181
45229
  hyperlinkConfig,
45182
45230
  themeColors,
45183
- converterContext?.backgroundColor
45231
+ converterContext?.backgroundColor,
45232
+ enableComments
45184
45233
  );
45185
45234
  }
45186
45235
  console.debug("[token-debug] paragraph-token-run", {
@@ -45191,6 +45240,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45191
45240
  runStyleId: activeRunStyleId,
45192
45241
  mergedMarksCount: mergedMarks.length
45193
45242
  });
45243
+ applyInlineRunProperties(tokenRun, activeRunProperties);
45194
45244
  currentRuns.push(tokenRun);
45195
45245
  }
45196
45246
  return;
@@ -45378,7 +45428,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45378
45428
  trackedChanges,
45379
45429
  hyperlinkConfig,
45380
45430
  applyMarksToRun,
45381
- themeColors
45431
+ themeColors,
45432
+ enableComments
45382
45433
  );
45383
45434
  if (trackedChanges.enabled && filteredRuns.length === 0) {
45384
45435
  return;
@@ -46277,6 +46328,7 @@ function toFlowBlocks(pmDoc, options) {
46277
46328
  const hyperlinkConfig = {
46278
46329
  enableRichHyperlinks: options?.enableRichHyperlinks ?? false
46279
46330
  };
46331
+ const enableComments = options?.enableComments ?? true;
46280
46332
  const themeColors = options?.themeColors;
46281
46333
  const converterContext = options?.converterContext;
46282
46334
  if (!doc2.content) {
@@ -46326,7 +46378,8 @@ function toFlowBlocks(pmDoc, options) {
46326
46378
  bookmarks2,
46327
46379
  hyperlinkConfig2,
46328
46380
  themeColorsParam ?? themeColors,
46329
- converterCtx ?? converterContext
46381
+ converterCtx ?? converterContext,
46382
+ enableComments
46330
46383
  );
46331
46384
  const tableConverter = (node, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2, themeColorsParam, converterCtx) => tableNodeToBlock(
46332
46385
  node,
@@ -46365,6 +46418,7 @@ function toFlowBlocks(pmDoc, options) {
46365
46418
  listCounterContext: { getListCounter, incrementListCounter, resetListCounter },
46366
46419
  trackedChangesConfig,
46367
46420
  hyperlinkConfig,
46421
+ enableComments,
46368
46422
  bookmarks,
46369
46423
  sectionState: {
46370
46424
  ranges: sectionRanges,
@@ -46433,7 +46487,7 @@ function mergeDropCapParagraphs(blocks) {
46433
46487
  }
46434
46488
  return result;
46435
46489
  }
46436
- function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converterContext) {
46490
+ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converterContext, enableComments = true) {
46437
46491
  return paragraphToFlowBlocks$1(
46438
46492
  para,
46439
46493
  nextBlockId,
@@ -46480,7 +46534,8 @@ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaul
46480
46534
  }
46481
46535
  )
46482
46536
  },
46483
- converterContext
46537
+ converterContext,
46538
+ enableComments
46484
46539
  );
46485
46540
  }
46486
46541
  function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize, styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, _paragraphToFlowBlocksParam, converterContext, options) {
@@ -48367,6 +48422,7 @@ async function measureParagraphBlock(block, maxWidth) {
48367
48422
  let lastFontSize = 12;
48368
48423
  let tabStopCursor = 0;
48369
48424
  let pendingTabAlignment = null;
48425
+ let pendingRunSpacing = 0;
48370
48426
  let lastAppliedTabAlign = null;
48371
48427
  const warnedTabVals = /* @__PURE__ */ new Set();
48372
48428
  let activeTabGroup = null;
@@ -48377,6 +48433,10 @@ async function measureParagraphBlock(block, maxWidth) {
48377
48433
  }
48378
48434
  return true;
48379
48435
  };
48436
+ const resolveBoundarySpacing = (lineWidth, isRunStart, run) => {
48437
+ if (lineWidth <= 0) return 0;
48438
+ return isRunStart ? pendingRunSpacing : run.letterSpacing ?? 0;
48439
+ };
48380
48440
  const alignPendingTabForWidth = (segmentWidth, beforeDecimalWidth) => {
48381
48441
  if (!pendingTabAlignment || !currentLine) return void 0;
48382
48442
  if (segmentWidth < 0) {
@@ -48504,6 +48564,7 @@ async function measureParagraphBlock(block, maxWidth) {
48504
48564
  tabStopCursor = 0;
48505
48565
  pendingTabAlignment = null;
48506
48566
  lastAppliedTabAlign = null;
48567
+ pendingRunSpacing = 0;
48507
48568
  continue;
48508
48569
  }
48509
48570
  if (isLineBreakRun(run)) {
@@ -48546,6 +48607,7 @@ async function measureParagraphBlock(block, maxWidth) {
48546
48607
  tabStopCursor = 0;
48547
48608
  pendingTabAlignment = null;
48548
48609
  lastAppliedTabAlign = null;
48610
+ pendingRunSpacing = 0;
48549
48611
  continue;
48550
48612
  }
48551
48613
  if (isTabRun(run)) {
@@ -48611,6 +48673,7 @@ async function measureParagraphBlock(block, maxWidth) {
48611
48673
  } else {
48612
48674
  pendingTabAlignment = null;
48613
48675
  }
48676
+ pendingRunSpacing = 0;
48614
48677
  continue;
48615
48678
  }
48616
48679
  if (isImageRun(run)) {
@@ -48649,6 +48712,7 @@ async function measureParagraphBlock(block, maxWidth) {
48649
48712
  }
48650
48713
  ]
48651
48714
  };
48715
+ pendingRunSpacing = 0;
48652
48716
  if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex) {
48653
48717
  activeTabGroup = null;
48654
48718
  }
@@ -48710,6 +48774,7 @@ async function measureParagraphBlock(block, maxWidth) {
48710
48774
  currentLine.width = roundValue(tabAlign.target);
48711
48775
  }
48712
48776
  lastAppliedTabAlign = null;
48777
+ pendingRunSpacing = 0;
48713
48778
  continue;
48714
48779
  }
48715
48780
  if (isFieldAnnotationRun(run)) {
@@ -48749,6 +48814,7 @@ async function measureParagraphBlock(block, maxWidth) {
48749
48814
  }
48750
48815
  ]
48751
48816
  };
48817
+ pendingRunSpacing = 0;
48752
48818
  continue;
48753
48819
  }
48754
48820
  if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
@@ -48801,9 +48867,11 @@ async function measureParagraphBlock(block, maxWidth) {
48801
48867
  currentLine.width = roundValue(tabAlign.target);
48802
48868
  }
48803
48869
  lastAppliedTabAlign = null;
48870
+ pendingRunSpacing = 0;
48804
48871
  continue;
48805
48872
  }
48806
48873
  if (!("text" in run) || !("fontSize" in run)) {
48874
+ pendingRunSpacing = 0;
48807
48875
  continue;
48808
48876
  }
48809
48877
  lastFontSize = run.fontSize;
@@ -48814,6 +48882,7 @@ async function measureParagraphBlock(block, maxWidth) {
48814
48882
  const segment = tabSegments[segmentIndex];
48815
48883
  const isLastSegment = segmentIndex === tabSegments.length - 1;
48816
48884
  if (/^[ ]+$/.test(segment)) {
48885
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0;
48817
48886
  const spacesLength = segment.length;
48818
48887
  const spacesStartChar = charPosInRun;
48819
48888
  const spacesEndChar = charPosInRun + spacesLength;
@@ -48832,7 +48901,7 @@ async function measureParagraphBlock(block, maxWidth) {
48832
48901
  spaceCount: spacesLength
48833
48902
  };
48834
48903
  } else {
48835
- const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
48904
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run);
48836
48905
  if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
48837
48906
  trimTrailingWrapSpaces(currentLine);
48838
48907
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -48896,6 +48965,7 @@ async function measureParagraphBlock(block, maxWidth) {
48896
48965
  const spaceStartChar = charPosInRun;
48897
48966
  const spaceEndChar = charPosInRun + 1;
48898
48967
  const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run, spaceStartChar);
48968
+ const isRunStart2 = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
48899
48969
  if (!currentLine) {
48900
48970
  currentLine = {
48901
48971
  fromRun: runIndex,
@@ -48910,7 +48980,7 @@ async function measureParagraphBlock(block, maxWidth) {
48910
48980
  spaceCount: 1
48911
48981
  };
48912
48982
  } else {
48913
- const boundarySpacing2 = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
48983
+ const boundarySpacing2 = resolveBoundarySpacing(currentLine.width, isRunStart2, run);
48914
48984
  if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
48915
48985
  trimTrailingWrapSpaces(currentLine);
48916
48986
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -49095,7 +49165,8 @@ async function measureParagraphBlock(block, maxWidth) {
49095
49165
  continue;
49096
49166
  }
49097
49167
  const isTocEntry = block.attrs?.isTocEntry;
49098
- const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
49168
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
49169
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run);
49099
49170
  const justifyAlignment = block.attrs?.alignment === "justify";
49100
49171
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
49101
49172
  (shouldIncludeDelimiterSpace ? run.letterSpacing ?? 0 : 0);
@@ -49263,6 +49334,7 @@ async function measureParagraphBlock(block, maxWidth) {
49263
49334
  }
49264
49335
  }
49265
49336
  }
49337
+ pendingRunSpacing = run.letterSpacing ?? 0;
49266
49338
  }
49267
49339
  if (!currentLine && lines.length === 0) {
49268
49340
  const uiDisplayFallbackFontSize = (block.runs[0]?.kind === "text" ? block.runs[0].fontSize : void 0) ?? 12;
@@ -50066,6 +50138,7 @@ class PresentationEditor extends EventEmitter {
50066
50138
  #dragLastPointer = null;
50067
50139
  #dragLastRawHit = null;
50068
50140
  #dragUsedPageNotMountedFallback = false;
50141
+ #suppressFocusInFromDraggable = false;
50069
50142
  // Cell selection drag state
50070
50143
  // Tracks cell-specific context when drag starts in a table for multi-cell selection
50071
50144
  #cellAnchor = null;
@@ -50671,12 +50744,13 @@ class PresentationEditor extends EventEmitter {
50671
50744
  if (!validModes.includes(mode)) {
50672
50745
  throw new TypeError(`[PresentationEditor] Invalid mode "${mode}". Must be one of: ${validModes.join(", ")}`);
50673
50746
  }
50747
+ const modeChanged = this.#documentMode !== mode;
50674
50748
  this.#documentMode = mode;
50675
50749
  this.#editor.setDocumentMode(mode);
50676
50750
  this.#syncDocumentModeClass();
50677
50751
  this.#syncHiddenEditorA11yAttributes();
50678
50752
  const trackedChangesChanged = this.#syncTrackedChangesPreferences();
50679
- if (trackedChangesChanged) {
50753
+ if (modeChanged || trackedChangesChanged) {
50680
50754
  this.#pendingDocChange = true;
50681
50755
  this.#scheduleRerender();
50682
50756
  }
@@ -52049,6 +52123,7 @@ class PresentationEditor extends EventEmitter {
52049
52123
  return;
52050
52124
  }
52051
52125
  const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
52126
+ this.#suppressFocusInFromDraggable = isDraggableAnnotation;
52052
52127
  if (!this.#layoutState.layout) {
52053
52128
  if (!isDraggableAnnotation) {
52054
52129
  event.preventDefault();
@@ -52805,6 +52880,10 @@ class PresentationEditor extends EventEmitter {
52805
52880
  if (isInRegisteredSurface(event)) {
52806
52881
  return;
52807
52882
  }
52883
+ if (this.#suppressFocusInFromDraggable) {
52884
+ this.#suppressFocusInFromDraggable = false;
52885
+ return;
52886
+ }
52808
52887
  const target = event.target;
52809
52888
  const activeTarget = this.#getActiveDomTarget();
52810
52889
  if (!activeTarget) {
@@ -52831,6 +52910,7 @@ class PresentationEditor extends EventEmitter {
52831
52910
  }
52832
52911
  };
52833
52912
  #handlePointerUp = (event) => {
52913
+ this.#suppressFocusInFromDraggable = false;
52834
52914
  if (!this.#isDragging) return;
52835
52915
  if (typeof this.#viewportHost.hasPointerCapture === "function" && typeof this.#viewportHost.releasePointerCapture === "function" && this.#viewportHost.hasPointerCapture(event.pointerId)) {
52836
52916
  this.#viewportHost.releasePointerCapture(event.pointerId);
@@ -53075,12 +53155,14 @@ class PresentationEditor extends EventEmitter {
53075
53155
  } : void 0;
53076
53156
  const atomNodeTypes = getAtomNodeTypes(this.#editor?.schema ?? null);
53077
53157
  const positionMap = this.#editor?.state?.doc && docJson ? buildPositionMapFromPmDoc(this.#editor.state.doc, docJson) : null;
53158
+ const commentsEnabled = this.#documentMode !== "viewing";
53078
53159
  const result = toFlowBlocks(docJson, {
53079
53160
  mediaFiles: this.#editor?.storage?.image?.media,
53080
53161
  emitSectionBreaks: true,
53081
53162
  sectionMetadata,
53082
53163
  trackedChangesMode: this.#trackedChangesMode,
53083
53164
  enableTrackedChanges: this.#trackedChangesEnabled,
53165
+ enableComments: commentsEnabled,
53084
53166
  enableRichHyperlinks: true,
53085
53167
  themeColors: this.#editor?.converter?.themeColors ?? void 0,
53086
53168
  converterContext,
@@ -53211,10 +53293,12 @@ class PresentationEditor extends EventEmitter {
53211
53293
  const payload = { layout, blocks, measures, metrics };
53212
53294
  this.emit("layoutUpdated", payload);
53213
53295
  this.emit("paginationUpdate", payload);
53214
- const commentPositions = this.#collectCommentPositions();
53215
- const positionKeys = Object.keys(commentPositions);
53216
- if (positionKeys.length > 0) {
53217
- this.emit("commentPositions", { positions: commentPositions });
53296
+ if (this.#documentMode !== "viewing") {
53297
+ const commentPositions = this.#collectCommentPositions();
53298
+ const positionKeys = Object.keys(commentPositions);
53299
+ if (positionKeys.length > 0) {
53300
+ this.emit("commentPositions", { positions: commentPositions });
53301
+ }
53218
53302
  }
53219
53303
  if (this.#telemetryEmitter && metrics) {
53220
53304
  this.#telemetryEmitter({ type: "layout", data: { layout, blocks, measures, metrics } });
@@ -60578,16 +60662,7 @@ const Table = Node$1.create({
60578
60662
  * @param {import("./tableHelpers/createTableBorders.js").TableBorders} [borders] - Border styling for this table
60579
60663
  */
60580
60664
  borders: {
60581
- default: {},
60582
- renderDOM({ borders }) {
60583
- if (!borders) return {};
60584
- const style2 = Object.entries(borders).reduce((acc, [key2, { size: size2, color }]) => {
60585
- return `${acc}border-${key2}: ${Math.ceil(size2)}px solid ${color || "black"};`;
60586
- }, "");
60587
- return {
60588
- style: style2
60589
- };
60590
- }
60665
+ default: {}
60591
60666
  },
60592
60667
  /**
60593
60668
  * @category Attribute