@superdoc-dev/cli 0.17.0-next.37 → 0.17.0-next.39

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.
Files changed (2) hide show
  1. package/dist/index.js +1055 -276
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -69157,7 +69157,7 @@ var init_remark_gfm_BUJjZJLy_es = __esm(() => {
69157
69157
  emptyOptions2 = {};
69158
69158
  });
69159
69159
 
69160
- // ../../packages/superdoc/dist/chunks/SuperConverter-Du0apG1R.es.js
69160
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DQ2wMaLK.es.js
69161
69161
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
69162
69162
  const fieldValue = extension$1.config[field];
69163
69163
  if (typeof fieldValue === "function")
@@ -114147,6 +114147,91 @@ function getTrackedMarkText(editor, item) {
114147
114147
  return nodeText;
114148
114148
  return editor.state.doc.textBetween(item.from, item.to, " ", "");
114149
114149
  }
114150
+ function rawMarkMatchesChange(mark, change) {
114151
+ return trackedMarkMatchesChange(mark.mark, change);
114152
+ }
114153
+ function trackedMarkMatchesChange(mark, change) {
114154
+ const attrs = mark.attrs ?? {};
114155
+ const rawId = toNonEmptyString(attrs.id);
114156
+ if (!rawId)
114157
+ return false;
114158
+ const markType = mark.type.name;
114159
+ const groupKey = getTrackedChangeGroupKey(attrs, markType, rawId);
114160
+ return groupKey === change.rawId || groupKey === change.id || rawId === change.commandRawId || rawId === change.id;
114161
+ }
114162
+ function findMarkedTextNodeNavigationSelection(editor, change) {
114163
+ let multiCharacterSelection = null;
114164
+ let singleCharacterSelection = null;
114165
+ try {
114166
+ editor.state.doc.nodesBetween(change.from, change.to, (node3, pos) => {
114167
+ if (multiCharacterSelection)
114168
+ return false;
114169
+ if (!node3.isText)
114170
+ return true;
114171
+ if (!(Array.isArray(node3.marks) ? node3.marks : []).some((mark) => trackedMarkMatchesChange(mark, change)))
114172
+ return false;
114173
+ const textLength = typeof node3.text === "string" ? node3.text.length : node3.nodeSize;
114174
+ if (textLength > 1) {
114175
+ const caret = pos + 1;
114176
+ multiCharacterSelection = {
114177
+ from: caret,
114178
+ to: caret
114179
+ };
114180
+ return false;
114181
+ }
114182
+ if (!singleCharacterSelection && textLength > 0)
114183
+ singleCharacterSelection = {
114184
+ from: pos,
114185
+ to: pos + textLength
114186
+ };
114187
+ return false;
114188
+ });
114189
+ } catch {
114190
+ return null;
114191
+ }
114192
+ return multiCharacterSelection ?? singleCharacterSelection;
114193
+ }
114194
+ function resolveTrackedChangeNavigationSelection(editor, id2) {
114195
+ const change = resolveTrackedChange(editor, id2);
114196
+ if (!change || change.structural)
114197
+ return null;
114198
+ const markedTextSelection = findMarkedTextNodeNavigationSelection(editor, change);
114199
+ if (markedTextSelection)
114200
+ return markedTextSelection;
114201
+ const matchingMarks = getRawTrackedMarks(editor).filter((mark) => rawMarkMatchesChange(mark, change)).filter((mark) => Number.isFinite(mark.from) && Number.isFinite(mark.to) && mark.to > mark.from).sort((a, b) => {
114202
+ if (a.from !== b.from)
114203
+ return a.from - b.from;
114204
+ return a.to - b.to;
114205
+ });
114206
+ const multiCharacterMark = matchingMarks.find((mark) => mark.to - mark.from > 1);
114207
+ if (multiCharacterMark) {
114208
+ const pos = multiCharacterMark.from + 1;
114209
+ return {
114210
+ from: pos,
114211
+ to: pos
114212
+ };
114213
+ }
114214
+ const singleCharacterMark = matchingMarks[0];
114215
+ if (singleCharacterMark)
114216
+ return {
114217
+ from: singleCharacterMark.from,
114218
+ to: singleCharacterMark.to
114219
+ };
114220
+ if (change.to > change.from) {
114221
+ if (change.to - change.from > 1) {
114222
+ const pos = change.from + 1;
114223
+ return {
114224
+ from: pos,
114225
+ to: pos
114226
+ };
114227
+ }
114228
+ return {
114229
+ from: change.from,
114230
+ to: change.to
114231
+ };
114232
+ }
114233
+ return null;
114234
+ }
114150
114235
  function groupTrackedChanges(editor) {
114151
114236
  const currentDoc = editor.state.doc;
114152
114237
  const cached = groupedCache.get(editor);
@@ -130804,15 +130889,12 @@ var isRegExp = (value) => {
130804
130889
  const originalElementsSource = originalXml.elements;
130805
130890
  const originalElements = originalElementsSource ? carbonCopy(originalElementsSource) : [];
130806
130891
  const childElements = Array.isArray(node3.elements) ? node3.elements : [];
130807
- let childContent = [];
130808
- if (childElements.length && params3.nodeListHandler?.handler) {
130809
- const childParams = {
130892
+ if (childElements.length && params3.nodeListHandler?.handler)
130893
+ params3.nodeListHandler.handler({
130810
130894
  ...params3,
130811
130895
  nodes: childElements,
130812
130896
  path: [...params3.path || [], node3]
130813
- };
130814
- childContent = params3.nodeListHandler.handler(childParams) || [];
130815
- }
130897
+ });
130816
130898
  if (originalElements?.length)
130817
130899
  originalXml.elements = originalElements;
130818
130900
  return {
@@ -130823,7 +130905,7 @@ var isRegExp = (value) => {
130823
130905
  originalXml
130824
130906
  },
130825
130907
  marks: [],
130826
- content: childContent
130908
+ content: undefined
130827
130909
  }],
130828
130910
  consumed: 1
130829
130911
  };
@@ -137234,7 +137316,7 @@ Docs: https://docs.superdoc.dev/getting-started/fonts`);
137234
137316
  state.kern = kernNode.attributes["w:val"];
137235
137317
  }
137236
137318
  }, SuperConverter;
