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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +817 -84
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -69157,7 +69157,7 @@ var init_remark_gfm_BUJjZJLy_es = __esm(() => {
69157
69157
  emptyOptions2 = {};
69158
69158
  });
69159
69159
 
69160
- // ../../packages/superdoc/dist/chunks/SuperConverter-Du0apG1R.es.js
69160
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DQ2wMaLK.es.js
69161
69161
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
69162
69162
  const fieldValue = extension$1.config[field];
69163
69163
  if (typeof fieldValue === "function")
@@ -114147,6 +114147,91 @@ function getTrackedMarkText(editor, item) {
114147
114147
  return nodeText;
114148
114148
  return editor.state.doc.textBetween(item.from, item.to, " ", "");
114149
114149
  }
114150
+ function rawMarkMatchesChange(mark, change) {
114151
+ return trackedMarkMatchesChange(mark.mark, change);
114152
+ }
114153
+ function trackedMarkMatchesChange(mark, change) {
114154
+ const attrs = mark.attrs ?? {};
114155
+ const rawId = toNonEmptyString(attrs.id);
114156
+ if (!rawId)
114157
+ return false;
114158
+ const markType = mark.type.name;
114159
+ const groupKey = getTrackedChangeGroupKey(attrs, markType, rawId);
114160
+ return groupKey === change.rawId || groupKey === change.id || rawId === change.commandRawId || rawId === change.id;
114161
+ }
114162
+ function findMarkedTextNodeNavigationSelection(editor, change) {
114163
+ let multiCharacterSelection = null;
114164
+ let singleCharacterSelection = null;
114165
+ try {
114166
+ editor.state.doc.nodesBetween(change.from, change.to, (node3, pos) => {
114167
+ if (multiCharacterSelection)
114168
+ return false;
114169
+ if (!node3.isText)
114170
+ return true;
114171
+ if (!(Array.isArray(node3.marks) ? node3.marks : []).some((mark) => trackedMarkMatchesChange(mark, change)))
114172
+ return false;
114173
+ const textLength = typeof node3.text === "string" ? node3.text.length : node3.nodeSize;
114174
+ if (textLength > 1) {
114175
+ const caret = pos + 1;
114176
+ multiCharacterSelection = {
114177
+ from: caret,
114178
+ to: caret
114179
+ };
114180
+ return false;
114181
+ }
114182
+ if (!singleCharacterSelection && textLength > 0)
114183
+ singleCharacterSelection = {
114184
+ from: pos,
114185
+ to: pos + textLength
114186
+ };
114187
+ return false;
114188
+ });
114189
+ } catch {
114190
+ return null;
114191
+ }
114192
+ return multiCharacterSelection ?? singleCharacterSelection;
114193
+ }
114194
+ function resolveTrackedChangeNavigationSelection(editor, id2) {
114195
+ const change = resolveTrackedChange(editor, id2);
114196
+ if (!change || change.structural)
114197
+ return null;
114198
+ const markedTextSelection = findMarkedTextNodeNavigationSelection(editor, change);
114199
+ if (markedTextSelection)
114200
+ return markedTextSelection;
114201
+ const matchingMarks = getRawTrackedMarks(editor).filter((mark) => rawMarkMatchesChange(mark, change)).filter((mark) => Number.isFinite(mark.from) && Number.isFinite(mark.to) && mark.to > mark.from).sort((a, b) => {
114202
+ if (a.from !== b.from)
114203
+ return a.from - b.from;
114204
+ return a.to - b.to;
114205
+ });
114206
+ const multiCharacterMark = matchingMarks.find((mark) => mark.to - mark.from > 1);
114207
+ if (multiCharacterMark) {
114208
+ const pos = multiCharacterMark.from + 1;
114209
+ return {
114210
+ from: pos,
114211
+ to: pos
114212
+ };
114213
+ }
114214
+ const singleCharacterMark = matchingMarks[0];
114215
+ if (singleCharacterMark)
114216
+ return {
114217
+ from: singleCharacterMark.from,
114218
+ to: singleCharacterMark.to
114219
+ };
114220
+ if (change.to > change.from) {
114221
+ if (change.to - change.from > 1) {
114222
+ const pos = change.from + 1;
114223
+ return {
114224
+ from: pos,
114225
+ to: pos
114226
+ };
114227
+ }
114228
+ return {
114229
+ from: change.from,
114230
+ to: change.to
114231
+ };
114232
+ }
114233
+ return null;
114234
+ }
114150
114235
  function groupTrackedChanges(editor) {
114151
114236
  const currentDoc = editor.state.doc;
114152
114237
  const cached = groupedCache.get(editor);
@@ -130804,15 +130889,12 @@ var isRegExp = (value) => {
130804
130889
  const originalElementsSource = originalXml.elements;
130805
130890
  const originalElements = originalElementsSource ? carbonCopy(originalElementsSource) : [];
130806
130891
  const childElements = Array.isArray(node3.elements) ? node3.elements : [];
130807
- let childContent = [];
130808
- if (childElements.length && params3.nodeListHandler?.handler) {
130809
- const childParams = {
130892
+ if (childElements.length && params3.nodeListHandler?.handler)
130893
+ params3.nodeListHandler.handler({
130810
130894
  ...params3,
130811
130895
  nodes: childElements,
130812
130896
  path: [...params3.path || [], node3]
130813
- };
130814
- childContent = params3.nodeListHandler.handler(childParams) || [];
130815
- }
130897
+ });
130816
130898
  if (originalElements?.length)
130817
130899
  originalXml.elements = originalElements;
130818
130900
  return {
@@ -130823,7 +130905,7 @@ var isRegExp = (value) => {
130823
130905
  originalXml
130824
130906
  },
130825
130907
  marks: [],
130826
- content: childContent
130908
+ content: undefined
130827
130909
  }],
130828
130910
  consumed: 1
130829
130911
  };
@@ -137234,7 +137316,7 @@ Docs: https://docs.superdoc.dev/getting-started/fonts`);
137234
137316
  state.kern = kernNode.attributes["w:val"];
137235
137317
  }
137236
137318
  }, SuperConverter;
