@superdoc-dev/mcp 0.10.0-next.5 → 0.10.0-next.7

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 +253 -89
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -211378,7 +211378,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
211378
211378
  init_remark_gfm_BhnWr3yf_es();
211379
211379
  });
211380
211380
 
211381
- // ../../packages/superdoc/dist/chunks/src-B9A7ox0h.es.js
211381
+ // ../../packages/superdoc/dist/chunks/src-CYzfdR4C.es.js
211382
211382
  function deleteProps(obj, propOrProps) {
211383
211383
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
211384
211384
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -212729,12 +212729,80 @@ function findContainingBlockAncestor(element3) {
212729
212729
  }
212730
212730
  return null;
212731
212731
  }
212732
+ function isZeroWidthMarker(node2) {
212733
+ if (node2.type.name === "fieldAnnotation" && node2.attrs?.hidden === true)
212734
+ return true;
212735
+ return ZERO_WIDTH_MARKER_NODE_NAMES.has(node2.type.name);
212736
+ }
212737
+ function findFirstTextPosInNode(node2, nodePos) {
212738
+ if (node2.isText)
212739
+ return nodePos;
212740
+ for (let index2 = 0, offset$1 = 0;index2 < node2.childCount; index2 += 1) {
212741
+ const child = node2.child(index2);
212742
+ const found2 = findFirstTextPosInNode(child, nodePos + 1 + offset$1);
212743
+ if (found2 != null)
212744
+ return found2;
212745
+ offset$1 += child.nodeSize;
212746
+ }
212747
+ return null;
212748
+ }
212749
+ function findFirstContentCursorPosInNode(node2, nodePos) {
212750
+ if (isZeroWidthMarker(node2))
212751
+ return null;
212752
+ if (node2.isText || node2.isAtom)
212753
+ return nodePos;
212754
+ if (node2.isTextblock && node2.childCount === 0)
212755
+ return nodePos + 1;
212756
+ for (let index2 = 0, offset$1 = 0;index2 < node2.childCount; index2 += 1) {
212757
+ const child = node2.child(index2);
212758
+ const found2 = findFirstContentCursorPosInNode(child, nodePos + 1 + offset$1);
212759
+ if (found2 != null)
212760
+ return found2;
212761
+ offset$1 += child.nodeSize;
212762
+ }
212763
+ if (node2.isTextblock)
212764
+ return nodePos + 1;
212765
+ return null;
212766
+ }
212767
+ function findLastTextPosInNode(node2, nodePos) {
212768
+ if (node2.isText)
212769
+ return nodePos + (node2.text?.length ?? 0);
212770
+ for (let index2 = node2.childCount - 1, offset$1 = node2.content.size;index2 >= 0; index2 -= 1) {
212771
+ const child = node2.child(index2);
212772
+ offset$1 -= child.nodeSize;
212773
+ const found2 = findLastTextPosInNode(child, nodePos + 1 + offset$1);
212774
+ if (found2 != null)
212775
+ return found2;
212776
+ }
212777
+ return null;
212778
+ }
212779
+ function findLastContentCursorPosInNode(node2, nodePos) {
212780
+ if (isZeroWidthMarker(node2))
212781
+ return null;
212782
+ if (node2.isText)
212783
+ return nodePos + (node2.text?.length ?? 0);
212784
+ if (node2.isAtom)
212785
+ return node2.isInline ? nodePos + node2.nodeSize : nodePos;
212786
+ if (node2.isTextblock && node2.childCount === 0)
212787
+ return nodePos + 1;
212788
+ for (let index2 = node2.childCount - 1, offset$1 = node2.content.size;index2 >= 0; index2 -= 1) {
212789
+ const child = node2.child(index2);
212790
+ offset$1 -= child.nodeSize;
212791
+ const found2 = findLastContentCursorPosInNode(child, nodePos + 1 + offset$1);
212792
+ if (found2 != null)
212793
+ return found2;
212794
+ }
212795
+ if (node2.isTextblock)
212796
+ return nodePos + node2.nodeSize - 1;
212797
+ return null;
212798
+ }
212732
212799
  function collectSDTNodes(doc$12) {
212733
212800
  const sdtNodes = [];
212734
212801
  doc$12.descendants((node2, pos) => {
212735
212802
  if (node2.type.name === "structuredContent" || node2.type.name === "structuredContentBlock")
212736
212803
  sdtNodes.push({
212737
212804
  type: node2.type.name,
212805
+ node: node2,
212738
212806
  lockMode: node2.attrs.lockMode,
212739
212807
  pos,
212740
212808
  end: pos + node2.nodeSize
@@ -212790,6 +212858,15 @@ function isAtBlockSdtWrapperDeletePosition(state, sdt, pos) {
212790
212858
  return false;
212791
212859
  return $pos.before(textblockDepth) === $pos.start(sdtDepth);
212792
212860
  }
212861
+ function selectionCoversSdtContent(sdt, from$1, to) {
212862
+ if (from$1 === sdt.pos + 1 && to === sdt.end - 1)
212863
+ return true;
212864
+ if (sdt.type !== "structuredContentBlock")
212865
+ return false;
212866
+ const contentStart = findFirstContentCursorPosInNode(sdt.node, sdt.pos);
212867
+ const contentEnd = findLastContentCursorPosInNode(sdt.node, sdt.pos);
212868
+ return contentStart != null && contentEnd != null && from$1 === contentStart && to === contentEnd;
212869
+ }
212793
212870
  function createStructuredContentLockPlugin() {
212794
212871
  return new Plugin({
212795
212872
  key: STRUCTURED_CONTENT_LOCK_KEY,
@@ -212817,7 +212894,7 @@ function createStructuredContentLockPlugin() {
212817
212894
  if (sdtNodes.length === 0)
212818
212895
  return false;
212819
212896
  if (from$1 !== to && !(selection instanceof NodeSelection)) {
212820
- const exactContentSDT = sdtNodes.find((s2) => from$1 === s2.pos + 1 && to === s2.end - 1);
212897
+ const exactContentSDT = sdtNodes.find((s2) => selectionCoversSdtContent(s2, from$1, to));
212821
212898
  if (exactContentSDT) {
212822
212899
  const isContentLocked = exactContentSDT.lockMode === "contentLocked" || exactContentSDT.lockMode === "sdtContentLocked";
212823
212900
  const isWrapperDeletable = exactContentSDT.lockMode !== "sdtLocked" && exactContentSDT.lockMode !== "sdtContentLocked";
@@ -213950,80 +214027,70 @@ function shallowEqual$2(a2, b$1) {
213950
214027
  return false;
213951
214028
  return true;
213952
214029
  }
213953
- function isSdtContentFullyLocked(node2) {
213954
- return node2.attrs.lockMode === "sdtContentLocked";
213955
- }
213956
- function findAncestorDepth$2($pos, predicate) {
214030
+ function findAncestorDepth$3($pos, predicate) {
213957
214031
  for (let depth = $pos.depth;depth > 0; depth -= 1)
213958
214032
  if (predicate($pos.node(depth)))
213959
214033
  return depth;
213960
214034
  return null;
213961
214035
  }
213962
- function isZeroWidthMarker(node2) {
213963
- if (node2.type.name === "fieldAnnotation" && node2.attrs?.hidden === true)
213964
- return true;
213965
- return ZERO_WIDTH_MARKER_NODE_NAMES.has(node2.type.name);
213966
- }
213967
- function findFirstTextPosInNode(node2, nodePos) {
213968
- if (node2.isText)
213969
- return nodePos;
213970
- for (let index2 = 0, offset$1 = 0;index2 < node2.childCount; index2 += 1) {
213971
- const child = node2.child(index2);
213972
- const found2 = findFirstTextPosInNode(child, nodePos + 1 + offset$1);
213973
- if (found2 != null)
213974
- return found2;
213975
- offset$1 += child.nodeSize;
214036
+ function findSiblingAcrossHiddenMarkers$1(doc$12, pos, direction) {
214037
+ let currentPos = pos;
214038
+ let node2 = direction === "before" ? doc$12.resolve(currentPos).nodeBefore : doc$12.resolve(currentPos).nodeAfter;
214039
+ while (node2 && isZeroWidthMarker(node2)) {
214040
+ currentPos += direction === "before" ? -node2.nodeSize : node2.nodeSize;
214041
+ node2 = direction === "before" ? doc$12.resolve(currentPos).nodeBefore : doc$12.resolve(currentPos).nodeAfter;
213976
214042
  }
213977
- return null;
214043
+ return {
214044
+ node: node2,
214045
+ nodePos: direction === "before" && node2 ? currentPos - node2.nodeSize : currentPos
214046
+ };
213978
214047
  }
213979
- function findFirstContentCursorPosInNode(node2, nodePos) {
213980
- if (isZeroWidthMarker(node2))
214048
+ function isAtTextBlockBoundary($from, direction) {
214049
+ const textblockDepth = findAncestorDepth$3($from, (node2) => node2.isTextblock);
214050
+ if (textblockDepth == null)
213981
214051
  return null;
213982
- if (node2.isText || node2.isAtom)
213983
- return nodePos;
213984
- if (node2.isTextblock && node2.childCount === 0)
213985
- return nodePos + 1;
213986
- for (let index2 = 0, offset$1 = 0;index2 < node2.childCount; index2 += 1) {
213987
- const child = node2.child(index2);
213988
- const found2 = findFirstContentCursorPosInNode(child, nodePos + 1 + offset$1);
213989
- if (found2 != null)
213990
- return found2;
213991
- offset$1 += child.nodeSize;
213992
- }
213993
- if (node2.isTextblock)
213994
- return nodePos + 1;
213995
- return null;
214052
+ const textblock = $from.node(textblockDepth);
214053
+ const textblockPos = $from.before(textblockDepth);
214054
+ const boundary = direction === "before" ? findFirstContentCursorPosInNode(textblock, textblockPos) ?? $from.start(textblockDepth) : findLastContentCursorPosInNode(textblock, textblockPos) ?? $from.end(textblockDepth);
214055
+ if ($from.pos !== boundary)
214056
+ return null;
214057
+ return {
214058
+ textblockDepth,
214059
+ textblockPos
214060
+ };
213996
214061
  }
213997
- function findLastTextPosInNode(node2, nodePos) {
213998
- if (node2.isText)
213999
- return nodePos + (node2.text?.length ?? 0);
214000
- for (let index2 = node2.childCount - 1, offset$1 = node2.content.size;index2 >= 0; index2 -= 1) {
214001
- const child = node2.child(index2);
214002
- offset$1 -= child.nodeSize;
214003
- const found2 = findLastTextPosInNode(child, nodePos + 1 + offset$1);
214004
- if (found2 != null)
214005
- return found2;
214006
- }
214007
- return null;
214062
+ function selectAdjacentBlockSdtContent(direction) {
214063
+ return ({ state, dispatch }) => {
214064
+ const { selection } = state;
214065
+ if (!selection.empty)
214066
+ return false;
214067
+ const boundary = isAtTextBlockBoundary(selection.$from, direction);
214068
+ if (!boundary)
214069
+ return false;
214070
+ const siblingBoundaryPos = direction === "before" ? boundary.textblockPos : selection.$from.after(boundary.textblockDepth);
214071
+ const { node: node2, nodePos } = findSiblingAcrossHiddenMarkers$1(state.doc, siblingBoundaryPos, direction);
214072
+ if (node2?.type.name !== "structuredContentBlock")
214073
+ return false;
214074
+ if (node2.content.size === 0)
214075
+ return false;
214076
+ const contentStart = findFirstContentCursorPosInNode(node2, nodePos);
214077
+ const contentEnd = findLastContentCursorPosInNode(node2, nodePos);
214078
+ if (contentStart == null || contentEnd == null)
214079
+ return false;
214080
+ if (contentStart >= contentEnd)
214081
+ return false;
214082
+ if (dispatch)
214083
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, contentStart, contentEnd)).scrollIntoView());
214084
+ return true;
214085
+ };
214008
214086
  }
214009
- function findLastContentCursorPosInNode(node2, nodePos) {
214010
- if (isZeroWidthMarker(node2))
214011
- return null;
214012
- if (node2.isText)
214013
- return nodePos + (node2.text?.length ?? 0);
214014
- if (node2.isAtom)
214015
- return node2.isInline ? nodePos + node2.nodeSize : nodePos;
214016
- if (node2.isTextblock && node2.childCount === 0)
214017
- return nodePos + 1;
214018
- for (let index2 = node2.childCount - 1, offset$1 = node2.content.size;index2 >= 0; index2 -= 1) {
214019
- const child = node2.child(index2);
214020
- offset$1 -= child.nodeSize;
214021
- const found2 = findLastContentCursorPosInNode(child, nodePos + 1 + offset$1);
214022
- if (found2 != null)
214023
- return found2;
214024
- }
214025
- if (node2.isTextblock)
214026
- return nodePos + node2.nodeSize - 1;
214087
+ function isSdtContentFullyLocked(node2) {
214088
+ return node2.attrs.lockMode === "sdtContentLocked";
214089
+ }
214090
+ function findAncestorDepth$2($pos, predicate) {
214091
+ for (let depth = $pos.depth;depth > 0; depth -= 1)
214092
+ if (predicate($pos.node(depth)))
214093
+ return depth;
214027
214094
  return null;
214028
214095
  }
214029
214096
  function findAncestorDepth$1($pos, predicate) {
@@ -272702,7 +272769,7 @@ var Node$13 = class Node$14 {
272702
272769
  const transaction = view.state.tr.setSelection(selection);
272703
272770
  view.dispatch(transaction);
272704
272771
  }
272705
- }, StructuredContentInlineView, findChildren$12, SD_BLOCK_ID_ATTRIBUTE_NAME = "sdBlockId", SD_BLOCK_REV_ATTRIBUTE_NAME = "sdBlockRev", BLOCK_NODE_METADATA_UPDATE_META = "blockNodeMetadataUpdate", BlockNodePluginKey, BlockNode, nodeAllowsSdBlockIdAttr = (node2) => {
272772
+ }, StructuredContentInlineView, ZERO_WIDTH_MARKER_NODE_NAMES, findChildren$12, SD_BLOCK_ID_ATTRIBUTE_NAME = "sdBlockId", SD_BLOCK_REV_ATTRIBUTE_NAME = "sdBlockRev", BLOCK_NODE_METADATA_UPDATE_META = "blockNodeMetadataUpdate", BlockNodePluginKey, BlockNode, nodeAllowsSdBlockIdAttr = (node2) => {
272706
272773
  return !!(node2?.isBlock && node2?.type?.spec?.attrs?.[SD_BLOCK_ID_ATTRIBUTE_NAME]);
272707
272774
  }, nodeAllowsSdBlockRevAttr = (node2) => {
272708
272775
  return !!(node2?.isBlock && node2?.type?.spec?.attrs?.[SD_BLOCK_REV_ATTRIBUTE_NAME]);
@@ -274358,7 +274425,7 @@ var Node$13 = class Node$14 {
274358
274425
  dispatch(tr.scrollIntoView());
274359
274426
  }
274360
274427
  return true;
274361
- }, deleteBlockSdtAtTextBlockStart = () => ({ state, dispatch }) => {
274428
+ }, selectBlockSdtBeforeTextBlockStart = () => selectAdjacentBlockSdtContent("before"), selectBlockSdtAfterTextBlockEnd = () => selectAdjacentBlockSdtContent("after"), deleteBlockSdtAtTextBlockStart = () => ({ state, dispatch }) => {
274362
274429
  const { selection } = state;
274363
274430
  if (!selection.empty)
274364
274431
  return false;
@@ -274387,7 +274454,7 @@ var Node$13 = class Node$14 {
274387
274454
  dispatch(tr.setSelection(Selection.near(tr.doc.resolve(selectionPos), -1)).scrollIntoView());
274388
274455
  }
274389
274456
  return true;
274390
- }, ZERO_WIDTH_MARKER_NODE_NAMES, moveIntoBlockSdtBeforeTextBlockStart = () => moveIntoAdjacentBlockSdt("before"), moveIntoBlockSdtAfterTextBlockEnd = () => moveIntoAdjacentBlockSdt("after"), deleteSkipEmptyRun = () => ({ state, dispatch }) => {
274457
+ }, moveIntoBlockSdtBeforeTextBlockStart = () => moveIntoAdjacentBlockSdt("before"), moveIntoBlockSdtAfterTextBlockEnd = () => moveIntoAdjacentBlockSdt("after"), deleteSkipEmptyRun = () => ({ state, dispatch }) => {
274391
274458
  const sel = state.selection;
274392
274459
  if (!sel.empty)
274393
274460
  return false;
@@ -285754,6 +285821,7 @@ var Node$13 = class Node$14 {
285754
285821
  },
285755
285822
  () => commands$1.deleteBlockSdtAtTextBlockStart(),
285756
285823
  () => commands$1.selectInlineSdtBeforeRunStart(),
285824
+ () => commands$1.selectBlockSdtBeforeTextBlockStart(),
285757
285825
  () => commands$1.moveIntoBlockSdtBeforeTextBlockStart(),
285758
285826
  () => commands$1.backspaceEmptyRunParagraph(),
285759
285827
  () => commands$1.backspaceSkipEmptyRun(),
@@ -285772,6 +285840,7 @@ var Node$13 = class Node$14 {
285772
285840
  return editor.commands.first(({ commands: commands$1 }) => [
285773
285841
  () => commands$1.deleteBlockSdtAtTextBlockStart(),
285774
285842
  () => commands$1.selectInlineSdtAfterRunEnd(),
285843
+ () => commands$1.selectBlockSdtAfterTextBlockEnd(),
285775
285844
  () => commands$1.moveIntoBlockSdtAfterTextBlockEnd(),
285776
285845
  () => commands$1.deleteSkipEmptyRun(),
285777
285846
  () => commands$1.deleteAtomAfter(),
@@ -287803,7 +287872,7 @@ var Node$13 = class Node$14 {
287803
287872
  return false;
287804
287873
  const docs = tr.docs ?? [];
287805
287874
  return tr.steps.some((step2, index2) => stepTouchesTrackedReviewState(step2, docs[index2] ?? state.doc));
287806
- }, cloneExtensionInstance = (extension2) => {
287875
+ }, CONTENT_CONTROL_POINTER_WINDOW_MS = 800, cloneExtensionInstance = (extension2) => {
287807
287876
  const extensionLike = extension2;
287808
287877
  const config3 = extensionLike?.config;
287809
287878
  const ExtensionCtor = extensionLike?.constructor;
@@ -304384,7 +304453,7 @@ menclose::after {
304384
304453
  nextSelection = TextSelection.create(doc$12, hit.pos);
304385
304454
  if (!nextSelection.$from.parent.inlineContent)
304386
304455
  nextSelection = Selection.near(doc$12.resolve(hit.pos), 1);
304387
- let tr = editor.state.tr.setSelection(nextSelection);
304456
+ let tr = editor.state.tr.setSelection(nextSelection).setMeta("uiEvent", "click");
304388
304457
  if (inlineSdtBoundaryPos != null && inlineSdtBoundaryDirection) {
304389
304458
  tr = applyEditableSlotAtInlineBoundary(tr, inlineSdtBoundaryPos, inlineSdtBoundaryDirection);
304390
304459
  nextSelection = tr.selection;
@@ -308360,7 +308429,7 @@ menclose::after {
308360
308429
  return;
308361
308430
  console.log(...args$1);
308362
308431
  }, 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;
308363
- var init_src_B9A7ox0h_es = __esm(() => {
308432
+ var init_src_CYzfdR4C_es = __esm(() => {
308364
308433
  init_rolldown_runtime_Bg48TavK_es();
308365
308434
  init_SuperConverter_C6hKp29w_es();
308366
308435
  init_jszip_C49i9kUs_es();
@@ -310118,6 +310187,22 @@ ${err.toString()}`);
310118
310187
  return true;
310119
310188
  }
310120
310189
  };
310190
+ ZERO_WIDTH_MARKER_NODE_NAMES = new Set([
310191
+ "bookmarkStart",
310192
+ "bookmarkEnd",
310193
+ "commentRangeStart",
310194
+ "commentRangeEnd",
310195
+ "commentReference",
310196
+ "permStart",
310197
+ "permEnd",
310198
+ "permStartBlock",
310199
+ "permEndBlock",
310200
+ "tableOfContentsEntry",
310201
+ "indexEntry",
310202
+ "authorityEntry",
310203
+ "passthroughInline",
310204
+ "passthroughBlock"
310205
+ ]);
310121
310206
  ({ findChildren: findChildren$12 } = helpers_exports);
310122
310207
  BlockNodePluginKey = new PluginKey("blockNodePlugin");
310123
310208
  BlockNode = Extension.create({
@@ -311386,22 +311471,6 @@ ${err.toString()}`);
311386
311471
  macBaseKeymap[key2] = pcBaseKeymap[key2];
311387
311472
  typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os != "undefined" && os.platform && os.platform();
311388
311473
  DELETABLE_INLINE_ATOMS$1 = new Set(["noBreakHyphen"]);
311389
- ZERO_WIDTH_MARKER_NODE_NAMES = new Set([
311390
- "bookmarkStart",
311391
- "bookmarkEnd",
311392
- "commentRangeStart",
311393
- "commentRangeEnd",
311394
- "commentReference",
311395
- "permStart",
311396
- "permEnd",
311397
- "permStartBlock",
311398
- "permEndBlock",
311399
- "tableOfContentsEntry",
311400
- "indexEntry",
311401
- "authorityEntry",
311402
- "passthroughInline",
311403
- "passthroughBlock"
311404
- ]);
311405
311474
  DELETABLE_INLINE_ATOMS = new Set(["noBreakHyphen"]);
311406
311475
  commands_exports = /* @__PURE__ */ __export2({
311407
311476
  SELECT_INLINE_SDT_BEFORE_RUN_START_META: () => SELECT_INLINE_SDT_BEFORE_RUN_START_META,
@@ -311452,6 +311521,8 @@ ${err.toString()}`);
311452
311521
  resetAttributes: () => resetAttributes,
311453
311522
  restoreSelection: () => restoreSelection,
311454
311523
  selectAll: () => selectAll$1,
311524
+ selectBlockSdtAfterTextBlockEnd: () => selectBlockSdtAfterTextBlockEnd,
311525
+ selectBlockSdtBeforeTextBlockStart: () => selectBlockSdtBeforeTextBlockStart,
311455
311526
  selectInlineSdtAfterRunEnd: () => selectInlineSdtAfterRunEnd,
311456
311527
  selectInlineSdtBeforeRunStart: () => selectInlineSdtBeforeRunStart,
311457
311528
  selectNodeBackward: () => selectNodeBackward$1,
@@ -332558,6 +332629,8 @@ function print() { __p += __j.call(arguments, '') }
332558
332629
  }
332559
332630
  #telemetry = null;
332560
332631
  #documentOpenTracked = false;
332632
+ #lastActiveContentControlRef = null;
332633
+ #lastPointerDownAt = 0;
332561
332634
  #constructorFragment = null;
332562
332635
  constructor(options) {
332563
332636
  super();
@@ -332779,9 +332852,15 @@ function print() { __p += __j.call(arguments, '') }
332779
332852
  this.on("fonts-resolved", this.options.onFontsResolved);
332780
332853
  this.on("exception", this.options.onException);
332781
332854
  this.on("pointerDown", this.options.onPointerDown);
332855
+ this.#trackContentControlPointer();
332782
332856
  this.on("pointerUp", this.options.onPointerUp);
332783
332857
  this.on("rightClick", this.options.onRightClick);
332784
332858
  }
332859
+ #trackContentControlPointer() {
332860
+ this.on("pointerDown", () => {
332861
+ this.#lastPointerDownAt = Date.now();
332862
+ });
332863
+ }
332785
332864
  async#loadDocument(source, options) {
332786
332865
  try {
332787
332866
  const resolvedMode = options?.mode ?? this.options.mode ?? "docx";
@@ -332932,6 +333011,8 @@ function print() { __p += __j.call(arguments, '') }
332932
333011
  this.options.fileSource = null;
332933
333012
  this.options.fragment = null;
332934
333013
  this._state = undefined;
333014
+ this.#lastActiveContentControlRef = null;
333015
+ this.#lastPointerDownAt = 0;
332935
333016
  }
332936
333017
  #initProtectionState() {
332937
333018
  const protStorage = getProtectionStorage(this);
@@ -332991,6 +333072,7 @@ function print() { __p += __j.call(arguments, '') }
332991
333072
  this.on("fonts-resolved", this.options.onFontsResolved);
332992
333073
  this.on("exception", this.options.onException);
332993
333074
  this.on("pointerDown", this.options.onPointerDown);
333075
+ this.#trackContentControlPointer();
332994
333076
  this.on("pointerUp", this.options.onPointerUp);
332995
333077
  this.on("rightClick", this.options.onRightClick);
332996
333078
  if (!shouldMountRenderer)
@@ -333039,6 +333121,7 @@ function print() { __p += __j.call(arguments, '') }
333039
333121
  this.on("locked", this.options.onDocumentLocked);
333040
333122
  this.on("list-definitions-change", this.options.onListDefinitionsChange);
333041
333123
  this.on("pointerDown", this.options.onPointerDown);
333124
+ this.#trackContentControlPointer();
333042
333125
  this.on("pointerUp", this.options.onPointerUp);
333043
333126
  this.on("rightClick", this.options.onRightClick);
333044
333127
  if (!shouldMountRenderer)
@@ -333858,6 +333941,11 @@ function print() { __p += __j.call(arguments, '') }
333858
333941
  editor: this,
333859
333942
  transaction: transactionToApply
333860
333943
  });
333944
+ this.#emitContentControlEvents({
333945
+ transaction: transactionToApply,
333946
+ nextState,
333947
+ selectionHasChanged
333948
+ });
333861
333949
  const focus = transactionToApply.getMeta("focus");
333862
333950
  if (focus)
333863
333951
  this.emit("focus", {
@@ -333886,6 +333974,82 @@ function print() { __p += __j.call(arguments, '') }
333886
333974
  });
333887
333975
  }
333888
333976
  }
333977
+ #emitContentControlEvents({ transaction, nextState, selectionHasChanged }) {
333978
+ const uiEvent = transaction.getMeta("uiEvent");
333979
+ const recentPointerDown = Date.now() - this.#lastPointerDownAt <= CONTENT_CONTROL_POINTER_WINDOW_MS;
333980
+ const source = uiEvent === "click" || recentPointerDown ? "pointer" : "keyboard";
333981
+ const activePath = nextState.selection ? this.#collectActiveSdtRefs(nextState.selection) : [];
333982
+ const activeContentControl = activePath[0] ?? null;
333983
+ if (selectionHasChanged) {
333984
+ const previous3 = this.#lastActiveContentControlRef;
333985
+ if (previous3?.id !== activeContentControl?.id) {
333986
+ if (activeContentControl)
333987
+ this.emit("contentControlFocus", {
333988
+ active: activeContentControl,
333989
+ previous: previous3,
333990
+ activePath,
333991
+ source
333992
+ });
333993
+ else if (previous3)
333994
+ this.emit("contentControlBlur", {
333995
+ active: null,
333996
+ previous: previous3,
333997
+ activePath: [],
333998
+ source
333999
+ });
334000
+ this.#lastActiveContentControlRef = activeContentControl;
334001
+ }
334002
+ }
334003
+ if (uiEvent === "click" && activeContentControl)
334004
+ this.emit("contentControlClick", {
334005
+ target: activeContentControl,
334006
+ source: "pointer"
334007
+ });
334008
+ }
334009
+ #collectActiveSdtRefs(selection) {
334010
+ const refs = [];
334011
+ const seenIds = /* @__PURE__ */ new Set;
334012
+ const selectedNode = selection instanceof NodeSelection ? selection.node : null;
334013
+ if (selectedNode && (selectedNode.type?.name === "structuredContent" || selectedNode.type?.name === "structuredContentBlock")) {
334014
+ const ref$1 = this.#toSdtRef(selectedNode);
334015
+ if (ref$1) {
334016
+ refs.push(ref$1);
334017
+ seenIds.add(ref$1.id);
334018
+ }
334019
+ }
334020
+ const anchor = selection.$anchor;
334021
+ if (anchor && typeof anchor.depth === "number" && typeof anchor.node === "function")
334022
+ for (let depth = anchor.depth;depth >= 0; depth -= 1) {
334023
+ const node2 = anchor.node(depth);
334024
+ if (!node2)
334025
+ continue;
334026
+ const typeName = node2?.type?.name;
334027
+ if (typeName !== "structuredContent" && typeName !== "structuredContentBlock")
334028
+ continue;
334029
+ const ref$1 = this.#toSdtRef(node2);
334030
+ if (!ref$1)
334031
+ continue;
334032
+ if (seenIds.has(ref$1.id))
334033
+ continue;
334034
+ refs.push(ref$1);
334035
+ seenIds.add(ref$1.id);
334036
+ }
334037
+ return refs;
334038
+ }
334039
+ #toSdtRef(node2) {
334040
+ const attrs = node2.attrs;
334041
+ const id2 = attrs?.id;
334042
+ if (typeof id2 !== "string" || id2.length === 0)
334043
+ return null;
334044
+ const scope = node2.type.name === "structuredContent" ? "inline" : "block";
334045
+ return {
334046
+ id: id2,
334047
+ tag: typeof attrs.tag === "string" ? attrs.tag : undefined,
334048
+ alias: typeof attrs.alias === "string" ? attrs.alias : undefined,
334049
+ controlType: typeof attrs.controlType === "string" ? attrs.controlType : "unknown",
334050
+ scope
334051
+ };
334052
+ }
333889
334053
  dispatch(tr) {
333890
334054
  this.#dispatchTransaction(tr);
333891
334055
  }
@@ -342613,7 +342777,7 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
342613
342777
 
342614
342778
  // ../../packages/superdoc/dist/super-editor.es.js
342615
342779
  var init_super_editor_es = __esm(() => {
342616
- init_src_B9A7ox0h_es();
342780
+ init_src_CYzfdR4C_es();
342617
342781
  init_SuperConverter_C6hKp29w_es();
342618
342782
  init_jszip_C49i9kUs_es();
342619
342783
  init_xml_js_CqGKpaft_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.10.0-next.5",
3
+ "version": "0.10.0-next.7",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"