137237
- var init_SuperConverter_Du0apG1R_es = __esm(() => {
137319
+ var init_SuperConverter_DQ2wMaLK_es = __esm(() => {
137238
137320
  init_rolldown_runtime_Bg48TavK_es();
137239
137321
  init_jszip_C49i9kUs_es();
137240
137322
  init_xml_js_CqGKpaft_es();
@@ -166243,7 +166325,7 @@ var init_SuperConverter_Du0apG1R_es = __esm(() => {
166243
166325
  };
166244
166326
  });
166245
166327
 
166246
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BNcguDpP.es.js
166328
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BhSfQYaO.es.js
166247
166329
  function parseSizeUnit(val = "0") {
166248
166330
  const length3 = val.toString() || "0";
166249
166331
  const value = Number.parseFloat(length3);
@@ -176986,9 +177068,9 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, MARK_KEYS, STEP_OP_CATALOG_UNFROZEN2, P
176986
177068
  }
176987
177069
  };
176988
177070
  };
176989
- var init_create_headless_toolbar_BNcguDpP_es = __esm(() => {
177071
+ var init_create_headless_toolbar_BhSfQYaO_es = __esm(() => {
176990
177072
  init_rolldown_runtime_Bg48TavK_es();
176991
- init_SuperConverter_Du0apG1R_es();
177073
+ init_SuperConverter_DQ2wMaLK_es();
176992
177074
  init_jszip_C49i9kUs_es();
176993
177075
  init_uuid_B2wVPhPi_es();
176994
177076
  init_constants_D9qj59G2_es();
@@ -180566,157 +180648,6 @@ var __plugin_vue_export_helper_default = (sfc, props) => {
180566
180648
  };
180567
180649
  var init__plugin_vue_export_helper_HmhZBO0u_es = () => {};
180568
180650
 
180569
- // ../../packages/superdoc/dist/chunks/ui-BMYSpkne.es.js
180570
- function buildAnnotationSelector() {
180571
- return `.${DOM_CLASS_NAMES.ANNOTATION}[${DATA_ATTRS.PM_START}]`;
180572
- }
180573
- function findRenderedCommentElements(host, commentId, storyKey) {
180574
- if (!host || !commentId)
180575
- return [];
180576
- return Array.from(host.querySelectorAll("[data-comment-ids]")).filter((el) => {
180577
- const raw = el.dataset.commentIds;
180578
- if (!raw)
180579
- return false;
180580
- if (!raw.split(",").some((token) => token.trim() === commentId))
180581
- return false;
180582
- if (!storyKey)
180583
- return true;
180584
- const elStoryKey = el.dataset.storyKey;
180585
- if (elStoryKey)
180586
- return elStoryKey === storyKey;
180587
- return storyKey === BODY_STORY_KEY;
180588
- });
180589
- }
180590
- function findRenderedTrackedChangeElementsStrict(host, entityId, escapeAttrValue, storyKey) {
180591
- if (!host || !entityId)
180592
- return [];
180593
- const baseSelector = `[data-track-change-id="${escapeAttrValue(entityId)}"]`;
180594
- if (!storyKey)
180595
- return Array.from(host.querySelectorAll(baseSelector));
180596
- const storySelector = `${baseSelector}[data-story-key="${escapeAttrValue(storyKey)}"]`;
180597
- return Array.from(host.querySelectorAll(storySelector));
180598
- }
180599
- function findRenderedContentControlElements(host, entityId, escapeAttrValue, _storyKey) {
180600
- if (!host || !entityId)
180601
- return [];
180602
- const id2 = escapeAttrValue(entityId);
180603
- const selector = `.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}[data-sdt-id="${id2}"][data-sdt-type="structuredContent"],.${DOM_CLASS_NAMES.BLOCK_SDT}[data-sdt-id="${id2}"][data-sdt-type="structuredContent"]`;
180604
- return Array.from(host.querySelectorAll(selector));
180605
- }
180606
- function elementsToRangeRects(elements) {
180607
- const result = [];
180608
- for (const element of elements) {
180609
- const rect = element.getBoundingClientRect();
180610
- if (![
180611
- rect.top,
180612
- rect.left,
180613
- rect.right,
180614
- rect.bottom,
180615
- rect.width,
180616
- rect.height
180617
- ].every(Number.isFinite))
180618
- continue;
180619
- const pageEl = element.closest(".superdoc-page");
180620
- const pageIndexAttr = Number(pageEl?.dataset?.pageIndex ?? 0);
180621
- result.push({
180622
- pageIndex: Number.isFinite(pageIndexAttr) ? pageIndexAttr : 0,
180623
- left: rect.left,
180624
- top: rect.top,
180625
- right: rect.right,
180626
- bottom: rect.bottom,
180627
- width: rect.width,
180628
- height: rect.height
180629
- });
180630
- }
180631
- return result;
180632
- }
180633
- var DOM_CLASS_NAMES, STRUCTURED_CONTENT_CHROME_LABEL_CLASS_NAMES, DATA_ATTRS, DATASET_KEYS, encodeLayoutStoryDataset = (story) => story.kind === "body" ? "body" : story.id ? `${story.kind}:${story.id}` : story.kind, decodeLayoutStoryDataset = (raw) => {
180634
- if (!raw)
180635
- return { kind: "unknown" };
180636
- if (raw === "body")
180637
- return { kind: "body" };
180638
- const idx = raw.indexOf(":");
180639
- const kind = idx === -1 ? raw : raw.slice(0, idx);
180640
- const id2 = idx === -1 ? undefined : raw.slice(idx + 1);
180641
- switch (kind) {
180642
- case "body":
180643
- case "header":
180644
- case "footer":
180645
- case "footnote":
180646
- case "endnote":
180647
- return id2 ? {
180648
- kind,
180649
- id: id2
180650
- } : { kind };
180651
- default:
180652
- return { kind: "unknown" };
180653
- }
180654
- }, DRAGGABLE_SELECTOR;
180655
- var init_ui_BMYSpkne_es = __esm(() => {
180656
- init_SuperConverter_Du0apG1R_es();
180657
- DOM_CLASS_NAMES = {
180658
- PAGE: "superdoc-page",
180659
- FRAGMENT: "superdoc-fragment",
180660
- LINE: "superdoc-line",
180661
- INLINE_SDT_WRAPPER: "superdoc-structured-content-inline",
180662
- INLINE_SDT_LABEL: "superdoc-structured-content-inline__label",
180663
- BLOCK_SDT: "superdoc-structured-content-block",
180664
- BLOCK_SDT_LABEL: "superdoc-structured-content__label",
180665
- TABLE_FRAGMENT: "superdoc-table-fragment",
180666
- DOCUMENT_SECTION: "superdoc-document-section",
180667
- SDT_GROUP_HOVER: "sdt-group-hover",
180668
- TOC_ENTRY: "superdoc-toc-entry",
180669
- TOC_GROUP_HOVER: "toc-group-hover",
180670
- IMAGE_FRAGMENT: "superdoc-image-fragment",
180671
- INLINE_IMAGE: "superdoc-inline-image",
180672
- LIST_MARKER: "superdoc-list-marker",
180673
- INLINE_IMAGE_CLIP_WRAPPER: "superdoc-inline-image-clip-wrapper",
180674
- ANNOTATION: "annotation",
180675
- ANNOTATION_CONTENT: "annotation-content",
180676
- ANNOTATION_CARET_ANCHOR: "annotation-caret-anchor"
180677
- };
180678
- STRUCTURED_CONTENT_CHROME_LABEL_CLASS_NAMES = [DOM_CLASS_NAMES.INLINE_SDT_LABEL, DOM_CLASS_NAMES.BLOCK_SDT_LABEL];
180679
- DATA_ATTRS = {
180680
- PM_START: "data-pm-start",
180681
- PM_END: "data-pm-end",
180682
- LAYOUT_EPOCH: "data-layout-epoch",
180683
- TABLE_BOUNDARIES: "data-table-boundaries",
180684
- SDT_ID: "data-sdt-id",
180685
- SDT_TYPE: "data-sdt-type",
180686
- FIELD_ID: "data-field-id",
180687
- FIELD_TYPE: "data-field-type",
180688
- DRAGGABLE: "data-draggable",
180689
- DISPLAY_LABEL: "data-display-label",
180690
- VARIANT: "data-variant",
180691
- TYPE: "data-type",
180692
- LAYOUT_BOUNDARY_SCHEMA: "data-layout-boundary-schema",
180693
- LAYOUT_FRAGMENT_ID: "data-layout-fragment-id",
180694
- LAYOUT_STORY: "data-layout-story",
180695
- LAYOUT_BLOCK_REF: "data-layout-block-ref"
180696
- };
180697
- DATASET_KEYS = {
180698
- PM_START: "pmStart",
180699
- PM_END: "pmEnd",
180700
- LAYOUT_EPOCH: "layoutEpoch",
180701
- TABLE_BOUNDARIES: "tableBoundaries",
180702
- SDT_ID: "sdtId",
180703
- SDT_TYPE: "sdtType",
180704
- FIELD_ID: "fieldId",
180705
- FIELD_TYPE: "fieldType",
180706
- DRAGGABLE: "draggable",
180707
- DISPLAY_LABEL: "displayLabel",
180708
- VARIANT: "variant",
180709
- TYPE: "type",
180710
- LAYOUT_BOUNDARY_SCHEMA: "layoutBoundarySchema",
180711
- LAYOUT_FRAGMENT_ID: "layoutFragmentId",
180712
- LAYOUT_STORY: "layoutStory",
180713
- LAYOUT_BLOCK_REF: "layoutBlockRef"
180714
- };
180715
- `${DOM_CLASS_NAMES.BLOCK_SDT}${DATA_ATTRS.SDT_ID}`;
180716
- DRAGGABLE_SELECTOR = `[${DATA_ATTRS.DRAGGABLE}="true"]`;
180717
- DATA_ATTRS.LAYOUT_EPOCH;
180718
- });
180719
-
180720
180651
  // ../../packages/superdoc/dist/chunks/eventemitter3-UwU_CLPU.es.js
180721
180652
  var import_eventemitter3;
180722
180653
  var init_eventemitter3_UwU_CLPU_es = __esm(() => {
@@ -227233,7 +227164,7 @@ var init_remark_gfm_DCND_V_3_es = __esm(() => {
227233
227164
  init_remark_gfm_BUJjZJLy_es();
227234
227165
  });
227235
227166
 
227236
- // ../../packages/superdoc/dist/chunks/src-bGJhSgx_.es.js
227167
+ // ../../packages/superdoc/dist/chunks/src-CR8eXLKh.es.js
227237
227168
  function deleteProps(obj, propOrProps) {
227238
227169
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
227239
227170
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -236683,6 +236614,9 @@ function replaceCommand(wrap5, moveForward) {
236683
236614
  return true;
236684
236615
  };
236685
236616
  }
236617
+ function buildAnnotationSelector() {
236618
+ return `.${DOM_CLASS_NAMES.ANNOTATION}[${DATA_ATTRS.PM_START}]`;
236619
+ }
236686
236620
  function isPresenting(editor) {
236687
236621
  const presentationCtx = editor?.presentationEditor;
236688
236622
  if (!presentationCtx)
@@ -251846,19 +251780,16 @@ function readBlockId(node3) {
251846
251780
  function mapRawChangeIdsToCanonical(editor, rawIds) {
251847
251781
  if (rawIds.length === 0)
251848
251782
  return rawIds;
251849
- let grouped;
251783
+ let canonicalIdByAlias;
251850
251784
  try {
251851
- grouped = groupTrackedChanges(editor);
251785
+ canonicalIdByAlias = buildTrackedChangeCanonicalIdMap(editor);
251852
251786
  } catch {
251853
251787
  return [];
251854
251788
  }
251855
- const rawToCanonical = /* @__PURE__ */ new Map;
251856
- for (const change of grouped)
251857
- rawToCanonical.set(change.rawId, change.id);
251858
251789
  const seen = /* @__PURE__ */ new Set;
251859
251790
  const out = [];
251860
251791
  for (const raw of rawIds) {
251861
- const canonical = rawToCanonical.get(raw);
251792
+ const canonical = canonicalIdByAlias.get(raw);
251862
251793
  if (!canonical)
251863
251794
  continue;
251864
251795
  if (seen.has(canonical))
@@ -275105,7 +275036,7 @@ function getMeasurementContext() {
275105
275036
  function getRunFontString(run2) {
275106
275037
  if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" || "src" in run2)
275107
275038
  return "normal normal 16px Arial";
275108
- return `${run2.italic ? "italic" : "normal"} ${run2.bold ? "bold" : "normal"} ${run2.fontSize ?? 16}px ${DEFAULT_FONT_MEASURE_CONTEXT.resolvePhysical(run2.fontFamily ?? "Arial", faceOf$1(run2))}`;
275039
+ return `${run2.italic ? "italic" : "normal"} ${run2.bold ? "bold" : "normal"} ${run2.fontSize ?? 16}px ${run2.fontFamily ?? "Arial"}`;
275109
275040
  }
275110
275041
  function measureCharacterX(block, line, charOffset, availableWidthOverride, alignmentOverride) {
275111
275042
  const ctx$1 = getMeasurementContext();
@@ -275245,43 +275176,97 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
275245
275176
  return lastPm;
275246
275177
  }
275247
275178
  function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, alignmentOverride) {
275248
- const maxOffset = lineCharLength(block, line);
275249
- const xAtOffset = (offset$1) => measureCharacterX(block, line, offset$1, availableWidthOverride, alignmentOverride);
275250
- const charOffset = nearestOffsetToX(x, maxOffset, xAtOffset);
275251
- return {
275252
- charOffset,
275253
- pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
275254
- };
275255
- }
275256
- function lineCharLength(block, line) {
275257
- let length$12 = 0;
275258
- for (const run2 of sliceRunsForLine(block, line)) {
275179
+ const ctx$1 = getMeasurementContext();
275180
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
275181
+ const justify = getJustifyAdjustment({
275182
+ block,
275183
+ line,
275184
+ availableWidthOverride: availableWidth,
275185
+ alignmentOverride
275186
+ });
275187
+ const alignment$1 = alignmentOverride ?? (block.kind === "paragraph" ? block.attrs?.alignment : undefined);
275188
+ const renderedLineWidth = alignment$1 === "justify" ? line.width + Math.max(0, availableWidth - line.width) : line.width;
275189
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== undefined);
275190
+ const alignmentOffset = !hasExplicitPositioning && alignment$1 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment$1 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
275191
+ if (!ctx$1) {
275192
+ const runs$1 = sliceRunsForLine(block, line);
275193
+ const charsInLine = Math.max(1, runs$1.reduce((sum, run2) => {
275194
+ if (isTabRun$1(run2))
275195
+ return sum + TAB_CHAR_LENGTH;
275196
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math")
275197
+ return sum;
275198
+ return sum + (run2.text ?? "").length;
275199
+ }, 0));
275200
+ const ratio = Math.max(0, Math.min(1, (x - alignmentOffset) / renderedLineWidth));
275201
+ const charOffset = Math.round(ratio * charsInLine);
275202
+ return {
275203
+ charOffset,
275204
+ pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
275205
+ };
275206
+ }
275207
+ const runs2 = sliceRunsForLine(block, line);
275208
+ const safeX = Math.max(0, Math.min(renderedLineWidth, x - alignmentOffset));
275209
+ let currentX = 0;
275210
+ let currentCharOffset = 0;
275211
+ let spaceTally = 0;
275212
+ for (const run2 of runs2) {
275259
275213
  if (isTabRun$1(run2)) {
275260
- length$12 += TAB_CHAR_LENGTH;
275214
+ const tabWidth = run2.width ?? 0;
275215
+ const startX = currentX;
275216
+ const endX = currentX + tabWidth;
275217
+ if (safeX <= endX) {
275218
+ const offsetInRun = safeX < startX + tabWidth / 2 ? 0 : TAB_CHAR_LENGTH;
275219
+ const charOffset = currentCharOffset + offsetInRun;
275220
+ return {
275221
+ charOffset,
275222
+ pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
275223
+ };
275224
+ }
275225
+ currentX = endX;
275226
+ currentCharOffset += TAB_CHAR_LENGTH;
275261
275227
  continue;
275262
275228
  }
275263
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math")
275229
+ const text5 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" ? "" : run2.text ?? "";
275230
+ const runLength = text5.length;
275231
+ const displayText = applyTextTransform$3(text5, isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" ? undefined : run2.textTransform);
275232
+ if (runLength === 0)
275264
275233
  continue;
275265
- length$12 += (run2.text ?? "").length;
275266
- }
275267
- return length$12;
275268
- }
275269
- function nearestOffsetToX(x, maxOffset, xAtOffset) {
275270
- if (maxOffset <= 0 || x <= xAtOffset(0))
275271
- return 0;
275272
- if (x >= xAtOffset(maxOffset))
275273
- return maxOffset;
275274
- let lo = 0;
275275
- let hi = maxOffset;
275276
- while (lo < hi) {
275277
- const mid = lo + hi + 1 >> 1;
275278
- if (xAtOffset(mid) <= x)
275279
- lo = mid;
275280
- else
275281
- hi = mid - 1;
275234
+ ctx$1.font = getRunFontString(run2);
275235
+ for (let i3 = 0;i3 <= runLength; i3++) {
275236
+ const textUpToChar = displayText.slice(0, i3);
275237
+ const measured$1 = ctx$1.measureText(textUpToChar);
275238
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text5.slice(0, i3)) : 0;
275239
+ const charX = currentX + measured$1.width + computeLetterSpacingWidth(run2, i3, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
275240
+ if (charX >= safeX) {
275241
+ if (i3 === 0) {
275242
+ const pmPosition$1 = charOffsetToPm(block, line, currentCharOffset, pmStart);
275243
+ return {
275244
+ charOffset: currentCharOffset,
275245
+ pmPosition: pmPosition$1
275246
+ };
275247
+ }
275248
+ const prevText = displayText.slice(0, i3 - 1);
275249
+ const prevMeasured = ctx$1.measureText(prevText);
275250
+ const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i3 - 1, runLength);
275251
+ const charOffset = Math.abs(safeX - prevX) < Math.abs(safeX - charX) ? currentCharOffset + i3 - 1 : currentCharOffset + i3;
275252
+ return {
275253
+ charOffset,
275254
+ pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
275255
+ };
275256
+ }
275257
+ }
275258
+ const measured = ctx$1.measureText(displayText);
275259
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
275260
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text5) : 0;
275261
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
275262
+ spaceTally += spacesInRun;
275263
+ currentCharOffset += runLength;
275282
275264
  }
275283
- const upper = Math.min(lo + 1, maxOffset);
275284
- return x - xAtOffset(lo) < xAtOffset(upper) - x ? lo : upper;
275265
+ const pmPosition = charOffsetToPm(block, line, currentCharOffset, pmStart);
275266
+ return {
275267
+ charOffset: currentCharOffset,
275268
+ pmPosition
275269
+ };
275285
275270
  }
275286
275271
  function getWordLayoutConfig(block) {
275287
275272
  if (!block || block.kind !== "paragraph")
@@ -280911,7 +280896,16 @@ function safeCleanup(fn2, context) {
280911
280896
  console.warn(`[PresentationEditor] ${context} cleanup failed:`, error3);
280912
280897
  }
280913
280898
  }
280899
+ function ensureHiddenHostStylesheet(doc$12) {
280900
+ if (doc$12.getElementById(HIDDEN_HOST_STYLE_ID))
280901
+ return;
280902
+ const style2 = doc$12.createElement("style");
280903
+ style2.id = HIDDEN_HOST_STYLE_ID;
280904
+ style2.textContent = ".presentation-editor__hidden-host .sd-paragraph-content { display: block; }";
280905
+ (doc$12.head ?? doc$12.documentElement)?.appendChild(style2);
280906
+ }
280914
280907
  function createHiddenHost(doc$12, widthPx) {
280908
+ ensureHiddenHostStylesheet(doc$12);
280915
280909
  const wrapper = doc$12.createElement("div");
280916
280910
  wrapper.className = "presentation-editor__hidden-host-wrapper";
280917
280911
  wrapper.style.setProperty("position", "fixed");
@@ -280938,6 +280932,66 @@ function createHiddenHost(doc$12, widthPx) {
280938
280932
  host
280939
280933
  };
280940
280934
  }
280935
+ function findRenderedCommentElements(host, commentId, storyKey) {
280936
+ if (!host || !commentId)
280937
+ return [];
280938
+ return Array.from(host.querySelectorAll("[data-comment-ids]")).filter((el) => {
280939
+ const raw = el.dataset.commentIds;
280940
+ if (!raw)
280941
+ return false;
280942
+ if (!raw.split(",").some((token$1) => token$1.trim() === commentId))
280943
+ return false;
280944
+ if (!storyKey)
280945
+ return true;
280946
+ const elStoryKey = el.dataset.storyKey;
280947
+ if (elStoryKey)
280948
+ return elStoryKey === storyKey;
280949
+ return storyKey === BODY_STORY_KEY;
280950
+ });
280951
+ }
280952
+ function findRenderedTrackedChangeElementsStrict(host, entityId, escapeAttrValue$1, storyKey) {
280953
+ if (!host || !entityId)
280954
+ return [];
280955
+ const baseSelector = `[data-track-change-id="${escapeAttrValue$1(entityId)}"]`;
280956
+ if (!storyKey)
280957
+ return Array.from(host.querySelectorAll(baseSelector));
280958
+ const storySelector = `${baseSelector}[data-story-key="${escapeAttrValue$1(storyKey)}"]`;
280959
+ return Array.from(host.querySelectorAll(storySelector));
280960
+ }
280961
+ function findRenderedContentControlElements(host, entityId, escapeAttrValue$1, _storyKey) {
280962
+ if (!host || !entityId)
280963
+ return [];
280964
+ const id2 = escapeAttrValue$1(entityId);
280965
+ const selector = `.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}[data-sdt-id="${id2}"][data-sdt-type="structuredContent"],.${DOM_CLASS_NAMES.BLOCK_SDT}[data-sdt-id="${id2}"][data-sdt-type="structuredContent"]`;
280966
+ return Array.from(host.querySelectorAll(selector));
280967
+ }
280968
+ function elementsToRangeRects(elements) {
280969
+ const result = [];
280970
+ for (const element3 of elements) {
280971
+ const rect = element3.getBoundingClientRect();
280972
+ if (![
280973
+ rect.top,
280974
+ rect.left,
280975
+ rect.right,
280976
+ rect.bottom,
280977
+ rect.width,
280978
+ rect.height
280979
+ ].every(Number.isFinite))
280980
+ continue;
280981
+ const pageEl = element3.closest(".superdoc-page");
280982
+ const pageIndexAttr = Number(pageEl?.dataset?.pageIndex ?? 0);
280983
+ result.push({
280984
+ pageIndex: Number.isFinite(pageIndexAttr) ? pageIndexAttr : 0,
280985
+ left: rect.left,
280986
+ top: rect.top,
280987
+ right: rect.right,
280988
+ bottom: rect.bottom,
280989
+ width: rect.width,
280990
+ height: rect.height
280991
+ });
280992
+ }
280993
+ return result;
280994
+ }
280941
280995
  function getFallbackCursorColor(clientId, fallbackColors) {
280942
280996
  return fallbackColors[clientId % fallbackColors.length];
280943
280997
  }
@@ -282073,24 +282127,33 @@ function renderSelectionRects({ localSelectionLayer, rects, pageHeight, pageGap,
282073
282127
  localSelectionLayer.appendChild(highlight);
282074
282128
  });
282075
282129
  }
282076
- function renderCaretOverlay({ localSelectionLayer, caretLayout, convertPageLocalToOverlayCoords: convertPageLocalToOverlayCoords$1 }) {
282077
- const coords = convertPageLocalToOverlayCoords$1(caretLayout.pageIndex, caretLayout.x, caretLayout.y);
282078
- if (!coords)
282079
- return;
282080
- const finalHeight = Math.max(1, caretLayout.height);
282081
- const caretEl = localSelectionLayer.ownerDocument?.createElement("div");
282130
+ function createCaretElement(doc$12, { left: left$1, top: top$1, height }) {
282131
+ const caretEl = doc$12?.createElement("div");
282082
282132
  if (!caretEl)
282083
- return;
282133
+ return null;
282084
282134
  caretEl.className = "presentation-editor__selection-caret";
282085
282135
  caretEl.style.position = "absolute";
282086
- caretEl.style.left = `${coords.x}px`;
282087
- caretEl.style.top = `${coords.y}px`;
282136
+ caretEl.style.left = `${left$1}px`;
282137
+ caretEl.style.top = `${top$1}px`;
282088
282138
  caretEl.style.width = "2px";
282089
- caretEl.style.height = `${finalHeight}px`;
282139
+ caretEl.style.height = `${Math.max(1, height)}px`;
282090
282140
  caretEl.style.backgroundColor = "#000000";
282091
282141
  caretEl.style.borderRadius = "1px";
282092
282142
  caretEl.style.boxShadow = "0 0 0 1px rgba(255, 255, 255, 0.92)";
282093
282143
  caretEl.style.pointerEvents = "none";
282144
+ return caretEl;
282145
+ }
282146
+ function renderCaretOverlay({ localSelectionLayer, caretLayout, convertPageLocalToOverlayCoords: convertPageLocalToOverlayCoords$1 }) {
282147
+ const coords = convertPageLocalToOverlayCoords$1(caretLayout.pageIndex, caretLayout.x, caretLayout.y);
282148
+ if (!coords)
282149
+ return;
282150
+ const caretEl = createCaretElement(localSelectionLayer.ownerDocument, {
282151
+ left: coords.x,
282152
+ top: coords.y,
282153
+ height: caretLayout.height
282154
+ });
282155
+ if (!caretEl)
282156
+ return;
282094
282157
  localSelectionLayer.appendChild(caretEl);
282095
282158
  }
282096
282159
  function computeTableCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom }, pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
@@ -288200,6 +288263,9 @@ function serializePerIdNumbering(order$1, numberById, formatById) {
288200
288263
  }
288201
288264
  return parts.join(";");
288202
288265
  }
288266
+ function shouldContinueNavigation(options) {
288267
+ return options.shouldContinue?.() !== false;
288268
+ }
288203
288269
  function escapeAttrValue(value) {
288204
288270
  const cssApi = typeof globalThis === "object" && globalThis && "CSS" in globalThis ? globalThis.CSS : undefined;
288205
288271
  if (typeof cssApi?.escape === "function")
@@ -299600,7 +299666,7 @@ var Node$13 = class Node$14 {
299600
299666
  const pendingDeadKeyPlaceholder = TrackChangesBasePluginKey.getState(state)?.pendingDeadKeyPlaceholder ?? null;
299601
299667
  const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta2) => !ALLOWED_META_KEYS.has(meta2));
299602
299668
  const isBlockIdentityRepair = Boolean(tr.getMeta("superdoc/block-identity-repair"));
299603
- if (ySyncMeta?.isChangeOrigin || !tr.steps.length || isBlockIdentityRepair || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
299669
+ if (ySyncMeta?.isChangeOrigin || !tr.steps.length || isBlockIdentityRepair || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey) || tr.getMeta("compositionTrackingFlush") === true) {
299604
299670
  if (pendingDeadKeyPlaceholder && !isCompositionTransaction(tr))
299605
299671
  mergeTrackChangesMeta(tr, { pendingDeadKeyPlaceholder: null });
299606
299672
  return tr;
@@ -302516,7 +302582,28 @@ var Node$13 = class Node$14 {
302516
302582
  if (!allowedRanges?.length)
302517
302583
  return false;
302518
302584
  return allowedRanges.some((allowed) => range.from >= allowed.from && range.to <= allowed.to);
302519
- }, PermissionRanges, Protection, VerticalNavigationPluginKey, createDefaultState = () => ({
302585
+ }, PermissionRanges, Protection, DOM_CLASS_NAMES, STRUCTURED_CONTENT_CHROME_LABEL_CLASS_NAMES, DATA_ATTRS, DATASET_KEYS, encodeLayoutStoryDataset = (story) => story.kind === "body" ? "body" : story.id ? `${story.kind}:${story.id}` : story.kind, decodeLayoutStoryDataset = (raw) => {
302586
+ if (!raw)
302587
+ return { kind: "unknown" };
302588
+ if (raw === "body")
302589
+ return { kind: "body" };
302590
+ const idx = raw.indexOf(":");
302591
+ const kind = idx === -1 ? raw : raw.slice(0, idx);
302592
+ const id2 = idx === -1 ? undefined : raw.slice(idx + 1);
302593
+ switch (kind) {
302594
+ case "body":
302595
+ case "header":
302596
+ case "footer":
302597
+ case "footnote":
302598
+ case "endnote":
302599
+ return id2 ? {
302600
+ kind,
302601
+ id: id2
302602
+ } : { kind };
302603
+ default:
302604
+ return { kind: "unknown" };
302605
+ }
302606
+ }, DRAGGABLE_SELECTOR, VerticalNavigationPluginKey, createDefaultState = () => ({
302520
302607
  goalX: null,
302521
302608
  goalClientX: null
302522
302609
  }), VerticalNavigation, STRONG_RTL_CHAR_RE$1, STRONG_LTR_CHAR_RE, isStrongRtl = (char) => STRONG_RTL_CHAR_RE$1.test(char), isStrongLtr = (char) => STRONG_LTR_CHAR_RE.test(char), hasMixedDirectionBoundary = (leftChar, rightChar) => isStrongRtl(leftChar) && isStrongLtr(rightChar) || isStrongLtr(leftChar) && isStrongRtl(rightChar), resolveCaretPoint = (doc$12, range) => {
@@ -304504,7 +304591,9 @@ var Node$13 = class Node$14 {
304504
304591
  if (!tr)
304505
304592
  return;
304506
304593
  view.dispatch?.(closeHistory(tr));
304507
- }, handleEnter = (editor) => {
304594
+ }, isComposing = (editor) => editor?.view?.composing === true, handleEnter = (editor) => {
304595
+ if (isComposing(editor))
304596
+ return false;
304508
304597
  const { view } = editor;
304509
304598
  dispatchHistoryBoundary(view);
304510
304599
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -304515,6 +304604,8 @@ var Node$13 = class Node$14 {
304515
304604
  () => commands$1.splitBlock()
304516
304605
  ]);
304517
304606
  }, handleBackspace = (editor) => {
304607
+ if (isComposing(editor))
304608
+ return false;
304518
304609
  const { view } = editor;
304519
304610
  dispatchHistoryBoundary(view);
304520
304611
  return editor.commands.first(({ commands: commands$1, tr }) => [
@@ -304541,6 +304632,8 @@ var Node$13 = class Node$14 {
304541
304632
  () => commands$1.selectNodeBackward()
304542
304633
  ]);
304543
304634
  }, handleDelete2 = (editor) => {
304635
+ if (isComposing(editor))
304636
+ return false;
304544
304637
  const { view } = editor;
304545
304638
  dispatchHistoryBoundary(view);
304546
304639
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -304610,13 +304703,13 @@ var Node$13 = class Node$14 {
304610
304703
  }, handleInsertTextBeforeInput = (view, event, editor) => {
304611
304704
  const isInsertTextInput = event?.inputType === "insertText";
304612
304705
  const hasTextData = typeof event?.data === "string" && event.data.length > 0;
304613
- const isComposing = event?.isComposing === true;
304706
+ const isComposing$1 = event?.isComposing === true;
304614
304707
  recordStoryInputDebug(view, event, editor, "beforeinput:start", {
304615
304708
  isInsertTextInput,
304616
304709
  hasTextData,
304617
- isComposing
304710
+ isComposing: isComposing$1
304618
304711
  });
304619
- if (!isInsertTextInput || !hasTextData || isComposing) {
304712
+ if (!isInsertTextInput || !hasTextData || isComposing$1) {
304620
304713
  recordStoryInputDebug(view, event, editor, "beforeinput:skip");
304621
304714
  return false;
304622
304715
  }
@@ -306610,8 +306703,10 @@ var Node$13 = class Node$14 {
306610
306703
  }, Editor, token = (varName, fallback) => ({
306611
306704
  css: `var(${varName}, ${fallback})`,
306612
306705
  fallback
306613
- }), H, TRACK_CHANGE_FOCUSED_CLASS = "track-change-focused", COMMENT_HIGHLIGHT_SELECTOR$1 = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR$1 = "[data-track-change-id]", CommentHighlightDecorator = class {
306706
+ }), H, TRACK_CHANGE_FOCUSED_CLASS = "track-change-focused", COMMENT_HIGHLIGHT_SELECTOR$1 = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR$1 = "[data-track-change-id], [data-track-change-ids]", CommentHighlightDecorator = class {
306614
306707
  #activeCommentId = null;
306708
+ #activeTrackChangeIds = /* @__PURE__ */ new Set;
306709
+ #activeTrackChangeIdsKey = "";
306615
306710
  #container = null;
306616
306711
  setContainer(container) {
306617
306712
  this.#container = container;
@@ -306625,6 +306720,15 @@ var Node$13 = class Node$14 {
306625
306720
  this.#activeCommentId = commentId;
306626
306721
  return true;
306627
306722
  }
306723
+ setActiveTrackChangeIds(ids) {
306724
+ const nextIds = Array.from(new Set(ids.filter((id2) => id2.length > 0)));
306725
+ const nextKey = nextIds.join("\x00");
306726
+ if (this.#activeTrackChangeIdsKey === nextKey)
306727
+ return false;
306728
+ this.#activeTrackChangeIdsKey = nextKey;
306729
+ this.#activeTrackChangeIds = new Set(nextIds);
306730
+ return true;
306731
+ }
306628
306732
  apply() {
306629
306733
  const root3 = this.#container;
306630
306734
  if (!root3)
@@ -306696,16 +306800,27 @@ var Node$13 = class Node$14 {
306696
306800
  return null;
306697
306801
  }
306698
306802
  #applyTrackChangeFocus(root3) {
306699
- const activeId = this.#activeCommentId;
306803
+ const legacyActiveId = this.#activeCommentId;
306804
+ const activeTrackChangeIds = this.#activeTrackChangeIds;
306700
306805
  const elements = root3.querySelectorAll(TRACK_CHANGE_SELECTOR$1);
306701
306806
  for (let i3 = 0;i3 < elements.length; i3++) {
306702
306807
  const el = elements[i3];
306703
- if (activeId && el.dataset.trackChangeId === activeId)
306808
+ if (this.#matchesActiveTrackChange(el, activeTrackChangeIds, legacyActiveId))
306704
306809
  el.classList.add(TRACK_CHANGE_FOCUSED_CLASS);
306705
306810
  else
306706
306811
  el.classList.remove(TRACK_CHANGE_FOCUSED_CLASS);
306707
306812
  }
306708
306813
  }
306814
+ #matchesActiveTrackChange(el, activeTrackChangeIds, legacyActiveId) {
306815
+ const ids = [
306816
+ el.dataset.trackChangeId,
306817
+ el.dataset.trackChangePreferredTargetId,
306818
+ ...parseCommaSeparated(el.dataset.trackChangeIds)
306819
+ ].filter((id2) => Boolean(id2));
306820
+ if (legacyActiveId && ids.includes(legacyActiveId))
306821
+ return true;
306822
+ return ids.some((id2) => activeTrackChangeIds.has(id2));
306823
+ }
306709
306824
  }, EXCLUDED_PLUGIN_KEY_REF_LIST, EXCLUDED_PLUGIN_KEY_REFS, EXCLUDED_PLUGIN_KEY_PREFIXES, TEXT_RANGE_BLOCK_SEP = `
306710
306825
  `, TEXT_RANGE_LEAF_SEP = `
306711
306826
  `, DecorationBridge = class DecorationBridge2 {
@@ -307410,6 +307525,9 @@ var Node$13 = class Node$14 {
307410
307525
  setActiveComment(commentId) {
307411
307526
  return this.#commentHighlightDecorator.setActiveComment(commentId);
307412
307527
  }
307528
+ setActiveTrackChangeIds(ids) {
307529
+ return this.#commentHighlightDecorator.setActiveTrackChangeIds(ids);
307530
+ }
307413
307531
  recordDecorationTransaction(transaction) {
307414
307532
  this.#decorationBridge.recordTransaction(transaction);
307415
307533
  }
@@ -314672,7 +314790,7 @@ menclose::after {
314672
314790
  container.style.width = `${Math.max(0, data.contentWidth)}px`;
314673
314791
  else
314674
314792
  container.style.width = `calc(100% - ${marginLeft + marginRight}px)`;
314675
- container.style.pointerEvents = "auto";
314793
+ container.style.pointerEvents = "none";
314676
314794
  container.style.height = `${effectiveHeight}px`;
314677
314795
  container.style.top = `${Math.max(0, effectiveOffset)}px`;
314678
314796
  container.style.zIndex = "1";
@@ -317042,10 +317160,7 @@ menclose::after {
317042
317160
  return run2.text?.length ?? 0;
317043
317161
  }, isVisualOnlyRun = (run2) => {
317044
317162
  return getRunDataAttrs(run2)?.[FOOTNOTE_MARKER_DATA_ATTR$1] === "true";
317045
- }, SPACE_CHARS$1, isTabRun$1 = (run2) => run2?.kind === "tab", faceOf$1 = (run2) => ({
317046
- weight: run2.bold ? "700" : "400",
317047
- style: run2.italic ? "italic" : "normal"
317048
- }), isWordChar$3 = (char) => {
317163
+ }, SPACE_CHARS$1, isTabRun$1 = (run2) => run2?.kind === "tab", isWordChar$3 = (char) => {
317049
317164
  if (!char)
317050
317165
  return false;
317051
317166
  const code6 = char.charCodeAt(0);
@@ -320325,7 +320440,7 @@ menclose::after {
320325
320440
  this.#onRebuild();
320326
320441
  });
320327
320442
  }
320328
- }, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, log2 = (...args$1) => {}, CLASS, FOOTNOTE_MARKER_DATA_ATTR = "data-sd-footnote-number", DEFAULT_MARKER_FONT_FAMILY$1 = "Arial", DEFAULT_MARKER_FONT_SIZE$1 = 12, SCROLL_DEBOUNCE_MS = 32, DEFAULT_STALE_TIMEOUT_MS, THROTTLE_MS = 16, RemoteCursorManager = class {
320443
+ }, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, log2 = (...args$1) => {}, CLASS, FOOTNOTE_MARKER_DATA_ATTR = "data-sd-footnote-number", DEFAULT_MARKER_FONT_FAMILY$1 = "Arial", DEFAULT_MARKER_FONT_SIZE$1 = 12, HIDDEN_HOST_STYLE_ID = "sd-presentation-hidden-host-styles", SCROLL_DEBOUNCE_MS = 32, DEFAULT_STALE_TIMEOUT_MS, THROTTLE_MS = 16, RemoteCursorManager = class {
320329
320444
  #options;
320330
320445
  #remoteCursorState = /* @__PURE__ */ new Map;
320331
320446
  #remoteCursorElements = /* @__PURE__ */ new Map;
@@ -326211,25 +326326,24 @@ menclose::after {
326211
326326
  }
326212
326327
  `, movableObjectInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
326213
326328
  return typeof event?.source === "string" && INTERNAL_NOTE_COMMIT_SOURCES.has(event.source);
326214
- }, DOCUMENT_RELS_PART_ID = "word/_rels/document.xml.rels", DEFAULT_PAGE_SIZE, DEFAULT_MARGINS, DEFAULT_PAGE_GAP = 24, DEFAULT_HORIZONTAL_PAGE_GAP = 20, layoutDebugEnabled, perfLog = (...args$1) => {
326329
+ }, DOCUMENT_RELS_PART_ID = "word/_rels/document.xml.rels", DEFAULT_PAGE_SIZE, DEFAULT_MARGINS, DEFAULT_PAGE_GAP = 24, DEFAULT_HORIZONTAL_PAGE_GAP = 20, NAVIGATED_CARET_REPAIR_DELAYS_MS, NAVIGATED_CARET_DRIFT_TOLERANCE_PX = 3, NAVIGATED_CARET_MAX_REPAIR_ATTEMPTS = 3, SELECTION_SCROLL_SETTLE_RENDER_DELAY_MS = 120, SELECTION_SCROLL_SETTLE_FINALIZE_DELAY_MS = 900, layoutDebugEnabled, perfLog = (...args$1) => {
326215
326330
  if (!layoutDebugEnabled)
326216
326331
  return;
326217
326332
  console.log(...args$1);
326218
326333
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
326219
- var init_src_bGJhSgx__es = __esm(() => {
326334
+ var init_src_CR8eXLKh_es = __esm(() => {
326220
326335
  init_rolldown_runtime_Bg48TavK_es();
326221
- init_SuperConverter_Du0apG1R_es();
326336
+ init_SuperConverter_DQ2wMaLK_es();
326222
326337
  init_jszip_C49i9kUs_es();
326223
326338
  init_xml_js_CqGKpaft_es();
326224
326339
  init_uuid_B2wVPhPi_es();
326225
- init_create_headless_toolbar_BNcguDpP_es();
326340
+ init_create_headless_toolbar_BhSfQYaO_es();
326226
326341
  init_constants_D9qj59G2_es();
326227
326342
  init_unified_BDuVPlMu_es();
326228
326343
  init_remark_gfm_BUJjZJLy_es();
326229
326344
  init_remark_stringify_BZvKOjUX_es();
326230
326345
  init_DocxZipper_BzS208BW_es();
326231
326346
  init__plugin_vue_export_helper_HmhZBO0u_es();
326232
- init_ui_BMYSpkne_es();
326233
326347
  init_eventemitter3_UwU_CLPU_es();
326234
326348
  init_errors_C_DoKMoN_es();
326235
326349
  init_blank_docx_CDDHd6CH_es();
@@ -351403,6 +351517,66 @@ function print() { __p += __j.call(arguments, '') }
351403
351517
  };
351404
351518
  }
351405
351519
  });
351520
+ DOM_CLASS_NAMES = {
351521
+ PAGE: "superdoc-page",
351522
+ FRAGMENT: "superdoc-fragment",
351523
+ LINE: "superdoc-line",
351524
+ INLINE_SDT_WRAPPER: "superdoc-structured-content-inline",
351525
+ INLINE_SDT_LABEL: "superdoc-structured-content-inline__label",
351526
+ BLOCK_SDT: "superdoc-structured-content-block",
351527
+ BLOCK_SDT_LABEL: "superdoc-structured-content__label",
351528
+ TABLE_FRAGMENT: "superdoc-table-fragment",
351529
+ DOCUMENT_SECTION: "superdoc-document-section",
351530
+ SDT_GROUP_HOVER: "sdt-group-hover",
351531
+ TOC_ENTRY: "superdoc-toc-entry",
351532
+ TOC_GROUP_HOVER: "toc-group-hover",
351533
+ IMAGE_FRAGMENT: "superdoc-image-fragment",
351534
+ INLINE_IMAGE: "superdoc-inline-image",
351535
+ LIST_MARKER: "superdoc-list-marker",
351536
+ INLINE_IMAGE_CLIP_WRAPPER: "superdoc-inline-image-clip-wrapper",
351537
+ ANNOTATION: "annotation",
351538
+ ANNOTATION_CONTENT: "annotation-content",
351539
+ ANNOTATION_CARET_ANCHOR: "annotation-caret-anchor"
351540
+ };
351541
+ STRUCTURED_CONTENT_CHROME_LABEL_CLASS_NAMES = [DOM_CLASS_NAMES.INLINE_SDT_LABEL, DOM_CLASS_NAMES.BLOCK_SDT_LABEL];
351542
+ DATA_ATTRS = {
351543
+ PM_START: "data-pm-start",
351544
+ PM_END: "data-pm-end",
351545
+ LAYOUT_EPOCH: "data-layout-epoch",
351546
+ TABLE_BOUNDARIES: "data-table-boundaries",
351547
+ SDT_ID: "data-sdt-id",
351548
+ SDT_TYPE: "data-sdt-type",
351549
+ FIELD_ID: "data-field-id",
351550
+ FIELD_TYPE: "data-field-type",
351551
+ DRAGGABLE: "data-draggable",
351552
+ DISPLAY_LABEL: "data-display-label",
351553
+ VARIANT: "data-variant",
351554
+ TYPE: "data-type",
351555
+ LAYOUT_BOUNDARY_SCHEMA: "data-layout-boundary-schema",
351556
+ LAYOUT_FRAGMENT_ID: "data-layout-fragment-id",
351557
+ LAYOUT_STORY: "data-layout-story",
351558
+ LAYOUT_BLOCK_REF: "data-layout-block-ref"
351559
+ };
351560
+ DATASET_KEYS = {
351561
+ PM_START: "pmStart",
351562
+ PM_END: "pmEnd",
351563
+ LAYOUT_EPOCH: "layoutEpoch",
351564
+ TABLE_BOUNDARIES: "tableBoundaries",
351565
+ SDT_ID: "sdtId",
351566
+ SDT_TYPE: "sdtType",
351567
+ FIELD_ID: "fieldId",
351568
+ FIELD_TYPE: "fieldType",
351569
+ DRAGGABLE: "draggable",
351570
+ DISPLAY_LABEL: "displayLabel",
351571
+ VARIANT: "variant",
351572
+ TYPE: "type",
351573
+ LAYOUT_BOUNDARY_SCHEMA: "layoutBoundarySchema",
351574
+ LAYOUT_FRAGMENT_ID: "layoutFragmentId",
351575
+ LAYOUT_STORY: "layoutStory",
351576
+ LAYOUT_BLOCK_REF: "layoutBlockRef"
351577
+ };
351578
+ `${DOM_CLASS_NAMES.BLOCK_SDT}${DATA_ATTRS.SDT_ID}`;
351579
+ DRAGGABLE_SELECTOR = `[${DATA_ATTRS.DRAGGABLE}="true"]`;
351406
351580
  VerticalNavigationPluginKey = new PluginKey("verticalNavigation");
351407
351581
  VerticalNavigation = Extension.create({
351408
351582
  name: "verticalNavigation",
@@ -354121,7 +354295,7 @@ function print() { __p += __j.call(arguments, '') }
354121
354295
  const activeIndex = exports_vue.ref(-1);
354122
354296
  const query2 = exports_vue.ref("");
354123
354297
  const inputDisplay = exports_vue.ref("");
354124
- const isComposing = exports_vue.ref(false);
354298
+ const isComposing$1 = exports_vue.ref(false);
354125
354299
  const menuPosition = exports_vue.ref({
354126
354300
  top: "0px",
354127
354301
  left: "0px",
@@ -354264,7 +354438,7 @@ function print() { __p += __j.call(arguments, '') }
354264
354438
  resetToApplied();
354265
354439
  };
354266
354440
  const onInput = (event) => {
354267
- if (isComposing.value)
354441
+ if (isComposing$1.value)
354268
354442
  return;
354269
354443
  const el = event.target;
354270
354444
  const typed = el.value;
@@ -354286,7 +354460,7 @@ function print() { __p += __j.call(arguments, '') }
354286
354460
  }
354287
354461
  };
354288
354462
  const onCompositionEnd = (event) => {
354289
- isComposing.value = false;
354463
+ isComposing$1.value = false;
354290
354464
  onInput(event);
354291
354465
  };
354292
354466
  const moveActive = (direction) => {
@@ -354337,7 +354511,7 @@ function print() { __p += __j.call(arguments, '') }
354337
354511
  return false;
354338
354512
  };
354339
354513
  const onKeydown = (event) => {
354340
- if (event.isComposing || isComposing.value || event.keyCode === 229)
354514
+ if (event.isComposing || isComposing$1.value || event.keyCode === 229)
354341
354515
  return;
354342
354516
  if (event.ctrlKey || event.metaKey || event.altKey)
354343
354517
  return;
@@ -354493,7 +354667,7 @@ function print() { __p += __j.call(arguments, '') }
354493
354667
  onBlur,
354494
354668
  onInput,
354495
354669
  onKeydown,
354496
- onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing.value = true),
354670
+ onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing$1.value = true),
354497
354671
  onCompositionend: onCompositionEnd
354498
354672
  }, null, 44, _hoisted_1$7)], 32),
354499
354673
  exports_vue.createElementVNode("button", {
@@ -358271,6 +358445,11 @@ function print() { __p += __j.call(arguments, '') }
358271
358445
  this.#trackDocumentOpen();
358272
358446
  }
358273
358447
  unmount() {
358448
+ this.view?.dom?.removeEventListener("compositionend", this.#handleDomCompositionEnd);
358449
+ this.view?.dom?.removeEventListener("blur", this.#handleDomCompositionEnd);
358450
+ this.#deferredCompositionRange = null;
358451
+ this.#deferredCompositionDeletions = [];
358452
+ this.#deferredCompositionId = undefined;
358274
358453
  if (this.#renderer)
358275
358454
  this.#renderer.destroy();
358276
358455
  else if (this.view)
@@ -358911,6 +359090,8 @@ function print() { __p += __j.call(arguments, '') }
358911
359090
  state: this.state,
358912
359091
  handleClick: this.#handleNodeSelection.bind(this)
358913
359092
  });
359093
+ this.view?.dom?.addEventListener("compositionend", this.#handleDomCompositionEnd);
359094
+ this.view?.dom?.addEventListener("blur", this.#handleDomCompositionEnd);
358914
359095
  this.createNodeViews();
358915
359096
  }
358916
359097
  createNodeViews() {
@@ -359021,6 +359202,223 @@ function print() { __p += __j.call(arguments, '') }
359021
359202
  this.#dispatchTransaction(tr);
359022
359203
  }, 50);
359023
359204
  }
359205
+ #deferredCompositionRange = null;
359206
+ #deferredCompositionDeletions = [];
359207
+ #deferredCompositionId = undefined;
359208
+ #canDeferCompositionTracking(tr, state) {
359209
+ if (!tr.steps.length)
359210
+ return false;
359211
+ const range = this.#deferredCompositionRange;
359212
+ for (let index2 = 0;index2 < tr.steps.length; index2 += 1) {
359213
+ const step3 = tr.steps[index2];
359214
+ if (!(step3 instanceof ReplaceStep))
359215
+ return false;
359216
+ if (step3.from < step3.to && (!range || step3.from < range.from || step3.to > range.to)) {
359217
+ const sourceDoc = tr.docs[index2] ?? state.doc;
359218
+ if (!this.#canRestoreDeferredCompositionDeletion(step3, sourceDoc))
359219
+ return false;
359220
+ }
359221
+ }
359222
+ return true;
359223
+ }
359224
+ #canRestoreDeferredCompositionDeletion(step3, doc$12) {
359225
+ if (step3.slice.size === 0)
359226
+ return false;
359227
+ let hasText = false;
359228
+ let hasUnsupportedContent = false;
359229
+ doc$12.nodesBetween(step3.from, step3.to, (node3) => {
359230
+ if (hasUnsupportedContent)
359231
+ return false;
359232
+ if (node3.type.name.includes("table") || node3.isLeaf && !node3.isText) {
359233
+ hasUnsupportedContent = true;
359234
+ return false;
359235
+ }
359236
+ if (node3.isText && node3.text)
359237
+ hasText = true;
359238
+ return true;
359239
+ });
359240
+ return hasText && !hasUnsupportedContent;
359241
+ }
359242
+ #collectDeferredCompositionDeletions(tr) {
359243
+ const deletions = [];
359244
+ const range = this.#deferredCompositionRange;
359245
+ tr.steps.forEach((step3, index2) => {
359246
+ if (!(step3 instanceof ReplaceStep) || step3.from >= step3.to)
359247
+ return;
359248
+ if (range && step3.from >= range.from && step3.to <= range.to)
359249
+ return;
359250
+ const sourceDoc = tr.docs[index2] ?? this.state.doc;
359251
+ if (!this.#canRestoreDeferredCompositionDeletion(step3, sourceDoc))
359252
+ return;
359253
+ const rest = tr.mapping.slice(index2 + 1);
359254
+ deletions.push({
359255
+ pos: rest.map(step3.from + step3.slice.size, 1),
359256
+ slice: sourceDoc.slice(step3.from, step3.to)
359257
+ });
359258
+ });
359259
+ return deletions;
359260
+ }
359261
+ #replacesWithinDeferredRange(tr) {
359262
+ const range = this.#deferredCompositionRange;
359263
+ if (!range || !tr.steps.length)
359264
+ return false;
359265
+ return tr.steps.every((step3) => step3 instanceof ReplaceStep && step3.from < step3.to && step3.from >= range.from && step3.to <= range.to);
359266
+ }
359267
+ #updateDeferredCompositionRange(applied, deferredSource) {
359268
+ if (!this.#deferredCompositionRange && !deferredSource)
359269
+ return;
359270
+ let range = this.#deferredCompositionRange;
359271
+ for (const tr of applied) {
359272
+ if (range) {
359273
+ const from$1 = tr.mapping.map(range.from, -1);
359274
+ const to = tr.mapping.map(range.to, 1);
359275
+ range = from$1 < to ? {
359276
+ from: from$1,
359277
+ to
359278
+ } : null;
359279
+ }
359280
+ if (tr === deferredSource)
359281
+ tr.steps.forEach((step3, index2) => {
359282
+ if (!(step3 instanceof ReplaceStep) || step3.slice.size === 0)
359283
+ return;
359284
+ const rest = tr.mapping.slice(index2 + 1);
359285
+ const from$1 = rest.map(step3.from, -1);
359286
+ const to = rest.map(step3.from + step3.slice.size, 1);
359287
+ range = range ? {
359288
+ from: Math.min(range.from, from$1),
359289
+ to: Math.max(range.to, to)
359290
+ } : {
359291
+ from: from$1,
359292
+ to
359293
+ };
359294
+ });
359295
+ }
359296
+ this.#deferredCompositionRange = range;
359297
+ }
359298
+ #mapDeferredCompositionDeletions(applied) {
359299
+ if (!this.#deferredCompositionDeletions.length)
359300
+ return;
359301
+ this.#deferredCompositionDeletions = this.#mapCompositionDeletions(this.#deferredCompositionDeletions, applied);
359302
+ }
359303
+ #mapCompositionDeletions(deletions, applied) {
359304
+ if (!deletions.length || !applied.length)
359305
+ return deletions;
359306
+ return deletions.map((deletion) => {
359307
+ let pos = deletion.pos;
359308
+ for (const tr of applied)
359309
+ pos = tr.mapping.map(pos, -1);
359310
+ return {
359311
+ ...deletion,
359312
+ pos
359313
+ };
359314
+ });
359315
+ }
359316
+ #flushDeferredCompositionTracking() {
359317
+ const range = this.#deferredCompositionRange;
359318
+ const deletions = this.#deferredCompositionDeletions;
359319
+ const compositionId = this.#deferredCompositionId;
359320
+ this.#deferredCompositionRange = null;
359321
+ this.#deferredCompositionDeletions = [];
359322
+ this.#deferredCompositionId = undefined;
359323
+ if (!range || this.isDestroyed || !this.view)
359324
+ return;
359325
+ const state = this.state;
359326
+ if (!TrackChangesBasePluginKey.getState(state)?.isTrackChangesActive)
359327
+ return;
359328
+ const from$1 = Math.max(0, Math.min(range.from, state.doc.content.size));
359329
+ const to = Math.max(from$1, Math.min(range.to, state.doc.content.size));
359330
+ if (from$1 >= to)
359331
+ return;
359332
+ const insertMarkType = state.schema.marks[TrackInsertMarkName];
359333
+ if (!insertMarkType)
359334
+ return;
359335
+ let fullyMarked = true;
359336
+ state.doc.nodesBetween(from$1, to, (node3) => {
359337
+ if (node3.isText && !insertMarkType.isInSet(node3.marks))
359338
+ fullyMarked = false;
359339
+ return !node3.isText;
359340
+ });
359341
+ if (fullyMarked && !deletions.length)
359342
+ return;
359343
+ const tr = state.tr;
359344
+ const fixedTimeTo10Mins = Math.floor(Date.now() / 600000) * 600000;
359345
+ const date = new Date(fixedTimeTo10Mins).toISOString();
359346
+ const user = this.options.user ?? {};
359347
+ let insertedMark = fullyMarked ? null : markInsertion({
359348
+ tr,
359349
+ from: from$1,
359350
+ to,
359351
+ user,
359352
+ date
359353
+ });
359354
+ const replacementGroupId = insertedMark && deletions.length && this.options.trackedChanges?.replacements !== "independent" ? insertedMark.attrs.id : "";
359355
+ if (insertedMark && replacementGroupId) {
359356
+ const replacementInsertMark = insertedMark.type.create({
359357
+ ...insertedMark.attrs,
359358
+ changeType: CanonicalChangeType.Replacement,
359359
+ replacementGroupId,
359360
+ replacementSideId: `${replacementGroupId}#inserted`
359361
+ });
359362
+ tr.removeMark(from$1, to, insertedMark);
359363
+ tr.addMark(from$1, to, replacementInsertMark);
359364
+ insertedMark = replacementInsertMark;
359365
+ }
359366
+ let deletionMeta = null;
359367
+ deletions.forEach((deletion) => {
359368
+ const deleteFrom = tr.mapping.map(deletion.pos, -1);
359369
+ const beforeSize = tr.doc.content.size;
359370
+ tr.replace(deleteFrom, deleteFrom, deletion.slice);
359371
+ const deleteTo = deleteFrom + (tr.doc.content.size - beforeSize);
359372
+ if (deleteTo <= deleteFrom)
359373
+ return;
359374
+ const deletionResult = markDeletion({
359375
+ tr,
359376
+ from: deleteFrom,
359377
+ to: deleteTo,
359378
+ user,
359379
+ date,
359380
+ id: replacementGroupId || undefined
359381
+ });
359382
+ const deletionMark = replacementGroupId ? deletionResult.deletionMark.type.create({
359383
+ ...deletionResult.deletionMark.attrs,
359384
+ changeType: CanonicalChangeType.Replacement,
359385
+ replacementGroupId,
359386
+ replacementSideId: `${replacementGroupId}#deleted`
359387
+ }) : deletionResult.deletionMark;
359388
+ if (deletionMark !== deletionResult.deletionMark) {
359389
+ tr.removeMark(deleteFrom, deleteTo, deletionResult.deletionMark);
359390
+ tr.addMark(deleteFrom, deleteTo, deletionMark);
359391
+ }
359392
+ deletionMeta = {
359393
+ deletionMark,
359394
+ deletionNodes: deletionResult.nodes
359395
+ };
359396
+ });
359397
+ tr.setMeta("skipTrackChanges", true);
359398
+ tr.setMeta("compositionTrackingFlush", true);
359399
+ if (compositionId !== undefined)
359400
+ tr.setMeta("composition", compositionId);
359401
+ tr.setMeta(TrackChangesBasePluginKey, {
359402
+ ...insertedMark ? { insertedMark } : {},
359403
+ ...deletionMeta ?? {}
359404
+ });
359405
+ this.view.dispatch(tr);
359406
+ }
359407
+ #handleDomCompositionEnd = (event) => {
359408
+ const forceFlush = event?.type === "blur";
359409
+ queueMicrotask(() => {
359410
+ if (!this.#deferredCompositionRange)
359411
+ return;
359412
+ if (this.view?.composing && !forceFlush)
359413
+ return;
359414
+ try {
359415
+ this.view?.domObserver?.flush?.();
359416
+ } catch {}
359417
+ if (this.view?.composing && !forceFlush)
359418
+ return;
359419
+ this.#flushDeferredCompositionTracking();
359420
+ });
359421
+ };
359024
359422
  #dispatchTransaction(transaction) {
359025
359423
  if (this.isDestroyed)
359026
359424
  return;
@@ -359039,13 +359437,21 @@ function print() { __p += __j.call(arguments, '') }
359039
359437
  const protectsExistingTrackedReviewState = transactionTouchesTrackedReviewState(prevState, transactionToApply);
359040
359438
  if (protectsExistingTrackedReviewState && skipTrackChanges)
359041
359439
  transactionToApply.setMeta("protectTrackedReviewState", true);
359042
- const shouldTrack = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges || protectsExistingTrackedReviewState;
359440
+ const shouldTrackForComposition = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges;
359441
+ const shouldTrack = shouldTrackForComposition || protectsExistingTrackedReviewState;
359043
359442
  if (!shouldTrack && directInsertionMutationCommentMeta && !transactionToApply.getMeta(TrackChangesBasePluginKey))
359044
359443
  transactionToApply.setMeta(TrackChangesBasePluginKey, directInsertionMutationCommentMeta);
359045
359444
  if (shouldTrack && forceTrackChanges && !this.options.user)
359046
359445
  throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");
359446
+ const deferTrackingForComposition = shouldTrackForComposition && (isCompositionTransaction(transactionToApply) || this.view?.composing === true && this.#replacesWithinDeferredRange(transactionToApply)) && this.#canDeferCompositionTracking(transactionToApply, prevState);
359447
+ const deferredCompositionDeletions = deferTrackingForComposition ? this.#collectDeferredCompositionDeletions(transactionToApply) : [];
359448
+ if (deferTrackingForComposition) {
359449
+ const compositionMeta = transactionToApply.getMeta("composition");
359450
+ if (compositionMeta !== undefined)
359451
+ this.#deferredCompositionId = compositionMeta;
359452
+ }
359047
359453
  const trackedUser = this.options.user ?? {};
359048
- transactionToApply = shouldTrack ? trackedTransaction({
359454
+ transactionToApply = shouldTrack && !deferTrackingForComposition ? trackedTransaction({
359049
359455
  tr: transactionToApply,
359050
359456
  state: prevState,
359051
359457
  user: trackedUser,
@@ -359053,6 +359459,12 @@ function print() { __p += __j.call(arguments, '') }
359053
359459
  }) : transactionToApply;
359054
359460
  const { state: appliedState, transactions: appliedTransactions } = prevState.applyTransaction(transactionToApply);
359055
359461
  nextState = appliedState;
359462
+ this.#updateDeferredCompositionRange(appliedTransactions, deferTrackingForComposition ? transactionToApply : null);
359463
+ this.#mapDeferredCompositionDeletions(appliedTransactions);
359464
+ if (deferredCompositionDeletions.length)
359465
+ this.#deferredCompositionDeletions.push(...this.#mapCompositionDeletions(deferredCompositionDeletions, appliedTransactions.slice(1)));
359466
+ if (deferTrackingForComposition && this.view?.composing !== true)
359467
+ this.#handleDomCompositionEnd();
359056
359468
  effectiveTransaction = appliedTransactions.find((t) => t.docChanged) ?? transactionToApply;
359057
359469
  } catch (error3) {
359058
359470
  if (forceTrackChanges)
@@ -361648,6 +362060,12 @@ function print() { __p += __j.call(arguments, '') }
361648
362060
  bottom: 72,
361649
362061
  left: 72
361650
362062
  };
362063
+ NAVIGATED_CARET_REPAIR_DELAYS_MS = [
362064
+ 120,
362065
+ 360,
362066
+ 900,
362067
+ 1300
362068
+ ];
361651
362069
  layoutDebugEnabled = typeof process$1 !== "undefined" && typeof process$1.env !== "undefined" && Boolean(process$1.env.SD_DEBUG_LAYOUT);
361652
362070
  GLOBAL_PERFORMANCE = typeof performance !== "undefined" ? performance : undefined;
361653
362071
  PresentationEditor = class PresentationEditor2 extends EventEmitter2 {
@@ -361722,8 +362140,15 @@ function print() { __p += __j.call(arguments, '') }
361722
362140
  #renderScheduled = false;
361723
362141
  #pendingDocChange = false;
361724
362142
  #focusScrollRafId = null;
362143
+ #selectionScrollSettleCleanup = null;
362144
+ #selectionNavigationToken = 0;
362145
+ #activeSelectionNavigation = null;
361725
362146
  #pendingMapping = null;
361726
362147
  #isRerendering = false;
362148
+ #isComposing = false;
362149
+ #compositionDeferralCleanup = [];
362150
+ #compositionTargetCleanup = [];
362151
+ #compositionTargetDom = null;
361727
362152
  #selectionSync = new SelectionSyncCoordinator;
361728
362153
  #fontGate = null;
361729
362154
  #fontResolver = createFontResolver();
@@ -362064,6 +362489,8 @@ function print() { __p += __j.call(arguments, '') }
362064
362489
  this.#setupPointerHandlers();
362065
362490
  this.#setupDragHandlers();
362066
362491
  this.#setupInputBridge();
362492
+ this.#setupCompositionDeferral();
362493
+ this.#refreshCompositionDeferralTarget();
362067
362494
  this.#syncTrackedChangesPreferences();
362068
362495
  this.#syncHeaderFooterTrackedChangesRenderConfig();
362069
362496
  this.#setupSemanticResizeObserver();
@@ -363669,6 +364096,7 @@ function print() { __p += __j.call(arguments, '') }
363669
364096
  const targetEl = this.#findElementAtPosition(pageEl, clampedPos);
363670
364097
  const elToScroll = targetEl ?? pageEl;
363671
364098
  const block = options.ifNeeded && targetEl && this.#isElementFullyVisibleInScrollContainer(targetEl) ? "nearest" : requestedBlock;
364099
+ this.#startSelectionNavigation(clampedPos);
363672
364100
  elToScroll.scrollIntoView({
363673
364101
  block,
363674
364102
  inline: "nearest",
@@ -363687,6 +364115,7 @@ function print() { __p += __j.call(arguments, '') }
363687
364115
  });
363688
364116
  this.#shouldScrollSelectionIntoView = false;
363689
364117
  this.#suppressSelectionScrollUntilRaf = false;
364118
+ this.#scheduleSelectionUpdateAfterScrollSettles();
363690
364119
  });
363691
364120
  }
363692
364121
  return true;
@@ -363769,6 +364198,164 @@ function print() { __p += __j.call(arguments, '') }
363769
364198
  }
363770
364199
  };
363771
364200
  }
364201
+ #startSelectionNavigation(targetPos) {
364202
+ const token$1 = ++this.#selectionNavigationToken;
364203
+ this.#activeSelectionNavigation = {
364204
+ token: token$1,
364205
+ targetPos,
364206
+ scrollSettled: false,
364207
+ repairAttempts: 0
364208
+ };
364209
+ return token$1;
364210
+ }
364211
+ #markSelectionNavigationScrollSettled() {
364212
+ if (this.#activeSelectionNavigation)
364213
+ this.#activeSelectionNavigation.scrollSettled = true;
364214
+ }
364215
+ #finishSelectionNavigation(token$1) {
364216
+ if (token$1 != null && this.#activeSelectionNavigation?.token !== token$1)
364217
+ return;
364218
+ this.#activeSelectionNavigation = null;
364219
+ }
364220
+ #scheduleNavigatedSelectionRender(targetPos) {
364221
+ this.#startSelectionNavigation(targetPos);
364222
+ this.#scheduleSelectionUpdateAfterScrollSettles();
364223
+ this.#scheduleSelectionUpdate({ immediate: true });
364224
+ this.#scheduleNavigatedCaretViewportRepairs(targetPos);
364225
+ }
364226
+ #scheduleNavigatedCaretViewportRepairs(targetPos) {
364227
+ const win = this.#visibleHost.ownerDocument?.defaultView;
364228
+ if (!win)
364229
+ return;
364230
+ for (const delay of NAVIGATED_CARET_REPAIR_DELAYS_MS)
364231
+ win.setTimeout(() => {
364232
+ if (!this.#localSelectionLayer?.isConnected)
364233
+ return;
364234
+ const selection = this.getActiveEditor()?.state?.selection;
364235
+ if (!selection || selection.from !== targetPos || selection.to !== targetPos)
364236
+ return;
364237
+ this.#rebuildDomPositionIndex();
364238
+ this.#renderNavigatedCaretFromViewportCoords(targetPos);
364239
+ }, delay);
364240
+ }
364241
+ #queueSelectionNavigationCaretRepair(caretPos, navigation) {
364242
+ if (this.#activeSelectionNavigation?.token !== navigation.token)
364243
+ return false;
364244
+ const caretEl = this.#localSelectionLayer.querySelector(".presentation-editor__selection-caret");
364245
+ if (!(caretEl instanceof HTMLElement))
364246
+ return false;
364247
+ const expected = this.coordsAtPos(caretPos);
364248
+ if (!expected)
364249
+ return false;
364250
+ const actual = caretEl.getBoundingClientRect();
364251
+ if (Math.abs(actual.top - expected.top) <= NAVIGATED_CARET_DRIFT_TOLERANCE_PX)
364252
+ return false;
364253
+ if (navigation.repairAttempts >= NAVIGATED_CARET_MAX_REPAIR_ATTEMPTS)
364254
+ return false;
364255
+ navigation.repairAttempts += 1;
364256
+ const win = this.#visibleHost.ownerDocument?.defaultView;
364257
+ const repair = () => {
364258
+ if (this.#activeSelectionNavigation?.token !== navigation.token)
364259
+ return;
364260
+ this.#rebuildDomPositionIndex();
364261
+ this.#scheduleSelectionUpdate({ immediate: true });
364262
+ };
364263
+ if (win)
364264
+ win.requestAnimationFrame(repair);
364265
+ else
364266
+ repair();
364267
+ return true;
364268
+ }
364269
+ #renderNavigatedCaretFromViewportCoords(caretPos) {
364270
+ const coords = this.coordsAtPos(caretPos);
364271
+ if (!coords)
364272
+ return false;
364273
+ const zoom = Number.isFinite(this.#layoutOptions.zoom) && this.#layoutOptions.zoom > 0 ? this.#layoutOptions.zoom : 1;
364274
+ const layerRect = this.#localSelectionLayer.getBoundingClientRect();
364275
+ const caretEl = createCaretElement(this.#localSelectionLayer.ownerDocument, {
364276
+ left: (coords.left - layerRect.left) / zoom,
364277
+ top: (coords.top - layerRect.top) / zoom,
364278
+ height: coords.height / zoom
364279
+ });
364280
+ if (!caretEl)
364281
+ return false;
364282
+ this.#localSelectionLayer.innerHTML = "";
364283
+ this.#localSelectionLayer.appendChild(caretEl);
364284
+ return true;
364285
+ }
364286
+ #scheduleSelectionUpdateAfterScrollSettles() {
364287
+ const win = this.#visibleHost.ownerDocument?.defaultView;
364288
+ if (!win) {
364289
+ this.#scheduleSelectionUpdate();
364290
+ return;
364291
+ }
364292
+ this.#selectionScrollSettleCleanup?.();
364293
+ const scrollTarget = this.#scrollContainer instanceof Window || this.#scrollContainer instanceof Element ? this.#scrollContainer : win;
364294
+ let timeoutId = null;
364295
+ let finalTimeoutId = null;
364296
+ let scrollRenderRafId = null;
364297
+ let cleanedUp = false;
364298
+ const cleanup = () => {
364299
+ if (cleanedUp)
364300
+ return;
364301
+ cleanedUp = true;
364302
+ scrollTarget.removeEventListener("scroll", onScroll);
364303
+ scrollTarget.removeEventListener("scrollend", finalizeRender);
364304
+ if (timeoutId != null) {
364305
+ win.clearTimeout(timeoutId);
364306
+ timeoutId = null;
364307
+ }
364308
+ if (finalTimeoutId != null) {
364309
+ win.clearTimeout(finalTimeoutId);
364310
+ finalTimeoutId = null;
364311
+ }
364312
+ if (scrollRenderRafId != null) {
364313
+ win.cancelAnimationFrame(scrollRenderRafId);
364314
+ scrollRenderRafId = null;
364315
+ }
364316
+ if (this.#selectionScrollSettleCleanup === cleanup)
364317
+ this.#selectionScrollSettleCleanup = null;
364318
+ };
364319
+ const renderAfterPause = () => {
364320
+ timeoutId = null;
364321
+ this.#scheduleSelectionUpdate({ immediate: true });
364322
+ };
364323
+ const finalizeRender = () => {
364324
+ if (cleanedUp)
364325
+ return;
364326
+ this.#markSelectionNavigationScrollSettled();
364327
+ cleanup();
364328
+ this.#scheduleSelectionUpdate({ immediate: true });
364329
+ };
364330
+ const queueRender = () => {
364331
+ if (timeoutId != null)
364332
+ win.clearTimeout(timeoutId);
364333
+ timeoutId = win.setTimeout(renderAfterPause, SELECTION_SCROLL_SETTLE_RENDER_DELAY_MS);
364334
+ };
364335
+ const queueFinalize = () => {
364336
+ if (finalTimeoutId != null)
364337
+ win.clearTimeout(finalTimeoutId);
364338
+ finalTimeoutId = win.setTimeout(finalizeRender, SELECTION_SCROLL_SETTLE_FINALIZE_DELAY_MS);
364339
+ };
364340
+ const requestScrollRender = () => {
364341
+ if (scrollRenderRafId != null)
364342
+ return;
364343
+ scrollRenderRafId = win.requestAnimationFrame(() => {
364344
+ scrollRenderRafId = null;
364345
+ this.#scheduleSelectionUpdate({ immediate: true });
364346
+ });
364347
+ };
364348
+ const onScroll = () => {
364349
+ requestScrollRender();
364350
+ queueRender();
364351
+ queueFinalize();
364352
+ };
364353
+ scrollTarget.addEventListener("scroll", onScroll, { passive: true });
364354
+ scrollTarget.addEventListener("scrollend", finalizeRender, { passive: true });
364355
+ this.#selectionScrollSettleCleanup = cleanup;
364356
+ queueRender();
364357
+ queueFinalize();
364358
+ }
363772
364359
  #findElementAtPosition(pageEl, pos) {
363773
364360
  const elements = Array.from(pageEl.querySelectorAll("[data-pm-start][data-pm-end]"));
363774
364361
  let bestMatch = null;
@@ -363792,6 +364379,8 @@ function print() { __p += __j.call(arguments, '') }
363792
364379
  return bestMatch;
363793
364380
  }
363794
364381
  async scrollToPositionAsync(pos, options = {}) {
364382
+ if (!shouldContinueNavigation(options))
364383
+ return false;
363795
364384
  if (this.scrollToPosition(pos, options))
363796
364385
  return true;
363797
364386
  const doc$12 = this.getActiveEditor()?.state?.doc;
@@ -363817,11 +364406,15 @@ function print() { __p += __j.call(arguments, '') }
363817
364406
  }
363818
364407
  if (pageIndex == null)
363819
364408
  return false;
364409
+ if (!shouldContinueNavigation(options))
364410
+ return false;
363820
364411
  this.#scrollPageIntoView(pageIndex);
363821
364412
  if (!await this.#waitForPageMount(pageIndex, { timeout: PresentationEditor2.ANCHOR_NAV_TIMEOUT_MS })) {
363822
364413
  console.warn(`[PresentationEditor] scrollToPositionAsync: Page ${pageIndex} failed to mount within timeout`);
363823
364414
  return false;
363824
364415
  }
364416
+ if (!shouldContinueNavigation(options))
364417
+ return false;
363825
364418
  return this.scrollToPosition(pos, {
363826
364419
  ...options,
363827
364420
  ifNeeded: false
@@ -364006,6 +364599,11 @@ function print() { __p += __j.call(arguments, '') }
364006
364599
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#focusScrollRafId);
364007
364600
  this.#focusScrollRafId = null;
364008
364601
  }, "Focus scroll RAF");
364602
+ if (this.#selectionScrollSettleCleanup)
364603
+ safeCleanup(() => {
364604
+ this.#selectionScrollSettleCleanup?.();
364605
+ }, "Selection scroll settle");
364606
+ this.#finishSelectionNavigation();
364009
364607
  if (this.#decorationSyncRafHandle != null)
364010
364608
  safeCleanup(() => {
364011
364609
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#decorationSyncRafHandle);
@@ -364060,6 +364658,7 @@ function print() { __p += __j.call(arguments, '') }
364060
364658
  this.#inputBridge?.notifyTargetChanged();
364061
364659
  this.#inputBridge?.destroy();
364062
364660
  this.#inputBridge = null;
364661
+ this.#teardownCompositionDeferral();
364063
364662
  if (this.#a11ySelectionAnnounceTimeout != null) {
364064
364663
  clearTimeout(this.#a11ySelectionAnnounceTimeout);
364065
364664
  this.#a11ySelectionAnnounceTimeout = null;
@@ -364193,6 +364792,12 @@ function print() { __p += __j.call(arguments, '') }
364193
364792
  #syncCommentHighlights() {
364194
364793
  this.#postPaintPipeline.applyCommentHighlights();
364195
364794
  }
364795
+ setActiveTrackChangeIds(ids) {
364796
+ const didChange = this.#postPaintPipeline.setActiveTrackChangeIds(ids);
364797
+ if (didChange)
364798
+ this.#syncInlineStyleLayers();
364799
+ return didChange;
364800
+ }
364196
364801
  #syncInlineStyleLayers() {
364197
364802
  const state = this.#editor?.view?.state;
364198
364803
  if (!state) {
@@ -364649,7 +365254,10 @@ function print() { __p += __j.call(arguments, '') }
364649
365254
  }
364650
365255
  #setupInputBridge() {
364651
365256
  this.#inputBridge?.destroy();
364652
- this.#inputBridge = new PresentationInputBridge(this.#visibleHost.ownerDocument?.defaultView ?? window, this.#visibleHost, () => this.#getActiveDomTarget(), () => !this.#isViewLocked(), () => this.#editorInputManager?.notifyTargetChanged(), {
365257
+ this.#inputBridge = new PresentationInputBridge(this.#visibleHost.ownerDocument?.defaultView ?? window, this.#visibleHost, () => this.#getActiveDomTarget(), () => !this.#isViewLocked(), () => {
365258
+ this.#refreshCompositionDeferralTarget();
365259
+ this.#editorInputManager?.notifyTargetChanged();
365260
+ }, {
364653
365261
  useWindowFallback: true,
364654
365262
  getTargetEditor: () => this.getActiveEditor()
364655
365263
  });
@@ -365285,6 +365893,70 @@ function print() { __p += __j.call(arguments, '') }
365285
365893
  this.#selectionSync.onLayoutStart();
365286
365894
  this.#scheduleRerender();
365287
365895
  }
365896
+ #beginCompositionDeferral() {
365897
+ this.#isComposing = true;
365898
+ }
365899
+ #endCompositionDeferral() {
365900
+ if (!this.#isComposing)
365901
+ return;
365902
+ this.#isComposing = false;
365903
+ if (this.#pendingDocChange && !this.#renderScheduled && !this.#isRerendering)
365904
+ this.#scheduleRerender();
365905
+ }
365906
+ #resetCompositionDeferral() {
365907
+ this.#isComposing = false;
365908
+ }
365909
+ #handleNonComposingInputForCompositionDeferral = (event) => {
365910
+ if ("isComposing" in event && event.isComposing === false)
365911
+ this.#endCompositionDeferral();
365912
+ };
365913
+ #setupCompositionDeferral() {
365914
+ this.#teardownCompositionDeferral();
365915
+ const add = (target, type, handler2) => {
365916
+ if (!target)
365917
+ return;
365918
+ target.addEventListener(type, handler2);
365919
+ this.#compositionDeferralCleanup.push(() => target.removeEventListener(type, handler2));
365920
+ };
365921
+ const begin = () => this.#beginCompositionDeferral();
365922
+ const end$1 = () => this.#endCompositionDeferral();
365923
+ add(this.#visibleHost, "compositionstart", begin);
365924
+ add(this.#visibleHost, "compositionend", end$1);
365925
+ add(this.#visibleHost, "input", this.#handleNonComposingInputForCompositionDeferral);
365926
+ add(this.#visibleHost, "beforeinput", this.#handleNonComposingInputForCompositionDeferral);
365927
+ }
365928
+ #teardownCompositionDeferral() {
365929
+ this.#compositionTargetCleanup.forEach((cleanup) => cleanup());
365930
+ this.#compositionTargetCleanup = [];
365931
+ this.#compositionTargetDom = null;
365932
+ this.#compositionDeferralCleanup.forEach((cleanup) => cleanup());
365933
+ this.#compositionDeferralCleanup = [];
365934
+ this.#resetCompositionDeferral();
365935
+ }
365936
+ #refreshCompositionDeferralTarget() {
365937
+ const nextTarget = this.#getActiveDomTarget();
365938
+ if (nextTarget === this.#compositionTargetDom)
365939
+ return;
365940
+ this.#compositionTargetCleanup.forEach((cleanup) => cleanup());
365941
+ this.#compositionTargetCleanup = [];
365942
+ this.#compositionTargetDom = nextTarget;
365943
+ if (!nextTarget) {
365944
+ this.#endCompositionDeferral();
365945
+ return;
365946
+ }
365947
+ const begin = () => this.#beginCompositionDeferral();
365948
+ const end$1 = () => this.#endCompositionDeferral();
365949
+ nextTarget.addEventListener("compositionstart", begin);
365950
+ nextTarget.addEventListener("compositionend", end$1);
365951
+ nextTarget.addEventListener("blur", end$1);
365952
+ nextTarget.addEventListener("focusout", end$1);
365953
+ nextTarget.addEventListener("beforeinput", this.#handleNonComposingInputForCompositionDeferral);
365954
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("compositionstart", begin));
365955
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("compositionend", end$1));
365956
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("blur", end$1));
365957
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("focusout", end$1));
365958
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("beforeinput", this.#handleNonComposingInputForCompositionDeferral));
365959
+ }
365288
365960
  #scheduleRerender() {
365289
365961
  if (this.#renderScheduled)
365290
365962
  return;
@@ -365303,6 +365975,8 @@ function print() { __p += __j.call(arguments, '') }
365303
365975
  }
365304
365976
  if (!this.#pendingDocChange)
365305
365977
  return;
365978
+ if (this.#isComposing)
365979
+ return;
365306
365980
  this.#pendingDocChange = false;
365307
365981
  this.#isRerendering = true;
365308
365982
  const activeHfEditor = (this.#headerFooterSession?.session?.mode ?? "body") !== "body" ? this.#headerFooterSession?.activeEditor : null;
@@ -366089,9 +366763,22 @@ function print() { __p += __j.call(arguments, '') }
366089
366763
  }
366090
366764
  if (from$1 === to || isDragDropIndicatorActive) {
366091
366765
  const caretPos = this.#dragDropIndicatorPos ?? from$1;
366766
+ const activeNavigation$1 = this.#activeSelectionNavigation;
366767
+ const isRenderingNavigatedCaret = activeNavigation$1?.targetPos === caretPos;
366768
+ if (isRenderingNavigatedCaret)
366769
+ this.#rebuildDomPositionIndex();
366770
+ else if (activeNavigation$1)
366771
+ this.#finishSelectionNavigation(activeNavigation$1.token);
366772
+ if (isRenderingNavigatedCaret && activeNavigation$1?.scrollSettled && this.#renderNavigatedCaretFromViewportCoords(caretPos)) {
366773
+ this.#finishSelectionNavigation(activeNavigation$1.token);
366774
+ return;
366775
+ }
366092
366776
  const caretLayout = this.#computeCaretLayoutRect(caretPos);
366093
- if (!caretLayout)
366777
+ if (!caretLayout) {
366778
+ if (isRenderingNavigatedCaret)
366779
+ this.#localSelectionLayer.innerHTML = "";
366094
366780
  return;
366781
+ }
366095
366782
  try {
366096
366783
  this.#localSelectionLayer.innerHTML = "";
366097
366784
  renderCaretOverlay({
@@ -366099,6 +366786,9 @@ function print() { __p += __j.call(arguments, '') }
366099
366786
  caretLayout,
366100
366787
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
366101
366788
  });
366789
+ const queuedNavigationRepair = isRenderingNavigatedCaret && activeNavigation$1 ? this.#queueSelectionNavigationCaretRepair(caretPos, activeNavigation$1) : false;
366790
+ if (isRenderingNavigatedCaret && activeNavigation$1?.scrollSettled && !queuedNavigationRepair)
366791
+ this.#finishSelectionNavigation(activeNavigation$1?.token);
366102
366792
  } catch (error3) {
366103
366793
  if (process$1.env.NODE_ENV === "development")
366104
366794
  console.warn("[PresentationEditor] Failed to render caret overlay:", error3);
@@ -366107,8 +366797,16 @@ function print() { __p += __j.call(arguments, '') }
366107
366797
  this.#scrollActiveEndIntoView(caretLayout.pageIndex);
366108
366798
  return;
366109
366799
  }
366800
+ const activeNavigation = this.#activeSelectionNavigation;
366801
+ const selectionContainsNavigationTarget = activeNavigation != null && activeNavigation.targetPos >= from$1 && activeNavigation.targetPos <= to;
366802
+ if (activeNavigation && !selectionContainsNavigationTarget)
366803
+ this.#finishSelectionNavigation(activeNavigation.token);
366804
+ if (selectionContainsNavigationTarget)
366805
+ this.#rebuildDomPositionIndex();
366110
366806
  const domRects = this.#computeSelectionRectsFromDom(from$1, to);
366111
366807
  if (domRects == null) {
366808
+ if (selectionContainsNavigationTarget)
366809
+ this.#localSelectionLayer.innerHTML = "";
366112
366810
  debugLog("warn", "Local selection: DOM rect computation failed", {
366113
366811
  from: from$1,
366114
366812
  to
@@ -366125,7 +366823,7 @@ function print() { __p += __j.call(arguments, '') }
366125
366823
  try {
366126
366824
  this.#localSelectionLayer.innerHTML = "";
366127
366825
  const isFieldAnnotationSelection2 = selection instanceof NodeSelection && selection.node?.type?.name === "fieldAnnotation";
366128
- if (domRects.length > 0 && !isFieldAnnotationSelection2)
366826
+ if (domRects.length > 0 && !isFieldAnnotationSelection2) {
366129
366827
  renderSelectionRects({
366130
366828
  localSelectionLayer: this.#localSelectionLayer,
366131
366829
  rects: domRects,
@@ -366133,6 +366831,9 @@ function print() { __p += __j.call(arguments, '') }
366133
366831
  pageGap: this.#layoutState.layout?.pageGap ?? 0,
366134
366832
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
366135
366833
  });
366834
+ if (selectionContainsNavigationTarget && activeNavigation?.scrollSettled)
366835
+ this.#finishSelectionNavigation(activeNavigation?.token);
366836
+ }
366136
366837
  } catch (error3) {
366137
366838
  if (process$1.env.NODE_ENV === "development")
366138
366839
  console.warn("[PresentationEditor] Failed to render selection rects:", error3);
@@ -367092,9 +367793,12 @@ function print() { __p += __j.call(arguments, '') }
367092
367793
  });
367093
367794
  if (!await this.scrollToPositionAsync(contentPos, {
367094
367795
  behavior: options.behavior ?? "auto",
367095
- block: options.block ?? "center"
367796
+ block: options.block ?? "center",
367797
+ shouldContinue: options.shouldContinue
367096
367798
  }))
367097
367799
  return false;
367800
+ if (!shouldContinueNavigation(options))
367801
+ return false;
367098
367802
  editor.commands?.setTextSelection?.({
367099
367803
  from: contentPos,
367100
367804
  to: contentPos
@@ -367116,9 +367820,10 @@ function print() { __p += __j.call(arguments, '') }
367116
367820
  return false;
367117
367821
  await this.scrollToPositionAsync(editor.state.selection.from, {
367118
367822
  behavior: options.behavior ?? "auto",
367119
- block: options.block ?? "center"
367823
+ block: options.block ?? "center",
367824
+ shouldContinue: options.shouldContinue
367120
367825
  });
367121
- return true;
367826
+ return shouldContinueNavigation(options);
367122
367827
  }
367123
367828
  async#navigateToBookmark(target) {
367124
367829
  const editor = this.#editor;
@@ -367149,64 +367854,113 @@ function print() { __p += __j.call(arguments, '') }
367149
367854
  const behavior = options.behavior ?? "auto";
367150
367855
  const block = options.block ?? "center";
367151
367856
  const navigationIds = this.#resolveTrackedChangeNavigationIds(entityId, storyKey);
367857
+ if (!shouldContinueNavigation(options))
367858
+ return false;
367152
367859
  if (storyKey && storyKey !== "body") {
367153
- for (const id2 of navigationIds)
367860
+ for (const id2 of navigationIds) {
367861
+ if (!shouldContinueNavigation(options))
367862
+ return false;
367154
367863
  if (this.#navigateToActiveStoryTrackedChange(id2, storyKey))
367155
367864
  return true;
367865
+ }
367156
367866
  for (const id2 of navigationIds)
367157
- if (await this.#activateTrackedChangeStorySurface(id2, storyKey, preferredPageIndex)) {
367158
- for (const activeId of navigationIds)
367867
+ if (await this.#activateTrackedChangeStorySurface(id2, storyKey, preferredPageIndex, options)) {
367868
+ if (!shouldContinueNavigation(options))
367869
+ return false;
367870
+ for (const activeId of navigationIds) {
367871
+ if (!shouldContinueNavigation(options))
367872
+ return false;
367159
367873
  if (this.#navigateToActiveStoryTrackedChange(activeId, storyKey))
367160
367874
  return true;
367875
+ }
367161
367876
  }
367162
- for (const id2 of navigationIds)
367877
+ for (const id2 of navigationIds) {
367878
+ if (!shouldContinueNavigation(options))
367879
+ return false;
367163
367880
  if (await this.#scrollToRenderedTrackedChange(id2, storyKey, preferredPageIndex, {
367164
367881
  behavior,
367165
- block
367882
+ block,
367883
+ shouldContinue: options.shouldContinue
367166
367884
  }))
367167
367885
  return true;
367886
+ }
367168
367887
  return false;
367169
367888
  }
367889
+ this.exitActiveStorySurface();
367170
367890
  const setCursorById = editor.commands?.setCursorById;
367171
- if (typeof setCursorById === "function") {
367172
- for (const id2 of navigationIds)
367891
+ for (const id2 of navigationIds) {
367892
+ if (!shouldContinueNavigation(options))
367893
+ return false;
367894
+ const selection = resolveTrackedChangeNavigationSelection(editor, id2);
367895
+ if (!selection)
367896
+ continue;
367897
+ const setTextSelection$1 = editor.commands?.setTextSelection;
367898
+ if (!await this.scrollToPositionAsync(selection.from, {
367899
+ behavior,
367900
+ block,
367901
+ shouldContinue: options.shouldContinue
367902
+ }) || !shouldContinueNavigation(options))
367903
+ return false;
367904
+ if (typeof setTextSelection$1 !== "function" || setTextSelection$1(selection) !== true)
367905
+ continue;
367906
+ editor.view?.focus?.();
367907
+ this.#scheduleNavigatedSelectionRender(selection.from);
367908
+ return true;
367909
+ }
367910
+ if (typeof setCursorById === "function")
367911
+ for (const id2 of navigationIds) {
367912
+ if (!shouldContinueNavigation(options))
367913
+ return false;
367173
367914
  if (setCursorById(id2, { preferredActiveThreadId: id2 })) {
367174
- await this.scrollToPositionAsync(editor.state.selection.from, {
367915
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
367175
367916
  behavior,
367176
- block
367177
- });
367917
+ block,
367918
+ shouldContinue: options.shouldContinue
367919
+ }) || !shouldContinueNavigation(options))
367920
+ return false;
367921
+ editor.view?.focus?.();
367922
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
367178
367923
  return true;
367179
367924
  }
367180
- }
367925
+ }
367181
367926
  const resolved = navigationIds.map((id2) => resolveTrackedChange(editor, id2)).find(Boolean);
367182
367927
  if (!resolved) {
367183
367928
  for (const id2 of navigationIds)
367184
367929
  if (await this.#scrollToRenderedTrackedChange(id2, undefined, preferredPageIndex, {
367185
367930
  behavior,
367186
- block
367931
+ block,
367932
+ shouldContinue: options.shouldContinue
367187
367933
  }))
367188
367934
  return true;
367189
367935
  return false;
367190
367936
  }
367191
367937
  if (typeof setCursorById === "function" && resolved.rawId !== entityId) {
367938
+ if (!shouldContinueNavigation(options))
367939
+ return false;
367192
367940
  if (setCursorById(resolved.rawId, { preferredActiveThreadId: resolved.rawId })) {
367193
- await this.scrollToPositionAsync(editor.state.selection.from, {
367941
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
367194
367942
  behavior,
367195
- block
367196
- });
367943
+ block,
367944
+ shouldContinue: options.shouldContinue
367945
+ }) || !shouldContinueNavigation(options))
367946
+ return false;
367947
+ editor.view?.focus?.();
367948
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
367197
367949
  return true;
367198
367950
  }
367199
367951
  }
367200
367952
  if (!await this.scrollToPositionAsync(resolved.from, {
367201
367953
  behavior,
367202
- block
367203
- }))
367954
+ block,
367955
+ shouldContinue: options.shouldContinue
367956
+ }) || !shouldContinueNavigation(options))
367204
367957
  return false;
367205
367958
  editor.commands?.setTextSelection?.({
367206
367959
  from: resolved.from,
367207
367960
  to: resolved.from
367208
367961
  });
367209
367962
  editor.view?.focus?.();
367963
+ this.#scheduleNavigatedSelectionRender(resolved.from);
367210
367964
  return true;
367211
367965
  }
367212
367966
  #resolveTrackedChangeNavigationIds(entityId, storyKey) {
@@ -367242,7 +367996,7 @@ function print() { __p += __j.call(arguments, '') }
367242
367996
  } catch {}
