@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
@@ -41841,7 +41841,7 @@ const _SuperConverter = class _SuperConverter2 {
41841
41841
  static getStoredSuperdocVersion(docx) {
41842
41842
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
41843
41843
  }
41844
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.31") {
41844
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.32") {
41845
41845
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
41846
41846
  }
41847
41847
  /**
@@ -45147,7 +45147,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45147
45147
  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);
45148
45148
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45149
45149
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45150
- 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;
45150
+ 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;
45151
45151
  var GOOD_LEAF_SIZE = 200;
45152
45152
  var RopeSequence = function RopeSequence2() {
45153
45153
  };
@@ -59014,7 +59014,7 @@ const isHeadless = (editor) => {
59014
59014
  const shouldSkipNodeView = (editor) => {
59015
59015
  return isHeadless(editor);
59016
59016
  };
59017
- const summaryVersion = "1.0.0-beta.31";
59017
+ const summaryVersion = "1.0.0-beta.32";
59018
59018
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59019
59019
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59020
59020
  function mapAttributes(attrs) {
@@ -59803,7 +59803,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
59803
59803
  { default: remarkStringify },
59804
59804
  { default: remarkGfm }
59805
59805
  ] = await Promise.all([
59806
- import("./index-eG-VYUeN-CIuOnW8W.es.js"),
59806
+ import("./index-SGV4U12y-BPGxOtvI.es.js"),
59807
59807
  import("./index-DRCvimau-Cw339678.es.js"),
59808
59808
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
59809
59809
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60008,7 +60008,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60008
60008
  * Process collaboration migrations
60009
60009
  */
60010
60010
  processCollaborationMigrations() {
60011
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.31");
60011
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.32");
60012
60012
  if (!this.options.ydoc) return;
60013
60013
  const metaMap = this.options.ydoc.getMap("meta");
60014
60014
  let docVersion = metaMap.get("version");
@@ -65150,7 +65150,27 @@ function handleStructuredContentBlockNode(node, context) {
65150
65150
  blocks.push(block);
65151
65151
  recordBlockKind(block.kind);
65152
65152
  });
65153
- } else if (child.type === "table") ;
65153
+ } else if (child.type === "table") {
65154
+ const tableNodeToBlock2 = converters?.tableNodeToBlock;
65155
+ if (tableNodeToBlock2) {
65156
+ const tableBlock = tableNodeToBlock2(
65157
+ child,
65158
+ nextBlockId,
65159
+ positions,
65160
+ defaultFont,
65161
+ defaultSize,
65162
+ styleContext,
65163
+ trackedChangesConfig,
65164
+ bookmarks,
65165
+ hyperlinkConfig
65166
+ );
65167
+ if (tableBlock) {
65168
+ applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
65169
+ blocks.push(tableBlock);
65170
+ recordBlockKind(tableBlock.kind);
65171
+ }
65172
+ }
65173
+ }
65154
65174
  });
65155
65175
  }
65156
65176
  function processParagraphChild(child, sectionMetadata, context, output, converters) {
@@ -65620,6 +65640,65 @@ function imageNodeToRun(node, positions, activeSdt) {
65620
65640
  }
65621
65641
  return run2;
65622
65642
  }
65643
+ function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
65644
+ const attrs = node.attrs ?? {};
65645
+ const rawVariant = attrs.type ?? fieldMetadata?.variant ?? "text";
65646
+ const validVariants = ["text", "image", "signature", "checkbox", "html", "link"];
65647
+ const variant = validVariants.includes(rawVariant) ? rawVariant : "text";
65648
+ 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) || "";
65649
+ const run2 = {
65650
+ kind: "fieldAnnotation",
65651
+ variant,
65652
+ displayLabel
65653
+ };
65654
+ const fieldId = typeof attrs.fieldId === "string" ? attrs.fieldId : fieldMetadata?.fieldId;
65655
+ if (fieldId) run2.fieldId = fieldId;
65656
+ const fieldType = typeof attrs.fieldType === "string" ? attrs.fieldType : fieldMetadata?.fieldType;
65657
+ if (fieldType) run2.fieldType = fieldType;
65658
+ const fieldColor = typeof attrs.fieldColor === "string" ? attrs.fieldColor : fieldMetadata?.fieldColor;
65659
+ if (fieldColor) run2.fieldColor = fieldColor;
65660
+ const borderColor = typeof attrs.borderColor === "string" ? attrs.borderColor : fieldMetadata?.borderColor;
65661
+ if (borderColor) run2.borderColor = borderColor;
65662
+ const highlighted = attrs.highlighted ?? fieldMetadata?.highlighted;
65663
+ if (highlighted === false) run2.highlighted = false;
65664
+ if (attrs.hidden === true || fieldMetadata?.hidden === true) run2.hidden = true;
65665
+ const visibility = attrs.visibility ?? fieldMetadata?.visibility;
65666
+ if (visibility === "hidden") run2.visibility = "hidden";
65667
+ const imageSrc = typeof attrs.imageSrc === "string" ? attrs.imageSrc : fieldMetadata?.imageSrc;
65668
+ if (imageSrc) run2.imageSrc = imageSrc;
65669
+ const linkUrl = typeof attrs.linkUrl === "string" ? attrs.linkUrl : fieldMetadata?.linkUrl;
65670
+ if (linkUrl) run2.linkUrl = linkUrl;
65671
+ const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
65672
+ if (typeof rawHtml === "string") run2.rawHtml = rawHtml;
65673
+ const size2 = attrs.size ?? fieldMetadata?.size;
65674
+ if (size2 && (typeof size2.width === "number" || typeof size2.height === "number")) {
65675
+ run2.size = {
65676
+ width: typeof size2.width === "number" ? size2.width : void 0,
65677
+ height: typeof size2.height === "number" ? size2.height : void 0
65678
+ };
65679
+ }
65680
+ const fontFamily2 = attrs.fontFamily ?? fieldMetadata?.fontFamily;
65681
+ if (typeof fontFamily2 === "string") run2.fontFamily = fontFamily2;
65682
+ const fontSize2 = attrs.fontSize ?? fieldMetadata?.fontSize;
65683
+ if (typeof fontSize2 === "string" || typeof fontSize2 === "number") run2.fontSize = fontSize2;
65684
+ const textColor = attrs.textColor ?? fieldMetadata?.textColor;
65685
+ if (typeof textColor === "string") run2.textColor = textColor;
65686
+ const textHighlight = attrs.textHighlight ?? fieldMetadata?.textHighlight;
65687
+ if (typeof textHighlight === "string") run2.textHighlight = textHighlight;
65688
+ const formatting = fieldMetadata?.formatting;
65689
+ if (attrs.bold === true || formatting?.bold === true) run2.bold = true;
65690
+ if (attrs.italic === true || formatting?.italic === true) run2.italic = true;
65691
+ if (attrs.underline === true || formatting?.underline === true) run2.underline = true;
65692
+ const pos = positions.get(node);
65693
+ if (pos) {
65694
+ run2.pmStart = pos.start;
65695
+ run2.pmEnd = pos.end;
65696
+ }
65697
+ if (fieldMetadata) {
65698
+ run2.sdt = fieldMetadata;
65699
+ }
65700
+ return run2;
65701
+ }
65623
65702
  const isTextRun$1 = (run2) => run2.kind !== "tab";
65624
65703
  const dataAttrsCompatible = (a, b2) => {
65625
65704
  const aAttrs = a.dataAttrs;
@@ -65915,28 +65994,20 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
65915
65994
  }
65916
65995
  if (node.type === "fieldAnnotation") {
65917
65996
  const fieldMetadata = resolveNodeSdtMetadata(node, "fieldAnnotation");
65997
+ let contentText;
65918
65998
  if (Array.isArray(node.content) && node.content.length > 0) {
65919
- node.content.forEach((child) => visitNode(child, inheritedMarks, fieldMetadata ?? activeSdt, activeRunStyleId));
65920
- } else {
65921
- const nodeAttrs = typeof node.attrs === "object" && node.attrs !== null ? node.attrs : {};
65922
- 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) || "";
65923
- if (label && typeof label === "string") {
65924
- const run2 = textNodeToRun(
65925
- { type: "text", text: label },
65926
- positions,
65927
- defaultFont,
65928
- defaultSize,
65929
- inheritedMarks,
65930
- fieldMetadata ?? activeSdt,
65931
- hyperlinkConfig,
65932
- themeColors
65933
- );
65934
- const inlineStyleId = getInlineStyleId(inheritedMarks);
65935
- applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
65936
- applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
65937
- currentRuns.push(run2);
65938
- }
65999
+ const extractText = (n) => {
66000
+ if (n.type === "text" && typeof n.text === "string") return n.text;
66001
+ if (Array.isArray(n.content)) {
66002
+ return n.content.map(extractText).join("");
66003
+ }
66004
+ return "";
66005
+ };
66006
+ contentText = node.content.map(extractText).join("");
65939
66007
  }
66008
+ const nodeForRun = contentText && contentText.length > 0 ? { ...node, attrs: { ...node.attrs ?? {}, displayLabel: contentText } } : node;
66009
+ const run2 = fieldAnnotationNodeToRun(nodeForRun, positions, fieldMetadata);
66010
+ currentRuns.push(run2);
65940
66011
  return;
65941
66012
  }
65942
66013
  if (node.type === "pageReference") {
@@ -66773,9 +66844,9 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
66773
66844
  }
66774
66845
  const attrs = spacingEl.attributes;
66775
66846
  const spacing = {};
66776
- const before = parseIntSafe(attrs["w:before"]);
66777
- const after = parseIntSafe(attrs["w:after"]);
66778
- const line = parseIntSafe(attrs["w:line"]);
66847
+ const before = parseIntSafe$1(attrs["w:before"]);
66848
+ const after = parseIntSafe$1(attrs["w:after"]);
66849
+ const line = parseIntSafe$1(attrs["w:line"]);
66779
66850
  const rawLineRule = attrs["w:lineRule"];
66780
66851
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
66781
66852
  if (before != null) spacing.before = twipsToPx$1(before);
@@ -66790,11 +66861,11 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
66790
66861
  if (lineRule) spacing.lineRule = lineRule;
66791
66862
  const result = Object.keys(spacing).length > 0 ? { spacing } : void 0;
66792
66863
  return result;
66793
- } catch (err) {
66864
+ } catch {
66794
66865
  return void 0;
66795
66866
  }
