@superdoc-dev/mcp 0.12.0-next.41 → 0.12.0-next.43

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 +1061 -288
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -50479,7 +50479,7 @@ var init_remark_gfm_BUJjZJLy_es = __esm(() => {
50479
50479
  emptyOptions2 = {};
50480
50480
  });
50481
50481
 
50482
- // ../../packages/superdoc/dist/chunks/SuperConverter-Du0apG1R.es.js
50482
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DQ2wMaLK.es.js
50483
50483
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
50484
50484
  const fieldValue = extension$1.config[field];
50485
50485
  if (typeof fieldValue === "function")
@@ -95469,6 +95469,91 @@ function getTrackedMarkText(editor, item) {
95469
95469
  return nodeText;
95470
95470
  return editor.state.doc.textBetween(item.from, item.to, " ", "");
95471
95471
  }
95472
+ function rawMarkMatchesChange(mark, change) {
95473
+ return trackedMarkMatchesChange(mark.mark, change);
95474
+ }
95475
+ function trackedMarkMatchesChange(mark, change) {
95476
+ const attrs = mark.attrs ?? {};
95477
+ const rawId = toNonEmptyString(attrs.id);
95478
+ if (!rawId)
95479
+ return false;
95480
+ const markType = mark.type.name;
95481
+ const groupKey = getTrackedChangeGroupKey(attrs, markType, rawId);
95482
+ return groupKey === change.rawId || groupKey === change.id || rawId === change.commandRawId || rawId === change.id;
95483
+ }
95484
+ function findMarkedTextNodeNavigationSelection(editor, change) {
95485
+ let multiCharacterSelection = null;
95486
+ let singleCharacterSelection = null;
95487
+ try {
95488
+ editor.state.doc.nodesBetween(change.from, change.to, (node2, pos) => {
95489
+ if (multiCharacterSelection)
95490
+ return false;
95491
+ if (!node2.isText)
95492
+ return true;
95493
+ if (!(Array.isArray(node2.marks) ? node2.marks : []).some((mark) => trackedMarkMatchesChange(mark, change)))
95494
+ return false;
95495
+ const textLength = typeof node2.text === "string" ? node2.text.length : node2.nodeSize;
95496
+ if (textLength > 1) {
95497
+ const caret = pos + 1;
95498
+ multiCharacterSelection = {
95499
+ from: caret,
95500
+ to: caret
95501
+ };
95502
+ return false;
95503
+ }
95504
+ if (!singleCharacterSelection && textLength > 0)
95505
+ singleCharacterSelection = {
95506
+ from: pos,
95507
+ to: pos + textLength
95508
+ };
95509
+ return false;
95510
+ });
95511
+ } catch {
95512
+ return null;
95513
+ }
95514
+ return multiCharacterSelection ?? singleCharacterSelection;
95515
+ }
95516
+ function resolveTrackedChangeNavigationSelection(editor, id) {
95517
+ const change = resolveTrackedChange(editor, id);
95518
+ if (!change || change.structural)
95519
+ return null;
95520
+ const markedTextSelection = findMarkedTextNodeNavigationSelection(editor, change);
95521
+ if (markedTextSelection)
95522
+ return markedTextSelection;
95523
+ 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) => {
95524
+ if (a.from !== b.from)
95525
+ return a.from - b.from;
95526
+ return a.to - b.to;
95527
+ });
95528
+ const multiCharacterMark = matchingMarks.find((mark) => mark.to - mark.from > 1);
95529
+ if (multiCharacterMark) {
95530
+ const pos = multiCharacterMark.from + 1;
95531
+ return {
95532
+ from: pos,
95533
+ to: pos
95534
+ };
95535
+ }
95536
+ const singleCharacterMark = matchingMarks[0];
95537
+ if (singleCharacterMark)
95538
+ return {
95539
+ from: singleCharacterMark.from,
95540
+ to: singleCharacterMark.to
95541
+ };
95542
+ if (change.to > change.from) {
95543
+ if (change.to - change.from > 1) {
95544
+ const pos = change.from + 1;
95545
+ return {
95546
+ from: pos,
95547
+ to: pos
95548
+ };
95549
+ }
95550
+ return {
95551
+ from: change.from,
95552
+ to: change.to
95553
+ };
95554
+ }
95555
+ return null;
95556
+ }
95472
95557
  function groupTrackedChanges(editor) {
95473
95558
  const currentDoc = editor.state.doc;
95474
95559
  const cached2 = groupedCache.get(editor);
@@ -112126,15 +112211,12 @@ var isRegExp = (value) => {
112126
112211
  const originalElementsSource = originalXml.elements;
112127
112212
  const originalElements = originalElementsSource ? carbonCopy(originalElementsSource) : [];
112128
112213
  const childElements = Array.isArray(node2.elements) ? node2.elements : [];
112129
- let childContent = [];
112130
- if (childElements.length && params.nodeListHandler?.handler) {
112131
- const childParams = {
112214
+ if (childElements.length && params.nodeListHandler?.handler)
112215
+ params.nodeListHandler.handler({
112132
112216
  ...params,
112133
112217
  nodes: childElements,
112134
112218
  path: [...params.path || [], node2]
112135
- };
112136
- childContent = params.nodeListHandler.handler(childParams) || [];
112137
- }
112219
+ });
112138
112220
  if (originalElements?.length)
112139
112221
  originalXml.elements = originalElements;
112140
112222
  return {
@@ -112145,7 +112227,7 @@ var isRegExp = (value) => {
112145
112227
  originalXml
112146
112228
  },
112147
112229
  marks: [],
112148
- content: childContent
112230
+ content: undefined
112149
112231
  }],
112150
112232
  consumed: 1
112151
112233
  };
@@ -118556,7 +118638,7 @@ Docs: https://docs.superdoc.dev/getting-started/fonts`);
118556
118638
  state.kern = kernNode.attributes["w:val"];
118557
118639
  }
118558
118640
  }, SuperConverter;