367243
367997
  return ids;
367244
367998
  }
367245
- async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex) {
367999
+ async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex, options = {}) {
367246
368000
  let locator = null;
367247
368001
  try {
367248
368002
  locator = parseStoryKey(storyKey);
@@ -367251,15 +368005,23 @@ function print() { __p += __j.call(arguments, '') }
367251
368005
  }
367252
368006
  if (!locator || locator.storyType === "body")
367253
368007
  return false;
368008
+ if (!shouldContinueNavigation(options))
368009
+ return false;
367254
368010
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
367255
368011
  if (!candidate)
367256
368012
  return false;
368013
+ if (!shouldContinueNavigation(options))
368014
+ return false;
367257
368015
  const rect = candidate.getBoundingClientRect();
367258
368016
  const clientX = rect.left + Math.max(rect.width / 2, 1);
367259
368017
  const clientY = rect.top + Math.max(rect.height / 2, 1);
367260
368018
  const pageIndex = this.#resolveRenderedPageIndexForElement(candidate);
368019
+ if (!shouldContinueNavigation(options))
368020
+ return false;
367261
368021
  if (locator.storyType === "footnote" || locator.storyType === "endnote") {
367262
368022
  try {
368023
+ if (!shouldContinueNavigation(options))
368024
+ return false;
367263
368025
  if (!this.#activateRenderedNoteSession({
367264
368026
  storyType: locator.storyType,
367265
368027
  noteId: locator.noteId
@@ -367272,7 +368034,7 @@ function print() { __p += __j.call(arguments, '') }
367272
368034
  } catch {
367273
368035
  return false;
367274
368036
  }
367275
- return this.#waitForTrackedChangeStorySurface(storyKey);
368037
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
367276
368038
  }
367277
368039
  if (locator.storyType !== "headerFooterPart")
367278
368040
  return false;
@@ -367281,21 +368043,27 @@ function print() { __p += __j.call(arguments, '') }
367281
368043
  const region = this.#hitTestHeaderFooterRegion(clientX, clientY, pageIndex, pageLocalY);
367282
368044
  if (!region)
367283
368045
  return false;
368046
+ if (!shouldContinueNavigation(options))
368047
+ return false;
367284
368048
  this.#activateHeaderFooterRegion(region, {
367285
368049
  clientX,
367286
368050
  clientY,
367287
368051
  pageIndex,
367288
368052
  source: "programmatic"
367289
368053
  });