137237
- var init_SuperConverter_Du0apG1R_es = __esm(() => {
137319
+ var init_SuperConverter_DQ2wMaLK_es = __esm(() => {
137238
137320
  init_rolldown_runtime_Bg48TavK_es();
137239
137321
  init_jszip_C49i9kUs_es();
137240
137322
  init_xml_js_CqGKpaft_es();
@@ -166243,7 +166325,7 @@ var init_SuperConverter_Du0apG1R_es = __esm(() => {
166243
166325
  };
166244
166326
  });
166245
166327
 
166246
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BNcguDpP.es.js
166328
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BhSfQYaO.es.js
166247
166329
  function parseSizeUnit(val = "0") {
166248
166330
  const length3 = val.toString() || "0";
166249
166331
  const value = Number.parseFloat(length3);
@@ -176986,9 +177068,9 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, MARK_KEYS, STEP_OP_CATALOG_UNFROZEN2, P
176986
177068
  }
176987
177069
  };
176988
177070
  };
176989
- var init_create_headless_toolbar_BNcguDpP_es = __esm(() => {
177071
+ var init_create_headless_toolbar_BhSfQYaO_es = __esm(() => {
176990
177072
  init_rolldown_runtime_Bg48TavK_es();
176991
- init_SuperConverter_Du0apG1R_es();
177073
+ init_SuperConverter_DQ2wMaLK_es();
176992
177074
  init_jszip_C49i9kUs_es();
176993
177075
  init_uuid_B2wVPhPi_es();
176994
177076
  init_constants_D9qj59G2_es();
@@ -227082,7 +227164,7 @@ var init_remark_gfm_DCND_V_3_es = __esm(() => {
227082
227164
  init_remark_gfm_BUJjZJLy_es();
227083
227165
  });
227084
227166
 
227085
- // ../../packages/superdoc/dist/chunks/src-DfMY3HP9.es.js
227167
+ // ../../packages/superdoc/dist/chunks/src-CR8eXLKh.es.js
227086
227168
  function deleteProps(obj, propOrProps) {
227087
227169
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
227088
227170
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -251698,19 +251780,16 @@ function readBlockId(node3) {
251698
251780
  function mapRawChangeIdsToCanonical(editor, rawIds) {
251699
251781
  if (rawIds.length === 0)
251700
251782
  return rawIds;
251701
- let grouped;
251783
+ let canonicalIdByAlias;
251702
251784
  try {
251703
- grouped = groupTrackedChanges(editor);
251785
+ canonicalIdByAlias = buildTrackedChangeCanonicalIdMap(editor);
251704
251786
  } catch {
251705
251787
  return [];
251706
251788
  }
251707
- const rawToCanonical = /* @__PURE__ */ new Map;
251708
- for (const change of grouped)
251709
- rawToCanonical.set(change.rawId, change.id);
251710
251789
  const seen = /* @__PURE__ */ new Set;
251711
251790
  const out = [];
251712
251791
  for (const raw of rawIds) {
251713
- const canonical = rawToCanonical.get(raw);
251792
+ const canonical = canonicalIdByAlias.get(raw);
251714
251793
  if (!canonical)
251715
251794
  continue;
251716
251795
  if (seen.has(canonical))
@@ -280817,7 +280896,16 @@ function safeCleanup(fn2, context) {
280817
280896
  console.warn(`[PresentationEditor] ${context} cleanup failed:`, error3);
280818
280897
  }
280819
280898
  }
280899
+ function ensureHiddenHostStylesheet(doc$12) {
280900
+ if (doc$12.getElementById(HIDDEN_HOST_STYLE_ID))
280901
+ return;
280902
+ const style2 = doc$12.createElement("style");
280903
+ style2.id = HIDDEN_HOST_STYLE_ID;
280904
+ style2.textContent = ".presentation-editor__hidden-host .sd-paragraph-content { display: block; }";
280905
+ (doc$12.head ?? doc$12.documentElement)?.appendChild(style2);
280906
+ }
280820
280907
  function createHiddenHost(doc$12, widthPx) {
280908
+ ensureHiddenHostStylesheet(doc$12);
280821
280909
  const wrapper = doc$12.createElement("div");
280822
280910
  wrapper.className = "presentation-editor__hidden-host-wrapper";
280823
280911
  wrapper.style.setProperty("position", "fixed");
@@ -282039,24 +282127,33 @@ function renderSelectionRects({ localSelectionLayer, rects, pageHeight, pageGap,
282039
282127
  localSelectionLayer.appendChild(highlight);
282040
282128
  });
282041
282129
  }
282042
- function renderCaretOverlay({ localSelectionLayer, caretLayout, convertPageLocalToOverlayCoords: convertPageLocalToOverlayCoords$1 }) {
282043
- const coords = convertPageLocalToOverlayCoords$1(caretLayout.pageIndex, caretLayout.x, caretLayout.y);
282044
- if (!coords)
282045
- return;
282046
- const finalHeight = Math.max(1, caretLayout.height);
282047
- const caretEl = localSelectionLayer.ownerDocument?.createElement("div");
282130
+ function createCaretElement(doc$12, { left: left$1, top: top$1, height }) {
282131
+ const caretEl = doc$12?.createElement("div");
282048
282132
  if (!caretEl)
282049
- return;
282133
+ return null;
282050
282134
  caretEl.className = "presentation-editor__selection-caret";
282051
282135
  caretEl.style.position = "absolute";
282052
- caretEl.style.left = `${coords.x}px`;
282053
- caretEl.style.top = `${coords.y}px`;
282136
+ caretEl.style.left = `${left$1}px`;
282137
+ caretEl.style.top = `${top$1}px`;
282054
282138
  caretEl.style.width = "2px";
282055
- caretEl.style.height = `${finalHeight}px`;
282139
+ caretEl.style.height = `${Math.max(1, height)}px`;
282056
282140
  caretEl.style.backgroundColor = "#000000";
282057
282141
  caretEl.style.borderRadius = "1px";
282058
282142
  caretEl.style.boxShadow = "0 0 0 1px rgba(255, 255, 255, 0.92)";
282059
282143
  caretEl.style.pointerEvents = "none";
282144
+ return caretEl;
282145
+ }
282146
+ function renderCaretOverlay({ localSelectionLayer, caretLayout, convertPageLocalToOverlayCoords: convertPageLocalToOverlayCoords$1 }) {
282147
+ const coords = convertPageLocalToOverlayCoords$1(caretLayout.pageIndex, caretLayout.x, caretLayout.y);
282148
+ if (!coords)
282149
+ return;
282150
+ const caretEl = createCaretElement(localSelectionLayer.ownerDocument, {
282151
+ left: coords.x,
282152
+ top: coords.y,
282153
+ height: caretLayout.height
282154
+ });
282155
+ if (!caretEl)
282156
+ return;
282060
282157
  localSelectionLayer.appendChild(caretEl);
282061
282158
  }
282062
282159
  function computeTableCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom }, pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
@@ -288166,6 +288263,9 @@ function serializePerIdNumbering(order$1, numberById, formatById) {
288166
288263
  }
288167
288264
  return parts.join(";");
288168
288265
  }
288266
+ function shouldContinueNavigation(options) {
288267
+ return options.shouldContinue?.() !== false;
288268
+ }
288169
288269
  function escapeAttrValue(value) {
288170
288270
  const cssApi = typeof globalThis === "object" && globalThis && "CSS" in globalThis ? globalThis.CSS : undefined;
288171
288271
  if (typeof cssApi?.escape === "function")
@@ -299566,7 +299666,7 @@ var Node$13 = class Node$14 {
299566
299666
  const pendingDeadKeyPlaceholder = TrackChangesBasePluginKey.getState(state)?.pendingDeadKeyPlaceholder ?? null;
299567
299667
  const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta2) => !ALLOWED_META_KEYS.has(meta2));
299568
299668
  const isBlockIdentityRepair = Boolean(tr.getMeta("superdoc/block-identity-repair"));
299569
- if (ySyncMeta?.isChangeOrigin || !tr.steps.length || isBlockIdentityRepair || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
299669
+ if (ySyncMeta?.isChangeOrigin || !tr.steps.length || isBlockIdentityRepair || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey) || tr.getMeta("compositionTrackingFlush") === true) {
299570
299670
  if (pendingDeadKeyPlaceholder && !isCompositionTransaction(tr))
299571
299671
  mergeTrackChangesMeta(tr, { pendingDeadKeyPlaceholder: null });
299572
299672
  return tr;
@@ -304491,7 +304591,9 @@ var Node$13 = class Node$14 {
304491
304591
  if (!tr)
304492
304592
  return;
304493
304593
  view.dispatch?.(closeHistory(tr));
304494
- }, handleEnter = (editor) => {
304594
+ }, isComposing = (editor) => editor?.view?.composing === true, handleEnter = (editor) => {
304595
+ if (isComposing(editor))
304596
+ return false;
304495
304597
  const { view } = editor;
304496
304598
  dispatchHistoryBoundary(view);
304497
304599
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -304502,6 +304604,8 @@ var Node$13 = class Node$14 {
304502
304604
  () => commands$1.splitBlock()
304503
304605
  ]);
304504
304606
  }, handleBackspace = (editor) => {
304607
+ if (isComposing(editor))
304608
+ return false;
304505
304609
  const { view } = editor;
304506
304610
  dispatchHistoryBoundary(view);
304507
304611
  return editor.commands.first(({ commands: commands$1, tr }) => [
@@ -304528,6 +304632,8 @@ var Node$13 = class Node$14 {
304528
304632
  () => commands$1.selectNodeBackward()
304529
304633
  ]);
304530
304634
  }, handleDelete2 = (editor) => {
304635
+ if (isComposing(editor))
304636
+ return false;
304531
304637
  const { view } = editor;
304532
304638
  dispatchHistoryBoundary(view);
304533
304639
  return editor.commands.first(({ commands: commands$1 }) => [
@@ -304597,13 +304703,13 @@ var Node$13 = class Node$14 {
304597
304703
  }, handleInsertTextBeforeInput = (view, event, editor) => {
304598
304704
  const isInsertTextInput = event?.inputType === "insertText";
304599
304705
  const hasTextData = typeof event?.data === "string" && event.data.length > 0;
304600
- const isComposing = event?.isComposing === true;
304706
+ const isComposing$1 = event?.isComposing === true;
304601
304707
  recordStoryInputDebug(view, event, editor, "beforeinput:start", {
304602
304708
  isInsertTextInput,
304603
304709
  hasTextData,
304604
- isComposing
304710
+ isComposing: isComposing$1
304605
304711
  });
304606
- if (!isInsertTextInput || !hasTextData || isComposing) {
304712
+ if (!isInsertTextInput || !hasTextData || isComposing$1) {
304607
304713
  recordStoryInputDebug(view, event, editor, "beforeinput:skip");
304608
304714
  return false;
304609
304715
  }
@@ -306597,8 +306703,10 @@ var Node$13 = class Node$14 {
306597
306703
  }, Editor, token = (varName, fallback) => ({
306598
306704
  css: `var(${varName}, ${fallback})`,
306599
306705
  fallback
306600
- }), H, TRACK_CHANGE_FOCUSED_CLASS = "track-change-focused", COMMENT_HIGHLIGHT_SELECTOR$1 = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR$1 = "[data-track-change-id]", CommentHighlightDecorator = class {
306706
+ }), H, TRACK_CHANGE_FOCUSED_CLASS = "track-change-focused", COMMENT_HIGHLIGHT_SELECTOR$1 = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR$1 = "[data-track-change-id], [data-track-change-ids]", CommentHighlightDecorator = class {
306601
306707
  #activeCommentId = null;
306708
+ #activeTrackChangeIds = /* @__PURE__ */ new Set;
306709
+ #activeTrackChangeIdsKey = "";
306602
306710
  #container = null;
306603
306711
  setContainer(container) {
306604
306712
  this.#container = container;
@@ -306612,6 +306720,15 @@ var Node$13 = class Node$14 {
306612
306720
  this.#activeCommentId = commentId;
306613
306721
  return true;
306614
306722
  }
306723
+ setActiveTrackChangeIds(ids) {
306724
+ const nextIds = Array.from(new Set(ids.filter((id2) => id2.length > 0)));
306725
+ const nextKey = nextIds.join("\x00");
306726
+ if (this.#activeTrackChangeIdsKey === nextKey)
306727
+ return false;
306728
+ this.#activeTrackChangeIdsKey = nextKey;
306729
+ this.#activeTrackChangeIds = new Set(nextIds);
306730
+ return true;
306731
+ }
306615
306732
  apply() {
306616
306733
  const root3 = this.#container;
306617
306734
  if (!root3)
@@ -306683,16 +306800,27 @@ var Node$13 = class Node$14 {
306683
306800
  return null;
306684
306801
  }
306685
306802
  #applyTrackChangeFocus(root3) {
306686
- const activeId = this.#activeCommentId;
306803
+ const legacyActiveId = this.#activeCommentId;
306804
+ const activeTrackChangeIds = this.#activeTrackChangeIds;
306687
306805
  const elements = root3.querySelectorAll(TRACK_CHANGE_SELECTOR$1);
306688
306806
  for (let i3 = 0;i3 < elements.length; i3++) {
306689
306807
  const el = elements[i3];
306690
- if (activeId && el.dataset.trackChangeId === activeId)
306808
+ if (this.#matchesActiveTrackChange(el, activeTrackChangeIds, legacyActiveId))
306691
306809
  el.classList.add(TRACK_CHANGE_FOCUSED_CLASS);
306692
306810
  else
306693
306811
  el.classList.remove(TRACK_CHANGE_FOCUSED_CLASS);
306694
306812
  }
306695
306813
  }
306814
+ #matchesActiveTrackChange(el, activeTrackChangeIds, legacyActiveId) {
306815
+ const ids = [
306816
+ el.dataset.trackChangeId,
306817
+ el.dataset.trackChangePreferredTargetId,
306818
+ ...parseCommaSeparated(el.dataset.trackChangeIds)
306819
+ ].filter((id2) => Boolean(id2));
306820
+ if (legacyActiveId && ids.includes(legacyActiveId))
306821
+ return true;
306822
+ return ids.some((id2) => activeTrackChangeIds.has(id2));
306823
+ }
306696
306824
  }, EXCLUDED_PLUGIN_KEY_REF_LIST, EXCLUDED_PLUGIN_KEY_REFS, EXCLUDED_PLUGIN_KEY_PREFIXES, TEXT_RANGE_BLOCK_SEP = `
306697
306825
  `, TEXT_RANGE_LEAF_SEP = `
306698
306826
  `, DecorationBridge = class DecorationBridge2 {
@@ -307397,6 +307525,9 @@ var Node$13 = class Node$14 {
307397
307525
  setActiveComment(commentId) {
307398
307526
  return this.#commentHighlightDecorator.setActiveComment(commentId);
307399
307527
  }
307528
+ setActiveTrackChangeIds(ids) {
307529
+ return this.#commentHighlightDecorator.setActiveTrackChangeIds(ids);
307530
+ }
307400
307531
  recordDecorationTransaction(transaction) {
307401
307532
  this.#decorationBridge.recordTransaction(transaction);
307402
307533
  }
@@ -320309,7 +320440,7 @@ menclose::after {
320309
320440
  this.#onRebuild();
320310
320441
  });
320311
320442
  }
320312
- }, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, log2 = (...args$1) => {}, CLASS, FOOTNOTE_MARKER_DATA_ATTR = "data-sd-footnote-number", DEFAULT_MARKER_FONT_FAMILY$1 = "Arial", DEFAULT_MARKER_FONT_SIZE$1 = 12, SCROLL_DEBOUNCE_MS = 32, DEFAULT_STALE_TIMEOUT_MS, THROTTLE_MS = 16, RemoteCursorManager = class {
320443
+ }, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, log2 = (...args$1) => {}, CLASS, FOOTNOTE_MARKER_DATA_ATTR = "data-sd-footnote-number", DEFAULT_MARKER_FONT_FAMILY$1 = "Arial", DEFAULT_MARKER_FONT_SIZE$1 = 12, HIDDEN_HOST_STYLE_ID = "sd-presentation-hidden-host-styles", SCROLL_DEBOUNCE_MS = 32, DEFAULT_STALE_TIMEOUT_MS, THROTTLE_MS = 16, RemoteCursorManager = class {
320313
320444
  #options;
320314
320445
  #remoteCursorState = /* @__PURE__ */ new Map;
320315
320446
  #remoteCursorElements = /* @__PURE__ */ new Map;
@@ -326195,18 +326326,18 @@ menclose::after {
326195
326326
  }
326196
326327
  `, movableObjectInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
326197
326328
  return typeof event?.source === "string" && INTERNAL_NOTE_COMMIT_SOURCES.has(event.source);
326198
- }, DOCUMENT_RELS_PART_ID = "word/_rels/document.xml.rels", DEFAULT_PAGE_SIZE, DEFAULT_MARGINS, DEFAULT_PAGE_GAP = 24, DEFAULT_HORIZONTAL_PAGE_GAP = 20, layoutDebugEnabled, perfLog = (...args$1) => {
326329
+ }, DOCUMENT_RELS_PART_ID = "word/_rels/document.xml.rels", DEFAULT_PAGE_SIZE, DEFAULT_MARGINS, DEFAULT_PAGE_GAP = 24, DEFAULT_HORIZONTAL_PAGE_GAP = 20, NAVIGATED_CARET_REPAIR_DELAYS_MS, NAVIGATED_CARET_DRIFT_TOLERANCE_PX = 3, NAVIGATED_CARET_MAX_REPAIR_ATTEMPTS = 3, SELECTION_SCROLL_SETTLE_RENDER_DELAY_MS = 120, SELECTION_SCROLL_SETTLE_FINALIZE_DELAY_MS = 900, layoutDebugEnabled, perfLog = (...args$1) => {
326199
326330
  if (!layoutDebugEnabled)
326200
326331
  return;
326201
326332
  console.log(...args$1);
326202
326333
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
326203
- var init_src_DfMY3HP9_es = __esm(() => {
326334
+ var init_src_CR8eXLKh_es = __esm(() => {
326204
326335
  init_rolldown_runtime_Bg48TavK_es();
326205
- init_SuperConverter_Du0apG1R_es();
326336
+ init_SuperConverter_DQ2wMaLK_es();
326206
326337
  init_jszip_C49i9kUs_es();
326207
326338
  init_xml_js_CqGKpaft_es();
326208
326339
  init_uuid_B2wVPhPi_es();
326209
- init_create_headless_toolbar_BNcguDpP_es();
326340
+ init_create_headless_toolbar_BhSfQYaO_es();
326210
326341
  init_constants_D9qj59G2_es();
326211
326342
  init_unified_BDuVPlMu_es();
326212
326343
  init_remark_gfm_BUJjZJLy_es();
@@ -354164,7 +354295,7 @@ function print() { __p += __j.call(arguments, '') }
354164
354295
  const activeIndex = exports_vue.ref(-1);
354165
354296
  const query2 = exports_vue.ref("");
354166
354297
  const inputDisplay = exports_vue.ref("");
354167
- const isComposing = exports_vue.ref(false);
354298
+ const isComposing$1 = exports_vue.ref(false);
354168
354299
  const menuPosition = exports_vue.ref({
354169
354300
  top: "0px",
354170
354301
  left: "0px",
@@ -354307,7 +354438,7 @@ function print() { __p += __j.call(arguments, '') }
354307
354438
  resetToApplied();
354308
354439
  };
354309
354440
  const onInput = (event) => {
354310
- if (isComposing.value)
354441
+ if (isComposing$1.value)
354311
354442
  return;
354312
354443
  const el = event.target;
354313
354444
  const typed = el.value;
@@ -354329,7 +354460,7 @@ function print() { __p += __j.call(arguments, '') }
354329
354460
  }
354330
354461
  };
354331
354462
  const onCompositionEnd = (event) => {
354332
- isComposing.value = false;
354463
+ isComposing$1.value = false;
354333
354464
  onInput(event);
354334
354465
  };
354335
354466
  const moveActive = (direction) => {
@@ -354380,7 +354511,7 @@ function print() { __p += __j.call(arguments, '') }
354380
354511
  return false;
354381
354512
  };
354382
354513
  const onKeydown = (event) => {
354383
- if (event.isComposing || isComposing.value || event.keyCode === 229)
354514
+ if (event.isComposing || isComposing$1.value || event.keyCode === 229)
354384
354515
  return;
354385
354516
  if (event.ctrlKey || event.metaKey || event.altKey)
354386
354517
  return;
@@ -354536,7 +354667,7 @@ function print() { __p += __j.call(arguments, '') }
354536
354667
  onBlur,
354537
354668
  onInput,
354538
354669
  onKeydown,
354539
- onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing.value = true),
354670
+ onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing$1.value = true),
354540
354671
  onCompositionend: onCompositionEnd
354541
354672
  }, null, 44, _hoisted_1$7)], 32),
354542
354673
  exports_vue.createElementVNode("button", {
@@ -358314,6 +358445,11 @@ function print() { __p += __j.call(arguments, '') }
358314
358445
  this.#trackDocumentOpen();
358315
358446
  }
358316
358447
  unmount() {
358448
+ this.view?.dom?.removeEventListener("compositionend", this.#handleDomCompositionEnd);
358449
+ this.view?.dom?.removeEventListener("blur", this.#handleDomCompositionEnd);
358450
+ this.#deferredCompositionRange = null;
358451
+ this.#deferredCompositionDeletions = [];
358452
+ this.#deferredCompositionId = undefined;
358317
358453
  if (this.#renderer)
358318
358454
  this.#renderer.destroy();
358319
358455
  else if (this.view)
@@ -358954,6 +359090,8 @@ function print() { __p += __j.call(arguments, '') }
358954
359090
  state: this.state,
358955
359091
  handleClick: this.#handleNodeSelection.bind(this)
358956
359092
  });
359093
+ this.view?.dom?.addEventListener("compositionend", this.#handleDomCompositionEnd);
359094
+ this.view?.dom?.addEventListener("blur", this.#handleDomCompositionEnd);
358957
359095
  this.createNodeViews();
358958
359096
  }
358959
359097
  createNodeViews() {
@@ -359064,6 +359202,223 @@ function print() { __p += __j.call(arguments, '') }
359064
359202
  this.#dispatchTransaction(tr);
359065
359203
  }, 50);
359066
359204
  }
359205
+ #deferredCompositionRange = null;
359206
+ #deferredCompositionDeletions = [];
359207
+ #deferredCompositionId = undefined;
359208
+ #canDeferCompositionTracking(tr, state) {
359209
+ if (!tr.steps.length)
359210
+ return false;
359211
+ const range = this.#deferredCompositionRange;
359212
+ for (let index2 = 0;index2 < tr.steps.length; index2 += 1) {
359213
+ const step3 = tr.steps[index2];
359214
+ if (!(step3 instanceof ReplaceStep))
359215
+ return false;
359216
+ if (step3.from < step3.to && (!range || step3.from < range.from || step3.to > range.to)) {
359217
+ const sourceDoc = tr.docs[index2] ?? state.doc;
359218
+ if (!this.#canRestoreDeferredCompositionDeletion(step3, sourceDoc))
359219
+ return false;
359220
+ }
359221
+ }
359222
+ return true;
359223
+ }
359224
+ #canRestoreDeferredCompositionDeletion(step3, doc$12) {
359225
+ if (step3.slice.size === 0)
359226
+ return false;
359227
+ let hasText = false;
359228
+ let hasUnsupportedContent = false;
359229
+ doc$12.nodesBetween(step3.from, step3.to, (node3) => {
359230
+ if (hasUnsupportedContent)
359231
+ return false;
359232
+ if (node3.type.name.includes("table") || node3.isLeaf && !node3.isText) {
359233
+ hasUnsupportedContent = true;
359234
+ return false;
359235
+ }
359236
+ if (node3.isText && node3.text)
359237
+ hasText = true;
359238
+ return true;
359239
+ });
359240
+ return hasText && !hasUnsupportedContent;
359241
+ }
359242
+ #collectDeferredCompositionDeletions(tr) {
359243
+ const deletions = [];
359244
+ const range = this.#deferredCompositionRange;
359245
+ tr.steps.forEach((step3, index2) => {
359246
+ if (!(step3 instanceof ReplaceStep) || step3.from >= step3.to)
359247
+ return;
359248
+ if (range && step3.from >= range.from && step3.to <= range.to)
359249
+ return;
359250
+ const sourceDoc = tr.docs[index2] ?? this.state.doc;
359251
+ if (!this.#canRestoreDeferredCompositionDeletion(step3, sourceDoc))
359252
+ return;
359253
+ const rest = tr.mapping.slice(index2 + 1);
359254
+ deletions.push({
359255
+ pos: rest.map(step3.from + step3.slice.size, 1),
359256
+ slice: sourceDoc.slice(step3.from, step3.to)
359257
+ });
359258
+ });
359259
+ return deletions;
359260
+ }
359261
+ #replacesWithinDeferredRange(tr) {
359262
+ const range = this.#deferredCompositionRange;
359263
+ if (!range || !tr.steps.length)
359264
+ return false;
359265
+ return tr.steps.every((step3) => step3 instanceof ReplaceStep && step3.from < step3.to && step3.from >= range.from && step3.to <= range.to);
359266
+ }
359267
+ #updateDeferredCompositionRange(applied, deferredSource) {
359268
+ if (!this.#deferredCompositionRange && !deferredSource)
359269
+ return;
359270
+ let range = this.#deferredCompositionRange;
359271
+ for (const tr of applied) {
359272
+ if (range) {
359273
+ const from$1 = tr.mapping.map(range.from, -1);
359274
+ const to = tr.mapping.map(range.to, 1);
359275
+ range = from$1 < to ? {
359276
+ from: from$1,
359277
+ to
359278
+ } : null;
359279
+ }
359280
+ if (tr === deferredSource)
359281
+ tr.steps.forEach((step3, index2) => {
359282
+ if (!(step3 instanceof ReplaceStep) || step3.slice.size === 0)
359283
+ return;
359284
+ const rest = tr.mapping.slice(index2 + 1);
359285
+ const from$1 = rest.map(step3.from, -1);
359286
+ const to = rest.map(step3.from + step3.slice.size, 1);
359287
+ range = range ? {
359288
+ from: Math.min(range.from, from$1),
359289
+ to: Math.max(range.to, to)
359290
+ } : {
359291
+ from: from$1,
359292
+ to
359293
+ };
359294
+ });
359295
+ }
359296
+ this.#deferredCompositionRange = range;
359297
+ }
359298
+ #mapDeferredCompositionDeletions(applied) {
359299
+ if (!this.#deferredCompositionDeletions.length)
359300
+ return;
359301
+ this.#deferredCompositionDeletions = this.#mapCompositionDeletions(this.#deferredCompositionDeletions, applied);
359302
+ }
359303
+ #mapCompositionDeletions(deletions, applied) {
359304
+ if (!deletions.length || !applied.length)
359305
+ return deletions;
359306
+ return deletions.map((deletion) => {
359307
+ let pos = deletion.pos;
359308
+ for (const tr of applied)
359309
+ pos = tr.mapping.map(pos, -1);
359310
+ return {
359311
+ ...deletion,
359312
+ pos
359313
+ };
359314
+ });
359315
+ }
359316
+ #flushDeferredCompositionTracking() {
359317
+ const range = this.#deferredCompositionRange;
359318
+ const deletions = this.#deferredCompositionDeletions;
359319
+ const compositionId = this.#deferredCompositionId;
359320
+ this.#deferredCompositionRange = null;
359321
+ this.#deferredCompositionDeletions = [];
359322
+ this.#deferredCompositionId = undefined;
359323
+ if (!range || this.isDestroyed || !this.view)
359324
+ return;
359325
+ const state = this.state;
359326
+ if (!TrackChangesBasePluginKey.getState(state)?.isTrackChangesActive)
359327
+ return;
359328
+ const from$1 = Math.max(0, Math.min(range.from, state.doc.content.size));
359329
+ const to = Math.max(from$1, Math.min(range.to, state.doc.content.size));
359330
+ if (from$1 >= to)
359331
+ return;
359332
+ const insertMarkType = state.schema.marks[TrackInsertMarkName];
359333
+ if (!insertMarkType)
359334
+ return;
359335
+ let fullyMarked = true;
359336
+ state.doc.nodesBetween(from$1, to, (node3) => {
359337
+ if (node3.isText && !insertMarkType.isInSet(node3.marks))
359338
+ fullyMarked = false;
359339
+ return !node3.isText;
359340
+ });
359341
+ if (fullyMarked && !deletions.length)
359342
+ return;
359343
+ const tr = state.tr;
359344
+ const fixedTimeTo10Mins = Math.floor(Date.now() / 600000) * 600000;
359345
+ const date = new Date(fixedTimeTo10Mins).toISOString();
359346
+ const user = this.options.user ?? {};
359347
+ let insertedMark = fullyMarked ? null : markInsertion({
359348
+ tr,
359349
+ from: from$1,
359350
+ to,
359351
+ user,
359352
+ date
359353
+ });
359354
+ const replacementGroupId = insertedMark && deletions.length && this.options.trackedChanges?.replacements !== "independent" ? insertedMark.attrs.id : "";
359355
+ if (insertedMark && replacementGroupId) {
359356
+ const replacementInsertMark = insertedMark.type.create({
359357
+ ...insertedMark.attrs,
359358
+ changeType: CanonicalChangeType.Replacement,
359359
+ replacementGroupId,
359360
+ replacementSideId: `${replacementGroupId}#inserted`
359361
+ });
359362
+ tr.removeMark(from$1, to, insertedMark);
359363
+ tr.addMark(from$1, to, replacementInsertMark);
359364
+ insertedMark = replacementInsertMark;
359365
+ }
359366
+ let deletionMeta = null;
359367
+ deletions.forEach((deletion) => {
359368
+ const deleteFrom = tr.mapping.map(deletion.pos, -1);
359369
+ const beforeSize = tr.doc.content.size;
359370
+ tr.replace(deleteFrom, deleteFrom, deletion.slice);
359371
+ const deleteTo = deleteFrom + (tr.doc.content.size - beforeSize);
359372
+ if (deleteTo <= deleteFrom)
359373
+ return;
359374
+ const deletionResult = markDeletion({
359375
+ tr,
359376
+ from: deleteFrom,
359377
+ to: deleteTo,
359378
+ user,
359379
+ date,
359380
+ id: replacementGroupId || undefined
359381
+ });
359382
+ const deletionMark = replacementGroupId ? deletionResult.deletionMark.type.create({
359383
+ ...deletionResult.deletionMark.attrs,
359384
+ changeType: CanonicalChangeType.Replacement,
359385
+ replacementGroupId,
359386
+ replacementSideId: `${replacementGroupId}#deleted`
359387
+ }) : deletionResult.deletionMark;
359388
+ if (deletionMark !== deletionResult.deletionMark) {
359389
+ tr.removeMark(deleteFrom, deleteTo, deletionResult.deletionMark);
359390
+ tr.addMark(deleteFrom, deleteTo, deletionMark);
359391
+ }
359392
+ deletionMeta = {
359393
+ deletionMark,
359394
+ deletionNodes: deletionResult.nodes
359395
+ };
359396
+ });
359397
+ tr.setMeta("skipTrackChanges", true);
359398
+ tr.setMeta("compositionTrackingFlush", true);
359399
+ if (compositionId !== undefined)
359400
+ tr.setMeta("composition", compositionId);
359401
+ tr.setMeta(TrackChangesBasePluginKey, {
359402
+ ...insertedMark ? { insertedMark } : {},
359403
+ ...deletionMeta ?? {}
359404
+ });
359405
+ this.view.dispatch(tr);
359406
+ }
359407
+ #handleDomCompositionEnd = (event) => {
359408
+ const forceFlush = event?.type === "blur";
359409
+ queueMicrotask(() => {
359410
+ if (!this.#deferredCompositionRange)
359411
+ return;
359412
+ if (this.view?.composing && !forceFlush)
359413
+ return;
359414
+ try {
359415
+ this.view?.domObserver?.flush?.();
359416
+ } catch {}
359417
+ if (this.view?.composing && !forceFlush)
359418
+ return;
359419
+ this.#flushDeferredCompositionTracking();
359420
+ });
359421
+ };
359067
359422
  #dispatchTransaction(transaction) {
359068
359423
  if (this.isDestroyed)
359069
359424
  return;
@@ -359082,13 +359437,21 @@ function print() { __p += __j.call(arguments, '') }
359082
359437
  const protectsExistingTrackedReviewState = transactionTouchesTrackedReviewState(prevState, transactionToApply);
359083
359438
  if (protectsExistingTrackedReviewState && skipTrackChanges)
359084
359439
  transactionToApply.setMeta("protectTrackedReviewState", true);
359085
- const shouldTrack = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges || protectsExistingTrackedReviewState;
359440
+ const shouldTrackForComposition = (isTrackChangesActive$1 || forceTrackChanges) && !skipTrackChanges;
359441
+ const shouldTrack = shouldTrackForComposition || protectsExistingTrackedReviewState;
359086
359442
  if (!shouldTrack && directInsertionMutationCommentMeta && !transactionToApply.getMeta(TrackChangesBasePluginKey))
359087
359443
  transactionToApply.setMeta(TrackChangesBasePluginKey, directInsertionMutationCommentMeta);
359088
359444
  if (shouldTrack && forceTrackChanges && !this.options.user)
359089
359445
  throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");
359446
+ const deferTrackingForComposition = shouldTrackForComposition && (isCompositionTransaction(transactionToApply) || this.view?.composing === true && this.#replacesWithinDeferredRange(transactionToApply)) && this.#canDeferCompositionTracking(transactionToApply, prevState);
359447
+ const deferredCompositionDeletions = deferTrackingForComposition ? this.#collectDeferredCompositionDeletions(transactionToApply) : [];
359448
+ if (deferTrackingForComposition) {
359449
+ const compositionMeta = transactionToApply.getMeta("composition");
359450
+ if (compositionMeta !== undefined)
359451
+ this.#deferredCompositionId = compositionMeta;
359452
+ }
359090
359453
  const trackedUser = this.options.user ?? {};
359091
- transactionToApply = shouldTrack ? trackedTransaction({
359454
+ transactionToApply = shouldTrack && !deferTrackingForComposition ? trackedTransaction({
359092
359455
  tr: transactionToApply,
359093
359456
  state: prevState,
359094
359457
  user: trackedUser,
@@ -359096,6 +359459,12 @@ function print() { __p += __j.call(arguments, '') }
359096
359459
  }) : transactionToApply;
359097
359460
  const { state: appliedState, transactions: appliedTransactions } = prevState.applyTransaction(transactionToApply);
359098
359461
  nextState = appliedState;
359462
+ this.#updateDeferredCompositionRange(appliedTransactions, deferTrackingForComposition ? transactionToApply : null);
359463
+ this.#mapDeferredCompositionDeletions(appliedTransactions);
359464
+ if (deferredCompositionDeletions.length)
359465
+ this.#deferredCompositionDeletions.push(...this.#mapCompositionDeletions(deferredCompositionDeletions, appliedTransactions.slice(1)));
359466
+ if (deferTrackingForComposition && this.view?.composing !== true)
359467
+ this.#handleDomCompositionEnd();
359099
359468
  effectiveTransaction = appliedTransactions.find((t) => t.docChanged) ?? transactionToApply;
359100
359469
  } catch (error3) {
359101
359470
  if (forceTrackChanges)
@@ -361691,6 +362060,12 @@ function print() { __p += __j.call(arguments, '') }
361691
362060
  bottom: 72,
361692
362061
  left: 72
361693
362062
  };
362063
+ NAVIGATED_CARET_REPAIR_DELAYS_MS = [
362064
+ 120,
362065
+ 360,
362066
+ 900,
362067
+ 1300
362068
+ ];
361694
362069
  layoutDebugEnabled = typeof process$1 !== "undefined" && typeof process$1.env !== "undefined" && Boolean(process$1.env.SD_DEBUG_LAYOUT);
361695
362070
  GLOBAL_PERFORMANCE = typeof performance !== "undefined" ? performance : undefined;
361696
362071
  PresentationEditor = class PresentationEditor2 extends EventEmitter2 {
@@ -361765,8 +362140,15 @@ function print() { __p += __j.call(arguments, '') }
361765
362140
  #renderScheduled = false;
361766
362141
  #pendingDocChange = false;
361767
362142
  #focusScrollRafId = null;
362143
+ #selectionScrollSettleCleanup = null;
362144
+ #selectionNavigationToken = 0;
362145
+ #activeSelectionNavigation = null;
361768
362146
  #pendingMapping = null;
361769
362147
  #isRerendering = false;
362148
+ #isComposing = false;
362149
+ #compositionDeferralCleanup = [];
362150
+ #compositionTargetCleanup = [];
362151
+ #compositionTargetDom = null;
361770
362152
  #selectionSync = new SelectionSyncCoordinator;
361771
362153
  #fontGate = null;
361772
362154
  #fontResolver = createFontResolver();
@@ -362107,6 +362489,8 @@ function print() { __p += __j.call(arguments, '') }
362107
362489
  this.#setupPointerHandlers();
362108
362490
  this.#setupDragHandlers();
362109
362491
  this.#setupInputBridge();
362492
+ this.#setupCompositionDeferral();
362493
+ this.#refreshCompositionDeferralTarget();
362110
362494
  this.#syncTrackedChangesPreferences();
362111
362495
  this.#syncHeaderFooterTrackedChangesRenderConfig();
362112
362496
  this.#setupSemanticResizeObserver();
@@ -363712,6 +364096,7 @@ function print() { __p += __j.call(arguments, '') }
363712
364096
  const targetEl = this.#findElementAtPosition(pageEl, clampedPos);
363713
364097
  const elToScroll = targetEl ?? pageEl;
363714
364098
  const block = options.ifNeeded && targetEl && this.#isElementFullyVisibleInScrollContainer(targetEl) ? "nearest" : requestedBlock;
364099
+ this.#startSelectionNavigation(clampedPos);
363715
364100
  elToScroll.scrollIntoView({
363716
364101
  block,
363717
364102
  inline: "nearest",
@@ -363730,6 +364115,7 @@ function print() { __p += __j.call(arguments, '') }
363730
364115
  });
363731
364116
  this.#shouldScrollSelectionIntoView = false;
363732
364117
  this.#suppressSelectionScrollUntilRaf = false;
364118
+ this.#scheduleSelectionUpdateAfterScrollSettles();
363733
364119
  });
363734
364120
  }
363735
364121
  return true;
@@ -363812,6 +364198,164 @@ function print() { __p += __j.call(arguments, '') }
363812
364198
  }
363813
364199
  };
363814
364200
  }
364201
+ #startSelectionNavigation(targetPos) {
364202
+ const token$1 = ++this.#selectionNavigationToken;
364203
+ this.#activeSelectionNavigation = {
364204
+ token: token$1,
364205
+ targetPos,
364206
+ scrollSettled: false,
364207
+ repairAttempts: 0
364208
+ };
364209
+ return token$1;
364210
+ }
364211
+ #markSelectionNavigationScrollSettled() {
364212
+ if (this.#activeSelectionNavigation)
364213
+ this.#activeSelectionNavigation.scrollSettled = true;
364214
+ }
364215
+ #finishSelectionNavigation(token$1) {
364216
+ if (token$1 != null && this.#activeSelectionNavigation?.token !== token$1)
364217
+ return;
364218
+ this.#activeSelectionNavigation = null;
364219
+ }
364220
+ #scheduleNavigatedSelectionRender(targetPos) {
364221
+ this.#startSelectionNavigation(targetPos);
364222
+ this.#scheduleSelectionUpdateAfterScrollSettles();
364223
+ this.#scheduleSelectionUpdate({ immediate: true });
364224
+ this.#scheduleNavigatedCaretViewportRepairs(targetPos);
364225
+ }
364226
+ #scheduleNavigatedCaretViewportRepairs(targetPos) {
364227
+ const win = this.#visibleHost.ownerDocument?.defaultView;
364228
+ if (!win)
364229
+ return;
364230
+ for (const delay of NAVIGATED_CARET_REPAIR_DELAYS_MS)
364231
+ win.setTimeout(() => {
364232
+ if (!this.#localSelectionLayer?.isConnected)
364233
+ return;
364234
+ const selection = this.getActiveEditor()?.state?.selection;
364235
+ if (!selection || selection.from !== targetPos || selection.to !== targetPos)
364236
+ return;
364237
+ this.#rebuildDomPositionIndex();
364238
+ this.#renderNavigatedCaretFromViewportCoords(targetPos);
364239
+ }, delay);
364240
+ }
364241
+ #queueSelectionNavigationCaretRepair(caretPos, navigation) {
364242
+ if (this.#activeSelectionNavigation?.token !== navigation.token)
364243
+ return false;
364244
+ const caretEl = this.#localSelectionLayer.querySelector(".presentation-editor__selection-caret");
364245
+ if (!(caretEl instanceof HTMLElement))
364246
+ return false;
364247
+ const expected = this.coordsAtPos(caretPos);
364248
+ if (!expected)
364249
+ return false;
364250
+ const actual = caretEl.getBoundingClientRect();
364251
+ if (Math.abs(actual.top - expected.top) <= NAVIGATED_CARET_DRIFT_TOLERANCE_PX)
364252
+ return false;
364253
+ if (navigation.repairAttempts >= NAVIGATED_CARET_MAX_REPAIR_ATTEMPTS)
364254
+ return false;
364255
+ navigation.repairAttempts += 1;
364256
+ const win = this.#visibleHost.ownerDocument?.defaultView;
364257
+ const repair = () => {
364258
+ if (this.#activeSelectionNavigation?.token !== navigation.token)
364259
+ return;
364260
+ this.#rebuildDomPositionIndex();
364261
+ this.#scheduleSelectionUpdate({ immediate: true });
364262
+ };
364263
+ if (win)
364264
+ win.requestAnimationFrame(repair);
364265
+ else
364266
+ repair();
364267
+ return true;
364268
+ }
364269
+ #renderNavigatedCaretFromViewportCoords(caretPos) {
364270
+ const coords = this.coordsAtPos(caretPos);
364271
+ if (!coords)
364272
+ return false;
364273
+ const zoom = Number.isFinite(this.#layoutOptions.zoom) && this.#layoutOptions.zoom > 0 ? this.#layoutOptions.zoom : 1;
364274
+ const layerRect = this.#localSelectionLayer.getBoundingClientRect();
364275
+ const caretEl = createCaretElement(this.#localSelectionLayer.ownerDocument, {
364276
+ left: (coords.left - layerRect.left) / zoom,
364277
+ top: (coords.top - layerRect.top) / zoom,
364278
+ height: coords.height / zoom
364279
+ });
364280
+ if (!caretEl)
364281
+ return false;
364282
+ this.#localSelectionLayer.innerHTML = "";
364283
+ this.#localSelectionLayer.appendChild(caretEl);
364284
+ return true;
364285
+ }
364286
+ #scheduleSelectionUpdateAfterScrollSettles() {
364287
+ const win = this.#visibleHost.ownerDocument?.defaultView;
364288
+ if (!win) {
364289
+ this.#scheduleSelectionUpdate();
364290
+ return;
364291
+ }
364292
+ this.#selectionScrollSettleCleanup?.();
364293
+ const scrollTarget = this.#scrollContainer instanceof Window || this.#scrollContainer instanceof Element ? this.#scrollContainer : win;
364294
+ let timeoutId = null;
364295
+ let finalTimeoutId = null;
364296
+ let scrollRenderRafId = null;
364297
+ let cleanedUp = false;
364298
+ const cleanup = () => {
364299
+ if (cleanedUp)
364300
+ return;
364301
+ cleanedUp = true;
364302
+ scrollTarget.removeEventListener("scroll", onScroll);
364303
+ scrollTarget.removeEventListener("scrollend", finalizeRender);
364304
+ if (timeoutId != null) {
364305
+ win.clearTimeout(timeoutId);
364306
+ timeoutId = null;
364307
+ }
364308
+ if (finalTimeoutId != null) {
364309
+ win.clearTimeout(finalTimeoutId);
364310
+ finalTimeoutId = null;
364311
+ }
364312
+ if (scrollRenderRafId != null) {
364313
+ win.cancelAnimationFrame(scrollRenderRafId);
364314
+ scrollRenderRafId = null;
364315
+ }
364316
+ if (this.#selectionScrollSettleCleanup === cleanup)
364317
+ this.#selectionScrollSettleCleanup = null;
364318
+ };
364319
+ const renderAfterPause = () => {
364320
+ timeoutId = null;
364321
+ this.#scheduleSelectionUpdate({ immediate: true });
364322
+ };
364323
+ const finalizeRender = () => {
364324
+ if (cleanedUp)
364325
+ return;
364326
+ this.#markSelectionNavigationScrollSettled();
364327
+ cleanup();
364328
+ this.#scheduleSelectionUpdate({ immediate: true });
364329
+ };
364330
+ const queueRender = () => {
364331
+ if (timeoutId != null)
364332
+ win.clearTimeout(timeoutId);
364333
+ timeoutId = win.setTimeout(renderAfterPause, SELECTION_SCROLL_SETTLE_RENDER_DELAY_MS);
364334
+ };
364335
+ const queueFinalize = () => {
364336
+ if (finalTimeoutId != null)
364337
+ win.clearTimeout(finalTimeoutId);
364338
+ finalTimeoutId = win.setTimeout(finalizeRender, SELECTION_SCROLL_SETTLE_FINALIZE_DELAY_MS);
364339
+ };
364340
+ const requestScrollRender = () => {
364341
+ if (scrollRenderRafId != null)
364342
+ return;
364343
+ scrollRenderRafId = win.requestAnimationFrame(() => {
364344
+ scrollRenderRafId = null;
364345
+ this.#scheduleSelectionUpdate({ immediate: true });
364346
+ });
364347
+ };
364348
+ const onScroll = () => {
364349
+ requestScrollRender();
364350
+ queueRender();
364351
+ queueFinalize();
364352
+ };
364353
+ scrollTarget.addEventListener("scroll", onScroll, { passive: true });
364354
+ scrollTarget.addEventListener("scrollend", finalizeRender, { passive: true });
364355
+ this.#selectionScrollSettleCleanup = cleanup;
364356
+ queueRender();
364357
+ queueFinalize();
364358
+ }
363815
364359
  #findElementAtPosition(pageEl, pos) {
363816
364360
  const elements = Array.from(pageEl.querySelectorAll("[data-pm-start][data-pm-end]"));
363817
364361
  let bestMatch = null;
@@ -363835,6 +364379,8 @@ function print() { __p += __j.call(arguments, '') }
363835
364379
  return bestMatch;
363836
364380
  }
363837
364381
  async scrollToPositionAsync(pos, options = {}) {
364382
+ if (!shouldContinueNavigation(options))
364383
+ return false;
363838
364384
  if (this.scrollToPosition(pos, options))
363839
364385
  return true;
363840
364386
  const doc$12 = this.getActiveEditor()?.state?.doc;
@@ -363860,11 +364406,15 @@ function print() { __p += __j.call(arguments, '') }
363860
364406
  }
363861
364407
  if (pageIndex == null)
363862
364408
  return false;
364409
+ if (!shouldContinueNavigation(options))
364410
+ return false;
363863
364411
  this.#scrollPageIntoView(pageIndex);
363864
364412
  if (!await this.#waitForPageMount(pageIndex, { timeout: PresentationEditor2.ANCHOR_NAV_TIMEOUT_MS })) {
363865
364413
  console.warn(`[PresentationEditor] scrollToPositionAsync: Page ${pageIndex} failed to mount within timeout`);
363866
364414
  return false;
363867
364415
  }
364416
+ if (!shouldContinueNavigation(options))
364417
+ return false;
363868
364418
  return this.scrollToPosition(pos, {
363869
364419
  ...options,
363870
364420
  ifNeeded: false
@@ -364049,6 +364599,11 @@ function print() { __p += __j.call(arguments, '') }
364049
364599
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#focusScrollRafId);
364050
364600
  this.#focusScrollRafId = null;
364051
364601
  }, "Focus scroll RAF");
364602
+ if (this.#selectionScrollSettleCleanup)
364603
+ safeCleanup(() => {
364604
+ this.#selectionScrollSettleCleanup?.();
364605
+ }, "Selection scroll settle");
364606
+ this.#finishSelectionNavigation();
364052
364607
  if (this.#decorationSyncRafHandle != null)
364053
364608
  safeCleanup(() => {
364054
364609
  (this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#decorationSyncRafHandle);
@@ -364103,6 +364658,7 @@ function print() { __p += __j.call(arguments, '') }
364103
364658
  this.#inputBridge?.notifyTargetChanged();
364104
364659
  this.#inputBridge?.destroy();
364105
364660
  this.#inputBridge = null;
364661
+ this.#teardownCompositionDeferral();
364106
364662
  if (this.#a11ySelectionAnnounceTimeout != null) {
364107
364663
  clearTimeout(this.#a11ySelectionAnnounceTimeout);
364108
364664
  this.#a11ySelectionAnnounceTimeout = null;
@@ -364236,6 +364792,12 @@ function print() { __p += __j.call(arguments, '') }
364236
364792
  #syncCommentHighlights() {
364237
364793
  this.#postPaintPipeline.applyCommentHighlights();
364238
364794
  }
364795
+ setActiveTrackChangeIds(ids) {
364796
+ const didChange = this.#postPaintPipeline.setActiveTrackChangeIds(ids);
364797
+ if (didChange)
364798
+ this.#syncInlineStyleLayers();
364799
+ return didChange;
364800
+ }
364239
364801
  #syncInlineStyleLayers() {
364240
364802
  const state = this.#editor?.view?.state;
364241
364803
  if (!state) {
@@ -364692,7 +365254,10 @@ function print() { __p += __j.call(arguments, '') }
364692
365254
  }
364693
365255
  #setupInputBridge() {
364694
365256
  this.#inputBridge?.destroy();
364695
- this.#inputBridge = new PresentationInputBridge(this.#visibleHost.ownerDocument?.defaultView ?? window, this.#visibleHost, () => this.#getActiveDomTarget(), () => !this.#isViewLocked(), () => this.#editorInputManager?.notifyTargetChanged(), {
365257
+ this.#inputBridge = new PresentationInputBridge(this.#visibleHost.ownerDocument?.defaultView ?? window, this.#visibleHost, () => this.#getActiveDomTarget(), () => !this.#isViewLocked(), () => {
365258
+ this.#refreshCompositionDeferralTarget();
365259
+ this.#editorInputManager?.notifyTargetChanged();
365260
+ }, {
364696
365261
  useWindowFallback: true,
364697
365262
  getTargetEditor: () => this.getActiveEditor()
364698
365263
  });
@@ -365328,6 +365893,70 @@ function print() { __p += __j.call(arguments, '') }
365328
365893
  this.#selectionSync.onLayoutStart();
365329
365894
  this.#scheduleRerender();
365330
365895
  }
365896
+ #beginCompositionDeferral() {
365897
+ this.#isComposing = true;
365898
+ }
365899
+ #endCompositionDeferral() {
365900
+ if (!this.#isComposing)
365901
+ return;
365902
+ this.#isComposing = false;
365903
+ if (this.#pendingDocChange && !this.#renderScheduled && !this.#isRerendering)
365904
+ this.#scheduleRerender();
365905
+ }
365906
+ #resetCompositionDeferral() {
365907
+ this.#isComposing = false;
365908
+ }
365909
+ #handleNonComposingInputForCompositionDeferral = (event) => {
365910
+ if ("isComposing" in event && event.isComposing === false)
365911
+ this.#endCompositionDeferral();
365912
+ };
365913
+ #setupCompositionDeferral() {
365914
+ this.#teardownCompositionDeferral();
365915
+ const add = (target, type, handler2) => {
365916
+ if (!target)
365917
+ return;
365918
+ target.addEventListener(type, handler2);
365919
+ this.#compositionDeferralCleanup.push(() => target.removeEventListener(type, handler2));
365920
+ };
365921
+ const begin = () => this.#beginCompositionDeferral();
365922
+ const end$1 = () => this.#endCompositionDeferral();
365923
+ add(this.#visibleHost, "compositionstart", begin);
365924
+ add(this.#visibleHost, "compositionend", end$1);
365925
+ add(this.#visibleHost, "input", this.#handleNonComposingInputForCompositionDeferral);
365926
+ add(this.#visibleHost, "beforeinput", this.#handleNonComposingInputForCompositionDeferral);
365927
+ }
365928
+ #teardownCompositionDeferral() {
365929
+ this.#compositionTargetCleanup.forEach((cleanup) => cleanup());
365930
+ this.#compositionTargetCleanup = [];
365931
+ this.#compositionTargetDom = null;
365932
+ this.#compositionDeferralCleanup.forEach((cleanup) => cleanup());
365933
+ this.#compositionDeferralCleanup = [];
365934
+ this.#resetCompositionDeferral();
365935
+ }
365936
+ #refreshCompositionDeferralTarget() {
365937
+ const nextTarget = this.#getActiveDomTarget();
365938
+ if (nextTarget === this.#compositionTargetDom)
365939
+ return;
365940
+ this.#compositionTargetCleanup.forEach((cleanup) => cleanup());
365941
+ this.#compositionTargetCleanup = [];
365942
+ this.#compositionTargetDom = nextTarget;
365943
+ if (!nextTarget) {
365944
+ this.#endCompositionDeferral();
365945
+ return;
365946
+ }
365947
+ const begin = () => this.#beginCompositionDeferral();
365948
+ const end$1 = () => this.#endCompositionDeferral();
365949
+ nextTarget.addEventListener("compositionstart", begin);
365950
+ nextTarget.addEventListener("compositionend", end$1);
365951
+ nextTarget.addEventListener("blur", end$1);
365952
+ nextTarget.addEventListener("focusout", end$1);
365953
+ nextTarget.addEventListener("beforeinput", this.#handleNonComposingInputForCompositionDeferral);
365954
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("compositionstart", begin));
365955
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("compositionend", end$1));
365956
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("blur", end$1));
365957
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("focusout", end$1));
365958
+ this.#compositionTargetCleanup.push(() => nextTarget.removeEventListener("beforeinput", this.#handleNonComposingInputForCompositionDeferral));
365959
+ }
365331
365960
  #scheduleRerender() {
365332
365961
  if (this.#renderScheduled)
365333
365962
  return;
@@ -365346,6 +365975,8 @@ function print() { __p += __j.call(arguments, '') }
365346
365975
  }
365347
365976
  if (!this.#pendingDocChange)
365348
365977
  return;
365978
+ if (this.#isComposing)
365979
+ return;
365349
365980
  this.#pendingDocChange = false;
365350
365981
  this.#isRerendering = true;
365351
365982
  const activeHfEditor = (this.#headerFooterSession?.session?.mode ?? "body") !== "body" ? this.#headerFooterSession?.activeEditor : null;
@@ -366132,9 +366763,22 @@ function print() { __p += __j.call(arguments, '') }
366132
366763
  }
366133
366764
  if (from$1 === to || isDragDropIndicatorActive) {
366134
366765
  const caretPos = this.#dragDropIndicatorPos ?? from$1;
366766
+ const activeNavigation$1 = this.#activeSelectionNavigation;
366767
+ const isRenderingNavigatedCaret = activeNavigation$1?.targetPos === caretPos;
366768
+ if (isRenderingNavigatedCaret)
366769
+ this.#rebuildDomPositionIndex();
366770
+ else if (activeNavigation$1)
366771
+ this.#finishSelectionNavigation(activeNavigation$1.token);
366772
+ if (isRenderingNavigatedCaret && activeNavigation$1?.scrollSettled && this.#renderNavigatedCaretFromViewportCoords(caretPos)) {
366773
+ this.#finishSelectionNavigation(activeNavigation$1.token);
366774
+ return;
366775
+ }
366135
366776
  const caretLayout = this.#computeCaretLayoutRect(caretPos);
366136
- if (!caretLayout)
366777
+ if (!caretLayout) {
366778
+ if (isRenderingNavigatedCaret)
366779
+ this.#localSelectionLayer.innerHTML = "";
366137
366780
  return;
366781
+ }
366138
366782
  try {
366139
366783
  this.#localSelectionLayer.innerHTML = "";
366140
366784
  renderCaretOverlay({
@@ -366142,6 +366786,9 @@ function print() { __p += __j.call(arguments, '') }
366142
366786
  caretLayout,
366143
366787
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
366144
366788
  });
366789
+ const queuedNavigationRepair = isRenderingNavigatedCaret && activeNavigation$1 ? this.#queueSelectionNavigationCaretRepair(caretPos, activeNavigation$1) : false;
366790
+ if (isRenderingNavigatedCaret && activeNavigation$1?.scrollSettled && !queuedNavigationRepair)
366791
+ this.#finishSelectionNavigation(activeNavigation$1?.token);
366145
366792
  } catch (error3) {
366146
366793
  if (process$1.env.NODE_ENV === "development")
366147
366794
  console.warn("[PresentationEditor] Failed to render caret overlay:", error3);
@@ -366150,8 +366797,16 @@ function print() { __p += __j.call(arguments, '') }
366150
366797
  this.#scrollActiveEndIntoView(caretLayout.pageIndex);
366151
366798
  return;
366152
366799
  }
366800
+ const activeNavigation = this.#activeSelectionNavigation;
366801
+ const selectionContainsNavigationTarget = activeNavigation != null && activeNavigation.targetPos >= from$1 && activeNavigation.targetPos <= to;
366802
+ if (activeNavigation && !selectionContainsNavigationTarget)
366803
+ this.#finishSelectionNavigation(activeNavigation.token);
366804
+ if (selectionContainsNavigationTarget)
366805
+ this.#rebuildDomPositionIndex();
366153
366806
  const domRects = this.#computeSelectionRectsFromDom(from$1, to);
366154
366807
  if (domRects == null) {
366808
+ if (selectionContainsNavigationTarget)
366809
+ this.#localSelectionLayer.innerHTML = "";
366155
366810
  debugLog("warn", "Local selection: DOM rect computation failed", {
366156
366811
  from: from$1,
366157
366812
  to
@@ -366168,7 +366823,7 @@ function print() { __p += __j.call(arguments, '') }
366168
366823
  try {
366169
366824
  this.#localSelectionLayer.innerHTML = "";
366170
366825
  const isFieldAnnotationSelection2 = selection instanceof NodeSelection && selection.node?.type?.name === "fieldAnnotation";
366171
- if (domRects.length > 0 && !isFieldAnnotationSelection2)
366826
+ if (domRects.length > 0 && !isFieldAnnotationSelection2) {
366172
366827
  renderSelectionRects({
366173
366828
  localSelectionLayer: this.#localSelectionLayer,
366174
366829
  rects: domRects,
@@ -366176,6 +366831,9 @@ function print() { __p += __j.call(arguments, '') }
366176
366831
  pageGap: this.#layoutState.layout?.pageGap ?? 0,
366177
366832
  convertPageLocalToOverlayCoords: (pageIndex, x, y$1) => this.#convertPageLocalToOverlayCoords(pageIndex, x, y$1)
366178
366833
  });
366834
+ if (selectionContainsNavigationTarget && activeNavigation?.scrollSettled)
366835
+ this.#finishSelectionNavigation(activeNavigation?.token);
366836
+ }
366179
366837
  } catch (error3) {
366180
366838
  if (process$1.env.NODE_ENV === "development")
366181
366839
  console.warn("[PresentationEditor] Failed to render selection rects:", error3);
@@ -367135,9 +367793,12 @@ function print() { __p += __j.call(arguments, '') }
367135
367793
  });
367136
367794
  if (!await this.scrollToPositionAsync(contentPos, {
367137
367795
  behavior: options.behavior ?? "auto",
367138
- block: options.block ?? "center"
367796
+ block: options.block ?? "center",
367797
+ shouldContinue: options.shouldContinue
367139
367798
  }))
367140
367799
  return false;
367800
+ if (!shouldContinueNavigation(options))
367801
+ return false;
367141
367802
  editor.commands?.setTextSelection?.({
367142
367803
  from: contentPos,
367143
367804
  to: contentPos
@@ -367159,9 +367820,10 @@ function print() { __p += __j.call(arguments, '') }
367159
367820
  return false;
367160
367821
  await this.scrollToPositionAsync(editor.state.selection.from, {
367161
367822
  behavior: options.behavior ?? "auto",
367162
- block: options.block ?? "center"
367823
+ block: options.block ?? "center",
367824
+ shouldContinue: options.shouldContinue
367163
367825
  });
367164
- return true;
367826
+ return shouldContinueNavigation(options);
367165
367827
  }
367166
367828
  async#navigateToBookmark(target) {
367167
367829
  const editor = this.#editor;
@@ -367192,64 +367854,113 @@ function print() { __p += __j.call(arguments, '') }
367192
367854
  const behavior = options.behavior ?? "auto";
367193
367855
  const block = options.block ?? "center";
367194
367856
  const navigationIds = this.#resolveTrackedChangeNavigationIds(entityId, storyKey);
367857
+ if (!shouldContinueNavigation(options))
367858
+ return false;
367195
367859
  if (storyKey && storyKey !== "body") {
367196
- for (const id2 of navigationIds)
367860
+ for (const id2 of navigationIds) {
367861
+ if (!shouldContinueNavigation(options))
367862
+ return false;
367197
367863
  if (this.#navigateToActiveStoryTrackedChange(id2, storyKey))
367198
367864
  return true;
367865
+ }
367199
367866
  for (const id2 of navigationIds)
367200
- if (await this.#activateTrackedChangeStorySurface(id2, storyKey, preferredPageIndex)) {
367201
- for (const activeId of navigationIds)
367867
+ if (await this.#activateTrackedChangeStorySurface(id2, storyKey, preferredPageIndex, options)) {
367868
+ if (!shouldContinueNavigation(options))
367869
+ return false;
367870
+ for (const activeId of navigationIds) {
367871
+ if (!shouldContinueNavigation(options))
367872
+ return false;
367202
367873
  if (this.#navigateToActiveStoryTrackedChange(activeId, storyKey))
367203
367874
  return true;
367875
+ }
367204
367876
  }
367205
- for (const id2 of navigationIds)
367877
+ for (const id2 of navigationIds) {
367878
+ if (!shouldContinueNavigation(options))
367879
+ return false;
367206
367880
  if (await this.#scrollToRenderedTrackedChange(id2, storyKey, preferredPageIndex, {
367207
367881
  behavior,
367208
- block
367882
+ block,
367883
+ shouldContinue: options.shouldContinue
367209
367884
  }))
367210
367885
  return true;
367886
+ }
367211
367887
  return false;
367212
367888
  }
367889
+ this.exitActiveStorySurface();
367213
367890
  const setCursorById = editor.commands?.setCursorById;
367214
- if (typeof setCursorById === "function") {
367215
- for (const id2 of navigationIds)
367891
+ for (const id2 of navigationIds) {
367892
+ if (!shouldContinueNavigation(options))
367893
+ return false;
367894
+ const selection = resolveTrackedChangeNavigationSelection(editor, id2);
367895
+ if (!selection)
367896
+ continue;
367897
+ const setTextSelection$1 = editor.commands?.setTextSelection;
367898
+ if (!await this.scrollToPositionAsync(selection.from, {
367899
+ behavior,
367900
+ block,
367901
+ shouldContinue: options.shouldContinue
367902
+ }) || !shouldContinueNavigation(options))
367903
+ return false;
367904
+ if (typeof setTextSelection$1 !== "function" || setTextSelection$1(selection) !== true)
367905
+ continue;
367906
+ editor.view?.focus?.();
367907
+ this.#scheduleNavigatedSelectionRender(selection.from);
367908
+ return true;
367909
+ }
367910
+ if (typeof setCursorById === "function")
367911
+ for (const id2 of navigationIds) {
367912
+ if (!shouldContinueNavigation(options))
367913
+ return false;
367216
367914
  if (setCursorById(id2, { preferredActiveThreadId: id2 })) {
367217
- await this.scrollToPositionAsync(editor.state.selection.from, {
367915
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
367218
367916
  behavior,
367219
- block
367220
- });
367917
+ block,
367918
+ shouldContinue: options.shouldContinue
367919
+ }) || !shouldContinueNavigation(options))
367920
+ return false;
367921
+ editor.view?.focus?.();
367922
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
367221
367923
  return true;
367222
367924
  }
367223
- }
367925
+ }
367224
367926
  const resolved = navigationIds.map((id2) => resolveTrackedChange(editor, id2)).find(Boolean);
367225
367927
  if (!resolved) {
367226
367928
  for (const id2 of navigationIds)
367227
367929
  if (await this.#scrollToRenderedTrackedChange(id2, undefined, preferredPageIndex, {
367228
367930
  behavior,
367229
- block
367931
+ block,
367932
+ shouldContinue: options.shouldContinue
367230
367933
  }))
367231
367934
  return true;
367232
367935
  return false;
367233
367936
  }
367234
367937
  if (typeof setCursorById === "function" && resolved.rawId !== entityId) {
367938
+ if (!shouldContinueNavigation(options))
367939
+ return false;
367235
367940
  if (setCursorById(resolved.rawId, { preferredActiveThreadId: resolved.rawId })) {
367236
- await this.scrollToPositionAsync(editor.state.selection.from, {
367941
+ if (!await this.scrollToPositionAsync(editor.state.selection.from, {
367237
367942
  behavior,
367238
- block
367239
- });
367943
+ block,
367944
+ shouldContinue: options.shouldContinue
367945
+ }) || !shouldContinueNavigation(options))
367946
+ return false;
367947
+ editor.view?.focus?.();
367948
+ this.#scheduleNavigatedSelectionRender(editor.state.selection.from);
367240
367949
  return true;
367241
367950
  }
367242
367951
  }
367243
367952
  if (!await this.scrollToPositionAsync(resolved.from, {
367244
367953
  behavior,
367245
- block
367246
- }))
367954
+ block,
367955
+ shouldContinue: options.shouldContinue
367956
+ }) || !shouldContinueNavigation(options))
367247
367957
  return false;
367248
367958
  editor.commands?.setTextSelection?.({
367249
367959
  from: resolved.from,
367250
367960
  to: resolved.from
367251
367961
  });
367252
367962
  editor.view?.focus?.();
367963
+ this.#scheduleNavigatedSelectionRender(resolved.from);
367253
367964
  return true;
367254
367965
  }
367255
367966
  #resolveTrackedChangeNavigationIds(entityId, storyKey) {
@@ -367285,7 +367996,7 @@ function print() { __p += __j.call(arguments, '') }
367285
367996
  } catch {}
