@harbour-enterprises/superdoc 1.0.0-beta.31 → 1.0.0-beta.32

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 (27) hide show
  1. package/dist/chunks/{PdfViewer-C8iiBtQt.cjs → PdfViewer-CTKbqDWv.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-jGctuklH.es.js → PdfViewer-edjIRb_p.es.js} +1 -1
  3. package/dist/chunks/{index-ELjoBC86.cjs → index-Cajp7-Xa.cjs} +3 -3
  4. package/dist/chunks/{index-Bu5UUj9S.es.js → index-Pwv0a9G5.es.js} +3 -3
  5. package/dist/chunks/{index-eG-VYUeN-CIuOnW8W.es.js → index-SGV4U12y-BPGxOtvI.es.js} +1 -1
  6. package/dist/chunks/{index-eG-VYUeN-CG3M1n5T.cjs → index-SGV4U12y-Dh5jaROA.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-DatOA_vA.cjs → super-editor.es-BbbbKgEs.cjs} +1314 -62
  8. package/dist/chunks/{super-editor.es-BAKZgAuj.es.js → super-editor.es-CdGsYGU1.es.js} +1314 -62
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-CRKt1TG_.js → converter-CpuOoAUa.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-CgVw58T-.js → docx-zipper-Dk99r397.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-COQCS1pn.js → editor-CFv-RJI-.js} +1363 -63
  13. package/dist/super-editor/chunks/{index-eG-VYUeN.js → index-SGV4U12y.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-B3CSV2yT.js → toolbar-CQr3Xnx9.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +1316 -64
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -41859,7 +41859,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41859
41859
  static getStoredSuperdocVersion(docx) {
41860
41860
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
41861
41861
  }
41862
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.31") {
41862
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.32") {
41863
41863
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
41864
41864
  }
41865
41865
  /**
@@ -53022,7 +53022,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53022
53022
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
53023
53023
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53024
53024
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
53025
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
53025
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
53026
53026
  var GOOD_LEAF_SIZE = 200;
53027
53027
  var RopeSequence = function RopeSequence2() {
53028
53028
  };
@@ -66889,7 +66889,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66889
66889
  const shouldSkipNodeView = (editor) => {
66890
66890
  return isHeadless(editor);
66891
66891
  };
66892
- const summaryVersion = "1.0.0-beta.31";
66892
+ const summaryVersion = "1.0.0-beta.32";
66893
66893
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
66894
66894
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
66895
66895
  function mapAttributes(attrs) {
@@ -67678,7 +67678,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67678
67678
  { default: remarkStringify2 },
67679
67679
  { default: remarkGfm2 }
67680
67680
  ] = await Promise.all([
67681
- Promise.resolve().then(() => indexEGVYUeN),
67681
+ Promise.resolve().then(() => indexSGV4U12y),
67682
67682
  Promise.resolve().then(() => indexDRCvimau),
67683
67683
  Promise.resolve().then(() => indexC_x_N6Uh),
67684
67684
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -67883,7 +67883,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67883
67883
  * Process collaboration migrations
67884
67884
  */
67885
67885
  processCollaborationMigrations() {
67886
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.31");
67886
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.32");
67887
67887
  if (!this.options.ydoc) return;
67888
67888
  const metaMap = this.options.ydoc.getMap("meta");
67889
67889
  let docVersion = metaMap.get("version");
@@ -73025,7 +73025,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73025
73025
  blocks2.push(block);
73026
73026
  recordBlockKind(block.kind);
73027
73027
  });
73028
- } else if (child.type === "table") ;
73028
+ } else if (child.type === "table") {
73029
+ const tableNodeToBlock2 = converters?.tableNodeToBlock;
73030
+ if (tableNodeToBlock2) {
73031
+ const tableBlock = tableNodeToBlock2(
73032
+ child,
73033
+ nextBlockId,
73034
+ positions,
73035
+ defaultFont,
73036
+ defaultSize,
73037
+ styleContext,
73038
+ trackedChangesConfig,
73039
+ bookmarks,
73040
+ hyperlinkConfig
73041
+ );
73042
+ if (tableBlock) {
73043
+ applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
73044
+ blocks2.push(tableBlock);
73045
+ recordBlockKind(tableBlock.kind);
73046
+ }
73047
+ }
73048
+ }
73029
73049
  });
73030
73050
  }
73031
73051
  function processParagraphChild(child, sectionMetadata, context, output, converters) {
@@ -73495,6 +73515,65 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73495
73515
  }
73496
73516
  return run2;
73497
73517
  }
73518
+ function fieldAnnotationNodeToRun(node2, positions, fieldMetadata) {
73519
+ const attrs = node2.attrs ?? {};
73520
+ const rawVariant = attrs.type ?? fieldMetadata?.variant ?? "text";
73521
+ const validVariants = ["text", "image", "signature", "checkbox", "html", "link"];
73522
+ const variant = validVariants.includes(rawVariant) ? rawVariant : "text";
73523
+ const displayLabel = (typeof attrs.displayLabel === "string" ? attrs.displayLabel : void 0) || (typeof attrs.defaultDisplayLabel === "string" ? attrs.defaultDisplayLabel : void 0) || (typeof fieldMetadata?.displayLabel === "string" ? fieldMetadata.displayLabel : void 0) || (typeof fieldMetadata?.defaultDisplayLabel === "string" ? fieldMetadata.defaultDisplayLabel : void 0) || (typeof attrs.alias === "string" ? attrs.alias : void 0) || (typeof fieldMetadata?.alias === "string" ? fieldMetadata.alias : void 0) || "";
73524
+ const run2 = {
73525
+ kind: "fieldAnnotation",
73526
+ variant,
73527
+ displayLabel
73528
+ };
73529
+ const fieldId = typeof attrs.fieldId === "string" ? attrs.fieldId : fieldMetadata?.fieldId;
73530
+ if (fieldId) run2.fieldId = fieldId;
73531
+ const fieldType = typeof attrs.fieldType === "string" ? attrs.fieldType : fieldMetadata?.fieldType;
73532
+ if (fieldType) run2.fieldType = fieldType;
73533
+ const fieldColor = typeof attrs.fieldColor === "string" ? attrs.fieldColor : fieldMetadata?.fieldColor;
73534
+ if (fieldColor) run2.fieldColor = fieldColor;
73535
+ const borderColor = typeof attrs.borderColor === "string" ? attrs.borderColor : fieldMetadata?.borderColor;
73536
+ if (borderColor) run2.borderColor = borderColor;
73537
+ const highlighted = attrs.highlighted ?? fieldMetadata?.highlighted;
73538
+ if (highlighted === false) run2.highlighted = false;
73539
+ if (attrs.hidden === true || fieldMetadata?.hidden === true) run2.hidden = true;
73540
+ const visibility = attrs.visibility ?? fieldMetadata?.visibility;
73541
+ if (visibility === "hidden") run2.visibility = "hidden";
73542
+ const imageSrc = typeof attrs.imageSrc === "string" ? attrs.imageSrc : fieldMetadata?.imageSrc;
73543
+ if (imageSrc) run2.imageSrc = imageSrc;
73544
+ const linkUrl = typeof attrs.linkUrl === "string" ? attrs.linkUrl : fieldMetadata?.linkUrl;
73545
+ if (linkUrl) run2.linkUrl = linkUrl;
73546
+ const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
73547
+ if (typeof rawHtml === "string") run2.rawHtml = rawHtml;
73548
+ const size2 = attrs.size ?? fieldMetadata?.size;
73549
+ if (size2 && (typeof size2.width === "number" || typeof size2.height === "number")) {
73550
+ run2.size = {
73551
+ width: typeof size2.width === "number" ? size2.width : void 0,
73552
+ height: typeof size2.height === "number" ? size2.height : void 0
73553
+ };
73554
+ }
73555
+ const fontFamily2 = attrs.fontFamily ?? fieldMetadata?.fontFamily;
73556
+ if (typeof fontFamily2 === "string") run2.fontFamily = fontFamily2;
73557
+ const fontSize2 = attrs.fontSize ?? fieldMetadata?.fontSize;
73558
+ if (typeof fontSize2 === "string" || typeof fontSize2 === "number") run2.fontSize = fontSize2;
73559
+ const textColor = attrs.textColor ?? fieldMetadata?.textColor;
73560
+ if (typeof textColor === "string") run2.textColor = textColor;
73561
+ const textHighlight = attrs.textHighlight ?? fieldMetadata?.textHighlight;
73562
+ if (typeof textHighlight === "string") run2.textHighlight = textHighlight;
73563
+ const formatting = fieldMetadata?.formatting;
73564
+ if (attrs.bold === true || formatting?.bold === true) run2.bold = true;
73565
+ if (attrs.italic === true || formatting?.italic === true) run2.italic = true;
73566
+ if (attrs.underline === true || formatting?.underline === true) run2.underline = true;
73567
+ const pos = positions.get(node2);
73568
+ if (pos) {
73569
+ run2.pmStart = pos.start;
73570
+ run2.pmEnd = pos.end;
73571
+ }
73572
+ if (fieldMetadata) {
73573
+ run2.sdt = fieldMetadata;
73574
+ }
73575
+ return run2;
73576
+ }
73498
73577
  const isTextRun$1 = (run2) => run2.kind !== "tab";
73499
73578
  const dataAttrsCompatible = (a2, b2) => {
73500
73579
  const aAttrs = a2.dataAttrs;
@@ -73790,28 +73869,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73790
73869
  }
73791
73870
  if (node2.type === "fieldAnnotation") {
73792
73871
  const fieldMetadata = resolveNodeSdtMetadata(node2, "fieldAnnotation");
73872
+ let contentText;
73793
73873
  if (Array.isArray(node2.content) && node2.content.length > 0) {
73794
- node2.content.forEach((child) => visitNode(child, inheritedMarks, fieldMetadata ?? activeSdt, activeRunStyleId));
73795
- } else {
73796
- const nodeAttrs = typeof node2.attrs === "object" && node2.attrs !== null ? node2.attrs : {};
73797
- const label = (typeof nodeAttrs.displayLabel === "string" ? nodeAttrs.displayLabel : void 0) || (typeof nodeAttrs.defaultDisplayLabel === "string" ? nodeAttrs.defaultDisplayLabel : void 0) || (typeof nodeAttrs.alias === "string" ? nodeAttrs.alias : void 0) || "";
73798
- if (label && typeof label === "string") {
73799
- const run2 = textNodeToRun(
73800
- { type: "text", text: label },
73801
- positions,
73802
- defaultFont,
73803
- defaultSize,
73804
- inheritedMarks,
73805
- fieldMetadata ?? activeSdt,
73806
- hyperlinkConfig,
73807
- themeColors
73808
- );
73809
- const inlineStyleId = getInlineStyleId(inheritedMarks);
73810
- applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
73811
- applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
73812
- currentRuns.push(run2);
73813
- }
73874
+ const extractText = (n) => {
73875
+ if (n.type === "text" && typeof n.text === "string") return n.text;
73876
+ if (Array.isArray(n.content)) {
73877
+ return n.content.map(extractText).join("");
73878
+ }
73879
+ return "";
73880
+ };
73881
+ contentText = node2.content.map(extractText).join("");
73814
73882
  }
73883
+ const nodeForRun = contentText && contentText.length > 0 ? { ...node2, attrs: { ...node2.attrs ?? {}, displayLabel: contentText } } : node2;
73884
+ const run2 = fieldAnnotationNodeToRun(nodeForRun, positions, fieldMetadata);
73885
+ currentRuns.push(run2);
73815
73886
  return;
73816
73887
  }