367290
- return this.#waitForTrackedChangeStorySurface(storyKey);
368054
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
367291
368055
  }
367292
- async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500) {
368056
+ async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500, options = {}) {
367293
368057
  const deadline = Date.now() + timeoutMs;
367294
368058
  while (Date.now() < deadline) {
368059
+ if (!shouldContinueNavigation(options))
368060
+ return false;
367295
368061
  if (this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey)
367296
368062
  return true;
367297
368063
  await new Promise((resolve3) => setTimeout(resolve3, 16));
367298
368064
  }
368065
+ if (!shouldContinueNavigation(options))
368066
+ return false;
367299
368067
  return this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey;
367300
368068
  }
367301
368069
  async#activateBookmarkStorySurface(storyKey) {
@@ -367433,6 +368201,12 @@ function print() { __p += __j.call(arguments, '') }
367433
368201
  return false;
367434
368202
  const sessionEditor = activeSurface.editor;
367435
368203
  const setCursorById = sessionEditor.commands?.setCursorById;
368204
+ const navigationSelection = resolveTrackedChangeNavigationSelection(sessionEditor, entityId);
368205
+ const setTextSelection$1 = sessionEditor.commands?.setTextSelection;
368206
+ if (navigationSelection && typeof setTextSelection$1 === "function" && setTextSelection$1(navigationSelection) === true) {
368207
+ this.#focusAndRevealActiveStorySelection(sessionEditor);
368208
+ return true;
368209
+ }
367436
368210
  if (typeof setCursorById === "function" && setCursorById(entityId, { preferredActiveThreadId: entityId })) {
367437
368211
  this.#focusAndRevealActiveStorySelection(sessionEditor);
367438
368212
  return true;
@@ -367470,6 +368244,8 @@ function print() { __p += __j.call(arguments, '') }
367470
368244
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
367471
368245
  if (!candidate)
367472
368246
  return false;
368247
+ if (!shouldContinueNavigation(options))
368248
+ return false;
367473
368249
  try {
367474
368250
  candidate.scrollIntoView({
367475
368251
  behavior: options.behavior ?? "auto",
@@ -368411,11 +369187,11 @@ function print() { __p += __j.call(arguments, '') }
368411
369187
  ]);
368412
369188
  });