367286
367997
  return ids;
367287
367998
  }
367288
- async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex) {
367999
+ async#activateTrackedChangeStorySurface(entityId, storyKey, preferredPageIndex, options = {}) {
367289
368000
  let locator = null;
367290
368001
  try {
367291
368002
  locator = parseStoryKey(storyKey);
@@ -367294,15 +368005,23 @@ function print() { __p += __j.call(arguments, '') }
367294
368005
  }
367295
368006
  if (!locator || locator.storyType === "body")
367296
368007
  return false;
368008
+ if (!shouldContinueNavigation(options))
368009
+ return false;
367297
368010
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
367298
368011
  if (!candidate)
367299
368012
  return false;
368013
+ if (!shouldContinueNavigation(options))
368014
+ return false;
367300
368015
  const rect = candidate.getBoundingClientRect();
367301
368016
  const clientX = rect.left + Math.max(rect.width / 2, 1);
367302
368017
  const clientY = rect.top + Math.max(rect.height / 2, 1);
367303
368018
  const pageIndex = this.#resolveRenderedPageIndexForElement(candidate);
368019
+ if (!shouldContinueNavigation(options))
368020
+ return false;
367304
368021
  if (locator.storyType === "footnote" || locator.storyType === "endnote") {
367305
368022
  try {
368023
+ if (!shouldContinueNavigation(options))
368024
+ return false;
367306
368025
  if (!this.#activateRenderedNoteSession({
367307
368026
  storyType: locator.storyType,
367308
368027
  noteId: locator.noteId
@@ -367315,7 +368034,7 @@ function print() { __p += __j.call(arguments, '') }
367315
368034
  } catch {
367316
368035
  return false;
367317
368036
  }
367318
- return this.#waitForTrackedChangeStorySurface(storyKey);
368037
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
367319
368038
  }
367320
368039
  if (locator.storyType !== "headerFooterPart")
367321
368040
  return false;
@@ -367324,21 +368043,27 @@ function print() { __p += __j.call(arguments, '') }
367324
368043
  const region = this.#hitTestHeaderFooterRegion(clientX, clientY, pageIndex, pageLocalY);
367325
368044
  if (!region)
367326
368045
  return false;
368046
+ if (!shouldContinueNavigation(options))
368047
+ return false;
367327
368048
  this.#activateHeaderFooterRegion(region, {
367328
368049
  clientX,
367329
368050
  clientY,
367330
368051
  pageIndex,
367331
368052
  source: "programmatic"
367332
368053
  });
