@superdoc-dev/mcp 0.3.0-next.64 → 0.3.0-next.65

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 +599 -167
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -199223,7 +199223,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
199223
199223
  init_remark_gfm_BhnWr3yf_es();
199224
199224
  });
199225
199225
 
199226
- // ../../packages/superdoc/dist/chunks/src-C-jV2TZI.es.js
199226
+ // ../../packages/superdoc/dist/chunks/src-CSHo1aJM.es.js
199227
199227
  function deleteProps(obj, propOrProps) {
199228
199228
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
199229
199229
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -240188,6 +240188,49 @@ function resolveAnnotationDisplayLabel(annotation, contentEl) {
240188
240188
  value: derivedLabel
240189
240189
  };
240190
240190
  }
240191
+ function parsePmNumber(value) {
240192
+ return value && value.trim().length > 0 ? value : null;
240193
+ }
240194
+ function collectImageRoots(container) {
240195
+ const roots = [];
240196
+ const seen = /* @__PURE__ */ new Set;
240197
+ const add = (element3) => {
240198
+ if (!element3 || seen.has(element3))
240199
+ return;
240200
+ seen.add(element3);
240201
+ roots.push(element3);
240202
+ };
240203
+ for (const fragment of Array.from(container.querySelectorAll(`.${DOM_CLASS_NAMES.IMAGE_FRAGMENT}`))) {
240204
+ if (!fragment.hasAttribute("data-image-metadata") && fragment.querySelector?.(`[data-image-metadata]`) == null)
240205
+ continue;
240206
+ add(fragment);
240207
+ }
240208
+ for (const wrapper of Array.from(container.querySelectorAll(`.${DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER}`))) {
240209
+ if (wrapper.querySelector?.(`[data-image-metadata]`) == null)
240210
+ continue;
240211
+ add(wrapper);
240212
+ }
240213
+ for (const inlineImage of Array.from(container.querySelectorAll(`.${DOM_CLASS_NAMES.INLINE_IMAGE}`)))
240214
+ if (inlineImage.hasAttribute("data-image-metadata") && inlineImage.closest(`.${DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER}`) == null)
240215
+ add(inlineImage);
240216
+ return roots;
240217
+ }
240218
+ function resolveImageLabel(root3) {
240219
+ const directLabel = root3.dataset[DATASET_KEYS.DISPLAY_LABEL];
240220
+ if (directLabel)
240221
+ return directLabel;
240222
+ const img2 = root3.tagName === "IMG" ? root3 : root3.querySelector("img");
240223
+ const alt = img2?.getAttribute("alt")?.trim();
240224
+ if (alt)
240225
+ return alt;
240226
+ const title = img2?.getAttribute("title")?.trim();
240227
+ if (title)
240228
+ return title;
240229
+ return root3.getAttribute("data-block-id") ?? root3.getAttribute("data-sd-block-id") ?? "Image";
240230
+ }
240231
+ function resolveImageKind(root3) {
240232
+ return root3.classList.contains(DOM_CLASS_NAMES.IMAGE_FRAGMENT) ? "block" : "inline";
240233
+ }
240191
240234
  function cssClassForKind(kind) {
240192
240235
  switch (kind) {
240193
240236
  case "spelling":
@@ -251583,6 +251626,97 @@ function findNearestTextblockResolvedPos(doc$12, pos) {
251583
251626
  return null;
251584
251627
  return textblockPos;
251585
251628
  }
251629
+ function matchesStructuredContentId(node2, id2) {
251630
+ if (!id2)
251631
+ return false;
251632
+ const attrs = node2.attrs;
251633
+ const nodeId = attrs?.id;
251634
+ const nodeSdtId = attrs?.sdtId;
251635
+ return nodeId != null && String(nodeId) === id2 || nodeSdtId != null && String(nodeSdtId) === id2;
251636
+ }
251637
+ function resolvePosSafely(doc$12, pos) {
251638
+ if (!Number.isInteger(pos))
251639
+ return null;
251640
+ try {
251641
+ return doc$12.resolve(pos);
251642
+ } catch {
251643
+ return null;
251644
+ }
251645
+ }
251646
+ function findStructuredContentBlockAtPos(doc$12, pos) {
251647
+ if (!Number.isFinite(pos))
251648
+ return null;
251649
+ const $pos = resolvePosSafely(doc$12, pos);
251650
+ if (!$pos)
251651
+ return null;
251652
+ for (let depth = $pos.depth;depth > 0; depth--) {
251653
+ const node2 = $pos.node(depth);
251654
+ if (node2.type?.name === "structuredContentBlock")
251655
+ return {
251656
+ node: node2,
251657
+ pos: $pos.before(depth),
251658
+ start: $pos.start(depth),
251659
+ end: $pos.end(depth)
251660
+ };
251661
+ }
251662
+ return null;
251663
+ }
251664
+ function findStructuredContentBlockById(doc$12, id2) {
251665
+ if (!id2)
251666
+ return null;
251667
+ let found2 = null;
251668
+ doc$12.descendants((node2, pos) => {
251669
+ if (node2.type?.name !== "structuredContentBlock")
251670
+ return true;
251671
+ if (!matchesStructuredContentId(node2, id2))
251672
+ return true;
251673
+ found2 = {
251674
+ node: node2,
251675
+ pos,
251676
+ start: pos + 1,
251677
+ end: pos + node2.nodeSize - 1
251678
+ };
251679
+ return false;
251680
+ });
251681
+ return found2;
251682
+ }
251683
+ function findStructuredContentInlineAtPos(doc$12, pos) {
251684
+ if (!Number.isFinite(pos))
251685
+ return null;
251686
+ const $pos = resolvePosSafely(doc$12, pos);
251687
+ if (!$pos)
251688
+ return null;
251689
+ for (let depth = $pos.depth;depth > 0; depth--) {
251690
+ const node2 = $pos.node(depth);
251691
+ if (node2.type?.name === "structuredContent")
251692
+ return {
251693
+ node: node2,
251694
+ pos: $pos.before(depth),
251695
+ start: $pos.start(depth),
251696
+ end: $pos.end(depth)
251697
+ };
251698
+ }
251699
+ return null;
251700
+ }
251701
+ function findStructuredContentInlineById(doc$12, id2) {
251702
+ if (!id2)
251703
+ return null;
251704
+ let found2 = null;
251705
+ doc$12.descendants((node2, pos) => {
251706
+ if (node2.type?.name !== "structuredContent")
251707
+ return true;
251708
+ if (!matchesStructuredContentId(node2, id2))
251709
+ return true;
251710
+ found2 = {
251711
+ node: node2,
251712
+ pos,
251713
+ start: pos + 1,
251714
+ end: pos + node2.nodeSize - 1
251715
+ };
251716
+ return false;
251717
+ });
251718
+ return found2;
251719
+ }
251586
251720
  function getSelectionDebugConfig() {
251587
251721
  if (typeof window === "undefined")
251588
251722
  return DEFAULT_CONFIG;
@@ -252674,7 +252808,7 @@ function createLayoutMetrics(perf, startMark, layout, blocks2) {
252674
252808
  };
252675
252809
  }
252676
252810
  function coerceNumber(value) {
252677
- if (isFiniteNumber(value))
252811
+ if (isFiniteNumber$1(value))
252678
252812
  return Number(value);
252679
252813
  if (typeof value === "string" && value.trim() !== "") {
252680
252814
  const parsed = Number(value);
@@ -252682,7 +252816,7 @@ function coerceNumber(value) {
252682
252816
  }
252683
252817
  }
252684
252818
  function coercePositiveNumber(value, fallback) {
252685
- if (!isFiniteNumber(fallback) || fallback <= 0)
252819
+ if (!isFiniteNumber$1(fallback) || fallback <= 0)
252686
252820
  throw new Error(`coercePositiveNumber: fallback must be a positive number, got ${fallback}`);
252687
252821
  const numeric = coerceNumber(value);
252688
252822
  if (numeric != null && numeric > 0)
@@ -252728,7 +252862,7 @@ function toBoxSpacing(spacing) {
252728
252862
  "left"
252729
252863
  ].forEach((side) => {
252730
252864
  const value = spacing[side];
252731
- if (isFiniteNumber(value))
252865
+ if (isFiniteNumber$1(value))
252732
252866
  result[side] = Number(value);
252733
252867
  });
252734
252868
  return Object.keys(result).length > 0 ? result : undefined;
@@ -252762,7 +252896,7 @@ function isShapeGroupTransform(value) {
252762
252896
  if (!value || typeof value !== "object")
252763
252897
  return false;
252764
252898
  const maybe = value;
252765
- return isFiniteNumber(maybe.x) || isFiniteNumber(maybe.y) || isFiniteNumber(maybe.width) || isFiniteNumber(maybe.height) || isFiniteNumber(maybe.childWidth) || isFiniteNumber(maybe.childHeight) || isFiniteNumber(maybe.childX) || isFiniteNumber(maybe.childY);
252899
+ return isFiniteNumber$1(maybe.x) || isFiniteNumber$1(maybe.y) || isFiniteNumber$1(maybe.width) || isFiniteNumber$1(maybe.height) || isFiniteNumber$1(maybe.childWidth) || isFiniteNumber$1(maybe.childHeight) || isFiniteNumber$1(maybe.childX) || isFiniteNumber$1(maybe.childY);
252766
252900
  }
252767
252901
  function normalizeShapeSize(value) {
252768
252902
  if (!value || typeof value !== "object")
@@ -253168,7 +253302,7 @@ function convertBorderSpec(ooxmlBorder, options) {
253168
253302
  style: "none",
253169
253303
  width: 0
253170
253304
  };
253171
- if (!isFiniteNumber(sizeNumber))
253305
+ if (!isFiniteNumber$1(sizeNumber))
253172
253306
  return;
253173
253307
  const numericSize = sizeNumber;
253174
253308
  if (numericSize <= 0)
@@ -253195,7 +253329,7 @@ function convertTableBorderValue(ooxmlBorder, options) {
253195
253329
  const { val, size: size$1, color: color2 } = border;
253196
253330
  if (val === "nil" || val === "none" || size$1 === 0)
253197
253331
  return { none: true };
253198
- if (!isFiniteNumber(size$1))
253332
+ if (!isFiniteNumber$1(size$1))
253199
253333
  return;
253200
253334
  const numericSize = size$1;
253201
253335
  if (numericSize <= 0)
@@ -254768,7 +254902,7 @@ function toBoxSpacing$1(spacing) {
254768
254902
  "left"
254769
254903
  ].forEach((side) => {
254770
254904
  const value = spacing[side];
254771
- if (isFiniteNumber(value))
254905
+ if (isFiniteNumber$1(value))
254772
254906
  result[side] = Number(value);
254773
254907
  });
254774
254908
  return Object.keys(result).length > 0 ? result : undefined;
@@ -257705,6 +257839,143 @@ async function goToAnchor({ anchor, layout, blocks: blocks2, measures, bookmarks
257705
257839
  console.warn("[PresentationEditor] goToAnchor: Navigation succeeded but could not move caret (editor commands unavailable)");
257706
257840
  return true;
257707
257841
  }
257842
+ function isFiniteNumber(value) {
257843
+ return typeof value === "number" && Number.isFinite(value);
257844
+ }
257845
+ function readString(value) {
257846
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
257847
+ }
257848
+ function readNumber(value) {
257849
+ if (isFiniteNumber(value))
257850
+ return value;
257851
+ if (typeof value === "string" && value.trim().length > 0) {
257852
+ const parsed = Number(value);
257853
+ return Number.isFinite(parsed) ? parsed : null;
257854
+ }
257855
+ return null;
257856
+ }
257857
+ function buildStructuredContentDragPayload(sourceElement) {
257858
+ const dataset = sourceElement.dataset;
257859
+ const sdtId = readString(dataset.sdtId);
257860
+ const sourceStart = readNumber(dataset.pmStart);
257861
+ const sourceEnd = readNumber(dataset.pmEnd);
257862
+ if (!sdtId || sourceStart == null || sourceEnd == null)
257863
+ return null;
257864
+ return {
257865
+ kind: "structuredContent",
257866
+ nodeType: dataset.nodeType === "structuredContentBlock" ? "structuredContentBlock" : "structuredContent",
257867
+ sdtId,
257868
+ label: readString(dataset.displayLabel) ?? sourceElement.textContent?.trim() ?? "Structured content",
257869
+ sourceStart,
257870
+ sourceEnd,
257871
+ lockMode: readString(dataset.lockMode) ?? "unlocked"
257872
+ };
257873
+ }
257874
+ function buildExistingImageDragPayload(sourceElement) {
257875
+ const dataset = sourceElement.dataset;
257876
+ const sourceStart = readNumber(dataset.pmStart);
257877
+ const sourceEnd = readNumber(dataset.pmEnd);
257878
+ if (sourceStart == null || sourceEnd == null)
257879
+ return null;
257880
+ return {
257881
+ kind: "existingImage",
257882
+ imageKind: dataset.imageKind === "block" ? "block" : "inline",
257883
+ nodeType: dataset.nodeType ?? "image",
257884
+ sourceStart,
257885
+ sourceEnd,
257886
+ blockId: readString(dataset.blockId) ?? readString(sourceElement.getAttribute("data-block-id")) ?? readString(sourceElement.getAttribute("data-sd-block-id")) ?? undefined,
257887
+ label: readString(dataset.displayLabel) ?? sourceElement.getAttribute("aria-label") ?? "Image"
257888
+ };
257889
+ }
257890
+ function buildInternalObjectDragPayload(sourceElement) {
257891
+ const sourceKind = sourceElement.dataset.dragSourceKind;
257892
+ if (sourceKind === "structuredContent")
257893
+ return buildStructuredContentDragPayload(sourceElement);
257894
+ if (sourceKind === "existingImage")
257895
+ return buildExistingImageDragPayload(sourceElement);
257896
+ return null;
257897
+ }
257898
+ function canInsertNodeAtPosition(doc$12, pos, node2) {
257899
+ try {
257900
+ const resolvedPos = doc$12.resolve(pos);
257901
+ const { parent } = resolvedPos;
257902
+ const index2 = resolvedPos.index();
257903
+ if (typeof parent.canReplaceWith === "function")
257904
+ return parent.canReplaceWith(index2, index2, node2.type);
257905
+ return Boolean(parent.type.contentMatch.matchType(node2.type));
257906
+ } catch {
257907
+ return false;
257908
+ }
257909
+ }
257910
+ function resolveInsertionBoundary(doc$12, pos, node2, canInsertAt, bias) {
257911
+ try {
257912
+ const resolvedPos = doc$12.resolve(pos);
257913
+ const candidates = [];
257914
+ for (let depth = resolvedPos.depth;depth > 0; depth--) {
257915
+ const before = resolvedPos.before(depth);
257916
+ const after = resolvedPos.after(depth);
257917
+ if (bias === "before")
257918
+ candidates.push(before, after);
257919
+ else
257920
+ candidates.push(after, before);
257921
+ }
257922
+ for (const candidate of candidates) {
257923
+ if (candidate < 0 || candidate > doc$12.content.size)
257924
+ continue;
257925
+ if (candidate === pos)
257926
+ continue;
257927
+ if (canInsertAt(doc$12, candidate, node2))
257928
+ return candidate;
257929
+ }
257930
+ } catch {
257931
+ return null;
257932
+ }
257933
+ return null;
257934
+ }
257935
+ function createInternalNodeMoveTransaction(state, request) {
257936
+ const { sourceStart, sourceEnd, targetPos, expectedNodeType, canInsertAt } = request;
257937
+ if (targetPos >= sourceStart && targetPos <= sourceEnd)
257938
+ return {
257939
+ ok: false,
257940
+ reason: "same-range"
257941
+ };
257942
+ const sourceNode = state.doc.nodeAt(sourceStart);
257943
+ if (!sourceNode || sourceEnd !== sourceStart + sourceNode.nodeSize)
257944
+ return {
257945
+ ok: false,
257946
+ reason: "invalid-source"
257947
+ };
257948
+ if (expectedNodeType && sourceNode.type.name !== expectedNodeType)
257949
+ return {
257950
+ ok: false,
257951
+ reason: "wrong-node-type"
257952
+ };
257953
+ const tr = state.tr;
257954
+ tr.delete(sourceStart, sourceEnd);
257955
+ const mappedTarget = tr.mapping.map(targetPos);
257956
+ if (mappedTarget < 0 || mappedTarget > tr.doc.content.size)
257957
+ return {
257958
+ ok: false,
257959
+ reason: "invalid-target"
257960
+ };
257961
+ let insertTarget = mappedTarget;
257962
+ if (!canInsertAt(tr.doc, insertTarget, sourceNode)) {
257963
+ const boundaryTarget = resolveInsertionBoundary(tr.doc, insertTarget, sourceNode, canInsertAt, targetPos <= sourceStart ? "before" : "after");
257964
+ if (boundaryTarget == null)
257965
+ return {
257966
+ ok: false,
257967
+ reason: "invalid-target"
257968
+ };
257969
+ insertTarget = boundaryTarget;
257970
+ }
257971
+ tr.insert(insertTarget, sourceNode);
257972
+ tr.setMeta("uiEvent", "drop");
257973
+ return {
257974
+ ok: true,
257975
+ transaction: tr,
257976
+ mappedTarget: insertTarget
257977
+ };
257978
+ }
257708
257979
  function isValidFieldAnnotationAttributes(attrs) {
257709
257980
  if (!attrs || typeof attrs !== "object")
257710
257981
  return false;
@@ -257746,6 +258017,11 @@ function hasFieldAnnotationData(event) {
257746
258017
  function isInternalDrag(event) {
257747
258018
  return event.dataTransfer?.types?.includes(INTERNAL_MIME_TYPE) ?? false;
257748
258019
  }
258020
+ function hasInternalObjectType(event) {
258021
+ if (!event.dataTransfer)
258022
+ return false;
258023
+ return Array.from(event.dataTransfer.types ?? []).map((type) => type.toLowerCase()).includes(INTERNAL_OBJECT_MIME_TYPE.toLowerCase());
258024
+ }
257749
258025
  function extractDragData(event) {
257750
258026
  if (!event.dataTransfer)
257751
258027
  return null;
@@ -257761,6 +258037,23 @@ function extractDragData(event) {
257761
258037
  return null;
257762
258038
  }
257763
258039
  }
258040
+ function resolveDragSourceElement(event) {
258041
+ return event.target?.closest?.("[data-drag-source-kind]");
258042
+ }
258043
+ function resolveInternalObjectSourceRange(doc$12, payload) {
258044
+ if (payload.kind === "structuredContent") {
258045
+ const resolved = payload.nodeType === "structuredContentBlock" ? findStructuredContentBlockById(doc$12, payload.sdtId) : findStructuredContentInlineById(doc$12, payload.sdtId);
258046
+ if (resolved)
258047
+ return {
258048
+ sourceStart: resolved.pos,
258049
+ sourceEnd: resolved.pos + resolved.node.nodeSize
258050
+ };
258051
+ }
258052
+ return {
258053
+ sourceStart: payload.sourceStart,
258054
+ sourceEnd: payload.sourceEnd
258055
+ };
258056
+ }
257764
258057
  function hasPossibleFiles(event) {
257765
258058
  return event.dataTransfer?.types?.includes("Files") ?? false;
257766
258059
  }
@@ -257787,6 +258080,8 @@ function getDroppedImageFiles(event) {
257787
258080
  function getDropPayloadKind(event) {
257788
258081
  if (hasFieldAnnotationData(event))
257789
258082
  return "fieldAnnotation";
258083
+ if (hasInternalObjectType(event))
258084
+ return "internalObject";
257790
258085
  if (hasPossibleFiles(event))
257791
258086
  return "imageFiles";
257792
258087
  return "none";
@@ -261782,6 +262077,15 @@ function ensureEditorFieldAnnotationInteractionStyles(doc$12) {
261782
262077
  doc$12.head?.appendChild(styleEl);
261783
262078
  fieldAnnotationInteractionStylesInjected = true;
261784
262079
  }
262080
+ function ensureEditorMovableObjectInteractionStyles(doc$12) {
262081
+ if (movableObjectInteractionStylesInjected || !doc$12)
262082
+ return;
262083
+ const styleEl = doc$12.createElement("style");
262084
+ styleEl.setAttribute("data-superdoc-editor-movable-object-interaction-styles", "true");
262085
+ styleEl.textContent = MOVABLE_OBJECT_INTERACTION_STYLES;
262086
+ doc$12.head?.appendChild(styleEl);
262087
+ movableObjectInteractionStylesInjected = true;
262088
+ }
261785
262089
  function parseRenderedNoteTarget(blockId) {
261786
262090
  if (typeof blockId !== "string" || blockId.length === 0)
261787
262091
  return null;
@@ -276628,7 +276932,7 @@ var Node$13 = class Node$14 {
276628
276932
  }
276629
276933
  this.#applied.delete(el);
276630
276934
  }
276631
- }, INTERACTION_EPOCH_KEY = "interactionEpoch", DISPLAY_LABEL_SOURCE_KEY = "displayLabelSource", DISPLAY_LABEL_SOURCE, FieldAnnotationInteractionLayer = class {
276935
+ }, INTERACTION_EPOCH_KEY$2 = "interactionEpoch", DISPLAY_LABEL_SOURCE_KEY = "displayLabelSource", DISPLAY_LABEL_SOURCE, FieldAnnotationInteractionLayer = class {
276632
276936
  #container = null;
276633
276937
  setContainer(container) {
276634
276938
  this.#container = container;
@@ -276640,9 +276944,9 @@ var Node$13 = class Node$14 {
276640
276944
  const annotations = this.#container.querySelectorAll(buildAnnotationSelector());
276641
276945
  for (let index2 = 0;index2 < annotations.length; index2 += 1) {
276642
276946
  const annotation = annotations[index2];
276643
- if (annotation.dataset[INTERACTION_EPOCH_KEY] === epochStr)
276947
+ if (annotation.dataset[INTERACTION_EPOCH_KEY$2] === epochStr)
276644
276948
  continue;
276645
- annotation.dataset[INTERACTION_EPOCH_KEY] = epochStr;
276949
+ annotation.dataset[INTERACTION_EPOCH_KEY$2] = epochStr;
276646
276950
  annotation.draggable = true;
276647
276951
  annotation.dataset[DATASET_KEYS.DRAGGABLE] = "true";
276648
276952
  const displayLabel = resolveAnnotationDisplayLabel(annotation, annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CONTENT}`));
@@ -276666,7 +276970,7 @@ var Node$13 = class Node$14 {
276666
276970
  delete annotation.dataset[DATASET_KEYS.DRAGGABLE];
276667
276971
  delete annotation.dataset[DATASET_KEYS.DISPLAY_LABEL];
276668
276972
  delete annotation.dataset[DATASET_KEYS.VARIANT];
276669
- delete annotation.dataset[INTERACTION_EPOCH_KEY];
276973
+ delete annotation.dataset[INTERACTION_EPOCH_KEY$2];
276670
276974
  delete annotation.dataset[DISPLAY_LABEL_SOURCE_KEY];
276671
276975
  annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CARET_ANCHOR}`)?.remove();
276672
276976
  }
@@ -276700,6 +277004,95 @@ var Node$13 = class Node$14 {
276700
277004
  annotation.style.position = "relative";
276701
277005
  annotation.appendChild(caretAnchor);
276702
277006
  }
277007
+ }, INTERACTION_EPOCH_KEY$1 = "imageInteractionEpoch", ImageInteractionLayer = class {
277008
+ #container = null;
277009
+ setContainer(container) {
277010
+ this.#container = container;
277011
+ }
277012
+ apply(layoutEpoch) {
277013
+ if (!this.#container)
277014
+ return;
277015
+ const epochStr = String(layoutEpoch);
277016
+ for (const root3 of collectImageRoots(this.#container)) {
277017
+ if (root3.dataset[INTERACTION_EPOCH_KEY$1] === epochStr)
277018
+ continue;
277019
+ const pmStart = parsePmNumber(root3.dataset.pmStart);
277020
+ const pmEnd = parsePmNumber(root3.dataset.pmEnd);
277021
+ if (!pmStart || !pmEnd)
277022
+ continue;
277023
+ root3.dataset[INTERACTION_EPOCH_KEY$1] = epochStr;
277024
+ root3.draggable = true;
277025
+ root3.dataset.dragSourceKind = "existingImage";
277026
+ root3.dataset.imageKind = resolveImageKind(root3);
277027
+ root3.dataset.nodeType = "image";
277028
+ root3.dataset.displayLabel = resolveImageLabel(root3);
277029
+ root3.dataset.pmStart = pmStart;
277030
+ root3.dataset.pmEnd = pmEnd;
277031
+ }
277032
+ }
277033
+ clear() {
277034
+ if (!this.#container)
277035
+ return;
277036
+ for (const root3 of collectImageRoots(this.#container)) {
277037
+ root3.removeAttribute("draggable");
277038
+ delete root3.dataset.dragSourceKind;
277039
+ delete root3.dataset.imageKind;
277040
+ delete root3.dataset.nodeType;
277041
+ delete root3.dataset.displayLabel;
277042
+ delete root3.dataset[INTERACTION_EPOCH_KEY$1];
277043
+ }
277044
+ }
277045
+ }, BLOCK_LABEL_SELECTOR = ".superdoc-structured-content__label", INLINE_LABEL_SELECTOR, INTERACTION_EPOCH_KEY = "structuredContentInteractionEpoch", StructuredContentInteractionLayer = class {
277046
+ #container = null;
277047
+ setContainer(container) {
277048
+ this.#container = container;
277049
+ }
277050
+ apply(layoutEpoch) {
277051
+ if (!this.#container)
277052
+ return;
277053
+ const labels = Array.from(this.#container.querySelectorAll(`${BLOCK_LABEL_SELECTOR}, ${INLINE_LABEL_SELECTOR}`));
277054
+ for (const label of labels) {
277055
+ if (label.dataset[INTERACTION_EPOCH_KEY] === String(layoutEpoch))
277056
+ continue;
277057
+ const sdtElement = label.closest(`.${DOM_CLASS_NAMES.BLOCK_SDT}, .${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}`);
277058
+ if (!sdtElement?.dataset.sdtId || !sdtElement.dataset.pmStart || !sdtElement.dataset.pmEnd)
277059
+ continue;
277060
+ const lockMode = sdtElement.dataset.lockMode ?? "unlocked";
277061
+ if (lockMode !== "unlocked") {
277062
+ label.draggable = false;
277063
+ continue;
277064
+ }
277065
+ const scope = sdtElement.dataset.sdtScope ?? (sdtElement.classList.contains(DOM_CLASS_NAMES.BLOCK_SDT) ? "block" : "inline");
277066
+ const labelText = label.textContent?.trim() || "Structured content";
277067
+ label.dataset[INTERACTION_EPOCH_KEY] = String(layoutEpoch);
277068
+ label.draggable = true;
277069
+ label.dataset.dragSourceKind = "structuredContent";
277070
+ label.dataset.sdtId = sdtElement.dataset.sdtId;
277071
+ label.dataset.pmStart = sdtElement.dataset.pmStart;
277072
+ label.dataset.pmEnd = sdtElement.dataset.pmEnd;
277073
+ label.dataset.sdtScope = scope;
277074
+ label.dataset.lockMode = lockMode;
277075
+ label.dataset[DATASET_KEYS.DISPLAY_LABEL] = labelText;
277076
+ label.dataset.nodeType = scope === "block" ? "structuredContentBlock" : "structuredContent";
277077
+ }
277078
+ }
277079
+ clear() {
277080
+ if (!this.#container)
277081
+ return;
277082
+ const labels = Array.from(this.#container.querySelectorAll(`${BLOCK_LABEL_SELECTOR}, ${INLINE_LABEL_SELECTOR}`));
277083
+ for (const label of labels) {
277084
+ label.removeAttribute("draggable");
277085
+ delete label.dataset.dragSourceKind;
277086
+ delete label.dataset.sdtId;
277087
+ delete label.dataset.pmStart;
277088
+ delete label.dataset.pmEnd;
277089
+ delete label.dataset.sdtScope;
277090
+ delete label.dataset.lockMode;
277091
+ delete label.dataset.nodeType;
277092
+ delete label.dataset[DATASET_KEYS.DISPLAY_LABEL];
277093
+ delete label.dataset[INTERACTION_EPOCH_KEY];
277094
+ }
277095
+ }
276703
277096
  }, PROOFING_CSS, splitOriginMap, PresentationProofingDecorator = class {
276704
277097
  #container = null;
276705
277098
  setContainer(container) {
@@ -276721,17 +277114,23 @@ var Node$13 = class Node$14 {
276721
277114
  }
276722
277115
  }, PresentationPostPaintPipeline = class {
276723
277116
  #fieldAnnotationLayer;
277117
+ #imageLayer;
277118
+ #structuredContentLayer;
276724
277119
  #commentHighlightDecorator;
276725
277120
  #decorationBridge;
276726
277121
  #proofingDecorator;
276727
277122
  constructor(deps = {}) {
276728
277123
  this.#fieldAnnotationLayer = deps.fieldAnnotationLayer ?? new FieldAnnotationInteractionLayer;
277124
+ this.#imageLayer = deps.imageLayer ?? new ImageInteractionLayer;
277125
+ this.#structuredContentLayer = deps.structuredContentLayer ?? new StructuredContentInteractionLayer;
276729
277126
  this.#commentHighlightDecorator = deps.commentHighlightDecorator ?? new CommentHighlightDecorator;
276730
277127
  this.#decorationBridge = deps.decorationBridge ?? new DecorationBridge;
276731
277128
  this.#proofingDecorator = deps.proofingDecorator ?? new PresentationProofingDecorator;
276732
277129
  }
276733
277130
  setContainer(container) {
276734
277131
  this.#fieldAnnotationLayer.setContainer(container);
277132
+ this.#imageLayer.setContainer(container);
277133
+ this.#structuredContentLayer.setContainer(container);
276735
277134
  this.#commentHighlightDecorator.setContainer(container);
276736
277135
  this.#proofingDecorator.setContainer(container);
276737
277136
  }
@@ -276771,6 +277170,8 @@ var Node$13 = class Node$14 {
276771
277170
  refreshAfterPaint(options) {
276772
277171
  this.#fieldAnnotationLayer.apply(options.layoutEpoch);
276773
277172
  options.rebuildDomPositionIndex();
277173
+ this.#imageLayer.apply(options.layoutEpoch);
277174
+ this.#structuredContentLayer.apply(options.layoutEpoch);
276774
277175
  this.syncInlineStyleLayers(options.editorState, options.domPositionIndex);
276775
277176
  this.applyProofingAnnotations(options.proofingAnnotations, options.rebuildDomPositionIndex);
276776
277177
  options.reapplyStructuredContentHover?.();
@@ -276778,6 +277179,8 @@ var Node$13 = class Node$14 {
276778
277179
  destroy() {
276779
277180
  this.#proofingDecorator.clear();
276780
277181
  this.#fieldAnnotationLayer.clear();
277182
+ this.#imageLayer.clear();
277183
+ this.#structuredContentLayer.clear();
276781
277184
  this.#commentHighlightDecorator.destroy();
276782
277185
  this.#decorationBridge.destroy();
276783
277186
  }
@@ -279239,6 +279642,10 @@ menclose::after {
279239
279642
  container.classList.add(CLASS_NAMES$1.fragment);
279240
279643
  applyStyles$2(container, fragmentStyles);
279241
279644
  applyFragmentFrame(container, fragment);
279645
+ if (fragment.pmStart != null)
279646
+ container.dataset.pmStart = String(fragment.pmStart);
279647
+ if (fragment.pmEnd != null)
279648
+ container.dataset.pmEnd = String(fragment.pmEnd);
279242
279649
  container.style.height = `${fragment.height}px`;
279243
279650
  applySdtDataset(container, block.attrs?.sdt);
279244
279651
  applyContainerSdtDataset?.(container, block.attrs?.containerSdt);
@@ -284182,12 +284589,12 @@ menclose::after {
284182
284589
  if (pt == null || !Number.isFinite(pt))
284183
284590
  return;
284184
284591
  return pt * PX_PER_PT2;
284185
- }, isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
284592
+ }, isFiniteNumber$1 = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
284186
284593
  if (!value)
284187
284594
  return "";
284188
284595
  return String(value);
284189
284596
  }, pickNumber = (value) => {
284190
- if (isFiniteNumber(value))
284597
+ if (isFiniteNumber$1(value))
284191
284598
  return value;
284192
284599
  if (typeof value === "string") {
284193
284600
  const parsed = parseFloat(value);
@@ -284385,7 +284792,7 @@ menclose::after {
284385
284792
  };
284386
284793
  }
284387
284794
  }, MIN_BORDER_SIZE_PX2 = 0.5, MAX_BORDER_SIZE_PX2 = 100, borderSizeToPx = (size$1) => {
284388
- if (!isFiniteNumber(size$1))
284795
+ if (!isFiniteNumber$1(size$1))
284389
284796
  return;
284390
284797
  if (size$1 <= 0)
284391
284798
  return 0;
@@ -284678,7 +285085,7 @@ menclose::after {
284678
285085
  const toNum = (v) => {
284679
285086
  if (typeof v === "string" && v.trim() !== "" && isFinite(Number(v)))
284680
285087
  return Number(v);
284681
- if (isFiniteNumber(v))
285088
+ if (isFiniteNumber$1(v))
284682
285089
  return Number(v);
284683
285090
  };
284684
285091
  const left$1 = toNum(indent2.left);
@@ -285286,7 +285693,7 @@ menclose::after {
285286
285693
  return;
285287
285694
  return sanitized;
285288
285695
  }, normalizeLengthPx = (value) => {
285289
- if (isFiniteNumber(value))
285696
+ if (isFiniteNumber$1(value))
285290
285697
  return value;
285291
285698
  if (typeof value !== "string")
285292
285699
  return;
@@ -286799,7 +287206,7 @@ menclose::after {
286799
287206
  this.#onCursorsUpdate = null;
286800
287207
  this.#isSetup = false;
286801
287208
  }
286802
- }, SEMANTIC_FOOTNOTES_HEADING_BLOCK_ID = "__sd_semantic_footnotes_heading", SEMANTIC_FOOTNOTE_BLOCK_ID_PREFIX = "__sd_semantic_footnote", MULTI_CLICK_TIME_THRESHOLD_MS = 400, MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5, DRAG_SELECTION_DISTANCE_THRESHOLD_PX = 5, AUTO_SCROLL_EDGE_PX = 32, AUTO_SCROLL_MAX_SPEED_PX = 24, SCROLL_DETECTION_TOLERANCE_PX = 1, DEFAULT_PAGE_MARGIN_PX = 72, COMMENT_HIGHLIGHT_SELECTOR = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR = "[data-track-change-id]", PM_TRACK_CHANGE_SELECTOR = ".track-insert[data-id], .track-delete[data-id], .track-format[data-id]", VISIBLE_HEADER_FOOTER_SELECTOR = ".superdoc-page-header, .superdoc-page-footer", VISIBLE_BODY_CONTENT_SELECTOR = ".superdoc-line, .superdoc-fragment, [data-block-id]", COMMENT_THREAD_HIT_TOLERANCE_PX = 3, COMMENT_THREAD_HIT_SAMPLE_OFFSETS, clamp = (value, min$2, max$2) => Math.max(min$2, Math.min(max$2, value)), EditorInputManager = class {
287209
+ }, SEMANTIC_FOOTNOTES_HEADING_BLOCK_ID = "__sd_semantic_footnotes_heading", SEMANTIC_FOOTNOTE_BLOCK_ID_PREFIX = "__sd_semantic_footnote", MULTI_CLICK_TIME_THRESHOLD_MS = 400, MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5, DRAG_SELECTION_DISTANCE_THRESHOLD_PX = 5, AUTO_SCROLL_EDGE_PX = 32, AUTO_SCROLL_MAX_SPEED_PX = 24, SCROLL_DETECTION_TOLERANCE_PX = 1, DEFAULT_PAGE_MARGIN_PX = 72, COMMENT_HIGHLIGHT_SELECTOR = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR = "[data-track-change-id]", PM_TRACK_CHANGE_SELECTOR = ".track-insert[data-id], .track-delete[data-id], .track-format[data-id]", VISIBLE_HEADER_FOOTER_SELECTOR = ".superdoc-page-header, .superdoc-page-footer", VISIBLE_BODY_CONTENT_SELECTOR = ".superdoc-line, .superdoc-fragment, [data-block-id]", COMMENT_THREAD_HIT_TOLERANCE_PX = 3, COMMENT_THREAD_HIT_SAMPLE_OFFSETS, clamp = (value, min$2, max$2) => Math.max(min$2, Math.min(max$2, value)), DRAG_SOURCE_SELECTOR = '[data-draggable="true"], [data-drag-source-kind]', EditorInputManager = class {
286803
287210
  #deps = null;
286804
287211
  #callbacks = {};
286805
287212
  #isDragging = false;
@@ -287361,7 +287768,9 @@ menclose::after {
287361
287768
  }
287362
287769
  const annotationEl = target?.closest?.(buildAnnotationSelector());
287363
287770
  const isDraggableAnnotation = target?.closest?.(DRAGGABLE_SELECTOR) != null;
287364
- this.#suppressFocusInFromDraggable = isDraggableAnnotation;
287771
+ const isNativeDragSource = target?.closest?.(DRAG_SOURCE_SELECTOR) != null;
287772
+ const suppressFocusForDrag = isDraggableAnnotation || isNativeDragSource;
287773
+ this.#suppressFocusInFromDraggable = suppressFocusForDrag;
287365
287774
  if (annotationEl) {
287366
287775
  this.#handleAnnotationClick(event, annotationEl);
287367
287776
  return;
@@ -287374,7 +287783,7 @@ menclose::after {
287374
287783
  const activeNoteTarget = this.#getActiveRenderedNoteTarget();
287375
287784
  if (!layoutState.layout) {
287376
287785
  if (clickedNoteTarget && !isSameRenderedNoteTarget(activeNoteTarget, clickedNoteTarget)) {
287377
- if (!isDraggableAnnotation)
287786
+ if (!suppressFocusForDrag)
287378
287787
  event.preventDefault();
287379
287788
  if (this.#callbacks.activateRenderedNoteSession?.(clickedNoteTarget, {
287380
287789
  clientX: event.clientX,
@@ -287395,7 +287804,7 @@ menclose::after {
287395
287804
  return;
287396
287805
  } else
287397
287806
  this.#syncNonBodyCommentActivation(event, target, bodyEditor);
287398
- this.#handleClickWithoutLayout(event, isDraggableAnnotation);
287807
+ this.#handleClickWithoutLayout(event, suppressFocusForDrag);
287399
287808
  return;
287400
287809
  }
287401
287810
  const normalizedPoint = this.#callbacks.normalizeClientPoint?.(event.clientX, event.clientY);
@@ -287410,7 +287819,7 @@ menclose::after {
287410
287819
  };
287411
287820
  if (clickedNoteTarget) {
287412
287821
  if (!isSameRenderedNoteTarget(activeNoteTarget, clickedNoteTarget)) {
287413
- if (!isDraggableAnnotation)
287822
+ if (!suppressFocusForDrag)
287414
287823
  event.preventDefault();
287415
287824
  if (this.#callbacks.activateRenderedNoteSession?.(clickedNoteTarget, {
287416
287825
  clientX: event.clientX,
@@ -287486,7 +287895,7 @@ menclose::after {
287486
287895
  mappedPos: null
287487
287896
  };
287488
287897
  this.#callbacks.updateSelectionDebugHud?.();
287489
- if (!isDraggableAnnotation)
287898
+ if (!suppressFocusForDrag)
287490
287899
  event.preventDefault();
287491
287900
  const inlineStructuredContentLabel = target?.closest?.(".superdoc-structured-content-inline__label");
287492
287901
  if (inlineStructuredContentLabel && doc$12) {
@@ -287604,7 +288013,7 @@ menclose::after {
287604
288013
  this.#focusEditor();
287605
288014
  if (!handledByDepth)
287606
288015
  try {
287607
- const sdtBlock = clickDepth === 1 ? this.#findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
288016
+ const sdtBlock = clickDepth === 1 ? findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
287608
288017
  let nextSelection;
287609
288018
  let inlineSdtBoundaryPos = null;
287610
288019
  let inlineSdtBoundaryDirection = null;
@@ -287612,7 +288021,7 @@ menclose::after {
287612
288021
  if (sdtBlock && !insideTableInSdt)
287613
288022
  nextSelection = NodeSelection.create(doc$12, sdtBlock.pos);
287614
288023
  else {
287615
- const inlineSdt = clickDepth === 1 ? this.#findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
288024
+ const inlineSdt = clickDepth === 1 ? findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
287616
288025
  if (inlineSdt && hit.pos >= inlineSdt.end) {
287617
288026
  const afterInlineSdt = inlineSdt.pos + inlineSdt.node.nodeSize;
287618
288027
  inlineSdtBoundaryPos = afterInlineSdt;
@@ -287873,26 +288282,6 @@ menclose::after {
287873
288282
  });
287874
288283
  }
287875
288284
  }
287876
- #findStructuredContentBlockAtPos(doc$12, pos) {
287877
- if (!Number.isFinite(pos))
287878
- return null;
287879
- try {
287880
- const $pos = doc$12.resolve(pos);
287881
- for (let depth = $pos.depth;depth > 0; depth--) {
287882
- const node2 = $pos.node(depth);
287883
- if (node2.type?.name === "structuredContentBlock")
287884
- return {
287885
- node: node2,
287886
- pos: $pos.before(depth),
287887
- start: $pos.start(depth),
287888
- end: $pos.end(depth)
287889
- };
287890
- }
287891
- } catch {
287892
- return null;
287893
- }
287894
- return null;
287895
- }
287896
288285
  #isInsideTableWithinStructuredContentBlock(doc$12, pos, sdtPos) {
287897
288286
  if (!Number.isFinite(pos) || !Number.isFinite(sdtPos))
287898
288287
  return false;
@@ -287916,82 +288305,26 @@ menclose::after {
287916
288305
  return false;
287917
288306
  }
287918
288307
  }
287919
- #findStructuredContentBlockById(doc$12, id2) {
287920
- let found2 = null;
287921
- doc$12.descendants((node2, pos) => {
287922
- if (node2.type?.name !== "structuredContentBlock")
287923
- return true;
287924
- const nodeId = node2.attrs?.id;
287925
- if (String(nodeId ?? "") !== id2)
287926
- return true;
287927
- found2 = {
287928
- node: node2,
287929
- pos,
287930
- start: pos + 1,
287931
- end: pos + node2.nodeSize - 1
287932
- };
287933
- return false;
287934
- });
287935
- return found2;
287936
- }
287937
- #findStructuredContentInlineAtPos(doc$12, pos) {
287938
- if (!Number.isFinite(pos))
287939
- return null;
287940
- try {
287941
- const $pos = doc$12.resolve(pos);
287942
- for (let depth = $pos.depth;depth > 0; depth--) {
287943
- const node2 = $pos.node(depth);
287944
- if (node2.type?.name === "structuredContent")
287945
- return {
287946
- node: node2,
287947
- pos: $pos.before(depth),
287948
- start: $pos.start(depth),
287949
- end: $pos.end(depth)
287950
- };
287951
- }
287952
- } catch {
287953
- return null;
287954
- }
287955
- return null;
287956
- }
287957
- #findStructuredContentInlineById(doc$12, id2) {
287958
- let found2 = null;
287959
- doc$12.descendants((node2, pos) => {
287960
- if (node2.type?.name !== "structuredContent")
287961
- return true;
287962
- const nodeId = node2.attrs?.id;
287963
- if (String(nodeId ?? "") !== id2)
287964
- return true;
287965
- found2 = {
287966
- node: node2,
287967
- pos,
287968
- start: pos + 1,
287969
- end: pos + node2.nodeSize - 1
287970
- };
287971
- return false;
287972
- });
287973
- return found2;
287974
- }
287975
288308
  #resolveStructuredContentBlockFromElement(doc$12, element3) {
287976
288309
  const container = element3.closest?.(".superdoc-structured-content-block");
287977
288310
  if (!container)
287978
288311
  return null;
287979
288312
  const sdtId = container.dataset?.sdtId;
287980
288313
  if (sdtId) {
287981
- const match$1 = this.#findStructuredContentBlockById(doc$12, sdtId);
288314
+ const match$1 = findStructuredContentBlockById(doc$12, sdtId);
287982
288315
  if (match$1)
287983
288316
  return match$1;
287984
288317
  }
287985
288318
  const containerSdtId = container.dataset?.sdtContainerId;
287986
288319
  if (containerSdtId) {
287987
- const match$1 = this.#findStructuredContentBlockById(doc$12, containerSdtId);
288320
+ const match$1 = findStructuredContentBlockById(doc$12, containerSdtId);
287988
288321
  if (match$1)
287989
288322
  return match$1;
287990
288323
  }
287991
288324
  const pmStartRaw = container.dataset?.pmStart;
287992
288325
  const pmStart = pmStartRaw != null ? Number(pmStartRaw) : NaN;
287993
288326
  if (Number.isFinite(pmStart))
287994
- return this.#findStructuredContentBlockAtPos(doc$12, pmStart);
288327
+ return findStructuredContentBlockAtPos(doc$12, pmStart);
287995
288328
  return null;
287996
288329
  }
287997
288330
  #resolveStructuredContentInlineFromElement(doc$12, element3) {
@@ -288000,14 +288333,14 @@ menclose::after {
288000
288333
  return null;
288001
288334
  const sdtId = container.dataset?.sdtId;
288002
288335
  if (sdtId) {
288003
- const match$1 = this.#findStructuredContentInlineById(doc$12, sdtId);
288336
+ const match$1 = findStructuredContentInlineById(doc$12, sdtId);
288004
288337
  if (match$1)
288005
288338
  return match$1;
288006
288339
  }
288007
288340
  const pmStartRaw = container.dataset?.pmStart;
288008
288341
  const pmStart = pmStartRaw != null ? Number(pmStartRaw) : NaN;
288009
288342
  if (Number.isFinite(pmStart))
288010
- return this.#findStructuredContentInlineAtPos(doc$12, pmStart);
288343
+ return findStructuredContentInlineAtPos(doc$12, pmStart);
288011
288344
  return null;
288012
288345
  }
288013
288346
  #findStructuredContentBlockContentRange(resolved) {
@@ -288988,10 +289321,11 @@ menclose::after {
288988
289321
  #isCompositionKeyboardEvent(event) {
288989
289322
  return event.isComposing || event.keyCode === 229 || event.key === "Dead" || event.key === "Compose";
288990
289323
  }
288991
- }, isObject3 = (value) => typeof value === "object" && value !== null, INTERNAL_MIME_TYPE = "application/x-field-annotation", FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation", IMAGE_EXTENSIONS, DragDropManager = class {
289324
+ }, isObject3 = (value) => typeof value === "object" && value !== null, INTERNAL_OBJECT_MIME_TYPE = "application/x-superdoc-internal-object", INTERNAL_MIME_TYPE = "application/x-field-annotation", FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation", IMAGE_EXTENSIONS, DragDropManager = class {
288992
289325
  #deps = null;
288993
289326
  #dragOverRaf = null;
288994
289327
  #pendingDragOver = null;
289328
+ #activeInternalObjectPayload = null;
288995
289329
  #boundHandleDragStart = null;
288996
289330
  #boundHandleDragOver = null;
288997
289331
  #boundHandleDrop = null;
@@ -289051,23 +289385,45 @@ menclose::after {
289051
289385
  }
289052
289386
  destroy() {
289053
289387
  this.#cancelPendingDragOverSelection();
289388
+ this.#activeInternalObjectPayload = null;
289389
+ this.#deps?.clearDragDropIndicator();
289054
289390
  this.unbind();
289055
289391
  this.#deps = null;
289056
289392
  }
289057
289393
  #handleDragStart(event) {
289058
289394
  const target = event.target;
289059
- if (!target?.dataset?.[DATASET_KEYS.DRAGGABLE] || target.dataset[DATASET_KEYS.DRAGGABLE] !== "true")
289395
+ const sourceElement = resolveDragSourceElement(event);
289396
+ const fieldAnnotationElement = target?.closest?.(`[${DATASET_KEYS.DRAGGABLE}="true"]`);
289397
+ if (!target) {
289398
+ this.#activeInternalObjectPayload = null;
289060
289399
  return;
289061
- const data = extractFieldAnnotationData(target);
289400
+ }
289401
+ const internalObjectPayload = sourceElement ? buildInternalObjectDragPayload(sourceElement) : null;
289402
+ const isInternalObjectSource = internalObjectPayload !== null;
289403
+ const isFieldAnnotation = fieldAnnotationElement != null;
289404
+ this.#activeInternalObjectPayload = isInternalObjectSource ? internalObjectPayload : null;
289405
+ if (!isFieldAnnotation && !isInternalObjectSource) {
289406
+ this.#activeInternalObjectPayload = null;
289407
+ return;
289408
+ }
289062
289409
  if (event.dataTransfer) {
289063
- const jsonData = JSON.stringify({
289064
- attributes: data.attributes,
289065
- sourceField: data
289066
- });
289067
- event.dataTransfer.setData(INTERNAL_MIME_TYPE, jsonData);
289068
- event.dataTransfer.setData(FIELD_ANNOTATION_DATA_TYPE, jsonData);
289069
- event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
289070
- event.dataTransfer.setDragImage(target, 0, 0);
289410
+ if (isInternalObjectSource && internalObjectPayload) {
289411
+ const jsonData = JSON.stringify(internalObjectPayload);
289412
+ event.dataTransfer.setData(INTERNAL_OBJECT_MIME_TYPE, jsonData);
289413
+ event.dataTransfer.setData("text/plain", internalObjectPayload.label);
289414
+ event.dataTransfer.setDragImage(sourceElement ?? target, 0, 0);
289415
+ } else {
289416
+ const draggableTarget = fieldAnnotationElement ?? target;
289417
+ const data = extractFieldAnnotationData(draggableTarget);
289418
+ const jsonData = JSON.stringify({
289419
+ attributes: data.attributes,
289420
+ sourceField: data
289421
+ });
289422
+ event.dataTransfer.setData(INTERNAL_MIME_TYPE, jsonData);
289423
+ event.dataTransfer.setData(FIELD_ANNOTATION_DATA_TYPE, jsonData);
289424
+ event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
289425
+ event.dataTransfer.setDragImage(draggableTarget, 0, 0);
289426
+ }
289071
289427
  event.dataTransfer.effectAllowed = "move";
289072
289428
  }
289073
289429
  }
@@ -289083,6 +289439,8 @@ menclose::after {
289083
289439
  if (event.dataTransfer)
289084
289440
  if (kind === "fieldAnnotation")
289085
289441
  event.dataTransfer.dropEffect = isInternalDrag(event) ? "move" : "copy";
289442
+ else if (kind === "internalObject")
289443
+ event.dataTransfer.dropEffect = "move";
289086
289444
  else
289087
289445
  event.dataTransfer.dropEffect = "copy";
289088
289446
  this.#scheduleDragOverSelection(event.clientX, event.clientY);
@@ -289096,6 +289454,7 @@ menclose::after {
289096
289454
  event.preventDefault();
289097
289455
  event.stopPropagation();
289098
289456
  this.#cancelPendingDragOverSelection();
289457
+ this.#deps.clearDragDropIndicator();
289099
289458
  const activeEditor = this.#deps.getActiveEditor();
289100
289459
  if (!activeEditor?.isEditable)
289101
289460
  return;
@@ -289111,6 +289470,14 @@ menclose::after {
289111
289470
  const dropPos = hit?.pos ?? fallbackPos;
289112
289471
  if (dropPos == null)
289113
289472
  return;
289473
+ if (kind === "internalObject") {
289474
+ try {
289475
+ this.#handleInternalObjectDrop(event, dropPos);
289476
+ } finally {
289477
+ this.#activeInternalObjectPayload = null;
289478
+ }
289479
+ return;
289480
+ }
289114
289481
  if (isInternalDrag(event)) {
289115
289482
  this.#handleInternalDrop(event, dropPos);
289116
289483
  return;
@@ -289119,6 +289486,8 @@ menclose::after {
289119
289486
  }
289120
289487
  #handleDragEnd(_event) {
289121
289488
  this.#cancelPendingDragOverSelection();
289489
+ this.#activeInternalObjectPayload = null;
289490
+ this.#deps?.clearDragDropIndicator();
289122
289491
  this.#deps?.getPainterHost()?.classList.remove("drag-over");
289123
289492
  }
289124
289493
  #handleDragLeave(event) {
@@ -289129,6 +289498,7 @@ menclose::after {
289129
289498
  if (relatedTarget && viewportHost.contains(relatedTarget))
289130
289499
  return;
289131
289500
  this.#cancelPendingDragOverSelection();
289501
+ this.#deps?.clearDragDropIndicator();
289132
289502
  this.#deps?.getPainterHost()?.classList.remove("drag-over");
289133
289503
  }
289134
289504
  #scheduleDragOverSelection(clientX, clientY) {
@@ -289164,17 +289534,12 @@ menclose::after {
289164
289534
  return;
289165
289535
  const hit = this.#deps.hitTest(clientX, clientY);
289166
289536
  const doc$12 = activeEditor.state?.doc;
289167
- if (!hit || !doc$12)
289537
+ if (!hit || !doc$12) {
289538
+ this.#deps.clearDragDropIndicator();
289168
289539
  return;
289540
+ }
289169
289541
  const pos = Math.min(Math.max(hit.pos, 1), doc$12.content.size);
289170
- const currentSelection = activeEditor.state.selection;
289171
- if (currentSelection instanceof TextSelection && currentSelection.from === pos && currentSelection.to === pos)
289172
- return;
289173
- try {
289174
- const tr = activeEditor.state.tr.setSelection(TextSelection.create(doc$12, pos)).setMeta("addToHistory", false);
289175
- activeEditor.view?.dispatch(tr);
289176
- this.#deps.scheduleSelectionUpdate();
289177
- } catch {}
289542
+ this.#deps.showDragDropIndicator(pos);
289178
289543
  }
289179
289544
  async#handleImageDrop(event) {
289180
289545
  if (!this.#deps)
@@ -289272,16 +289637,47 @@ menclose::after {
289272
289637
  });
289273
289638
  if (sourceStart === null || sourceEnd === null || !sourceNode)
289274
289639
  return;
289275
- if (targetPos >= sourceStart && targetPos <= sourceEnd)
289640
+ const result = createInternalNodeMoveTransaction({
289641
+ doc: state.doc,
289642
+ tr: state.tr
289643
+ }, {
289644
+ sourceStart,
289645
+ sourceEnd,
289646
+ targetPos,
289647
+ expectedNodeType: "fieldAnnotation",
289648
+ canInsertAt: () => true
289649
+ });
289650
+ if (!result.ok)
289651
+ return;
289652
+ view.dispatch(result.transaction);
289653
+ }
289654
+ #handleInternalObjectDrop(event, targetPos) {
289655
+ if (!this.#deps)
289276
289656
  return;
289277
- const tr = state.tr;
289278
- tr.delete(sourceStart, sourceEnd);
289279
- const mappedTarget = tr.mapping.map(targetPos);
289280
- if (mappedTarget < 0 || mappedTarget > tr.doc.content.size)
289657
+ const { state, view } = this.#deps.getActiveEditor();
289658
+ if (!state || !view)
289281
289659
  return;
289282
- tr.insert(mappedTarget, sourceNode);
289283
- tr.setMeta("uiEvent", "drop");
289284
- view.dispatch(tr);
289660
+ const payload = this.#activeInternalObjectPayload;
289661
+ if (!payload)
289662
+ return;
289663
+ if (payload.kind === "structuredContent" && payload.lockMode !== "unlocked")
289664
+ return;
289665
+ const { sourceStart, sourceEnd } = resolveInternalObjectSourceRange(state.doc, payload);
289666
+ const result = createInternalNodeMoveTransaction({
289667
+ doc: state.doc,
289668
+ tr: state.tr
289669
+ }, {
289670
+ sourceStart,
289671
+ sourceEnd,
289672
+ targetPos,
289673
+ expectedNodeType: payload.nodeType,
289674
+ canInsertAt: canInsertNodeAtPosition
289675
+ });
289676
+ if (!result.ok)
289677
+ return;
289678
+ view.dispatch(result.transaction);
289679
+ this.#focusEditor();
289680
+ this.#deps.scheduleSelectionUpdate();
289285
289681
  }
289286
289682
  #handleExternalDrop(event, pos) {
289287
289683
  if (!this.#deps)
@@ -289325,6 +289721,8 @@ menclose::after {
289325
289721
  if (event.dataTransfer)
289326
289722
  if (kind === "fieldAnnotation")
289327
289723
  event.dataTransfer.dropEffect = isInternalDrag(event) ? "move" : "copy";
289724
+ else if (kind === "internalObject")
289725
+ event.dataTransfer.dropEffect = "move";
289328
289726
  else
289329
289727
  event.dataTransfer.dropEffect = "copy";
289330
289728
  }
@@ -291438,14 +291836,32 @@ menclose::after {
291438
291836
  pointer-events: none;
291439
291837
  z-index: 1000;
291440
291838
  }
291441
- `, fieldAnnotationInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
291839
+ `, fieldAnnotationInteractionStylesInjected = false, MOVABLE_OBJECT_INTERACTION_STYLES = `
291840
+ /* Editing affordance: allow grab cursors for draggable SDT labels and images */
291841
+ .superdoc-layout [data-drag-source-kind] {
291842
+ cursor: grab;
291843
+ }
291844
+
291845
+ .superdoc-layout [data-drag-source-kind]:active {
291846
+ cursor: grabbing;
291847
+ }
291848
+
291849
+ /* Keep the active drag source from selecting text while dragging */
291850
+ .superdoc-layout .superdoc-structured-content__label,
291851
+ .superdoc-layout .superdoc-structured-content-inline__label,
291852
+ .superdoc-layout .superdoc-image-fragment[data-drag-source-kind="existingImage"],
291853
+ .superdoc-layout .superdoc-inline-image-clip-wrapper[data-drag-source-kind="existingImage"],
291854
+ .superdoc-layout .superdoc-inline-image[data-drag-source-kind="existingImage"] {
291855
+ user-select: none;
291856
+ }
291857
+ `, movableObjectInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
291442
291858
  return typeof event?.source === "string" && INTERNAL_NOTE_COMMIT_SOURCES.has(event.source);
291443
291859
  }, 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) => {
291444
291860
  if (!layoutDebugEnabled)
291445
291861
  return;
291446
291862
  console.log(...args$1);
291447
291863
  }, 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;
291448
- var init_src_C_jV2TZI_es = __esm(() => {
291864
+ var init_src_CSHo1aJM_es = __esm(() => {
291449
291865
  init_rolldown_runtime_Bg48TavK_es();
291450
291866
  init_SuperConverter_D1o6_yKI_es();
291451
291867
  init_jszip_C49i9kUs_es();
@@ -317478,6 +317894,7 @@ function print() { __p += __j.call(arguments, '') }
317478
317894
  CANONICAL: "canonical",
317479
317895
  DERIVED: "derived"
317480
317896
  };
317897
+ INLINE_LABEL_SELECTOR = `.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}__label`;
317481
317898
  PROOFING_CSS = {
317482
317899
  SPELLING: "sd-proofing-spelling",
317483
317900
  GRAMMAR: "sd-proofing-grammar",
@@ -323055,6 +323472,7 @@ function print() { __p += __j.call(arguments, '') }
323055
323472
  #isRerendering = false;
323056
323473
  #selectionSync = new SelectionSyncCoordinator;
323057
323474
  #shouldScrollSelectionIntoView = false;
323475
+ #dragDropIndicatorPos = null;
323058
323476
  #epochMapper = new EpochPositionMapper;
323059
323477
  #layoutEpoch = 0;
323060
323478
  #htmlAnnotationHeights = /* @__PURE__ */ new Map;
@@ -323171,6 +323589,7 @@ function print() { __p += __j.call(arguments, '') }
323171
323589
  this.#postPaintPipeline.setContainer(this.#painterHost);
323172
323590
  ensureEditorNativeSelectionStyles(doc$12);
323173
323591
  ensureEditorFieldAnnotationInteractionStyles(doc$12);
323592
+ ensureEditorMovableObjectInteractionStyles(doc$12);
323174
323593
  this.#painterHost.addEventListener("mouseover", this.#handleStructuredContentBlockMouseEnter);
323175
323594
  this.#painterHost.addEventListener("mouseout", this.#handleStructuredContentBlockMouseLeave);
323176
323595
  this.#domIndexObserverManager = new DomPositionIndexObserverManager({
@@ -325526,12 +325945,30 @@ function print() { __p += __j.call(arguments, '') }
325526
325945
  getActiveEditor: () => this.getActiveEditor(),
325527
325946
  hitTest: (clientX, clientY) => this.hitTest(clientX, clientY),
325528
325947
  scheduleSelectionUpdate: () => this.#scheduleSelectionUpdate(),
325948
+ showDragDropIndicator: (pos) => this.#showDragDropIndicator(pos),
325949
+ clearDragDropIndicator: () => this.#clearDragDropIndicator(),
325529
325950
  getViewportHost: () => this.#viewportHost,
325530
325951
  getPainterHost: () => this.#painterHost,
325531
325952
  insertImageFile: (params$1) => processAndInsertImageFile(params$1)
325532
325953
  });
325533
325954
  this.#dragDropManager.bind();
325534
325955
  }
325956
+ #showDragDropIndicator(pos) {
325957
+ const docSize = this.getActiveEditor()?.state?.doc?.content.size;
325958
+ if (!Number.isFinite(pos) || docSize == null)
325959
+ return;
325960
+ const clampedPos = Math.min(Math.max(pos, 1), docSize);
325961
+ if (this.#dragDropIndicatorPos === clampedPos)
325962
+ return;
325963
+ this.#dragDropIndicatorPos = clampedPos;
325964
+ this.#scheduleSelectionUpdate({ immediate: true });
325965
+ }
325966
+ #clearDragDropIndicator() {
325967
+ if (this.#dragDropIndicatorPos == null)
325968
+ return;
325969
+ this.#dragDropIndicatorPos = null;
325970
+ this.#scheduleSelectionUpdate({ immediate: true });
325971
+ }
325535
325972
  #focusEditorAfterImageSelection() {
325536
325973
  this.#shouldScrollSelectionIntoView = true;
325537
325974
  this.#scheduleSelectionUpdate();
@@ -326679,6 +327116,7 @@ function print() { __p += __j.call(arguments, '') }
326679
327116
  return;
326680
327117
  }
326681
327118
  let node2 = null;
327119
+ let pos = null;
326682
327120
  let id2 = null;
326683
327121
  if (selection instanceof NodeSelection) {
326684
327122
  if (selection.node?.type?.name !== "structuredContentBlock") {
@@ -326686,23 +327124,24 @@ function print() { __p += __j.call(arguments, '') }
326686
327124
  return;
326687
327125
  }
326688
327126
  node2 = selection.node;
327127
+ pos = selection.from;
326689
327128
  } else {
326690
- const $pos = selection.$from;
326691
- if (!$pos || typeof $pos.depth !== "number" || typeof $pos.node !== "function") {
327129
+ const editorDoc = this.#editor?.view?.state?.doc;
327130
+ if (!editorDoc) {
326692
327131
  this.#clearSelectedStructuredContentBlockClass();
326693
327132
  return;
326694
327133
  }
326695
- for (let depth = $pos.depth;depth > 0; depth--) {
326696
- const candidate = $pos.node(depth);
326697
- if (candidate.type?.name === "structuredContentBlock") {
326698
- node2 = candidate;
326699
- break;
326700
- }
326701
- }
326702
- if (!node2) {
327134
+ const resolved = findStructuredContentBlockAtPos(editorDoc, selection.from);
327135
+ if (!resolved) {
326703
327136
  this.#clearSelectedStructuredContentBlockClass();
326704
327137
  return;
326705
327138
  }
327139
+ node2 = resolved.node;
327140
+ pos = resolved.pos;
327141
+ }
327142
+ if (pos == null) {
327143
+ this.#clearSelectedStructuredContentBlockClass();
327144
+ return;
326706
327145
  }
326707
327146
  if (!this.#painterHost) {
326708
327147
  this.#clearSelectedStructuredContentBlockClass();
@@ -326714,7 +327153,7 @@ function print() { __p += __j.call(arguments, '') }
326714
327153
  if (id2)
326715
327154
  elements = this.#painterAdapter.getStructuredContentBlockElementsById(id2);
326716
327155
  if (elements.length === 0) {
326717
- const container = this.getElementAtPos(selection.from, { fallbackToCoords: true })?.closest?.(`.${DOM_CLASS_NAMES.BLOCK_SDT}`);
327156
+ const container = this.getElementAtPos(pos, { fallbackToCoords: true })?.closest?.(`.${DOM_CLASS_NAMES.BLOCK_SDT}`);
326718
327157
  if (container)
326719
327158
  elements = [container];
326720
327159
  }
@@ -326837,27 +327276,18 @@ function print() { __p += __j.call(arguments, '') }
326837
327276
  node2 = selection.node;
326838
327277
  pos = selection.from;
326839
327278
  } else {
326840
- const $pos = selection.$from;
326841
- if (!$pos || typeof $pos.depth !== "number" || typeof $pos.node !== "function") {
327279
+ const editorDoc = this.#editor?.view?.state?.doc;
327280
+ if (!editorDoc) {
326842
327281
  this.#clearSelectedStructuredContentInlineClass();
326843
327282
  return;
326844
327283
  }
326845
- for (let depth = $pos.depth;depth > 0; depth--) {
326846
- const candidate = $pos.node(depth);
326847
- if (candidate.type?.name === "structuredContent") {
326848
- if (typeof $pos.before !== "function") {
326849
- this.#clearSelectedStructuredContentInlineClass();
326850
- return;
326851
- }
326852
- node2 = candidate;
326853
- pos = $pos.before(depth);
326854
- break;
326855
- }
326856
- }
326857
- if (!node2 || pos == null) {
327284
+ const resolved = findStructuredContentInlineAtPos(editorDoc, selection.from);
327285
+ if (!resolved) {
326858
327286
  this.#clearSelectedStructuredContentInlineClass();
326859
327287
  return;
326860
327288
  }
327289
+ node2 = resolved.node;
327290
+ pos = resolved.pos;
326861
327291
  }
326862
327292
  if (!this.#painterHost) {
326863
327293
  this.#clearSelectedStructuredContentInlineClass();
@@ -326911,7 +327341,8 @@ function print() { __p += __j.call(arguments, '') }
326911
327341
  const hasFocus = activeEditor?.view?.hasFocus?.() ?? false;
326912
327342
  const contextMenuOpen = activeEditor?.state ? !!ContextMenuPluginKey.getState(activeEditor.state)?.open : false;
326913
327343
  const isOnEditorUi = !!document.activeElement?.closest?.("[data-editor-ui-surface], .sd-toolbar-dropdown-menu, .toolbar-dropdown-menu");
326914
- if (!hasFocus && !contextMenuOpen && !isOnEditorUi) {
327344
+ const isDragDropIndicatorActive = this.#dragDropIndicatorPos != null;
327345
+ if (!hasFocus && !contextMenuOpen && !isOnEditorUi && !isDragDropIndicatorActive) {
326915
327346
  try {
326916
327347
  this.#clearSelectedFieldAnnotationClass();
326917
327348
  this.#localSelectionLayer.innerHTML = "";
@@ -326951,8 +327382,9 @@ function print() { __p += __j.call(arguments, '') }
326951
327382
  }
326952
327383
  return;
326953
327384
  }
326954
- if (from$1 === to) {
326955
- const caretLayout = this.#computeCaretLayoutRect(from$1);
327385
+ if (from$1 === to || isDragDropIndicatorActive) {
327386
+ const caretPos = this.#dragDropIndicatorPos ?? from$1;
327387
+ const caretLayout = this.#computeCaretLayoutRect(caretPos);
326956
327388
  if (!caretLayout)
326957
327389
  return;
326958
327390
  try {
@@ -326966,7 +327398,7 @@ function print() { __p += __j.call(arguments, '') }
326966
327398
  if (process$12.env.NODE_ENV === "development")
326967
327399
  console.warn("[PresentationEditor] Failed to render caret overlay:", error48);
326968
327400
  }
326969
- if (shouldScrollIntoView)
327401
+ if (shouldScrollIntoView && !isDragDropIndicatorActive)
326970
327402
  this.#scrollActiveEndIntoView(caretLayout.pageIndex);
326971
327403
  return;
326972
327404
  }
@@ -329087,7 +329519,7 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
329087
329519
 
329088
329520
  // ../../packages/superdoc/dist/super-editor.es.js
329089
329521
  var init_super_editor_es = __esm(() => {
329090
- init_src_C_jV2TZI_es();
329522
+ init_src_CSHo1aJM_es();
329091
329523
  init_SuperConverter_D1o6_yKI_es();
329092
329524
  init_jszip_C49i9kUs_es();
329093
329525
  init_xml_js_CqGKpaft_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.3.0-next.64",
3
+ "version": "0.3.0-next.65",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -20,8 +20,8 @@
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
22
  "@superdoc/document-api": "0.0.1",
23
- "@superdoc/super-editor": "0.0.1",
24
- "superdoc": "1.31.0"
23
+ "superdoc": "1.31.0",
24
+ "@superdoc/super-editor": "0.0.1"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"