368413
369189
 
368414
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-NCPalg_h.es.js
369190
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BjToI9WN.es.js
368415
369191
  var DEFAULT_TEXT_ALIGN_OPTIONS, DEFAULT_LINE_HEIGHT_OPTIONS, DEFAULT_ZOOM_OPTIONS, DEFAULT_DOCUMENT_MODE_OPTIONS, DEFAULT_FONT_SIZE_OPTIONS, headlessToolbarConstants, MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS, FONT_SIZE_OPTIONS;
368416
- var init_create_super_doc_ui_NCPalg_h_es = __esm(() => {
368417
- init_SuperConverter_Du0apG1R_es();
368418
- init_create_headless_toolbar_BNcguDpP_es();
369192
+ var init_create_super_doc_ui_BjToI9WN_es = __esm(() => {
369193
+ init_SuperConverter_DQ2wMaLK_es();
369194
+ init_create_headless_toolbar_BhSfQYaO_es();
368419
369195
  DEFAULT_TEXT_ALIGN_OPTIONS = [
368420
369196
  {
368421
369197
  label: "Left",
@@ -368693,6 +369469,9 @@ var init_create_super_doc_ui_NCPalg_h_es = __esm(() => {
368693
369469
  }));
368694
369470
  });
368695
369471
 
369472
+ // ../../packages/superdoc/dist/chunks/ui-CGB3qmy3.es.js
369473
+ var init_ui_CGB3qmy3_es = () => {};
369474
+
368696
369475
  // ../../packages/superdoc/dist/chunks/zipper-BxRAi0-5.es.js
368697
369476
  var import_jszip_min3;
368698
369477
  var init_zipper_BxRAi0_5_es = __esm(() => {
@@ -368703,16 +369482,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
368703
369482
 
368704
369483
  // ../../packages/superdoc/dist/super-editor.es.js
368705
369484
  var init_super_editor_es = __esm(() => {
368706
- init_src_bGJhSgx__es();
368707
- init_SuperConverter_Du0apG1R_es();
369485
+ init_src_CR8eXLKh_es();
369486
+ init_SuperConverter_DQ2wMaLK_es();
368708
369487
  init_jszip_C49i9kUs_es();
368709
369488
  init_xml_js_CqGKpaft_es();
368710
- init_create_headless_toolbar_BNcguDpP_es();
369489
+ init_create_headless_toolbar_BhSfQYaO_es();
368711
369490
  init_constants_D9qj59G2_es();
368712
369491
  init_unified_BDuVPlMu_es();
368713
369492
  init_DocxZipper_BzS208BW_es();
368714
- init_ui_BMYSpkne_es();
368715
- init_create_super_doc_ui_NCPalg_h_es();
369493
+ init_create_super_doc_ui_BjToI9WN_es();
369494
+ init_ui_CGB3qmy3_es();
368716
369495
  init_eventemitter3_UwU_CLPU_es();
368717
369496
  init_errors_C_DoKMoN_es();
368718
369497
  init_zipper_BxRAi0_5_es();