118559
- var init_SuperConverter_Du0apG1R_es = __esm(() => {
118641
+ var init_SuperConverter_DQ2wMaLK_es = __esm(() => {
118560
118642
  init_rolldown_runtime_Bg48TavK_es();
118561
118643
  init_jszip_C49i9kUs_es();
118562
118644
  init_xml_js_CqGKpaft_es();
@@ -147565,7 +147647,7 @@ var init_SuperConverter_Du0apG1R_es = __esm(() => {
147565
147647
  };
147566
147648
  });
147567
147649
 
147568
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BNcguDpP.es.js
147650
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BhSfQYaO.es.js
147569
147651
  function parseSizeUnit(val = "0") {
147570
147652
  const length = val.toString() || "0";
147571
147653
  const value = Number.parseFloat(length);
@@ -158308,9 +158390,9 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, MARK_KEYS, STEP_OP_CATALOG_UNFROZEN, PU
158308
158390
  }
158309
158391
  };
158310
158392
  };
158311
- var init_create_headless_toolbar_BNcguDpP_es = __esm(() => {
158393
+ var init_create_headless_toolbar_BhSfQYaO_es = __esm(() => {
158312
158394
  init_rolldown_runtime_Bg48TavK_es();
158313
- init_SuperConverter_Du0apG1R_es();
158395
+ init_SuperConverter_DQ2wMaLK_es();
158314
158396
  init_jszip_C49i9kUs_es();
158315
158397
  init_uuid_B2wVPhPi_es();
158316
158398
  init_constants_D9qj59G2_es();
@@ -161888,157 +161970,6 @@ var __plugin_vue_export_helper_default = (sfc, props) => {
161888
161970
  };
161889
161971
  var init__plugin_vue_export_helper_HmhZBO0u_es = () => {};
161890
161972
 
161891
- // ../../packages/superdoc/dist/chunks/ui-BMYSpkne.es.js
161892
- function buildAnnotationSelector() {
161893
- return `.${DOM_CLASS_NAMES.ANNOTATION}[${DATA_ATTRS.PM_START}]`;
161894
- }
161895
- function findRenderedCommentElements(host, commentId, storyKey) {
161896
- if (!host || !commentId)
161897
- return [];
161898
- return Array.from(host.querySelectorAll("[data-comment-ids]")).filter((el) => {
161899
- const raw = el.dataset.commentIds;
161900
- if (!raw)
161901
- return false;
161902
- if (!raw.split(",").some((token) => token.trim() === commentId))
161903
- return false;
161904
- if (!storyKey)
161905
- return true;
161906
- const elStoryKey = el.dataset.storyKey;
161907
- if (elStoryKey)
161908
- return elStoryKey === storyKey;
161909
- return storyKey === BODY_STORY_KEY;
161910
- });
161911
- }
161912
- function findRenderedTrackedChangeElementsStrict(host, entityId, escapeAttrValue, storyKey) {
161913
- if (!host || !entityId)
161914
- return [];
161915
- const baseSelector = `[data-track-change-id="${escapeAttrValue(entityId)}"]`;
161916
- if (!storyKey)
161917
- return Array.from(host.querySelectorAll(baseSelector));
161918
- const storySelector = `${baseSelector}[data-story-key="${escapeAttrValue(storyKey)}"]`;
161919
- return Array.from(host.querySelectorAll(storySelector));
161920
- }
161921
- function findRenderedContentControlElements(host, entityId, escapeAttrValue, _storyKey) {
161922
- if (!host || !entityId)
161923
- return [];
161924
- const id = escapeAttrValue(entityId);
161925
- const selector = `.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}[data-sdt-id="${id}"][data-sdt-type="structuredContent"],.${DOM_CLASS_NAMES.BLOCK_SDT}[data-sdt-id="${id}"][data-sdt-type="structuredContent"]`;
161926
- return Array.from(host.querySelectorAll(selector));
161927
- }
161928
- function elementsToRangeRects(elements) {
161929
- const result = [];
161930
- for (const element of elements) {
161931
- const rect = element.getBoundingClientRect();
161932
- if (![
161933
- rect.top,
161934
- rect.left,
161935
- rect.right,
161936
- rect.bottom,
161937
- rect.width,
161938
- rect.height
161939
- ].every(Number.isFinite))
161940
- continue;
161941
- const pageEl = element.closest(".superdoc-page");
161942
- const pageIndexAttr = Number(pageEl?.dataset?.pageIndex ?? 0);
161943
- result.push({
161944
- pageIndex: Number.isFinite(pageIndexAttr) ? pageIndexAttr : 0,
161945
- left: rect.left,
161946
- top: rect.top,
161947
- right: rect.right,
161948
- bottom: rect.bottom,
161949
- width: rect.width,
161950
- height: rect.height
161951
- });
161952
- }
161953
- return result;
161954
- }
161955
- 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) => {
161956
- if (!raw)
161957
- return { kind: "unknown" };
161958
- if (raw === "body")
161959
- return { kind: "body" };
161960
- const idx = raw.indexOf(":");
161961
- const kind = idx === -1 ? raw : raw.slice(0, idx);
161962
- const id = idx === -1 ? undefined : raw.slice(idx + 1);
161963
- switch (kind) {
161964
- case "body":
161965
- case "header":
161966
- case "footer":
161967
- case "footnote":
161968
- case "endnote":
161969
- return id ? {
161970
- kind,
161971
- id
161972
- } : { kind };
161973
- default:
161974
- return { kind: "unknown" };
161975
- }
161976
- }, DRAGGABLE_SELECTOR;
161977
- var init_ui_BMYSpkne_es = __esm(() => {
161978
- init_SuperConverter_Du0apG1R_es();
161979
- DOM_CLASS_NAMES = {
161980
- PAGE: "superdoc-page",
161981
- FRAGMENT: "superdoc-fragment",
161982
- LINE: "superdoc-line",
161983
- INLINE_SDT_WRAPPER: "superdoc-structured-content-inline",
161984
- INLINE_SDT_LABEL: "superdoc-structured-content-inline__label",
161985
- BLOCK_SDT: "superdoc-structured-content-block",
161986
- BLOCK_SDT_LABEL: "superdoc-structured-content__label",
161987
- TABLE_FRAGMENT: "superdoc-table-fragment",
161988
- DOCUMENT_SECTION: "superdoc-document-section",
161989
- SDT_GROUP_HOVER: "sdt-group-hover",
161990
- TOC_ENTRY: "superdoc-toc-entry",
161991
- TOC_GROUP_HOVER: "toc-group-hover",
161992
- IMAGE_FRAGMENT: "superdoc-image-fragment",
161993
- INLINE_IMAGE: "superdoc-inline-image",
161994
- LIST_MARKER: "superdoc-list-marker",
161995
- INLINE_IMAGE_CLIP_WRAPPER: "superdoc-inline-image-clip-wrapper",
161996
- ANNOTATION: "annotation",
161997
- ANNOTATION_CONTENT: "annotation-content",
161998
- ANNOTATION_CARET_ANCHOR: "annotation-caret-anchor"
161999
- };
162000
- STRUCTURED_CONTENT_CHROME_LABEL_CLASS_NAMES = [DOM_CLASS_NAMES.INLINE_SDT_LABEL, DOM_CLASS_NAMES.BLOCK_SDT_LABEL];
162001
- DATA_ATTRS = {
162002
- PM_START: "data-pm-start",
162003
- PM_END: "data-pm-end",
162004
- LAYOUT_EPOCH: "data-layout-epoch",
162005
- TABLE_BOUNDARIES: "data-table-boundaries",
162006
- SDT_ID: "data-sdt-id",
162007
- SDT_TYPE: "data-sdt-type",
162008
- FIELD_ID: "data-field-id",
162009
- FIELD_TYPE: "data-field-type",
162010
- DRAGGABLE: "data-draggable",
162011
- DISPLAY_LABEL: "data-display-label",
162012
- VARIANT: "data-variant",
162013
- TYPE: "data-type",
162014
- LAYOUT_BOUNDARY_SCHEMA: "data-layout-boundary-schema",
162015
- LAYOUT_FRAGMENT_ID: "data-layout-fragment-id",
162016
- LAYOUT_STORY: "data-layout-story",
162017
- LAYOUT_BLOCK_REF: "data-layout-block-ref"
162018
- };
162019
- DATASET_KEYS = {
162020
- PM_START: "pmStart",
162021
- PM_END: "pmEnd",
162022
- LAYOUT_EPOCH: "layoutEpoch",
162023
- TABLE_BOUNDARIES: "tableBoundaries",
162024
- SDT_ID: "sdtId",
162025
- SDT_TYPE: "sdtType",
162026
- FIELD_ID: "fieldId",
162027
- FIELD_TYPE: "fieldType",
162028
- DRAGGABLE: "draggable",
162029
- DISPLAY_LABEL: "displayLabel",
162030
- VARIANT: "variant",
162031
- TYPE: "type",
162032
- LAYOUT_BOUNDARY_SCHEMA: "layoutBoundarySchema",
162033
- LAYOUT_FRAGMENT_ID: "layoutFragmentId",
162034
- LAYOUT_STORY: "layoutStory",
162035
- LAYOUT_BLOCK_REF: "layoutBlockRef"
162036
- };
162037
- `${DOM_CLASS_NAMES.BLOCK_SDT}${DATA_ATTRS.SDT_ID}`;
162038
- DRAGGABLE_SELECTOR = `[${DATA_ATTRS.DRAGGABLE}="true"]`;
162039
- DATA_ATTRS.LAYOUT_EPOCH;
162040
- });
162041
-
162042
161973
  // ../../packages/superdoc/dist/chunks/eventemitter3-UwU_CLPU.es.js
162043
161974
  var import_eventemitter3;
162044
161975
  var init_eventemitter3_UwU_CLPU_es = __esm(() => {
@@ -214076,7 +214007,7 @@ var init_remark_gfm_DCND_V_3_es = __esm(() => {
214076
214007
  init_remark_gfm_BUJjZJLy_es();
214077
214008
  });
214078
214009
 
214079
- // ../../packages/superdoc/dist/chunks/src-bGJhSgx_.es.js
214010
+ // ../../packages/superdoc/dist/chunks/src-CR8eXLKh.es.js
214080
214011
  function deleteProps(obj, propOrProps) {
214081
214012
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
214082
214013
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -223526,6 +223457,9 @@ function replaceCommand(wrap4, moveForward) {
223526
223457
  return true;
223527
223458
  };
223528
223459
  }
223460
+ function buildAnnotationSelector() {
223461
+ return `.${DOM_CLASS_NAMES.ANNOTATION}[${DATA_ATTRS.PM_START}]`;
223462
+ }
223529
223463
  function isPresenting(editor) {
223530
223464
  const presentationCtx = editor?.presentationEditor;
223531
223465
  if (!presentationCtx)
@@ -238556,19 +238490,16 @@ function readBlockId(node2) {
238556
238490
  function mapRawChangeIdsToCanonical(editor, rawIds) {
238557
238491
  if (rawIds.length === 0)
238558
238492
  return rawIds;
238559
- let grouped;
238493
+ let canonicalIdByAlias;
238560
238494
  try {
238561
- grouped = groupTrackedChanges(editor);
238495
+ canonicalIdByAlias = buildTrackedChangeCanonicalIdMap(editor);
238562
238496
  } catch {
238563
238497
  return [];
238564
238498
  }
238565
- const rawToCanonical = /* @__PURE__ */ new Map;
238566
- for (const change of grouped)
238567
- rawToCanonical.set(change.rawId, change.id);
238568
238499
  const seen = /* @__PURE__ */ new Set;
238569
238500
  const out = [];
238570
238501
  for (const raw of rawIds) {
238571
- const canonical = rawToCanonical.get(raw);
238502
+ const canonical = canonicalIdByAlias.get(raw);
238572
238503
  if (!canonical)
238573
238504
  continue;
238574
238505
  if (seen.has(canonical))
@@ -261815,7 +261746,7 @@ function getMeasurementContext() {
261815
261746
  function getRunFontString(run2) {
261816
261747
  if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" || "src" in run2)
261817
261748
  return "normal normal 16px Arial";
261818
- return `${run2.italic ? "italic" : "normal"} ${run2.bold ? "bold" : "normal"} ${run2.fontSize ?? 16}px ${DEFAULT_FONT_MEASURE_CONTEXT.resolvePhysical(run2.fontFamily ?? "Arial", faceOf$1(run2))}`;
261749
+ return `${run2.italic ? "italic" : "normal"} ${run2.bold ? "bold" : "normal"} ${run2.fontSize ?? 16}px ${run2.fontFamily ?? "Arial"}`;
261819
261750
  }
261820
261751
  function measureCharacterX(block, line, charOffset, availableWidthOverride, alignmentOverride) {
261821
261752
  const ctx$1 = getMeasurementContext();
@@ -261955,43 +261886,97 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
261955
261886
  return lastPm;
261956
261887
  }
261957
261888
  function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, alignmentOverride) {
261958
- const maxOffset = lineCharLength(block, line);
261959
- const xAtOffset = (offset$1) => measureCharacterX(block, line, offset$1, availableWidthOverride, alignmentOverride);
261960
- const charOffset = nearestOffsetToX(x, maxOffset, xAtOffset);
261961
- return {
261962
- charOffset,
261963
- pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
261964
- };
261965
- }
261966
- function lineCharLength(block, line) {
261967
- let length$1 = 0;
261968
- for (const run2 of sliceRunsForLine(block, line)) {
261889
+ const ctx$1 = getMeasurementContext();
261890
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
261891
+ const justify = getJustifyAdjustment({
261892
+ block,
261893
+ line,
261894
+ availableWidthOverride: availableWidth,
261895
+ alignmentOverride
261896
+ });
261897
+ const alignment$1 = alignmentOverride ?? (block.kind === "paragraph" ? block.attrs?.alignment : undefined);
261898
+ const renderedLineWidth = alignment$1 === "justify" ? line.width + Math.max(0, availableWidth - line.width) : line.width;
261899
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== undefined);
261900
+ const alignmentOffset = !hasExplicitPositioning && alignment$1 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment$1 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
261901
+ if (!ctx$1) {
261902
+ const runs$1 = sliceRunsForLine(block, line);
261903
+ const charsInLine = Math.max(1, runs$1.reduce((sum, run2) => {
261904
+ if (isTabRun$1(run2))
261905
+ return sum + TAB_CHAR_LENGTH;
261906
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math")
261907
+ return sum;
261908
+ return sum + (run2.text ?? "").length;
261909
+ }, 0));
261910
+ const ratio = Math.max(0, Math.min(1, (x - alignmentOffset) / renderedLineWidth));
261911
+ const charOffset = Math.round(ratio * charsInLine);
261912
+ return {
261913
+ charOffset,
261914
+ pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
261915
+ };
261916
+ }
261917
+ const runs2 = sliceRunsForLine(block, line);
261918
+ const safeX = Math.max(0, Math.min(renderedLineWidth, x - alignmentOffset));
261919
+ let currentX = 0;
261920
+ let currentCharOffset = 0;
261921
+ let spaceTally = 0;
261922
+ for (const run2 of runs2) {
261969
261923
  if (isTabRun$1(run2)) {
261970
- length$1 += TAB_CHAR_LENGTH;
261924
+ const tabWidth = run2.width ?? 0;
261925
+ const startX = currentX;
261926
+ const endX = currentX + tabWidth;
261927
+ if (safeX <= endX) {
261928
+ const offsetInRun = safeX < startX + tabWidth / 2 ? 0 : TAB_CHAR_LENGTH;
261929
+ const charOffset = currentCharOffset + offsetInRun;
261930
+ return {
261931
+ charOffset,
261932
+ pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
261933
+ };
261934
+ }
261935
+ currentX = endX;
261936
+ currentCharOffset += TAB_CHAR_LENGTH;
261971
261937
  continue;
261972
261938
  }
261973
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math")
261939
+ const text5 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" ? "" : run2.text ?? "";
261940
+ const runLength = text5.length;
261941
+ 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);
261942
+ if (runLength === 0)
261974
261943
  continue;
261975
- length$1 += (run2.text ?? "").length;
261976
- }
261977
- return length$1;
261978
- }
261979
- function nearestOffsetToX(x, maxOffset, xAtOffset) {
261980
- if (maxOffset <= 0 || x <= xAtOffset(0))
261981
- return 0;
261982
- if (x >= xAtOffset(maxOffset))
261983
- return maxOffset;
261984
- let lo = 0;
261985
- let hi = maxOffset;
261986
- while (lo < hi) {
261987
- const mid = lo + hi + 1 >> 1;
261988
- if (xAtOffset(mid) <= x)
261989
- lo = mid;
261990
- else
261991
- hi = mid - 1;
261944
+ ctx$1.font = getRunFontString(run2);
261945
+ for (let i3 = 0;i3 <= runLength; i3++) {
261946
+ const textUpToChar = displayText.slice(0, i3);
261947
+ const measured$1 = ctx$1.measureText(textUpToChar);
261948
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text5.slice(0, i3)) : 0;
261949
+ const charX = currentX + measured$1.width + computeLetterSpacingWidth(run2, i3, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
261950
+ if (charX >= safeX) {
261951
+ if (i3 === 0) {
261952
+ const pmPosition$1 = charOffsetToPm(block, line, currentCharOffset, pmStart);
261953
+ return {
261954
+ charOffset: currentCharOffset,
261955
+ pmPosition: pmPosition$1
261956
+ };
261957
+ }
261958
+ const prevText = displayText.slice(0, i3 - 1);
261959
+ const prevMeasured = ctx$1.measureText(prevText);
261960
+ const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i3 - 1, runLength);
261961
+ const charOffset = Math.abs(safeX - prevX) < Math.abs(safeX - charX) ? currentCharOffset + i3 - 1 : currentCharOffset + i3;
261962
+ return {
261963
+ charOffset,
261964
+ pmPosition: charOffsetToPm(block, line, charOffset, pmStart)
261965
+ };
261966
+ }
261967
+ }
261968
+ const measured = ctx$1.measureText(displayText);
261969
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
261970
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text5) : 0;
261971
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
261972
+ spaceTally += spacesInRun;
261973
+ currentCharOffset += runLength;
261992
261974
  }
261993
- const upper = Math.min(lo + 1, maxOffset);
261994
- return x - xAtOffset(lo) < xAtOffset(upper) - x ? lo : upper;
261975
+ const pmPosition = charOffsetToPm(block, line, currentCharOffset, pmStart);
261976
+ return {
261977
+ charOffset: currentCharOffset,
261978
+ pmPosition
261979
+ };
261995
261980
  }
261996
261981
  function getWordLayoutConfig(block) {
261997
261982
  if (!block || block.kind !== "paragraph")
@@ -267621,7 +267606,16 @@ function safeCleanup(fn2, context) {
267621
267606
  console.warn(`[PresentationEditor] ${context} cleanup failed:`, error48);
267622
267607
  }
267623
267608
  }
267609
+ function ensureHiddenHostStylesheet(doc$12) {
267610
+ if (doc$12.getElementById(HIDDEN_HOST_STYLE_ID))
267611
+ return;
267612
+ const style2 = doc$12.createElement("style");
267613
+ style2.id = HIDDEN_HOST_STYLE_ID;
267614
+ style2.textContent = ".presentation-editor__hidden-host .sd-paragraph-content { display: block; }";
267615
+ (doc$12.head ?? doc$12.documentElement)?.appendChild(style2);
267616
+ }
267624
267617
  function createHiddenHost(doc$12, widthPx) {
267618
+ ensureHiddenHostStylesheet(doc$12);
267625
267619
  const wrapper = doc$12.createElement("div");
267626
267620
  wrapper.className = "presentation-editor__hidden-host-wrapper";
267627
267621
  wrapper.style.setProperty("position", "fixed");
@@ -267648,6 +267642,66 @@ function createHiddenHost(doc$12, widthPx) {
267648
267642
  host
267649
267643
  };
267650
267644
  }
267645
+ function findRenderedCommentElements(host, commentId, storyKey) {
267646
+ if (!host || !commentId)
267647
+ return [];
267648
+ return Array.from(host.querySelectorAll("[data-comment-ids]")).filter((el) => {
267649
+ const raw = el.dataset.commentIds;
267650
+ if (!raw)
267651
+ return false;
267652
+ if (!raw.split(",").some((token$1) => token$1.trim() === commentId))
267653
+ return false;
267654
+ if (!storyKey)
267655
+ return true;
267656
+ const elStoryKey = el.dataset.storyKey;
267657
+ if (elStoryKey)
267658
+ return elStoryKey === storyKey;
267659
+ return storyKey === BODY_STORY_KEY;
267660
+ });
267661
+ }
267662
+ function findRenderedTrackedChangeElementsStrict(host, entityId, escapeAttrValue$1, storyKey) {
267663
+ if (!host || !entityId)
267664
+ return [];
267665
+ const baseSelector = `[data-track-change-id="${escapeAttrValue$1(entityId)}"]`;
267666
+ if (!storyKey)
267667
+ return Array.from(host.querySelectorAll(baseSelector));
267668
+ const storySelector = `${baseSelector}[data-story-key="${escapeAttrValue$1(storyKey)}"]`;
267669
+ return Array.from(host.querySelectorAll(storySelector));
267670
+ }
267671
+ function findRenderedContentControlElements(host, entityId, escapeAttrValue$1, _storyKey) {
267672
+ if (!host || !entityId)
267673
+ return [];
267674
+ const id2 = escapeAttrValue$1(entityId);
267675
+ 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"]`;
267676
+ return Array.from(host.querySelectorAll(selector));
267677
+ }
267678
+ function elementsToRangeRects(elements) {
267679
+ const result = [];
267680
+ for (const element3 of elements) {
267681
+ const rect = element3.getBoundingClientRect();
267682
+ if (![
267683
+ rect.top,
267684
+ rect.left,
267685
+ rect.right,
267686
+ rect.bottom,
267687
+ rect.width,
267688
+ rect.height
267689
+ ].every(Number.isFinite))
267690
+ continue;
267691
+ const pageEl = element3.closest(".superdoc-page");
267692
+ const pageIndexAttr = Number(pageEl?.dataset?.pageIndex ?? 0);
267693
+ result.push({
267694
+ pageIndex: Number.isFinite(pageIndexAttr) ? pageIndexAttr : 0,
267695
+ left: rect.left,
267696
+ top: rect.top,
267697
+ right: rect.right,
267698
+ bottom: rect.bottom,
267699
+ width: rect.width,
267700
+ height: rect.height
267701
+ });
267702
+ }
267703
+ return result;
267704
+ }
267651
267705
  function getFallbackCursorColor(clientId, fallbackColors) {
267652
267706
  return fallbackColors[clientId % fallbackColors.length];
267653
267707
  }
@@ -268783,24 +268837,33 @@ function renderSelectionRects({ localSelectionLayer, rects, pageHeight, pageGap,
268783
268837
  localSelectionLayer.appendChild(highlight);
268784
268838
  });
268785
268839
  }
268786
- function renderCaretOverlay({ localSelectionLayer, caretLayout, convertPageLocalToOverlayCoords: convertPageLocalToOverlayCoords$1 }) {
268787
- const coords = convertPageLocalToOverlayCoords$1(caretLayout.pageIndex, caretLayout.x, caretLayout.y);
268788
- if (!coords)
268789
- return;
268790
- const finalHeight = Math.max(1, caretLayout.height);
268791
- const caretEl = localSelectionLayer.ownerDocument?.createElement("div");
268840
+ function createCaretElement(doc$12, { left: left$1, top: top$1, height }) {
268841
+ const caretEl = doc$12?.createElement("div");
268792
268842
  if (!caretEl)
268793
- return;
268843
+ return null;
268794
268844
  caretEl.className = "presentation-editor__selection-caret";
268795
268845
  caretEl.style.position = "absolute";
268796
- caretEl.style.left = `${coords.x}px`;
268797
- caretEl.style.top = `${coords.y}px`;
268846
+ caretEl.style.left = `${left$1}px`;
268847
+ caretEl.style.top = `${top$1}px`;
268798
268848
  caretEl.style.width = "2px";
268799
- caretEl.style.height = `${finalHeight}px`;
268849
+ caretEl.style.height = `${Math.max(1, height)}px`;
268800
268850
  caretEl.style.backgroundColor = "#000000";
268801
268851
  caretEl.style.borderRadius = "1px";
268802
268852
  caretEl.style.boxShadow = "0 0 0 1px rgba(255, 255, 255, 0.92)";
268803
268853
  caretEl.style.pointerEvents = "none";
268854
+ return caretEl;
268855
+ }
268856
+ function renderCaretOverlay({ localSelectionLayer, caretLayout, convertPageLocalToOverlayCoords: convertPageLocalToOverlayCoords$1 }) {
268857
+ const coords = convertPageLocalToOverlayCoords$1(caretLayout.pageIndex, caretLayout.x, caretLayout.y);
268858
+ if (!coords)
268859
+ return;
268860
+ const caretEl = createCaretElement(localSelectionLayer.ownerDocument, {
268861
+ left: coords.x,
268862
+ top: coords.y,
268863
+ height: caretLayout.height
268864
+ });
268865
+ if (!caretEl)
268866
+ return;
268804
268867
  localSelectionLayer.appendChild(caretEl);
268805
268868
  }
268806
268869
  function computeTableCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom }, pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
@@ -274910,6 +274973,9 @@ function serializePerIdNumbering(order$1, numberById, formatById) {
274910
274973
  }
274911
274974
  return parts.join(";");
274912
274975
  }
274976
+ function shouldContinueNavigation(options) {
274977
+ return options.shouldContinue?.() !== false;
274978
+ }
274913
274979
  function escapeAttrValue(value) {
274914
274980
  const cssApi = typeof globalThis === "object" && globalThis && "CSS" in globalThis ? globalThis.CSS : undefined;
274915
274981
  if (typeof cssApi?.escape === "function")
@@ -286310,7 +286376,7 @@ var Node$13 = class Node$14 {
286310
286376
  const pendingDeadKeyPlaceholder = TrackChangesBasePluginKey.getState(state)?.pendingDeadKeyPlaceholder ?? null;
286311
286377
  const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta4) => !ALLOWED_META_KEYS.has(meta4));
286312
286378
  const isBlockIdentityRepair = Boolean(tr.getMeta("superdoc/block-identity-repair"));
286313
- if (ySyncMeta?.isChangeOrigin || !tr.steps.length || isBlockIdentityRepair || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
286379
+ if (ySyncMeta?.isChangeOrigin || !tr.steps.length || isBlockIdentityRepair || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey) || tr.getMeta("compositionTrackingFlush") === true) {
286314
286380
  if (pendingDeadKeyPlaceholder && !isCompositionTransaction(tr))
286315
286381
  mergeTrackChangesMeta(tr, { pendingDeadKeyPlaceholder: null });
286316
286382
  return tr;
@@ -289226,7 +289292,28 @@ var Node$13 = class Node$14 {
289226
289292
  if (!allowedRanges?.length)
289227
289293
  return false;
289228
289294
  return allowedRanges.some((allowed) => range.from >= allowed.from && range.to <= allowed.to);
289229
- }, PermissionRanges, Protection, VerticalNavigationPluginKey, createDefaultState = () => ({
289295
+ }, 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) => {
289296
+ if (!raw)
289297
+ return { kind: "unknown" };
289298
+ if (raw === "body")
289299
+ return { kind: "body" };
289300
+ const idx = raw.indexOf(":");
289301
+ const kind = idx === -1 ? raw : raw.slice(0, idx);
289302
+ const id2 = idx === -1 ? undefined : raw.slice(idx + 1);
289303
+ switch (kind) {
289304
+ case "body":
289305
+ case "header":
289306
+ case "footer":
289307
+ case "footnote":
289308
+ case "endnote":
289309
+ return id2 ? {
289310
+ kind,
289311
+ id: id2
289312
+ } : { kind };
289313
+ default:
289314
+ return { kind: "unknown" };
289315
+ }
289316
+ }, DRAGGABLE_SELECTOR, VerticalNavigationPluginKey, createDefaultState = () => ({
289230
289317
  goalX: null,
289231
289318
  goalClientX: null
289232
289319
  }), 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) => {
@@ -291214,7 +291301,9 @@ var Node$13 = class Node$14 {
291214
291301
  if (!tr)
291215
291302
  return;
291216
291303
  view.dispatch?.(closeHistory(tr));
291217
- }, handleEnter = (editor) => {
291304
+ }, isComposing = (editor) => editor?.view?.composing === true, handleEnter = (editor) => {
291305
+ if (isComposing(editor))
291306
+ return false;
291218
291307
  const { view } = editor;
291219
291308
  dispatchHistoryBoundary(view);
291220
291309
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -291225,6 +291314,8 @@ var Node$13 = class Node$14 {
291225
291314
  () => commands$1.splitBlock()
291226
291315
  ]);
291227
291316
  }, handleBackspace = (editor) => {
291317
+ if (isComposing(editor))
291318
+ return false;
291228
291319
  const { view } = editor;
291229
291320
  dispatchHistoryBoundary(view);
291230
291321
  return editor.commands.first(({ commands: commands$1, tr }) => [
@@ -291251,6 +291342,8 @@ var Node$13 = class Node$14 {
291251
291342
  () => commands$1.selectNodeBackward()
291252
291343
  ]);
291253
291344
  }, handleDelete2 = (editor) => {
291345
+ if (isComposing(editor))
291346
+ return false;
291254
291347
  const { view } = editor;
291255
291348
  dispatchHistoryBoundary(view);
291256
291349
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -291320,13 +291413,13 @@ var Node$13 = class Node$14 {
291320
291413
  }, handleInsertTextBeforeInput = (view, event, editor) => {
291321
291414
  const isInsertTextInput = event?.inputType === "insertText";
291322
291415
  const hasTextData = typeof event?.data === "string" && event.data.length > 0;
291323
- const isComposing = event?.isComposing === true;
291416
+ const isComposing$1 = event?.isComposing === true;
291324
291417
  recordStoryInputDebug(view, event, editor, "beforeinput:start", {
291325
291418
  isInsertTextInput,
291326
291419
  hasTextData,
291327
- isComposing
291420
+ isComposing: isComposing$1
291328
291421
  });
291329
- if (!isInsertTextInput || !hasTextData || isComposing) {
291422
+ if (!isInsertTextInput || !hasTextData || isComposing$1) {
291330
291423
  recordStoryInputDebug(view, event, editor, "beforeinput:skip");
291331
291424
  return false;
291332
291425
  }
@@ -293320,8 +293413,10 @@ var Node$13 = class Node$14 {
293320
293413
  }, Editor, token = (varName, fallback) => ({
293321
293414
  css: `var(${varName}, ${fallback})`,
293322
293415
  fallback
293323
- }), 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 {
293416
+ }), 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 {
293324
293417
  #activeCommentId = null;
293418
+ #activeTrackChangeIds = /* @__PURE__ */ new Set;
293419
+ #activeTrackChangeIdsKey = "";
293325
293420
  #container = null;
293326
293421
  setContainer(container) {
293327
293422
  this.#container = container;
@@ -293335,6 +293430,15 @@ var Node$13 = class Node$14 {
293335
293430
  this.#activeCommentId = commentId;
293336
293431
  return true;
293337
293432
  }
293433
+ setActiveTrackChangeIds(ids) {
293434
+ const nextIds = Array.from(new Set(ids.filter((id2) => id2.length > 0)));
293435
+ const nextKey = nextIds.join("\x00");
293436
+ if (this.#activeTrackChangeIdsKey === nextKey)
293437
+ return false;
293438
+ this.#activeTrackChangeIdsKey = nextKey;
293439
+ this.#activeTrackChangeIds = new Set(nextIds);
293440
+ return true;
293441
+ }
293338
293442
  apply() {
293339
293443
  const root3 = this.#container;
293340
293444
  if (!root3)
@@ -293406,16 +293510,27 @@ var Node$13 = class Node$14 {
293406
293510
  return null;
293407
293511
  }
293408
293512
  #applyTrackChangeFocus(root3) {
293409
- const activeId = this.#activeCommentId;
293513
+ const legacyActiveId = this.#activeCommentId;
293514
+ const activeTrackChangeIds = this.#activeTrackChangeIds;
293410
293515
  const elements = root3.querySelectorAll(TRACK_CHANGE_SELECTOR$1);
293411
293516
  for (let i3 = 0;i3 < elements.length; i3++) {
293412
293517
  const el = elements[i3];
293413
- if (activeId && el.dataset.trackChangeId === activeId)
293518
+ if (this.#matchesActiveTrackChange(el, activeTrackChangeIds, legacyActiveId))
293414
293519
  el.classList.add(TRACK_CHANGE_FOCUSED_CLASS);
293415
293520
  else
293416
293521
  el.classList.remove(TRACK_CHANGE_FOCUSED_CLASS);
293417
293522
  }
293418
293523
  }
293524
+ #matchesActiveTrackChange(el, activeTrackChangeIds, legacyActiveId) {
293525
+ const ids = [
293526
+ el.dataset.trackChangeId,
293527
+ el.dataset.trackChangePreferredTargetId,
293528
+ ...parseCommaSeparated(el.dataset.trackChangeIds)
293529
+ ].filter((id2) => Boolean(id2));
293530
+ if (legacyActiveId && ids.includes(legacyActiveId))
293531
+ return true;
293532
+ return ids.some((id2) => activeTrackChangeIds.has(id2));
293533
+ }
293419
293534
  }, EXCLUDED_PLUGIN_KEY_REF_LIST, EXCLUDED_PLUGIN_KEY_REFS, EXCLUDED_PLUGIN_KEY_PREFIXES, TEXT_RANGE_BLOCK_SEP = `
293420
293535
  `, TEXT_RANGE_LEAF_SEP = `
293421
293536
  `, DecorationBridge = class DecorationBridge2 {
@@ -294120,6 +294235,9 @@ var Node$13 = class Node$14 {
294120
294235
  setActiveComment(commentId) {
294121
294236
  return this.#commentHighlightDecorator.setActiveComment(commentId);
294122
294237
  }
294238
+ setActiveTrackChangeIds(ids) {
294239
+ return this.#commentHighlightDecorator.setActiveTrackChangeIds(ids);
294240
+ }
294123
294241
  recordDecorationTransaction(transaction) {
294124
294242
  this.#decorationBridge.recordTransaction(transaction);
294125
294243
  }
@@ -301382,7 +301500,7 @@ menclose::after {
301382
301500
  container.style.width = `${Math.max(0, data.contentWidth)}px`;
301383
301501
  else
301384
301502
  container.style.width = `calc(100% - ${marginLeft + marginRight}px)`;
301385
- container.style.pointerEvents = "auto";
301503
+ container.style.pointerEvents = "none";
301386
301504
  container.style.height = `${effectiveHeight}px`;
301387
301505
  container.style.top = `${Math.max(0, effectiveOffset)}px`;
301388
301506
  container.style.zIndex = "1";
@@ -303752,10 +303870,7 @@ menclose::after {
303752
303870
  return run2.text?.length ?? 0;
303753
303871
  }, isVisualOnlyRun = (run2) => {
303754
303872
  return getRunDataAttrs(run2)?.[FOOTNOTE_MARKER_DATA_ATTR$1] === "true";
303755
- }, SPACE_CHARS$1, isTabRun$1 = (run2) => run2?.kind === "tab", faceOf$1 = (run2) => ({
303756
- weight: run2.bold ? "700" : "400",
303757
- style: run2.italic ? "italic" : "normal"
303758
- }), isWordChar$3 = (char) => {
303873
+ }, SPACE_CHARS$1, isTabRun$1 = (run2) => run2?.kind === "tab", isWordChar$3 = (char) => {
303759
303874
  if (!char)
303760
303875
  return false;
303761
303876
  const code6 = char.charCodeAt(0);
@@ -307035,7 +307150,7 @@ menclose::after {
307035
307150
  this.#onRebuild();
307036
307151
  });
307037
307152
  }
307038
- }, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, log = (...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 {
307153
+ }, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, log = (...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 {
307039
307154
  #options;
307040
307155
  #remoteCursorState = /* @__PURE__ */ new Map;
307041
307156
  #remoteCursorElements = /* @__PURE__ */ new Map;
@@ -312921,25 +313036,24 @@ menclose::after {
312921
313036
  }
312922
313037
  `, movableObjectInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
312923
313038
  return typeof event?.source === "string" && INTERNAL_NOTE_COMMIT_SOURCES.has(event.source);
312924
- }, 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) => {
313039
+ }, 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) => {
312925
313040
  if (!layoutDebugEnabled)
312926
313041
  return;
312927
313042
  console.log(...args$1);
312928
313043
  }, 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;
312929
- var init_src_bGJhSgx__es = __esm(() => {
313044
+ var init_src_CR8eXLKh_es = __esm(() => {
312930
313045
  init_rolldown_runtime_Bg48TavK_es();
312931
- init_SuperConverter_Du0apG1R_es();
313046
+ init_SuperConverter_DQ2wMaLK_es();
312932
313047
  init_jszip_C49i9kUs_es();
312933
313048
  init_xml_js_CqGKpaft_es();
312934
313049
  init_uuid_B2wVPhPi_es();
312935
- init_create_headless_toolbar_BNcguDpP_es();
313050
+ init_create_headless_toolbar_BhSfQYaO_es();
312936
313051
  init_constants_D9qj59G2_es();
312937
313052
  init_unified_BDuVPlMu_es();
312938
313053
  init_remark_gfm_BUJjZJLy_es();
312939
313054
  init_remark_stringify_BZvKOjUX_es();
312940
313055
  init_DocxZipper_BzS208BW_es();
312941
313056
  init__plugin_vue_export_helper_HmhZBO0u_es();
312942
- init_ui_BMYSpkne_es();
312943
313057
  init_eventemitter3_UwU_CLPU_es();
312944
313058
  init_errors_C_DoKMoN_es();
312945
313059
  init_blank_docx_CDDHd6CH_es();
@@ -338113,6 +338227,66 @@ function print() { __p += __j.call(arguments, '') }
338113
338227
  };
338114
338228
  }
338115
338229
  });
338230
+ DOM_CLASS_NAMES = {
338231
+ PAGE: "superdoc-page",
338232
+ FRAGMENT: "superdoc-fragment",
338233
+ LINE: "superdoc-line",
338234
+ INLINE_SDT_WRAPPER: "superdoc-structured-content-inline",
338235
+ INLINE_SDT_LABEL: "superdoc-structured-content-inline__label",
338236
+ BLOCK_SDT: "superdoc-structured-content-block",
338237
+ BLOCK_SDT_LABEL: "superdoc-structured-content__label",
338238
+ TABLE_FRAGMENT: "superdoc-table-fragment",
338239
+ DOCUMENT_SECTION: "superdoc-document-section",
338240
+ SDT_GROUP_HOVER: "sdt-group-hover",
338241
+ TOC_ENTRY: "superdoc-toc-entry",
338242
+ TOC_GROUP_HOVER: "toc-group-hover",
338243
+ IMAGE_FRAGMENT: "superdoc-image-fragment",
338244
+ INLINE_IMAGE: "superdoc-inline-image",
338245
+ LIST_MARKER: "superdoc-list-marker",
338246
+ INLINE_IMAGE_CLIP_WRAPPER: "superdoc-inline-image-clip-wrapper",
338247
+ ANNOTATION: "annotation",
338248
+ ANNOTATION_CONTENT: "annotation-content",
338249
+ ANNOTATION_CARET_ANCHOR: "annotation-caret-anchor"
338250
+ };
338251
+ STRUCTURED_CONTENT_CHROME_LABEL_CLASS_NAMES = [DOM_CLASS_NAMES.INLINE_SDT_LABEL, DOM_CLASS_NAMES.BLOCK_SDT_LABEL];
338252
+ DATA_ATTRS = {
338253
+ PM_START: "data-pm-start",
338254
+ PM_END: "data-pm-end",
338255
+ LAYOUT_EPOCH: "data-layout-epoch",
338256
+ TABLE_BOUNDARIES: "data-table-boundaries",
338257
+ SDT_ID: "data-sdt-id",
338258
+ SDT_TYPE: "data-sdt-type",
338259
+ FIELD_ID: "data-field-id",
338260
+ FIELD_TYPE: "data-field-type",
338261
+ DRAGGABLE: "data-draggable",
338262
+ DISPLAY_LABEL: "data-display-label",
338263
+ VARIANT: "data-variant",
338264
+ TYPE: "data-type",
338265
+ LAYOUT_BOUNDARY_SCHEMA: "data-layout-boundary-schema",
338266
+ LAYOUT_FRAGMENT_ID: "data-layout-fragment-id",
338267
+ LAYOUT_STORY: "data-layout-story",
338268
+ LAYOUT_BLOCK_REF: "data-layout-block-ref"
338269
+ };
338270
+ DATASET_KEYS = {
338271
+ PM_START: "pmStart",
338272
+ PM_END: "pmEnd",
338273
+ LAYOUT_EPOCH: "layoutEpoch",
338274
+ TABLE_BOUNDARIES: "tableBoundaries",
338275
+ SDT_ID: "sdtId",
338276
+ SDT_TYPE: "sdtType",
338277
+ FIELD_ID: "fieldId",
338278
+ FIELD_TYPE: "fieldType",
338279
+ DRAGGABLE: "draggable",
338280
+ DISPLAY_LABEL: "displayLabel",
338281
+ VARIANT: "variant",
338282
+ TYPE: "type",
338283
+ LAYOUT_BOUNDARY_SCHEMA: "layoutBoundarySchema",
338284
+ LAYOUT_FRAGMENT_ID: "layoutFragmentId",
338285
+ LAYOUT_STORY: "layoutStory",
338286
+ LAYOUT_BLOCK_REF: "layoutBlockRef"
338287
+ };
338288
+ `${DOM_CLASS_NAMES.BLOCK_SDT}${DATA_ATTRS.SDT_ID}`;
338289
+ DRAGGABLE_SELECTOR = `[${DATA_ATTRS.DRAGGABLE}="true"]`;
338116
338290
  VerticalNavigationPluginKey = new PluginKey("verticalNavigation");
338117
338291
  VerticalNavigation = Extension.create({
338118
338292
  name: "verticalNavigation",
@@ -340831,7 +341005,7 @@ function print() { __p += __j.call(arguments, '') }
340831
341005
  const activeIndex = exports_vue.ref(-1);
340832
341006
  const query = exports_vue.ref("");
340833
341007
  const inputDisplay = exports_vue.ref("");
340834
- const isComposing = exports_vue.ref(false);
341008
+ const isComposing$1 = exports_vue.ref(false);
340835
341009
  const menuPosition = exports_vue.ref({
340836
341010
  top: "0px",
340837
341011
  left: "0px",
@@ -340974,7 +341148,7 @@ function print() { __p += __j.call(arguments, '') }
340974
341148
  resetToApplied();
340975
341149
  };
340976
341150
  const onInput = (event) => {
340977
- if (isComposing.value)
341151
+ if (isComposing$1.value)
340978
341152
  return;
340979
341153
  const el = event.target;
340980
341154
  const typed = el.value;
@@ -340996,7 +341170,7 @@ function print() { __p += __j.call(arguments, '') }
340996
341170
  }
340997
341171
  };
340998
341172
  const onCompositionEnd = (event) => {
340999
- isComposing.value = false;
341173
+ isComposing$1.value = false;
341000
341174
  onInput(event);
341001
341175
  };
341002
341176
  const moveActive = (direction) => {
@@ -341047,7 +341221,7 @@ function print() { __p += __j.call(arguments, '') }
341047
341221
  return false;
341048
341222
  };
341049
341223
  const onKeydown = (event) => {
341050
- if (event.isComposing || isComposing.value || event.keyCode === 229)
341224
+ if (event.isComposing || isComposing$1.value || event.keyCode === 229)
341051
341225
  return;
341052
341226
  if (event.ctrlKey || event.metaKey || event.altKey)
341053
341227
  return;
@@ -341203,7 +341377,7 @@ function print() { __p += __j.call(arguments, '') }
341203
341377
  onBlur,
341204
341378
  onInput,
341205
341379
  onKeydown,
341206
- onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing.value = true),
341380
+ onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing$1.value = true),
341207
341381
  onCompositionend: onCompositionEnd
341208
341382
  }, null, 44, _hoisted_1$7)], 32),
341209
341383
  exports_vue.createElementVNode("button", {
@@ -344981,6 +345155,11 @@ function print() { __p += __j.call(arguments, '') }
344981
345155
  this.#trackDocumentOpen();
344982
345156
  }
344983
345157
  unmount() {
345158
+ this.view?.dom?.removeEventListener("compositionend", this.#handleDomCompositionEnd);
345159
+ this.view?.dom?.removeEventListener("blur", this.#handleDomCompositionEnd);
345160
+ this.#deferredCompositionRange = null;
345161
+ this.#deferredCompositionDeletions = [];
345162
+ this.#deferredCompositionId = undefined;
344984
345163
  if (this.#renderer)
344985
345164
  this.#renderer.destroy();
344986
345165
  else if (this.view)
@@ -345621,6 +345800,8 @@ function print() { __p += __j.call(arguments, '') }
345621
345800
  state: this.state,
345622
345801
  handleClick: this.#handleNodeSelection.bind(this)
345623
345802
  });
345803
+ this.view?.dom?.addEventListener("compositionend", this.#handleDomCompositionEnd);
345804
+ this.view?.dom?.addEventListener("blur", this.#handleDomCompositionEnd);
345624
345805
  this.createNodeViews();
345625
345806
  }
345626
345807
  createNodeViews() {
@@ -345731,6 +345912,223 @@ function print() { __p += __j.call(arguments, '') }
345731
345912
  this.#dispatchTransaction(tr);
345732
345913
  }, 50);
345733
345914
  }
345915
+ #deferredCompositionRange = null;
345916
+ #deferredCompositionDeletions = [];
345917
+ #deferredCompositionId = undefined;
345918
+ #canDeferCompositionTracking(tr, state) {
345919
+ if (!tr.steps.length)
345920
+ return false;
345921
+ const range = this.#deferredCompositionRange;
345922
+ for (let index2 = 0;index2 < tr.steps.length; index2 += 1) {
345923
+ const step2 = tr.steps[index2];
345924
+ if (!(step2 instanceof ReplaceStep))
345925
+ return false;
345926
+ if (step2.from < step2.to && (!range || step2.from < range.from || step2.to > range.to)) {
345927
+ const sourceDoc = tr.docs[index2] ?? state.doc;
345928
+ if (!this.#canRestoreDeferredCompositionDeletion(step2, sourceDoc))
345929
+ return false;
345930
+ }
345931
+ }
345932
+ return true;
345933
+ }
345934
+ #canRestoreDeferredCompositionDeletion(step2, doc$12) {
345935
+ if (step2.slice.size === 0)
345936
+ return false;
345937
+ let hasText = false;
345938
+ let hasUnsupportedContent = false;
345939
+ doc$12.nodesBetween(step2.from, step2.to, (node2) => {
345940
+ if (hasUnsupportedContent)
345941
+ return false;
345942
+ if (node2.type.name.includes("table") || node2.isLeaf && !node2.isText) {
345943
+ hasUnsupportedContent = true;
345944
+ return false;
345945
+ }
345946
+ if (node2.isText && node2.text)
345947
+ hasText = true;
345948
+ return true;
345949
+ });
345950
+ return hasText && !hasUnsupportedContent;
345951
+ }
345952
+ #collectDeferredCompositionDeletions(tr) {
345953
+ const deletions = [];
345954
+ const range = this.#deferredCompositionRange;
345955
+ tr.steps.forEach((step2, index2) => {
345956
+ if (!(step2 instanceof ReplaceStep) || step2.from >= step2.to)
345957
+ return;
345958
+ if (range && step2.from >= range.from && step2.to <= range.to)
345959
+ return;
345960
+ const sourceDoc = tr.docs[index2] ?? this.state.doc;
345961
+ if (!this.#canRestoreDeferredCompositionDeletion(step2, sourceDoc))
345962
+ return;
345963
+ const rest = tr.mapping.slice(index2 + 1);
345964
+ deletions.push({
345965
+ pos: rest.map(step2.from + step2.slice.size, 1),
345966
+ slice: sourceDoc.slice(step2.from, step2.to)
345967
+ });
345968
+ });
345969
+ return deletions;
345970
+ }
345971
+ #replacesWithinDeferredRange(tr) {
345972
+ const range = this.#deferredCompositionRange;
345973
+ if (!range || !tr.steps.length)
345974
+ return false;
345975
+ return tr.steps.every((step2) => step2 instanceof ReplaceStep && step2.from < step2.to && step2.from >= range.from && step2.to <= range.to);
345976
+ }
345977
+ #updateDeferredCompositionRange(applied, deferredSource) {
345978
+ if (!this.#deferredCompositionRange && !deferredSource)
345979
+ return;
345980
+ let range = this.#deferredCompositionRange;
345981
+ for (const tr of applied) {
345982
+ if (range) {
345983
+ const from$1 = tr.mapping.map(range.from, -1);
345984
+ const to = tr.mapping.map(range.to, 1);
345985
+ range = from$1 < to ? {
345986
+ from: from$1,
345987
+ to
345988
+ } : null;
345989
+ }
345990
+ if (tr === deferredSource)
345991
+ tr.steps.forEach((step2, index2) => {
345992
+ if (!(step2 instanceof ReplaceStep) || step2.slice.size === 0)
345993
+ return;
345994
+ const rest = tr.mapping.slice(index2 + 1);
345995
+ const from$1 = rest.map(step2.from, -1);
345996
+ const to = rest.map(step2.from + step2.slice.size, 1);
345997
+ range = range ? {
345998
+ from: Math.min(range.from, from$1),
345999
+ to: Math.max(range.to, to)
346000
+ } : {
346001
+ from: from$1,
346002
+ to
346003
+ };
346004
+ });
346005
+ }
346006
+ this.#deferredCompositionRange = range;
346007
+ }
346008
+ #mapDeferredCompositionDeletions(applied) {
346009
+ if (!this.#deferredCompositionDeletions.length)
346010
+ return;
346011
+ this.#deferredCompositionDeletions = this.#mapCompositionDeletions(this.#deferredCompositionDeletions, applied);
346012
+ }
346013
+ #mapCompositionDeletions(deletions, applied) {
346014
+ if (!deletions.length || !applied.length)
346015
+ return deletions;
346016
+ return deletions.map((deletion) => {
346017
+ let pos = deletion.pos;
346018
+ for (const tr of applied)
346019
+ pos = tr.mapping.map(pos, -1);
346020
+ return {
346021
+ ...deletion,
346022
+ pos
346023
+ };
346024
+ });
346025
+ }
346026
+ #flushDeferredCompositionTracking() {
346027
+ const range = this.#deferredCompositionRange;
346028
+ const deletions = this.#deferredCompositionDeletions;
346029
+ const compositionId = this.#deferredCompositionId;
346030
+ this.#deferredCompositionRange = null;
346031
+ this.#deferredCompositionDeletions = [];
346032
+ this.#deferredCompositionId = undefined;
346033
+ if (!range || this.isDestroyed || !this.view)
346034
+ return;
346035
+ const state = this.state;
346036
+ if (!TrackChangesBasePluginKey.getState(state)?.isTrackChangesActive)
346037
+ return;
346038
+ const from$1 = Math.max(0, Math.min(range.from, state.doc.content.size));
346039
+ const to = Math.max(from$1, Math.min(range.to, state.doc.content.size));
346040
+ if (from$1 >= to)
346041
+ return;
346042
+ const insertMarkType = state.schema.marks[TrackInsertMarkName];
346043
+ if (!insertMarkType)
346044
+ return;
346045
+ let fullyMarked = true;
346046
+ state.doc.nodesBetween(from$1, to, (node2) => {
346047
+ if (node2.isText && !insertMarkType.isInSet(node2.marks))
346048
+ fullyMarked = false;
346049
+ return !node2.isText;
346050
+ });
346051
+ if (fullyMarked && !deletions.length)
346052
+ return;
346053
+ const tr = state.tr;
346054
+ const fixedTimeTo10Mins = Math.floor(Date.now() / 600000) * 600000;
346055
+ const date6 = new Date(fixedTimeTo10Mins).toISOString();
346056
+ const user = this.options.user ?? {};
346057
+ let insertedMark = fullyMarked ? null : markInsertion({
346058
+ tr,
346059
+ from: from$1,
346060
+ to,
346061
+ user,
346062
+ date: date6
346063
+ });
346064
+ const replacementGroupId = insertedMark && deletions.length && this.options.trackedChanges?.replacements !== "independent" ? insertedMark.attrs.id : "";
346065
+ if (insertedMark && replacementGroupId) {
346066
+ const replacementInsertMark = insertedMark.type.create({
346067
+ ...insertedMark.attrs,
346068
+ changeType: CanonicalChangeType.Replacement,
346069
+ replacementGroupId,
346070
+ replacementSideId: `${replacementGroupId}#inserted`
346071
+ });
346072
+ tr.removeMark(from$1, to, insertedMark);
346073
+ tr.addMark(from$1, to, replacementInsertMark);
346074
+ insertedMark = replacementInsertMark;
346075
+ }
346076
+ let deletionMeta = null;
346077
+ deletions.forEach((deletion) => {
346078
+ const deleteFrom = tr.mapping.map(deletion.pos, -1);
346079
+ const beforeSize = tr.doc.content.size;
346080
+ tr.replace(deleteFrom, deleteFrom, deletion.slice);
346081
+ const deleteTo = deleteFrom + (tr.doc.content.size - beforeSize);
346082
+ if (deleteTo <= deleteFrom)
346083
+ return;
346084
+ const deletionResult = markDeletion({
346085
+ tr,
346086
+ from: deleteFrom,
346087
+ to: deleteTo,
346088
+ user,
346089
+ date: date6,
346090
+ id: replacementGroupId || undefined
346091
+ });
346092
+ const deletionMark = replacementGroupId ? deletionResult.deletionMark.type.create({
346093
+ ...deletionResult.deletionMark.attrs,
346094
+ changeType: CanonicalChangeType.Replacement,
346095
+ replacementGroupId,
346096
+ replacementSideId: `${replacementGroupId}#deleted`
346097
+ }) : deletionResult.deletionMark;
346098
+ if (deletionMark !== deletionResult.deletionMark) {
346099
+ tr.removeMark(deleteFrom, deleteTo, deletionResult.deletionMark);
346100
+ tr.addMark(deleteFrom, deleteTo, deletionMark);
346101
+ }
346102
+ deletionMeta = {
346103
+ deletionMark,
346104
+ deletionNodes: deletionResult.nodes
346105
+ };
346106
+ });
346107
+ tr.setMeta("skipTrackChanges", true);
346108
+ tr.setMeta("compositionTrackingFlush", true);
346109
+ if (compositionId !== undefined)
346110
+ tr.setMeta("composition", compositionId);
346111
+ tr.setMeta(TrackChangesBasePluginKey, {
346112
+ ...insertedMark ? { insertedMark } : {},
346113
+ ...deletionMeta ?? {}
346114
+ });
346115
+ this.view.dispatch(tr);
346116
+ }
346117
+ #handleDomCompositionEnd = (event) => {
346118
+ const forceFlush = event?.type === "blur";
346119
+ queueMicrotask(() => {
346120
+ if (!this.#deferredCompositionRange)
346121
+ return;
346122
+ if (this.view?.composing && !forceFlush)
346123
+ return;
346124
+ try {
346125
+ this.view?.domObserver?.flush?.();
346126
+ } catch {}
346127
+ if (this.view?.composing && !forceFlush)
346128
+ return;
346129
+ this.#flushDeferredCompositionTracking();
346130
+ });
346131
+ };
345734
346132
  #dispatchTransaction(transaction) {
345735
346133
  if (this.isDestroyed)
345736
346134
  return;
@@ -345749,13 +346147,21 @@ function print() { __p += __j.call(arguments, '') }
345749
346147
  const protectsExistingTrackedReviewState = transactionTouchesTrackedReviewState(prevState, transactionToApply);
345750
346148
  if (protectsExistingTrackedReviewState && skipTrackChanges)
345751
346149
  transactionToApply.setMeta("protectTrackedReviewState", true);
345752
- const shouldTrack = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges || protectsExistingTrackedReviewState;
346150
+ const shouldTrackForComposition = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges;
346151
+ const shouldTrack = shouldTrackForComposition || protectsExistingTrackedReviewState;
345753
346152
  if (!shouldTrack && directInsertionMutationCommentMeta && !transactionToApply.getMeta(TrackChangesBasePluginKey))
345754
346153
  transactionToApply.setMeta(TrackChangesBasePluginKey, directInsertionMutationCommentMeta);
345755
346154
  if (shouldTrack && forceTrackChanges && !this.options.user)
345756
346155
  throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");
346156
+ const deferTrackingForComposition = shouldTrackForComposition && (isCompositionTransaction(transactionToApply) || this.view?.composing === true && this.#replacesWithinDeferredRange(transactionToApply)) && this.#canDeferCompositionTracking(transactionToApply, prevState);
346157
+ const deferredCompositionDeletions = deferTrackingForComposition ? this.#collectDeferredCompositionDeletions(transactionToApply) : [];
346158
+ if (deferTrackingForComposition) {
346159
+ const compositionMeta = transactionToApply.getMeta("composition");
346160
+ if (compositionMeta !== undefined)
346161
+ this.#deferredCompositionId = compositionMeta;
346162
+ }
345757
346163
  const trackedUser = this.options.user ?? {};
345758
- transactionToApply = shouldTrack ? trackedTransaction({
346164
+ transactionToApply = shouldTrack && !deferTrackingForComposition ? trackedTransaction({
345759
346165
  tr: transactionToApply,
345760
346166
  state: prevState,
345761
346167
  user: trackedUser,
@@ -345763,6 +346169,12 @@ function print() { __p += __j.call(arguments, '') }
345763
346169
  }) : transactionToApply;
345764
346170
  const { state: appliedState, transactions: appliedTransactions } = prevState.applyTransaction(transactionToApply);
345765
346171
  nextState = appliedState;
346172
+ this.#updateDeferredCompositionRange(appliedTransactions, deferTrackingForComposition ? transactionToApply : null);
346173
+ this.#mapDeferredCompositionDeletions(appliedTransactions);
346174
+ if (deferredCompositionDeletions.length)
346175
+ this.#deferredCompositionDeletions.push(...this.#mapCompositionDeletions(deferredCompositionDeletions, appliedTransactions.slice(1)));
346176
+ if (deferTrackingForComposition && this.view?.composing !== true)
346177
+ this.#handleDomCompositionEnd();
345766
346178
  effectiveTransaction = appliedTransactions.find((t) => t.docChanged) ?? transactionToApply;
345767
346179
  } catch (error48) {
345768
346180
  if (forceTrackChanges)
@@ -348358,6 +348770,12 @@ function print() { __p += __j.call(arguments, '') }
348358
348770
  bottom: 72,
348359
348771
  left: 72
348360
348772
  };
348773
+ NAVIGATED_CARET_REPAIR_DELAYS_MS = [
348774
+ 120,
348775
+ 360,
348776
+ 900,
348777
+ 1300
348778
+ ];
348361
348779
  layoutDebugEnabled = typeof process$1 !== "undefined" && typeof process$1.env !== "undefined" && Boolean(process$1.env.SD_DEBUG_LAYOUT);
348362
348780
  GLOBAL_PERFORMANCE = typeof performance !== "undefined" ? performance : undefined;
348363
348781
  PresentationEditor = class PresentationEditor2 extends EventEmitter {
@@ -348432,8 +348850,15 @@ function print() { __p += __j.call(arguments, '') }
348432
348850
  #renderScheduled = false;
348433
348851
  #pendingDocChange = false;
348434
348852
  #focusScrollRafId = null;
348853
+ #selectionScrollSettleCleanup = null;
348854
+ #selectionNavigationToken = 0;
348855
+ #activeSelectionNavigation = null;
348435
348856
  #pendingMapping = null;
348436
348857
  #isRerendering = false;
348858
+ #isComposing = false;
348859
+ #compositionDeferralCleanup = [];
348860
+ #compositionTargetCleanup = [];
348861
+ #compositionTargetDom = null;
348437
348862
  #selectionSync = new SelectionSyncCoordinator;
348438
348863
  #fontGate = null;
348439
348864
  #fontResolver = createFontResolver();
@@ -348774,6 +349199,8 @@ function print() { __p += __j.call(arguments, '') }
348774
349199
  this.#setupPointerHandlers();
348775
349200
  this.#setupDragHandlers();
348776
349201
  this.#setupInputBridge();
349202
+ this.#setupCompositionDeferral();
349203
+ this.#refreshCompositionDeferralTarget();
348777
349204
  this.#syncTrackedChangesPreferences();
348778
349205
  this.#syncHeaderFooterTrackedChangesRenderConfig();
348779
349206
  this.#setupSemanticResizeObserver();
@@ -350379,6 +350806,7 @@ function print() { __p += __j.call(arguments, '') }
350379
350806
  const targetEl = this.#findElementAtPosition(pageEl, clampedPos);
350380
350807
  const elToScroll = targetEl ?? pageEl;
350381
350808
  const block = options.ifNeeded && targetEl && this.#isElementFullyVisibleInScrollContainer(targetEl) ? "nearest" : requestedBlock;
350809
+ this.#startSelectionNavigation(clampedPos);
350382
350810
  elToScroll.scrollIntoView({
350383
350811
  block,
350384
350812
  inline: "nearest",
@@ -350397,6 +350825,7 @@ function print() { __p += __j.call(arguments, '') }
350397
350825
  });
350398
350826
  this.#shouldScrollSelectionIntoView = false;
350399
350827
  this.#suppressSelectionScrollUntilRaf = false;
350828
+ this.#scheduleSelectionUpdateAfterScrollSettles();
350400
350829
  });
350401
350830
  }
350402
350831
  return true;
@@ -350479,6 +350908,164 @@ function print() { __p += __j.call(arguments, '') }
350479
350908
  }
350480
350909
  };
350481
350910
  }
350911
+ #startSelectionNavigation(targetPos) {
350912
+ const token$1 = ++this.#selectionNavigationToken;
350913
+ this.#activeSelectionNavigation = {
350914
+ token: token$1,
350915
+ targetPos,
350916
+ scrollSettled: false,
350917
+ repairAttempts: 0
350918
+ };
350919
+ return token$1;
350920
+ }
350921
+ #markSelectionNavigationScrollSettled() {
350922
+ if (this.#activeSelectionNavigation)
350923
+ this.#activeSelectionNavigation.scrollSettled = true;
350924
+ }
350925
+ #finishSelectionNavigation(token$1) {
350926
+ if (token$1 != null && this.#activeSelectionNavigation?.token !== token$1)
350927
+ return;
350928
+ this.#activeSelectionNavigation = null;
350929
+ }
350930
+ #scheduleNavigatedSelectionRender(targetPos) {
350931
+ this.#startSelectionNavigation(targetPos);
350932
+ this.#scheduleSelectionUpdateAfterScrollSettles();
350933
+ this.#scheduleSelectionUpdate({ immediate: true });
350934
+ this.#scheduleNavigatedCaretViewportRepairs(targetPos);
350935
+ }
350936
+ #scheduleNavigatedCaretViewportRepairs(targetPos) {
350937
+ const win = this.#visibleHost.ownerDocument?.defaultView;
350938
+ if (!win)
350939
+ return;
350940
+ for (const delay of NAVIGATED_CARET_REPAIR_DELAYS_MS)
350941
+ win.setTimeout(() => {
350942
+ if (!this.#localSelectionLayer?.isConnected)
350943
+ return;
350944
+ const selection = this.getActiveEditor()?.state?.selection;
350945
+ if (!selection || selection.from !== targetPos || selection.to !== targetPos)
350946
+ return;
350947
+ this.#rebuildDomPositionIndex();
350948
+ this.#renderNavigatedCaretFromViewportCoords(targetPos);
350949
+ }, delay);
350950
+ }
350951
+ #queueSelectionNavigationCaretRepair(caretPos, navigation) {
350952
+ if (this.#activeSelectionNavigation?.token !== navigation.token)
350953
+ return false;
350954
+ const caretEl = this.#localSelectionLayer.querySelector(".presentation-editor__selection-caret");
350955
+ if (!(caretEl instanceof HTMLElement))
350956
+ return false;
350957
+ const expected = this.coordsAtPos(caretPos);
350958
+ if (!expected)
350959
+ return false;
350960
+ const actual = caretEl.getBoundingClientRect();
350961
+ if (Math.abs(actual.top - expected.top) <= NAVIGATED_CARET_DRIFT_TOLERANCE_PX)
350962
+ return false;
350963
+ if (navigation.repairAttempts >= NAVIGATED_CARET_MAX_REPAIR_ATTEMPTS)
350964
+ return false;
350965
+ navigation.repairAttempts += 1;
350966
+ const win = this.#visibleHost.ownerDocument?.defaultView;
350967
+ const repair = () => {
350968
+ if (this.#activeSelectionNavigation?.token !== navigation.token)
350969
+ return;
350970
+ this.#rebuildDomPositionIndex();
350971
+ this.#scheduleSelectionUpdate({ immediate: true });
350972
+ };
350973
+ if (win)
350974
+ win.requestAnimationFrame(repair);
350975
+ else
350976
+ repair();
350977
+ return true;
350978
+ }
350979
+ #renderNavigatedCaretFromViewportCoords(caretPos) {
350980
+ const coords = this.coordsAtPos(caretPos);
350981
+ if (!coords)
350982
+ return false;
350983
+ const zoom = Number.isFinite(this.#layoutOptions.zoom) && this.#layoutOptions.zoom > 0 ? this.#layoutOptions.zoom : 1;
350984
+ const layerRect = this.#localSelectionLayer.getBoundingClientRect();
350985
+ const caretEl = createCaretElement(this.#localSelectionLayer.ownerDocument, {
350986
+ left: (coords.left - layerRect.left) / zoom,
350987
+ top: (coords.top - layerRect.top) / zoom,
350988
+ height: coords.height / zoom
350989
+ });
350990
+ if (!caretEl)
350991
+ return false;
350992
+ this.#localSelectionLayer.innerHTML = "";
350993
+ this.#localSelectionLayer.appendChild(caretEl);
350994
+ return true;
350995
+ }
350996
+ #scheduleSelectionUpdateAfterScrollSettles() {
350997
+ const win = this.#visibleHost.ownerDocument?.defaultView;
350998
+ if (!win) {
350999
+ this.#scheduleSelectionUpdate();
351000
+ return;
351001
+ }
351002
+ this.#selectionScrollSettleCleanup?.();
351003
+ const scrollTarget = this.#scrollContainer instanceof Window || this.#scrollContainer instanceof Element ? this.#scrollContainer : win;
351004
+ let timeoutId = null;
351005
+ let finalTimeoutId = null;
351006
+ let scrollRenderRafId = null;
351007
+ let cleanedUp = false;
351008
+ const cleanup = () => {
351009
+ if (cleanedUp)
351010
+ return;
351011
+ cleanedUp = true;
351012
+ scrollTarget.removeEventListener("scroll", onScroll);
351013
+ scrollTarget.removeEventListener("scrollend", finalizeRender);
351014
+ if (timeoutId != null) {
351015
+ win.clearTimeout(timeoutId);
351016
+ timeoutId = null;
351017
+ }
351018
+ if (finalTimeoutId != null) {
351019
+ win.clearTimeout(finalTimeoutId);
351020
+ finalTimeoutId = null;
351021
+ }
351022
+ if (scrollRenderRafId != null) {
351023
+ win.cancelAnimationFrame(scrollRenderRafId);
351024
+ scrollRenderRafId = null;
351025
+ }
351026
+ if (this.#selectionScrollSettleCleanup === cleanup)
351027
+ this.#selectionScrollSettleCleanup = null;
351028
+ };
351029
+ const renderAfterPause = () => {
351030
+ timeoutId = null;
351031
+ this.#scheduleSelectionUpdate({ immediate: true });
351032
+ };
351033
+ const finalizeRender = () => {
351034
+ if (cleanedUp)
351035
+ return;
351036
+ this.#markSelectionNavigationScrollSettled();
351037
+ cleanup();
351038
+ this.#scheduleSelectionUpdate({ immediate: true });
351039
+ };
351040
+ const queueRender = () => {
351041
+ if (timeoutId != null)
351042
+ win.clearTimeout(timeoutId);
351043
+ timeoutId = win.setTimeout(renderAfterPause, SELECTION_SCROLL_SETTLE_RENDER_DELAY_MS);
351044
+ };
351045
+ const queueFinalize = () => {
351046
+ if (finalTimeoutId != null)
351047
+ win.clearTimeout(finalTimeoutId);
351048
+ finalTimeoutId = win.setTimeout(finalizeRender, SELECTION_SCROLL_SETTLE_FINALIZE_DELAY_MS);
351049
+ };
351050
+ const requestScrollRender = () => {
351051
+ if (scrollRenderRafId != null)
351052
+ return;
351053
+ scrollRenderRafId = win.requestAnimationFrame(() => {
351054
+ scrollRenderRafId = null;
351055
+ this.#scheduleSelectionUpdate({ immediate: true });
351056
+ });
351057
+ };
351058
+ const onScroll = () => {
351059
+ requestScrollRender();
351060
+ queueRender();
351061
+ queueFinalize();
351062
+ };
351063
+ scrollTarget.addEventListener("scroll", onScroll, { passive: true });
351064
+ scrollTarget.addEventListener("scrollend", finalizeRender, { passive: true });
351065
+ this.#selectionScrollSettleCleanup = cleanup;
351066
+ queueRender();
351067
+ queueFinalize();
351068
+ }
350482
351069
  #findElementAtPosition(pageEl, pos) {
350483
351070
  const elements = Array.from(pageEl.querySelectorAll("[data-pm-start][data-pm-end]"));
350484
351071
  let bestMatch = null;
@@ -350502,6 +351089,8 @@ function print() { __p += __j.call(arguments, '') }
350502
351089
  return bestMatch;
350503
351090
  }
350504
351091
  async scrollToPositionAsync(pos, options = {}) {
351092
+ if (!shouldContinueNavigation(options))
351093
+ return false;
350505
351094
  if (this.scrollToPosition(pos, options))
350506
351095
  return true;
350507
351096
  const doc$12 = this.getActiveEditor()?.state?.doc;
@@ -350527,11 +351116,15 @@ function print() { __p += __j.call(arguments, '') }
350527
351116
  }
350528
351117
  if (pageIndex == null)
350529
351118
  return false;
351119
+ if (!shouldContinueNavigation(options))
351120
+ return false;
350530
351121
  this.#scrollPageIntoView(pageIndex);
350531
351122
  if (!await this.#waitForPageMount(pageIndex, { timeout: PresentationEditor2.ANCHOR_NAV_TIMEOUT_MS })) {
350532
351123
  console.warn(`[PresentationEditor] scrollToPositionAsync: Page ${pageIndex} failed to mount within timeout`);
350533
351124
  return false;
350534
351125
  }
351126
+ if (!shouldContinueNavigation(options))
351127
+ return false;
350535
351128
  return this.scrollToPosition(pos, {
350536
351129
  ...options,
350537
351130
  ifNeeded: false
@@ -350716,6 +351309,11 @@ function print() { __p += __j.call(arguments, '') }
350716
351309
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#focusScrollRafId);
350717
351310
  this.#focusScrollRafId = null;
350718
351311
  }, "Focus scroll RAF");
351312
+ if (this.#selectionScrollSettleCleanup)
351313
+ safeCleanup(() => {
351314
+ this.#selectionScrollSettleCleanup?.();
351315
+ }, "Selection scroll settle");
351316
+ this.#finishSelectionNavigation();
350719
351317
  if (this.#decorationSyncRafHandle != null)
350720
351318
  safeCleanup(() => {
350721
351319
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#decorationSyncRafHandle);
@@ -350770,6 +351368,7 @@ function print() { __p += __j.call(arguments, '') }
350770
351368
  this.#inputBridge?.notifyTargetChanged();
350771
351369
  this.#inputBridge?.destroy();
350772
351370
  this.#inputBridge = null;
351371
+ this.#teardownCompositionDeferral();
350773
351372
  if (this.#a11ySelectionAnnounceTimeout != null) {
350774
351373
  clearTimeout(this.#a11ySelectionAnnounceTimeout);
350775
351374
  this.#a11ySelectionAnnounceTimeout = null;
@@ -350903,6 +351502,12 @@ function print() { __p += __j.call(arguments, '') }
350903
351502
  #syncCommentHighlights() {
350904
351503
  this.#postPaintPipeline.applyCommentHighlights();
350905
351504
  }
351505
+ setActiveTrackChangeIds(ids) {
351506
+ const didChange = this.#postPaintPipeline.setActiveTrackChangeIds(ids);
351507
+ if (didChange)
351508
+ this.#syncInlineStyleLayers();
351509
+ return didChange;
351510
+ }
350906
351511
  #syncInlineStyleLayers() {
350907
351512
  const state = this.#editor?.view?.state;
350908
351513
  if (!state) {
@@ -351359,7 +351964,10 @@ function print() { __p += __j.call(arguments, '') }
351359
351964
  }
351360
351965
  #setupInputBridge() {
351361
351966
  this.#inputBridge?.destroy();
351362
- this.#inputBridge = new PresentationInputBridge(this.#visibleHost.ownerDocument?.defaultView ?? window, this.#visibleHost, () => this.#getActiveDomTarget(), () => !this.#isViewLocked(), () => this.#editorInputManager?.notifyTargetChanged(), {
351967
+ this.#inputBridge = new PresentationInputBridge(this.#visibleHost.ownerDocument?.defaultView ?? window, this.#visibleHost, () => this.#getActiveDomTarget(), () => !this.#isViewLocked(), () => {
351968
+ this.#refreshCompositionDeferralTarget();
351969
+ this.#editorInputManager?.notifyTargetChanged();
351970
+ }, {
351363
351971
  useWindowFallback: true,
351364
351972
  getTargetEditor: () => this.getActiveEditor()
351365
351973
  });
@@ -351995,6 +352603,70 @@ function print() { __p += __j.call(arguments, '') }
351995
352603
  this.#selectionSync.onLayoutStart();
351996
352604
  this.#scheduleRerender();
351997
352605
  }
352606
+ #beginCompositionDeferral() {
352607
+ this.#isComposing = true;
352608
+ }
352609
+ #endCompositionDeferral() {
352610
+ if (!this.#isComposing)
352611
+ return;
352612
+ this.#isComposing = false;
352613
+ if (this.#pendingDocChange && !this.#renderScheduled && !this.#isRerendering)
352614
+ this.#scheduleRerender();
352615
+ }
352616
+ #resetCompositionDeferral() {
352617
+ this.#isComposing = false;
352618
+ }
352619
+ #handleNonComposingInputForCompositionDeferral = (event) => {
352620
+ if ("isComposing" in event && event.isComposing === false)
352621
+ this.#endCompositionDeferral();
352622
+ };
352623
+ #setupCompositionDeferral() {
352624
+ this.#teardownCompositionDeferral();
352625
+ const add = (target, type, handler2) => {
352626
+ if (!target)
352627
+ return;
352628
+ target.addEventListener(type, handler2);
352629
+ this.#compositionDeferralCleanup.push(() => target.removeEventListener(type, handler2));
352630
+ };
352631
+ const begin = () => this.#beginCompositionDeferral();
352632
+ const end$1 = () => this.#endCompositionDeferral();
352633
+ add(this.#visibleHost, "compositionstart", begin);
352634
+ add(this.#visibleHost, "compositionend", end$1);
352635
+ add(this.#visibleHost, "input", this.#handleNonComposingInputForCompositionDeferral);
352636
+ add(this.#visibleHost, "beforeinput", this.#handleNonComposingInputForCompositionDeferral);
352637
+ }
352638
+ #teardownCompositionDeferral() {
352639
+ this.#compositionTargetCleanup.forEach((cleanup) => cleanup());
352640
+ this.#compositionTargetCleanup = [];
352641
+ this.#compositionTargetDom = null;
352642
+ this.#compositionDeferralCleanup.forEach((cleanup) => cleanup());
352643
+ this.#compositionDeferralCleanup = [];
352644
+ this.#resetCompositionDeferral();
352645
+ }
352646
+ #refreshCompositionDeferralTarget() {
352647
+ const nextTarget = this.#getActiveDomTarget();
352648
+ if (nextTarget === this.#compositionTargetDom)
352649
+ return;
352650
+ this.#compositionTargetCleanup.forEach((cleanup) => cleanup());
352651
+ this.#compositionTargetCleanup = [];
352652
+ this.#compositionTargetDom = nextTarget;
352653
+ if (!nextTarget) {
352654
+ this.#endCompositionDeferral();
352655
+ return;
352656
+ }
352657
+ const begin = () => this.#beginCompositionDeferral();
352658
+ const end$1 = () => this.#endCompositionDeferral();
352659
+ nextTarget.addEventListener("compositionstart", begin);
352660
+ nextTarget.addEventListener("compositionend", end$1);
352661
+ nextTarget.addEventListener("blur", end$1);
352662
+ nextTarget.addEventListener("focusout", end$1);
352663
+ nextTarget.addEventListener("beforeinput", this.#handleNonComposingInputForCompositionDeferral);
352664
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("compositionstart", begin));
352665
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("compositionend", end$1));
352666
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("blur", end$1));
352667
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("focusout", end$1));
352668
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("beforeinput", this.#handleNonComposingInputForCompositionDeferral));
352669
+ }
351998
352670
  #scheduleRerender() {
351999
352671
  if (this.#renderScheduled)
352000
352672
  return;
@@ -352013,6 +352685,8 @@ function print() { __p += __j.call(arguments, '') }
352013
352685
  }
352014
352686
  if (!this.#pendingDocChange)
352015
352687
  return;
352688
+ if (this.#isComposing)
352689
+ return;
352016
352690
  this.#pendingDocChange = false;
352017
352691
  this.#isRerendering = true;
352018
352692
  const activeHfEditor = (this.#headerFooterSession?.session?.mode ?? "body") !== "body" ? this.#headerFooterSession?.activeEditor : null;
@@ -352799,9 +353473,22 @@ function print() { __p += __j.call(arguments, '') }
352799
353473
  }
352800
353474
  if (from$1 === to || isDragDropIndicatorActive) {
352801
353475
  const caretPos = this.#dragDropIndicatorPos ?? from$1;
353476
+ const activeNavigation$1 = this.#activeSelectionNavigation;
353477
+ const isRenderingNavigatedCaret = activeNavigation$1?.targetPos === caretPos;
353478
+ if (isRenderingNavigatedCaret)
353479
+ this.#rebuildDomPositionIndex();
353480
+ else if (activeNavigation$1)
353481
+ this.#finishSelectionNavigation(activeNavigation$1.token);
353482
+ if (isRenderingNavigatedCaret && activeNavigation$1?.scrollSettled && this.#renderNavigatedCaretFromViewportCoords(caretPos)) {
353483
+ this.#finishSelectionNavigation(activeNavigation$1.token);
353484
+ return;
353485
+ }
352802
353486
  const caretLayout = this.#computeCaretLayoutRect(caretPos);
352803
- if (!caretLayout)
353487
+ if (!caretLayout) {
353488
+ if (isRenderingNavigatedCaret)
353489
+ this.#localSelectionLayer.innerHTML = "";
352804
353490
  return;
353491
+ }
352805
353492
  try {
352806
353493
  this.#localSelectionLayer.innerHTML = "";
352807
353494
  renderCaretOverlay({
@@ -352809,6 +353496,9 @@ function print() { __p += __j.call(arguments, '') }
352809
353496
  caretLayout,
352810
353497
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
352811
353498
  });
353499
+ const queuedNavigationRepair = isRenderingNavigatedCaret && activeNavigation$1 ? this.#queueSelectionNavigationCaretRepair(caretPos, activeNavigation$1) : false;
353500
+ if (isRenderingNavigatedCaret && activeNavigation$1?.scrollSettled && !queuedNavigationRepair)
353501
+ this.#finishSelectionNavigation(activeNavigation$1?.token);
352812
353502
  } catch (error48) {
352813
353503
  if (process$1.env.NODE_ENV === "development")
352814
353504
  console.warn("[PresentationEditor] Failed to render caret overlay:", error48);
@@ -352817,8 +353507,16 @@ function print() { __p += __j.call(arguments, '') }
352817
353507
  this.#scrollActiveEndIntoView(caretLayout.pageIndex);
352818
353508
  return;
352819
353509
  }
353510
+ const activeNavigation = this.#activeSelectionNavigation;
353511
+ const selectionContainsNavigationTarget = activeNavigation != null && activeNavigation.targetPos >= from$1 && activeNavigation.targetPos <= to;
353512
+ if (activeNavigation && !selectionContainsNavigationTarget)
353513
+ this.#finishSelectionNavigation(activeNavigation.token);
353514
+ if (selectionContainsNavigationTarget)
353515
+ this.#rebuildDomPositionIndex();
352820
353516
  const domRects = this.#computeSelectionRectsFromDom(from$1, to);
352821
353517
  if (domRects == null) {
353518
+ if (selectionContainsNavigationTarget)
353519
+ this.#localSelectionLayer.innerHTML = "";
352822
353520
  debugLog("warn", "Local selection: DOM rect computation failed", {
352823
353521
  from: from$1,
352824
353522
  to
@@ -352835,7 +353533,7 @@ function print() { __p += __j.call(arguments, '') }
352835
353533
  try {
352836
353534
  this.#localSelectionLayer.innerHTML = "";
352837
353535
  const isFieldAnnotationSelection2 = selection instanceof NodeSelection && selection.node?.type?.name === "fieldAnnotation";
352838
- if (domRects.length > 0 && !isFieldAnnotationSelection2)
353536
+ if (domRects.length > 0 && !isFieldAnnotationSelection2) {
352839
353537
  renderSelectionRects({
352840
353538
  localSelectionLayer: this.#localSelectionLayer,
352841
353539
  rects: domRects,
@@ -352843,6 +353541,9 @@ function print() { __p += __j.call(arguments, '') }
352843
353541
  pageGap: this.#layoutState.layout?.pageGap ?? 0,
352844
353542
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
352845
353543
  });
353544
+ if (selectionContainsNavigationTarget && activeNavigation?.scrollSettled)
353545
+ this.#finishSelectionNavigation(activeNavigation?.token);
353546
+ }
352846
353547
  } catch (error48) {
352847
353548
  if (process$1.env.NODE_ENV === "development")
352848
353549
  console.warn("[PresentationEditor] Failed to render selection rects:", error48);
@@ -353802,9 +354503,12 @@ function print() { __p += __j.call(arguments, '') }
353802
354503
  });
353803
354504
  if (!await this.scrollToPositionAsync(contentPos, {
353804
354505
  behavior: options.behavior ?? "auto",
353805
- block: options.block ?? "center"
354506
+ block: options.block ?? "center",
354507
+ shouldContinue: options.shouldContinue
353806
354508
  }))
353807
354509
  return false;
354510
+ if (!shouldContinueNavigation(options))
354511
+ return false;
353808
354512
  editor.commands?.setTextSelection?.({
353809
354513
  from: contentPos,
353810
354514
  to: contentPos
@@ -353826,9 +354530,10 @@ function print() { __p += __j.call(arguments, '') }
353826
354530
  return false;
353827
354531
  await this.scrollToPositionAsync(editor.state.selection.from, {
353828
354532
  behavior: options.behavior ?? "auto",
353829
- block: options.block ?? "center"
354533
+ block: options.block ?? "center",
354534
+ shouldContinue: options.shouldContinue
353830
354535
  });
353831
- return true;
354536
+ return shouldContinueNavigation(options);
353832
354537
  }
353833
354538
  async#navigateToBookmark(target) {
353834
354539
  const editor = this.#editor;
@@ -353859,64 +354564,113 @@ function print() { __p += __j.call(arguments, '') }
353859
354564
  const behavior = options.behavior ?? "auto";
353860
354565
  const block = options.block ?? "center";
353861
354566
  const navigationIds = this.#resolveTrackedChangeNavigationIds(entityId, storyKey);
354567
+ if (!shouldContinueNavigation(options))
354568
+ return false;
353862
354569
  if (storyKey && storyKey !== "body") {
353863
- for (const id2 of navigationIds)
354570
+ for (const id2 of navigationIds) {
354571
+ if (!shouldContinueNavigation(options))
354572
+ return false;
353864
354573
  if (this.#navigateToActiveStoryTrackedChange(id2, storyKey))
353865
354574
  return true;
354575
+ }
353866
354576
  for (const id2 of navigationIds)
353867
- if (await this.#activateTrackedChangeStorySurface(id2, storyKey, preferredPageIndex)) {
353868
- for (const activeId of navigationIds)
354577
+ if (await this.#activateTrackedChangeStorySurface(id2, storyKey, preferredPageIndex, options)) {
354578
+ if (!shouldContinueNavigation(options))
354579
+ return false;
354580
+ for (const activeId of navigationIds) {
354581
+ if (!shouldContinueNavigation(options))
354582
+ return false;
353869
354583
  if (this.#navigateToActiveStoryTrackedChange(activeId, storyKey))
353870
354584
  return true;
354585
+ }
353871
354586
  }
353872
- for (const id2 of navigationIds)
354587
+ for (const id2 of navigationIds) {
354588
+ if (!shouldContinueNavigation(options))
354589
+ return false;
353873
354590
  if (await this.#scrollToRenderedTrackedChange(id2, storyKey, preferredPageIndex, {
353874
354591
  behavior,
353875
- block
354592
+ block,
354593
+ shouldContinue: options.shouldContinue
353876
354594
  }))
353877
354595
  return true;
354596
+ }
353878
354597
  return false;
353879
354598
  }
354599
+ this.exitActiveStorySurface();
353880
354600
  const setCursorById = editor.commands?.setCursorById;
353881
- if (typeof setCursorById === "function") {
353882
- for (const id2 of navigationIds)
354601
+ for (const id2 of navigationIds) {
354602
+ if (!shouldContinueNavigation(options))
354603
+ return false;
354604
+ const selection = resolveTrackedChangeNavigationSelection(editor, id2);
354605
+ if (!selection)
354606
+ continue;
354607
+ const setTextSelection$1 = editor.commands?.setTextSelection;
354608
+ if (!await this.scrollToPositionAsync(selection.from, {
354609
+ behavior,
354610
+ block,
354611
+ shouldContinue: options.shouldContinue
354612
+ }) || !shouldContinueNavigation(options))
354613
+ return false;
354614
+ if (typeof setTextSelection$1 !== "function" || setTextSelection$1(selection) !== true)
354615
+ continue;
354616
+ editor.view?.focus?.();
354617
+ this.#scheduleNavigatedSelectionRender(selection.from);
354618
+ return true;
354619
+ }
354620
+ if (typeof setCursorById === "function")
354621
+ for (const id2 of navigationIds) {
354622
+ if (!shouldContinueNavigation(options))
354623
+ return false;
353883
354624
  if (setCursorById(id2, { preferredActiveThreadId: id2 })) {
353884
- await this.scrollToPositionAsync(editor.state.selection.from, {
354625
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
353885
354626
  behavior,
353886
- block
353887
- });
354627
+ block,
354628
+ shouldContinue: options.shouldContinue
354629
+ }) || !shouldContinueNavigation(options))
354630
+ return false;
354631
+ editor.view?.focus?.();
354632
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
353888
354633
  return true;
353889
354634
  }
353890
- }
354635
+ }
353891
354636
  const resolved = navigationIds.map((id2) => resolveTrackedChange(editor, id2)).find(Boolean);
353892
354637
  if (!resolved) {
353893
354638
  for (const id2 of navigationIds)
353894
354639
  if (await this.#scrollToRenderedTrackedChange(id2, undefined, preferredPageIndex, {
353895
354640
  behavior,
353896
- block
354641
+ block,
354642
+ shouldContinue: options.shouldContinue
353897
354643
  }))
353898
354644
  return true;
353899
354645
  return false;
353900
354646
  }
353901
354647
  if (typeof setCursorById === "function" && resolved.rawId !== entityId) {
354648
+ if (!shouldContinueNavigation(options))
354649
+ return false;
353902
354650
  if (setCursorById(resolved.rawId, { preferredActiveThreadId: resolved.rawId })) {
353903
- await this.scrollToPositionAsync(editor.state.selection.from, {
354651
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
353904
354652
  behavior,
353905
- block
353906
- });
354653
+ block,
354654
+ shouldContinue: options.shouldContinue
354655
+ }) || !shouldContinueNavigation(options))
354656
+ return false;
354657
+ editor.view?.focus?.();
354658
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
353907
354659
  return true;
353908
354660
  }
353909
354661
  }
353910
354662
  if (!await this.scrollToPositionAsync(resolved.from, {
353911
354663
  behavior,
353912
- block
353913
- }))
354664
+ block,
354665
+ shouldContinue: options.shouldContinue
354666
+ }) || !shouldContinueNavigation(options))
353914
354667
  return false;