367333
- return this.#waitForTrackedChangeStorySurface(storyKey);
368054
+ return this.#waitForTrackedChangeStorySurface(storyKey, undefined, options);
367334
368055
  }
367335
- async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500) {
368056
+ async#waitForTrackedChangeStorySurface(storyKey, timeoutMs = 500, options = {}) {
367336
368057
  const deadline = Date.now() + timeoutMs;
367337
368058
  while (Date.now() < deadline) {
368059
+ if (!shouldContinueNavigation(options))
368060
+ return false;
367338
368061
  if (this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey)
367339
368062
  return true;
367340
368063
  await new Promise((resolve3) => setTimeout(resolve3, 16));
367341
368064
  }
368065
+ if (!shouldContinueNavigation(options))
368066
+ return false;
367342
368067
  return this.#getActiveTrackedChangeStorySurface()?.storyKey === storyKey;
367343
368068
  }
367344
368069
  async#activateBookmarkStorySurface(storyKey) {
@@ -367476,6 +368201,12 @@ function print() { __p += __j.call(arguments, '') }
367476
368201
  return false;
367477
368202
  const sessionEditor = activeSurface.editor;
367478
368203
  const setCursorById = sessionEditor.commands?.setCursorById;
368204
+ const navigationSelection = resolveTrackedChangeNavigationSelection(sessionEditor, entityId);
368205
+ const setTextSelection$1 = sessionEditor.commands?.setTextSelection;
368206
+ if (navigationSelection && typeof setTextSelection$1 === "function" && setTextSelection$1(navigationSelection) === true) {
368207
+ this.#focusAndRevealActiveStorySelection(sessionEditor);
368208
+ return true;
368209
+ }
367479
368210
  if (typeof setCursorById === "function" && setCursorById(entityId, { preferredActiveThreadId: entityId })) {
367480
368211
  this.#focusAndRevealActiveStorySelection(sessionEditor);
367481
368212
  return true;
@@ -367513,6 +368244,8 @@ function print() { __p += __j.call(arguments, '') }
367513
368244
  const candidate = this.#findRenderedTrackedChangeElement(entityId, storyKey, preferredPageIndex);
367514
368245
  if (!candidate)
367515
368246
  return false;
368247
+ if (!shouldContinueNavigation(options))
368248
+ return false;
367516
368249
  try {
367517
368250
  candidate.scrollIntoView({
367518
368251
  behavior: options.behavior ?? "auto",
@@ -368454,11 +369187,11 @@ function print() { __p += __j.call(arguments, '') }
368454
369187
  ]);
368455
369188
  });
