@superdoc-dev/cli 0.8.0-next.80 → 0.8.0-next.81

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 +8 -8
package/dist/index.js CHANGED
@@ -207687,7 +207687,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
207687
207687
  init_remark_gfm_BhnWr3yf_es();
207688
207688
  });
207689
207689
 
207690
- // ../../packages/superdoc/dist/chunks/src-C-jV2TZI.es.js
207690
+ // ../../packages/superdoc/dist/chunks/src-CSHo1aJM.es.js
207691
207691
  function deleteProps(obj, propOrProps) {
207692
207692
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
207693
207693
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -248652,6 +248652,49 @@ function resolveAnnotationDisplayLabel(annotation, contentEl) {
248652
248652
  value: derivedLabel
248653
248653
  };
248654
248654
  }
248655
+ function parsePmNumber(value) {
248656
+ return value && value.trim().length > 0 ? value : null;
248657
+ }
248658
+ function collectImageRoots(container) {
248659
+ const roots = [];
248660
+ const seen = /* @__PURE__ */ new Set;
248661
+ const add = (element3) => {
248662
+ if (!element3 || seen.has(element3))
248663
+ return;
248664
+ seen.add(element3);
248665
+ roots.push(element3);
248666
+ };
248667
+ for (const fragment2 of Array.from(container.querySelectorAll(`.${DOM_CLASS_NAMES.IMAGE_FRAGMENT}`))) {
248668
+ if (!fragment2.hasAttribute("data-image-metadata") && fragment2.querySelector?.(`[data-image-metadata]`) == null)
248669
+ continue;
248670
+ add(fragment2);
248671
+ }
248672
+ for (const wrapper of Array.from(container.querySelectorAll(`.${DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER}`))) {
248673
+ if (wrapper.querySelector?.(`[data-image-metadata]`) == null)
248674
+ continue;
248675
+ add(wrapper);
248676
+ }
248677
+ for (const inlineImage of Array.from(container.querySelectorAll(`.${DOM_CLASS_NAMES.INLINE_IMAGE}`)))
248678
+ if (inlineImage.hasAttribute("data-image-metadata") && inlineImage.closest(`.${DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER}`) == null)
248679
+ add(inlineImage);
248680
+ return roots;
248681
+ }
248682
+ function resolveImageLabel(root3) {
248683
+ const directLabel = root3.dataset[DATASET_KEYS.DISPLAY_LABEL];
248684
+ if (directLabel)
248685
+ return directLabel;
248686
+ const img2 = root3.tagName === "IMG" ? root3 : root3.querySelector("img");
248687
+ const alt = img2?.getAttribute("alt")?.trim();
248688
+ if (alt)
248689
+ return alt;
248690
+ const title = img2?.getAttribute("title")?.trim();
248691
+ if (title)
248692
+ return title;
248693
+ return root3.getAttribute("data-block-id") ?? root3.getAttribute("data-sd-block-id") ?? "Image";
248694
+ }
248695
+ function resolveImageKind(root3) {
248696
+ return root3.classList.contains(DOM_CLASS_NAMES.IMAGE_FRAGMENT) ? "block" : "inline";
248697
+ }
248655
248698
  function cssClassForKind(kind) {
248656
248699
  switch (kind) {
248657
248700
  case "spelling":
@@ -260047,6 +260090,97 @@ function findNearestTextblockResolvedPos(doc$12, pos) {
260047
260090
  return null;
260048
260091
  return textblockPos;
260049
260092
  }
260093
+ function matchesStructuredContentId(node3, id2) {
260094
+ if (!id2)
260095
+ return false;
260096
+ const attrs = node3.attrs;
260097
+ const nodeId = attrs?.id;
260098
+ const nodeSdtId = attrs?.sdtId;
260099
+ return nodeId != null && String(nodeId) === id2 || nodeSdtId != null && String(nodeSdtId) === id2;
260100
+ }
260101
+ function resolvePosSafely(doc$12, pos) {
260102
+ if (!Number.isInteger(pos))
260103
+ return null;
260104
+ try {
260105
+ return doc$12.resolve(pos);
260106
+ } catch {
260107
+ return null;
260108
+ }
260109
+ }
260110
+ function findStructuredContentBlockAtPos(doc$12, pos) {
260111
+ if (!Number.isFinite(pos))
260112
+ return null;
260113
+ const $pos = resolvePosSafely(doc$12, pos);
260114
+ if (!$pos)
260115
+ return null;
260116
+ for (let depth = $pos.depth;depth > 0; depth--) {
260117
+ const node3 = $pos.node(depth);
260118
+ if (node3.type?.name === "structuredContentBlock")
260119
+ return {
260120
+ node: node3,
260121
+ pos: $pos.before(depth),
260122
+ start: $pos.start(depth),
260123
+ end: $pos.end(depth)
260124
+ };
260125
+ }
260126
+ return null;
260127
+ }
260128
+ function findStructuredContentBlockById(doc$12, id2) {
260129
+ if (!id2)
260130
+ return null;
260131
+ let found2 = null;
260132
+ doc$12.descendants((node3, pos) => {
260133
+ if (node3.type?.name !== "structuredContentBlock")
260134
+ return true;
260135
+ if (!matchesStructuredContentId(node3, id2))
260136
+ return true;
260137
+ found2 = {
260138
+ node: node3,
260139
+ pos,
260140
+ start: pos + 1,
260141
+ end: pos + node3.nodeSize - 1
260142
+ };
260143
+ return false;
260144
+ });
260145
+ return found2;
260146
+ }
260147
+ function findStructuredContentInlineAtPos(doc$12, pos) {
260148
+ if (!Number.isFinite(pos))
260149
+ return null;
260150
+ const $pos = resolvePosSafely(doc$12, pos);
260151
+ if (!$pos)
260152
+ return null;
260153
+ for (let depth = $pos.depth;depth > 0; depth--) {
260154
+ const node3 = $pos.node(depth);
260155
+ if (node3.type?.name === "structuredContent")
260156
+ return {
260157
+ node: node3,
260158
+ pos: $pos.before(depth),
260159
+ start: $pos.start(depth),
260160
+ end: $pos.end(depth)
260161
+ };
260162
+ }
260163
+ return null;
260164
+ }
260165
+ function findStructuredContentInlineById(doc$12, id2) {
260166
+ if (!id2)
260167
+ return null;
260168
+ let found2 = null;
260169
+ doc$12.descendants((node3, pos) => {
260170
+ if (node3.type?.name !== "structuredContent")
260171
+ return true;
260172
+ if (!matchesStructuredContentId(node3, id2))
260173
+ return true;
260174
+ found2 = {
260175
+ node: node3,
260176
+ pos,
260177
+ start: pos + 1,
260178
+ end: pos + node3.nodeSize - 1
260179
+ };
260180
+ return false;
260181
+ });
260182
+ return found2;
260183
+ }
260050
260184
  function getSelectionDebugConfig() {
260051
260185
  if (typeof window === "undefined")
260052
260186
  return DEFAULT_CONFIG;
@@ -261138,7 +261272,7 @@ function createLayoutMetrics(perf, startMark, layout, blocks2) {
261138
261272
  };
261139
261273
  }
261140
261274
  function coerceNumber(value) {
261141
- if (isFiniteNumber(value))
261275
+ if (isFiniteNumber$1(value))
261142
261276
  return Number(value);
261143
261277
  if (typeof value === "string" && value.trim() !== "") {
261144
261278
  const parsed = Number(value);
@@ -261146,7 +261280,7 @@ function coerceNumber(value) {
261146
261280
  }
261147
261281
  }
261148
261282
  function coercePositiveNumber(value, fallback) {
261149
- if (!isFiniteNumber(fallback) || fallback <= 0)
261283
+ if (!isFiniteNumber$1(fallback) || fallback <= 0)
261150
261284
  throw new Error(`coercePositiveNumber: fallback must be a positive number, got ${fallback}`);
261151
261285
  const numeric = coerceNumber(value);
261152
261286
  if (numeric != null && numeric > 0)
@@ -261192,7 +261326,7 @@ function toBoxSpacing(spacing) {
261192
261326
  "left"
261193
261327
  ].forEach((side) => {
261194
261328
  const value = spacing[side];
261195
- if (isFiniteNumber(value))
261329
+ if (isFiniteNumber$1(value))
261196
261330
  result[side] = Number(value);
261197
261331
  });
261198
261332
  return Object.keys(result).length > 0 ? result : undefined;
@@ -261226,7 +261360,7 @@ function isShapeGroupTransform(value) {
261226
261360
  if (!value || typeof value !== "object")
261227
261361
  return false;
261228
261362
  const maybe = value;
261229
- 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);
261363
+ 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);
261230
261364
  }
261231
261365
  function normalizeShapeSize(value) {
261232
261366
  if (!value || typeof value !== "object")
@@ -261632,7 +261766,7 @@ function convertBorderSpec(ooxmlBorder, options) {
261632
261766
  style: "none",
261633
261767
  width: 0
261634
261768
  };
261635
- if (!isFiniteNumber(sizeNumber))
261769
+ if (!isFiniteNumber$1(sizeNumber))
261636
261770
  return;
261637
261771
  const numericSize = sizeNumber;
261638
261772
  if (numericSize <= 0)
@@ -261659,7 +261793,7 @@ function convertTableBorderValue(ooxmlBorder, options) {
261659
261793
  const { val, size: size$1, color: color2 } = border;
261660
261794
  if (val === "nil" || val === "none" || size$1 === 0)
261661
261795
  return { none: true };
261662
- if (!isFiniteNumber(size$1))
261796
+ if (!isFiniteNumber$1(size$1))
261663
261797
  return;
261664
261798
  const numericSize = size$1;
261665
261799
  if (numericSize <= 0)
@@ -263232,7 +263366,7 @@ function toBoxSpacing$1(spacing) {
263232
263366
  "left"
263233
263367
  ].forEach((side) => {
263234
263368
  const value = spacing[side];
263235
- if (isFiniteNumber(value))
263369
+ if (isFiniteNumber$1(value))
263236
263370
  result[side] = Number(value);
263237
263371
  });
263238
263372
  return Object.keys(result).length > 0 ? result : undefined;
@@ -266169,6 +266303,143 @@ async function goToAnchor({ anchor, layout, blocks: blocks2, measures, bookmarks
266169
266303
  console.warn("[PresentationEditor] goToAnchor: Navigation succeeded but could not move caret (editor commands unavailable)");
266170
266304
  return true;
266171
266305
  }
266306
+ function isFiniteNumber(value) {
266307
+ return typeof value === "number" && Number.isFinite(value);
266308
+ }
266309
+ function readString(value) {
266310
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
266311
+ }
266312
+ function readNumber(value) {
266313
+ if (isFiniteNumber(value))
266314
+ return value;
266315
+ if (typeof value === "string" && value.trim().length > 0) {
266316
+ const parsed = Number(value);
266317
+ return Number.isFinite(parsed) ? parsed : null;
266318
+ }
266319
+ return null;
266320
+ }
266321
+ function buildStructuredContentDragPayload(sourceElement) {
266322
+ const dataset = sourceElement.dataset;
266323
+ const sdtId = readString(dataset.sdtId);
266324
+ const sourceStart = readNumber(dataset.pmStart);
266325
+ const sourceEnd = readNumber(dataset.pmEnd);
266326
+ if (!sdtId || sourceStart == null || sourceEnd == null)
266327
+ return null;
266328
+ return {
266329
+ kind: "structuredContent",
266330
+ nodeType: dataset.nodeType === "structuredContentBlock" ? "structuredContentBlock" : "structuredContent",
266331
+ sdtId,
266332
+ label: readString(dataset.displayLabel) ?? sourceElement.textContent?.trim() ?? "Structured content",
266333
+ sourceStart,
266334
+ sourceEnd,
266335
+ lockMode: readString(dataset.lockMode) ?? "unlocked"
266336
+ };
266337
+ }
266338
+ function buildExistingImageDragPayload(sourceElement) {
266339
+ const dataset = sourceElement.dataset;
266340
+ const sourceStart = readNumber(dataset.pmStart);
266341
+ const sourceEnd = readNumber(dataset.pmEnd);
266342
+ if (sourceStart == null || sourceEnd == null)
266343
+ return null;
266344
+ return {
266345
+ kind: "existingImage",
266346
+ imageKind: dataset.imageKind === "block" ? "block" : "inline",
266347
+ nodeType: dataset.nodeType ?? "image",
266348
+ sourceStart,
266349
+ sourceEnd,
266350
+ blockId: readString(dataset.blockId) ?? readString(sourceElement.getAttribute("data-block-id")) ?? readString(sourceElement.getAttribute("data-sd-block-id")) ?? undefined,
266351
+ label: readString(dataset.displayLabel) ?? sourceElement.getAttribute("aria-label") ?? "Image"
266352
+ };
266353
+ }
266354
+ function buildInternalObjectDragPayload(sourceElement) {
266355
+ const sourceKind = sourceElement.dataset.dragSourceKind;
266356
+ if (sourceKind === "structuredContent")
266357
+ return buildStructuredContentDragPayload(sourceElement);
266358
+ if (sourceKind === "existingImage")
266359
+ return buildExistingImageDragPayload(sourceElement);
266360
+ return null;
266361
+ }
266362
+ function canInsertNodeAtPosition(doc$12, pos, node3) {
266363
+ try {
266364
+ const resolvedPos = doc$12.resolve(pos);
266365
+ const { parent } = resolvedPos;
266366
+ const index2 = resolvedPos.index();
266367
+ if (typeof parent.canReplaceWith === "function")
266368
+ return parent.canReplaceWith(index2, index2, node3.type);
266369
+ return Boolean(parent.type.contentMatch.matchType(node3.type));
266370
+ } catch {
266371
+ return false;
266372
+ }
266373
+ }
266374
+ function resolveInsertionBoundary(doc$12, pos, node3, canInsertAt, bias) {
266375
+ try {
266376
+ const resolvedPos = doc$12.resolve(pos);
266377
+ const candidates = [];
266378
+ for (let depth = resolvedPos.depth;depth > 0; depth--) {
266379
+ const before2 = resolvedPos.before(depth);
266380
+ const after2 = resolvedPos.after(depth);
266381
+ if (bias === "before")
266382
+ candidates.push(before2, after2);
266383
+ else
266384
+ candidates.push(after2, before2);
266385
+ }
266386
+ for (const candidate of candidates) {
266387
+ if (candidate < 0 || candidate > doc$12.content.size)
266388
+ continue;
266389
+ if (candidate === pos)
266390
+ continue;
266391
+ if (canInsertAt(doc$12, candidate, node3))
266392
+ return candidate;
266393
+ }
266394
+ } catch {
266395
+ return null;
266396
+ }
266397
+ return null;
266398
+ }
266399
+ function createInternalNodeMoveTransaction(state, request) {
266400
+ const { sourceStart, sourceEnd, targetPos, expectedNodeType, canInsertAt } = request;
266401
+ if (targetPos >= sourceStart && targetPos <= sourceEnd)
266402
+ return {
266403
+ ok: false,
266404
+ reason: "same-range"
266405
+ };
266406
+ const sourceNode = state.doc.nodeAt(sourceStart);
266407
+ if (!sourceNode || sourceEnd !== sourceStart + sourceNode.nodeSize)
266408
+ return {
266409
+ ok: false,
266410
+ reason: "invalid-source"
266411
+ };
266412
+ if (expectedNodeType && sourceNode.type.name !== expectedNodeType)
266413
+ return {
266414
+ ok: false,
266415
+ reason: "wrong-node-type"
266416
+ };
266417
+ const tr = state.tr;
266418
+ tr.delete(sourceStart, sourceEnd);
266419
+ const mappedTarget = tr.mapping.map(targetPos);
266420
+ if (mappedTarget < 0 || mappedTarget > tr.doc.content.size)
266421
+ return {
266422
+ ok: false,
266423
+ reason: "invalid-target"
266424
+ };
266425
+ let insertTarget = mappedTarget;
266426
+ if (!canInsertAt(tr.doc, insertTarget, sourceNode)) {
266427
+ const boundaryTarget = resolveInsertionBoundary(tr.doc, insertTarget, sourceNode, canInsertAt, targetPos <= sourceStart ? "before" : "after");
266428
+ if (boundaryTarget == null)
266429
+ return {
266430
+ ok: false,
266431
+ reason: "invalid-target"
266432
+ };
266433
+ insertTarget = boundaryTarget;
266434
+ }
266435
+ tr.insert(insertTarget, sourceNode);
266436
+ tr.setMeta("uiEvent", "drop");
266437
+ return {
266438
+ ok: true,
266439
+ transaction: tr,
266440
+ mappedTarget: insertTarget
266441
+ };
266442
+ }
266172
266443
  function isValidFieldAnnotationAttributes(attrs) {
266173
266444
  if (!attrs || typeof attrs !== "object")
266174
266445
  return false;
@@ -266210,6 +266481,11 @@ function hasFieldAnnotationData(event) {
266210
266481
  function isInternalDrag(event) {
266211
266482
  return event.dataTransfer?.types?.includes(INTERNAL_MIME_TYPE) ?? false;
266212
266483
  }
266484
+ function hasInternalObjectType(event) {
266485
+ if (!event.dataTransfer)
266486
+ return false;
266487
+ return Array.from(event.dataTransfer.types ?? []).map((type) => type.toLowerCase()).includes(INTERNAL_OBJECT_MIME_TYPE.toLowerCase());
266488
+ }
266213
266489
  function extractDragData(event) {
266214
266490
  if (!event.dataTransfer)
266215
266491
  return null;
@@ -266225,6 +266501,23 @@ function extractDragData(event) {
266225
266501
  return null;
266226
266502
  }
266227
266503
  }
266504
+ function resolveDragSourceElement(event) {
266505
+ return event.target?.closest?.("[data-drag-source-kind]");
266506
+ }
266507
+ function resolveInternalObjectSourceRange(doc$12, payload) {
266508
+ if (payload.kind === "structuredContent") {
266509
+ const resolved = payload.nodeType === "structuredContentBlock" ? findStructuredContentBlockById(doc$12, payload.sdtId) : findStructuredContentInlineById(doc$12, payload.sdtId);
266510
+ if (resolved)
266511
+ return {
266512
+ sourceStart: resolved.pos,
266513
+ sourceEnd: resolved.pos + resolved.node.nodeSize
266514
+ };
266515
+ }
266516
+ return {
266517
+ sourceStart: payload.sourceStart,
266518
+ sourceEnd: payload.sourceEnd
266519
+ };
266520
+ }
266228
266521
  function hasPossibleFiles(event) {
266229
266522
  return event.dataTransfer?.types?.includes("Files") ?? false;
266230
266523
  }
@@ -266251,6 +266544,8 @@ function getDroppedImageFiles(event) {
266251
266544
  function getDropPayloadKind(event) {
266252
266545
  if (hasFieldAnnotationData(event))
266253
266546
  return "fieldAnnotation";
266547
+ if (hasInternalObjectType(event))
266548
+ return "internalObject";
266254
266549
  if (hasPossibleFiles(event))
266255
266550
  return "imageFiles";
266256
266551
  return "none";
@@ -270246,6 +270541,15 @@ function ensureEditorFieldAnnotationInteractionStyles(doc$12) {
270246
270541
  doc$12.head?.appendChild(styleEl);
270247
270542
  fieldAnnotationInteractionStylesInjected = true;
270248
270543
  }
270544
+ function ensureEditorMovableObjectInteractionStyles(doc$12) {
270545
+ if (movableObjectInteractionStylesInjected || !doc$12)
270546
+ return;
270547
+ const styleEl = doc$12.createElement("style");
270548
+ styleEl.setAttribute("data-superdoc-editor-movable-object-interaction-styles", "true");
270549
+ styleEl.textContent = MOVABLE_OBJECT_INTERACTION_STYLES;
270550
+ doc$12.head?.appendChild(styleEl);
270551
+ movableObjectInteractionStylesInjected = true;
270552
+ }
270249
270553
  function parseRenderedNoteTarget(blockId) {
270250
270554
  if (typeof blockId !== "string" || blockId.length === 0)
270251
270555
  return null;
@@ -285092,7 +285396,7 @@ var Node$13 = class Node$14 {
285092
285396
  }
285093
285397
  this.#applied.delete(el);
285094
285398
  }
285095
- }, INTERACTION_EPOCH_KEY = "interactionEpoch", DISPLAY_LABEL_SOURCE_KEY = "displayLabelSource", DISPLAY_LABEL_SOURCE, FieldAnnotationInteractionLayer = class {
285399
+ }, INTERACTION_EPOCH_KEY$2 = "interactionEpoch", DISPLAY_LABEL_SOURCE_KEY = "displayLabelSource", DISPLAY_LABEL_SOURCE, FieldAnnotationInteractionLayer = class {
285096
285400
  #container = null;
285097
285401
  setContainer(container) {
285098
285402
  this.#container = container;
@@ -285104,9 +285408,9 @@ var Node$13 = class Node$14 {
285104
285408
  const annotations = this.#container.querySelectorAll(buildAnnotationSelector());
285105
285409
  for (let index2 = 0;index2 < annotations.length; index2 += 1) {
285106
285410
  const annotation = annotations[index2];
285107
- if (annotation.dataset[INTERACTION_EPOCH_KEY] === epochStr)
285411
+ if (annotation.dataset[INTERACTION_EPOCH_KEY$2] === epochStr)
285108
285412
  continue;
285109
- annotation.dataset[INTERACTION_EPOCH_KEY] = epochStr;
285413
+ annotation.dataset[INTERACTION_EPOCH_KEY$2] = epochStr;
285110
285414
  annotation.draggable = true;
285111
285415
  annotation.dataset[DATASET_KEYS.DRAGGABLE] = "true";
285112
285416
  const displayLabel = resolveAnnotationDisplayLabel(annotation, annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CONTENT}`));
@@ -285130,7 +285434,7 @@ var Node$13 = class Node$14 {
285130
285434
  delete annotation.dataset[DATASET_KEYS.DRAGGABLE];
285131
285435
  delete annotation.dataset[DATASET_KEYS.DISPLAY_LABEL];
285132
285436
  delete annotation.dataset[DATASET_KEYS.VARIANT];
285133
- delete annotation.dataset[INTERACTION_EPOCH_KEY];
285437
+ delete annotation.dataset[INTERACTION_EPOCH_KEY$2];
285134
285438
  delete annotation.dataset[DISPLAY_LABEL_SOURCE_KEY];
285135
285439
  annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CARET_ANCHOR}`)?.remove();
285136
285440
  }
@@ -285164,6 +285468,95 @@ var Node$13 = class Node$14 {
285164
285468
  annotation.style.position = "relative";
285165
285469
  annotation.appendChild(caretAnchor);
285166
285470
  }
285471
+ }, INTERACTION_EPOCH_KEY$1 = "imageInteractionEpoch", ImageInteractionLayer = class {
285472
+ #container = null;
285473
+ setContainer(container) {
285474
+ this.#container = container;
285475
+ }
285476
+ apply(layoutEpoch) {
285477
+ if (!this.#container)
285478
+ return;
285479
+ const epochStr = String(layoutEpoch);
285480
+ for (const root3 of collectImageRoots(this.#container)) {
285481
+ if (root3.dataset[INTERACTION_EPOCH_KEY$1] === epochStr)
285482
+ continue;
285483
+ const pmStart = parsePmNumber(root3.dataset.pmStart);
285484
+ const pmEnd = parsePmNumber(root3.dataset.pmEnd);
285485
+ if (!pmStart || !pmEnd)
285486
+ continue;
285487
+ root3.dataset[INTERACTION_EPOCH_KEY$1] = epochStr;
285488
+ root3.draggable = true;
285489
+ root3.dataset.dragSourceKind = "existingImage";
285490
+ root3.dataset.imageKind = resolveImageKind(root3);
285491
+ root3.dataset.nodeType = "image";
285492
+ root3.dataset.displayLabel = resolveImageLabel(root3);
285493
+ root3.dataset.pmStart = pmStart;
285494
+ root3.dataset.pmEnd = pmEnd;
285495
+ }
285496
+ }
285497
+ clear() {
285498
+ if (!this.#container)
285499
+ return;
285500
+ for (const root3 of collectImageRoots(this.#container)) {
285501
+ root3.removeAttribute("draggable");
285502
+ delete root3.dataset.dragSourceKind;
285503
+ delete root3.dataset.imageKind;
285504
+ delete root3.dataset.nodeType;
285505
+ delete root3.dataset.displayLabel;
285506
+ delete root3.dataset[INTERACTION_EPOCH_KEY$1];
285507
+ }
285508
+ }
285509
+ }, BLOCK_LABEL_SELECTOR = ".superdoc-structured-content__label", INLINE_LABEL_SELECTOR, INTERACTION_EPOCH_KEY = "structuredContentInteractionEpoch", StructuredContentInteractionLayer = class {
285510
+ #container = null;
285511
+ setContainer(container) {
285512
+ this.#container = container;
285513
+ }
285514
+ apply(layoutEpoch) {
285515
+ if (!this.#container)
285516
+ return;
285517
+ const labels = Array.from(this.#container.querySelectorAll(`${BLOCK_LABEL_SELECTOR}, ${INLINE_LABEL_SELECTOR}`));
285518
+ for (const label of labels) {
285519
+ if (label.dataset[INTERACTION_EPOCH_KEY] === String(layoutEpoch))
285520
+ continue;
285521
+ const sdtElement = label.closest(`.${DOM_CLASS_NAMES.BLOCK_SDT}, .${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}`);
285522
+ if (!sdtElement?.dataset.sdtId || !sdtElement.dataset.pmStart || !sdtElement.dataset.pmEnd)
285523
+ continue;
285524
+ const lockMode = sdtElement.dataset.lockMode ?? "unlocked";
285525
+ if (lockMode !== "unlocked") {
285526
+ label.draggable = false;
285527
+ continue;
285528
+ }
285529
+ const scope = sdtElement.dataset.sdtScope ?? (sdtElement.classList.contains(DOM_CLASS_NAMES.BLOCK_SDT) ? "block" : "inline");
285530
+ const labelText = label.textContent?.trim() || "Structured content";
285531
+ label.dataset[INTERACTION_EPOCH_KEY] = String(layoutEpoch);
285532
+ label.draggable = true;
285533
+ label.dataset.dragSourceKind = "structuredContent";
285534
+ label.dataset.sdtId = sdtElement.dataset.sdtId;
285535
+ label.dataset.pmStart = sdtElement.dataset.pmStart;
285536
+ label.dataset.pmEnd = sdtElement.dataset.pmEnd;
285537
+ label.dataset.sdtScope = scope;
285538
+ label.dataset.lockMode = lockMode;
285539
+ label.dataset[DATASET_KEYS.DISPLAY_LABEL] = labelText;
285540
+ label.dataset.nodeType = scope === "block" ? "structuredContentBlock" : "structuredContent";
285541
+ }
285542
+ }
285543
+ clear() {
285544
+ if (!this.#container)
285545
+ return;
285546
+ const labels = Array.from(this.#container.querySelectorAll(`${BLOCK_LABEL_SELECTOR}, ${INLINE_LABEL_SELECTOR}`));
285547
+ for (const label of labels) {
285548
+ label.removeAttribute("draggable");
285549
+ delete label.dataset.dragSourceKind;
285550
+ delete label.dataset.sdtId;
285551
+ delete label.dataset.pmStart;
285552
+ delete label.dataset.pmEnd;
285553
+ delete label.dataset.sdtScope;
285554
+ delete label.dataset.lockMode;
285555
+ delete label.dataset.nodeType;
285556
+ delete label.dataset[DATASET_KEYS.DISPLAY_LABEL];
285557
+ delete label.dataset[INTERACTION_EPOCH_KEY];
285558
+ }
285559
+ }
285167
285560
  }, PROOFING_CSS, splitOriginMap, PresentationProofingDecorator = class {
285168
285561
  #container = null;
285169
285562
  setContainer(container) {
@@ -285185,17 +285578,23 @@ var Node$13 = class Node$14 {
285185
285578
  }
285186
285579
  }, PresentationPostPaintPipeline = class {
285187
285580
  #fieldAnnotationLayer;
285581
+ #imageLayer;
285582
+ #structuredContentLayer;
285188
285583
  #commentHighlightDecorator;
285189
285584
  #decorationBridge;
285190
285585
  #proofingDecorator;
285191
285586
  constructor(deps = {}) {
285192
285587
  this.#fieldAnnotationLayer = deps.fieldAnnotationLayer ?? new FieldAnnotationInteractionLayer;
285588
+ this.#imageLayer = deps.imageLayer ?? new ImageInteractionLayer;
285589
+ this.#structuredContentLayer = deps.structuredContentLayer ?? new StructuredContentInteractionLayer;
285193
285590
  this.#commentHighlightDecorator = deps.commentHighlightDecorator ?? new CommentHighlightDecorator;
285194
285591
  this.#decorationBridge = deps.decorationBridge ?? new DecorationBridge;
285195
285592
  this.#proofingDecorator = deps.proofingDecorator ?? new PresentationProofingDecorator;
285196
285593
  }
285197
285594
  setContainer(container) {
285198
285595
  this.#fieldAnnotationLayer.setContainer(container);
285596
+ this.#imageLayer.setContainer(container);
285597
+ this.#structuredContentLayer.setContainer(container);
285199
285598
  this.#commentHighlightDecorator.setContainer(container);
285200
285599
  this.#proofingDecorator.setContainer(container);
285201
285600
  }
@@ -285235,6 +285634,8 @@ var Node$13 = class Node$14 {
285235
285634
  refreshAfterPaint(options) {
285236
285635
  this.#fieldAnnotationLayer.apply(options.layoutEpoch);
285237
285636
  options.rebuildDomPositionIndex();
285637
+ this.#imageLayer.apply(options.layoutEpoch);
285638
+ this.#structuredContentLayer.apply(options.layoutEpoch);
285238
285639
  this.syncInlineStyleLayers(options.editorState, options.domPositionIndex);
285239
285640
  this.applyProofingAnnotations(options.proofingAnnotations, options.rebuildDomPositionIndex);
285240
285641
  options.reapplyStructuredContentHover?.();
@@ -285242,6 +285643,8 @@ var Node$13 = class Node$14 {
285242
285643
  destroy() {
285243
285644
  this.#proofingDecorator.clear();
285244
285645
  this.#fieldAnnotationLayer.clear();
285646
+ this.#imageLayer.clear();
285647
+ this.#structuredContentLayer.clear();
285245
285648
  this.#commentHighlightDecorator.destroy();
285246
285649
  this.#decorationBridge.destroy();
285247
285650
  }
@@ -287703,6 +288106,10 @@ menclose::after {
287703
288106
  container.classList.add(CLASS_NAMES$1.fragment);
287704
288107
  applyStyles$2(container, fragmentStyles);
287705
288108
  applyFragmentFrame(container, fragment2);
288109
+ if (fragment2.pmStart != null)
288110
+ container.dataset.pmStart = String(fragment2.pmStart);
288111
+ if (fragment2.pmEnd != null)
288112
+ container.dataset.pmEnd = String(fragment2.pmEnd);
287706
288113
  container.style.height = `${fragment2.height}px`;
287707
288114
  applySdtDataset(container, block.attrs?.sdt);
287708
288115
  applyContainerSdtDataset?.(container, block.attrs?.containerSdt);
@@ -292646,12 +293053,12 @@ menclose::after {
292646
293053
  if (pt == null || !Number.isFinite(pt))
292647
293054
  return;
292648
293055
  return pt * PX_PER_PT2;
292649
- }, isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
293056
+ }, isFiniteNumber$1 = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
292650
293057
  if (!value)
292651
293058
  return "";
292652
293059
  return String(value);
292653
293060
  }, pickNumber = (value) => {
292654
- if (isFiniteNumber(value))
293061
+ if (isFiniteNumber$1(value))
292655
293062
  return value;
292656
293063
  if (typeof value === "string") {
292657
293064
  const parsed = parseFloat(value);
@@ -292849,7 +293256,7 @@ menclose::after {
292849
293256
  };
292850
293257
  }
292851
293258
  }, MIN_BORDER_SIZE_PX2 = 0.5, MAX_BORDER_SIZE_PX2 = 100, borderSizeToPx = (size$1) => {
292852
- if (!isFiniteNumber(size$1))
293259
+ if (!isFiniteNumber$1(size$1))
292853
293260
  return;
292854
293261
  if (size$1 <= 0)
292855
293262
  return 0;
@@ -293142,7 +293549,7 @@ menclose::after {
293142
293549
  const toNum = (v) => {
293143
293550
  if (typeof v === "string" && v.trim() !== "" && isFinite(Number(v)))
293144
293551
  return Number(v);
293145
- if (isFiniteNumber(v))
293552
+ if (isFiniteNumber$1(v))
293146
293553
  return Number(v);
293147
293554
  };
293148
293555
  const left$1 = toNum(indent2.left);
@@ -293750,7 +294157,7 @@ menclose::after {
293750
294157
  return;
293751
294158
  return sanitized;
293752
294159
  }, normalizeLengthPx = (value) => {
293753
- if (isFiniteNumber(value))
294160
+ if (isFiniteNumber$1(value))
293754
294161
  return value;
293755
294162
  if (typeof value !== "string")
293756
294163
  return;
@@ -295263,7 +295670,7 @@ menclose::after {
295263
295670
  this.#onCursorsUpdate = null;
295264
295671
  this.#isSetup = false;
295265
295672
  }
295266
- }, 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 {
295673
+ }, 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 {
295267
295674
  #deps = null;
295268
295675
  #callbacks = {};
295269
295676
  #isDragging = false;
@@ -295825,7 +296232,9 @@ menclose::after {
295825
296232
  }
295826
296233
  const annotationEl = target?.closest?.(buildAnnotationSelector());
295827
296234
  const isDraggableAnnotation = target?.closest?.(DRAGGABLE_SELECTOR) != null;
295828
- this.#suppressFocusInFromDraggable = isDraggableAnnotation;
296235
+ const isNativeDragSource = target?.closest?.(DRAG_SOURCE_SELECTOR) != null;
296236
+ const suppressFocusForDrag = isDraggableAnnotation || isNativeDragSource;
296237
+ this.#suppressFocusInFromDraggable = suppressFocusForDrag;
295829
296238
  if (annotationEl) {
295830
296239
  this.#handleAnnotationClick(event, annotationEl);
295831
296240
  return;
@@ -295838,7 +296247,7 @@ menclose::after {
295838
296247
  const activeNoteTarget = this.#getActiveRenderedNoteTarget();
295839
296248
  if (!layoutState.layout) {
295840
296249
  if (clickedNoteTarget && !isSameRenderedNoteTarget(activeNoteTarget, clickedNoteTarget)) {
295841
- if (!isDraggableAnnotation)
296250
+ if (!suppressFocusForDrag)
295842
296251
  event.preventDefault();
295843
296252
  if (this.#callbacks.activateRenderedNoteSession?.(clickedNoteTarget, {
295844
296253
  clientX: event.clientX,
@@ -295859,7 +296268,7 @@ menclose::after {
295859
296268
  return;
295860
296269
  } else
295861
296270
  this.#syncNonBodyCommentActivation(event, target, bodyEditor);
295862
- this.#handleClickWithoutLayout(event, isDraggableAnnotation);
296271
+ this.#handleClickWithoutLayout(event, suppressFocusForDrag);
295863
296272
  return;
295864
296273
  }
295865
296274
  const normalizedPoint = this.#callbacks.normalizeClientPoint?.(event.clientX, event.clientY);
@@ -295874,7 +296283,7 @@ menclose::after {
295874
296283
  };
295875
296284
  if (clickedNoteTarget) {
295876
296285
  if (!isSameRenderedNoteTarget(activeNoteTarget, clickedNoteTarget)) {
295877
- if (!isDraggableAnnotation)
296286
+ if (!suppressFocusForDrag)
295878
296287
  event.preventDefault();
295879
296288
  if (this.#callbacks.activateRenderedNoteSession?.(clickedNoteTarget, {
295880
296289
  clientX: event.clientX,
@@ -295950,7 +296359,7 @@ menclose::after {
295950
296359
  mappedPos: null
295951
296360
  };
295952
296361
  this.#callbacks.updateSelectionDebugHud?.();
295953
- if (!isDraggableAnnotation)
296362
+ if (!suppressFocusForDrag)
295954
296363
  event.preventDefault();
295955
296364
  const inlineStructuredContentLabel = target?.closest?.(".superdoc-structured-content-inline__label");
295956
296365
  if (inlineStructuredContentLabel && doc$12) {
@@ -296068,7 +296477,7 @@ menclose::after {
296068
296477
  this.#focusEditor();
296069
296478
  if (!handledByDepth)
296070
296479
  try {
296071
- const sdtBlock = clickDepth === 1 ? this.#findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
296480
+ const sdtBlock = clickDepth === 1 ? findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
296072
296481
  let nextSelection;
296073
296482
  let inlineSdtBoundaryPos = null;
296074
296483
  let inlineSdtBoundaryDirection = null;
@@ -296076,7 +296485,7 @@ menclose::after {
296076
296485
  if (sdtBlock && !insideTableInSdt)
296077
296486
  nextSelection = NodeSelection.create(doc$12, sdtBlock.pos);
296078
296487
  else {
296079
- const inlineSdt = clickDepth === 1 ? this.#findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
296488
+ const inlineSdt = clickDepth === 1 ? findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
296080
296489
  if (inlineSdt && hit.pos >= inlineSdt.end) {
296081
296490
  const afterInlineSdt = inlineSdt.pos + inlineSdt.node.nodeSize;
296082
296491
  inlineSdtBoundaryPos = afterInlineSdt;
@@ -296337,26 +296746,6 @@ menclose::after {
296337
296746
  });
296338
296747
  }
296339
296748
  }
296340
- #findStructuredContentBlockAtPos(doc$12, pos) {
296341
- if (!Number.isFinite(pos))
296342
- return null;
296343
- try {
296344
- const $pos = doc$12.resolve(pos);
296345
- for (let depth = $pos.depth;depth > 0; depth--) {
296346
- const node3 = $pos.node(depth);
296347
- if (node3.type?.name === "structuredContentBlock")
296348
- return {
296349
- node: node3,
296350
- pos: $pos.before(depth),
296351
- start: $pos.start(depth),
296352
- end: $pos.end(depth)
296353
- };
296354
- }
296355
- } catch {
296356
- return null;
296357
- }
296358
- return null;
296359
- }
296360
296749
  #isInsideTableWithinStructuredContentBlock(doc$12, pos, sdtPos) {
296361
296750
  if (!Number.isFinite(pos) || !Number.isFinite(sdtPos))
296362
296751
  return false;
@@ -296380,82 +296769,26 @@ menclose::after {
296380
296769
  return false;
296381
296770
  }
296382
296771
  }
296383
- #findStructuredContentBlockById(doc$12, id2) {
296384
- let found2 = null;
296385
- doc$12.descendants((node3, pos) => {
296386
- if (node3.type?.name !== "structuredContentBlock")
296387
- return true;
296388
- const nodeId = node3.attrs?.id;
296389
- if (String(nodeId ?? "") !== id2)
296390
- return true;
296391
- found2 = {
296392
- node: node3,
296393
- pos,
296394
- start: pos + 1,
296395
- end: pos + node3.nodeSize - 1
296396
- };
296397
- return false;
296398
- });
296399
- return found2;
296400
- }
296401
- #findStructuredContentInlineAtPos(doc$12, pos) {
296402
- if (!Number.isFinite(pos))
296403
- return null;
296404
- try {
296405
- const $pos = doc$12.resolve(pos);
296406
- for (let depth = $pos.depth;depth > 0; depth--) {
296407
- const node3 = $pos.node(depth);
296408
- if (node3.type?.name === "structuredContent")
296409
- return {
296410
- node: node3,
296411
- pos: $pos.before(depth),
296412
- start: $pos.start(depth),
296413
- end: $pos.end(depth)
296414
- };
296415
- }
296416
- } catch {
296417
- return null;
296418
- }
296419
- return null;
296420
- }
296421
- #findStructuredContentInlineById(doc$12, id2) {
296422
- let found2 = null;
296423
- doc$12.descendants((node3, pos) => {
296424
- if (node3.type?.name !== "structuredContent")
296425
- return true;
296426
- const nodeId = node3.attrs?.id;
296427
- if (String(nodeId ?? "") !== id2)
296428
- return true;
296429
- found2 = {
296430
- node: node3,
296431
- pos,
296432
- start: pos + 1,
296433
- end: pos + node3.nodeSize - 1
296434
- };
296435
- return false;
296436
- });
296437
- return found2;
296438
- }
296439
296772
  #resolveStructuredContentBlockFromElement(doc$12, element3) {
296440
296773
  const container = element3.closest?.(".superdoc-structured-content-block");
296441
296774
  if (!container)
296442
296775
  return null;
296443
296776
  const sdtId = container.dataset?.sdtId;
296444
296777
  if (sdtId) {
296445
- const match$1 = this.#findStructuredContentBlockById(doc$12, sdtId);
296778
+ const match$1 = findStructuredContentBlockById(doc$12, sdtId);
296446
296779
  if (match$1)
296447
296780
  return match$1;
296448
296781
  }
296449
296782
  const containerSdtId = container.dataset?.sdtContainerId;
296450
296783
  if (containerSdtId) {
296451
- const match$1 = this.#findStructuredContentBlockById(doc$12, containerSdtId);
296784
+ const match$1 = findStructuredContentBlockById(doc$12, containerSdtId);
296452
296785
  if (match$1)
296453
296786
  return match$1;
296454
296787
  }
296455
296788
  const pmStartRaw = container.dataset?.pmStart;
296456
296789
  const pmStart = pmStartRaw != null ? Number(pmStartRaw) : NaN;
296457
296790
  if (Number.isFinite(pmStart))
296458
- return this.#findStructuredContentBlockAtPos(doc$12, pmStart);
296791
+ return findStructuredContentBlockAtPos(doc$12, pmStart);
296459
296792
  return null;
296460
296793
  }
296461
296794
  #resolveStructuredContentInlineFromElement(doc$12, element3) {
@@ -296464,14 +296797,14 @@ menclose::after {
296464
296797
  return null;
296465
296798
  const sdtId = container.dataset?.sdtId;
296466
296799
  if (sdtId) {
296467
- const match$1 = this.#findStructuredContentInlineById(doc$12, sdtId);
296800
+ const match$1 = findStructuredContentInlineById(doc$12, sdtId);
296468
296801
  if (match$1)
296469
296802
  return match$1;
296470
296803
  }
296471
296804
  const pmStartRaw = container.dataset?.pmStart;
296472
296805
  const pmStart = pmStartRaw != null ? Number(pmStartRaw) : NaN;
296473
296806
  if (Number.isFinite(pmStart))
296474
- return this.#findStructuredContentInlineAtPos(doc$12, pmStart);
296807
+ return findStructuredContentInlineAtPos(doc$12, pmStart);
296475
296808
  return null;
296476
296809
  }
296477
296810
  #findStructuredContentBlockContentRange(resolved) {
@@ -297452,10 +297785,11 @@ menclose::after {
297452
297785
  #isCompositionKeyboardEvent(event) {
297453
297786
  return event.isComposing || event.keyCode === 229 || event.key === "Dead" || event.key === "Compose";
297454
297787
  }
297455
- }, isObject2 = (value) => typeof value === "object" && value !== null, INTERNAL_MIME_TYPE = "application/x-field-annotation", FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation", IMAGE_EXTENSIONS, DragDropManager = class {
297788
+ }, isObject2 = (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 {
297456
297789
  #deps = null;
297457
297790
  #dragOverRaf = null;
297458
297791
  #pendingDragOver = null;
297792
+ #activeInternalObjectPayload = null;
297459
297793
  #boundHandleDragStart = null;
297460
297794
  #boundHandleDragOver = null;
297461
297795
  #boundHandleDrop = null;
@@ -297515,23 +297849,45 @@ menclose::after {
297515
297849
  }
297516
297850
  destroy() {
297517
297851
  this.#cancelPendingDragOverSelection();
297852
+ this.#activeInternalObjectPayload = null;
297853
+ this.#deps?.clearDragDropIndicator();
297518
297854
  this.unbind();
297519
297855
  this.#deps = null;
297520
297856
  }
297521
297857
  #handleDragStart(event) {
297522
297858
  const target = event.target;
297523
- if (!target?.dataset?.[DATASET_KEYS.DRAGGABLE] || target.dataset[DATASET_KEYS.DRAGGABLE] !== "true")
297859
+ const sourceElement = resolveDragSourceElement(event);
297860
+ const fieldAnnotationElement = target?.closest?.(`[${DATASET_KEYS.DRAGGABLE}="true"]`);
297861
+ if (!target) {
297862
+ this.#activeInternalObjectPayload = null;
297524
297863
  return;
297525
- const data = extractFieldAnnotationData(target);
297864
+ }
297865
+ const internalObjectPayload = sourceElement ? buildInternalObjectDragPayload(sourceElement) : null;
297866
+ const isInternalObjectSource = internalObjectPayload !== null;
297867
+ const isFieldAnnotation = fieldAnnotationElement != null;
297868
+ this.#activeInternalObjectPayload = isInternalObjectSource ? internalObjectPayload : null;
297869
+ if (!isFieldAnnotation && !isInternalObjectSource) {
297870
+ this.#activeInternalObjectPayload = null;
297871
+ return;
297872
+ }
297526
297873
  if (event.dataTransfer) {
297527
- const jsonData = JSON.stringify({
297528
- attributes: data.attributes,
297529
- sourceField: data
297530
- });
297531
- event.dataTransfer.setData(INTERNAL_MIME_TYPE, jsonData);
297532
- event.dataTransfer.setData(FIELD_ANNOTATION_DATA_TYPE, jsonData);
297533
- event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
297534
- event.dataTransfer.setDragImage(target, 0, 0);
297874
+ if (isInternalObjectSource && internalObjectPayload) {
297875
+ const jsonData = JSON.stringify(internalObjectPayload);
297876
+ event.dataTransfer.setData(INTERNAL_OBJECT_MIME_TYPE, jsonData);
297877
+ event.dataTransfer.setData("text/plain", internalObjectPayload.label);
297878
+ event.dataTransfer.setDragImage(sourceElement ?? target, 0, 0);
297879
+ } else {
297880
+ const draggableTarget = fieldAnnotationElement ?? target;
297881
+ const data = extractFieldAnnotationData(draggableTarget);
297882
+ const jsonData = JSON.stringify({
297883
+ attributes: data.attributes,
297884
+ sourceField: data
297885
+ });
297886
+ event.dataTransfer.setData(INTERNAL_MIME_TYPE, jsonData);
297887
+ event.dataTransfer.setData(FIELD_ANNOTATION_DATA_TYPE, jsonData);
297888
+ event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
297889
+ event.dataTransfer.setDragImage(draggableTarget, 0, 0);
297890
+ }
297535
297891
  event.dataTransfer.effectAllowed = "move";
297536
297892
  }
297537
297893
  }
@@ -297547,6 +297903,8 @@ menclose::after {
297547
297903
  if (event.dataTransfer)
297548
297904
  if (kind === "fieldAnnotation")
297549
297905
  event.dataTransfer.dropEffect = isInternalDrag(event) ? "move" : "copy";
297906
+ else if (kind === "internalObject")
297907
+ event.dataTransfer.dropEffect = "move";
297550
297908
  else
297551
297909
  event.dataTransfer.dropEffect = "copy";
297552
297910
  this.#scheduleDragOverSelection(event.clientX, event.clientY);
@@ -297560,6 +297918,7 @@ menclose::after {
297560
297918
  event.preventDefault();
297561
297919
  event.stopPropagation();
297562
297920
  this.#cancelPendingDragOverSelection();
297921
+ this.#deps.clearDragDropIndicator();
297563
297922
  const activeEditor = this.#deps.getActiveEditor();
297564
297923
  if (!activeEditor?.isEditable)
297565
297924
  return;
@@ -297575,6 +297934,14 @@ menclose::after {
297575
297934
  const dropPos = hit?.pos ?? fallbackPos;
297576
297935
  if (dropPos == null)
297577
297936
  return;
297937
+ if (kind === "internalObject") {
297938
+ try {
297939
+ this.#handleInternalObjectDrop(event, dropPos);
297940
+ } finally {
297941
+ this.#activeInternalObjectPayload = null;
297942
+ }
297943
+ return;
297944
+ }
297578
297945
  if (isInternalDrag(event)) {
297579
297946
  this.#handleInternalDrop(event, dropPos);
297580
297947
  return;
@@ -297583,6 +297950,8 @@ menclose::after {
297583
297950
  }
297584
297951
  #handleDragEnd(_event) {
297585
297952
  this.#cancelPendingDragOverSelection();
297953
+ this.#activeInternalObjectPayload = null;
297954
+ this.#deps?.clearDragDropIndicator();
297586
297955
  this.#deps?.getPainterHost()?.classList.remove("drag-over");
297587
297956
  }
297588
297957
  #handleDragLeave(event) {
@@ -297593,6 +297962,7 @@ menclose::after {
297593
297962
  if (relatedTarget && viewportHost.contains(relatedTarget))
297594
297963
  return;
297595
297964
  this.#cancelPendingDragOverSelection();
297965
+ this.#deps?.clearDragDropIndicator();
297596
297966
  this.#deps?.getPainterHost()?.classList.remove("drag-over");
297597
297967
  }
297598
297968
  #scheduleDragOverSelection(clientX, clientY) {
@@ -297628,17 +297998,12 @@ menclose::after {
297628
297998
  return;
297629
297999
  const hit = this.#deps.hitTest(clientX, clientY);
297630
298000
  const doc$12 = activeEditor.state?.doc;
297631
- if (!hit || !doc$12)
298001
+ if (!hit || !doc$12) {
298002
+ this.#deps.clearDragDropIndicator();
297632
298003
  return;
298004
+ }
297633
298005
  const pos = Math.min(Math.max(hit.pos, 1), doc$12.content.size);
297634
- const currentSelection = activeEditor.state.selection;
297635
- if (currentSelection instanceof TextSelection && currentSelection.from === pos && currentSelection.to === pos)
297636
- return;
297637
- try {
297638
- const tr = activeEditor.state.tr.setSelection(TextSelection.create(doc$12, pos)).setMeta("addToHistory", false);
297639
- activeEditor.view?.dispatch(tr);
297640
- this.#deps.scheduleSelectionUpdate();
297641
- } catch {}
298006
+ this.#deps.showDragDropIndicator(pos);
297642
298007
  }
297643
298008
  async#handleImageDrop(event) {
297644
298009
  if (!this.#deps)
@@ -297736,16 +298101,47 @@ menclose::after {
297736
298101
  });
297737
298102
  if (sourceStart === null || sourceEnd === null || !sourceNode)
297738
298103
  return;
297739
- if (targetPos >= sourceStart && targetPos <= sourceEnd)
298104
+ const result = createInternalNodeMoveTransaction({
298105
+ doc: state.doc,
298106
+ tr: state.tr
298107
+ }, {
298108
+ sourceStart,
298109
+ sourceEnd,
298110
+ targetPos,
298111
+ expectedNodeType: "fieldAnnotation",
298112
+ canInsertAt: () => true
298113
+ });
298114
+ if (!result.ok)
297740
298115
  return;
297741
- const tr = state.tr;
297742
- tr.delete(sourceStart, sourceEnd);
297743
- const mappedTarget = tr.mapping.map(targetPos);
297744
- if (mappedTarget < 0 || mappedTarget > tr.doc.content.size)
298116
+ view.dispatch(result.transaction);
298117
+ }
298118
+ #handleInternalObjectDrop(event, targetPos) {
298119
+ if (!this.#deps)
297745
298120
  return;
297746
- tr.insert(mappedTarget, sourceNode);
297747
- tr.setMeta("uiEvent", "drop");
297748
- view.dispatch(tr);
298121
+ const { state, view } = this.#deps.getActiveEditor();
298122
+ if (!state || !view)
298123
+ return;
298124
+ const payload = this.#activeInternalObjectPayload;
298125
+ if (!payload)
298126
+ return;
298127
+ if (payload.kind === "structuredContent" && payload.lockMode !== "unlocked")
298128
+ return;
298129
+ const { sourceStart, sourceEnd } = resolveInternalObjectSourceRange(state.doc, payload);
298130
+ const result = createInternalNodeMoveTransaction({
298131
+ doc: state.doc,
298132
+ tr: state.tr
298133
+ }, {
298134
+ sourceStart,
298135
+ sourceEnd,
298136
+ targetPos,
298137
+ expectedNodeType: payload.nodeType,
298138
+ canInsertAt: canInsertNodeAtPosition
298139
+ });
298140
+ if (!result.ok)
298141
+ return;
298142
+ view.dispatch(result.transaction);
298143
+ this.#focusEditor();
298144
+ this.#deps.scheduleSelectionUpdate();
297749
298145
  }
297750
298146
  #handleExternalDrop(event, pos) {
297751
298147
  if (!this.#deps)
@@ -297789,6 +298185,8 @@ menclose::after {
297789
298185
  if (event.dataTransfer)
297790
298186
  if (kind === "fieldAnnotation")
297791
298187
  event.dataTransfer.dropEffect = isInternalDrag(event) ? "move" : "copy";
298188
+ else if (kind === "internalObject")
298189
+ event.dataTransfer.dropEffect = "move";
297792
298190
  else
297793
298191
  event.dataTransfer.dropEffect = "copy";
297794
298192
  }
@@ -299902,14 +300300,32 @@ menclose::after {
299902
300300
  pointer-events: none;
299903
300301
  z-index: 1000;
299904
300302
  }
299905
- `, fieldAnnotationInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
300303
+ `, fieldAnnotationInteractionStylesInjected = false, MOVABLE_OBJECT_INTERACTION_STYLES = `
300304
+ /* Editing affordance: allow grab cursors for draggable SDT labels and images */
300305
+ .superdoc-layout [data-drag-source-kind] {
300306
+ cursor: grab;
300307
+ }
300308
+
300309
+ .superdoc-layout [data-drag-source-kind]:active {
300310
+ cursor: grabbing;
300311
+ }
300312
+
300313
+ /* Keep the active drag source from selecting text while dragging */
300314
+ .superdoc-layout .superdoc-structured-content__label,
300315
+ .superdoc-layout .superdoc-structured-content-inline__label,
300316
+ .superdoc-layout .superdoc-image-fragment[data-drag-source-kind="existingImage"],
300317
+ .superdoc-layout .superdoc-inline-image-clip-wrapper[data-drag-source-kind="existingImage"],
300318
+ .superdoc-layout .superdoc-inline-image[data-drag-source-kind="existingImage"] {
300319
+ user-select: none;
300320
+ }
300321
+ `, movableObjectInteractionStylesInjected = false, INTERNAL_NOTE_COMMIT_SOURCES, isInternalNoteCommitSource = (event) => {
299906
300322
  return typeof event?.source === "string" && INTERNAL_NOTE_COMMIT_SOURCES.has(event.source);
299907
300323
  }, 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) => {
299908
300324
  if (!layoutDebugEnabled)
299909
300325
  return;
299910
300326
  console.log(...args$1);
299911
300327
  }, 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;
299912
- var init_src_C_jV2TZI_es = __esm(() => {
300328
+ var init_src_CSHo1aJM_es = __esm(() => {
299913
300329
  init_rolldown_runtime_Bg48TavK_es();
299914
300330
  init_SuperConverter_D1o6_yKI_es();
299915
300331
  init_jszip_C49i9kUs_es();
@@ -325942,6 +326358,7 @@ function print() { __p += __j.call(arguments, '') }
325942
326358
  CANONICAL: "canonical",
325943
326359
  DERIVED: "derived"
325944
326360
  };
326361
+ INLINE_LABEL_SELECTOR = `.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}__label`;
325945
326362
  PROOFING_CSS = {
325946
326363
  SPELLING: "sd-proofing-spelling",
325947
326364
  GRAMMAR: "sd-proofing-grammar",
@@ -331519,6 +331936,7 @@ function print() { __p += __j.call(arguments, '') }
331519
331936
  #isRerendering = false;
331520
331937
  #selectionSync = new SelectionSyncCoordinator;
331521
331938
  #shouldScrollSelectionIntoView = false;
331939
+ #dragDropIndicatorPos = null;
331522
331940
  #epochMapper = new EpochPositionMapper;
331523
331941
  #layoutEpoch = 0;
331524
331942
  #htmlAnnotationHeights = /* @__PURE__ */ new Map;
@@ -331635,6 +332053,7 @@ function print() { __p += __j.call(arguments, '') }
331635
332053
  this.#postPaintPipeline.setContainer(this.#painterHost);
331636
332054
  ensureEditorNativeSelectionStyles(doc$12);
331637
332055
  ensureEditorFieldAnnotationInteractionStyles(doc$12);
332056
+ ensureEditorMovableObjectInteractionStyles(doc$12);
331638
332057
  this.#painterHost.addEventListener("mouseover", this.#handleStructuredContentBlockMouseEnter);
331639
332058
  this.#painterHost.addEventListener("mouseout", this.#handleStructuredContentBlockMouseLeave);
331640
332059
  this.#domIndexObserverManager = new DomPositionIndexObserverManager({
@@ -333990,12 +334409,30 @@ function print() { __p += __j.call(arguments, '') }
333990
334409
  getActiveEditor: () => this.getActiveEditor(),
333991
334410
  hitTest: (clientX, clientY) => this.hitTest(clientX, clientY),
333992
334411
  scheduleSelectionUpdate: () => this.#scheduleSelectionUpdate(),
334412
+ showDragDropIndicator: (pos) => this.#showDragDropIndicator(pos),
334413
+ clearDragDropIndicator: () => this.#clearDragDropIndicator(),
333993
334414
  getViewportHost: () => this.#viewportHost,
333994
334415
  getPainterHost: () => this.#painterHost,
333995
334416
  insertImageFile: (params$1) => processAndInsertImageFile(params$1)
333996
334417
  });
333997
334418
  this.#dragDropManager.bind();
333998
334419
  }
334420
+ #showDragDropIndicator(pos) {
334421
+ const docSize = this.getActiveEditor()?.state?.doc?.content.size;
334422
+ if (!Number.isFinite(pos) || docSize == null)
334423
+ return;
334424
+ const clampedPos = Math.min(Math.max(pos, 1), docSize);
334425
+ if (this.#dragDropIndicatorPos === clampedPos)
334426
+ return;
334427
+ this.#dragDropIndicatorPos = clampedPos;
334428
+ this.#scheduleSelectionUpdate({ immediate: true });
334429
+ }
334430
+ #clearDragDropIndicator() {
334431
+ if (this.#dragDropIndicatorPos == null)
334432
+ return;
334433
+ this.#dragDropIndicatorPos = null;
334434
+ this.#scheduleSelectionUpdate({ immediate: true });
334435
+ }
333999
334436
  #focusEditorAfterImageSelection() {
334000
334437
  this.#shouldScrollSelectionIntoView = true;
334001
334438
  this.#scheduleSelectionUpdate();
@@ -335143,6 +335580,7 @@ function print() { __p += __j.call(arguments, '') }
335143
335580
  return;
335144
335581
  }
335145
335582
  let node3 = null;
335583
+ let pos = null;
335146
335584
  let id2 = null;
335147
335585
  if (selection instanceof NodeSelection) {
335148
335586
  if (selection.node?.type?.name !== "structuredContentBlock") {
@@ -335150,23 +335588,24 @@ function print() { __p += __j.call(arguments, '') }
335150
335588
  return;
335151
335589
  }
335152
335590
  node3 = selection.node;
335591
+ pos = selection.from;
335153
335592
  } else {
335154
- const $pos = selection.$from;
335155
- if (!$pos || typeof $pos.depth !== "number" || typeof $pos.node !== "function") {
335593
+ const editorDoc = this.#editor?.view?.state?.doc;
335594
+ if (!editorDoc) {
335156
335595
  this.#clearSelectedStructuredContentBlockClass();
335157
335596
  return;
335158
335597
  }
335159
- for (let depth = $pos.depth;depth > 0; depth--) {
335160
- const candidate = $pos.node(depth);
335161
- if (candidate.type?.name === "structuredContentBlock") {
335162
- node3 = candidate;
335163
- break;
335164
- }
335165
- }
335166
- if (!node3) {
335598
+ const resolved = findStructuredContentBlockAtPos(editorDoc, selection.from);
335599
+ if (!resolved) {
335167
335600
  this.#clearSelectedStructuredContentBlockClass();
335168
335601
  return;
335169
335602
  }
335603
+ node3 = resolved.node;
335604
+ pos = resolved.pos;
335605
+ }
335606
+ if (pos == null) {
335607
+ this.#clearSelectedStructuredContentBlockClass();
335608
+ return;
335170
335609
  }
335171
335610
  if (!this.#painterHost) {
335172
335611
  this.#clearSelectedStructuredContentBlockClass();
@@ -335178,7 +335617,7 @@ function print() { __p += __j.call(arguments, '') }
335178
335617
  if (id2)
335179
335618
  elements = this.#painterAdapter.getStructuredContentBlockElementsById(id2);
335180
335619
  if (elements.length === 0) {
335181
- const container = this.getElementAtPos(selection.from, { fallbackToCoords: true })?.closest?.(`.${DOM_CLASS_NAMES.BLOCK_SDT}`);
335620
+ const container = this.getElementAtPos(pos, { fallbackToCoords: true })?.closest?.(`.${DOM_CLASS_NAMES.BLOCK_SDT}`);
335182
335621
  if (container)
335183
335622
  elements = [container];
335184
335623
  }
@@ -335301,27 +335740,18 @@ function print() { __p += __j.call(arguments, '') }
335301
335740
  node3 = selection.node;
335302
335741
  pos = selection.from;
335303
335742
  } else {
335304
- const $pos = selection.$from;
335305
- if (!$pos || typeof $pos.depth !== "number" || typeof $pos.node !== "function") {
335743
+ const editorDoc = this.#editor?.view?.state?.doc;
335744
+ if (!editorDoc) {
335306
335745
  this.#clearSelectedStructuredContentInlineClass();
335307
335746
  return;
335308
335747
  }
335309
- for (let depth = $pos.depth;depth > 0; depth--) {
335310
- const candidate = $pos.node(depth);
335311
- if (candidate.type?.name === "structuredContent") {
335312
- if (typeof $pos.before !== "function") {
335313
- this.#clearSelectedStructuredContentInlineClass();
335314
- return;
335315
- }
335316
- node3 = candidate;
335317
- pos = $pos.before(depth);
335318
- break;
335319
- }
335320
- }
335321
- if (!node3 || pos == null) {
335748
+ const resolved = findStructuredContentInlineAtPos(editorDoc, selection.from);
335749
+ if (!resolved) {
335322
335750
  this.#clearSelectedStructuredContentInlineClass();
335323
335751
  return;
335324
335752
  }
335753
+ node3 = resolved.node;
335754
+ pos = resolved.pos;
335325
335755
  }
335326
335756
  if (!this.#painterHost) {
335327
335757
  this.#clearSelectedStructuredContentInlineClass();
@@ -335375,7 +335805,8 @@ function print() { __p += __j.call(arguments, '') }
335375
335805
  const hasFocus = activeEditor?.view?.hasFocus?.() ?? false;
335376
335806
  const contextMenuOpen = activeEditor?.state ? !!ContextMenuPluginKey.getState(activeEditor.state)?.open : false;
335377
335807
  const isOnEditorUi = !!document.activeElement?.closest?.("[data-editor-ui-surface], .sd-toolbar-dropdown-menu, .toolbar-dropdown-menu");
335378
- if (!hasFocus && !contextMenuOpen && !isOnEditorUi) {
335808
+ const isDragDropIndicatorActive = this.#dragDropIndicatorPos != null;
335809
+ if (!hasFocus && !contextMenuOpen && !isOnEditorUi && !isDragDropIndicatorActive) {
335379
335810
  try {
335380
335811
  this.#clearSelectedFieldAnnotationClass();
335381
335812
  this.#localSelectionLayer.innerHTML = "";
@@ -335415,8 +335846,9 @@ function print() { __p += __j.call(arguments, '') }
335415
335846
  }
335416
335847
  return;
335417
335848
  }
335418
- if (from$1 === to) {
335419
- const caretLayout = this.#computeCaretLayoutRect(from$1);
335849
+ if (from$1 === to || isDragDropIndicatorActive) {
335850
+ const caretPos = this.#dragDropIndicatorPos ?? from$1;
335851
+ const caretLayout = this.#computeCaretLayoutRect(caretPos);
335420
335852
  if (!caretLayout)
335421
335853
  return;
335422
335854
  try {
@@ -335430,7 +335862,7 @@ function print() { __p += __j.call(arguments, '') }
335430
335862
  if (process$12.env.NODE_ENV === "development")
335431
335863
  console.warn("[PresentationEditor] Failed to render caret overlay:", error3);
335432
335864
  }
335433
- if (shouldScrollIntoView)
335865
+ if (shouldScrollIntoView && !isDragDropIndicatorActive)
335434
335866
  this.#scrollActiveEndIntoView(caretLayout.pageIndex);
335435
335867
  return;
335436
335868
  }
@@ -337551,7 +337983,7 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
337551
337983
 
337552
337984
  // ../../packages/superdoc/dist/super-editor.es.js
337553
337985
  var init_super_editor_es = __esm(() => {
337554
- init_src_C_jV2TZI_es();
337986
+ init_src_CSHo1aJM_es();
337555
337987
  init_SuperConverter_D1o6_yKI_es();
337556
337988
  init_jszip_C49i9kUs_es();
337557
337989
  init_xml_js_CqGKpaft_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.8.0-next.80",
3
+ "version": "0.8.0-next.81",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -26,19 +26,19 @@
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
28
  "@superdoc/pm-adapter": "0.0.0",
29
- "superdoc": "1.31.0",
30
- "@superdoc/super-editor": "0.0.1"
29
+ "@superdoc/super-editor": "0.0.1",
30
+ "superdoc": "1.31.0"
31
31
  },
32
32
  "module": "src/index.ts",
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.8.0-next.80",
38
- "@superdoc-dev/cli-darwin-x64": "0.8.0-next.80",
39
- "@superdoc-dev/cli-linux-x64": "0.8.0-next.80",
40
- "@superdoc-dev/cli-linux-arm64": "0.8.0-next.80",
41
- "@superdoc-dev/cli-windows-x64": "0.8.0-next.80"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.8.0-next.81",
38
+ "@superdoc-dev/cli-darwin-x64": "0.8.0-next.81",
39
+ "@superdoc-dev/cli-linux-arm64": "0.8.0-next.81",
40
+ "@superdoc-dev/cli-linux-x64": "0.8.0-next.81",
41
+ "@superdoc-dev/cli-windows-x64": "0.8.0-next.81"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",