73817
73888
  if (node2.type === "pageReference") {
@@ -74648,9 +74719,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74648
74719
  }
74649
74720
  const attrs = spacingEl.attributes;
74650
74721
  const spacing = {};
74651
- const before = parseIntSafe(attrs["w:before"]);
74652
- const after = parseIntSafe(attrs["w:after"]);
74653
- const line = parseIntSafe(attrs["w:line"]);
74722
+ const before = parseIntSafe$1(attrs["w:before"]);
74723
+ const after = parseIntSafe$1(attrs["w:after"]);
74724
+ const line = parseIntSafe$1(attrs["w:line"]);
74654
74725
  const rawLineRule = attrs["w:lineRule"];
74655
74726
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
74656
74727
  if (before != null) spacing.before = twipsToPx$1(before);
@@ -74665,11 +74736,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74665
74736
  if (lineRule) spacing.lineRule = lineRule;
74666
74737
  const result = Object.keys(spacing).length > 0 ? { spacing } : void 0;
74667
74738
  return result;
74668
- } catch (err) {
74739
+ } catch {
74669
74740
  return void 0;
74670
74741
  }
74671
74742
  };
74672
- const parseIntSafe = (value) => {
74743
+ const parseIntSafe$1 = (value) => {
74673
74744
  if (value == null) return void 0;
74674
74745
  const num = typeof value === "number" ? value : parseInt(String(value), 10);
74675
74746
  return Number.isFinite(num) ? num : void 0;
@@ -75321,7 +75392,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75321
75392
  return measurementCtx;
75322
75393
  }
75323
75394
  function getRunFontString(run2) {
75324
- if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
75395
+ if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
75325
75396
  return "normal normal 16px Arial";
75326
75397
  }
75327
75398
  const style2 = run2.italic ? "italic" : "normal";
@@ -75352,6 +75423,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75352
75423
  result.push(run2);
75353
75424
  continue;
75354
75425
  }
75426
+ if (run2.kind === "fieldAnnotation") {
75427
+ result.push(run2);
75428
+ continue;
75429
+ }
75355
75430
  const text2 = run2.text ?? "";
75356
75431
  const isFirstRun = runIndex === line.fromRun;
75357
75432
  const isLastRun = runIndex === line.toRun;
@@ -75385,7 +75460,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75385
75460
  1,
75386
75461
  runs22.reduce((sum, run2) => {
75387
75462
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
75388
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
75463
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
75464
+ return sum;
75389
75465
  return sum + (run2.text ?? "").length;
75390
75466
  }, 0)
75391
75467
  );
@@ -75406,7 +75482,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75406
75482
  currentCharOffset += runLength2;
75407
75483
  continue;
75408
75484
  }
75409
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
75485
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
75410
75486
  const runLength = text2.length;
75411
75487
  if (currentCharOffset + runLength >= charOffset) {
75412
75488
  const offsetInRun = charOffset - currentCharOffset;
@@ -75449,7 +75525,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75449
75525
  if (isTabRun$1(run2)) {
75450
75526
  return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
75451
75527
  }
75452
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
75528
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
75453
75529
  return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
75454
75530
  }
75455
75531
  const text2 = run2.text ?? "";
@@ -75478,7 +75554,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75478
75554
  let lastPm = fallbackPmStart;
75479
75555
  for (const run2 of runs2) {
75480
75556
  const isTab = isTabRun$1(run2);
75481
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
75557
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
75482
75558
  const runLength = isTab ? TAB_CHAR_LENGTH : text2.length;
75483
75559
  const runPmStart = typeof run2.pmStart === "number" ? run2.pmStart : null;
75484
75560
  const runPmEnd = typeof run2.pmEnd === "number" ? run2.pmEnd : runPmStart != null ? runPmStart + runLength : null;
@@ -75504,7 +75580,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75504
75580
  1,
75505
75581
  runs22.reduce((sum, run2) => {
75506
75582
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
75507
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
75583
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
75584
+ return sum;
75508
75585
  return sum + (run2.text ?? "").length;
75509
75586
  }, 0)
75510
75587
  );
@@ -75539,7 +75616,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75539
75616
  currentCharOffset += TAB_CHAR_LENGTH;
75540
75617
  continue;
75541
75618
  }
75542
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
75619
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
75543
75620
  const runLength = text2.length;
75544
75621
  if (runLength === 0) continue;
75545
75622
  ctx2.font = getRunFontString(run2);
@@ -75579,7 +75656,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75579
75656
  };
75580
75657
  }
75581
75658
  const computeLetterSpacingWidth = (run2, precedingChars, runLength) => {
75582
- if (isTabRun$1(run2) || "src" in run2 || !("letterSpacing" in run2) || !run2.letterSpacing) {
75659
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "fieldAnnotation" || !("letterSpacing" in run2) || !run2.letterSpacing) {
75583
75660
  return 0;
75584
75661
  }
75585
75662
  const maxGaps = Math.max(runLength - 1, 0);
@@ -75676,6 +75753,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75676
75753
  pmStart: fragmentEl.dataset.pmStart,
75677
75754
  pmEnd: fragmentEl.dataset.pmEnd
75678
75755
  });
75756
+ const hitChainLine = hitChain.find(
75757
+ (el) => el.classList?.contains?.(CLASS_NAMES$1.line) && el.dataset?.pmStart !== void 0 && el.dataset?.pmEnd !== void 0
75758
+ );
75759
+ if (hitChainLine) {
75760
+ log("Using hit chain line directly:", {
75761
+ pmStart: hitChainLine.dataset.pmStart,
75762
+ pmEnd: hitChainLine.dataset.pmEnd
75763
+ });
75764
+ const result2 = processLineElement(hitChainLine, viewX);
75765
+ return result2;
75766
+ }
75679
75767
  const result = processFragment(fragmentEl, viewX, viewY);
75680
75768
  return result;
75681
75769
  }
@@ -75741,7 +75829,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75741
75829
  if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
75742
75830
  return null;
75743
75831
  }
75744
- const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
75832
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
75833
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
75834
+ );
75745
75835
  log(
75746
75836
  "Spans/anchors in line:",
75747
75837
  spanEls.map((el, i2) => {
@@ -75800,6 +75890,77 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75800
75890
  const pos = spanStart + charIndex;
75801
75891
  return pos;
75802
75892
  }
75893
+ function processLineElement(lineEl, viewX) {
75894
+ const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
75895
+ const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
75896
+ const lineRect = lineEl.getBoundingClientRect();
75897
+ log("processLineElement:", {
75898
+ pmStart: lineStart,
75899
+ pmEnd: lineEnd,
75900
+ rect: { top: lineRect.top, bottom: lineRect.bottom, left: lineRect.left, right: lineRect.right }
75901
+ });
75902
+ if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
75903
+ return null;
75904
+ }
75905
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
75906
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
75907
+ );
75908
+ log(
75909
+ "Spans/anchors in line:",
75910
+ spanEls.map((el, i2) => {
75911
+ const rect = el.getBoundingClientRect();
75912
+ return {
75913
+ index: i2,
75914
+ tag: el.tagName,
75915
+ pmStart: el.dataset.pmStart,
75916
+ pmEnd: el.dataset.pmEnd,
75917
+ text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
75918
+ visibility: el.style.visibility,
75919
+ rect: { left: rect.left, right: rect.right, width: rect.width }
75920
+ };
75921
+ })
75922
+ );
75923
+ if (spanEls.length === 0) {
75924
+ return lineStart;
75925
+ }
75926
+ const firstRect = spanEls[0].getBoundingClientRect();
75927
+ if (viewX <= firstRect.left) {
75928
+ return lineStart;
75929
+ }
75930
+ const lastRect = spanEls[spanEls.length - 1].getBoundingClientRect();
75931
+ if (viewX >= lastRect.right) {
75932
+ return lineEnd;
75933
+ }
75934
+ const targetEl = findSpanAtX(spanEls, viewX);
75935
+ if (!targetEl) {
75936
+ return lineStart;
75937
+ }
75938
+ const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
75939
+ const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
75940
+ const targetRect = targetEl.getBoundingClientRect();
75941
+ log("Target element:", {
75942
+ tag: targetEl.tagName,
75943
+ pmStart: spanStart,
75944
+ pmEnd: spanEnd,
75945
+ text: targetEl.textContent?.substring(0, 30),
75946
+ visibility: targetEl.style.visibility,
75947
+ rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
75948
+ });
75949
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
75950
+ return null;
75951
+ }
75952
+ const firstChild = targetEl.firstChild;
75953
+ if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
75954
+ const elRect = targetEl.getBoundingClientRect();
75955
+ const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
75956
+ const snapPos = closerToLeft ? spanStart : spanEnd;
75957
+ return snapPos;
75958
+ }
75959
+ const textNode = firstChild;
75960
+ const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
75961
+ const pos = spanStart + charIndex;
75962
+ return pos;
75963
+ }
75803
75964
  function findLineAtY(lineEls, viewY) {
75804
75965
  if (lineEls.length === 0) {
75805
75966
  return null;
@@ -78690,7 +78851,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
78690
78851
  return `img:${srcHash}:${imgRun.width}x${imgRun.height}`;
78691
78852
  }
78692
78853
  const text2 = normalizeText(
78693
- "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
78854
+ "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? ""
78694
78855
  );
78695
78856
  const bold = "bold" in run2 ? run2.bold : false;
78696
78857
  const italic = "italic" in run2 ? run2.italic : false;
@@ -79402,7 +79563,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79402
79563
  let pmStart = Infinity;
79403
79564
  let pmEnd = 0;
79404
79565
  for (const run2 of block.runs) {
79405
- text2 += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text;
79566
+ text2 += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text;
79406
79567
  if (run2.pmStart !== void 0) {
79407
79568
  pmStart = Math.min(pmStart, run2.pmStart);
79408
79569
  }
@@ -79452,7 +79613,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79452
79613
  return `${italic}${bold}${size2}px ${family}`.trim();
79453
79614
  }
79454
79615
  function runText(run2) {
79455
- return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
79616
+ return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
79456
79617
  }
79457
79618
  function measureRunSliceWidth(run2, fromChar, toChar) {
79458
79619
  const context = getCtx();
@@ -79614,7 +79775,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79614
79775
  for (let i2 = 0; i2 < a2.runs.length; i2 += 1) {
79615
79776
  const runA = a2.runs[i2];
79616
79777
  const runB = b2.runs[i2];
79617
- if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
79778
+ if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
79618
79779
  return false;
79619
79780
  }
79620
79781
  }
@@ -79734,7 +79895,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79734
79895
  parts.push(block.id);
79735
79896
  if (block.kind === "paragraph") {
79736
79897
  for (const run2 of block.runs) {
79737
- if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
79898
+ if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break" && run2.kind !== "fieldAnnotation") {
79738
79899
  parts.push(run2.text ?? "");
79739
79900
  }
79740
79901
  if ("bold" in run2 && run2.bold) parts.push("b");
@@ -80219,6 +80380,255 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80219
80380
  /** P3: Heavy debounce for full document layout */
80220
80381
  [Priority.P3]: 150
80221
80382
  });