353915
354668
  editor.commands?.setTextSelection?.({
353916
354669
  from: resolved.from,
353917
354670
  to: resolved.from
353918
354671
  });
353919
354672
  editor.view?.focus?.();
354673
+ this.#scheduleNavigatedSelectionRender(resolved.from);
353920
354674
  return true;
353921
354675
  }
353922
354676
  #resolveTrackedChangeNavigationIds(entityId, storyKey) {
@@ -353952,7 +354706,7 @@ function print() { __p += __j.call(arguments, '') }
353952
354706
  } catch {}
353953
354707
  return ids;
353954
354708
  }
353955
- async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex) {
354709
+ async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex, options = {}) {
353956
354710
  let locator = null;
353957
354711
  try {
353958
354712
  locator = parseStoryKey(storyKey);
@@ -353961,15 +354715,23 @@ function print() { __p += __j.call(arguments, '') }
353961
354715
  }
353962
354716
  if (!locator || locator.storyType === "body")
353963
354717
  return false;
354718
+ if (!shouldContinueNavigation(options))
354719
+ return false;
353964
354720
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
353965
354721
  if (!candidate)
353966
354722
  return false;
354723
+ if (!shouldContinueNavigation(options))
354724
+ return false;
353967
354725
  const rect = candidate.getBoundingClientRect();
353968
354726
  const clientX = rect.left + Math.max(rect.width / 2, 1);
353969
354727
  const clientY = rect.top + Math.max(rect.height / 2, 1);
353970
354728
  const pageIndex = this.#resolveRenderedPageIndexForElement(candidate);
354729
+ if (!shouldContinueNavigation(options))
354730
+ return false;
353971
354731
  if (locator.storyType === "footnote" || locator.storyType === "endnote") {
353972
354732
  try {
354733
+ if (!shouldContinueNavigation(options))
354734
+ return false;
353973
354735
  if (!this.#activateRenderedNoteSession({
353974
354736
  storyType: locator.storyType,
353975
354737
  noteId: locator.noteId
@@ -353982,7 +354744,7 @@ function print() { __p += __j.call(arguments, '') }
353982
354744
  } catch {
353983
354745
  return false;
353984
354746
  }
353985
- return this.#waitForTrackedChangeStorySurface(storyKey);
354747
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
353986
354748
  }
353987
354749
  if (locator.storyType !== "headerFooterPart")
353988
354750
  return false;
@@ -353991,21 +354753,27 @@ function print() { __p += __j.call(arguments, '') }
353991
354753
  const region = this.#hitTestHeaderFooterRegion(clientX, clientY, pageIndex, pageLocalY);
353992
354754
  if (!region)
353993
354755
  return false;
354756
+ if (!shouldContinueNavigation(options))
354757
+ return false;
353994
354758
  this.#activateHeaderFooterRegion(region, {
353995
354759
  clientX,
353996
354760
  clientY,
353997
354761
  pageIndex,
353998
354762
  source: "programmatic"
353999
354763
  });
