@superdoc-dev/mcp 0.3.0-next.63 → 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 +744 -212
  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-ItIaPxzW.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) => {
@@ -199280,9 +199280,11 @@ function cssColorToHex(cssColor) {
199280
199280
  return trimmed;
199281
199281
  }
199282
199282
  function computeTabStops$1(context) {
199283
- const { explicitStops, defaultTabInterval, paragraphIndent } = context;
199283
+ const { explicitStops, defaultTabInterval, paragraphIndent, rawParagraphIndent } = context;
199284
199284
  const leftIndent = paragraphIndent.left ?? 0;
199285
199285
  const hanging = paragraphIndent.hanging ?? 0;
199286
+ const rawLeftIndent = rawParagraphIndent?.left ?? leftIndent;
199287
+ const rawHanging = rawParagraphIndent?.hanging ?? hanging;
199286
199288
  const effectiveMinIndent = Math.max(0, leftIndent - hanging);
199287
199289
  const clearPositions = explicitStops.filter((stop) => stop.val === "clear").map((stop) => stop.pos);
199288
199290
  const filteredExplicitStops = explicitStops.filter((stop) => stop.val !== "clear").filter((stop) => stop.pos >= effectiveMinIndent).map((stop) => ({
@@ -199293,6 +199295,7 @@ function computeTabStops$1(context) {
199293
199295
  const stops = [...filteredExplicitStops];
199294
199296
  const hasStartAlignedExplicit = filteredExplicitStops.some((stop) => stop.val === "start");
199295
199297
  const hasExplicitStops = filteredExplicitStops.length > 0;
199298
+ const hasClearAtPosition = (position4) => clearPositions.some((clearPos) => Math.abs(clearPos - position4) < TAB_POSITION_TOLERANCE_TWIPS);
199296
199299
  const hasClearAtLeftIndent = clearPositions.some((clearPos) => Math.abs(clearPos - leftIndent) < TAB_POSITION_TOLERANCE_TWIPS);
199297
199300
  if (!hasExplicitStops && !hasClearAtLeftIndent && hanging > 0 && leftIndent > effectiveMinIndent)
199298
199301
  stops.push({
@@ -199301,6 +199304,22 @@ function computeTabStops$1(context) {
199301
199304
  leader: "none",
199302
199305
  source: "default"
199303
199306
  });
199307
+ const firstLineOrigin = rawLeftIndent - rawHanging;
199308
+ if (firstLineOrigin < 0 && !hasClearAtPosition(0) && !stops.some((stop) => Math.abs(stop.pos) < TAB_POSITION_TOLERANCE_TWIPS))
199309
+ stops.push({
199310
+ val: "start",
199311
+ pos: 0,
199312
+ leader: "none",
199313
+ source: "default"
199314
+ });
199315
+ const leftIndentStop = Math.abs(rawLeftIndent);
199316
+ if (rawHanging > 0 && leftIndentStop > 0 && firstLineOrigin < leftIndentStop && !hasClearAtPosition(leftIndentStop) && !stops.some((stop) => Math.abs(stop.pos - leftIndentStop) < TAB_POSITION_TOLERANCE_TWIPS))
199317
+ stops.push({
199318
+ val: "start",
199319
+ pos: leftIndentStop,
199320
+ leader: "none",
199321
+ source: "default"
199322
+ });
199304
199323
  const defaultStart = !hasStartAlignedExplicit ? 0 : Math.max(maxExplicit, leftIndent);
199305
199324
  let pos = defaultStart;
199306
199325
  const targetLimit = Math.max(defaultStart, leftIndent, maxExplicit) + 14400;
@@ -240169,6 +240188,49 @@ function resolveAnnotationDisplayLabel(annotation, contentEl) {
240169
240188
  value: derivedLabel
240170
240189
  };
240171
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
+ }
240172
240234
  function cssClassForKind(kind) {
240173
240235
  switch (kind) {
240174
240236
  case "spelling":
@@ -243264,7 +243326,8 @@ function resolveParagraphContent(fragment, block, measure) {
243264
243326
  if (!hasExplicitSegmentPositioning)
243265
243327
  textIndentPx = firstLineOffset;
243266
243328
  }
243267
- availableWidth = adjustAvailableWidthForTextIndent(availableWidth, textIndentPx, line.maxWidth);
243329
+ const availableWidthIndentOffset = isFirstLine && !isListFirstLine && line.hasExplicitTabStops !== true ? firstLineOffset : textIndentPx;
243330
+ availableWidth = adjustAvailableWidthForTextIndent(availableWidth, availableWidthIndentOffset, line.maxWidth);
243268
243331
  const indentLeft = paraIndent?.left ?? 0;
243269
243332
  const firstLine = paraIndent?.firstLine ?? 0;
243270
243333
  const hanging = paraIndent?.hanging ?? 0;
@@ -249133,8 +249196,8 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
249133
249196
  const wordLayout = attrs?.wordLayout;
249134
249197
  const rawIndentLeft = typeof indent2?.left === "number" && Number.isFinite(indent2.left) ? indent2.left : 0;
249135
249198
  const rawIndentRight = typeof indent2?.right === "number" && Number.isFinite(indent2.right) ? indent2.right : 0;
249136
- const indentLeft = Math.max(0, rawIndentLeft);
249137
- const indentRight = Math.max(0, rawIndentRight);
249199
+ const indentLeft = rawIndentLeft;
249200
+ const indentRight = rawIndentRight;
249138
249201
  const indentFirstLine = Math.max(0, indent2?.firstLine ?? 0);
249139
249202
  const indentHanging = Math.max(0, indent2?.hanging ?? 0);
249140
249203
  const baseFirstLineOffset = attrs?.suppressFirstLineIndent === true ? 0 : firstLineIndent || indentFirstLine - indentHanging;
@@ -251563,6 +251626,97 @@ function findNearestTextblockResolvedPos(doc$12, pos) {
251563
251626
  return null;
251564
251627
  return textblockPos;
251565
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
+ }
251566
251720
  function getSelectionDebugConfig() {
251567
251721
  if (typeof window === "undefined")
251568
251722
  return DEFAULT_CONFIG;
@@ -252654,7 +252808,7 @@ function createLayoutMetrics(perf, startMark, layout, blocks2) {
252654
252808
  };
252655
252809
  }
252656
252810
  function coerceNumber(value) {
252657
- if (isFiniteNumber(value))
252811
+ if (isFiniteNumber$1(value))
252658
252812
  return Number(value);
252659
252813
  if (typeof value === "string" && value.trim() !== "") {
252660
252814
  const parsed = Number(value);
@@ -252662,7 +252816,7 @@ function coerceNumber(value) {
252662
252816
  }
252663
252817
  }
252664
252818
  function coercePositiveNumber(value, fallback) {
252665
- if (!isFiniteNumber(fallback) || fallback <= 0)
252819
+ if (!isFiniteNumber$1(fallback) || fallback <= 0)
252666
252820
  throw new Error(`coercePositiveNumber: fallback must be a positive number, got ${fallback}`);
252667
252821
  const numeric = coerceNumber(value);
252668
252822
  if (numeric != null && numeric > 0)
@@ -252708,7 +252862,7 @@ function toBoxSpacing(spacing) {
252708
252862
  "left"
252709
252863
  ].forEach((side) => {
252710
252864
  const value = spacing[side];
252711
- if (isFiniteNumber(value))
252865
+ if (isFiniteNumber$1(value))
252712
252866
  result[side] = Number(value);
252713
252867
  });
252714
252868
  return Object.keys(result).length > 0 ? result : undefined;
@@ -252742,7 +252896,7 @@ function isShapeGroupTransform(value) {
252742
252896
  if (!value || typeof value !== "object")
252743
252897
  return false;
252744
252898
  const maybe = value;
252745
- 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);
252746
252900
  }
252747
252901
  function normalizeShapeSize(value) {
252748
252902
  if (!value || typeof value !== "object")
@@ -253148,7 +253302,7 @@ function convertBorderSpec(ooxmlBorder, options) {
253148
253302
  style: "none",
253149
253303
  width: 0
253150
253304
  };
253151
- if (!isFiniteNumber(sizeNumber))
253305
+ if (!isFiniteNumber$1(sizeNumber))
253152
253306
  return;
253153
253307
  const numericSize = sizeNumber;
253154
253308
  if (numericSize <= 0)
@@ -253175,7 +253329,7 @@ function convertTableBorderValue(ooxmlBorder, options) {
253175
253329
  const { val, size: size$1, color: color2 } = border;
253176
253330
  if (val === "nil" || val === "none" || size$1 === 0)
253177
253331
  return { none: true };
253178
- if (!isFiniteNumber(size$1))
253332
+ if (!isFiniteNumber$1(size$1))
253179
253333
  return;
253180
253334
  const numericSize = size$1;
253181
253335
  if (numericSize <= 0)
@@ -254748,7 +254902,7 @@ function toBoxSpacing$1(spacing) {
254748
254902
  "left"
254749
254903
  ].forEach((side) => {
254750
254904
  const value = spacing[side];
254751
- if (isFiniteNumber(value))
254905
+ if (isFiniteNumber$1(value))
254752
254906
  result[side] = Number(value);
254753
254907
  });
254754
254908
  return Object.keys(result).length > 0 ? result : undefined;
@@ -257685,6 +257839,143 @@ async function goToAnchor({ anchor, layout, blocks: blocks2, measures, bookmarks
257685
257839
  console.warn("[PresentationEditor] goToAnchor: Navigation succeeded but could not move caret (editor commands unavailable)");
257686
257840
  return true;
257687
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
+ }
257688
257979
  function isValidFieldAnnotationAttributes(attrs) {
257689
257980
  if (!attrs || typeof attrs !== "object")
257690
257981
  return false;
@@ -257726,6 +258017,11 @@ function hasFieldAnnotationData(event) {
257726
258017
  function isInternalDrag(event) {
257727
258018
  return event.dataTransfer?.types?.includes(INTERNAL_MIME_TYPE) ?? false;
257728
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
+ }
257729
258025
  function extractDragData(event) {
257730
258026
  if (!event.dataTransfer)
257731
258027
  return null;
@@ -257741,6 +258037,23 @@ function extractDragData(event) {
257741
258037
  return null;
257742
258038
  }
257743
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
+ }
257744
258057
  function hasPossibleFiles(event) {
257745
258058
  return event.dataTransfer?.types?.includes("Files") ?? false;
257746
258059
  }
@@ -257767,6 +258080,8 @@ function getDroppedImageFiles(event) {
257767
258080
  function getDropPayloadKind(event) {
257768
258081
  if (hasFieldAnnotationData(event))
257769
258082
  return "fieldAnnotation";
258083
+ if (hasInternalObjectType(event))
258084
+ return "internalObject";
257770
258085
  if (hasPossibleFiles(event))
257771
258086
  return "imageFiles";
257772
258087
  return "none";
@@ -259636,6 +259951,7 @@ async function measureParagraphBlock(block, maxWidth) {
259636
259951
  let hasSeenTextRun = false;
259637
259952
  let tabStopCursor = 0;
259638
259953
  let pendingTabAlignment = null;
259954
+ let pendingSegmentPrecedingTabEndX;
259639
259955
  let pendingLeader = null;
259640
259956
  let pendingRunSpacing = 0;
259641
259957
  let lastAppliedTabAlign = null;
@@ -259658,7 +259974,7 @@ async function measureParagraphBlock(block, maxWidth) {
259658
259974
  return;
259659
259975
  if (segmentWidth < 0)
259660
259976
  segmentWidth = 0;
259661
- const { target, val } = pendingTabAlignment;
259977
+ const { target, val, compensateNegativeLeft } = pendingTabAlignment;
259662
259978
  let startX = currentLine.width;
259663
259979
  if (val === "decimal") {
259664
259980
  const beforeWidth = beforeDecimalWidth ?? 0;
@@ -259669,10 +259985,9 @@ async function measureParagraphBlock(block, maxWidth) {
259669
259985
  startX = Math.max(0, target - segmentWidth / 2);
259670
259986
  else
259671
259987
  startX = Math.max(0, target);
259672
- if (pendingLeader) {
259673
- const effectiveIndent = lines.length === 0 ? indentLeft + rawFirstLineOffset : indentLeft;
259988
+ const effectiveIndent = lines.length === 0 ? indentLeft + rawFirstLineOffset : indentLeft;
259989
+ if (pendingLeader)
259674
259990
  pendingLeader.to = startX + effectiveIndent;
259675
- }
259676
259991
  currentLine.width = roundValue(startX);
259677
259992
  lastAppliedTabAlign = {
259678
259993
  target,
@@ -259680,7 +259995,17 @@ async function measureParagraphBlock(block, maxWidth) {
259680
259995
  };
259681
259996
  pendingTabAlignment = null;
259682
259997
  pendingLeader = null;
259683
- return startX;
259998
+ const shouldCompensateNegativeLeft = compensateNegativeLeft === true;
259999
+ pendingSegmentPrecedingTabEndX = shouldCompensateNegativeLeft ? startX : undefined;
260000
+ return shouldCompensateNegativeLeft ? startX - Math.min(effectiveIndent, 0) : startX;
260001
+ };
260002
+ const consumePendingPrecedingTabEndX = () => {
260003
+ const value = pendingSegmentPrecedingTabEndX;
260004
+ pendingSegmentPrecedingTabEndX = undefined;
260005
+ return value;
260006
+ };
260007
+ const clearPendingPrecedingTabEndX = () => {
260008
+ pendingSegmentPrecedingTabEndX = undefined;
259684
260009
  };
259685
260010
  const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
259686
260011
  if (!pendingTabAlignment || !currentLine)
@@ -260021,7 +260346,8 @@ async function measureParagraphBlock(block, maxWidth) {
260021
260346
  } else
260022
260347
  pendingTabAlignment = {
260023
260348
  target: clampedTarget - effectiveIndent,
260024
- val: stop.val
260349
+ val: stop.val,
260350
+ compensateNegativeLeft: stop.val === "start" && indentLeft < 0 && effectiveIndent === indentLeft && stop.source !== "explicit"
260025
260351
  };
260026
260352
  } else {
260027
260353
  pendingTabAlignment = null;
@@ -260043,6 +260369,7 @@ async function measureParagraphBlock(block, maxWidth) {
260043
260369
  activeTabGroup.currentX = roundValue(activeTabGroup.currentX + imageWidth);
260044
260370
  } else if (pendingTabAlignment && currentLine)
260045
260371
  imageStartX = alignPendingTabForWidth(imageWidth);
260372
+ const imagePrecedingTabEndX = imageStartX !== undefined ? consumePendingPrecedingTabEndX() : undefined;
260046
260373
  if (!currentLine) {
260047
260374
  currentLine = {
260048
260375
  fromRun: runIndex,
@@ -260059,7 +260386,8 @@ async function measureParagraphBlock(block, maxWidth) {
260059
260386
  fromChar: 0,
260060
260387
  toChar: 1,
260061
260388
  width: imageWidth,
260062
- ...imageStartX !== undefined ? { x: imageStartX } : {}
260389
+ ...imageStartX !== undefined ? { x: imageStartX } : {},
260390
+ ...imagePrecedingTabEndX !== undefined ? { precedingTabEndX: imagePrecedingTabEndX } : {}
260063
260391
  }]
260064
260392
  };
260065
260393
  pendingRunSpacing = 0;
@@ -260111,7 +260439,8 @@ async function measureParagraphBlock(block, maxWidth) {
260111
260439
  fromChar: 0,
260112
260440
  toChar: 1,
260113
260441
  width: imageWidth,
260114
- ...imageStartX !== undefined ? { x: imageStartX } : {}
260442
+ ...imageStartX !== undefined ? { x: imageStartX } : {},
260443
+ ...imagePrecedingTabEndX !== undefined ? { precedingTabEndX: imagePrecedingTabEndX } : {}
260115
260444
  });
260116
260445
  }
260117
260446
  if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex)
@@ -260186,6 +260515,7 @@ async function measureParagraphBlock(block, maxWidth) {
260186
260515
  let annotationStartX;
260187
260516
  if (pendingTabAlignment && currentLine)
260188
260517
  annotationStartX = alignPendingTabForWidth(annotationWidth);
260518
+ const annotationPrecedingTabEndX = annotationStartX !== undefined ? consumePendingPrecedingTabEndX() : undefined;
260189
260519
  if (!currentLine) {
260190
260520
  currentLine = {
260191
260521
  fromRun: runIndex,
@@ -260201,7 +260531,8 @@ async function measureParagraphBlock(block, maxWidth) {
260201
260531
  fromChar: 0,
260202
260532
  toChar: 1,
260203
260533
  width: annotationWidth,
260204
- ...annotationStartX !== undefined ? { x: annotationStartX } : {}
260534
+ ...annotationStartX !== undefined ? { x: annotationStartX } : {},
260535
+ ...annotationPrecedingTabEndX !== undefined ? { precedingTabEndX: annotationPrecedingTabEndX } : {}
260205
260536
  }]
260206
260537
  };
260207
260538
  pendingRunSpacing = 0;
@@ -260248,7 +260579,8 @@ async function measureParagraphBlock(block, maxWidth) {
260248
260579
  fromChar: 0,
260249
260580
  toChar: 1,
260250
260581
  width: annotationWidth,
260251
- ...annotationStartX !== undefined ? { x: annotationStartX } : {}
260582
+ ...annotationStartX !== undefined ? { x: annotationStartX } : {},
260583
+ ...annotationPrecedingTabEndX !== undefined ? { precedingTabEndX: annotationPrecedingTabEndX } : {}
260252
260584
  });
260253
260585
  }
260254
260586
  const tabAlign = lastAppliedTabAlign;
@@ -260356,6 +260688,18 @@ async function measureParagraphBlock(block, maxWidth) {
260356
260688
  if (segmentStartX == null)
260357
260689
  segmentStartX = currentLine.width;
260358
260690
  }
260691
+ let hasPendingSegmentTabGeometry = segmentStartX !== undefined;
260692
+ const consumeSegmentPrecedingTabEndX = () => {
260693
+ if (!hasPendingSegmentTabGeometry)
260694
+ return;
260695
+ hasPendingSegmentTabGeometry = false;
260696
+ return consumePendingPrecedingTabEndX();
260697
+ };
260698
+ const clearWrapState = () => {
260699
+ segmentStartX = undefined;
260700
+ hasPendingSegmentTabGeometry = false;
260701
+ clearPendingPrecedingTabEndX();
260702
+ };
260359
260703
  for (let wordIndex = 0;wordIndex < words.length; wordIndex++) {
260360
260704
  const word$1 = words[wordIndex];
260361
260705
  if (word$1 === "") {
@@ -260397,6 +260741,7 @@ async function measureParagraphBlock(block, maxWidth) {
260397
260741
  pendingLeader = null;
260398
260742
  lastAppliedTabAlign = null;
260399
260743
  activeTabGroup = null;
260744
+ clearWrapState();
260400
260745
  currentLine = {
260401
260746
  fromRun: runIndex,
260402
260747
  fromChar: spaceStartChar,
@@ -260421,11 +260766,15 @@ async function measureParagraphBlock(block, maxWidth) {
260421
260766
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
260422
260767
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
260423
260768
  let spaceExplicitX;
260769
+ let spacePrecedingTabEndX;
260424
260770
  if (inActiveTabGroup && activeTabGroup) {
260425
260771
  spaceExplicitX = activeTabGroup.currentX;
260426
260772
  activeTabGroup.currentX = roundValue(activeTabGroup.currentX + singleSpaceWidth);
260773
+ } else if (wordIndex === 0 && segmentStartX !== undefined) {
260774
+ spaceExplicitX = segmentStartX;
260775
+ spacePrecedingTabEndX = consumeSegmentPrecedingTabEndX();
260427
260776
  }
260428
- appendSegment(currentLine.segments, runIndex, spaceStartChar, spaceEndChar, singleSpaceWidth, spaceExplicitX);
260777
+ appendSegment(currentLine.segments, runIndex, spaceStartChar, spaceEndChar, singleSpaceWidth, spaceExplicitX, spacePrecedingTabEndX);
260429
260778
  currentLine.spaceCount += 1;
260430
260779
  }
260431
260780
  }
@@ -260453,6 +260802,7 @@ async function measureParagraphBlock(block, maxWidth) {
260453
260802
  pendingTabAlignment = null;
260454
260803
  pendingLeader = null;
260455
260804
  currentLine = null;
260805
+ clearWrapState();
260456
260806
  }
260457
260807
  const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
260458
260808
  const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
@@ -260498,6 +260848,7 @@ async function measureParagraphBlock(block, maxWidth) {
260498
260848
  pendingTabAlignment = null;
260499
260849
  pendingLeader = null;
260500
260850
  currentLine = null;
260851
+ clearWrapState();
260501
260852
  }
260502
260853
  } else if (isLastChunk) {
260503
260854
  currentLine = {
@@ -260545,6 +260896,7 @@ async function measureParagraphBlock(block, maxWidth) {
260545
260896
  };
260546
260897
  addBarTabsToLine(chunkLine);
260547
260898
  lines.push(chunkLine);
260899
+ clearWrapState();
260548
260900
  }
260549
260901
  chunkCharOffset = chunkEndChar;
260550
260902
  }
@@ -260606,6 +260958,8 @@ async function measureParagraphBlock(block, maxWidth) {
260606
260958
  }
260607
260959
  }
260608
260960
  if (shouldBreak) {
260961
+ if (wordIndex === 0 && hasPendingSegmentTabGeometry)
260962
+ clearWrapState();
260609
260963
  trimTrailingWrapSpaces(currentLine);
260610
260964
  const metrics = finalizeLineMetrics(currentLine, spacing);
260611
260965
  const completedLine = {
@@ -260658,7 +261012,7 @@ async function measureParagraphBlock(block, maxWidth) {
260658
261012
  activeTabGroup.currentX = roundValue(activeTabGroup.currentX + wordOnlyWidth);
260659
261013
  } else if (wordIndex === 0 && segmentStartX !== undefined)
260660
261014
  explicitXHere = segmentStartX;
260661
- appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, explicitXHere);
261015
+ appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, explicitXHere, wordIndex === 0 ? consumeSegmentPrecedingTabEndX() : undefined);
260662
261016
  trimTrailingWrapSpaces(currentLine);
260663
261017
  const metrics = finalizeLineMetrics(currentLine, spacing);
260664
261018
  const completedLine = {
@@ -260688,7 +261042,7 @@ async function measureParagraphBlock(block, maxWidth) {
260688
261042
  currentLine.width = roundValue(targetWidth);
260689
261043
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
260690
261044
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
260691
- appendSegment(currentLine.segments, runIndex, wordStartChar, newToChar, wordCommitWidth, explicitX);
261045
+ appendSegment(currentLine.segments, runIndex, wordStartChar, newToChar, wordCommitWidth, explicitX, wordIndex === 0 ? consumeSegmentPrecedingTabEndX() : undefined);
260692
261046
  if (shouldIncludeDelimiterSpace)
260693
261047
  currentLine.spaceCount += 1;
260694
261048
  }
@@ -260741,7 +261095,8 @@ async function measureParagraphBlock(block, maxWidth) {
260741
261095
  validateTabStopVal(stop);
260742
261096
  pendingTabAlignment = {
260743
261097
  target: clampedTarget - effectiveIndent,
260744
- val: stop.val
261098
+ val: stop.val,
261099
+ compensateNegativeLeft: stop.val === "start" && indentLeft < 0 && effectiveIndent === indentLeft && stop.source !== "explicit"
260745
261100
  };
260746
261101
  } else {
260747
261102
  pendingTabAlignment = null;
@@ -261722,6 +262077,15 @@ function ensureEditorFieldAnnotationInteractionStyles(doc$12) {
261722
262077
  doc$12.head?.appendChild(styleEl);
261723
262078
  fieldAnnotationInteractionStylesInjected = true;
261724
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
+ }
261725
262089
  function parseRenderedNoteTarget(blockId) {
261726
262090
  if (typeof blockId !== "string" || blockId.length === 0)
261727
262091
  return null;
@@ -276568,7 +276932,7 @@ var Node$13 = class Node$14 {
276568
276932
  }
276569
276933
  this.#applied.delete(el);
276570
276934
  }
276571
- }, 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 {
276572
276936
  #container = null;
276573
276937
  setContainer(container) {
276574
276938
  this.#container = container;
@@ -276580,9 +276944,9 @@ var Node$13 = class Node$14 {
276580
276944
  const annotations = this.#container.querySelectorAll(buildAnnotationSelector());
276581
276945
  for (let index2 = 0;index2 < annotations.length; index2 += 1) {
276582
276946
  const annotation = annotations[index2];
276583
- if (annotation.dataset[INTERACTION_EPOCH_KEY] === epochStr)
276947
+ if (annotation.dataset[INTERACTION_EPOCH_KEY$2] === epochStr)
276584
276948
  continue;
276585
- annotation.dataset[INTERACTION_EPOCH_KEY] = epochStr;
276949
+ annotation.dataset[INTERACTION_EPOCH_KEY$2] = epochStr;
276586
276950
  annotation.draggable = true;
276587
276951
  annotation.dataset[DATASET_KEYS.DRAGGABLE] = "true";
276588
276952
  const displayLabel = resolveAnnotationDisplayLabel(annotation, annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CONTENT}`));
@@ -276606,7 +276970,7 @@ var Node$13 = class Node$14 {
276606
276970
  delete annotation.dataset[DATASET_KEYS.DRAGGABLE];
276607
276971
  delete annotation.dataset[DATASET_KEYS.DISPLAY_LABEL];
276608
276972
  delete annotation.dataset[DATASET_KEYS.VARIANT];
276609
- delete annotation.dataset[INTERACTION_EPOCH_KEY];
276973
+ delete annotation.dataset[INTERACTION_EPOCH_KEY$2];
276610
276974
  delete annotation.dataset[DISPLAY_LABEL_SOURCE_KEY];
276611
276975
  annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CARET_ANCHOR}`)?.remove();
276612
276976
  }
@@ -276640,6 +277004,95 @@ var Node$13 = class Node$14 {
276640
277004
  annotation.style.position = "relative";
276641
277005
  annotation.appendChild(caretAnchor);
276642
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
+ }
276643
277096
  }, PROOFING_CSS, splitOriginMap, PresentationProofingDecorator = class {
276644
277097
  #container = null;
276645
277098
  setContainer(container) {
@@ -276661,17 +277114,23 @@ var Node$13 = class Node$14 {
276661
277114
  }
276662
277115
  }, PresentationPostPaintPipeline = class {
276663
277116
  #fieldAnnotationLayer;
277117
+ #imageLayer;
277118
+ #structuredContentLayer;
276664
277119
  #commentHighlightDecorator;
276665
277120
  #decorationBridge;
276666
277121
  #proofingDecorator;
276667
277122
  constructor(deps = {}) {
276668
277123
  this.#fieldAnnotationLayer = deps.fieldAnnotationLayer ?? new FieldAnnotationInteractionLayer;
277124
+ this.#imageLayer = deps.imageLayer ?? new ImageInteractionLayer;
277125
+ this.#structuredContentLayer = deps.structuredContentLayer ?? new StructuredContentInteractionLayer;
276669
277126
  this.#commentHighlightDecorator = deps.commentHighlightDecorator ?? new CommentHighlightDecorator;
276670
277127
  this.#decorationBridge = deps.decorationBridge ?? new DecorationBridge;
276671
277128
  this.#proofingDecorator = deps.proofingDecorator ?? new PresentationProofingDecorator;
276672
277129
  }
276673
277130
  setContainer(container) {
276674
277131
  this.#fieldAnnotationLayer.setContainer(container);
277132
+ this.#imageLayer.setContainer(container);
277133
+ this.#structuredContentLayer.setContainer(container);
276675
277134
  this.#commentHighlightDecorator.setContainer(container);
276676
277135
  this.#proofingDecorator.setContainer(container);
276677
277136
  }
@@ -276711,6 +277170,8 @@ var Node$13 = class Node$14 {
276711
277170
  refreshAfterPaint(options) {
276712
277171
  this.#fieldAnnotationLayer.apply(options.layoutEpoch);
276713
277172
  options.rebuildDomPositionIndex();
277173
+ this.#imageLayer.apply(options.layoutEpoch);
277174
+ this.#structuredContentLayer.apply(options.layoutEpoch);
276714
277175
  this.syncInlineStyleLayers(options.editorState, options.domPositionIndex);
276715
277176
  this.applyProofingAnnotations(options.proofingAnnotations, options.rebuildDomPositionIndex);
276716
277177
  options.reapplyStructuredContentHover?.();
@@ -276718,6 +277179,8 @@ var Node$13 = class Node$14 {
276718
277179
  destroy() {
276719
277180
  this.#proofingDecorator.clear();
276720
277181
  this.#fieldAnnotationLayer.clear();
277182
+ this.#imageLayer.clear();
277183
+ this.#structuredContentLayer.clear();
276721
277184
  this.#commentHighlightDecorator.destroy();
276722
277185
  this.#decorationBridge.destroy();
276723
277186
  }
@@ -279179,6 +279642,10 @@ menclose::after {
279179
279642
  container.classList.add(CLASS_NAMES$1.fragment);
279180
279643
  applyStyles$2(container, fragmentStyles);
279181
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);
279182
279649
  container.style.height = `${fragment.height}px`;
279183
279650
  applySdtDataset(container, block.attrs?.sdt);
279184
279651
  applyContainerSdtDataset?.(container, block.attrs?.containerSdt);
@@ -281921,7 +282388,7 @@ menclose::after {
281921
282388
  if (transform2 === "capitalize")
281922
282389
  return capitalizeText$2(text5, fullText, startOffset);
281923
282390
  return text5;
281924
- }, DEFAULT_TAB_INTERVAL_TWIPS$2 = 720, TWIPS_PER_PX$2, TAB_EPSILON$1 = 0.1, WIDTH_FUDGE_PX = 0.5, twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$2, pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$2), sanitizeIndent$1 = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0, sanitizeDecimalSeparator$1 = (value) => value === "," ? "," : ".", getRunWidth = (run2) => {
282391
+ }, DEFAULT_TAB_INTERVAL_TWIPS$2 = 720, TWIPS_PER_PX$2, TAB_EPSILON$1 = 0.1, WIDTH_FUDGE_PX = 0.5, twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$2, pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$2), sanitizeIndent$1 = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0, sanitizeRawIndent = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0, sanitizeDecimalSeparator$1 = (value) => value === "," ? "," : ".", getRunWidth = (run2) => {
281925
282392
  const width = run2.width;
281926
282393
  return typeof width === "number" ? width : 0;
281927
282394
  }, isLineBreakRun$1 = (run2) => run2.kind === "lineBreak" || run2.kind === "break" && run2.breakType === "line", markerFontString = (run2) => {
@@ -281935,10 +282402,17 @@ menclose::after {
281935
282402
  firstLine: pxToTwips$1(sanitizeIndent$1(indent2?.firstLine)),
281936
282403
  hanging: pxToTwips$1(sanitizeIndent$1(indent2?.hanging))
281937
282404
  };
282405
+ const rawParagraphIndentTwips = {
282406
+ left: pxToTwips$1(sanitizeRawIndent(indent2?.left)),
282407
+ right: pxToTwips$1(sanitizeRawIndent(indent2?.right)),
282408
+ firstLine: pxToTwips$1(sanitizeRawIndent(indent2?.firstLine)),
282409
+ hanging: pxToTwips$1(sanitizeIndent$1(indent2?.hanging))
282410
+ };
281938
282411
  return computeTabStops$1({
281939
282412
  explicitStops: tabs ?? [],
281940
282413
  defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$2,
281941
- paragraphIndent: paragraphIndentTwips
282414
+ paragraphIndent: paragraphIndentTwips,
282415
+ rawParagraphIndent: rawParagraphIndentTwips
281942
282416
  }).map((stop) => ({
281943
282417
  pos: twipsToPx$2(stop.pos),
281944
282418
  val: stop.val,
@@ -282163,6 +282637,10 @@ menclose::after {
282163
282637
  }
282164
282638
  const clampedTarget = Number.isFinite(maxAbsWidth) ? Math.min(target, maxAbsWidth) : target;
282165
282639
  const relativeTarget = clampedTarget - effectiveIndent;
282640
+ const stopVal = stop?.val ?? "start";
282641
+ const shouldCompensateNegativeLeft = stopVal === "start" && indentLeft < 0 && effectiveIndent === indentLeft && stop?.source !== "explicit";
282642
+ const paintTarget = shouldCompensateNegativeLeft ? relativeTarget - Math.min(effectiveIndent, 0) : relativeTarget;
282643
+ const precedingTabEndX = shouldCompensateNegativeLeft ? relativeTarget : undefined;
282166
282644
  lineWidth = Math.max(lineWidth, relativeTarget);
282167
282645
  if (stop?.source === "explicit")
282168
282646
  line.hasExplicitTabStops = true;
@@ -282175,7 +282653,6 @@ menclose::after {
282175
282653
  };
282176
282654
  leaders.push(currentLeader);
282177
282655
  }
282178
- const stopVal = stop?.val ?? "start";
282179
282656
  if (stopVal === "end" || stopVal === "center" || stopVal === "decimal") {
282180
282657
  const groupMeasure = measureTabAlignmentGroupInLine(runs2, line, startRunIndex, startChar, decimalSeparator);
282181
282658
  if (groupMeasure.totalWidth > 0) {
@@ -282190,14 +282667,28 @@ menclose::after {
282190
282667
  }
282191
282668
  if (currentLeader)
282192
282669
  currentLeader.to = groupStartX + effectiveIndent;
282193
- pendingTabAlignStartX = groupStartX;
282670
+ pendingTabAlignStartX = {
282671
+ layoutX: groupStartX,
282672
+ paintX: groupStartX
282673
+ };
282194
282674
  } else
282195
282675
  cursorX = Math.max(cursorX, relativeTarget);
282196
- } else
282676
+ } else {
282197
282677
  cursorX = Math.max(cursorX, relativeTarget);
282678
+ pendingTabAlignStartX = {
282679
+ layoutX: relativeTarget,
282680
+ paintX: paintTarget,
282681
+ ...precedingTabEndX !== undefined ? { precedingTabEndX } : {}
282682
+ };
282683
+ }
282198
282684
  if (run2 && run2.kind === "tab")
282199
282685
  run2.width = Math.max(0, relativeTarget - originX);
282200
282686
  };
282687
+ const consumePendingTabAlignStart = () => {
282688
+ const pending = pendingTabAlignStartX;
282689
+ pendingTabAlignStartX = null;
282690
+ return pending;
282691
+ };
282201
282692
  for (let runIndex = line.fromRun;runIndex <= line.toRun; runIndex += 1) {
282202
282693
  const run2 = runs2[runIndex];
282203
282694
  if (!run2)
@@ -282229,10 +282720,12 @@ menclose::after {
282229
282720
  toChar: i4,
282230
282721
  width: segmentWidth
282231
282722
  };
282232
- if (pendingTabAlignStartX != null) {
282233
- segment.x = pendingTabAlignStartX;
282234
- cursorX = pendingTabAlignStartX + segmentWidth;
282235
- pendingTabAlignStartX = null;
282723
+ const pendingTabAlign = consumePendingTabAlignStart();
282724
+ if (pendingTabAlign != null) {
282725
+ segment.x = pendingTabAlign.paintX;
282726
+ if (pendingTabAlign.precedingTabEndX !== undefined)
282727
+ segment.precedingTabEndX = pendingTabAlign.precedingTabEndX;
282728
+ cursorX = pendingTabAlign.layoutX + segmentWidth;
282236
282729
  } else
282237
282730
  cursorX += segmentWidth;
282238
282731
  lineWidth = Math.max(lineWidth, cursorX);
@@ -282250,10 +282743,12 @@ menclose::after {
282250
282743
  toChar: sliceEnd,
282251
282744
  width: segmentWidth
282252
282745
  };
282253
- if (pendingTabAlignStartX != null) {
282254
- segment.x = pendingTabAlignStartX;
282255
- cursorX = pendingTabAlignStartX + segmentWidth;
282256
- pendingTabAlignStartX = null;
282746
+ const pendingTabAlign = consumePendingTabAlignStart();
282747
+ if (pendingTabAlign != null) {
282748
+ segment.x = pendingTabAlign.paintX;
282749
+ if (pendingTabAlign.precedingTabEndX !== undefined)
282750
+ segment.precedingTabEndX = pendingTabAlign.precedingTabEndX;
282751
+ cursorX = pendingTabAlign.layoutX + segmentWidth;
282257
282752
  } else
282258
282753
  cursorX += segmentWidth;
282259
282754
  lineWidth = Math.max(lineWidth, cursorX);
@@ -284094,12 +284589,12 @@ menclose::after {
284094
284589
  if (pt == null || !Number.isFinite(pt))
284095
284590
  return;
284096
284591
  return pt * PX_PER_PT2;
284097
- }, 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) => {
284098
284593
  if (!value)
284099
284594
  return "";
284100
284595
  return String(value);
284101
284596
  }, pickNumber = (value) => {
284102
- if (isFiniteNumber(value))
284597
+ if (isFiniteNumber$1(value))
284103
284598
  return value;
284104
284599
  if (typeof value === "string") {
284105
284600
  const parsed = parseFloat(value);
@@ -284297,7 +284792,7 @@ menclose::after {
284297
284792
  };
284298
284793
  }
284299
284794
  }, MIN_BORDER_SIZE_PX2 = 0.5, MAX_BORDER_SIZE_PX2 = 100, borderSizeToPx = (size$1) => {
284300
- if (!isFiniteNumber(size$1))
284795
+ if (!isFiniteNumber$1(size$1))
284301
284796
  return;
284302
284797
  if (size$1 <= 0)
284303
284798
  return 0;
@@ -284590,7 +285085,7 @@ menclose::after {
284590
285085
  const toNum = (v) => {
284591
285086
  if (typeof v === "string" && v.trim() !== "" && isFinite(Number(v)))
284592
285087
  return Number(v);
284593
- if (isFiniteNumber(v))
285088
+ if (isFiniteNumber$1(v))
284594
285089
  return Number(v);
284595
285090
  };
284596
285091
  const left$1 = toNum(indent2.left);
@@ -285198,7 +285693,7 @@ menclose::after {
285198
285693
  return;
285199
285694
  return sanitized;
285200
285695
  }, normalizeLengthPx = (value) => {
285201
- if (isFiniteNumber(value))
285696
+ if (isFiniteNumber$1(value))
285202
285697
  return value;
285203
285698
  if (typeof value !== "string")
285204
285699
  return;
@@ -286711,7 +287206,7 @@ menclose::after {
286711
287206
  this.#onCursorsUpdate = null;
286712
287207
  this.#isSetup = false;
286713
287208
  }
286714
- }, 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 {
286715
287210
  #deps = null;
286716
287211
  #callbacks = {};
286717
287212
  #isDragging = false;
@@ -287273,7 +287768,9 @@ menclose::after {
287273
287768
  }
287274
287769
  const annotationEl = target?.closest?.(buildAnnotationSelector());
287275
287770
  const isDraggableAnnotation = target?.closest?.(DRAGGABLE_SELECTOR) != null;
287276
- this.#suppressFocusInFromDraggable = isDraggableAnnotation;
287771
+ const isNativeDragSource = target?.closest?.(DRAG_SOURCE_SELECTOR) != null;
287772
+ const suppressFocusForDrag = isDraggableAnnotation || isNativeDragSource;
287773
+ this.#suppressFocusInFromDraggable = suppressFocusForDrag;
287277
287774
  if (annotationEl) {
287278
287775
  this.#handleAnnotationClick(event, annotationEl);
287279
287776
  return;
@@ -287286,7 +287783,7 @@ menclose::after {
287286
287783
  const activeNoteTarget = this.#getActiveRenderedNoteTarget();
287287
287784
  if (!layoutState.layout) {
287288
287785
  if (clickedNoteTarget && !isSameRenderedNoteTarget(activeNoteTarget, clickedNoteTarget)) {
287289
- if (!isDraggableAnnotation)
287786
+ if (!suppressFocusForDrag)
287290
287787
  event.preventDefault();
287291
287788
  if (this.#callbacks.activateRenderedNoteSession?.(clickedNoteTarget, {
287292
287789
  clientX: event.clientX,
@@ -287307,7 +287804,7 @@ menclose::after {
287307
287804
  return;
287308
287805
  } else
287309
287806
  this.#syncNonBodyCommentActivation(event, target, bodyEditor);
287310
- this.#handleClickWithoutLayout(event, isDraggableAnnotation);
287807
+ this.#handleClickWithoutLayout(event, suppressFocusForDrag);
287311
287808
  return;
287312
287809
  }
287313
287810
  const normalizedPoint = this.#callbacks.normalizeClientPoint?.(event.clientX, event.clientY);
@@ -287322,7 +287819,7 @@ menclose::after {
287322
287819
  };
287323
287820
  if (clickedNoteTarget) {
287324
287821
  if (!isSameRenderedNoteTarget(activeNoteTarget, clickedNoteTarget)) {
287325
- if (!isDraggableAnnotation)
287822
+ if (!suppressFocusForDrag)
287326
287823
  event.preventDefault();
287327
287824
  if (this.#callbacks.activateRenderedNoteSession?.(clickedNoteTarget, {
287328
287825
  clientX: event.clientX,
@@ -287398,7 +287895,7 @@ menclose::after {
287398
287895
  mappedPos: null
287399
287896
  };
287400
287897
  this.#callbacks.updateSelectionDebugHud?.();
287401
- if (!isDraggableAnnotation)
287898
+ if (!suppressFocusForDrag)
287402
287899
  event.preventDefault();
287403
287900
  const inlineStructuredContentLabel = target?.closest?.(".superdoc-structured-content-inline__label");
287404
287901
  if (inlineStructuredContentLabel && doc$12) {
@@ -287516,7 +288013,7 @@ menclose::after {
287516
288013
  this.#focusEditor();
287517
288014
  if (!handledByDepth)
287518
288015
  try {
287519
- const sdtBlock = clickDepth === 1 ? this.#findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
288016
+ const sdtBlock = clickDepth === 1 ? findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
287520
288017
  let nextSelection;
287521
288018
  let inlineSdtBoundaryPos = null;
287522
288019
  let inlineSdtBoundaryDirection = null;
@@ -287524,7 +288021,7 @@ menclose::after {
287524
288021
  if (sdtBlock && !insideTableInSdt)
287525
288022
  nextSelection = NodeSelection.create(doc$12, sdtBlock.pos);
287526
288023
  else {
287527
- const inlineSdt = clickDepth === 1 ? this.#findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
288024
+ const inlineSdt = clickDepth === 1 ? findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
287528
288025
  if (inlineSdt && hit.pos >= inlineSdt.end) {
287529
288026
  const afterInlineSdt = inlineSdt.pos + inlineSdt.node.nodeSize;
287530
288027
  inlineSdtBoundaryPos = afterInlineSdt;
@@ -287785,26 +288282,6 @@ menclose::after {
287785
288282
  });
287786
288283
  }
287787
288284
  }
287788
- #findStructuredContentBlockAtPos(doc$12, pos) {
287789
- if (!Number.isFinite(pos))
287790
- return null;
287791
- try {
287792
- const $pos = doc$12.resolve(pos);
287793
- for (let depth = $pos.depth;depth > 0; depth--) {
287794
- const node2 = $pos.node(depth);
287795
- if (node2.type?.name === "structuredContentBlock")
287796
- return {
287797
- node: node2,
287798
- pos: $pos.before(depth),
287799
- start: $pos.start(depth),
287800
- end: $pos.end(depth)
287801
- };
287802
- }
287803
- } catch {
287804
- return null;
287805
- }
287806
- return null;
287807
- }
287808
288285
  #isInsideTableWithinStructuredContentBlock(doc$12, pos, sdtPos) {
287809
288286
  if (!Number.isFinite(pos) || !Number.isFinite(sdtPos))
287810
288287
  return false;
@@ -287828,82 +288305,26 @@ menclose::after {
287828
288305
  return false;
287829
288306
  }
287830
288307
  }
287831
- #findStructuredContentBlockById(doc$12, id2) {
287832
- let found2 = null;
287833
- doc$12.descendants((node2, pos) => {
287834
- if (node2.type?.name !== "structuredContentBlock")
287835
- return true;
287836
- const nodeId = node2.attrs?.id;
287837
- if (String(nodeId ?? "") !== id2)
287838
- return true;
287839
- found2 = {
287840
- node: node2,
287841
- pos,
287842
- start: pos + 1,
287843
- end: pos + node2.nodeSize - 1
287844
- };
287845
- return false;
287846
- });
287847
- return found2;
287848
- }
287849
- #findStructuredContentInlineAtPos(doc$12, pos) {
287850
- if (!Number.isFinite(pos))
287851
- return null;
287852
- try {
287853
- const $pos = doc$12.resolve(pos);
287854
- for (let depth = $pos.depth;depth > 0; depth--) {
287855
- const node2 = $pos.node(depth);
287856
- if (node2.type?.name === "structuredContent")
287857
- return {
287858
- node: node2,
287859
- pos: $pos.before(depth),
287860
- start: $pos.start(depth),
287861
- end: $pos.end(depth)
287862
- };
287863
- }
287864
- } catch {
287865
- return null;
287866
- }
287867
- return null;
287868
- }
287869
- #findStructuredContentInlineById(doc$12, id2) {
287870
- let found2 = null;
287871
- doc$12.descendants((node2, pos) => {
287872
- if (node2.type?.name !== "structuredContent")
287873
- return true;
287874
- const nodeId = node2.attrs?.id;
287875
- if (String(nodeId ?? "") !== id2)
287876
- return true;
287877
- found2 = {
287878
- node: node2,
287879
- pos,
287880
- start: pos + 1,
287881
- end: pos + node2.nodeSize - 1
287882
- };
287883
- return false;
287884
- });
287885
- return found2;
287886
- }
287887
288308
  #resolveStructuredContentBlockFromElement(doc$12, element3) {
287888
288309
  const container = element3.closest?.(".superdoc-structured-content-block");
287889
288310
  if (!container)
287890
288311
  return null;
287891
288312
  const sdtId = container.dataset?.sdtId;
287892
288313
  if (sdtId) {
287893
- const match$1 = this.#findStructuredContentBlockById(doc$12, sdtId);
288314
+ const match$1 = findStructuredContentBlockById(doc$12, sdtId);
287894
288315
  if (match$1)
287895
288316
  return match$1;
287896
288317
  }
287897
288318
  const containerSdtId = container.dataset?.sdtContainerId;
287898
288319
  if (containerSdtId) {
287899
- const match$1 = this.#findStructuredContentBlockById(doc$12, containerSdtId);
288320
+ const match$1 = findStructuredContentBlockById(doc$12, containerSdtId);
287900
288321
  if (match$1)
287901
288322
  return match$1;
287902
288323
  }
287903
288324
  const pmStartRaw = container.dataset?.pmStart;
287904
288325
  const pmStart = pmStartRaw != null ? Number(pmStartRaw) : NaN;
287905
288326
  if (Number.isFinite(pmStart))
287906
- return this.#findStructuredContentBlockAtPos(doc$12, pmStart);
288327
+ return findStructuredContentBlockAtPos(doc$12, pmStart);
287907
288328
  return null;
287908
288329
  }
287909
288330
  #resolveStructuredContentInlineFromElement(doc$12, element3) {
@@ -287912,14 +288333,14 @@ menclose::after {
287912
288333
  return null;
287913
288334
  const sdtId = container.dataset?.sdtId;
287914
288335
  if (sdtId) {
287915
- const match$1 = this.#findStructuredContentInlineById(doc$12, sdtId);
288336
+ const match$1 = findStructuredContentInlineById(doc$12, sdtId);
287916
288337
  if (match$1)
287917
288338
  return match$1;
287918
288339
  }
287919
288340
  const pmStartRaw = container.dataset?.pmStart;
287920
288341
  const pmStart = pmStartRaw != null ? Number(pmStartRaw) : NaN;
287921
288342
  if (Number.isFinite(pmStart))
287922
- return this.#findStructuredContentInlineAtPos(doc$12, pmStart);
288343
+ return findStructuredContentInlineAtPos(doc$12, pmStart);
287923
288344
  return null;
287924
288345
  }
287925
288346
  #findStructuredContentBlockContentRange(resolved) {
@@ -288900,10 +289321,11 @@ menclose::after {
288900
289321
  #isCompositionKeyboardEvent(event) {
288901
289322
  return event.isComposing || event.keyCode === 229 || event.key === "Dead" || event.key === "Compose";
288902
289323
  }
288903
- }, 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 {
288904
289325
  #deps = null;
288905
289326
  #dragOverRaf = null;
288906
289327
  #pendingDragOver = null;
289328
+ #activeInternalObjectPayload = null;
288907
289329
  #boundHandleDragStart = null;
288908
289330
  #boundHandleDragOver = null;
288909
289331
  #boundHandleDrop = null;
@@ -288963,23 +289385,45 @@ menclose::after {
288963
289385
  }
288964
289386
  destroy() {
288965
289387
  this.#cancelPendingDragOverSelection();
289388
+ this.#activeInternalObjectPayload = null;
289389
+ this.#deps?.clearDragDropIndicator();
288966
289390
  this.unbind();
288967
289391
  this.#deps = null;
288968
289392
  }
288969
289393
  #handleDragStart(event) {
288970
289394
  const target = event.target;
288971
- 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;
289399
+ return;
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;
288972
289407
  return;
288973
- const data = extractFieldAnnotationData(target);
289408
+ }
288974
289409
  if (event.dataTransfer) {
288975
- const jsonData = JSON.stringify({
288976
- attributes: data.attributes,
288977
- sourceField: data
288978
- });
288979
- event.dataTransfer.setData(INTERNAL_MIME_TYPE, jsonData);
288980
- event.dataTransfer.setData(FIELD_ANNOTATION_DATA_TYPE, jsonData);
288981
- event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
288982
- 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
+ }
288983
289427
  event.dataTransfer.effectAllowed = "move";
288984
289428
  }
288985
289429
  }
@@ -288995,6 +289439,8 @@ menclose::after {
288995
289439
  if (event.dataTransfer)
288996
289440
  if (kind === "fieldAnnotation")
288997
289441
  event.dataTransfer.dropEffect = isInternalDrag(event) ? "move" : "copy";
289442
+ else if (kind === "internalObject")
289443
+ event.dataTransfer.dropEffect = "move";
288998
289444
  else
288999
289445
  event.dataTransfer.dropEffect = "copy";
289000
289446
  this.#scheduleDragOverSelection(event.clientX, event.clientY);
@@ -289008,6 +289454,7 @@ menclose::after {
289008
289454
  event.preventDefault();
289009
289455
  event.stopPropagation();
289010
289456
  this.#cancelPendingDragOverSelection();
289457
+ this.#deps.clearDragDropIndicator();
289011
289458
  const activeEditor = this.#deps.getActiveEditor();
289012
289459
  if (!activeEditor?.isEditable)
289013
289460
  return;
@@ -289023,6 +289470,14 @@ menclose::after {
289023
289470
  const dropPos = hit?.pos ?? fallbackPos;
289024
289471
  if (dropPos == null)
289025
289472
  return;
289473
+ if (kind === "internalObject") {
289474
+ try {
289475
+ this.#handleInternalObjectDrop(event, dropPos);
289476
+ } finally {
289477
+ this.#activeInternalObjectPayload = null;
289478
+ }
289479
+ return;
289480
+ }
289026
289481
  if (isInternalDrag(event)) {
289027
289482
  this.#handleInternalDrop(event, dropPos);
289028
289483
  return;
@@ -289031,6 +289486,8 @@ menclose::after {
289031
289486
  }
289032
289487
  #handleDragEnd(_event) {
289033
289488
  this.#cancelPendingDragOverSelection();
289489
+ this.#activeInternalObjectPayload = null;
289490
+ this.#deps?.clearDragDropIndicator();
289034
289491
  this.#deps?.getPainterHost()?.classList.remove("drag-over");
289035
289492
  }
289036
289493
  #handleDragLeave(event) {
@@ -289041,6 +289498,7 @@ menclose::after {
289041
289498
  if (relatedTarget && viewportHost.contains(relatedTarget))
289042
289499
  return;
289043
289500
  this.#cancelPendingDragOverSelection();
289501
+ this.#deps?.clearDragDropIndicator();
289044
289502
  this.#deps?.getPainterHost()?.classList.remove("drag-over");
289045
289503
  }
289046
289504
  #scheduleDragOverSelection(clientX, clientY) {
@@ -289076,17 +289534,12 @@ menclose::after {
289076
289534
  return;
289077
289535
  const hit = this.#deps.hitTest(clientX, clientY);
289078
289536
  const doc$12 = activeEditor.state?.doc;
289079
- if (!hit || !doc$12)
289537
+ if (!hit || !doc$12) {
289538
+ this.#deps.clearDragDropIndicator();
289080
289539
  return;
289540
+ }
289081
289541
  const pos = Math.min(Math.max(hit.pos, 1), doc$12.content.size);
289082
- const currentSelection = activeEditor.state.selection;
289083
- if (currentSelection instanceof TextSelection && currentSelection.from === pos && currentSelection.to === pos)
289084
- return;
289085
- try {
289086
- const tr = activeEditor.state.tr.setSelection(TextSelection.create(doc$12, pos)).setMeta("addToHistory", false);
289087
- activeEditor.view?.dispatch(tr);
289088
- this.#deps.scheduleSelectionUpdate();
289089
- } catch {}
289542
+ this.#deps.showDragDropIndicator(pos);
289090
289543
  }
289091
289544
  async#handleImageDrop(event) {
289092
289545
  if (!this.#deps)
@@ -289184,16 +289637,47 @@ menclose::after {
289184
289637
  });
289185
289638
  if (sourceStart === null || sourceEnd === null || !sourceNode)
289186
289639
  return;
289187
- 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)
289188
289651
  return;
289189
- const tr = state.tr;
289190
- tr.delete(sourceStart, sourceEnd);
289191
- const mappedTarget = tr.mapping.map(targetPos);
289192
- if (mappedTarget < 0 || mappedTarget > tr.doc.content.size)
289652
+ view.dispatch(result.transaction);
289653
+ }
289654
+ #handleInternalObjectDrop(event, targetPos) {
289655
+ if (!this.#deps)
289193
289656
  return;
289194
- tr.insert(mappedTarget, sourceNode);
289195
- tr.setMeta("uiEvent", "drop");
289196
- view.dispatch(tr);
289657
+ const { state, view } = this.#deps.getActiveEditor();
289658
+ if (!state || !view)
289659
+ return;
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();
289197
289681
  }
289198
289682
  #handleExternalDrop(event, pos) {
289199
289683
  if (!this.#deps)
@@ -289237,6 +289721,8 @@ menclose::after {
289237
289721
  if (event.dataTransfer)
289238
289722
  if (kind === "fieldAnnotation")
289239
289723
  event.dataTransfer.dropEffect = isInternalDrag(event) ? "move" : "copy";
289724
+ else if (kind === "internalObject")
289725
+ event.dataTransfer.dropEffect = "move";
289240
289726
  else
289241
289727
  event.dataTransfer.dropEffect = "copy";
289242
289728
  }
@@ -289615,11 +290101,11 @@ menclose::after {
289615
290101
  width: currentWidth
289616
290102
  });
289617
290103
  return chunks;
289618
- }, appendSegment = (segments, runIndex, fromChar, toChar, width, x) => {
290104
+ }, appendSegment = (segments, runIndex, fromChar, toChar, width, x, precedingTabEndX) => {
289619
290105
  if (!segments)
289620
290106
  return;
289621
290107
  const last2 = segments[segments.length - 1];
289622
- if (last2 && last2.runIndex === runIndex && last2.toChar === fromChar && x === undefined) {
290108
+ if (last2 && last2.runIndex === runIndex && last2.toChar === fromChar && last2.x === undefined && last2.precedingTabEndX === undefined && x === undefined && precedingTabEndX === undefined) {
289623
290109
  last2.toChar = toChar;
289624
290110
  last2.width += width;
289625
290111
  return;
@@ -289629,7 +290115,8 @@ menclose::after {
289629
290115
  fromChar,
289630
290116
  toChar,
289631
290117
  width,
289632
- x
290118
+ ...x !== undefined ? { x } : {},
290119
+ ...precedingTabEndX !== undefined ? { precedingTabEndX } : {}
289633
290120
  });
289634
290121
  }, resolveLineHeight = (spacing, fontSize, maxHeight = -1) => {
289635
290122
  let computedHeight = spacing?.line ?? WORD_SINGLE_LINE_SPACING_MULTIPLIER;
@@ -289679,10 +290166,17 @@ menclose::after {
289679
290166
  firstLine: pxToTwips(sanitizePositive(indent2?.firstLine)),
289680
290167
  hanging: pxToTwips(sanitizePositive(indent2?.hanging))
289681
290168
  };
290169
+ const rawParagraphIndentTwips = {
290170
+ left: pxToTwips(sanitizeIndent(indent2?.left)),
290171
+ right: pxToTwips(sanitizeIndent(indent2?.right)),
290172
+ firstLine: pxToTwips(sanitizeIndent(indent2?.firstLine)),
290173
+ hanging: pxToTwips(sanitizePositive(indent2?.hanging))
290174
+ };
289682
290175
  return computeTabStops({
289683
290176
  explicitStops: tabs ?? [],
289684
290177
  defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS,
289685
- paragraphIndent: paragraphIndentTwips
290178
+ paragraphIndent: paragraphIndentTwips,
290179
+ rawParagraphIndent: rawParagraphIndentTwips
289686
290180
  }).map((stop) => ({
289687
290181
  pos: twipsToPx(stop.pos),
289688
290182
  val: stop.val,
@@ -291342,14 +291836,32 @@ menclose::after {
291342
291836
  pointer-events: none;
291343
291837
  z-index: 1000;
291344
291838
  }
291345
- `, 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) => {
291346
291858
  return typeof event?.source === "string" && INTERNAL_NOTE_COMMIT_SOURCES.has(event.source);
291347
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) => {
291348
291860
  if (!layoutDebugEnabled)
291349
291861
  return;
291350
291862
  console.log(...args$1);
291351
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;
291352
- var init_src_ItIaPxzW_es = __esm(() => {
291864
+ var init_src_CSHo1aJM_es = __esm(() => {
291353
291865
  init_rolldown_runtime_Bg48TavK_es();
291354
291866
  init_SuperConverter_D1o6_yKI_es();
291355
291867
  init_jszip_C49i9kUs_es();
@@ -317382,6 +317894,7 @@ function print() { __p += __j.call(arguments, '') }
317382
317894
  CANONICAL: "canonical",
317383
317895
  DERIVED: "derived"
317384
317896
  };
317897
+ INLINE_LABEL_SELECTOR = `.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}__label`;
317385
317898
  PROOFING_CSS = {
317386
317899
  SPELLING: "sd-proofing-spelling",
317387
317900
  GRAMMAR: "sd-proofing-grammar",
@@ -319225,7 +319738,7 @@ function print() { __p += __j.call(arguments, '') }
319225
319738
  availableWidthOverride = fragment.width - listFirstLineTextStartPx - Math.max(0, paraIndentRight);
319226
319739
  const isFirstLine = index2 === 0 && !paraContinuesFromPrev;
319227
319740
  const isListFirstLine = Boolean(hasListFirstLineMarker && fragment.markerTextWidth);
319228
- if (isFirstLine && !isListFirstLine && !hasExplicitSegmentPositioning)
319741
+ if (isFirstLine && !isListFirstLine && line.hasExplicitTabStops !== true)
319229
319742
  availableWidthOverride = adjustAvailableWidthForTextIndent(availableWidthOverride, firstLineOffset, line.maxWidth);
319230
319743
  const shouldSkipJustifyForLastLine = index2 === lines.length - 1 && !paraContinuesOnNext && !paragraphEndsWithLineBreak;
319231
319744
  const lineEl = this.renderLine(block, line, context, availableWidthOverride, fragment.fromLine + index2, shouldSkipJustifyForLastLine, expandedRunsForBlock, shouldUseResolvedListTextStart ? listFirstLineTextStartPx : undefined);
@@ -321019,6 +321532,7 @@ function print() { __p += __j.call(arguments, '') }
321019
321532
  el.appendChild(barEl);
321020
321533
  });
321021
321534
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== undefined);
321535
+ const hasMultipleExplicitPositionedSegments = (line.segments?.filter((seg) => seg.x !== undefined).length ?? 0) > 1;
321022
321536
  const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
321023
321537
  const justifyShouldApply = shouldApplyJustify({
321024
321538
  alignment: block.attrs?.alignment,
@@ -321026,7 +321540,7 @@ function print() { __p += __j.call(arguments, '') }
321026
321540
  hasExplicitTabStops: line.hasExplicitTabStops === true,
321027
321541
  isLastLineOfParagraph: false,
321028
321542
  paragraphEndsWithLineBreak: false,
321029
- skipJustifyOverride: skipJustify
321543
+ skipJustifyOverride: skipJustify || hasMultipleExplicitPositionedSegments
321030
321544
  });
321031
321545
  const countSpaces$1 = (text5) => {
321032
321546
  let count = 0;
@@ -321193,12 +321707,14 @@ function print() { __p += __j.call(arguments, '') }
321193
321707
  else
321194
321708
  segmentsByRun.set(segment.runIndex, [segment]);
321195
321709
  });
321196
- const findImmediateNextSegmentX = (fromRunIndex) => {
321710
+ const findImmediateNextSegment = (fromRunIndex) => {
321197
321711
  const nextRunIdx = fromRunIndex + 1;
321198
321712
  if (nextRunIdx <= line.toRun) {
321199
321713
  const nextSegments = segmentsByRun.get(nextRunIdx);
321200
- if (nextSegments && nextSegments.length > 0)
321201
- return nextSegments[0].x;
321714
+ if (nextSegments && nextSegments.length > 0) {
321715
+ const firstSegment = nextSegments[0];
321716
+ return firstSegment.x !== undefined || firstSegment.precedingTabEndX !== undefined ? firstSegment : undefined;
321717
+ }
321202
321718
  }
321203
321719
  };
321204
321720
  let geoSdtWrapper = null;
@@ -321242,9 +321758,10 @@ function print() { __p += __j.call(arguments, '') }
321242
321758
  if (!baseRun)
321243
321759
  continue;
321244
321760
  if (baseRun.kind === "tab") {
321245
- const immediateNextX = findImmediateNextSegmentX(runIndex);
321761
+ const immediateNextSegment = findImmediateNextSegment(runIndex);
321246
321762
  const tabStartX = cumulativeX;
321247
- const tabEndX = immediateNextX !== undefined ? immediateNextX : tabStartX + (baseRun.width ?? 0);
321763
+ const measuredTabEndX = tabStartX + (baseRun.width ?? 0);
321764
+ const tabEndX = immediateNextSegment?.precedingTabEndX ?? immediateNextSegment?.x ?? measuredTabEndX;
321248
321765
  const actualTabWidth = tabEndX - tabStartX;
321249
321766
  const tabEl = this.doc.createElement("span");
321250
321767
  tabEl.style.position = "absolute";
@@ -321354,10 +321871,10 @@ function print() { __p += __j.call(arguments, '') }
321354
321871
  elem.style.position = "absolute";
321355
321872
  elem.style.left = `${xPos}px`;
321356
321873
  appendToLineGeo(elem, segmentRun, xPos, segment.width);
321357
- const width = segment.width;
321358
- cumulativeX = baseX + width;
321874
+ const visualWidth = segment.width + (spacingPerSpace !== 0 ? spacingPerSpace * countSpaces$1(segmentText) : 0);
321875
+ cumulativeX = baseX + visualWidth;
321359
321876
  if (geoSdtWrapper)
321360
- geoSdtMaxRight = Math.max(geoSdtMaxRight, xPos + width);
321877
+ geoSdtMaxRight = Math.max(geoSdtMaxRight, xPos + visualWidth);
321361
321878
  }
321362
321879
  });
321363
321880
  }
@@ -322955,6 +323472,7 @@ function print() { __p += __j.call(arguments, '') }
322955
323472
  #isRerendering = false;
322956
323473
  #selectionSync = new SelectionSyncCoordinator;
322957
323474
  #shouldScrollSelectionIntoView = false;
323475
+ #dragDropIndicatorPos = null;
322958
323476
  #epochMapper = new EpochPositionMapper;
322959
323477
  #layoutEpoch = 0;
322960
323478
  #htmlAnnotationHeights = /* @__PURE__ */ new Map;
@@ -323071,6 +323589,7 @@ function print() { __p += __j.call(arguments, '') }
323071
323589
  this.#postPaintPipeline.setContainer(this.#painterHost);
323072
323590
  ensureEditorNativeSelectionStyles(doc$12);
323073
323591
  ensureEditorFieldAnnotationInteractionStyles(doc$12);
323592
+ ensureEditorMovableObjectInteractionStyles(doc$12);
323074
323593
  this.#painterHost.addEventListener("mouseover", this.#handleStructuredContentBlockMouseEnter);
323075
323594
  this.#painterHost.addEventListener("mouseout", this.#handleStructuredContentBlockMouseLeave);
323076
323595
  this.#domIndexObserverManager = new DomPositionIndexObserverManager({
@@ -325426,12 +325945,30 @@ function print() { __p += __j.call(arguments, '') }
325426
325945
  getActiveEditor: () => this.getActiveEditor(),
325427
325946
  hitTest: (clientX, clientY) => this.hitTest(clientX, clientY),
325428
325947
  scheduleSelectionUpdate: () => this.#scheduleSelectionUpdate(),
325948
+ showDragDropIndicator: (pos) => this.#showDragDropIndicator(pos),
325949
+ clearDragDropIndicator: () => this.#clearDragDropIndicator(),
325429
325950
  getViewportHost: () => this.#viewportHost,
325430
325951
  getPainterHost: () => this.#painterHost,
325431
325952
  insertImageFile: (params$1) => processAndInsertImageFile(params$1)
325432
325953
  });
325433
325954
  this.#dragDropManager.bind();
325434
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
+ }
325435
325972
  #focusEditorAfterImageSelection() {
325436
325973
  this.#shouldScrollSelectionIntoView = true;
325437
325974
  this.#scheduleSelectionUpdate();
@@ -326579,6 +327116,7 @@ function print() { __p += __j.call(arguments, '') }
326579
327116
  return;
326580
327117
  }
326581
327118
  let node2 = null;
327119
+ let pos = null;
326582
327120
  let id2 = null;
326583
327121
  if (selection instanceof NodeSelection) {
326584
327122
  if (selection.node?.type?.name !== "structuredContentBlock") {
@@ -326586,23 +327124,24 @@ function print() { __p += __j.call(arguments, '') }
326586
327124
  return;
326587
327125
  }
326588
327126
  node2 = selection.node;
327127
+ pos = selection.from;
326589
327128
  } else {
326590
- const $pos = selection.$from;
326591
- if (!$pos || typeof $pos.depth !== "number" || typeof $pos.node !== "function") {
327129
+ const editorDoc = this.#editor?.view?.state?.doc;
327130
+ if (!editorDoc) {
326592
327131
  this.#clearSelectedStructuredContentBlockClass();
326593
327132
  return;
326594
327133
  }
326595
- for (let depth = $pos.depth;depth > 0; depth--) {
326596
- const candidate = $pos.node(depth);
326597
- if (candidate.type?.name === "structuredContentBlock") {
326598
- node2 = candidate;
326599
- break;
326600
- }
326601
- }
326602
- if (!node2) {
327134
+ const resolved = findStructuredContentBlockAtPos(editorDoc, selection.from);
327135
+ if (!resolved) {
326603
327136
  this.#clearSelectedStructuredContentBlockClass();
326604
327137
  return;
326605
327138
  }
327139
+ node2 = resolved.node;
327140
+ pos = resolved.pos;
327141
+ }
327142
+ if (pos == null) {
327143
+ this.#clearSelectedStructuredContentBlockClass();
327144
+ return;
326606
327145
  }
326607
327146
  if (!this.#painterHost) {
326608
327147
  this.#clearSelectedStructuredContentBlockClass();
@@ -326614,7 +327153,7 @@ function print() { __p += __j.call(arguments, '') }
326614
327153
  if (id2)
326615
327154
  elements = this.#painterAdapter.getStructuredContentBlockElementsById(id2);
326616
327155
  if (elements.length === 0) {
326617
- 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}`);
326618
327157
  if (container)
326619
327158
  elements = [container];
326620
327159
  }
@@ -326737,27 +327276,18 @@ function print() { __p += __j.call(arguments, '') }
326737
327276
  node2 = selection.node;
326738
327277
  pos = selection.from;
326739
327278
  } else {
326740
- const $pos = selection.$from;
326741
- if (!$pos || typeof $pos.depth !== "number" || typeof $pos.node !== "function") {
327279
+ const editorDoc = this.#editor?.view?.state?.doc;
327280
+ if (!editorDoc) {
326742
327281
  this.#clearSelectedStructuredContentInlineClass();
326743
327282
  return;
326744
327283
  }
326745
- for (let depth = $pos.depth;depth > 0; depth--) {
326746
- const candidate = $pos.node(depth);
326747
- if (candidate.type?.name === "structuredContent") {
326748
- if (typeof $pos.before !== "function") {
326749
- this.#clearSelectedStructuredContentInlineClass();
326750
- return;
326751
- }
326752
- node2 = candidate;
326753
- pos = $pos.before(depth);
326754
- break;
326755
- }
326756
- }
326757
- if (!node2 || pos == null) {
327284
+ const resolved = findStructuredContentInlineAtPos(editorDoc, selection.from);
327285
+ if (!resolved) {
326758
327286
  this.#clearSelectedStructuredContentInlineClass();
326759
327287
  return;
326760
327288
  }
327289
+ node2 = resolved.node;
327290
+ pos = resolved.pos;
326761
327291
  }
326762
327292
  if (!this.#painterHost) {
326763
327293
  this.#clearSelectedStructuredContentInlineClass();
@@ -326811,7 +327341,8 @@ function print() { __p += __j.call(arguments, '') }
326811
327341
  const hasFocus = activeEditor?.view?.hasFocus?.() ?? false;
326812
327342
  const contextMenuOpen = activeEditor?.state ? !!ContextMenuPluginKey.getState(activeEditor.state)?.open : false;
326813
327343
  const isOnEditorUi = !!document.activeElement?.closest?.("[data-editor-ui-surface], .sd-toolbar-dropdown-menu, .toolbar-dropdown-menu");
326814
- if (!hasFocus && !contextMenuOpen && !isOnEditorUi) {
327344
+ const isDragDropIndicatorActive = this.#dragDropIndicatorPos != null;
327345
+ if (!hasFocus && !contextMenuOpen && !isOnEditorUi && !isDragDropIndicatorActive) {
326815
327346
  try {
326816
327347
  this.#clearSelectedFieldAnnotationClass();
326817
327348
  this.#localSelectionLayer.innerHTML = "";
@@ -326851,8 +327382,9 @@ function print() { __p += __j.call(arguments, '') }
326851
327382
  }
326852
327383
  return;
326853
327384
  }
326854
- if (from$1 === to) {
326855
- 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);
326856
327388
  if (!caretLayout)
326857
327389
  return;
326858
327390
  try {
@@ -326866,7 +327398,7 @@ function print() { __p += __j.call(arguments, '') }
326866
327398
  if (process$12.env.NODE_ENV === "development")
326867
327399
  console.warn("[PresentationEditor] Failed to render caret overlay:", error48);
326868
327400
  }
326869
- if (shouldScrollIntoView)
327401
+ if (shouldScrollIntoView && !isDragDropIndicatorActive)
326870
327402
  this.#scrollActiveEndIntoView(caretLayout.pageIndex);
326871
327403
  return;
326872
327404
  }
@@ -328987,7 +329519,7 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
328987
329519
 
328988
329520
  // ../../packages/superdoc/dist/super-editor.es.js
328989
329521
  var init_super_editor_es = __esm(() => {
328990
- init_src_ItIaPxzW_es();
329522
+ init_src_CSHo1aJM_es();
328991
329523
  init_SuperConverter_D1o6_yKI_es();
328992
329524
  init_jszip_C49i9kUs_es();
328993
329525
  init_xml_js_CqGKpaft_es();