80383
+ const DEFAULT_MIME_TYPE$1 = "application/x-field-annotation";
80384
+ const LEGACY_MIME_TYPE = "fieldAnnotation";
80385
+ function parseIntSafe(value) {
80386
+ if (!value) return void 0;
80387
+ const parsed = parseInt(value, 10);
80388
+ return Number.isFinite(parsed) ? parsed : void 0;
80389
+ }
80390
+ function extractFieldAnnotationData(element2) {
80391
+ const dataset = element2.dataset;
80392
+ const attributes = {};
80393
+ for (const key2 in dataset) {
80394
+ const value = dataset[key2];
80395
+ if (value !== void 0) {
80396
+ attributes[key2] = value;
80397
+ }
80398
+ }
80399
+ return {
80400
+ fieldId: dataset.fieldId,
80401
+ fieldType: dataset.fieldType,
80402
+ variant: dataset.variant ?? dataset.type,
80403
+ displayLabel: dataset.displayLabel,
80404
+ pmStart: parseIntSafe(dataset.pmStart),
80405
+ pmEnd: parseIntSafe(dataset.pmEnd),
80406
+ attributes
80407
+ };
80408
+ }
80409
+ class DragHandler {
80410
+ /**
80411
+ * Creates a new DragHandler instance.
80412
+ *
80413
+ * @param container - The DOM container element (typically .superdoc-layout)
80414
+ * @param config - Configuration options and callbacks
80415
+ */
80416
+ constructor(container, config2 = {}) {
80417
+ this.container = container;
80418
+ this.config = config2;
80419
+ this.mimeType = config2.mimeType ?? DEFAULT_MIME_TYPE$1;
80420
+ this.boundHandlers = {
80421
+ dragstart: this.handleDragStart.bind(this),
80422
+ dragover: this.handleDragOver.bind(this),
80423
+ drop: this.handleDrop.bind(this),
80424
+ dragend: this.handleDragEnd.bind(this),
80425
+ dragleave: this.handleDragLeave.bind(this)
80426
+ };
80427
+ this.windowDragoverHandler = this.handleWindowDragOver.bind(this);
80428
+ this.windowDropHandler = this.handleWindowDrop.bind(this);
80429
+ this.attachListeners();
80430
+ }
80431
+ /**
80432
+ * Attaches event listeners to the container and window.
80433
+ */
80434
+ attachListeners() {
80435
+ this.container.addEventListener("dragstart", this.boundHandlers.dragstart);
80436
+ this.container.addEventListener("dragover", this.boundHandlers.dragover);
80437
+ this.container.addEventListener("drop", this.boundHandlers.drop);
80438
+ this.container.addEventListener("dragend", this.boundHandlers.dragend);
80439
+ this.container.addEventListener("dragleave", this.boundHandlers.dragleave);
80440
+ window.addEventListener("dragover", this.windowDragoverHandler, false);
80441
+ window.addEventListener("drop", this.windowDropHandler, false);
80442
+ }
80443
+ /**
80444
+ * Removes event listeners from the container and window.
80445
+ */
80446
+ removeListeners() {
80447
+ this.container.removeEventListener("dragstart", this.boundHandlers.dragstart);
80448
+ this.container.removeEventListener("dragover", this.boundHandlers.dragover);
80449
+ this.container.removeEventListener("drop", this.boundHandlers.drop);
80450
+ this.container.removeEventListener("dragend", this.boundHandlers.dragend);
80451
+ this.container.removeEventListener("dragleave", this.boundHandlers.dragleave);
80452
+ window.removeEventListener("dragover", this.windowDragoverHandler, false);
80453
+ window.removeEventListener("drop", this.windowDropHandler, false);
80454
+ }
80455
+ /**
80456
+ * Handles dragover at window level to allow drops on overlay elements.
80457
+ * This ensures preventDefault is called even when dragging over selection
80458
+ * highlights or other UI elements that sit on top of the layout content.
80459
+ */
80460
+ handleWindowDragOver(event) {
80461
+ if (this.hasFieldAnnotationData(event)) {
80462
+ event.preventDefault();
80463
+ if (event.dataTransfer) {
80464
+ event.dataTransfer.dropEffect = "move";
80465
+ }
80466
+ const target = event.target;
80467
+ if (!this.container.contains(target)) {
80468
+ this.config.onDragOver?.({
80469
+ event,
80470
+ clientX: event.clientX,
80471
+ clientY: event.clientY,
80472
+ hasFieldAnnotation: true
80473
+ });
80474
+ }
80475
+ }
80476
+ }
80477
+ /**
80478
+ * Handles drop at window level to catch drops on overlay elements.
80479
+ * If the drop target is outside the container, we process it here.
80480
+ */
80481
+ handleWindowDrop(event) {
80482
+ if (this.hasFieldAnnotationData(event)) {
80483
+ const target = event.target;
80484
+ if (!this.container.contains(target)) {
80485
+ this.handleDrop(event);
80486
+ }
80487
+ }
80488
+ }
80489
+ /**
80490
+ * Handles the dragstart event.
80491
+ * Sets up dataTransfer with field annotation data and drag image.
80492
+ */
80493
+ handleDragStart(event) {
80494
+ const target = event.target;
80495
+ if (!target?.dataset?.draggable || target.dataset.draggable !== "true") {
80496
+ return;
80497
+ }
80498
+ const data = extractFieldAnnotationData(target);
80499
+ if (event.dataTransfer) {
80500
+ const jsonData = JSON.stringify({
80501
+ attributes: data.attributes,
80502
+ sourceField: data
80503
+ });
80504
+ event.dataTransfer.setData(this.mimeType, jsonData);
80505
+ event.dataTransfer.setData(LEGACY_MIME_TYPE, jsonData);
80506
+ event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
80507
+ event.dataTransfer.setDragImage(target, 0, 0);
80508
+ event.dataTransfer.effectAllowed = "move";
80509
+ }
80510
+ this.config.onDragStart?.({
80511
+ event,
80512
+ element: target,
80513
+ data
80514
+ });
80515
+ }
80516
+ /**
80517
+ * Handles the dragover event.
80518
+ * Provides visual feedback and determines if drop is allowed.
80519
+ */
80520
+ handleDragOver(event) {
80521
+ const hasFieldAnnotation = this.hasFieldAnnotationData(event);
80522
+ if (hasFieldAnnotation) {
80523
+ event.preventDefault();
80524
+ if (event.dataTransfer) {
80525
+ event.dataTransfer.dropEffect = "move";
80526
+ }
80527
+ this.container.classList.add("drag-over");
80528
+ }
80529
+ this.config.onDragOver?.({
80530
+ event,
80531
+ clientX: event.clientX,
80532
+ clientY: event.clientY,
80533
+ hasFieldAnnotation
80534
+ });
80535
+ }
80536
+ /**
80537
+ * Handles the dragleave event.
80538
+ * Removes visual feedback when drag leaves the container.
80539
+ */
80540
+ handleDragLeave(event) {
80541
+ const relatedTarget = event.relatedTarget;
80542
+ if (!relatedTarget || !this.container.contains(relatedTarget)) {
80543
+ this.container.classList.remove("drag-over");
80544
+ }
80545
+ }
80546
+ /**
80547
+ * Handles the drop event.
80548
+ * Maps drop coordinates to ProseMirror position and emits drop event.
80549
+ */
80550
+ handleDrop(event) {
80551
+ this.container.classList.remove("drag-over");
80552
+ if (!this.hasFieldAnnotationData(event)) {
80553
+ return;
80554
+ }
80555
+ event.preventDefault();
80556
+ const data = this.extractDragData(event);
80557
+ if (!data) {
80558
+ return;
80559
+ }
80560
+ const pmPosition = clickToPositionDom(this.container, event.clientX, event.clientY);
80561
+ this.config.onDrop?.({
80562
+ event,
80563
+ data,
80564
+ pmPosition,
80565
+ clientX: event.clientX,
80566
+ clientY: event.clientY
80567
+ });
80568
+ }
80569
+ /**
80570
+ * Handles the dragend event.
80571
+ * Cleans up drag state.
80572
+ */
80573
+ handleDragEnd(event) {
80574
+ this.container.classList.remove("drag-over");
80575
+ this.config.onDragEnd?.(event);
80576
+ }
80577
+ /**
80578
+ * Checks if a drag event contains field annotation data.
80579
+ */
80580
+ hasFieldAnnotationData(event) {
80581
+ if (!event.dataTransfer) {
80582
+ return false;
80583
+ }
80584
+ const types2 = event.dataTransfer.types;
80585
+ return types2.includes(this.mimeType) || types2.includes(LEGACY_MIME_TYPE);
80586
+ }
80587
+ /**
80588
+ * Extracts field annotation data from a drag event's dataTransfer.
80589
+ */
80590
+ extractDragData(event) {
80591
+ if (!event.dataTransfer) {
80592
+ return null;
80593
+ }
80594
+ let jsonData = event.dataTransfer.getData(this.mimeType);
80595
+ if (!jsonData) {
80596
+ jsonData = event.dataTransfer.getData(LEGACY_MIME_TYPE);
80597
+ }
80598
+ if (!jsonData) {
80599
+ return null;
80600
+ }
80601
+ try {
80602
+ const parsed = JSON.parse(jsonData);
80603
+ return parsed.sourceField ?? parsed.attributes ?? parsed;
80604
+ } catch {
80605
+ return null;
80606
+ }
80607
+ }
80608
+ /**
80609
+ * Updates the configuration options.
80610
+ *
80611
+ * @param config - New configuration options to merge
80612
+ */
80613
+ updateConfig(config2) {
80614
+ this.config = { ...this.config, ...config2 };
80615
+ if (config2.mimeType) {
80616
+ this.mimeType = config2.mimeType;
80617
+ }
80618
+ }
80619
+ /**
80620
+ * Destroys the drag handler and removes all event listeners.
80621
+ * Call this when the layout engine is unmounted or the container is removed.
80622
+ */
80623
+ destroy() {
80624
+ this.removeListeners();
80625
+ this.container.classList.remove("drag-over");
80626
+ }
80627
+ }
80628
+ function createDragHandler(container, config2 = {}) {
80629
+ const handler2 = new DragHandler(container, config2);
80630
+ return () => handler2.destroy();
80631
+ }
80222
80632
  const isAtomicFragment = (fragment) => {
80223
80633
  return fragment.kind === "drawing" || fragment.kind === "image";
80224
80634
  };