354000
- return this.#waitForTrackedChangeStorySurface(storyKey);
354764
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
354001
354765
  }
354002
- async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500) {
354766
+ async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500, options = {}) {
354003
354767
  const deadline = Date.now() + timeoutMs;
354004
354768
  while (Date.now() < deadline) {
354769
+ if (!shouldContinueNavigation(options))
354770
+ return false;
354005
354771
  if (this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey)
354006
354772
  return true;
354007
354773
  await new Promise((resolve2) => setTimeout(resolve2, 16));
354008
354774
  }
354775
+ if (!shouldContinueNavigation(options))
354776
+ return false;
354009
354777
  return this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey;
354010
354778
  }
354011
354779
  async#activateBookmarkStorySurface(storyKey) {
@@ -354143,6 +354911,12 @@ function print() { __p += __j.call(arguments, '') }
354143
354911
  return false;
354144
354912
  const sessionEditor = activeSurface.editor;
354145
354913
  const setCursorById = sessionEditor.commands?.setCursorById;
354914
+ const navigationSelection = resolveTrackedChangeNavigationSelection(sessionEditor, entityId);
354915
+ const setTextSelection$1 = sessionEditor.commands?.setTextSelection;
354916
+ if (navigationSelection && typeof setTextSelection$1 === "function" && setTextSelection$1(navigationSelection) === true) {
354917
+ this.#focusAndRevealActiveStorySelection(sessionEditor);
354918
+ return true;
354919
+ }
354146
354920
  if (typeof setCursorById === "function" && setCursorById(entityId, { preferredActiveThreadId: entityId })) {
354147
354921
  this.#focusAndRevealActiveStorySelection(sessionEditor);
354148
354922
  return true;
@@ -354180,6 +354954,8 @@ function print() { __p += __j.call(arguments, '') }
354180
354954
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
354181
354955
  if (!candidate)
354182
354956
  return false;
354957
+ if (!shouldContinueNavigation(options))
354958
+ return false;
354183
354959
  try {
354184
354960
  candidate.scrollIntoView({
354185
354961
  behavior: options.behavior ?? "auto",
@@ -355121,11 +355897,11 @@ function print() { __p += __j.call(arguments, '') }
355121
355897
  ]);
355122
355898
  });
