@superdoc-dev/mcp 0.12.0-next.42 → 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 +823 -96
  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();
@@ -213925,7 +214007,7 @@ var init_remark_gfm_DCND_V_3_es = __esm(() => {
213925
214007
  init_remark_gfm_BUJjZJLy_es();
213926
214008
  });
213927
214009
 
213928
- // ../../packages/superdoc/dist/chunks/src-DfMY3HP9.es.js
214010
+ // ../../packages/superdoc/dist/chunks/src-CR8eXLKh.es.js
213929
214011
  function deleteProps(obj, propOrProps) {
213930
214012
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
213931
214013
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -238408,19 +238490,16 @@ function readBlockId(node2) {
238408
238490
  function mapRawChangeIdsToCanonical(editor, rawIds) {
238409
238491
  if (rawIds.length === 0)
238410
238492
  return rawIds;
238411
- let grouped;
238493
+ let canonicalIdByAlias;
238412
238494
  try {
238413
- grouped = groupTrackedChanges(editor);
238495
+ canonicalIdByAlias = buildTrackedChangeCanonicalIdMap(editor);
238414
238496
  } catch {
238415
238497
  return [];
238416
238498
  }
238417
- const rawToCanonical = /* @__PURE__ */ new Map;
238418
- for (const change of grouped)
238419
- rawToCanonical.set(change.rawId, change.id);
238420
238499
  const seen = /* @__PURE__ */ new Set;
238421
238500
  const out = [];
238422
238501
  for (const raw of rawIds) {
238423
- const canonical = rawToCanonical.get(raw);
238502
+ const canonical = canonicalIdByAlias.get(raw);
238424
238503
  if (!canonical)
238425
238504
  continue;
238426
238505
  if (seen.has(canonical))
@@ -267527,7 +267606,16 @@ function safeCleanup(fn2, context) {
267527
267606
  console.warn(`[PresentationEditor] ${context} cleanup failed:`, error48);
267528
267607
  }
267529
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
+ }
267530
267617
  function createHiddenHost(doc$12, widthPx) {
267618
+ ensureHiddenHostStylesheet(doc$12);
267531
267619
  const wrapper = doc$12.createElement("div");
267532
267620
  wrapper.className = "presentation-editor__hidden-host-wrapper";
267533
267621
  wrapper.style.setProperty("position", "fixed");
@@ -268749,24 +268837,33 @@ function renderSelectionRects({ localSelectionLayer, rects, pageHeight, pageGap,
268749
268837
  localSelectionLayer.appendChild(highlight);
268750
268838
  });
268751
268839
  }
268752
- function renderCaretOverlay({ localSelectionLayer, caretLayout, convertPageLocalToOverlayCoords: convertPageLocalToOverlayCoords$1 }) {
268753
- const coords = convertPageLocalToOverlayCoords$1(caretLayout.pageIndex, caretLayout.x, caretLayout.y);
268754
- if (!coords)
268755
- return;
268756
- const finalHeight = Math.max(1, caretLayout.height);
268757
- 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");
268758
268842
  if (!caretEl)
268759
- return;
268843
+ return null;
268760
268844
  caretEl.className = "presentation-editor__selection-caret";
268761
268845
  caretEl.style.position = "absolute";
268762
- caretEl.style.left = `${coords.x}px`;
268763
- caretEl.style.top = `${coords.y}px`;
268846
+ caretEl.style.left = `${left$1}px`;
268847
+ caretEl.style.top = `${top$1}px`;
268764
268848
  caretEl.style.width = "2px";
268765
- caretEl.style.height = `${finalHeight}px`;
268849
+ caretEl.style.height = `${Math.max(1, height)}px`;
268766
268850
  caretEl.style.backgroundColor = "#000000";
268767
268851
  caretEl.style.borderRadius = "1px";
268768
268852
  caretEl.style.boxShadow = "0 0 0 1px rgba(255, 255, 255, 0.92)";
268769
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;
268770
268867
  localSelectionLayer.appendChild(caretEl);
268771
268868
  }
268772
268869
  function computeTableCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom }, pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
@@ -274876,6 +274973,9 @@ function serializePerIdNumbering(order$1, numberById, formatById) {
274876
274973
  }
274877
274974
  return parts.join(";");
274878
274975
  }
274976
+ function shouldContinueNavigation(options) {
274977
+ return options.shouldContinue?.() !== false;
274978
+ }
274879
274979
  function escapeAttrValue(value) {
274880
274980
  const cssApi = typeof globalThis === "object" && globalThis && "CSS" in globalThis ? globalThis.CSS : undefined;
274881
274981
  if (typeof cssApi?.escape === "function")
@@ -286276,7 +286376,7 @@ var Node$13 = class Node$14 {
286276
286376
  const pendingDeadKeyPlaceholder = TrackChangesBasePluginKey.getState(state)?.pendingDeadKeyPlaceholder ?? null;
286277
286377
  const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta4) => !ALLOWED_META_KEYS.has(meta4));
286278
286378
  const isBlockIdentityRepair = Boolean(tr.getMeta("superdoc/block-identity-repair"));
286279
- 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) {
286280
286380
  if (pendingDeadKeyPlaceholder && !isCompositionTransaction(tr))
286281
286381
  mergeTrackChangesMeta(tr, { pendingDeadKeyPlaceholder: null });
286282
286382
  return tr;
@@ -291201,7 +291301,9 @@ var Node$13 = class Node$14 {
291201
291301
  if (!tr)
291202
291302
  return;
291203
291303
  view.dispatch?.(closeHistory(tr));
291204
- }, handleEnter = (editor) => {
291304
+ }, isComposing = (editor) => editor?.view?.composing === true, handleEnter = (editor) => {
291305
+ if (isComposing(editor))
291306
+ return false;
291205
291307
  const { view } = editor;
291206
291308
  dispatchHistoryBoundary(view);
291207
291309
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -291212,6 +291314,8 @@ var Node$13 = class Node$14 {
291212
291314
  () => commands$1.splitBlock()
291213
291315
  ]);
291214
291316
  }, handleBackspace = (editor) => {
291317
+ if (isComposing(editor))
291318
+ return false;
291215
291319
  const { view } = editor;
291216
291320
  dispatchHistoryBoundary(view);
291217
291321
  return editor.commands.first(({ commands: commands$1, tr }) => [
@@ -291238,6 +291342,8 @@ var Node$13 = class Node$14 {
291238
291342
  () => commands$1.selectNodeBackward()
291239
291343
  ]);
291240
291344
  }, handleDelete2 = (editor) => {
291345
+ if (isComposing(editor))
291346
+ return false;
291241
291347
  const { view } = editor;
291242
291348
  dispatchHistoryBoundary(view);
291243
291349
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -291307,13 +291413,13 @@ var Node$13 = class Node$14 {
291307
291413
  }, handleInsertTextBeforeInput = (view, event, editor) => {
291308
291414
  const isInsertTextInput = event?.inputType === "insertText";
291309
291415
  const hasTextData = typeof event?.data === "string" && event.data.length > 0;
291310
- const isComposing = event?.isComposing === true;
291416
+ const isComposing$1 = event?.isComposing === true;
291311
291417
  recordStoryInputDebug(view, event, editor, "beforeinput:start", {
291312
291418
  isInsertTextInput,
291313
291419
  hasTextData,
291314
- isComposing
291420
+ isComposing: isComposing$1
291315
291421
  });
291316
- if (!isInsertTextInput || !hasTextData || isComposing) {
291422
+ if (!isInsertTextInput || !hasTextData || isComposing$1) {
291317
291423
  recordStoryInputDebug(view, event, editor, "beforeinput:skip");
291318
291424
  return false;
291319
291425
  }
@@ -293307,8 +293413,10 @@ var Node$13 = class Node$14 {
293307
293413
  }, Editor, token = (varName, fallback) => ({
293308
293414
  css: `var(${varName}, ${fallback})`,
293309
293415
  fallback
293310
- }), 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 {
293311
293417
  #activeCommentId = null;
293418
+ #activeTrackChangeIds = /* @__PURE__ */ new Set;
293419
+ #activeTrackChangeIdsKey = "";
293312
293420
  #container = null;
293313
293421
  setContainer(container) {
293314
293422
  this.#container = container;
@@ -293322,6 +293430,15 @@ var Node$13 = class Node$14 {
293322
293430
  this.#activeCommentId = commentId;
293323
293431
  return true;
293324
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
+ }
293325
293442
  apply() {
293326
293443
  const root3 = this.#container;
293327
293444
  if (!root3)
@@ -293393,16 +293510,27 @@ var Node$13 = class Node$14 {
293393
293510
  return null;
293394
293511
  }
293395
293512
  #applyTrackChangeFocus(root3) {
293396
- const activeId = this.#activeCommentId;
293513
+ const legacyActiveId = this.#activeCommentId;
293514
+ const activeTrackChangeIds = this.#activeTrackChangeIds;
293397
293515
  const elements = root3.querySelectorAll(TRACK_CHANGE_SELECTOR$1);
293398
293516
  for (let i3 = 0;i3 < elements.length; i3++) {
293399
293517
  const el = elements[i3];
293400
- if (activeId && el.dataset.trackChangeId === activeId)
293518
+ if (this.#matchesActiveTrackChange(el, activeTrackChangeIds, legacyActiveId))
293401
293519
  el.classList.add(TRACK_CHANGE_FOCUSED_CLASS);
293402
293520
  else
293403
293521
  el.classList.remove(TRACK_CHANGE_FOCUSED_CLASS);
293404
293522
  }
293405
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
+ }
293406
293534
  }, EXCLUDED_PLUGIN_KEY_REF_LIST, EXCLUDED_PLUGIN_KEY_REFS, EXCLUDED_PLUGIN_KEY_PREFIXES, TEXT_RANGE_BLOCK_SEP = `
293407
293535
  `, TEXT_RANGE_LEAF_SEP = `
293408
293536
  `, DecorationBridge = class DecorationBridge2 {
@@ -294107,6 +294235,9 @@ var Node$13 = class Node$14 {
294107
294235
  setActiveComment(commentId) {
294108
294236
  return this.#commentHighlightDecorator.setActiveComment(commentId);
294109
294237
  }
294238
+ setActiveTrackChangeIds(ids) {
294239
+ return this.#commentHighlightDecorator.setActiveTrackChangeIds(ids);
294240
+ }
294110
294241
  recordDecorationTransaction(transaction) {
294111
294242
  this.#decorationBridge.recordTransaction(transaction);
294112
294243
  }
@@ -307019,7 +307150,7 @@ menclose::after {
307019
307150
  this.#onRebuild();
307020
307151
  });
307021
307152
  }
307022
- }, 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 {
307023
307154
  #options;
307024
307155
  #remoteCursorState = /* @__PURE__ */ new Map;
307025
307156
  #remoteCursorElements = /* @__PURE__ */ new Map;
@@ -312905,18 +313036,18 @@ menclose::after {
312905
313036
  }
312906
313037
  `, movableObjectInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
312907
313038
  return typeof event?.source === "string" && INTERNAL_NOTE_COMMIT_SOURCES.has(event.source);
312908
- }, 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) => {
312909
313040
  if (!layoutDebugEnabled)
312910
313041
  return;
312911
313042
  console.log(...args$1);
312912
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;
312913
- var init_src_DfMY3HP9_es = __esm(() => {
313044
+ var init_src_CR8eXLKh_es = __esm(() => {
312914
313045
  init_rolldown_runtime_Bg48TavK_es();
312915
- init_SuperConverter_Du0apG1R_es();
313046
+ init_SuperConverter_DQ2wMaLK_es();
312916
313047
  init_jszip_C49i9kUs_es();
312917
313048
  init_xml_js_CqGKpaft_es();
312918
313049
  init_uuid_B2wVPhPi_es();
312919
- init_create_headless_toolbar_BNcguDpP_es();
313050
+ init_create_headless_toolbar_BhSfQYaO_es();
312920
313051
  init_constants_D9qj59G2_es();
312921
313052
  init_unified_BDuVPlMu_es();
312922
313053
  init_remark_gfm_BUJjZJLy_es();
@@ -340874,7 +341005,7 @@ function print() { __p += __j.call(arguments, '') }
340874
341005
  const activeIndex = exports_vue.ref(-1);
340875
341006
  const query = exports_vue.ref("");
340876
341007
  const inputDisplay = exports_vue.ref("");
340877
- const isComposing = exports_vue.ref(false);
341008
+ const isComposing$1 = exports_vue.ref(false);
340878
341009
  const menuPosition = exports_vue.ref({
340879
341010
  top: "0px",
340880
341011
  left: "0px",
@@ -341017,7 +341148,7 @@ function print() { __p += __j.call(arguments, '') }
341017
341148
  resetToApplied();
341018
341149
  };
341019
341150
  const onInput = (event) => {
341020
- if (isComposing.value)
341151
+ if (isComposing$1.value)
341021
341152
  return;
341022
341153
  const el = event.target;
341023
341154
  const typed = el.value;
@@ -341039,7 +341170,7 @@ function print() { __p += __j.call(arguments, '') }
341039
341170
  }
341040
341171
  };
341041
341172
  const onCompositionEnd = (event) => {
341042
- isComposing.value = false;
341173
+ isComposing$1.value = false;
341043
341174
  onInput(event);
341044
341175
  };
341045
341176
  const moveActive = (direction) => {
@@ -341090,7 +341221,7 @@ function print() { __p += __j.call(arguments, '') }
341090
341221
  return false;
341091
341222
  };
341092
341223
  const onKeydown = (event) => {
341093
- if (event.isComposing || isComposing.value || event.keyCode === 229)
341224
+ if (event.isComposing || isComposing$1.value || event.keyCode === 229)
341094
341225
  return;
341095
341226
  if (event.ctrlKey || event.metaKey || event.altKey)
341096
341227
  return;
@@ -341246,7 +341377,7 @@ function print() { __p += __j.call(arguments, '') }
341246
341377
  onBlur,
341247
341378
  onInput,
341248
341379
  onKeydown,
341249
- onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing.value = true),
341380
+ onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing$1.value = true),
341250
341381
  onCompositionend: onCompositionEnd
341251
341382
  }, null, 44, _hoisted_1$7)], 32),
341252
341383
  exports_vue.createElementVNode("button", {
@@ -345024,6 +345155,11 @@ function print() { __p += __j.call(arguments, '') }
345024
345155
  this.#trackDocumentOpen();
345025
345156
  }
345026
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;
345027
345163
  if (this.#renderer)
345028
345164
  this.#renderer.destroy();
345029
345165
  else if (this.view)
@@ -345664,6 +345800,8 @@ function print() { __p += __j.call(arguments, '') }
345664
345800
  state: this.state,
345665
345801
  handleClick: this.#handleNodeSelection.bind(this)
345666
345802
  });
345803
+ this.view?.dom?.addEventListener("compositionend", this.#handleDomCompositionEnd);
345804
+ this.view?.dom?.addEventListener("blur", this.#handleDomCompositionEnd);
345667
345805
  this.createNodeViews();
345668
345806
  }
345669
345807
  createNodeViews() {
@@ -345774,6 +345912,223 @@ function print() { __p += __j.call(arguments, '') }
345774
345912
  this.#dispatchTransaction(tr);
345775
345913
  }, 50);
345776
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
+ };
345777
346132
  #dispatchTransaction(transaction) {
345778
346133
  if (this.isDestroyed)
345779
346134
  return;
@@ -345792,13 +346147,21 @@ function print() { __p += __j.call(arguments, '') }
345792
346147
  const protectsExistingTrackedReviewState = transactionTouchesTrackedReviewState(prevState, transactionToApply);
345793
346148
  if (protectsExistingTrackedReviewState && skipTrackChanges)
345794
346149
  transactionToApply.setMeta("protectTrackedReviewState", true);
345795
- const shouldTrack = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges || protectsExistingTrackedReviewState;
346150
+ const shouldTrackForComposition = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges;
346151
+ const shouldTrack = shouldTrackForComposition || protectsExistingTrackedReviewState;
345796
346152
  if (!shouldTrack && directInsertionMutationCommentMeta && !transactionToApply.getMeta(TrackChangesBasePluginKey))
345797
346153
  transactionToApply.setMeta(TrackChangesBasePluginKey, directInsertionMutationCommentMeta);
345798
346154
  if (shouldTrack && forceTrackChanges && !this.options.user)
345799
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
+ }
345800
346163
  const trackedUser = this.options.user ?? {};
345801
- transactionToApply = shouldTrack ? trackedTransaction({
346164
+ transactionToApply = shouldTrack && !deferTrackingForComposition ? trackedTransaction({
345802
346165
  tr: transactionToApply,
345803
346166
  state: prevState,
345804
346167
  user: trackedUser,
@@ -345806,6 +346169,12 @@ function print() { __p += __j.call(arguments, '') }
345806
346169
  }) : transactionToApply;
345807
346170
  const { state: appliedState, transactions: appliedTransactions } = prevState.applyTransaction(transactionToApply);
345808
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();
345809
346178
  effectiveTransaction = appliedTransactions.find((t) => t.docChanged) ?? transactionToApply;
345810
346179
  } catch (error48) {
345811
346180
  if (forceTrackChanges)
@@ -348401,6 +348770,12 @@ function print() { __p += __j.call(arguments, '') }
348401
348770
  bottom: 72,
348402
348771
  left: 72
348403
348772
  };
348773
+ NAVIGATED_CARET_REPAIR_DELAYS_MS = [
348774
+ 120,
348775
+ 360,
348776
+ 900,
348777
+ 1300
348778
+ ];
348404
348779
  layoutDebugEnabled = typeof process$1 !== "undefined" && typeof process$1.env !== "undefined" && Boolean(process$1.env.SD_DEBUG_LAYOUT);
348405
348780
  GLOBAL_PERFORMANCE = typeof performance !== "undefined" ? performance : undefined;
348406
348781
  PresentationEditor = class PresentationEditor2 extends EventEmitter {
@@ -348475,8 +348850,15 @@ function print() { __p += __j.call(arguments, '') }
348475
348850
  #renderScheduled = false;
348476
348851
  #pendingDocChange = false;
348477
348852
  #focusScrollRafId = null;
348853
+ #selectionScrollSettleCleanup = null;
348854
+ #selectionNavigationToken = 0;
348855
+ #activeSelectionNavigation = null;
348478
348856
  #pendingMapping = null;
348479
348857
  #isRerendering = false;
348858
+ #isComposing = false;
348859
+ #compositionDeferralCleanup = [];
348860
+ #compositionTargetCleanup = [];
348861
+ #compositionTargetDom = null;
348480
348862
  #selectionSync = new SelectionSyncCoordinator;
348481
348863
  #fontGate = null;
348482
348864
  #fontResolver = createFontResolver();
@@ -348817,6 +349199,8 @@ function print() { __p += __j.call(arguments, '') }
348817
349199
  this.#setupPointerHandlers();
348818
349200
  this.#setupDragHandlers();
348819
349201
  this.#setupInputBridge();
349202
+ this.#setupCompositionDeferral();
349203
+ this.#refreshCompositionDeferralTarget();
348820
349204
  this.#syncTrackedChangesPreferences();
348821
349205
  this.#syncHeaderFooterTrackedChangesRenderConfig();
348822
349206
  this.#setupSemanticResizeObserver();
@@ -350422,6 +350806,7 @@ function print() { __p += __j.call(arguments, '') }
350422
350806
  const targetEl = this.#findElementAtPosition(pageEl, clampedPos);
350423
350807
  const elToScroll = targetEl ?? pageEl;
350424
350808
  const block = options.ifNeeded && targetEl && this.#isElementFullyVisibleInScrollContainer(targetEl) ? "nearest" : requestedBlock;
350809
+ this.#startSelectionNavigation(clampedPos);
350425
350810
  elToScroll.scrollIntoView({
350426
350811
  block,
350427
350812
  inline: "nearest",
@@ -350440,6 +350825,7 @@ function print() { __p += __j.call(arguments, '') }
350440
350825
  });
350441
350826
  this.#shouldScrollSelectionIntoView = false;
350442
350827
  this.#suppressSelectionScrollUntilRaf = false;
350828
+ this.#scheduleSelectionUpdateAfterScrollSettles();
350443
350829
  });
350444
350830
  }
350445
350831
  return true;
@@ -350522,6 +350908,164 @@ function print() { __p += __j.call(arguments, '') }
350522
350908
  }
350523
350909
  };
350524
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
+ }
350525
351069
  #findElementAtPosition(pageEl, pos) {
350526
351070
  const elements = Array.from(pageEl.querySelectorAll("[data-pm-start][data-pm-end]"));
350527
351071
  let bestMatch = null;
@@ -350545,6 +351089,8 @@ function print() { __p += __j.call(arguments, '') }
350545
351089
  return bestMatch;
350546
351090
  }
350547
351091
  async scrollToPositionAsync(pos, options = {}) {
351092
+ if (!shouldContinueNavigation(options))
351093
+ return false;
350548
351094
  if (this.scrollToPosition(pos, options))
350549
351095
  return true;
350550
351096
  const doc$12 = this.getActiveEditor()?.state?.doc;
@@ -350570,11 +351116,15 @@ function print() { __p += __j.call(arguments, '') }
350570
351116
  }
350571
351117
  if (pageIndex == null)
350572
351118
  return false;
351119
+ if (!shouldContinueNavigation(options))
351120
+ return false;
350573
351121
  this.#scrollPageIntoView(pageIndex);
350574
351122
  if (!await this.#waitForPageMount(pageIndex, { timeout: PresentationEditor2.ANCHOR_NAV_TIMEOUT_MS })) {
350575
351123
  console.warn(`[PresentationEditor] scrollToPositionAsync: Page ${pageIndex} failed to mount within timeout`);
350576
351124
  return false;
350577
351125
  }
351126
+ if (!shouldContinueNavigation(options))
351127
+ return false;
350578
351128
  return this.scrollToPosition(pos, {
350579
351129
  ...options,
350580
351130
  ifNeeded: false
@@ -350759,6 +351309,11 @@ function print() { __p += __j.call(arguments, '') }
350759
351309
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#focusScrollRafId);
350760
351310
  this.#focusScrollRafId = null;
350761
351311
  }, "Focus scroll RAF");
351312
+ if (this.#selectionScrollSettleCleanup)
351313
+ safeCleanup(() => {
351314
+ this.#selectionScrollSettleCleanup?.();
351315
+ }, "Selection scroll settle");
351316
+ this.#finishSelectionNavigation();
350762
351317
  if (this.#decorationSyncRafHandle != null)
350763
351318
  safeCleanup(() => {
350764
351319
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#decorationSyncRafHandle);
@@ -350813,6 +351368,7 @@ function print() { __p += __j.call(arguments, '') }
350813
351368
  this.#inputBridge?.notifyTargetChanged();
350814
351369
  this.#inputBridge?.destroy();
350815
351370
  this.#inputBridge = null;
351371
+ this.#teardownCompositionDeferral();
350816
351372
  if (this.#a11ySelectionAnnounceTimeout != null) {
350817
351373
  clearTimeout(this.#a11ySelectionAnnounceTimeout);
350818
351374
  this.#a11ySelectionAnnounceTimeout = null;
@@ -350946,6 +351502,12 @@ function print() { __p += __j.call(arguments, '') }
350946
351502
  #syncCommentHighlights() {
350947
351503
  this.#postPaintPipeline.applyCommentHighlights();
350948
351504
  }
351505
+ setActiveTrackChangeIds(ids) {
351506
+ const didChange = this.#postPaintPipeline.setActiveTrackChangeIds(ids);
351507
+ if (didChange)
351508
+ this.#syncInlineStyleLayers();
351509
+ return didChange;
351510
+ }
350949
351511
  #syncInlineStyleLayers() {
350950
351512
  const state = this.#editor?.view?.state;
350951
351513
  if (!state) {
@@ -351402,7 +351964,10 @@ function print() { __p += __j.call(arguments, '') }
351402
351964
  }
351403
351965
  #setupInputBridge() {
351404
351966
  this.#inputBridge?.destroy();
351405
- 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
+ }, {
351406
351971
  useWindowFallback: true,
351407
351972
  getTargetEditor: () => this.getActiveEditor()
351408
351973
  });
@@ -352038,6 +352603,70 @@ function print() { __p += __j.call(arguments, '') }
352038
352603
  this.#selectionSync.onLayoutStart();
352039
352604
  this.#scheduleRerender();
352040
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
+ }
352041
352670
  #scheduleRerender() {
352042
352671
  if (this.#renderScheduled)
352043
352672
  return;
@@ -352056,6 +352685,8 @@ function print() { __p += __j.call(arguments, '') }
352056
352685
  }
352057
352686
  if (!this.#pendingDocChange)
352058
352687
  return;
352688
+ if (this.#isComposing)
352689
+ return;
352059
352690
  this.#pendingDocChange = false;
352060
352691
  this.#isRerendering = true;
352061
352692
  const activeHfEditor = (this.#headerFooterSession?.session?.mode ?? "body") !== "body" ? this.#headerFooterSession?.activeEditor : null;
@@ -352842,9 +353473,22 @@ function print() { __p += __j.call(arguments, '') }
352842
353473
  }
352843
353474
  if (from$1 === to || isDragDropIndicatorActive) {
352844
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
+ }
352845
353486
  const caretLayout = this.#computeCaretLayoutRect(caretPos);
352846
- if (!caretLayout)
353487
+ if (!caretLayout) {
353488
+ if (isRenderingNavigatedCaret)
353489
+ this.#localSelectionLayer.innerHTML = "";
352847
353490
  return;
353491
+ }
352848
353492
  try {
352849
353493
  this.#localSelectionLayer.innerHTML = "";
352850
353494
  renderCaretOverlay({
@@ -352852,6 +353496,9 @@ function print() { __p += __j.call(arguments, '') }
352852
353496
  caretLayout,
352853
353497
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
352854
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);
352855
353502
  } catch (error48) {
352856
353503
  if (process$1.env.NODE_ENV === "development")
352857
353504
  console.warn("[PresentationEditor] Failed to render caret overlay:", error48);
@@ -352860,8 +353507,16 @@ function print() { __p += __j.call(arguments, '') }
352860
353507
  this.#scrollActiveEndIntoView(caretLayout.pageIndex);
352861
353508
  return;
352862
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();
352863
353516
  const domRects = this.#computeSelectionRectsFromDom(from$1, to);
352864
353517
  if (domRects == null) {
353518
+ if (selectionContainsNavigationTarget)
353519
+ this.#localSelectionLayer.innerHTML = "";
352865
353520
  debugLog("warn", "Local selection: DOM rect computation failed", {
352866
353521
  from: from$1,
352867
353522
  to
@@ -352878,7 +353533,7 @@ function print() { __p += __j.call(arguments, '') }
352878
353533
  try {
352879
353534
  this.#localSelectionLayer.innerHTML = "";
352880
353535
  const isFieldAnnotationSelection2 = selection instanceof NodeSelection && selection.node?.type?.name === "fieldAnnotation";
352881
- if (domRects.length > 0 && !isFieldAnnotationSelection2)
353536
+ if (domRects.length > 0 && !isFieldAnnotationSelection2) {
352882
353537
  renderSelectionRects({
352883
353538
  localSelectionLayer: this.#localSelectionLayer,
352884
353539
  rects: domRects,
@@ -352886,6 +353541,9 @@ function print() { __p += __j.call(arguments, '') }
352886
353541
  pageGap: this.#layoutState.layout?.pageGap ?? 0,
352887
353542
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
352888
353543
  });
353544
+ if (selectionContainsNavigationTarget && activeNavigation?.scrollSettled)
353545
+ this.#finishSelectionNavigation(activeNavigation?.token);
353546
+ }
352889
353547
  } catch (error48) {
352890
353548
  if (process$1.env.NODE_ENV === "development")
352891
353549
  console.warn("[PresentationEditor] Failed to render selection rects:", error48);
@@ -353845,9 +354503,12 @@ function print() { __p += __j.call(arguments, '') }
353845
354503
  });
353846
354504
  if (!await this.scrollToPositionAsync(contentPos, {
353847
354505
  behavior: options.behavior ?? "auto",
353848
- block: options.block ?? "center"
354506
+ block: options.block ?? "center",
354507
+ shouldContinue: options.shouldContinue
353849
354508
  }))
353850
354509
  return false;
354510
+ if (!shouldContinueNavigation(options))
354511
+ return false;
353851
354512
  editor.commands?.setTextSelection?.({
353852
354513
  from: contentPos,
353853
354514
  to: contentPos
@@ -353869,9 +354530,10 @@ function print() { __p += __j.call(arguments, '') }
353869
354530
  return false;
353870
354531
  await this.scrollToPositionAsync(editor.state.selection.from, {
353871
354532
  behavior: options.behavior ?? "auto",
353872
- block: options.block ?? "center"
354533
+ block: options.block ?? "center",
354534
+ shouldContinue: options.shouldContinue
353873
354535
  });
353874
- return true;
354536
+ return shouldContinueNavigation(options);
353875
354537
  }
353876
354538
  async#navigateToBookmark(target) {
353877
354539
  const editor = this.#editor;
@@ -353902,64 +354564,113 @@ function print() { __p += __j.call(arguments, '') }
353902
354564
  const behavior = options.behavior ?? "auto";
353903
354565
  const block = options.block ?? "center";
353904
354566
  const navigationIds = this.#resolveTrackedChangeNavigationIds(entityId, storyKey);
354567
+ if (!shouldContinueNavigation(options))
354568
+ return false;
353905
354569
  if (storyKey && storyKey !== "body") {
353906
- for (const id2 of navigationIds)
354570
+ for (const id2 of navigationIds) {
354571
+ if (!shouldContinueNavigation(options))
354572
+ return false;
353907
354573
  if (this.#navigateToActiveStoryTrackedChange(id2, storyKey))
353908
354574
  return true;
354575
+ }
353909
354576
  for (const id2 of navigationIds)
353910
- if (await this.#activateTrackedChangeStorySurface(id2, storyKey, preferredPageIndex)) {
353911
- 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;
353912
354583
  if (this.#navigateToActiveStoryTrackedChange(activeId, storyKey))
353913
354584
  return true;
354585
+ }
353914
354586
  }
353915
- for (const id2 of navigationIds)
354587
+ for (const id2 of navigationIds) {
354588
+ if (!shouldContinueNavigation(options))
354589
+ return false;
353916
354590
  if (await this.#scrollToRenderedTrackedChange(id2, storyKey, preferredPageIndex, {
353917
354591
  behavior,
353918
- block
354592
+ block,
354593
+ shouldContinue: options.shouldContinue
353919
354594
  }))
353920
354595
  return true;
354596
+ }
353921
354597
  return false;
353922
354598
  }
354599
+ this.exitActiveStorySurface();
353923
354600
  const setCursorById = editor.commands?.setCursorById;
353924
- if (typeof setCursorById === "function") {
353925
- 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;
353926
354624
  if (setCursorById(id2, { preferredActiveThreadId: id2 })) {
353927
- await this.scrollToPositionAsync(editor.state.selection.from, {
354625
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
353928
354626
  behavior,
353929
- block
353930
- });
354627
+ block,
354628
+ shouldContinue: options.shouldContinue
354629
+ }) || !shouldContinueNavigation(options))
354630
+ return false;
354631
+ editor.view?.focus?.();
354632
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
353931
354633
  return true;
353932
354634
  }
353933
- }
354635
+ }
353934
354636
  const resolved = navigationIds.map((id2) => resolveTrackedChange(editor, id2)).find(Boolean);
353935
354637
  if (!resolved) {
353936
354638
  for (const id2 of navigationIds)
353937
354639
  if (await this.#scrollToRenderedTrackedChange(id2, undefined, preferredPageIndex, {
353938
354640
  behavior,
353939
- block
354641
+ block,
354642
+ shouldContinue: options.shouldContinue
353940
354643
  }))
353941
354644
  return true;
353942
354645
  return false;
353943
354646
  }
353944
354647
  if (typeof setCursorById === "function" && resolved.rawId !== entityId) {
354648
+ if (!shouldContinueNavigation(options))
354649
+ return false;
353945
354650
  if (setCursorById(resolved.rawId, { preferredActiveThreadId: resolved.rawId })) {
353946
- await this.scrollToPositionAsync(editor.state.selection.from, {
354651
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
353947
354652
  behavior,
353948
- block
353949
- });
354653
+ block,
354654
+ shouldContinue: options.shouldContinue
354655
+ }) || !shouldContinueNavigation(options))
354656
+ return false;
354657
+ editor.view?.focus?.();
354658
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
353950
354659
  return true;
353951
354660
  }
353952
354661
  }
353953
354662
  if (!await this.scrollToPositionAsync(resolved.from, {
353954
354663
  behavior,
353955
- block
353956
- }))
354664
+ block,
354665
+ shouldContinue: options.shouldContinue
354666
+ }) || !shouldContinueNavigation(options))
353957
354667
  return false;
353958
354668
  editor.commands?.setTextSelection?.({
353959
354669
  from: resolved.from,
353960
354670
  to: resolved.from
353961
354671
  });
353962
354672
  editor.view?.focus?.();
354673
+ this.#scheduleNavigatedSelectionRender(resolved.from);
353963
354674
  return true;
353964
354675
  }
353965
354676
  #resolveTrackedChangeNavigationIds(entityId, storyKey) {
@@ -353995,7 +354706,7 @@ function print() { __p += __j.call(arguments, '') }
353995
354706
  } catch {}
353996
354707
  return ids;
353997
354708
  }
353998
- async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex) {
354709
+ async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex, options = {}) {
353999
354710
  let locator = null;
354000
354711
  try {
354001
354712
  locator = parseStoryKey(storyKey);
@@ -354004,15 +354715,23 @@ function print() { __p += __j.call(arguments, '') }
354004
354715
  }
354005
354716
  if (!locator || locator.storyType === "body")
354006
354717
  return false;
354718
+ if (!shouldContinueNavigation(options))
354719
+ return false;
354007
354720
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
354008
354721
  if (!candidate)
354009
354722
  return false;
354723
+ if (!shouldContinueNavigation(options))
354724
+ return false;
354010
354725
  const rect = candidate.getBoundingClientRect();
354011
354726
  const clientX = rect.left + Math.max(rect.width / 2, 1);
354012
354727
  const clientY = rect.top + Math.max(rect.height / 2, 1);
354013
354728
  const pageIndex = this.#resolveRenderedPageIndexForElement(candidate);
354729
+ if (!shouldContinueNavigation(options))
354730
+ return false;
354014
354731
  if (locator.storyType === "footnote" || locator.storyType === "endnote") {
354015
354732
  try {
354733
+ if (!shouldContinueNavigation(options))
354734
+ return false;
354016
354735
  if (!this.#activateRenderedNoteSession({
354017
354736
  storyType: locator.storyType,
354018
354737
  noteId: locator.noteId
@@ -354025,7 +354744,7 @@ function print() { __p += __j.call(arguments, '') }
354025
354744
  } catch {
354026
354745
  return false;
354027
354746
  }
354028
- return this.#waitForTrackedChangeStorySurface(storyKey);
354747
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
354029
354748
  }
354030
354749
  if (locator.storyType !== "headerFooterPart")
354031
354750
  return false;
@@ -354034,21 +354753,27 @@ function print() { __p += __j.call(arguments, '') }
354034
354753
  const region = this.#hitTestHeaderFooterRegion(clientX, clientY, pageIndex, pageLocalY);
354035
354754
  if (!region)
354036
354755
  return false;
354756
+ if (!shouldContinueNavigation(options))
354757
+ return false;
354037
354758
  this.#activateHeaderFooterRegion(region, {
354038
354759
  clientX,
354039
354760
  clientY,
354040
354761
  pageIndex,
354041
354762
  source: "programmatic"
354042
354763
  });
354043
- return this.#waitForTrackedChangeStorySurface(storyKey);
354764
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
354044
354765
  }
354045
- async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500) {
354766
+ async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500, options = {}) {
354046
354767
  const deadline = Date.now() + timeoutMs;
354047
354768
  while (Date.now() < deadline) {
354769
+ if (!shouldContinueNavigation(options))
354770
+ return false;
354048
354771
  if (this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey)
354049
354772
  return true;
354050
354773
  await new Promise((resolve2) => setTimeout(resolve2, 16));
354051
354774
  }
354775
+ if (!shouldContinueNavigation(options))
354776
+ return false;
354052
354777
  return this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey;
354053
354778
  }
354054
354779
  async#activateBookmarkStorySurface(storyKey) {
@@ -354186,6 +354911,12 @@ function print() { __p += __j.call(arguments, '') }
354186
354911
  return false;
354187
354912
  const sessionEditor = activeSurface.editor;
354188
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
+ }
354189
354920
  if (typeof setCursorById === "function" && setCursorById(entityId, { preferredActiveThreadId: entityId })) {
354190
354921
  this.#focusAndRevealActiveStorySelection(sessionEditor);
354191
354922
  return true;
@@ -354223,6 +354954,8 @@ function print() { __p += __j.call(arguments, '') }
354223
354954
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
354224
354955
  if (!candidate)
354225
354956
  return false;
354957
+ if (!shouldContinueNavigation(options))
354958
+ return false;
354226
354959
  try {
354227
354960
  candidate.scrollIntoView({
354228
354961
  behavior: options.behavior ?? "auto",
@@ -355164,11 +355897,11 @@ function print() { __p += __j.call(arguments, '') }
355164
355897
  ]);
355165
355898
  });
355166
355899
 
355167
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-oSlpT6HI.es.js
355900
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BjToI9WN.es.js
355168
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;
355169
- var init_create_super_doc_ui_oSlpT6HI_es = __esm(() => {
355170
- init_SuperConverter_Du0apG1R_es();
355171
- 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();
355172
355905
  DEFAULT_TEXT_ALIGN_OPTIONS = [
355173
355906
  {
355174
355907
  label: "Left",
@@ -355459,15 +356192,15 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
355459
356192
 
355460
356193
  // ../../packages/superdoc/dist/super-editor.es.js
355461
356194
  var init_super_editor_es = __esm(() => {
355462
- init_src_DfMY3HP9_es();
355463
- init_SuperConverter_Du0apG1R_es();
356195
+ init_src_CR8eXLKh_es();
356196
+ init_SuperConverter_DQ2wMaLK_es();
355464
356197
  init_jszip_C49i9kUs_es();
355465
356198
  init_xml_js_CqGKpaft_es();
355466
- init_create_headless_toolbar_BNcguDpP_es();
356199
+ init_create_headless_toolbar_BhSfQYaO_es();
355467
356200
  init_constants_D9qj59G2_es();
355468
356201
  init_unified_BDuVPlMu_es();
355469
356202
  init_DocxZipper_BzS208BW_es();
355470
- init_create_super_doc_ui_oSlpT6HI_es();
356203
+ init_create_super_doc_ui_BjToI9WN_es();
355471
356204
  init_ui_CGB3qmy3_es();
355472
356205
  init_eventemitter3_UwU_CLPU_es();
355473
356206
  init_errors_C_DoKMoN_es();
@@ -456888,14 +457621,12 @@ var handlePassthroughNode2 = (params3) => {
456888
457621
  const originalElementsSource = originalXml.elements;
456889
457622
  const originalElements = originalElementsSource ? carbonCopy2(originalElementsSource) : [];
456890
457623
  const childElements = Array.isArray(node4.elements) ? node4.elements : [];
456891
- let childContent = [];
456892
457624
  if (childElements.length && params3.nodeListHandler?.handler) {
456893
- const childParams = {
457625
+ params3.nodeListHandler.handler({
456894
457626
  ...params3,
456895
457627
  nodes: childElements,
456896
457628
  path: [...params3.path || [], node4]
456897
- };
456898
- childContent = params3.nodeListHandler.handler(childParams) || [];
457629
+ });
456899
457630
  }
456900
457631
  if (originalElements?.length) {
456901
457632
  originalXml.elements = originalElements;
@@ -456907,7 +457638,7 @@ var handlePassthroughNode2 = (params3) => {
456907
457638
  originalXml
456908
457639
  },
456909
457640
  marks: [],
456910
- content: childContent
457641
+ content: undefined
456911
457642
  };
456912
457643
  return {
456913
457644
  nodes: [passthroughNode],
@@ -492452,20 +493183,16 @@ function readBlockId2(node4) {
492452
493183
  function mapRawChangeIdsToCanonical2(editor, rawIds) {
492453
493184
  if (rawIds.length === 0)
492454
493185
  return rawIds;
492455
- let grouped;
493186
+ let canonicalIdByAlias;
492456
493187
  try {
492457
- grouped = groupTrackedChanges2(editor);
493188
+ canonicalIdByAlias = buildTrackedChangeCanonicalIdMap2(editor);
492458
493189
  } catch {
492459
493190
  return [];
492460
493191
  }
492461
- const rawToCanonical = new Map;
492462
- for (const change of grouped) {
492463
- rawToCanonical.set(change.rawId, change.id);
492464
- }
492465
493192
  const seen = new Set;
492466
493193
  const out = [];
492467
493194
  for (const raw of rawIds) {
492468
- const canonical = rawToCanonical.get(raw);
493195
+ const canonical = canonicalIdByAlias.get(raw);
492469
493196
  if (!canonical)
492470
493197
  continue;
492471
493198
  if (seen.has(canonical))