@@ -80757,7 +81167,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80757
81167
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
80758
81168
  const run2 = block.runs[runIndex];
80759
81169
  if (!run2) continue;
80760
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
81170
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
80761
81171
  const runLength = text2.length;
80762
81172
  const runPmStart = run2.pmStart ?? null;
80763
81173
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
@@ -80781,7 +81191,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80781
81191
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
80782
81192
  const run2 = block.runs[runIndex];
80783
81193
  if (!run2) continue;
80784
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
81194
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
80785
81195
  const runTextLength = text2.length;
80786
81196
  const runPmStart = run2.pmStart ?? null;
80787
81197
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runTextLength : null);
@@ -83313,10 +83723,228 @@ ${l}
83313
83723
  .superdoc-layout .track-format-dec.highlighted {
83314
83724
  border-bottom: 2px solid gold;
83315
83725
  }
83726
+ `;
83727
+ const SDT_CONTAINER_STYLES = `
83728
+ /* Document Section - Block-level container with gray border and hover tooltip */
83729
+ .superdoc-document-section {
83730
+ background-color: #fafafa;
83731
+ border: 1px solid #ababab;
83732
+ border-radius: 4px;
83733
+ position: relative;
83734
+ box-sizing: border-box;
83735
+ }
83736
+
83737
+ /* Document section tooltip - positioned above the fragment */
83738
+ .superdoc-document-section__tooltip {
83739
+ position: absolute;
83740
+ top: -19px;
83741
+ left: -1px;
83742
+ max-width: 100px;
83743
+ min-width: 0;
83744
+ height: 18px;
83745
+ border: 1px solid #ababab;
83746
+ border-bottom: none;
83747
+ border-radius: 6px 6px 0 0;
83748
+ padding: 0 8px;
83749
+ align-items: center;
83750
+ font-size: 10px;
83751
+ display: none;
83752
+ z-index: 100;
83753
+ background-color: #fafafa;
83754
+ pointer-events: none;
83755
+ }
83756
+
83757
+ .superdoc-document-section__tooltip span {
83758
+ max-width: 100%;
83759
+ overflow: hidden;
83760
+ white-space: nowrap;
83761
+ text-overflow: ellipsis;
83762
+ }
83763
+
83764
+ /* Show tooltip on hover - adjust border radius to connect with tooltip tab */
83765
+ .superdoc-document-section:hover {
83766
+ border-radius: 0 4px 4px 4px;
83767
+ }
83768
+
83769
+ .superdoc-document-section:hover .superdoc-document-section__tooltip {
83770
+ display: flex;
83771
+ align-items: center;
83772
+ }
83773
+
83774
+ /* Continuation styling: first fragment has top corners, last has bottom corners */
83775
+ .superdoc-document-section[data-sdt-container-start="true"] {
83776
+ border-radius: 4px 4px 0 0;
83777
+ }
83778
+
83779
+ .superdoc-document-section[data-sdt-container-end="true"] {
83780
+ border-radius: 0 0 4px 4px;
83781
+ }
83782
+
83783
+ .superdoc-document-section[data-sdt-container-start="true"][data-sdt-container-end="true"] {
83784
+ border-radius: 4px;
83785
+ }
83786
+
83787
+ .superdoc-document-section[data-sdt-container-start="true"]:hover {
83788
+ border-radius: 0 4px 0 0;
83789
+ }
83790
+
83791
+ /* Middle fragments have no border radius */
83792
+ .superdoc-document-section:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
83793
+ border-radius: 0;
83794
+ border-top: none;
83795
+ }
83796
+
83797
+ /* Structured Content Block - Blue border container */
83798
+ .superdoc-structured-content-block {
83799
+ padding: 1px;
83800
+ box-sizing: border-box;
83801
+ border-radius: 4px;
83802
+ border: 1px solid #629be7;
83803
+ position: relative;
83804
+ }
83805
+
83806
+ /* Structured content drag handle/label - positioned above */
83807
+ .superdoc-structured-content__label {
83808
+ font-size: 10px;
83809
+ align-items: center;
83810
+ justify-content: center;
83811
+ position: absolute;
83812
+ left: 2px;
83813
+ top: -19px;
83814
+ width: calc(100% - 4px);
83815
+ max-width: 110px;
83816
+ min-width: 0;
83817
+ height: 18px;
83818
+ padding: 0 4px;
83819
+ border: 1px solid #629be7;
83820
+ border-bottom: none;
83821
+ border-radius: 6px 6px 0 0;
83822
+ background-color: #629be7dd;
83823
+ box-sizing: border-box;
83824
+ z-index: 10;
83825
+ display: none;
83826
+ pointer-events: none;
83827
+ }
83828
+
83829
+ .superdoc-structured-content__label span {
83830
+ max-width: 100%;
83831
+ overflow: hidden;
83832
+ white-space: nowrap;
83833
+ text-overflow: ellipsis;
83834
+ }
83835
+
83836
+ .superdoc-structured-content-block:hover .superdoc-structured-content__label {
83837
+ display: inline-flex;
83838
+ }
83839
+
83840
+ /* Continuation styling for structured content blocks */
83841
+ .superdoc-structured-content-block[data-sdt-container-start="true"] {
83842
+ border-radius: 4px 4px 0 0;
83843
+ }
83844
+
83845
+ .superdoc-structured-content-block[data-sdt-container-end="true"] {
83846
+ border-radius: 0 0 4px 4px;
83847
+ }
83848
+
83849
+ .superdoc-structured-content-block[data-sdt-container-start="true"][data-sdt-container-end="true"] {
83850
+ border-radius: 4px;
83851
+ }
83852
+
83853
+ .superdoc-structured-content-block:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
83854
+ border-radius: 0;
83855
+ border-top: none;
83856
+ }
83857
+
83858
+ /* Structured Content Inline - Inline wrapper with blue border */
83859
+ .superdoc-structured-content-inline {
83860
+ padding: 1px;
83861
+ box-sizing: border-box;
83862
+ border-radius: 4px;
83863
+ border: 1px solid #629be7;
83864
+ position: relative;
83865
+ display: inline;
83866
+ }
83867
+
83868
+ /* Hover effect for inline structured content */
83869
+ .superdoc-structured-content-inline:hover {
83870
+ background-color: rgba(98, 155, 231, 0.15);
83871
+ border-color: #4a8ad9;
83872
+ }
83873
+
83874
+ /* Inline structured content label - shown on hover */
83875
+ .superdoc-structured-content-inline__label {
83876
+ position: absolute;
83877
+ bottom: calc(100% + 2px);
83878
+ left: 50%;
83879
+ transform: translateX(-50%);
83880
+ font-size: 10px;
83881
+ padding: 2px 6px;
83882
+ background-color: #629be7dd;
83883
+ color: white;
83884
+ border-radius: 4px;
83885
+ white-space: nowrap;
83886
+ z-index: 100;
83887
+ display: none;
83888
+ pointer-events: none;
83889
+ }
83890
+
83891
+ .superdoc-structured-content-inline:hover .superdoc-structured-content-inline__label {
83892
+ display: block;
83893
+ }
83894
+
83895
+ /* Print mode: hide visual styling for SDT containers */
83896
+ @media print {
83897
+ .superdoc-document-section,
83898
+ .superdoc-structured-content-block,
83899
+ .superdoc-structured-content-inline {
83900
+ background: none;
83901
+ border: none;
83902
+ padding: 0;
83903
+ }
83904
+
83905
+ .superdoc-document-section__tooltip,
83906
+ .superdoc-structured-content__label,
83907
+ .superdoc-structured-content-inline__label {
83908
+ display: none !important;
83909
+ }
83910
+ }
83911
+ `;
83912
+ const FIELD_ANNOTATION_STYLES = `
83913
+ /* Field annotation draggable styles */
83914
+ .superdoc-layout .annotation[data-draggable="true"] {
83915
+ cursor: grab;
83916
+ user-select: none;
83917
+ -webkit-user-select: none;
83918
+ }
83919
+
83920
+ .superdoc-layout .annotation[data-draggable="true"]:hover {
83921
+ opacity: 0.9;
83922
+ }
83923
+
83924
+ .superdoc-layout .annotation[data-draggable="true"]:active {
83925
+ cursor: grabbing;
83926
+ }
83927
+
83928
+ /* Drag over indicator for drop targets */
83929
+ .superdoc-layout.drag-over {
83930
+ outline: 2px dashed #b015b3;
83931
+ outline-offset: -2px;
83932
+ }
83933
+
83934
+ /* Drop zone indicator */
83935
+ .superdoc-layout .superdoc-drop-indicator {
83936
+ position: absolute;
83937
+ width: 2px;
83938
+ background-color: #b015b3;
83939
+ pointer-events: none;
83940
+ z-index: 1000;
83941
+ }
83316
83942
  `;
83317
83943
  let printStylesInjected = false;
83318
83944
  let linkStylesInjected = false;
83319
83945
  let trackChangeStylesInjected = false;
83946
+ let sdtContainerStylesInjected = false;
83947
+ let fieldAnnotationStylesInjected = false;
83320
83948
  const ensurePrintStyles = (doc2) => {
83321
83949
  if (printStylesInjected || !doc2) return;
83322
83950
  const styleEl = doc2.createElement("style");
@@ -83341,6 +83969,22 @@ ${l}
83341
83969
  doc2.head?.appendChild(styleEl);
83342
83970
  trackChangeStylesInjected = true;
83343
83971
  };
83972
+ const ensureSdtContainerStyles = (doc2) => {
83973
+ if (sdtContainerStylesInjected || !doc2) return;
83974
+ const styleEl = doc2.createElement("style");
83975
+ styleEl.setAttribute("data-superdoc-sdt-container-styles", "true");
83976
+ styleEl.textContent = SDT_CONTAINER_STYLES;
83977
+ doc2.head?.appendChild(styleEl);
83978
+ sdtContainerStylesInjected = true;
83979
+ };
83980
+ const ensureFieldAnnotationStyles = (doc2) => {
83981
+ if (fieldAnnotationStylesInjected || !doc2) return;
83982
+ const styleEl = doc2.createElement("style");
83983
+ styleEl.setAttribute("data-superdoc-field-annotation-styles", "true");
83984
+ styleEl.textContent = FIELD_ANNOTATION_STYLES;
83985
+ doc2.head?.appendChild(styleEl);
83986
+ fieldAnnotationStylesInjected = true;
83987
+ };
83344
83988
  const ALLOWED_BORDER_STYLES = /* @__PURE__ */ new Set([
83345
83989
  "none",
83346
83990
  "single",
@@ -83670,6 +84314,50 @@ ${l}
83670
84314
  container.appendChild(cellElement);
83671
84315
  }
83672
84316
  };
84317
+ function isStructuredContentMetadata(sdt) {
84318
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
84319
+ }
84320
+ function isDocumentSectionMetadata(sdt) {
84321
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "documentSection";
84322
+ }
84323
+ function getSdtContainerConfig(sdt) {
84324
+ if (isDocumentSectionMetadata(sdt)) {
84325
+ return {
84326
+ className: "superdoc-document-section",
84327
+ labelText: sdt.title ?? "Document section",
84328
+ labelClassName: "superdoc-document-section__tooltip",
84329
+ isStart: true,
84330
+ isEnd: true
84331
+ };
84332
+ }
84333
+ if (isStructuredContentMetadata(sdt) && sdt.scope === "block") {
84334
+ return {
84335
+ className: "superdoc-structured-content-block",
84336
+ labelText: sdt.alias ?? "Structured content",
84337
+ labelClassName: "superdoc-structured-content__label",
84338
+ isStart: true,
84339
+ isEnd: true
84340
+ };
84341
+ }
84342
+ return null;
84343
+ }
84344
+ function applySdtContainerStyling(doc2, container, sdt, containerSdt) {
84345
+ let config2 = getSdtContainerConfig(sdt);
84346
+ if (!config2 && containerSdt) {
84347
+ config2 = getSdtContainerConfig(containerSdt);
84348
+ }
84349
+ if (!config2) return;
84350
+ container.classList.add(config2.className);
84351
+ container.dataset.sdtContainerStart = String(config2.isStart);
84352
+ container.dataset.sdtContainerEnd = String(config2.isEnd);
84353
+ container.style.overflow = "visible";
84354
+ const labelEl = doc2.createElement("div");
84355
+ labelEl.className = config2.labelClassName;
84356
+ const labelText = doc2.createElement("span");
84357
+ labelText.textContent = config2.labelText;
84358
+ labelEl.appendChild(labelText);
84359
+ container.appendChild(labelEl);
84360
+ }
83673
84361
  const renderTableFragment = (deps) => {
83674
84362
  const { doc: doc2, fragment, blockLookup, context, renderLine, applyFragmentFrame, applySdtDataset, applyStyles: applyStyles2 } = deps;
83675
84363
  if (!doc2) {
@@ -83706,6 +84394,7 @@ ${l}
83706
84394
  applyFragmentFrame(container, fragment);
83707
84395
  container.style.height = `${fragment.height}px`;
83708
84396
  applySdtDataset(container, block.attrs?.sdt);
84397
+ applySdtContainerStyling(doc2, container, block.attrs?.sdt);
83709
84398
  container.classList.add("superdoc-table-fragment");
83710
84399
  if (fragment.metadata?.columnBoundaries) {
83711
84400
  const columnCount = measure.columnWidths.length;
@@ -84172,6 +84861,8 @@ ${l}
84172
84861
  ensurePrintStyles(doc2);
84173
84862
  ensureLinkStyles(doc2);
84174
84863
  ensureTrackChangeStyles(doc2);
84864
+ ensureFieldAnnotationStyles(doc2);
84865
+ ensureSdtContainerStyles(doc2);
84175
84866
  mount2.classList.add(CLASS_NAMES.container);
84176
84867
  if (this.mount && this.mount !== mount2) {
84177
84868
  this.resetState();
@@ -84694,7 +85385,8 @@ ${l}
84694
85385
  fragmentEl.classList.add(CLASS_NAMES.fragment);
84695
85386
  const isTocEntry = block.attrs?.isTocEntry;
84696
85387
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
84697
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
85388
+ const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
85389
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
84698
85390
  applyStyles$2(fragmentEl, styles);
84699
85391
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
84700
85392
  if (isTocEntry) {
@@ -84714,6 +85406,7 @@ ${l}
84714
85406
  }
84715
85407
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
84716
85408
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
85409
+ applySdtContainerStyling(this.doc, fragmentEl, block.attrs?.sdt, block.attrs?.containerSdt);
84717
85410
  const dropCapDescriptor = block.attrs?.dropCapDescriptor;
84718
85411
  const dropCapMeasure = measure.dropCap;
84719
85412
  if (dropCapDescriptor && dropCapMeasure && !fragment.continuesFromPrev) {
@@ -84932,6 +85625,7 @@ ${l}
84932
85625
  fragmentEl.dataset.itemId = fragment.itemId;
84933
85626
  const paragraphMetadata = item.paragraph.attrs?.sdt;
84934
85627
  this.applySdtDataset(fragmentEl, paragraphMetadata);
85628
+ applySdtContainerStyling(this.doc, fragmentEl, paragraphMetadata, item.paragraph.attrs?.containerSdt);
84935
85629
  if (fragment.continuesFromPrev) {
84936
85630
  fragmentEl.dataset.continuesFromPrev = "true";
84937
85631
  }
@@ -85703,10 +86397,19 @@ ${l}
85703
86397
  isBreakRun(run2) {
85704
86398
  return run2.kind === "break";
85705
86399
  }
86400
+ /**
86401
+ * Type guard to check if a run is a field annotation run.
86402
+ */
86403
+ isFieldAnnotationRun(run2) {
86404
+ return run2.kind === "fieldAnnotation";
86405
+ }
85706
86406
  renderRun(run2, context, trackedConfig) {
85707
86407
  if (this.isImageRun(run2)) {
85708
86408
  return this.renderImageRun(run2);
85709
86409
  }
86410
+ if (this.isFieldAnnotationRun(run2)) {
86411
+ return this.renderFieldAnnotationRun(run2);
86412
+ }
85710
86413
  if (this.isLineBreakRun(run2)) {
85711
86414
  return null;
85712
86415
  }
@@ -85843,6 +86546,200 @@ ${l}
85843
86546
  }
85844
86547
  return img2;
85845
86548
  }
86549
+ /**
86550
+ * Renders a FieldAnnotationRun as an inline "pill" element matching super-editor's visual appearance.
86551
+ *
86552
+ * Field annotations are styled inline elements that display form fields with:
86553
+ * - Outer span with border, border-radius, padding, and background color
86554
+ * - Inner span containing the displayLabel or type-specific content (image, link, etc.)
86555
+ *
86556
+ * @param run - The FieldAnnotationRun to render containing field configuration and styling
86557
+ * @returns HTMLElement (span) or null if document is not available
86558
+ *
86559
+ * @example
86560
+ * ```typescript
86561
+ * // Text variant
86562
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'text', displayLabel: 'Full Name', fieldColor: '#980043' })
86563
+ * // Returns: <span class="annotation" style="border: 2px solid #b015b3; ..."><span class="annotation-content">Full Name</span></span>
86564
+ *
86565
+ * // Image variant with imageSrc
86566
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'image', displayLabel: 'Photo', imageSrc: 'data:image/png;...' })
86567
+ * // Returns: <span class="annotation"><span class="annotation-content"><img src="..." /></span></span>
86568
+ *
86569
+ * // Link variant
86570
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'link', displayLabel: 'Website', linkUrl: 'https://example.com' })
86571
+ * // Returns: <span class="annotation"><span class="annotation-content"><a href="...">https://example.com</a></span></span>
86572
+ * ```
86573
+ */
86574
+ renderFieldAnnotationRun(run2) {
86575
+ if (!this.doc) {
86576
+ return null;
86577
+ }
86578
+ if (run2.hidden) {
86579
+ const hidden2 = this.doc.createElement("span");
86580
+ hidden2.style.display = "none";
86581
+ if (run2.pmStart != null) hidden2.dataset.pmStart = String(run2.pmStart);
86582
+ if (run2.pmEnd != null) hidden2.dataset.pmEnd = String(run2.pmEnd);
86583
+ return hidden2;
86584
+ }
86585
+ const defaultBorderColor = "#b015b3";
86586
+ const defaultFieldColor = "#980043";
86587
+ const annotation = this.doc.createElement("span");
86588
+ annotation.classList.add("annotation");
86589
+ annotation.setAttribute("aria-label", "Field annotation");
86590
+ const showHighlight = run2.highlighted !== false;
86591
+ if (showHighlight) {
86592
+ const borderColor = run2.borderColor || defaultBorderColor;
86593
+ annotation.style.border = `2px solid ${borderColor}`;
86594
+ annotation.style.borderRadius = "2px";
86595
+ annotation.style.padding = "1px 2px";
86596
+ annotation.style.boxSizing = "border-box";
86597
+ const fieldColor = run2.fieldColor || defaultFieldColor;
86598
+ const bgColor = fieldColor.length === 7 ? `${fieldColor}33` : fieldColor;
86599
+ if (run2.textHighlight) {
86600
+ annotation.style.backgroundColor = run2.textHighlight;
86601
+ } else {
86602
+ annotation.style.backgroundColor = bgColor;
86603
+ }
86604
+ }
86605
+ if (run2.visibility === "hidden") {
86606
+ annotation.style.visibility = "hidden";
86607
+ }
86608
+ if (run2.size) {
86609
+ if (run2.size.width) {
86610
+ annotation.style.width = `${run2.size.width}px`;
86611
+ annotation.style.display = "inline-block";
86612
+ annotation.style.overflow = "hidden";
86613
+ }
86614
+ if (run2.size.height) {
86615
+ annotation.style.height = `${run2.size.height}px`;
86616
+ }
86617
+ }
86618
+ if (run2.fontFamily) {
86619
+ annotation.style.fontFamily = run2.fontFamily;
86620
+ }
86621
+ if (run2.fontSize) {
86622
+ const fontSize2 = typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize;
86623
+ annotation.style.fontSize = fontSize2;
86624
+ }
86625
+ if (run2.textColor) {
86626
+ annotation.style.color = run2.textColor;
86627
+ }
86628
+ if (run2.bold) {
86629
+ annotation.style.fontWeight = "bold";
86630
+ }
86631
+ if (run2.italic) {
86632
+ annotation.style.fontStyle = "italic";
86633
+ }
86634
+ if (run2.underline) {
86635
+ annotation.style.textDecoration = "underline";
86636
+ }
86637
+ annotation.style.zIndex = "1";
86638
+ const content2 = this.doc.createElement("span");
86639
+ content2.classList.add("annotation-content");
86640
+ content2.style.pointerEvents = "none";
86641
+ content2.setAttribute("contenteditable", "false");
86642
+ switch (run2.variant) {
86643
+ case "image":
86644
+ case "signature": {
86645
+ if (run2.imageSrc) {
86646
+ const img2 = this.doc.createElement("img");
86647
+ const isDataUrl = run2.imageSrc.startsWith("data:");
86648
+ if (isDataUrl) {
86649
+ if (run2.imageSrc.length <= MAX_DATA_URL_LENGTH && VALID_IMAGE_DATA_URL.test(run2.imageSrc)) {
86650
+ img2.src = run2.imageSrc;
86651
+ } else {
86652
+ content2.textContent = run2.displayLabel;
86653
+ break;
86654
+ }
86655
+ } else {
86656
+ const sanitized = sanitizeHref(run2.imageSrc);
86657
+ if (sanitized) {
86658
+ img2.src = sanitized.href;
86659
+ } else {
86660
+ content2.textContent = run2.displayLabel;
86661
+ break;
86662
+ }
86663
+ }
86664
+ img2.alt = run2.displayLabel;
86665
+ img2.style.height = "auto";
86666
+ img2.style.maxWidth = "100%";
86667
+ img2.style.pointerEvents = "none";
86668
+ img2.style.verticalAlign = "middle";
86669
+ if (run2.variant === "signature") {
86670
+ img2.style.maxHeight = "28px";
86671
+ }
86672
+ content2.appendChild(img2);
86673
+ annotation.style.display = "inline-block";
86674
+ content2.style.display = "inline-block";
86675
+ } else {
86676
+ content2.textContent = run2.displayLabel || (run2.variant === "signature" ? "Signature" : "");
86677
+ }
86678
+ break;
86679
+ }
86680
+ case "link": {
86681
+ if (run2.linkUrl) {
86682
+ const link2 = this.doc.createElement("a");
86683
+ const sanitized = sanitizeHref(run2.linkUrl);
86684
+ if (sanitized) {
86685
+ link2.href = sanitized.href;
86686
+ link2.target = "_blank";
86687
+ link2.rel = "noopener noreferrer";
86688
+ link2.textContent = run2.linkUrl;
86689
+ link2.style.textDecoration = "none";
86690
+ content2.style.pointerEvents = "all";
86691
+ content2.appendChild(link2);
86692
+ } else {
86693
+ content2.textContent = run2.displayLabel;
86694
+ }
86695
+ } else {
86696
+ content2.textContent = run2.displayLabel;
86697
+ }
86698
+ break;
86699
+ }
86700
+ case "html": {
86701
+ if (run2.rawHtml && typeof run2.rawHtml === "string") {
86702
+ content2.textContent = run2.displayLabel;
86703
+ annotation.style.display = "inline-block";
86704
+ content2.style.display = "inline-block";
86705
+ } else {
86706
+ content2.textContent = run2.displayLabel;
86707
+ }
86708
+ break;
86709
+ }
86710
+ case "text":
86711
+ case "checkbox":
86712
+ default: {
86713
+ content2.textContent = run2.displayLabel;
86714
+ break;
86715
+ }
86716
+ }
86717
+ annotation.appendChild(content2);
86718
+ annotation.dataset.type = run2.variant;
86719
+ if (run2.fieldId) {
86720
+ annotation.dataset.fieldId = run2.fieldId;
86721
+ }
86722
+ if (run2.fieldType) {
86723
+ annotation.dataset.fieldType = run2.fieldType;
86724
+ }
86725
+ annotation.draggable = true;
86726
+ annotation.dataset.draggable = "true";
86727
+ if (run2.displayLabel) {
86728
+ annotation.dataset.displayLabel = run2.displayLabel;
86729
+ }
86730
+ if (run2.variant) {
86731
+ annotation.dataset.variant = run2.variant;
86732
+ }
86733
+ assertPmPositions(run2, "field annotation run");
86734
+ if (run2.pmStart != null) {
86735
+ annotation.dataset.pmStart = String(run2.pmStart);
86736
+ }
86737
+ if (run2.pmEnd != null) {
86738
+ annotation.dataset.pmEnd = String(run2.pmEnd);
86739
+ }
86740
+ this.applySdtDataset(annotation, run2.sdt);
86741
+ return annotation;
86742
+ }
85846
86743
  /**
85847
86744
  * Renders a single line of a paragraph block.
85848
86745
  *
@@ -86020,6 +86917,22 @@ ${l}
86020
86917
  if (this.isBreakRun(baseRun)) {
86021
86918
  continue;
86022
86919
  }
86920
+ if (this.isFieldAnnotationRun(baseRun)) {
86921
+ const elem = this.renderRun(baseRun, context, trackedConfig);
86922
+ if (elem) {
86923
+ if (styleId) {
86924
+ elem.setAttribute("styleid", styleId);
86925
+ }
86926
+ const runSegments2 = segmentsByRun.get(runIndex);
86927
+ const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
86928
+ const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
86929
+ elem.style.position = "absolute";
86930
+ elem.style.left = `${segX}px`;
86931
+ el.appendChild(elem);
86932
+ cumulativeX = segX + segWidth;
86933
+ }
86934
+ continue;
86935
+ }
86023
86936
  const runSegments = segmentsByRun.get(runIndex);
86024
86937
  if (!runSegments || runSegments.length === 0) {
86025
86938
  continue;
@@ -86065,7 +86978,22 @@ ${l}
86065
86978
  });
86066
86979
  }
86067
86980
  } else {
86981
+ let currentInlineSdtWrapper = null;
86982
+ let currentInlineSdtId = null;
86983
+ const closeCurrentWrapper = () => {
86984
+ if (currentInlineSdtWrapper) {
86985
+ el.appendChild(currentInlineSdtWrapper);
86986
+ currentInlineSdtWrapper = null;
86987
+ currentInlineSdtId = null;
86988
+ }
86989
+ };
86068
86990
  runsForLine.forEach((run2) => {
86991
+ const runSdt = run2.sdt;
86992
+ const isInlineSdt = runSdt?.type === "structuredContent" && runSdt?.scope === "inline";
86993
+ const runSdtId = isInlineSdt && runSdt?.id ? String(runSdt.id) : null;
86994
+ if (runSdtId !== currentInlineSdtId) {
86995
+ closeCurrentWrapper();
86996
+ }
86069
86997
  if (run2.kind === "tab") {
86070
86998
  const tabEl = this.doc.createElement("span");
86071
86999
  tabEl.classList.add("superdoc-tab");
@@ -86093,9 +87021,37 @@ ${l}
86093
87021
  if (styleId) {
86094
87022
  elem.setAttribute("styleid", styleId);
86095
87023
  }
86096
- el.appendChild(elem);
87024
+ if (isInlineSdt && runSdtId && this.doc) {
87025
+ if (!currentInlineSdtWrapper) {
87026
+ currentInlineSdtWrapper = this.doc.createElement("span");
87027
+ currentInlineSdtWrapper.className = "superdoc-structured-content-inline";
87028
+ currentInlineSdtId = runSdtId;
87029
+ this.applySdtDataset(currentInlineSdtWrapper, runSdt);
87030
+ const alias = runSdt?.alias || "Inline content";
87031
+ const labelEl = this.doc.createElement("span");
87032
+ labelEl.className = "superdoc-structured-content-inline__label";
87033
+ labelEl.textContent = alias;
87034
+ currentInlineSdtWrapper.appendChild(labelEl);
87035
+ }
87036
+ const wrapperPmStart = currentInlineSdtWrapper.dataset.pmStart;
87037
+ const wrapperPmEnd = currentInlineSdtWrapper.dataset.pmEnd;
87038
+ if (run2.pmStart != null) {
87039
+ if (!wrapperPmStart || run2.pmStart < parseInt(wrapperPmStart, 10)) {
87040
+ currentInlineSdtWrapper.dataset.pmStart = String(run2.pmStart);
87041
+ }
87042
+ }
87043
+ if (run2.pmEnd != null) {
87044
+ if (!wrapperPmEnd || run2.pmEnd > parseInt(wrapperPmEnd, 10)) {
87045
+ currentInlineSdtWrapper.dataset.pmEnd = String(run2.pmEnd);
87046
+ }
87047
+ }
87048
+ currentInlineSdtWrapper.appendChild(elem);
87049
+ } else {
87050
+ el.appendChild(elem);
87051
+ }
86097
87052
  }
86098
87053
  });
87054
+ closeCurrentWrapper();
86099
87055
  }
86100
87056
  const anchors = el.querySelectorAll("a[href]");
86101
87057
  anchors.forEach((anchor) => {
@@ -86603,7 +87559,7 @@ ${l}
86603
87559
  return block.id;
86604
87560
  };
86605
87561
  const applyRunStyles = (element2, run2, _isLink = false) => {
86606
- if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
87562
+ if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
86607
87563
  return;
86608
87564
  }
86609
87565
  element2.style.fontFamily = run2.fontFamily;
@@ -86763,6 +87719,10 @@ ${l}
86763
87719
  result.push(run2);
86764
87720
  continue;
86765
87721
  }
87722
+ if (run2.kind === "fieldAnnotation") {
87723
+ result.push(run2);
87724
+ continue;
87725
+ }
86766
87726
  if (!("text" in run2)) {
86767
87727
  continue;
86768
87728
  }
@@ -87078,6 +88038,10 @@ ${l}
87078
88038
  const TAB_EPSILON = 0.1;
87079
88039
  const DEFAULT_DECIMAL_SEPARATOR = ".";
87080
88040
  const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
88041
+ const FIELD_ANNOTATION_PILL_PADDING = 8;
88042
+ const FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2;
88043
+ const FIELD_ANNOTATION_VERTICAL_PADDING = 6;
88044
+ const DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16;
87081
88045
  const roundValue = (value) => value;
87082
88046
  function getCanvasContext() {
87083
88047
  if (!canvasContext) {
@@ -87157,6 +88121,9 @@ ${l}
87157
88121
  function isLineBreakRun(run2) {
87158
88122
  return run2.kind === "lineBreak";
87159
88123
  }
88124
+ function isFieldAnnotationRun(run2) {
88125
+ return run2.kind === "fieldAnnotation";
88126
+ }
87160
88127
  async function measureBlock(block, constraints) {
87161
88128
  const normalized = normalizeConstraints(constraints);
87162
88129
  if (block.kind === "drawing") {
@@ -87523,6 +88490,92 @@ ${l}
87523
88490
  lastAppliedTabAlign = null;
87524
88491
  continue;
87525
88492
  }
88493
+ if (isFieldAnnotationRun(run2)) {
88494
+ const displayText = run2.displayLabel || "";
88495
+ const annotationFontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
88496
+ const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
88497
+ const fontWeight = run2.bold ? "bold" : "normal";
88498
+ const fontStyle = run2.italic ? "italic" : "normal";
88499
+ const annotationFont = `${fontStyle} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
88500
+ ctx2.font = annotationFont;
88501
+ const textWidth = displayText ? ctx2.measureText(displayText).width : 0;
88502
+ const annotationWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
88503
+ const annotationHeight = annotationFontSize * FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER + FIELD_ANNOTATION_VERTICAL_PADDING;
88504
+ let annotationStartX;
88505
+ if (pendingTabAlignment && currentLine) {
88506
+ annotationStartX = alignPendingTabForWidth(annotationWidth);
88507
+ }
88508
+ if (!currentLine) {
88509
+ currentLine = {
88510
+ fromRun: runIndex,
88511
+ fromChar: 0,
88512
+ toRun: runIndex,
88513
+ toChar: 1,
88514
+ // Field annotations are atomic units
88515
+ width: annotationWidth,
88516
+ maxFontSize: annotationHeight,
88517
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
88518
+ segments: [
88519
+ {
88520
+ runIndex,
88521
+ fromChar: 0,
88522
+ toChar: 1,
88523
+ width: annotationWidth,
88524
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
88525
+ }
88526
+ ]
88527
+ };
88528
+ continue;
88529
+ }
88530
+ if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
88531
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
88532
+ const completedLine = {
88533
+ ...currentLine,
88534
+ ...metrics
88535
+ };
88536
+ addBarTabsToLine(completedLine);
88537
+ lines.push(completedLine);
88538
+ tabStopCursor = 0;
88539
+ pendingTabAlignment = null;
88540
+ lastAppliedTabAlign = null;
88541
+ currentLine = {
88542
+ fromRun: runIndex,
88543
+ fromChar: 0,
88544
+ toRun: runIndex,
88545
+ toChar: 1,
88546
+ width: annotationWidth,
88547
+ maxFontSize: annotationHeight,
88548
+ maxWidth: getEffectiveWidth(contentWidth),
88549
+ segments: [
88550
+ {
88551
+ runIndex,
88552
+ fromChar: 0,
88553
+ toChar: 1,
88554
+ width: annotationWidth
88555
+ }
88556
+ ]
88557
+ };
88558
+ } else {
88559
+ currentLine.toRun = runIndex;
88560
+ currentLine.toChar = 1;
88561
+ currentLine.width = roundValue(currentLine.width + annotationWidth);
88562
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, annotationHeight);
88563
+ if (!currentLine.segments) currentLine.segments = [];
88564
+ currentLine.segments.push({
88565
+ runIndex,
88566
+ fromChar: 0,
88567
+ toChar: 1,
88568
+ width: annotationWidth,
88569
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
88570
+ });
88571
+ }
88572
+ const tabAlign = lastAppliedTabAlign;
88573
+ if (tabAlign && currentLine && tabAlign.val === "end") {
88574
+ currentLine.width = roundValue(tabAlign.target);
88575
+ }
88576
+ lastAppliedTabAlign = null;
88577
+ continue;
88578
+ }
87526
88579
  if (!("text" in run2) || !("fontSize" in run2)) {
87527
88580
  continue;
87528
88581
  }