355123
355899
 
355124
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-NCPalg_h.es.js
355900
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BjToI9WN.es.js
355125
355901
  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;
355126
- var init_create_super_doc_ui_NCPalg_h_es = __esm(() => {
355127
- init_SuperConverter_Du0apG1R_es();
355128
- init_create_headless_toolbar_BNcguDpP_es();
355902
+ var init_create_super_doc_ui_BjToI9WN_es = __esm(() => {
355903
+ init_SuperConverter_DQ2wMaLK_es();
355904
+ init_create_headless_toolbar_BhSfQYaO_es();
355129
355905
  DEFAULT_TEXT_ALIGN_OPTIONS = [
355130
355906
  {
355131
355907
  label: "Left",
@@ -355403,6 +356179,9 @@ var init_create_super_doc_ui_NCPalg_h_es = __esm(() => {
355403
356179
  }));
355404
356180
  });
355405
356181
 
356182
+ // ../../packages/superdoc/dist/chunks/ui-CGB3qmy3.es.js
356183
+ var init_ui_CGB3qmy3_es = () => {};
356184
+
355406
356185
  // ../../packages/superdoc/dist/chunks/zipper-BxRAi0-5.es.js
355407
356186
  var import_jszip_min3;
355408
356187
  var init_zipper_BxRAi0_5_es = __esm(() => {
@@ -355413,16 +356192,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
355413
356192
 
355414
356193
  // ../../packages/superdoc/dist/super-editor.es.js
355415
356194
  var init_super_editor_es = __esm(() => {
355416
- init_src_bGJhSgx__es();
355417
- init_SuperConverter_Du0apG1R_es();
356195
+ init_src_CR8eXLKh_es();
356196
+ init_SuperConverter_DQ2wMaLK_es();
355418
356197
  init_jszip_C49i9kUs_es();
355419
356198
  init_xml_js_CqGKpaft_es();
355420
- init_create_headless_toolbar_BNcguDpP_es();
356199
+ init_create_headless_toolbar_BhSfQYaO_es();
355421
356200
  init_constants_D9qj59G2_es();
355422
356201
  init_unified_BDuVPlMu_es();
355423
356202
  init_DocxZipper_BzS208BW_es();
355424
- init_ui_BMYSpkne_es();
355425
- init_create_super_doc_ui_NCPalg_h_es();
356203
+ init_create_super_doc_ui_BjToI9WN_es();
356204
+ init_ui_CGB3qmy3_es();
355426
356205
  init_eventemitter3_UwU_CLPU_es();
355427
356206
  init_errors_C_DoKMoN_es();
355428
356207
  init_zipper_BxRAi0_5_es();
@@ -456842,14 +457621,12 @@ var handlePassthroughNode2 = (params3) => {
456842
457621
  const originalElementsSource = originalXml.elements;
456843
457622
  const originalElements = originalElementsSource ? carbonCopy2(originalElementsSource) : [];
456844
457623
  const childElements = Array.isArray(node4.elements) ? node4.elements : [];
456845
- let childContent = [];
456846
457624
  if (childElements.length && params3.nodeListHandler?.handler) {
456847
- const childParams = {
457625
+ params3.nodeListHandler.handler({
456848
457626
  ...params3,
456849
457627
  nodes: childElements,
456850
457628
  path: [...params3.path || [], node4]
456851
- };
456852
- childContent = params3.nodeListHandler.handler(childParams) || [];
457629
+ });
456853
457630
  }
456854
457631
  if (originalElements?.length) {
456855
457632
  originalXml.elements = originalElements;
@@ -456861,7 +457638,7 @@ var handlePassthroughNode2 = (params3) => {
456861
457638
  originalXml
456862
457639
  },
456863
457640
  marks: [],
456864
- content: childContent
457641
+ content: undefined
456865
457642
  };
456866
457643
  return {
456867
457644
  nodes: [passthroughNode],
@@ -492406,20 +493183,16 @@ function readBlockId2(node4) {
492406
493183
  function mapRawChangeIdsToCanonical2(editor, rawIds) {
492407
493184
  if (rawIds.length === 0)
492408
493185
  return rawIds;
492409
- let grouped;
493186
+ let canonicalIdByAlias;
492410
493187
  try {
492411
- grouped = groupTrackedChanges2(editor);
493188
+ canonicalIdByAlias = buildTrackedChangeCanonicalIdMap2(editor);
492412
493189
  } catch {
492413
493190
  return [];
492414
493191
  }
492415
- const rawToCanonical = new Map;
492416
- for (const change of grouped) {
492417
- rawToCanonical.set(change.rawId, change.id);
492418
- }
492419
493192
  const seen = new Set;
492420
493193
  const out = [];
492421
493194
  for (const raw of rawIds) {
492422
- const canonical = rawToCanonical.get(raw);
493195
+ const canonical = canonicalIdByAlias.get(raw);
492423
493196
  if (!canonical)
492424
493197
  continue;
492425
493198
  if (seen.has(canonical))