66796
66867
  };
66797
- const parseIntSafe = (value) => {
66868
+ const parseIntSafe$1 = (value) => {
66798
66869
  if (value == null) return void 0;
66799
66870
  const num = typeof value === "number" ? value : parseInt(String(value), 10);
66800
66871
  return Number.isFinite(num) ? num : void 0;
@@ -67446,7 +67517,7 @@ function getMeasurementContext() {
67446
67517
  return measurementCtx;
67447
67518
  }
67448
67519
  function getRunFontString(run2) {
67449
- if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
67520
+ if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
67450
67521
  return "normal normal 16px Arial";
67451
67522
  }
67452
67523
  const style2 = run2.italic ? "italic" : "normal";
@@ -67477,6 +67548,10 @@ function sliceRunsForLine$1(block, line) {
67477
67548
  result.push(run2);
67478
67549
  continue;
67479
67550
  }
67551
+ if (run2.kind === "fieldAnnotation") {
67552
+ result.push(run2);
67553
+ continue;
67554
+ }
67480
67555
  const text = run2.text ?? "";
67481
67556
  const isFirstRun = runIndex === line.fromRun;
67482
67557
  const isLastRun = runIndex === line.toRun;
@@ -67510,7 +67585,8 @@ function measureCharacterX(block, line, charOffset) {
67510
67585
  1,
67511
67586
  runs2.reduce((sum, run2) => {
67512
67587
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
67513
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
67588
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
67589
+ return sum;
67514
67590
  return sum + (run2.text ?? "").length;
67515
67591
  }, 0)
67516
67592
  );
@@ -67531,7 +67607,7 @@ function measureCharacterX(block, line, charOffset) {
67531
67607
  currentCharOffset += runLength2;
67532
67608
  continue;
67533
67609
  }
67534
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67610
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67535
67611
  const runLength = text.length;
67536
67612
  if (currentCharOffset + runLength >= charOffset) {
67537
67613
  const offsetInRun = charOffset - currentCharOffset;
@@ -67574,7 +67650,7 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
67574
67650
  if (isTabRun$1(run2)) {
67575
67651
  return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
67576
67652
  }
67577
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
67653
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
67578
67654
  return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
67579
67655
  }
67580
67656
  const text = run2.text ?? "";
@@ -67603,7 +67679,7 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
67603
67679
  let lastPm = fallbackPmStart;
67604
67680
  for (const run2 of runs) {
67605
67681
  const isTab = isTabRun$1(run2);
67606
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67682
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67607
67683
  const runLength = isTab ? TAB_CHAR_LENGTH : text.length;
67608
67684
  const runPmStart = typeof run2.pmStart === "number" ? run2.pmStart : null;
67609
67685
  const runPmEnd = typeof run2.pmEnd === "number" ? run2.pmEnd : runPmStart != null ? runPmStart + runLength : null;
@@ -67629,7 +67705,8 @@ function findCharacterAtX(block, line, x2, pmStart) {
67629
67705
  1,
67630
67706
  runs2.reduce((sum, run2) => {
67631
67707
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
67632
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
67708
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
67709
+ return sum;
67633
67710
  return sum + (run2.text ?? "").length;
67634
67711
  }, 0)
67635
67712
  );
@@ -67664,7 +67741,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
67664
67741
  currentCharOffset += TAB_CHAR_LENGTH;
67665
67742
  continue;
67666
67743
  }
67667
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67744
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67668
67745
  const runLength = text.length;
67669
67746
  if (runLength === 0) continue;
67670
67747
  ctx2.font = getRunFontString(run2);
@@ -67704,7 +67781,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
67704
67781
  };
67705
67782
  }
67706
67783
  const computeLetterSpacingWidth = (run2, precedingChars, runLength) => {
67707
- if (isTabRun$1(run2) || "src" in run2 || !("letterSpacing" in run2) || !run2.letterSpacing) {
67784
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "fieldAnnotation" || !("letterSpacing" in run2) || !run2.letterSpacing) {
67708
67785
  return 0;
67709
67786
  }
67710
67787
  const maxGaps = Math.max(runLength - 1, 0);
@@ -67801,6 +67878,17 @@ function clickToPositionDom(domContainer, clientX, clientY) {
67801
67878
  pmStart: fragmentEl.dataset.pmStart,
67802
67879
  pmEnd: fragmentEl.dataset.pmEnd
67803
67880
  });
67881
+ const hitChainLine = hitChain.find(
67882
+ (el) => el.classList?.contains?.(CLASS_NAMES$1.line) && el.dataset?.pmStart !== void 0 && el.dataset?.pmEnd !== void 0
67883
+ );
67884
+ if (hitChainLine) {
67885
+ log("Using hit chain line directly:", {
67886
+ pmStart: hitChainLine.dataset.pmStart,
67887
+ pmEnd: hitChainLine.dataset.pmEnd
67888
+ });
67889
+ const result2 = processLineElement(hitChainLine, viewX);
67890
+ return result2;
67891
+ }
67804
67892
  const result = processFragment(fragmentEl, viewX, viewY);
67805
67893
  return result;
67806
67894
  }
@@ -67866,7 +67954,9 @@ function processFragment(fragmentEl, viewX, viewY) {
67866
67954
  if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
67867
67955
  return null;
67868
67956
  }