@@ -89487,6 +90540,12 @@ ${l}
89487
90540
  }
89488
90541
  return false;
89489
90542
  }
90543
+ function isValidFieldAnnotationAttributes(attrs) {
90544
+ if (!attrs || typeof attrs !== "object") return false;
90545
+ const a2 = attrs;
90546
+ return typeof a2.fieldId === "string" && typeof a2.fieldType === "string" && typeof a2.displayLabel === "string" && typeof a2.type === "string";
90547
+ }
90548
+ const FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation";
89490
90549
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
89491
90550
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
89492
90551
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -89512,6 +90571,7 @@ ${l}
89512
90571
  __privateAdd$1(this, _layoutOptions);
89513
90572
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
89514
90573
  __privateAdd$1(this, _domPainter, null);
90574
+ __privateAdd$1(this, _dragHandlerCleanup, null);
89515
90575
  __privateAdd$1(this, _layoutError, null);
89516
90576
  __privateAdd$1(this, _layoutErrorState, "healthy");
89517
90577
  __privateAdd$1(this, _errorBanner, null);
@@ -89570,8 +90630,12 @@ ${l}
89570
90630
  if (event.button !== 0) {
89571
90631
  return;
89572
90632
  }
90633
+ const target = event.target;
90634
+ const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
89573
90635
  if (!__privateGet$1(this, _layoutState).layout) {
89574
- event.preventDefault();
90636
+ if (!isDraggableAnnotation) {
90637
+ event.preventDefault();
90638
+ }
89575
90639
  if (document.activeElement instanceof HTMLElement) {
89576
90640
  document.activeElement.blur();
89577
90641
  }
@@ -89580,10 +90644,10 @@ ${l}
89580
90644
  return;
89581
90645
  }