368456
369189
 
368457
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-oSlpT6HI.es.js
369190
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BjToI9WN.es.js
368458
369191
  var DEFAULT_TEXT_ALIGN_OPTIONS, DEFAULT_LINE_HEIGHT_OPTIONS, DEFAULT_ZOOM_OPTIONS, DEFAULT_DOCUMENT_MODE_OPTIONS, DEFAULT_FONT_SIZE_OPTIONS, headlessToolbarConstants, MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS, FONT_SIZE_OPTIONS;
368459
- var init_create_super_doc_ui_oSlpT6HI_es = __esm(() => {
368460
- init_SuperConverter_Du0apG1R_es();
368461
- init_create_headless_toolbar_BNcguDpP_es();
369192
+ var init_create_super_doc_ui_BjToI9WN_es = __esm(() => {
369193
+ init_SuperConverter_DQ2wMaLK_es();
369194
+ init_create_headless_toolbar_BhSfQYaO_es();
368462
369195
  DEFAULT_TEXT_ALIGN_OPTIONS = [
368463
369196
  {
368464
369197
  label: "Left",
@@ -368749,15 +369482,15 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
368749
369482
 
368750
369483
  // ../../packages/superdoc/dist/super-editor.es.js
368751
369484
  var init_super_editor_es = __esm(() => {
368752
- init_src_DfMY3HP9_es();
368753
- init_SuperConverter_Du0apG1R_es();
369485
+ init_src_CR8eXLKh_es();
369486
+ init_SuperConverter_DQ2wMaLK_es();
368754
369487
  init_jszip_C49i9kUs_es();
368755
369488
  init_xml_js_CqGKpaft_es();
368756
- init_create_headless_toolbar_BNcguDpP_es();
369489
+ init_create_headless_toolbar_BhSfQYaO_es();
368757
369490
  init_constants_D9qj59G2_es();
368758
369491
  init_unified_BDuVPlMu_es();
368759
369492
  init_DocxZipper_BzS208BW_es();
368760
- init_create_super_doc_ui_oSlpT6HI_es();
369493
+ init_create_super_doc_ui_BjToI9WN_es();
368761
369494
  init_ui_CGB3qmy3_es();
368762
369495
  init_eventemitter3_UwU_CLPU_es();
368763
369496
  init_errors_C_DoKMoN_es();