67869
- const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
67957
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
67958
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
67959
+ );
67870
67960
  log(
67871
67961
  "Spans/anchors in line:",
67872
67962
  spanEls.map((el, i) => {
@@ -67925,6 +68015,77 @@ function processFragment(fragmentEl, viewX, viewY) {
67925
68015
  const pos = spanStart + charIndex;
67926
68016
  return pos;
67927
68017
  }
68018
+ function processLineElement(lineEl, viewX) {
68019
+ const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
68020
+ const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
68021
+ const lineRect = lineEl.getBoundingClientRect();
68022
+ log("processLineElement:", {
68023
+ pmStart: lineStart,
68024
+ pmEnd: lineEnd,
68025
+ rect: { top: lineRect.top, bottom: lineRect.bottom, left: lineRect.left, right: lineRect.right }
68026
+ });
68027
+ if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
68028
+ return null;
68029
+ }
68030
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
68031
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
68032
+ );
68033
+ log(
68034
+ "Spans/anchors in line:",
68035
+ spanEls.map((el, i) => {
68036
+ const rect = el.getBoundingClientRect();
68037
+ return {
68038
+ index: i,
68039
+ tag: el.tagName,
68040
+ pmStart: el.dataset.pmStart,
68041
+ pmEnd: el.dataset.pmEnd,
68042
+ text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
68043
+ visibility: el.style.visibility,
68044
+ rect: { left: rect.left, right: rect.right, width: rect.width }
68045
+ };
68046
+ })
68047
+ );
68048
+ if (spanEls.length === 0) {
68049
+ return lineStart;
68050
+ }
68051
+ const firstRect = spanEls[0].getBoundingClientRect();
68052
+ if (viewX <= firstRect.left) {
68053
+ return lineStart;
68054
+ }
68055
+ const lastRect = spanEls[spanEls.length - 1].getBoundingClientRect();
68056
+ if (viewX >= lastRect.right) {
68057
+ return lineEnd;
68058
+ }
68059
+ const targetEl = findSpanAtX(spanEls, viewX);
68060
+ if (!targetEl) {
68061
+ return lineStart;
68062
+ }
68063
+ const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
68064
+ const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
68065
+ const targetRect = targetEl.getBoundingClientRect();
68066
+ log("Target element:", {
68067
+ tag: targetEl.tagName,
68068
+ pmStart: spanStart,
68069
+ pmEnd: spanEnd,
68070
+ text: targetEl.textContent?.substring(0, 30),
68071
+ visibility: targetEl.style.visibility,
68072
+ rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
68073
+ });
68074
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
68075
+ return null;
68076
+ }
68077
+ const firstChild = targetEl.firstChild;
68078
+ if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
68079
+ const elRect = targetEl.getBoundingClientRect();
68080
+ const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
68081
+ const snapPos = closerToLeft ? spanStart : spanEnd;
68082
+ return snapPos;
68083
+ }
68084
+ const textNode = firstChild;
68085
+ const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
68086
+ const pos = spanStart + charIndex;
68087
+ return pos;
68088
+ }
67928
68089
  function findLineAtY(lineEls, viewY) {
67929
68090
  if (lineEls.length === 0) {
67930
68091
  return null;
@@ -70815,7 +70976,7 @@ const hashRuns = (block) => {
70815
70976
  return `img:${srcHash}:${imgRun.width}x${imgRun.height}`;
70816
70977
  }
70817
70978
  const text = normalizeText(
70818
- "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
70979
+ "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? ""
70819
70980
  );
70820
70981
  const bold = "bold" in run2 ? run2.bold : false;
70821
70982
  const italic = "italic" in run2 ? run2.italic : false;
@@ -71527,7 +71688,7 @@ function extractBlockText(block) {
71527
71688
  let pmStart = Infinity;
71528
71689
  let pmEnd = 0;
71529
71690
  for (const run2 of block.runs) {
71530
- text += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text;
71691
+ text += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text;
71531
71692
  if (run2.pmStart !== void 0) {
71532
71693
  pmStart = Math.min(pmStart, run2.pmStart);
71533
71694
  }
@@ -71577,7 +71738,7 @@ function fontString(run2) {
71577
71738
  return `${italic}${bold}${size2}px ${family}`.trim();
71578
71739
  }
71579
71740
  function runText(run2) {
71580
- return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
71741
+ return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
71581
71742
  }
71582
71743
  function measureRunSliceWidth(run2, fromChar, toChar) {
71583
71744
  const context = getCtx();
@@ -71739,7 +71900,7 @@ const paragraphBlocksEqual = (a, b2) => {
71739
71900
  for (let i = 0; i < a.runs.length; i += 1) {
71740
71901
  const runA = a.runs[i];
71741
71902
  const runB = b2.runs[i];
71742
- 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)) {
71903
+ 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)) {
71743
71904
  return false;
71744
71905
  }
71745
71906
  }
@@ -71859,7 +72020,7 @@ function computeHeaderFooterContentHash(blocks) {
71859
72020
  parts.push(block.id);
71860
72021
  if (block.kind === "paragraph") {
71861
72022
  for (const run2 of block.runs) {
71862
- if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
72023
+ if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break" && run2.kind !== "fieldAnnotation") {
71863
72024
  parts.push(run2.text ?? "");
71864
72025
  }
71865
72026
  if ("bold" in run2 && run2.bold) parts.push("b");
@@ -72344,6 +72505,255 @@ var Priority = /* @__PURE__ */ ((Priority2) => {
72344
72505
  /** P3: Heavy debounce for full document layout */
72345
72506
  [Priority.P3]: 150
72346
72507
  });
72508
+ const DEFAULT_MIME_TYPE$1 = "application/x-field-annotation";
72509
+ const LEGACY_MIME_TYPE = "fieldAnnotation";
72510
+ function parseIntSafe(value) {
72511
+ if (!value) return void 0;
72512
+ const parsed = parseInt(value, 10);
72513
+ return Number.isFinite(parsed) ? parsed : void 0;
72514
+ }
72515
+ function extractFieldAnnotationData(element) {
72516
+ const dataset = element.dataset;
72517
+ const attributes = {};
72518
+ for (const key2 in dataset) {
72519
+ const value = dataset[key2];
72520
+ if (value !== void 0) {
72521
+ attributes[key2] = value;
72522
+ }
72523
+ }
72524
+ return {
72525
+ fieldId: dataset.fieldId,
72526
+ fieldType: dataset.fieldType,
72527
+ variant: dataset.variant ?? dataset.type,
72528
+ displayLabel: dataset.displayLabel,
72529
+ pmStart: parseIntSafe(dataset.pmStart),
72530
+ pmEnd: parseIntSafe(dataset.pmEnd),
72531
+ attributes
72532
+ };
72533
+ }
72534
+ class DragHandler {
72535
+ /**
72536
+ * Creates a new DragHandler instance.
72537
+ *
72538
+ * @param container - The DOM container element (typically .superdoc-layout)
72539
+ * @param config - Configuration options and callbacks
72540
+ */
72541
+ constructor(container, config2 = {}) {
72542
+ this.container = container;
72543
+ this.config = config2;
72544
+ this.mimeType = config2.mimeType ?? DEFAULT_MIME_TYPE$1;
72545
+ this.boundHandlers = {
72546
+ dragstart: this.handleDragStart.bind(this),
72547
+ dragover: this.handleDragOver.bind(this),
72548
+ drop: this.handleDrop.bind(this),
72549
+ dragend: this.handleDragEnd.bind(this),
72550
+ dragleave: this.handleDragLeave.bind(this)
72551
+ };
72552
+ this.windowDragoverHandler = this.handleWindowDragOver.bind(this);
72553
+ this.windowDropHandler = this.handleWindowDrop.bind(this);
72554
+ this.attachListeners();
72555
+ }
72556
+ /**
72557
+ * Attaches event listeners to the container and window.
72558
+ */
72559
+ attachListeners() {
72560
+ this.container.addEventListener("dragstart", this.boundHandlers.dragstart);
72561
+ this.container.addEventListener("dragover", this.boundHandlers.dragover);
72562
+ this.container.addEventListener("drop", this.boundHandlers.drop);
72563
+ this.container.addEventListener("dragend", this.boundHandlers.dragend);
72564
+ this.container.addEventListener("dragleave", this.boundHandlers.dragleave);
72565
+ window.addEventListener("dragover", this.windowDragoverHandler, false);
72566
+ window.addEventListener("drop", this.windowDropHandler, false);
72567
+ }
72568
+ /**
72569
+ * Removes event listeners from the container and window.
72570
+ */
72571
+ removeListeners() {
72572
+ this.container.removeEventListener("dragstart", this.boundHandlers.dragstart);
72573
+ this.container.removeEventListener("dragover", this.boundHandlers.dragover);
72574
+ this.container.removeEventListener("drop", this.boundHandlers.drop);
72575
+ this.container.removeEventListener("dragend", this.boundHandlers.dragend);
72576
+ this.container.removeEventListener("dragleave", this.boundHandlers.dragleave);
72577
+ window.removeEventListener("dragover", this.windowDragoverHandler, false);
72578
+ window.removeEventListener("drop", this.windowDropHandler, false);
72579
+ }
72580
+ /**
72581
+ * Handles dragover at window level to allow drops on overlay elements.
72582
+ * This ensures preventDefault is called even when dragging over selection
72583
+ * highlights or other UI elements that sit on top of the layout content.
72584
+ */
72585
+ handleWindowDragOver(event) {
72586
+ if (this.hasFieldAnnotationData(event)) {
72587
+ event.preventDefault();
72588
+ if (event.dataTransfer) {
72589
+ event.dataTransfer.dropEffect = "move";
72590
+ }
72591
+ const target = event.target;
72592
+ if (!this.container.contains(target)) {
72593
+ this.config.onDragOver?.({
72594
+ event,
72595
+ clientX: event.clientX,
72596
+ clientY: event.clientY,
72597
+ hasFieldAnnotation: true
72598
+ });
72599
+ }
72600
+ }
72601
+ }
72602
+ /**
72603
+ * Handles drop at window level to catch drops on overlay elements.
72604
+ * If the drop target is outside the container, we process it here.
72605
+ */
72606
+ handleWindowDrop(event) {
72607
+ if (this.hasFieldAnnotationData(event)) {
72608
+ const target = event.target;
72609
+ if (!this.container.contains(target)) {
72610
+ this.handleDrop(event);
72611
+ }
72612
+ }
72613
+ }
72614
+ /**
72615
+ * Handles the dragstart event.
72616
+ * Sets up dataTransfer with field annotation data and drag image.
72617
+ */
72618
+ handleDragStart(event) {
72619
+ const target = event.target;
72620
+ if (!target?.dataset?.draggable || target.dataset.draggable !== "true") {
72621
+ return;
72622
+ }
72623
+ const data = extractFieldAnnotationData(target);
72624
+ if (event.dataTransfer) {
72625
+ const jsonData = JSON.stringify({
72626
+ attributes: data.attributes,
72627
+ sourceField: data
72628
+ });
72629
+ event.dataTransfer.setData(this.mimeType, jsonData);
72630
+ event.dataTransfer.setData(LEGACY_MIME_TYPE, jsonData);
72631
+ event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
72632
+ event.dataTransfer.setDragImage(target, 0, 0);
72633
+ event.dataTransfer.effectAllowed = "move";
72634
+ }
72635
+ this.config.onDragStart?.({
72636
+ event,
72637
+ element: target,
72638
+ data
72639
+ });
72640
+ }
72641
+ /**
72642
+ * Handles the dragover event.
72643
+ * Provides visual feedback and determines if drop is allowed.
72644
+ */
72645
+ handleDragOver(event) {
72646
+ const hasFieldAnnotation = this.hasFieldAnnotationData(event);
72647
+ if (hasFieldAnnotation) {
72648
+ event.preventDefault();
72649
+ if (event.dataTransfer) {
72650
+ event.dataTransfer.dropEffect = "move";
72651
+ }
72652
+ this.container.classList.add("drag-over");
72653
+ }
72654
+ this.config.onDragOver?.({
72655
+ event,
72656
+ clientX: event.clientX,
72657
+ clientY: event.clientY,
72658
+ hasFieldAnnotation
72659
+ });
72660
+ }
72661
+ /**
72662
+ * Handles the dragleave event.
72663
+ * Removes visual feedback when drag leaves the container.
72664
+ */
72665
+ handleDragLeave(event) {
72666
+ const relatedTarget = event.relatedTarget;
72667
+ if (!relatedTarget || !this.container.contains(relatedTarget)) {
72668
+ this.container.classList.remove("drag-over");
72669
+ }
72670
+ }
72671
+ /**
72672
+ * Handles the drop event.
72673
+ * Maps drop coordinates to ProseMirror position and emits drop event.
72674
+ */
72675
+ handleDrop(event) {
72676
+ this.container.classList.remove("drag-over");
72677
+ if (!this.hasFieldAnnotationData(event)) {
72678
+ return;
72679
+ }
72680
+ event.preventDefault();
72681
+ const data = this.extractDragData(event);
72682
+ if (!data) {
72683
+ return;
72684
+ }
72685
+ const pmPosition = clickToPositionDom(this.container, event.clientX, event.clientY);
72686
+ this.config.onDrop?.({
72687
+ event,
72688
+ data,
72689
+ pmPosition,
72690
+ clientX: event.clientX,
72691
+ clientY: event.clientY
72692
+ });
72693
+ }
72694
+ /**
72695
+ * Handles the dragend event.
72696
+ * Cleans up drag state.
72697
+ */
72698
+ handleDragEnd(event) {
72699
+ this.container.classList.remove("drag-over");
72700
+ this.config.onDragEnd?.(event);
72701
+ }
72702
+ /**
72703
+ * Checks if a drag event contains field annotation data.
72704
+ */
72705
+ hasFieldAnnotationData(event) {
72706
+ if (!event.dataTransfer) {
72707
+ return false;
72708
+ }
72709
+ const types2 = event.dataTransfer.types;
72710
+ return types2.includes(this.mimeType) || types2.includes(LEGACY_MIME_TYPE);
72711
+ }
72712
+ /**
72713
+ * Extracts field annotation data from a drag event's dataTransfer.
72714
+ */
72715
+ extractDragData(event) {
72716
+ if (!event.dataTransfer) {
72717
+ return null;
72718
+ }
72719
+ let jsonData = event.dataTransfer.getData(this.mimeType);
72720
+ if (!jsonData) {
72721
+ jsonData = event.dataTransfer.getData(LEGACY_MIME_TYPE);
72722
+ }
72723
+ if (!jsonData) {
72724
+ return null;
72725
+ }
72726
+ try {
72727
+ const parsed = JSON.parse(jsonData);
72728
+ return parsed.sourceField ?? parsed.attributes ?? parsed;
72729
+ } catch {
72730
+ return null;
72731
+ }
72732
+ }
72733
+ /**
72734
+ * Updates the configuration options.
72735
+ *
72736
+ * @param config - New configuration options to merge
72737
+ */
72738
+ updateConfig(config2) {
72739
+ this.config = { ...this.config, ...config2 };
72740
+ if (config2.mimeType) {
72741
+ this.mimeType = config2.mimeType;
72742
+ }
72743
+ }
72744
+ /**
72745
+ * Destroys the drag handler and removes all event listeners.
72746
+ * Call this when the layout engine is unmounted or the container is removed.
72747
+ */
72748
+ destroy() {
72749
+ this.removeListeners();
72750
+ this.container.classList.remove("drag-over");
72751
+ }
72752
+ }
72753
+ function createDragHandler(container, config2 = {}) {
72754
+ const handler2 = new DragHandler(container, config2);
72755
+ return () => handler2.destroy();
72756
+ }
72347
72757
  const isAtomicFragment = (fragment) => {
72348
72758
  return fragment.kind === "drawing" || fragment.kind === "image";
72349
72759
  };
@@ -72882,7 +73292,7 @@ function computeLinePmRange$1(block, line) {
72882
73292
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
72883
73293
  const run2 = block.runs[runIndex];
72884
73294
  if (!run2) continue;
72885
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
73295
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
72886
73296
  const runLength = text.length;
72887
73297
  const runPmStart = run2.pmStart ?? null;
72888
73298
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
@@ -72906,7 +73316,7 @@ function pmPosToCharOffset(block, line, pmPos) {
72906
73316
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
72907
73317
  const run2 = block.runs[runIndex];
72908
73318
  if (!run2) continue;
72909
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
73319
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
72910
73320
  const runTextLength = text.length;
72911
73321
  const runPmStart = run2.pmStart ?? null;
72912
73322
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runTextLength : null);
@@ -75439,9 +75849,227 @@ const TRACK_CHANGE_STYLES = `
75439
75849
  border-bottom: 2px solid gold;
75440
75850
  }
75441
75851
  `;
75852
+ const SDT_CONTAINER_STYLES = `
75853
+ /* Document Section - Block-level container with gray border and hover tooltip */
75854
+ .superdoc-document-section {
75855
+ background-color: #fafafa;
75856
+ border: 1px solid #ababab;
75857
+ border-radius: 4px;
75858
+ position: relative;
75859
+ box-sizing: border-box;
75860
+ }
75861
+
75862
+ /* Document section tooltip - positioned above the fragment */
75863
+ .superdoc-document-section__tooltip {
75864
+ position: absolute;
75865
+ top: -19px;
75866
+ left: -1px;
75867
+ max-width: 100px;
75868
+ min-width: 0;
75869
+ height: 18px;
75870
+ border: 1px solid #ababab;
75871
+ border-bottom: none;
75872
+ border-radius: 6px 6px 0 0;
75873
+ padding: 0 8px;
75874
+ align-items: center;
75875
+ font-size: 10px;
75876
+ display: none;
75877
+ z-index: 100;
75878
+ background-color: #fafafa;
75879
+ pointer-events: none;
75880
+ }
75881
+
75882
+ .superdoc-document-section__tooltip span {
75883
+ max-width: 100%;
75884
+ overflow: hidden;
75885
+ white-space: nowrap;
75886
+ text-overflow: ellipsis;
75887
+ }
75888
+
75889
+ /* Show tooltip on hover - adjust border radius to connect with tooltip tab */
75890
+ .superdoc-document-section:hover {
75891
+ border-radius: 0 4px 4px 4px;
75892
+ }
75893
+
75894
+ .superdoc-document-section:hover .superdoc-document-section__tooltip {
75895
+ display: flex;
75896
+ align-items: center;
75897
+ }
75898
+
75899
+ /* Continuation styling: first fragment has top corners, last has bottom corners */
75900
+ .superdoc-document-section[data-sdt-container-start="true"] {
75901
+ border-radius: 4px 4px 0 0;
75902
+ }
75903
+
75904
+ .superdoc-document-section[data-sdt-container-end="true"] {
75905
+ border-radius: 0 0 4px 4px;
75906
+ }
75907
+
75908
+ .superdoc-document-section[data-sdt-container-start="true"][data-sdt-container-end="true"] {
75909
+ border-radius: 4px;
75910
+ }
75911
+
75912
+ .superdoc-document-section[data-sdt-container-start="true"]:hover {
75913
+ border-radius: 0 4px 0 0;
75914
+ }
75915
+
75916
+ /* Middle fragments have no border radius */
75917
+ .superdoc-document-section:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
75918
+ border-radius: 0;
75919
+ border-top: none;
75920
+ }
75921
+
75922
+ /* Structured Content Block - Blue border container */
75923
+ .superdoc-structured-content-block {
75924
+ padding: 1px;
75925
+ box-sizing: border-box;
75926
+ border-radius: 4px;
75927
+ border: 1px solid #629be7;
75928
+ position: relative;
75929
+ }
75930
+
75931
+ /* Structured content drag handle/label - positioned above */
75932
+ .superdoc-structured-content__label {
75933
+ font-size: 10px;
75934
+ align-items: center;
75935
+ justify-content: center;
75936
+ position: absolute;
75937
+ left: 2px;
75938
+ top: -19px;
75939
+ width: calc(100% - 4px);
75940
+ max-width: 110px;
75941
+ min-width: 0;
75942
+ height: 18px;
75943
+ padding: 0 4px;
75944
+ border: 1px solid #629be7;
75945
+ border-bottom: none;
75946
+ border-radius: 6px 6px 0 0;
75947
+ background-color: #629be7dd;
75948
+ box-sizing: border-box;
75949
+ z-index: 10;
75950
+ display: none;
75951
+ pointer-events: none;
75952
+ }
75953
+
75954
+ .superdoc-structured-content__label span {
75955
+ max-width: 100%;
75956
+ overflow: hidden;
75957
+ white-space: nowrap;
75958
+ text-overflow: ellipsis;
75959
+ }
75960
+
75961
+ .superdoc-structured-content-block:hover .superdoc-structured-content__label {
75962
+ display: inline-flex;
75963
+ }
75964
+
75965
+ /* Continuation styling for structured content blocks */
75966
+ .superdoc-structured-content-block[data-sdt-container-start="true"] {
75967
+ border-radius: 4px 4px 0 0;
75968
+ }
75969
+
75970
+ .superdoc-structured-content-block[data-sdt-container-end="true"] {
75971
+ border-radius: 0 0 4px 4px;
75972
+ }
75973
+
75974
+ .superdoc-structured-content-block[data-sdt-container-start="true"][data-sdt-container-end="true"] {
75975
+ border-radius: 4px;
75976
+ }
75977
+
75978
+ .superdoc-structured-content-block:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
75979
+ border-radius: 0;
75980
+ border-top: none;
75981
+ }
75982
+
75983
+ /* Structured Content Inline - Inline wrapper with blue border */
75984
+ .superdoc-structured-content-inline {
75985
+ padding: 1px;
75986
+ box-sizing: border-box;
75987
+ border-radius: 4px;
75988
+ border: 1px solid #629be7;
75989
+ position: relative;
75990
+ display: inline;
75991
+ }
75992
+
75993
+ /* Hover effect for inline structured content */
75994
+ .superdoc-structured-content-inline:hover {
75995
+ background-color: rgba(98, 155, 231, 0.15);
75996
+ border-color: #4a8ad9;
75997
+ }
75998
+
75999
+ /* Inline structured content label - shown on hover */
76000
+ .superdoc-structured-content-inline__label {
76001
+ position: absolute;
76002
+ bottom: calc(100% + 2px);
76003
+ left: 50%;
76004
+ transform: translateX(-50%);
76005
+ font-size: 10px;
76006
+ padding: 2px 6px;
76007
+ background-color: #629be7dd;
76008
+ color: white;
76009
+ border-radius: 4px;
76010
+ white-space: nowrap;
76011
+ z-index: 100;
76012
+ display: none;
76013
+ pointer-events: none;
76014
+ }
76015
+
76016
+ .superdoc-structured-content-inline:hover .superdoc-structured-content-inline__label {
76017
+ display: block;
76018
+ }
76019
+
76020
+ /* Print mode: hide visual styling for SDT containers */
76021
+ @media print {
76022
+ .superdoc-document-section,
76023
+ .superdoc-structured-content-block,
76024
+ .superdoc-structured-content-inline {
76025
+ background: none;
76026
+ border: none;
76027
+ padding: 0;
76028
+ }
76029
+
76030
+ .superdoc-document-section__tooltip,
76031
+ .superdoc-structured-content__label,
76032
+ .superdoc-structured-content-inline__label {
76033
+ display: none !important;
76034
+ }
76035
+ }
76036
+ `;
76037
+ const FIELD_ANNOTATION_STYLES = `
76038
+ /* Field annotation draggable styles */
76039
+ .superdoc-layout .annotation[data-draggable="true"] {
76040
+ cursor: grab;
76041
+ user-select: none;
76042
+ -webkit-user-select: none;
76043
+ }
76044
+
76045
+ .superdoc-layout .annotation[data-draggable="true"]:hover {
76046
+ opacity: 0.9;
76047
+ }
76048
+
76049
+ .superdoc-layout .annotation[data-draggable="true"]:active {
76050
+ cursor: grabbing;
76051
+ }
76052
+
76053
+ /* Drag over indicator for drop targets */
76054
+ .superdoc-layout.drag-over {
76055
+ outline: 2px dashed #b015b3;
76056
+ outline-offset: -2px;
76057
+ }
76058
+
76059
+ /* Drop zone indicator */
76060
+ .superdoc-layout .superdoc-drop-indicator {
76061
+ position: absolute;
76062
+ width: 2px;
76063
+ background-color: #b015b3;
76064
+ pointer-events: none;
76065
+ z-index: 1000;
76066
+ }
76067
+ `;
75442
76068
  let printStylesInjected = false;
75443
76069
  let linkStylesInjected = false;
75444
76070
  let trackChangeStylesInjected = false;
76071
+ let sdtContainerStylesInjected = false;
76072
+ let fieldAnnotationStylesInjected = false;
75445
76073
  const ensurePrintStyles = (doc2) => {
75446
76074
  if (printStylesInjected || !doc2) return;
75447
76075
  const styleEl = doc2.createElement("style");
@@ -75466,6 +76094,22 @@ const ensureTrackChangeStyles = (doc2) => {
75466
76094
  doc2.head?.appendChild(styleEl);
75467
76095
  trackChangeStylesInjected = true;
75468
76096
  };
76097
+ const ensureSdtContainerStyles = (doc2) => {
76098
+ if (sdtContainerStylesInjected || !doc2) return;
76099
+ const styleEl = doc2.createElement("style");
76100
+ styleEl.setAttribute("data-superdoc-sdt-container-styles", "true");
76101
+ styleEl.textContent = SDT_CONTAINER_STYLES;
76102
+ doc2.head?.appendChild(styleEl);
76103
+ sdtContainerStylesInjected = true;
76104
+ };
76105
+ const ensureFieldAnnotationStyles = (doc2) => {
76106
+ if (fieldAnnotationStylesInjected || !doc2) return;
76107
+ const styleEl = doc2.createElement("style");
76108
+ styleEl.setAttribute("data-superdoc-field-annotation-styles", "true");
76109
+ styleEl.textContent = FIELD_ANNOTATION_STYLES;
76110
+ doc2.head?.appendChild(styleEl);
76111
+ fieldAnnotationStylesInjected = true;
76112
+ };
75469
76113
  const ALLOWED_BORDER_STYLES = /* @__PURE__ */ new Set([
75470
76114
  "none",
75471
76115
  "single",
@@ -75795,6 +76439,50 @@ const renderTableRow = (deps) => {
75795
76439
  container.appendChild(cellElement);
75796
76440
  }
75797
76441
  };
76442
+ function isStructuredContentMetadata(sdt) {
76443
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
76444
+ }
76445
+ function isDocumentSectionMetadata(sdt) {
76446
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "documentSection";
76447
+ }
76448
+ function getSdtContainerConfig(sdt) {
76449
+ if (isDocumentSectionMetadata(sdt)) {
76450
+ return {
76451
+ className: "superdoc-document-section",
76452
+ labelText: sdt.title ?? "Document section",
76453
+ labelClassName: "superdoc-document-section__tooltip",
76454
+ isStart: true,
76455
+ isEnd: true
76456
+ };
76457
+ }
76458
+ if (isStructuredContentMetadata(sdt) && sdt.scope === "block") {
76459
+ return {
76460
+ className: "superdoc-structured-content-block",
76461
+ labelText: sdt.alias ?? "Structured content",
76462
+ labelClassName: "superdoc-structured-content__label",
76463
+ isStart: true,
76464
+ isEnd: true
76465
+ };
76466
+ }
76467
+ return null;
76468
+ }
76469
+ function applySdtContainerStyling(doc2, container, sdt, containerSdt) {
76470
+ let config2 = getSdtContainerConfig(sdt);
76471
+ if (!config2 && containerSdt) {
76472
+ config2 = getSdtContainerConfig(containerSdt);
76473
+ }
76474
+ if (!config2) return;
76475
+ container.classList.add(config2.className);
76476
+ container.dataset.sdtContainerStart = String(config2.isStart);
76477
+ container.dataset.sdtContainerEnd = String(config2.isEnd);
76478
+ container.style.overflow = "visible";
76479
+ const labelEl = doc2.createElement("div");
76480
+ labelEl.className = config2.labelClassName;
76481
+ const labelText = doc2.createElement("span");
76482
+ labelText.textContent = config2.labelText;
76483
+ labelEl.appendChild(labelText);
76484
+ container.appendChild(labelEl);
76485
+ }
75798
76486
  const renderTableFragment = (deps) => {
75799
76487
  const { doc: doc2, fragment, blockLookup, context, renderLine, applyFragmentFrame, applySdtDataset, applyStyles: applyStyles2 } = deps;
75800
76488
  if (!doc2) {
@@ -75831,6 +76519,7 @@ const renderTableFragment = (deps) => {
75831
76519
  applyFragmentFrame(container, fragment);
75832
76520
  container.style.height = `${fragment.height}px`;
75833
76521
  applySdtDataset(container, block.attrs?.sdt);
76522
+ applySdtContainerStyling(doc2, container, block.attrs?.sdt);
75834
76523
  container.classList.add("superdoc-table-fragment");
75835
76524
  if (fragment.metadata?.columnBoundaries) {
75836
76525
  const columnCount = measure.columnWidths.length;
@@ -76297,6 +76986,8 @@ const _DomPainter = class _DomPainter2 {
76297
76986
  ensurePrintStyles(doc2);
76298
76987
  ensureLinkStyles(doc2);
76299
76988
  ensureTrackChangeStyles(doc2);
76989
+ ensureFieldAnnotationStyles(doc2);
76990
+ ensureSdtContainerStyles(doc2);
76300
76991
  mount2.classList.add(CLASS_NAMES.container);
76301
76992
  if (this.mount && this.mount !== mount2) {
76302
76993
  this.resetState();
@@ -76819,7 +77510,8 @@ const _DomPainter = class _DomPainter2 {
76819
77510
  fragmentEl.classList.add(CLASS_NAMES.fragment);
76820
77511
  const isTocEntry = block.attrs?.isTocEntry;
76821
77512
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
76822
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
77513
+ const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
77514
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
76823
77515
  applyStyles$2(fragmentEl, styles);
76824
77516
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
76825
77517
  if (isTocEntry) {
@@ -76839,6 +77531,7 @@ const _DomPainter = class _DomPainter2 {
76839
77531
  }
76840
77532
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
76841
77533
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
77534
+ applySdtContainerStyling(this.doc, fragmentEl, block.attrs?.sdt, block.attrs?.containerSdt);
76842
77535
  const dropCapDescriptor = block.attrs?.dropCapDescriptor;
76843
77536
  const dropCapMeasure = measure.dropCap;
76844
77537
  if (dropCapDescriptor && dropCapMeasure && !fragment.continuesFromPrev) {
@@ -77057,6 +77750,7 @@ const _DomPainter = class _DomPainter2 {
77057
77750
  fragmentEl.dataset.itemId = fragment.itemId;
77058
77751
  const paragraphMetadata = item.paragraph.attrs?.sdt;
77059
77752
  this.applySdtDataset(fragmentEl, paragraphMetadata);
77753
+ applySdtContainerStyling(this.doc, fragmentEl, paragraphMetadata, item.paragraph.attrs?.containerSdt);
77060
77754
  if (fragment.continuesFromPrev) {
77061
77755
  fragmentEl.dataset.continuesFromPrev = "true";
77062
77756
  }
@@ -77828,10 +78522,19 @@ const _DomPainter = class _DomPainter2 {
77828
78522
  isBreakRun(run2) {
77829
78523
  return run2.kind === "break";
77830
78524
  }
78525
+ /**
78526
+ * Type guard to check if a run is a field annotation run.
78527
+ */
78528
+ isFieldAnnotationRun(run2) {
78529
+ return run2.kind === "fieldAnnotation";
78530
+ }
77831
78531
  renderRun(run2, context, trackedConfig) {
77832
78532
  if (this.isImageRun(run2)) {
77833
78533
  return this.renderImageRun(run2);
77834
78534
  }
78535
+ if (this.isFieldAnnotationRun(run2)) {
78536
+ return this.renderFieldAnnotationRun(run2);
78537
+ }
77835
78538
  if (this.isLineBreakRun(run2)) {
77836
78539
  return null;
77837
78540
  }
@@ -77968,6 +78671,200 @@ const _DomPainter = class _DomPainter2 {
77968
78671
  }
77969
78672
  return img;
77970
78673
  }
78674
+ /**
78675
+ * Renders a FieldAnnotationRun as an inline "pill" element matching super-editor's visual appearance.
78676
+ *
78677
+ * Field annotations are styled inline elements that display form fields with:
78678
+ * - Outer span with border, border-radius, padding, and background color
78679
+ * - Inner span containing the displayLabel or type-specific content (image, link, etc.)
78680
+ *
78681
+ * @param run - The FieldAnnotationRun to render containing field configuration and styling
78682
+ * @returns HTMLElement (span) or null if document is not available
78683
+ *
78684
+ * @example
78685
+ * ```typescript
78686
+ * // Text variant
78687
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'text', displayLabel: 'Full Name', fieldColor: '#980043' })
78688
+ * // Returns: <span class="annotation" style="border: 2px solid #b015b3; ..."><span class="annotation-content">Full Name</span></span>
78689
+ *
78690
+ * // Image variant with imageSrc
78691
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'image', displayLabel: 'Photo', imageSrc: 'data:image/png;...' })
78692
+ * // Returns: <span class="annotation"><span class="annotation-content"><img src="..." /></span></span>
78693
+ *
78694
+ * // Link variant
78695
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'link', displayLabel: 'Website', linkUrl: 'https://example.com' })
78696
+ * // Returns: <span class="annotation"><span class="annotation-content"><a href="...">https://example.com</a></span></span>
78697
+ * ```
78698
+ */
78699
+ renderFieldAnnotationRun(run2) {
78700
+ if (!this.doc) {
78701
+ return null;
78702
+ }
78703
+ if (run2.hidden) {
78704
+ const hidden = this.doc.createElement("span");
78705
+ hidden.style.display = "none";
78706
+ if (run2.pmStart != null) hidden.dataset.pmStart = String(run2.pmStart);
78707
+ if (run2.pmEnd != null) hidden.dataset.pmEnd = String(run2.pmEnd);
78708
+ return hidden;
78709
+ }
78710
+ const defaultBorderColor = "#b015b3";
78711
+ const defaultFieldColor = "#980043";
78712
+ const annotation = this.doc.createElement("span");
78713
+ annotation.classList.add("annotation");
78714
+ annotation.setAttribute("aria-label", "Field annotation");
78715
+ const showHighlight = run2.highlighted !== false;
78716
+ if (showHighlight) {
78717
+ const borderColor = run2.borderColor || defaultBorderColor;
78718
+ annotation.style.border = `2px solid ${borderColor}`;
78719
+ annotation.style.borderRadius = "2px";
78720
+ annotation.style.padding = "1px 2px";
78721
+ annotation.style.boxSizing = "border-box";
78722
+ const fieldColor = run2.fieldColor || defaultFieldColor;
78723
+ const bgColor = fieldColor.length === 7 ? `${fieldColor}33` : fieldColor;
78724
+ if (run2.textHighlight) {
78725
+ annotation.style.backgroundColor = run2.textHighlight;
78726
+ } else {
78727
+ annotation.style.backgroundColor = bgColor;
78728
+ }
78729
+ }
78730
+ if (run2.visibility === "hidden") {
78731
+ annotation.style.visibility = "hidden";
78732
+ }
78733
+ if (run2.size) {
78734
+ if (run2.size.width) {
78735
+ annotation.style.width = `${run2.size.width}px`;
78736
+ annotation.style.display = "inline-block";
78737
+ annotation.style.overflow = "hidden";
78738
+ }
78739
+ if (run2.size.height) {
78740
+ annotation.style.height = `${run2.size.height}px`;
78741
+ }
78742
+ }
78743
+ if (run2.fontFamily) {
78744
+ annotation.style.fontFamily = run2.fontFamily;
78745
+ }
78746
+ if (run2.fontSize) {
78747
+ const fontSize2 = typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize;
78748
+ annotation.style.fontSize = fontSize2;
78749
+ }
78750
+ if (run2.textColor) {
78751
+ annotation.style.color = run2.textColor;
78752
+ }
78753
+ if (run2.bold) {
78754
+ annotation.style.fontWeight = "bold";
78755
+ }
78756
+ if (run2.italic) {
78757
+ annotation.style.fontStyle = "italic";
78758
+ }
78759
+ if (run2.underline) {
78760
+ annotation.style.textDecoration = "underline";
78761
+ }
78762
+ annotation.style.zIndex = "1";
78763
+ const content = this.doc.createElement("span");
78764
+ content.classList.add("annotation-content");
78765
+ content.style.pointerEvents = "none";
78766
+ content.setAttribute("contenteditable", "false");
78767
+ switch (run2.variant) {
78768
+ case "image":
78769
+ case "signature": {
78770
+ if (run2.imageSrc) {
78771
+ const img = this.doc.createElement("img");
78772
+ const isDataUrl = run2.imageSrc.startsWith("data:");
78773
+ if (isDataUrl) {
78774
+ if (run2.imageSrc.length <= MAX_DATA_URL_LENGTH && VALID_IMAGE_DATA_URL.test(run2.imageSrc)) {
78775
+ img.src = run2.imageSrc;
78776
+ } else {
78777
+ content.textContent = run2.displayLabel;
78778
+ break;
78779
+ }
78780
+ } else {
78781
+ const sanitized = sanitizeHref(run2.imageSrc);
78782
+ if (sanitized) {
78783
+ img.src = sanitized.href;
78784
+ } else {
78785
+ content.textContent = run2.displayLabel;
78786
+ break;
78787
+ }
78788
+ }
78789
+ img.alt = run2.displayLabel;
78790
+ img.style.height = "auto";
78791
+ img.style.maxWidth = "100%";
78792
+ img.style.pointerEvents = "none";
78793
+ img.style.verticalAlign = "middle";
78794
+ if (run2.variant === "signature") {
78795
+ img.style.maxHeight = "28px";
78796
+ }
78797
+ content.appendChild(img);
78798
+ annotation.style.display = "inline-block";
78799
+ content.style.display = "inline-block";
78800
+ } else {
78801
+ content.textContent = run2.displayLabel || (run2.variant === "signature" ? "Signature" : "");
78802
+ }
78803
+ break;
78804
+ }
78805
+ case "link": {
78806
+ if (run2.linkUrl) {
78807
+ const link = this.doc.createElement("a");
78808
+ const sanitized = sanitizeHref(run2.linkUrl);
78809
+ if (sanitized) {
78810
+ link.href = sanitized.href;
78811
+ link.target = "_blank";
78812
+ link.rel = "noopener noreferrer";
78813
+ link.textContent = run2.linkUrl;
78814
+ link.style.textDecoration = "none";
78815
+ content.style.pointerEvents = "all";
78816
+ content.appendChild(link);
78817
+ } else {
78818
+ content.textContent = run2.displayLabel;
78819
+ }
78820
+ } else {
78821
+ content.textContent = run2.displayLabel;
78822
+ }
78823
+ break;
78824
+ }
78825
+ case "html": {
78826
+ if (run2.rawHtml && typeof run2.rawHtml === "string") {
78827
+ content.textContent = run2.displayLabel;
78828
+ annotation.style.display = "inline-block";
78829
+ content.style.display = "inline-block";
78830
+ } else {
78831
+ content.textContent = run2.displayLabel;
78832
+ }
78833
+ break;
78834
+ }
78835
+ case "text":
78836
+ case "checkbox":
78837
+ default: {
78838
+ content.textContent = run2.displayLabel;
78839
+ break;
78840
+ }
78841
+ }
78842
+ annotation.appendChild(content);
78843
+ annotation.dataset.type = run2.variant;
78844
+ if (run2.fieldId) {
78845
+ annotation.dataset.fieldId = run2.fieldId;
78846
+ }
78847
+ if (run2.fieldType) {
78848
+ annotation.dataset.fieldType = run2.fieldType;
78849
+ }
78850
+ annotation.draggable = true;
78851
+ annotation.dataset.draggable = "true";
78852
+ if (run2.displayLabel) {
78853
+ annotation.dataset.displayLabel = run2.displayLabel;
78854
+ }
78855
+ if (run2.variant) {
78856
+ annotation.dataset.variant = run2.variant;
78857
+ }
78858
+ assertPmPositions(run2, "field annotation run");
78859
+ if (run2.pmStart != null) {
78860
+ annotation.dataset.pmStart = String(run2.pmStart);
78861
+ }
78862
+ if (run2.pmEnd != null) {
78863
+ annotation.dataset.pmEnd = String(run2.pmEnd);
78864
+ }
78865
+ this.applySdtDataset(annotation, run2.sdt);
78866
+ return annotation;
78867
+ }
77971
78868
  /**
77972
78869
  * Renders a single line of a paragraph block.
77973
78870
  *
@@ -78145,6 +79042,22 @@ const _DomPainter = class _DomPainter2 {
78145
79042
  if (this.isBreakRun(baseRun)) {
78146
79043
  continue;
78147
79044
  }
79045
+ if (this.isFieldAnnotationRun(baseRun)) {
79046
+ const elem = this.renderRun(baseRun, context, trackedConfig);
79047
+ if (elem) {
79048
+ if (styleId) {
79049
+ elem.setAttribute("styleid", styleId);
79050
+ }
79051
+ const runSegments2 = segmentsByRun.get(runIndex);
79052
+ const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
79053
+ const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
79054
+ elem.style.position = "absolute";
79055
+ elem.style.left = `${segX}px`;
79056
+ el.appendChild(elem);
79057
+ cumulativeX = segX + segWidth;
79058
+ }
79059
+ continue;
79060
+ }
78148
79061
  const runSegments = segmentsByRun.get(runIndex);
78149
79062
  if (!runSegments || runSegments.length === 0) {
78150
79063
  continue;
@@ -78190,7 +79103,22 @@ const _DomPainter = class _DomPainter2 {
78190
79103
  });
78191
79104
  }
78192
79105
  } else {
79106
+ let currentInlineSdtWrapper = null;
79107
+ let currentInlineSdtId = null;
79108
+ const closeCurrentWrapper = () => {
79109
+ if (currentInlineSdtWrapper) {
79110
+ el.appendChild(currentInlineSdtWrapper);
79111
+ currentInlineSdtWrapper = null;
79112
+ currentInlineSdtId = null;
79113
+ }
79114
+ };
78193
79115
  runsForLine.forEach((run2) => {
79116
+ const runSdt = run2.sdt;
79117
+ const isInlineSdt = runSdt?.type === "structuredContent" && runSdt?.scope === "inline";
79118
+ const runSdtId = isInlineSdt && runSdt?.id ? String(runSdt.id) : null;
79119
+ if (runSdtId !== currentInlineSdtId) {
79120
+ closeCurrentWrapper();
79121
+ }
78194
79122
  if (run2.kind === "tab") {
78195
79123
  const tabEl = this.doc.createElement("span");
78196
79124
  tabEl.classList.add("superdoc-tab");
@@ -78218,9 +79146,37 @@ const _DomPainter = class _DomPainter2 {
78218
79146
  if (styleId) {
78219
79147
  elem.setAttribute("styleid", styleId);
78220
79148
  }
78221
- el.appendChild(elem);
79149
+ if (isInlineSdt && runSdtId && this.doc) {
79150
+ if (!currentInlineSdtWrapper) {
79151
+ currentInlineSdtWrapper = this.doc.createElement("span");
79152
+ currentInlineSdtWrapper.className = "superdoc-structured-content-inline";
79153
+ currentInlineSdtId = runSdtId;
79154
+ this.applySdtDataset(currentInlineSdtWrapper, runSdt);
79155
+ const alias = runSdt?.alias || "Inline content";
79156
+ const labelEl = this.doc.createElement("span");
79157
+ labelEl.className = "superdoc-structured-content-inline__label";
79158
+ labelEl.textContent = alias;
79159
+ currentInlineSdtWrapper.appendChild(labelEl);
79160
+ }
79161
+ const wrapperPmStart = currentInlineSdtWrapper.dataset.pmStart;
79162
+ const wrapperPmEnd = currentInlineSdtWrapper.dataset.pmEnd;
79163
+ if (run2.pmStart != null) {
79164
+ if (!wrapperPmStart || run2.pmStart < parseInt(wrapperPmStart, 10)) {
79165
+ currentInlineSdtWrapper.dataset.pmStart = String(run2.pmStart);
79166
+ }
79167
+ }
79168
+ if (run2.pmEnd != null) {
79169
+ if (!wrapperPmEnd || run2.pmEnd > parseInt(wrapperPmEnd, 10)) {
79170
+ currentInlineSdtWrapper.dataset.pmEnd = String(run2.pmEnd);
79171
+ }
79172
+ }
79173
+ currentInlineSdtWrapper.appendChild(elem);
79174
+ } else {
79175
+ el.appendChild(elem);
79176
+ }
78222
79177
  }
78223
79178
  });
79179
+ closeCurrentWrapper();
78224
79180
  }
78225
79181
  const anchors = el.querySelectorAll("a[href]");
78226
79182
  anchors.forEach((anchor) => {
@@ -78728,7 +79684,7 @@ const deriveBlockVersion = (block) => {
78728
79684
  return block.id;
78729
79685
  };
78730
79686
  const applyRunStyles = (element, run2, _isLink = false) => {
78731
- if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
79687
+ if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
78732
79688
  return;
78733
79689
  }
78734
79690
  element.style.fontFamily = run2.fontFamily;
@@ -78888,6 +79844,10 @@ const sliceRunsForLine = (block, line) => {
78888
79844
  result.push(run2);
78889
79845
  continue;
78890
79846
  }
79847
+ if (run2.kind === "fieldAnnotation") {
79848
+ result.push(run2);
79849
+ continue;
79850
+ }
78891
79851
  if (!("text" in run2)) {
78892
79852
  continue;
78893
79853
  }
@@ -79203,6 +80163,10 @@ const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
79203
80163
  const TAB_EPSILON = 0.1;
79204
80164
  const DEFAULT_DECIMAL_SEPARATOR = ".";
79205
80165
  const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
80166
+ const FIELD_ANNOTATION_PILL_PADDING = 8;
80167
+ const FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2;
80168
+ const FIELD_ANNOTATION_VERTICAL_PADDING = 6;
80169
+ const DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16;
79206
80170
  const roundValue = (value) => value;
79207
80171
  function getCanvasContext() {
79208
80172
  if (!canvasContext) {
@@ -79282,6 +80246,9 @@ function isImageRun(run2) {
79282
80246
  function isLineBreakRun(run2) {
79283
80247
  return run2.kind === "lineBreak";
79284
80248
  }
80249
+ function isFieldAnnotationRun(run2) {
80250
+ return run2.kind === "fieldAnnotation";
80251
+ }
79285
80252
  async function measureBlock(block, constraints) {
79286
80253
  const normalized = normalizeConstraints(constraints);
79287
80254
  if (block.kind === "drawing") {
@@ -79648,6 +80615,92 @@ async function measureParagraphBlock(block, maxWidth) {
79648
80615
  lastAppliedTabAlign = null;
79649
80616
  continue;
79650
80617
  }
80618
+ if (isFieldAnnotationRun(run2)) {
80619
+ const displayText = run2.displayLabel || "";
80620
+ 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;
80621
+ const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
80622
+ const fontWeight = run2.bold ? "bold" : "normal";
80623
+ const fontStyle = run2.italic ? "italic" : "normal";
80624
+ const annotationFont = `${fontStyle} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
80625
+ ctx2.font = annotationFont;
80626
+ const textWidth = displayText ? ctx2.measureText(displayText).width : 0;
80627
+ const annotationWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
80628
+ const annotationHeight = annotationFontSize * FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER + FIELD_ANNOTATION_VERTICAL_PADDING;
80629
+ let annotationStartX;
80630
+ if (pendingTabAlignment && currentLine) {
80631
+ annotationStartX = alignPendingTabForWidth(annotationWidth);
80632
+ }
80633
+ if (!currentLine) {
80634
+ currentLine = {
80635
+ fromRun: runIndex,
80636
+ fromChar: 0,
80637
+ toRun: runIndex,
80638
+ toChar: 1,
80639
+ // Field annotations are atomic units
80640
+ width: annotationWidth,
80641
+ maxFontSize: annotationHeight,
80642
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
80643
+ segments: [
80644
+ {
80645
+ runIndex,
80646
+ fromChar: 0,
80647
+ toChar: 1,
80648
+ width: annotationWidth,
80649
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
80650
+ }
80651
+ ]
80652
+ };
80653
+ continue;
80654
+ }
80655
+ if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
80656
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
80657
+ const completedLine = {
80658
+ ...currentLine,
80659
+ ...metrics
80660
+ };
80661
+ addBarTabsToLine(completedLine);
80662
+ lines.push(completedLine);
80663
+ tabStopCursor = 0;
80664
+ pendingTabAlignment = null;
80665
+ lastAppliedTabAlign = null;
80666
+ currentLine = {
80667
+ fromRun: runIndex,
80668
+ fromChar: 0,
80669
+ toRun: runIndex,
80670
+ toChar: 1,
80671
+ width: annotationWidth,
80672
+ maxFontSize: annotationHeight,
80673
+ maxWidth: getEffectiveWidth(contentWidth),
80674
+ segments: [
80675
+ {
80676
+ runIndex,
80677
+ fromChar: 0,
80678
+ toChar: 1,
80679
+ width: annotationWidth
80680
+ }
80681
+ ]
80682
+ };
80683
+ } else {
80684
+ currentLine.toRun = runIndex;
80685
+ currentLine.toChar = 1;
80686
+ currentLine.width = roundValue(currentLine.width + annotationWidth);
80687
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, annotationHeight);
80688
+ if (!currentLine.segments) currentLine.segments = [];
80689
+ currentLine.segments.push({
80690
+ runIndex,
80691
+ fromChar: 0,
80692
+ toChar: 1,
80693
+ width: annotationWidth,
80694
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
80695
+ });
80696
+ }
80697
+ const tabAlign = lastAppliedTabAlign;
80698
+ if (tabAlign && currentLine && tabAlign.val === "end") {
80699
+ currentLine.width = roundValue(tabAlign.target);
80700
+ }
80701
+ lastAppliedTabAlign = null;
80702
+ continue;
80703
+ }
79651
80704
  if (!("text" in run2) || !("fontSize" in run2)) {
79652
80705
  continue;
79653
80706
  }
@@ -81612,6 +82665,12 @@ function isInRegisteredSurface(event) {
81612
82665
  }
81613
82666
  return false;
81614
82667
  }
82668
+ function isValidFieldAnnotationAttributes(attrs) {
82669
+ if (!attrs || typeof attrs !== "object") return false;
82670
+ const a = attrs;
82671
+ return typeof a.fieldId === "string" && typeof a.fieldType === "string" && typeof a.displayLabel === "string" && typeof a.type === "string";
82672
+ }
82673
+ const FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation";
81615
82674
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
81616
82675
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
81617
82676
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -81637,6 +82696,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81637
82696
  __privateAdd$1(this, _layoutOptions);
81638
82697
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
81639
82698
  __privateAdd$1(this, _domPainter, null);
82699
+ __privateAdd$1(this, _dragHandlerCleanup, null);
81640
82700
  __privateAdd$1(this, _layoutError, null);
81641
82701
  __privateAdd$1(this, _layoutErrorState, "healthy");
81642
82702
  __privateAdd$1(this, _errorBanner, null);
@@ -81695,8 +82755,12 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81695
82755
  if (event.button !== 0) {
81696
82756
  return;
81697
82757
  }
82758
+ const target = event.target;
82759
+ const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
81698
82760
  if (!__privateGet$1(this, _layoutState).layout) {
81699
- event.preventDefault();
82761
+ if (!isDraggableAnnotation) {
82762
+ event.preventDefault();
82763
+ }
81700
82764
  if (document.activeElement instanceof HTMLElement) {
81701
82765
  document.activeElement.blur();
81702
82766
  }
@@ -81705,10 +82769,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81705
82769
  return;
81706
82770
  }
81707
82771
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
81708
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
81709
- if (doc22) {
82772
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
82773
+ if (doc222) {
81710
82774
  try {
81711
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
82775
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
81712
82776
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81713
82777
  } catch (error) {
81714
82778
  if (process$1$1.env.NODE_ENV === "development") {
@@ -81744,7 +82808,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81744
82808
  if (headerFooterRegion) {
81745
82809
  return;
81746
82810
  }
81747
- const hit = clickToPosition(
82811
+ const rawHit = clickToPosition(
81748
82812
  __privateGet$1(this, _layoutState).layout,
81749
82813
  __privateGet$1(this, _layoutState).blocks,
81750
82814
  __privateGet$1(this, _layoutState).measures,
@@ -81753,7 +82817,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81753
82817
  event.clientX,
81754
82818
  event.clientY
81755
82819
  );
81756
- event.preventDefault();
82820
+ const doc22 = __privateGet$1(this, _editor3).state?.doc;
82821
+ const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
82822
+ if (!isDraggableAnnotation) {
82823
+ event.preventDefault();
82824
+ }
81757
82825
  if (!hit) {
81758
82826
  if (document.activeElement instanceof HTMLElement) {
81759
82827
  document.activeElement.blur();
@@ -81761,10 +82829,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81761
82829
  const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
81762
82830
  if (editorDom2) {
81763
82831
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
81764
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
81765
- if (doc22) {
82832
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
82833
+ if (doc222) {
81766
82834
  try {
81767
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
82835
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
81768
82836
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81769
82837
  } catch (error) {
81770
82838
  if (process$1$1.env.NODE_ENV === "development") {
@@ -81785,9 +82853,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81785
82853
  hit.pos
81786
82854
  );
81787
82855
  if (fragmentHit && (fragmentHit.fragment.kind === "image" || fragmentHit.fragment.kind === "drawing")) {
81788
- const doc22 = __privateGet$1(this, _editor3).state.doc;
82856
+ const doc222 = __privateGet$1(this, _editor3).state.doc;
81789
82857
  try {
81790
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc22, hit.pos));
82858
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc222, hit.pos));
81791
82859
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81792
82860
  if (__privateGet$1(this, _lastSelectedImageBlockId) && __privateGet$1(this, _lastSelectedImageBlockId) !== fragmentHit.fragment.blockId) {
81793
82861
  this.emit("imageDeselected", { blockId: __privateGet$1(this, _lastSelectedImageBlockId) });
@@ -81878,8 +82946,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81878
82946
  }
81879
82947
  }
81880
82948
  if (!handledByDepth) {
81881
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
81882
82949
  try {
82950
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
81883
82951
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81884
82952
  } catch {
81885
82953
  }
@@ -81954,6 +83022,90 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81954
83022
  }
81955
83023
  __privateSet(this, _isDragging, false);
81956
83024
  });
83025
+ __privateAdd$1(this, _handleDragOver, (event) => {
83026
+ const activeEditor = this.getActiveEditor();
83027
+ if (!activeEditor?.isEditable) {
83028
+ return;
83029
+ }
83030
+ event.preventDefault();
83031
+ if (event.dataTransfer) {
83032
+ event.dataTransfer.dropEffect = "copy";
83033
+ }
83034
+ const dt = event.dataTransfer;
83035
+ const hasFieldAnnotation = dt?.types?.includes(FIELD_ANNOTATION_DATA_TYPE) || Boolean(dt?.getData?.(FIELD_ANNOTATION_DATA_TYPE));
83036
+ if (!hasFieldAnnotation) {
83037
+ return;
83038
+ }
83039
+ const hit = this.hitTest(event.clientX, event.clientY);
83040
+ const doc22 = activeEditor.state?.doc;
83041
+ if (!hit || !doc22) {
83042
+ return;
83043
+ }
83044
+ const pos = Math.min(Math.max(hit.pos, 1), doc22.content.size);
83045
+ const currentSelection = activeEditor.state.selection;
83046
+ const isSameCursor = currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos;
83047
+ if (isSameCursor) {
83048
+ return;
83049
+ }
83050
+ try {
83051
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc22, pos)).setMeta("addToHistory", false);
83052
+ activeEditor.view?.dispatch(tr);
83053
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
83054
+ } catch (error) {
83055
+ if (process$1$1.env.NODE_ENV === "development") {
83056
+ console.debug("[PresentationEditor] Drag position update skipped:", error);
83057
+ }
83058
+ }
83059
+ });
83060
+ __privateAdd$1(this, _handleDrop, (event) => {
83061
+ const activeEditor = this.getActiveEditor();
83062
+ if (!activeEditor?.isEditable) {
83063
+ return;
83064
+ }
83065
+ if (event.dataTransfer?.types?.includes("application/x-field-annotation")) {
83066
+ return;
83067
+ }
83068
+ event.preventDefault();
83069
+ event.stopPropagation();
83070
+ const fieldAnnotationData = event.dataTransfer?.getData(FIELD_ANNOTATION_DATA_TYPE);
83071
+ if (!fieldAnnotationData) {
83072
+ return;
83073
+ }
83074
+ const hit = this.hitTest(event.clientX, event.clientY);
83075
+ const selection = activeEditor.state?.selection;
83076
+ const fallbackPos = selection?.from ?? activeEditor.state?.doc?.content.size ?? null;
83077
+ const pos = hit?.pos ?? fallbackPos;
83078
+ if (pos == null) {
83079
+ return;
83080
+ }
83081
+ let parsedData = null;
83082
+ try {
83083
+ parsedData = JSON.parse(fieldAnnotationData);
83084
+ } catch {
83085
+ return;
83086
+ }
83087
+ const { attributes, sourceField } = parsedData ?? {};
83088
+ activeEditor.emit?.("fieldAnnotationDropped", {
83089
+ sourceField,
83090
+ editor: activeEditor,
83091
+ coordinates: hit,
83092
+ pos
83093
+ });
83094
+ if (attributes && isValidFieldAnnotationAttributes(attributes)) {
83095
+ activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
83096
+ const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
83097
+ const tr = activeEditor.state?.tr.setSelection(TextSelection$1.create(activeEditor.state.doc, posAfter));
83098
+ if (tr) {
83099
+ activeEditor.view?.dispatch(tr);
83100
+ }
83101
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
83102
+ }
83103
+ const editorDom = activeEditor.view?.dom;
83104
+ if (editorDom) {
83105
+ editorDom.focus();
83106
+ activeEditor.view?.focus();
83107
+ }
83108
+ });
81957
83109
  __privateAdd$1(this, _handleDoubleClick, (event) => {
81958
83110
  if (event.button !== 0) return;
81959
83111
  if (!__privateGet$1(this, _layoutState).layout) return;
@@ -82143,6 +83295,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82143
83295
  __privateMethod$1(this, _PresentationEditor_instances, applyZoom_fn).call(this);
82144
83296
  __privateMethod$1(this, _PresentationEditor_instances, setupEditorListeners_fn).call(this);
82145
83297
  __privateMethod$1(this, _PresentationEditor_instances, setupPointerHandlers_fn).call(this);
83298
+ __privateMethod$1(this, _PresentationEditor_instances, setupDragHandlers_fn).call(this);
82146
83299
  __privateMethod$1(this, _PresentationEditor_instances, setupInputBridge_fn).call(this);
82147
83300
  __privateMethod$1(this, _PresentationEditor_instances, syncTrackedChangesPreferences_fn).call(this);
82148
83301
  if (options.documentId) {
@@ -82854,6 +84007,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82854
84007
  * Safe to call during partial initialization.
82855
84008
  */
82856
84009
  destroy() {
84010
+ var _a2;
82857
84011
  if (__privateGet$1(this, _rafHandle) != null) {
82858
84012
  __privateMethod$1(this, _PresentationEditor_instances, safeCleanup_fn).call(this, () => {
82859
84013
  const win = __privateGet$1(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
@@ -82875,6 +84029,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82875
84029
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
82876
84030
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
82877
84031
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
84032
+ __privateGet$1(this, _viewportHost)?.removeEventListener("dragover", __privateGet$1(this, _handleDragOver));
84033
+ __privateGet$1(this, _viewportHost)?.removeEventListener("drop", __privateGet$1(this, _handleDrop));
82878
84034
  __privateGet$1(this, _visibleHost)?.removeEventListener("keydown", __privateGet$1(this, _handleKeyDown));
82879
84035
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
82880
84036
  __privateGet$1(this, _inputBridge)?.destroy();
@@ -82913,6 +84069,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82913
84069
  __privateSet(this, _session, { mode: "body" });
82914
84070
  __privateSet(this, _activeHeaderFooterEditor, null);
82915
84071
  __privateSet(this, _domPainter, null);
84072
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
84073
+ __privateSet(this, _dragHandlerCleanup, null);
82916
84074
  __privateGet$1(this, _selectionOverlay2)?.remove();
82917
84075
  __privateGet$1(this, _painterHost)?.remove();
82918
84076
  __privateGet$1(this, _hiddenHost)?.remove();
@@ -82940,6 +84098,7 @@ _hiddenHost = /* @__PURE__ */ new WeakMap();
82940
84098
  _layoutOptions = /* @__PURE__ */ new WeakMap();
82941
84099
  _layoutState = /* @__PURE__ */ new WeakMap();
82942
84100
  _domPainter = /* @__PURE__ */ new WeakMap();
84101
+ _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
82943
84102
  _layoutError = /* @__PURE__ */ new WeakMap();
82944
84103
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
82945
84104
  _errorBanner = /* @__PURE__ */ new WeakMap();
@@ -83323,8 +84482,99 @@ setupPointerHandlers_fn = function() {
83323
84482
  __privateGet$1(this, _viewportHost).addEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
83324
84483
  __privateGet$1(this, _viewportHost).addEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
83325
84484
  __privateGet$1(this, _viewportHost).addEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
84485
+ __privateGet$1(this, _viewportHost).addEventListener("dragover", __privateGet$1(this, _handleDragOver));
84486
+ __privateGet$1(this, _viewportHost).addEventListener("drop", __privateGet$1(this, _handleDrop));
83326
84487
  __privateGet$1(this, _visibleHost).addEventListener("keydown", __privateGet$1(this, _handleKeyDown));
83327
84488
  };
84489
+ setupDragHandlers_fn = function() {
84490
+ var _a2;
84491
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
84492
+ __privateSet(this, _dragHandlerCleanup, null);
84493
+ __privateSet(this, _dragHandlerCleanup, createDragHandler(__privateGet$1(this, _painterHost), {
84494
+ onDragOver: (event) => {
84495
+ if (!event.hasFieldAnnotation || event.event.clientX === 0) {
84496
+ return;
84497
+ }
84498
+ const activeEditor = this.getActiveEditor();
84499
+ if (!activeEditor?.isEditable) {
84500
+ return;
84501
+ }
84502
+ const hit = this.hitTest(event.clientX, event.clientY);
84503
+ const doc2 = activeEditor.state?.doc;
84504
+ if (!hit || !doc2) {
84505
+ return;
84506
+ }
84507
+ const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
84508
+ const currentSelection = activeEditor.state.selection;
84509
+ if (currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos) {
84510
+ return;
84511
+ }
84512
+ try {
84513
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc2, pos)).setMeta("addToHistory", false);
84514
+ activeEditor.view?.dispatch(tr);
84515
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
84516
+ } catch {
84517
+ }
84518
+ },
84519
+ onDrop: (event) => {
84520
+ event.event.preventDefault();
84521
+ event.event.stopPropagation();
84522
+ if (event.pmPosition === null) {
84523
+ return;
84524
+ }
84525
+ const activeEditor = this.getActiveEditor();
84526
+ const { state: state2, view } = activeEditor;
84527
+ if (!state2 || !view) {
84528
+ return;
84529
+ }
84530
+ const fieldId = event.data.fieldId;
84531
+ if (fieldId) {
84532
+ const targetPos = event.pmPosition;
84533
+ let sourceStart = null;
84534
+ let sourceEnd = null;
84535
+ let sourceNode = null;
84536
+ state2.doc.descendants((node, pos) => {
84537
+ if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
84538
+ sourceStart = pos;
84539
+ sourceEnd = pos + node.nodeSize;
84540
+ sourceNode = node;
84541
+ return false;
84542
+ }
84543
+ return true;
84544
+ });
84545
+ if (sourceStart === null || sourceEnd === null || !sourceNode) {
84546
+ return;
84547
+ }
84548
+ if (targetPos >= sourceStart && targetPos <= sourceEnd) {
84549
+ return;
84550
+ }
84551
+ const tr = state2.tr;
84552
+ tr.delete(sourceStart, sourceEnd);
84553
+ const mappedTarget = tr.mapping.map(targetPos);
84554
+ if (mappedTarget < 0 || mappedTarget > tr.doc.content.size) {
84555
+ return;
84556
+ }
84557
+ tr.insert(mappedTarget, sourceNode);
84558
+ tr.setMeta("uiEvent", "drop");
84559
+ view.dispatch(tr);
84560
+ return;
84561
+ }
84562
+ const attrs = event.data.attributes;
84563
+ if (attrs && isValidFieldAnnotationAttributes(attrs)) {
84564
+ const inserted = activeEditor.commands?.addFieldAnnotation?.(event.pmPosition, attrs, true);
84565
+ if (inserted) {
84566
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
84567
+ }
84568
+ return;
84569
+ }
84570
+ activeEditor.emit("fieldAnnotationDropped", {
84571
+ sourceField: event.data,
84572
+ editor: activeEditor,
84573
+ coordinates: { pos: event.pmPosition }
84574
+ });
84575
+ }
84576
+ }));
84577
+ };
83328
84578
  setupInputBridge_fn = function() {
83329
84579
  __privateGet$1(this, _inputBridge)?.destroy();
83330
84580
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
@@ -83542,6 +84792,8 @@ isWordCharacter_fn = function(char) {
83542
84792
  _handlePointerMove = /* @__PURE__ */ new WeakMap();
83543
84793
  _handlePointerLeave = /* @__PURE__ */ new WeakMap();
83544
84794
  _handlePointerUp = /* @__PURE__ */ new WeakMap();
84795
+ _handleDragOver = /* @__PURE__ */ new WeakMap();
84796
+ _handleDrop = /* @__PURE__ */ new WeakMap();
83545
84797
  _handleDoubleClick = /* @__PURE__ */ new WeakMap();
83546
84798
  _handleKeyDown = /* @__PURE__ */ new WeakMap();
83547
84799
  focusHeaderFooterShortcut_fn = function(kind) {