89582
90646
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
89583
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
89584
- if (doc22) {
90647
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
90648
+ if (doc222) {
89585
90649
  try {
89586
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
90650
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
89587
90651
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89588
90652
  } catch (error) {
89589
90653
  if (process$1$1.env.NODE_ENV === "development") {
@@ -89619,7 +90683,7 @@ ${l}
89619
90683
  if (headerFooterRegion) {
89620
90684
  return;
89621
90685
  }
89622
- const hit = clickToPosition(
90686
+ const rawHit = clickToPosition(
89623
90687
  __privateGet$1(this, _layoutState).layout,
89624
90688
  __privateGet$1(this, _layoutState).blocks,
89625
90689
  __privateGet$1(this, _layoutState).measures,
@@ -89628,7 +90692,11 @@ ${l}
89628
90692
  event.clientX,
89629
90693
  event.clientY
89630
90694
  );
89631
- event.preventDefault();
90695
+ const doc22 = __privateGet$1(this, _editor3).state?.doc;
90696
+ const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
90697
+ if (!isDraggableAnnotation) {
90698
+ event.preventDefault();
90699
+ }
89632
90700
  if (!hit) {
89633
90701
  if (document.activeElement instanceof HTMLElement) {
89634
90702
  document.activeElement.blur();
@@ -89636,10 +90704,10 @@ ${l}
89636
90704
  const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
89637
90705
  if (editorDom2) {
89638
90706
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
89639
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
89640
- if (doc22) {
90707
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
90708
+ if (doc222) {
89641
90709
  try {
89642
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
90710
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
89643
90711
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89644
90712
  } catch (error) {
89645
90713
  if (process$1$1.env.NODE_ENV === "development") {
@@ -89660,9 +90728,9 @@ ${l}
89660
90728
  hit.pos
89661
90729
  );
89662
90730
  if (fragmentHit && (fragmentHit.fragment.kind === "image" || fragmentHit.fragment.kind === "drawing")) {
89663
- const doc22 = __privateGet$1(this, _editor3).state.doc;
90731
+ const doc222 = __privateGet$1(this, _editor3).state.doc;
89664
90732
  try {
89665
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc22, hit.pos));
90733
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc222, hit.pos));
89666
90734
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89667
90735
  if (__privateGet$1(this, _lastSelectedImageBlockId) && __privateGet$1(this, _lastSelectedImageBlockId) !== fragmentHit.fragment.blockId) {
89668
90736
  this.emit("imageDeselected", { blockId: __privateGet$1(this, _lastSelectedImageBlockId) });
@@ -89753,8 +90821,8 @@ ${l}
89753
90821
  }
89754
90822
  }
89755
90823
  if (!handledByDepth) {
89756
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
89757
90824
  try {
90825
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
89758
90826
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89759
90827
  } catch {
89760
90828
  }
@@ -89829,6 +90897,90 @@ ${l}
89829
90897
  }
89830
90898
  __privateSet(this, _isDragging, false);
89831
90899
  });
90900
+ __privateAdd$1(this, _handleDragOver, (event) => {
90901
+ const activeEditor = this.getActiveEditor();
90902
+ if (!activeEditor?.isEditable) {
90903
+ return;
90904
+ }
90905
+ event.preventDefault();
90906
+ if (event.dataTransfer) {
90907
+ event.dataTransfer.dropEffect = "copy";
90908
+ }
90909
+ const dt = event.dataTransfer;
90910
+ const hasFieldAnnotation = dt?.types?.includes(FIELD_ANNOTATION_DATA_TYPE) || Boolean(dt?.getData?.(FIELD_ANNOTATION_DATA_TYPE));
90911
+ if (!hasFieldAnnotation) {
90912
+ return;
90913
+ }
90914
+ const hit = this.hitTest(event.clientX, event.clientY);
90915
+ const doc22 = activeEditor.state?.doc;
90916
+ if (!hit || !doc22) {
90917
+ return;
90918
+ }
90919
+ const pos = Math.min(Math.max(hit.pos, 1), doc22.content.size);
90920
+ const currentSelection = activeEditor.state.selection;
90921
+ const isSameCursor = currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos;
90922
+ if (isSameCursor) {
90923
+ return;
90924
+ }
90925
+ try {
90926
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc22, pos)).setMeta("addToHistory", false);
90927
+ activeEditor.view?.dispatch(tr);
90928
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
90929
+ } catch (error) {
90930
+ if (process$1$1.env.NODE_ENV === "development") {
90931
+ console.debug("[PresentationEditor] Drag position update skipped:", error);
90932
+ }
90933
+ }
90934
+ });
90935
+ __privateAdd$1(this, _handleDrop, (event) => {
90936
+ const activeEditor = this.getActiveEditor();
90937
+ if (!activeEditor?.isEditable) {
90938
+ return;
90939
+ }
90940
+ if (event.dataTransfer?.types?.includes("application/x-field-annotation")) {
90941
+ return;
90942
+ }
90943
+ event.preventDefault();
90944
+ event.stopPropagation();
90945
+ const fieldAnnotationData = event.dataTransfer?.getData(FIELD_ANNOTATION_DATA_TYPE);
90946
+ if (!fieldAnnotationData) {
90947
+ return;
90948
+ }
90949
+ const hit = this.hitTest(event.clientX, event.clientY);
90950
+ const selection = activeEditor.state?.selection;
90951
+ const fallbackPos = selection?.from ?? activeEditor.state?.doc?.content.size ?? null;
90952
+ const pos = hit?.pos ?? fallbackPos;
90953
+ if (pos == null) {
90954
+ return;
90955
+ }
90956
+ let parsedData = null;
90957
+ try {
90958
+ parsedData = JSON.parse(fieldAnnotationData);
90959
+ } catch {
90960
+ return;
90961
+ }
90962
+ const { attributes, sourceField } = parsedData ?? {};
90963
+ activeEditor.emit?.("fieldAnnotationDropped", {
90964
+ sourceField,
90965
+ editor: activeEditor,
90966
+ coordinates: hit,
90967
+ pos
90968
+ });
90969
+ if (attributes && isValidFieldAnnotationAttributes(attributes)) {
90970
+ activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
90971
+ const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
90972
+ const tr = activeEditor.state?.tr.setSelection(TextSelection$1.create(activeEditor.state.doc, posAfter));
90973
+ if (tr) {
90974
+ activeEditor.view?.dispatch(tr);
90975
+ }
90976
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
90977
+ }
90978
+ const editorDom = activeEditor.view?.dom;
90979
+ if (editorDom) {
90980
+ editorDom.focus();
90981
+ activeEditor.view?.focus();
90982
+ }
90983
+ });
89832
90984
  __privateAdd$1(this, _handleDoubleClick, (event) => {
89833
90985
  if (event.button !== 0) return;
89834
90986
  if (!__privateGet$1(this, _layoutState).layout) return;
@@ -90018,6 +91170,7 @@ ${l}
90018
91170
  __privateMethod$1(this, _PresentationEditor_instances, applyZoom_fn).call(this);
90019
91171
  __privateMethod$1(this, _PresentationEditor_instances, setupEditorListeners_fn).call(this);
90020
91172
  __privateMethod$1(this, _PresentationEditor_instances, setupPointerHandlers_fn).call(this);
91173
+ __privateMethod$1(this, _PresentationEditor_instances, setupDragHandlers_fn).call(this);
90021
91174
  __privateMethod$1(this, _PresentationEditor_instances, setupInputBridge_fn).call(this);
90022
91175
  __privateMethod$1(this, _PresentationEditor_instances, syncTrackedChangesPreferences_fn).call(this);
90023
91176
  if (options.documentId) {
@@ -90729,6 +91882,7 @@ ${l}
90729
91882
  * Safe to call during partial initialization.
90730
91883
  */
90731
91884
  destroy() {
91885
+ var _a2;
90732
91886
  if (__privateGet$1(this, _rafHandle) != null) {
90733
91887
  __privateMethod$1(this, _PresentationEditor_instances, safeCleanup_fn).call(this, () => {
90734
91888
  const win = __privateGet$1(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
@@ -90750,6 +91904,8 @@ ${l}
90750
91904
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
90751
91905
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
90752
91906
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
91907
+ __privateGet$1(this, _viewportHost)?.removeEventListener("dragover", __privateGet$1(this, _handleDragOver));
91908
+ __privateGet$1(this, _viewportHost)?.removeEventListener("drop", __privateGet$1(this, _handleDrop));
90753
91909
  __privateGet$1(this, _visibleHost)?.removeEventListener("keydown", __privateGet$1(this, _handleKeyDown));
90754
91910
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
90755
91911
  __privateGet$1(this, _inputBridge)?.destroy();
@@ -90788,6 +91944,8 @@ ${l}
90788
91944
  __privateSet(this, _session, { mode: "body" });
90789
91945
  __privateSet(this, _activeHeaderFooterEditor, null);
90790
91946
  __privateSet(this, _domPainter, null);
91947
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
91948
+ __privateSet(this, _dragHandlerCleanup, null);
90791
91949
  __privateGet$1(this, _selectionOverlay2)?.remove();
90792
91950
  __privateGet$1(this, _painterHost)?.remove();
90793
91951
  __privateGet$1(this, _hiddenHost)?.remove();
@@ -90815,6 +91973,7 @@ ${l}
90815
91973
  _layoutOptions = /* @__PURE__ */ new WeakMap();
90816
91974
  _layoutState = /* @__PURE__ */ new WeakMap();
90817
91975
  _domPainter = /* @__PURE__ */ new WeakMap();
91976
+ _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
90818
91977
  _layoutError = /* @__PURE__ */ new WeakMap();
90819
91978
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
90820
91979
  _errorBanner = /* @__PURE__ */ new WeakMap();
@@ -91198,8 +92357,99 @@ ${l}
91198
92357
  __privateGet$1(this, _viewportHost).addEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
91199
92358
  __privateGet$1(this, _viewportHost).addEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
91200
92359
  __privateGet$1(this, _viewportHost).addEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
92360
+ __privateGet$1(this, _viewportHost).addEventListener("dragover", __privateGet$1(this, _handleDragOver));
92361
+ __privateGet$1(this, _viewportHost).addEventListener("drop", __privateGet$1(this, _handleDrop));
91201
92362
  __privateGet$1(this, _visibleHost).addEventListener("keydown", __privateGet$1(this, _handleKeyDown));
91202
92363
  };
92364
+ setupDragHandlers_fn = function() {
92365
+ var _a2;
92366
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
92367
+ __privateSet(this, _dragHandlerCleanup, null);
92368
+ __privateSet(this, _dragHandlerCleanup, createDragHandler(__privateGet$1(this, _painterHost), {
92369
+ onDragOver: (event) => {
92370
+ if (!event.hasFieldAnnotation || event.event.clientX === 0) {
92371
+ return;
92372
+ }
92373
+ const activeEditor = this.getActiveEditor();
92374
+ if (!activeEditor?.isEditable) {
92375
+ return;
92376
+ }
92377
+ const hit = this.hitTest(event.clientX, event.clientY);
92378
+ const doc2 = activeEditor.state?.doc;
92379
+ if (!hit || !doc2) {
92380
+ return;
92381
+ }
92382
+ const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
92383
+ const currentSelection = activeEditor.state.selection;
92384
+ if (currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos) {
92385
+ return;
92386
+ }
92387
+ try {
92388
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc2, pos)).setMeta("addToHistory", false);
92389
+ activeEditor.view?.dispatch(tr);
92390
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
92391
+ } catch {
92392
+ }
92393
+ },
92394
+ onDrop: (event) => {
92395
+ event.event.preventDefault();
92396
+ event.event.stopPropagation();
92397
+ if (event.pmPosition === null) {
92398
+ return;
92399
+ }
92400
+ const activeEditor = this.getActiveEditor();
92401
+ const { state: state2, view } = activeEditor;
92402
+ if (!state2 || !view) {
92403
+ return;
92404
+ }
92405
+ const fieldId = event.data.fieldId;
92406
+ if (fieldId) {
92407
+ const targetPos = event.pmPosition;
92408
+ let sourceStart = null;
92409
+ let sourceEnd = null;
92410
+ let sourceNode = null;
92411
+ state2.doc.descendants((node2, pos) => {
92412
+ if (node2.type.name === "fieldAnnotation" && node2.attrs.fieldId === fieldId) {
92413
+ sourceStart = pos;
92414
+ sourceEnd = pos + node2.nodeSize;
92415
+ sourceNode = node2;
92416
+ return false;
92417
+ }
92418
+ return true;
92419
+ });
92420
+ if (sourceStart === null || sourceEnd === null || !sourceNode) {
92421
+ return;
92422
+ }
92423
+ if (targetPos >= sourceStart && targetPos <= sourceEnd) {
92424
+ return;
92425
+ }
92426
+ const tr = state2.tr;
92427
+ tr.delete(sourceStart, sourceEnd);
92428
+ const mappedTarget = tr.mapping.map(targetPos);
92429
+ if (mappedTarget < 0 || mappedTarget > tr.doc.content.size) {
92430
+ return;
92431
+ }
92432
+ tr.insert(mappedTarget, sourceNode);
92433
+ tr.setMeta("uiEvent", "drop");
92434
+ view.dispatch(tr);
92435
+ return;
92436
+ }
92437
+ const attrs = event.data.attributes;
92438
+ if (attrs && isValidFieldAnnotationAttributes(attrs)) {
92439
+ const inserted = activeEditor.commands?.addFieldAnnotation?.(event.pmPosition, attrs, true);
92440
+ if (inserted) {
92441
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
92442
+ }
92443
+ return;
92444
+ }
92445
+ activeEditor.emit("fieldAnnotationDropped", {
92446
+ sourceField: event.data,
92447
+ editor: activeEditor,
92448
+ coordinates: { pos: event.pmPosition }
92449
+ });
92450
+ }
92451
+ }));
92452
+ };
91203
92453
  setupInputBridge_fn = function() {
91204
92454
  __privateGet$1(this, _inputBridge)?.destroy();
91205
92455
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
@@ -91417,6 +92667,8 @@ ${l}
91417
92667
  _handlePointerMove = /* @__PURE__ */ new WeakMap();
91418
92668
  _handlePointerLeave = /* @__PURE__ */ new WeakMap();
91419
92669
  _handlePointerUp = /* @__PURE__ */ new WeakMap();
92670
+ _handleDragOver = /* @__PURE__ */ new WeakMap();
92671
+ _handleDrop = /* @__PURE__ */ new WeakMap();
91420
92672
  _handleDoubleClick = /* @__PURE__ */ new WeakMap();
91421
92673
  _handleKeyDown = /* @__PURE__ */ new WeakMap();
91422
92674
  focusHeaderFooterShortcut_fn = function(kind) {
@@ -146148,7 +147400,7 @@ ${style2}
146148
147400
  this.config.colors = shuffleArray(this.config.colors);
146149
147401
  this.userColorMap = /* @__PURE__ */ new Map();
146150
147402
  this.colorIndex = 0;
146151
- this.version = "1.0.0-beta.31";
147403
+ this.version = "1.0.0-beta.32";
146152
147404
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
146153
147405
  this.superdocId = config2.superdocId || v4();
146154
147406
  this.colors = this.config.colors;
@@ -148592,7 +149844,7 @@ ${style2}
148592
149844
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
148593
149845
  );
148594
149846
  }
148595
- const indexEGVYUeN = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
149847
+ const indexSGV4U12y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
148596
149848
  __proto__: null,
148597
149849
  unified
148598
149850
  }, Symbol.toStringTag, { value: "Module" }));