superdoc 1.0.0-beta.31 → 1.0.0-beta.33

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 (28) hide show
  1. package/dist/chunks/{PdfViewer-C8iiBtQt.cjs → PdfViewer-1hoKlV0M.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-jGctuklH.es.js → PdfViewer-CVrn4X-3.es.js} +1 -1
  3. package/dist/chunks/{index-Bu5UUj9S.es.js → index-BTDOWM_2.es.js} +57 -32
  4. package/dist/chunks/{index-ELjoBC86.cjs → index-VKd9fPLu.cjs} +57 -32
  5. package/dist/chunks/{index-eG-VYUeN-CIuOnW8W.es.js → index-hX4H5xPH-ChjioDix.es.js} +1 -1
  6. package/dist/chunks/{index-eG-VYUeN-CG3M1n5T.cjs → index-hX4H5xPH-DfkQd7UH.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-BAKZgAuj.es.js → super-editor.es-CpmC4G9F.es.js} +1467 -138
  8. package/dist/chunks/{super-editor.es-DatOA_vA.cjs → super-editor.es-Dzrm58hW.cjs} +1467 -138
  9. package/dist/style.css +33 -33
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-CRKt1TG_.js → converter-DZNL-ld-.js} +1 -1
  12. package/dist/super-editor/chunks/{docx-zipper-CgVw58T-.js → docx-zipper-DukE72iM.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-COQCS1pn.js → editor-CJCGDp-l.js} +1516 -128
  14. package/dist/super-editor/chunks/{index-eG-VYUeN.js → index-hX4H5xPH.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-B3CSV2yT.js → toolbar-D6tqFv6-.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/super-editor.es.js +6 -6
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +1523 -169
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -18281,9 +18281,9 @@
18281
18281
  const areAttrsEqual = (attrsA = {}, attrsB = {}) => {
18282
18282
  return objectIncludes(attrsA, attrsB);
18283
18283
  };
18284
- const TrackInsertMarkName = "trackInsert";
18285
- const TrackDeleteMarkName = "trackDelete";
18286
- const TrackFormatMarkName = "trackFormat";
18284
+ const TrackInsertMarkName$1 = "trackInsert";
18285
+ const TrackDeleteMarkName$1 = "trackDelete";
18286
+ const TrackFormatMarkName$1 = "trackFormat";
18287
18287
  const generateV2HandlerEntity = (handlerName, translator2) => ({
18288
18288
  handlerName,
18289
18289
  handler: (params2) => {
@@ -20049,7 +20049,7 @@
20049
20049
  const runProperties = translator$1N.encode({ ...params2, nodes: [rPr] });
20050
20050
  submarks = encodeMarksFromRPr(runProperties, params2?.docx);
20051
20051
  }
20052
- return [{ type: TrackFormatMarkName, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20052
+ return [{ type: TrackFormatMarkName$1, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20053
20053
  }
20054
20054
  function handleStyleChangeMarks(rPr, currentMarks) {
20055
20055
  const styleChangeMark = rPr.elements?.find((el) => el.name === "w:rPrChange");
@@ -20064,7 +20064,7 @@
20064
20064
  authorEmail: attributes["w:authorEmail"]
20065
20065
  };
20066
20066
  const submarks = parseMarks(styleChangeMark);
20067
- return [{ type: TrackFormatMarkName, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20067
+ return [{ type: TrackFormatMarkName$1, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20068
20068
  }
20069
20069
  function createImportMarks(marks) {
20070
20070
  const textStyleMarksToCombine = marks.filter((mark2) => mark2.type === "textStyle");
@@ -20502,7 +20502,7 @@
20502
20502
  const prepareRunTrackingContext = (node2 = {}) => {
20503
20503
  const marks = Array.isArray(node2.marks) ? node2.marks : [];
20504
20504
  const trackingMarks = marks.filter(
20505
- (mark2) => mark2?.type === TrackInsertMarkName || mark2?.type === TrackDeleteMarkName
20505
+ (mark2) => mark2?.type === TrackInsertMarkName$1 || mark2?.type === TrackDeleteMarkName$1
20506
20506
  );
20507
20507
  if (!trackingMarks.length) {
20508
20508
  return { runNode: node2, trackingMarksByType: /* @__PURE__ */ new Map() };
@@ -20511,7 +20511,7 @@
20511
20511
  trackingMarks.forEach((mark2) => {
20512
20512
  if (mark2?.type) trackingMarksByType.set(mark2.type, cloneMark(mark2));
20513
20513
  });
20514
- const preservedMarks = marks.filter((mark2) => mark2?.type !== TrackInsertMarkName && mark2?.type !== TrackDeleteMarkName).map((mark2) => cloneMark(mark2));
20514
+ const preservedMarks = marks.filter((mark2) => mark2?.type !== TrackInsertMarkName$1 && mark2?.type !== TrackDeleteMarkName$1).map((mark2) => cloneMark(mark2));
20515
20515
  const clonedContent = Array.isArray(node2.content) ? node2.content.map((child) => {
20516
20516
  const childClone = cloneNode(child);
20517
20517
  const childMarks = Array.isArray(childClone.marks) ? childClone.marks.slice() : [];
@@ -20550,8 +20550,8 @@
20550
20550
  return runs2;
20551
20551
  }
20552
20552
  if (!trackingMarksByType.size) return runs2;
20553
- if (trackingMarksByType.has(TrackInsertMarkName)) {
20554
- const mark2 = trackingMarksByType.get(TrackInsertMarkName);
20553
+ if (trackingMarksByType.has(TrackInsertMarkName$1)) {
20554
+ const mark2 = trackingMarksByType.get(TrackInsertMarkName$1);
20555
20555
  const clonedRuns = cloneRuns(runs2);
20556
20556
  const wrapper = {
20557
20557
  name: "w:ins",
@@ -20568,8 +20568,8 @@
20568
20568
  };
20569
20569
  return [wrapper];
20570
20570
  }
20571
- if (trackingMarksByType.has(TrackDeleteMarkName)) {
20572
- const mark2 = trackingMarksByType.get(TrackDeleteMarkName);
20571
+ if (trackingMarksByType.has(TrackDeleteMarkName$1)) {
20572
+ const mark2 = trackingMarksByType.get(TrackDeleteMarkName$1);
20573
20573
  const clonedRuns = cloneRuns(runs2);
20574
20574
  clonedRuns.forEach(renameTextElementsForDeletion);
20575
20575
  const wrapper = {
@@ -41859,7 +41859,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41859
41859
  static getStoredSuperdocVersion(docx) {
41860
41860
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
41861
41861
  }
41862
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.31") {
41862
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.33") {
41863
41863
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
41864
41864
  }
41865
41865
  /**
@@ -53022,7 +53022,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53022
53022
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
53023
53023
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53024
53024
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
53025
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
53025
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
53026
53026
  var GOOD_LEAF_SIZE = 200;
53027
53027
  var RopeSequence = function RopeSequence2() {
53028
53028
  };
@@ -63874,13 +63874,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63874
63874
  return markFound;
63875
63875
  };
63876
63876
  const markInsertion = ({ tr, from: from2, to, user, date }) => {
63877
- tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName]);
63878
- tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName]);
63877
+ tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName$1]);
63878
+ tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName$1]);
63879
63879
  let trackedMark = findTrackedMarkBetween({
63880
63880
  tr,
63881
63881
  from: from2,
63882
63882
  to,
63883
- markName: TrackInsertMarkName,
63883
+ markName: TrackInsertMarkName$1,
63884
63884
  attrs: { authorEmail: user.email }
63885
63885
  });
63886
63886
  let id;
@@ -63889,7 +63889,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63889
63889
  } else {
63890
63890
  id = v4$1();
63891
63891
  }
63892
- const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName].create({
63892
+ const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName$1].create({
63893
63893
  id,
63894
63894
  author: user.name,
63895
63895
  authorEmail: user.email,
@@ -63915,7 +63915,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63915
63915
  tr,
63916
63916
  from: from2,
63917
63917
  to,
63918
- markName: TrackDeleteMarkName,
63918
+ markName: TrackDeleteMarkName$1,
63919
63919
  attrs: { authorEmail: user.email }
63920
63920
  });
63921
63921
  let id;
@@ -63926,7 +63926,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63926
63926
  } else {
63927
63927
  id = v4$1();
63928
63928
  }
63929
- const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName].create({
63929
+ const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName$1].create({
63930
63930
  id,
63931
63931
  author: user.name,
63932
63932
  authorEmail: user.email,
@@ -63939,7 +63939,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63939
63939
  if (node2.type.name.includes("table")) {
63940
63940
  return;
63941
63941
  }
63942
- if (node2.isInline && node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName && mark2.attrs.authorEmail === user.email)) {
63942
+ if (node2.isInline && node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName$1 && mark2.attrs.authorEmail === user.email)) {
63943
63943
  const removeStep = new ReplaceStep(
63944
63944
  deletionMap.map(Math.max(from2, pos)),
63945
63945
  deletionMap.map(Math.min(to, pos + node2.nodeSize)),
@@ -63948,14 +63948,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63948
63948
  if (!tr.maybeStep(removeStep).failed) {
63949
63949
  deletionMap.appendMap(removeStep.getMap());
63950
63950
  }
63951
- } else if (node2.isInline && !node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName)) {
63951
+ } else if (node2.isInline && !node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName$1)) {
63952
63952
  nodes.push(node2);
63953
63953
  tr.addMark(
63954
63954
  deletionMap.map(Math.max(from2, pos)),
63955
63955
  deletionMap.map(Math.min(to, pos + node2.nodeSize)),
63956
63956
  deletionMark
63957
63957
  );
63958
- } else if (node2.attrs.track && !node2.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName) && !["bulletList", "orderedList"].includes(node2.type.name)) ;
63958
+ } else if (node2.attrs.track && !node2.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName$1) && !["bulletList", "orderedList"].includes(node2.type.name)) ;
63959
63959
  });
63960
63960
  return { deletionMark, deletionMap, nodes };
63961
63961
  };
@@ -64022,7 +64022,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64022
64022
  }
64023
64023
  allInlineNodes.forEach(({ node: node2, pos }) => {
64024
64024
  const { marks } = node2;
64025
- const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
64025
+ const trackedMarks = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
64026
64026
  if (marks.length > 0) {
64027
64027
  marks.forEach((mark2) => {
64028
64028
  if (trackedMarks.includes(mark2.type.name)) {
@@ -64135,7 +64135,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64135
64135
  return DecorationSet.empty;
64136
64136
  }
64137
64137
  trackedChanges.forEach(({ mark: mark2, from: from2, to }) => {
64138
- if (mark2.type.name === TrackInsertMarkName) {
64138
+ if (mark2.type.name === TrackInsertMarkName$1) {
64139
64139
  if (onlyOriginalShown) {
64140
64140
  const decoration = Decoration.inline(from2, to, {
64141
64141
  class: "track-insert-dec hidden"
@@ -64153,7 +64153,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64153
64153
  decorations.push(decoration);
64154
64154
  }
64155
64155
  }
64156
- if (mark2.type.name === TrackDeleteMarkName) {
64156
+ if (mark2.type.name === TrackDeleteMarkName$1) {
64157
64157
  if (onlyOriginalShown) {
64158
64158
  const decoration = Decoration.inline(from2, to, {
64159
64159
  class: "track-delete-dec normal"
@@ -64185,7 +64185,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64185
64185
  decorations.push(decorationWidget);
64186
64186
  }
64187
64187
  }
64188
- if (mark2.type.name === TrackFormatMarkName) {
64188
+ if (mark2.type.name === TrackFormatMarkName$1) {
64189
64189
  if (onlyOriginalShown) {
64190
64190
  const decoration = Decoration.inline(from2, to, {
64191
64191
  class: "track-format-dec before"
@@ -64206,7 +64206,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64206
64206
  });
64207
64207
  return DecorationSet.create(state2.doc, decorations);
64208
64208
  };
64209
- const CommentMarkName = "commentMark";
64209
+ const CommentMarkName$1 = "commentMark";
64210
64210
  const resolveCommentMeta = ({ converter, importedId }) => {
64211
64211
  const comments = converter?.comments || [];
64212
64212
  const matchingImportedComment = comments.find((c2) => c2.importedId == importedId);
@@ -64237,7 +64237,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64237
64237
  const removeCommentsById = ({ commentId, state: state2, tr, dispatch }) => {
64238
64238
  const positions = getCommentPositionsById(commentId, state2.doc);
64239
64239
  positions.forEach(({ from: from2, to }) => {
64240
- tr.removeMark(from2, to, state2.schema.marks[CommentMarkName]);
64240
+ tr.removeMark(from2, to, state2.schema.marks[CommentMarkName$1]);
64241
64241
  });
64242
64242
  dispatch(tr);
64243
64243
  };
@@ -64245,7 +64245,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64245
64245
  const positions = [];
64246
64246
  doc2.descendants((node2, pos) => {
64247
64247
  const { marks } = node2;
64248
- const commentMark = marks.find((mark2) => mark2.type.name === CommentMarkName);
64248
+ const commentMark = marks.find((mark2) => mark2.type.name === CommentMarkName$1);
64249
64249
  if (commentMark) {
64250
64250
  const { attrs } = commentMark;
64251
64251
  const { commentId: currentCommentId } = attrs;
@@ -64265,7 +64265,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64265
64265
  const endNodes = [];
64266
64266
  const seen = /* @__PURE__ */ new Set();
64267
64267
  doc2.descendants((node2, pos) => {
64268
- const commentMarks = node2.marks?.filter((mark2) => mark2.type.name === CommentMarkName) || [];
64268
+ const commentMarks = node2.marks?.filter((mark2) => mark2.type.name === CommentMarkName$1) || [];
64269
64269
  commentMarks.forEach((commentMark) => {
64270
64270
  const { attrs = {} } = commentMark;
64271
64271
  const { commentId } = attrs;
@@ -64393,7 +64393,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64393
64393
  importedId,
64394
64394
  internal: itemToMark.internal
64395
64395
  };
64396
- tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
64396
+ tr.addMark(start2, pos + 1, schema.marks[CommentMarkName$1].create(markAttrs));
64397
64397
  toDelete.push({ start: pos, end: pos + 1 });
64398
64398
  } else if (type2.name === "commentReference") {
64399
64399
  toDelete.push({ start: pos, end: pos + 1 });
@@ -64511,7 +64511,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64511
64511
  existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
64512
64512
  }
64513
64513
  };
64514
- const TRACK_CHANGE_MARKS = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
64514
+ const TRACK_CHANGE_MARKS = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
64515
64515
  const CommentsPluginKey = new PluginKey("comments");
64516
64516
  const CommentsPlugin = Extension.create({
64517
64517
  name: "comments",
@@ -64527,7 +64527,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64527
64527
  tr.addMark(
64528
64528
  $from.pos,
64529
64529
  $to.pos,
64530
- this.editor.schema.marks[CommentMarkName].create({
64530
+ this.editor.schema.marks[CommentMarkName$1].create({
64531
64531
  commentId: resolvedCommentId,
64532
64532
  internal: resolvedInternal
64533
64533
  })
@@ -64567,7 +64567,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64567
64567
  doc2.descendants((node2, pos) => {
64568
64568
  if (foundStartNode) return;
64569
64569
  const { marks = [] } = node2;
64570
- const commentMark = marks.find((mark2) => mark2.type.name === CommentMarkName);
64570
+ const commentMark = marks.find((mark2) => mark2.type.name === CommentMarkName$1);
64571
64571
  if (commentMark) {
64572
64572
  const { attrs } = commentMark;
64573
64573
  const wid = attrs.commentId;
@@ -64581,7 +64581,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64581
64581
  tr.addMark(
64582
64582
  foundPos,
64583
64583
  foundPos + foundStartNode.nodeSize,
64584
- this.editor.schema.marks[CommentMarkName].create({
64584
+ this.editor.schema.marks[CommentMarkName$1].create({
64585
64585
  commentId,
64586
64586
  internal: isInternal
64587
64587
  })
@@ -64710,10 +64710,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64710
64710
  prevDoc = doc2;
64711
64711
  shouldUpdate = false;
64712
64712
  const decorations = [];
64713
- const allCommentPositions = onlyActiveThreadChanged ? prevAllCommentPositions : {};
64713
+ const allCommentPositions = {};
64714
64714
  doc2.descendants((node2, pos) => {
64715
64715
  const { marks = [] } = node2;
64716
- const commentMarks = marks.filter((mark2) => mark2.type.name === CommentMarkName);
64716
+ const commentMarks = marks.filter((mark2) => mark2.type.name === CommentMarkName$1);
64717
64717
  let hasActive = false;
64718
64718
  commentMarks.forEach((commentMark) => {
64719
64719
  const { attrs } = commentMark;
@@ -64839,7 +64839,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64839
64839
  return;
64840
64840
  }
64841
64841
  const { marks = [] } = node2;
64842
- const commentMark = marks.find((mark2) => mark2.type.name === CommentMarkName);
64842
+ const commentMark = marks.find((mark2) => mark2.type.name === CommentMarkName$1);
64843
64843
  if (commentMark) {
64844
64844
  overlaps.push({
64845
64845
  node: node2,
@@ -64862,7 +64862,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64862
64862
  }
64863
64863
  });
64864
64864
  const { marks: closestMarks = [] } = closestCommentRangeStart || {};
64865
- const closestCommentMark = closestMarks.find((mark2) => mark2.type.name === CommentMarkName);
64865
+ const closestCommentMark = closestMarks.find((mark2) => mark2.type.name === CommentMarkName$1);
64866
64866
  return closestCommentMark?.attrs?.commentId || closestCommentMark?.attrs?.importedId;
64867
64867
  };
64868
64868
  const findTrackedMark = ({
@@ -64912,7 +64912,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64912
64912
  let nodes = step?.slice?.content?.content || [];
64913
64913
  if (!nodes.length) {
64914
64914
  newEditorState.doc.descendants((node2) => {
64915
- const hasFormatMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
64915
+ const hasFormatMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName$1);
64916
64916
  if (hasFormatMark) {
64917
64917
  nodes = [node2];
64918
64918
  return false;
@@ -64937,19 +64937,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64937
64937
  const getTrackedChangeText = ({ nodes, mark: mark2, trackedChangeType, isDeletionInsertion }) => {
64938
64938
  let trackedChangeText = "";
64939
64939
  let deletionText = "";
64940
- if (trackedChangeType === TrackInsertMarkName) {
64940
+ if (trackedChangeType === TrackInsertMarkName$1) {
64941
64941
  trackedChangeText = nodes.reduce((acc, node2) => {
64942
64942
  if (!node2.marks.find((nodeMark) => nodeMark.type.name === mark2.type.name)) return acc;
64943
64943
  acc += node2?.text || node2?.textContent || "";
64944
64944
  return acc;
64945
64945
  }, "");
64946
64946
  }
64947
- if (trackedChangeType === TrackFormatMarkName) {
64947
+ if (trackedChangeType === TrackFormatMarkName$1) {
64948
64948
  trackedChangeText = translateFormatChangesToEnglish(mark2.attrs);
64949
64949
  }
64950
- if (trackedChangeType === TrackDeleteMarkName || isDeletionInsertion) {
64950
+ if (trackedChangeType === TrackDeleteMarkName$1 || isDeletionInsertion) {
64951
64951
  deletionText = nodes.reduce((acc, node2) => {
64952
- if (!node2.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName)) return acc;
64952
+ if (!node2.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName$1)) return acc;
64953
64953
  acc += node2?.text || node2?.textContent || "";
64954
64954
  return acc;
64955
64955
  }, "");
@@ -65015,7 +65015,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65015
65015
  if (to === null || pos + node2.nodeSize > to) to = pos + node2.nodeSize;
65016
65016
  }
65017
65017
  const commentMark = node2.marks.find(
65018
- (m2) => m2.type.name === CommentMarkName && (m2.attrs.commentId === id || m2.attrs.importedId === id)
65018
+ (m2) => m2.type.name === CommentMarkName$1 && (m2.attrs.commentId === id || m2.attrs.importedId === id)
65019
65019
  );
65020
65020
  if (commentMark) {
65021
65021
  if (from2 === null || pos < from2) from2 = pos;
@@ -65025,7 +65025,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65025
65025
  return from2 !== null && to !== null ? { from: from2, to } : null;
65026
65026
  }
65027
65027
  const replaceStep = ({ state: state2, tr, step, newTr, map: map2, user, date, originalStep, originalStepIndex }) => {
65028
- const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName];
65028
+ const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName$1];
65029
65029
  const deletionMark = findMark(state2, deletionMarkSchema, false);
65030
65030
  const positionTo = deletionMark ? deletionMark.to : step.to;
65031
65031
  const newStep = new ReplaceStep(
@@ -65089,17 +65089,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65089
65089
  if (!node2.isInline) {
65090
65090
  return;
65091
65091
  }
65092
- if (node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName)) {
65092
+ if (node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName$1)) {
65093
65093
  return false;
65094
65094
  }
65095
65095
  const existingChangeMark = node2.marks.find(
65096
- (mark2) => [TrackDeleteMarkName, TrackFormatMarkName].includes(mark2.type.name)
65096
+ (mark2) => [TrackDeleteMarkName$1, TrackFormatMarkName$1].includes(mark2.type.name)
65097
65097
  );
65098
65098
  const wid = existingChangeMark ? existingChangeMark.attrs.id : v4$1();
65099
65099
  newTr.addMark(Math.max(step.from, pos), Math.min(step.to, pos + node2.nodeSize), step.mark);
65100
65100
  const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
65101
65101
  if (allowedMarks.includes(step.mark.type.name) && !node2.marks.find((mark2) => mark2.type === step.mark.type)) {
65102
- const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
65102
+ const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName$1);
65103
65103
  let after = [];
65104
65104
  let before = [];
65105
65105
  if (formatChangeMark) {
@@ -65135,7 +65135,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65135
65135
  ];
65136
65136
  }
65137
65137
  if (after.length || before.length) {
65138
- const newFormatMark = state2.schema.marks[TrackFormatMarkName].create({
65138
+ const newFormatMark = state2.schema.marks[TrackFormatMarkName$1].create({
65139
65139
  id: wid,
65140
65140
  author: user.name,
65141
65141
  authorEmail: user.email,
@@ -65167,13 +65167,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65167
65167
  if (!node2.isInline) {
65168
65168
  return true;
65169
65169
  }
65170
- if (node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName)) {
65170
+ if (node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName$1)) {
65171
65171
  return false;
65172
65172
  }
65173
65173
  newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node2.nodeSize), step.mark);
65174
65174
  const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
65175
65175
  if (allowedMarks.includes(step.mark.type.name) && node2.marks.find((mark2) => mark2.type === step.mark.type)) {
65176
- const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
65176
+ const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName$1);
65177
65177
  let after = [];
65178
65178
  let before = [];
65179
65179
  if (formatChangeMark) {
@@ -65201,7 +65201,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65201
65201
  ];
65202
65202
  }
65203
65203
  if (after.length || before.length) {
65204
- const newFormatMark = state2.schema.marks[TrackFormatMarkName].create({
65204
+ const newFormatMark = state2.schema.marks[TrackFormatMarkName$1].create({
65205
65205
  id: v4$1(),
65206
65206
  author: user.name,
65207
65207
  authorEmail: user.email,
@@ -65282,7 +65282,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65282
65282
  newTr.setMeta("addToHistory", tr.getMeta("addToHistory"));
65283
65283
  }
65284
65284
  if (tr.selectionSet) {
65285
- const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName];
65285
+ const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName$1];
65286
65286
  const deletionMark = findMark(state2, deletionMarkSchema, false);
65287
65287
  if (tr.selection instanceof TextSelection$1 && (tr.selection.from < state2.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
65288
65288
  const caretPos = map2.map(tr.selection.from, -1);
@@ -66889,7 +66889,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66889
66889
  const shouldSkipNodeView = (editor) => {
66890
66890
  return isHeadless(editor);
66891
66891
  };
66892
- const summaryVersion = "1.0.0-beta.31";
66892
+ const summaryVersion = "1.0.0-beta.33";
66893
66893
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
66894
66894
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
66895
66895
  function mapAttributes(attrs) {
@@ -67678,7 +67678,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67678
67678
  { default: remarkStringify2 },
67679
67679
  { default: remarkGfm2 }
67680
67680
  ] = await Promise.all([
67681
- Promise.resolve().then(() => indexEGVYUeN),
67681
+ Promise.resolve().then(() => indexHX4H5xPH),
67682
67682
  Promise.resolve().then(() => indexDRCvimau),
67683
67683
  Promise.resolve().then(() => indexC_x_N6Uh),
67684
67684
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -67883,7 +67883,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67883
67883
  * Process collaboration migrations
67884
67884
  */
67885
67885
  processCollaborationMigrations() {
67886
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.31");
67886
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.33");
67887
67887
  if (!this.options.ydoc) return;
67888
67888
  const metaMap = this.options.ydoc.getMap("meta");
67889
67889
  let docVersion = metaMap.get("version");
@@ -73025,7 +73025,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73025
73025
  blocks2.push(block);
73026
73026
  recordBlockKind(block.kind);
73027
73027
  });
73028
- } else if (child.type === "table") ;
73028
+ } else if (child.type === "table") {
73029
+ const tableNodeToBlock2 = converters?.tableNodeToBlock;
73030
+ if (tableNodeToBlock2) {
73031
+ const tableBlock = tableNodeToBlock2(
73032
+ child,
73033
+ nextBlockId,
73034
+ positions,
73035
+ defaultFont,
73036
+ defaultSize,
73037
+ styleContext,
73038
+ trackedChangesConfig,
73039
+ bookmarks,
73040
+ hyperlinkConfig
73041
+ );
73042
+ if (tableBlock) {
73043
+ applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
73044
+ blocks2.push(tableBlock);
73045
+ recordBlockKind(tableBlock.kind);
73046
+ }
73047
+ }
73048
+ }
73029
73049
  });
73030
73050
  }
73031
73051
  function processParagraphChild(child, sectionMetadata, context, output, converters) {
@@ -73495,6 +73515,65 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73495
73515
  }
73496
73516
  return run2;
73497
73517
  }
73518
+ function fieldAnnotationNodeToRun(node2, positions, fieldMetadata) {
73519
+ const attrs = node2.attrs ?? {};
73520
+ const rawVariant = attrs.type ?? fieldMetadata?.variant ?? "text";
73521
+ const validVariants = ["text", "image", "signature", "checkbox", "html", "link"];
73522
+ const variant = validVariants.includes(rawVariant) ? rawVariant : "text";
73523
+ const displayLabel = (typeof attrs.displayLabel === "string" ? attrs.displayLabel : void 0) || (typeof attrs.defaultDisplayLabel === "string" ? attrs.defaultDisplayLabel : void 0) || (typeof fieldMetadata?.displayLabel === "string" ? fieldMetadata.displayLabel : void 0) || (typeof fieldMetadata?.defaultDisplayLabel === "string" ? fieldMetadata.defaultDisplayLabel : void 0) || (typeof attrs.alias === "string" ? attrs.alias : void 0) || (typeof fieldMetadata?.alias === "string" ? fieldMetadata.alias : void 0) || "";
73524
+ const run2 = {
73525
+ kind: "fieldAnnotation",
73526
+ variant,
73527
+ displayLabel
73528
+ };
73529
+ const fieldId = typeof attrs.fieldId === "string" ? attrs.fieldId : fieldMetadata?.fieldId;
73530
+ if (fieldId) run2.fieldId = fieldId;
73531
+ const fieldType = typeof attrs.fieldType === "string" ? attrs.fieldType : fieldMetadata?.fieldType;
73532
+ if (fieldType) run2.fieldType = fieldType;
73533
+ const fieldColor = typeof attrs.fieldColor === "string" ? attrs.fieldColor : fieldMetadata?.fieldColor;
73534
+ if (fieldColor) run2.fieldColor = fieldColor;
73535
+ const borderColor = typeof attrs.borderColor === "string" ? attrs.borderColor : fieldMetadata?.borderColor;
73536
+ if (borderColor) run2.borderColor = borderColor;
73537
+ const highlighted = attrs.highlighted ?? fieldMetadata?.highlighted;
73538
+ if (highlighted === false) run2.highlighted = false;
73539
+ if (attrs.hidden === true || fieldMetadata?.hidden === true) run2.hidden = true;
73540
+ const visibility = attrs.visibility ?? fieldMetadata?.visibility;
73541
+ if (visibility === "hidden") run2.visibility = "hidden";
73542
+ const imageSrc = typeof attrs.imageSrc === "string" ? attrs.imageSrc : fieldMetadata?.imageSrc;
73543
+ if (imageSrc) run2.imageSrc = imageSrc;
73544
+ const linkUrl = typeof attrs.linkUrl === "string" ? attrs.linkUrl : fieldMetadata?.linkUrl;
73545
+ if (linkUrl) run2.linkUrl = linkUrl;
73546
+ const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
73547
+ if (typeof rawHtml === "string") run2.rawHtml = rawHtml;
73548
+ const size2 = attrs.size ?? fieldMetadata?.size;
73549
+ if (size2 && (typeof size2.width === "number" || typeof size2.height === "number")) {
73550
+ run2.size = {
73551
+ width: typeof size2.width === "number" ? size2.width : void 0,
73552
+ height: typeof size2.height === "number" ? size2.height : void 0
73553
+ };
73554
+ }
73555
+ const fontFamily2 = attrs.fontFamily ?? fieldMetadata?.fontFamily;
73556
+ if (typeof fontFamily2 === "string") run2.fontFamily = fontFamily2;
73557
+ const fontSize2 = attrs.fontSize ?? fieldMetadata?.fontSize;
73558
+ if (typeof fontSize2 === "string" || typeof fontSize2 === "number") run2.fontSize = fontSize2;
73559
+ const textColor = attrs.textColor ?? fieldMetadata?.textColor;
73560
+ if (typeof textColor === "string") run2.textColor = textColor;
73561
+ const textHighlight = attrs.textHighlight ?? fieldMetadata?.textHighlight;
73562
+ if (typeof textHighlight === "string") run2.textHighlight = textHighlight;
73563
+ const formatting = fieldMetadata?.formatting;
73564
+ if (attrs.bold === true || formatting?.bold === true) run2.bold = true;
73565
+ if (attrs.italic === true || formatting?.italic === true) run2.italic = true;
73566
+ if (attrs.underline === true || formatting?.underline === true) run2.underline = true;
73567
+ const pos = positions.get(node2);
73568
+ if (pos) {
73569
+ run2.pmStart = pos.start;
73570
+ run2.pmEnd = pos.end;
73571
+ }
73572
+ if (fieldMetadata) {
73573
+ run2.sdt = fieldMetadata;
73574
+ }
73575
+ return run2;
73576
+ }
73498
73577
  const isTextRun$1 = (run2) => run2.kind !== "tab";
73499
73578
  const dataAttrsCompatible = (a2, b2) => {
73500
73579
  const aAttrs = a2.dataAttrs;
@@ -73790,28 +73869,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73790
73869
  }
73791
73870
  if (node2.type === "fieldAnnotation") {
73792
73871
  const fieldMetadata = resolveNodeSdtMetadata(node2, "fieldAnnotation");
73872
+ let contentText;
73793
73873
  if (Array.isArray(node2.content) && node2.content.length > 0) {
73794
- node2.content.forEach((child) => visitNode(child, inheritedMarks, fieldMetadata ?? activeSdt, activeRunStyleId));
73795
- } else {
73796
- const nodeAttrs = typeof node2.attrs === "object" && node2.attrs !== null ? node2.attrs : {};
73797
- const label = (typeof nodeAttrs.displayLabel === "string" ? nodeAttrs.displayLabel : void 0) || (typeof nodeAttrs.defaultDisplayLabel === "string" ? nodeAttrs.defaultDisplayLabel : void 0) || (typeof nodeAttrs.alias === "string" ? nodeAttrs.alias : void 0) || "";
73798
- if (label && typeof label === "string") {
73799
- const run2 = textNodeToRun(
73800
- { type: "text", text: label },
73801
- positions,
73802
- defaultFont,
73803
- defaultSize,
73804
- inheritedMarks,
73805
- fieldMetadata ?? activeSdt,
73806
- hyperlinkConfig,
73807
- themeColors
73808
- );
73809
- const inlineStyleId = getInlineStyleId(inheritedMarks);
73810
- applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
73811
- applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
73812
- currentRuns.push(run2);
73813
- }
73874
+ const extractText = (n) => {
73875
+ if (n.type === "text" && typeof n.text === "string") return n.text;
73876
+ if (Array.isArray(n.content)) {
73877
+ return n.content.map(extractText).join("");
73878
+ }
73879
+ return "";
73880
+ };
73881
+ contentText = node2.content.map(extractText).join("");
73814
73882
  }
73883
+ const nodeForRun = contentText && contentText.length > 0 ? { ...node2, attrs: { ...node2.attrs ?? {}, displayLabel: contentText } } : node2;
73884
+ const run2 = fieldAnnotationNodeToRun(nodeForRun, positions, fieldMetadata);
73885
+ currentRuns.push(run2);
73815
73886
  return;
73816
73887
  }
73817
73888
  if (node2.type === "pageReference") {
@@ -74648,9 +74719,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74648
74719
  }
74649
74720
  const attrs = spacingEl.attributes;
74650
74721
  const spacing = {};
74651
- const before = parseIntSafe(attrs["w:before"]);
74652
- const after = parseIntSafe(attrs["w:after"]);
74653
- const line = parseIntSafe(attrs["w:line"]);
74722
+ const before = parseIntSafe$1(attrs["w:before"]);
74723
+ const after = parseIntSafe$1(attrs["w:after"]);
74724
+ const line = parseIntSafe$1(attrs["w:line"]);
74654
74725
  const rawLineRule = attrs["w:lineRule"];
74655
74726
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
74656
74727
  if (before != null) spacing.before = twipsToPx$1(before);
@@ -74665,11 +74736,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74665
74736
  if (lineRule) spacing.lineRule = lineRule;
74666
74737
  const result = Object.keys(spacing).length > 0 ? { spacing } : void 0;
74667
74738
  return result;
74668
- } catch (err) {
74739
+ } catch {
74669
74740
  return void 0;
74670
74741
  }
74671
74742
  };
74672
- const parseIntSafe = (value) => {
74743
+ const parseIntSafe$1 = (value) => {
74673
74744
  if (value == null) return void 0;
74674
74745
  const num = typeof value === "number" ? value : parseInt(String(value), 10);
74675
74746
  return Number.isFinite(num) ? num : void 0;
@@ -75321,7 +75392,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75321
75392
  return measurementCtx;
75322
75393
  }
75323
75394
  function getRunFontString(run2) {
75324
- if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
75395
+ if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
75325
75396
  return "normal normal 16px Arial";
75326
75397
  }
75327
75398
  const style2 = run2.italic ? "italic" : "normal";
@@ -75352,6 +75423,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75352
75423
  result.push(run2);
75353
75424
  continue;
75354
75425
  }
75426
+ if (run2.kind === "fieldAnnotation") {
75427
+ result.push(run2);
75428
+ continue;
75429
+ }
75355
75430
  const text2 = run2.text ?? "";
75356
75431
  const isFirstRun = runIndex === line.fromRun;
75357
75432
  const isLastRun = runIndex === line.toRun;
@@ -75385,7 +75460,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75385
75460
  1,
75386
75461
  runs22.reduce((sum, run2) => {
75387
75462
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
75388
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
75463
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
75464
+ return sum;
75389
75465
  return sum + (run2.text ?? "").length;
75390
75466
  }, 0)
75391
75467
  );
@@ -75406,7 +75482,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75406
75482
  currentCharOffset += runLength2;
75407
75483
  continue;
75408
75484
  }
75409
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
75485
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
75410
75486
  const runLength = text2.length;
75411
75487
  if (currentCharOffset + runLength >= charOffset) {
75412
75488
  const offsetInRun = charOffset - currentCharOffset;
@@ -75449,7 +75525,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75449
75525
  if (isTabRun$1(run2)) {
75450
75526
  return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
75451
75527
  }
75452
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
75528
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
75453
75529
  return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
75454
75530
  }
75455
75531
  const text2 = run2.text ?? "";
@@ -75478,7 +75554,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75478
75554
  let lastPm = fallbackPmStart;
75479
75555
  for (const run2 of runs2) {
75480
75556
  const isTab = isTabRun$1(run2);
75481
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
75557
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
75482
75558
  const runLength = isTab ? TAB_CHAR_LENGTH : text2.length;
75483
75559
  const runPmStart = typeof run2.pmStart === "number" ? run2.pmStart : null;
75484
75560
  const runPmEnd = typeof run2.pmEnd === "number" ? run2.pmEnd : runPmStart != null ? runPmStart + runLength : null;
@@ -75504,7 +75580,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75504
75580
  1,
75505
75581
  runs22.reduce((sum, run2) => {
75506
75582
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
75507
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
75583
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
75584
+ return sum;
75508
75585
  return sum + (run2.text ?? "").length;
75509
75586
  }, 0)
75510
75587
  );
@@ -75539,7 +75616,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75539
75616
  currentCharOffset += TAB_CHAR_LENGTH;
75540
75617
  continue;
75541
75618
  }
75542
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
75619
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
75543
75620
  const runLength = text2.length;
75544
75621
  if (runLength === 0) continue;
75545
75622
  ctx2.font = getRunFontString(run2);
@@ -75579,7 +75656,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75579
75656
  };
75580
75657
  }
75581
75658
  const computeLetterSpacingWidth = (run2, precedingChars, runLength) => {
75582
- if (isTabRun$1(run2) || "src" in run2 || !("letterSpacing" in run2) || !run2.letterSpacing) {
75659
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "fieldAnnotation" || !("letterSpacing" in run2) || !run2.letterSpacing) {
75583
75660
  return 0;
75584
75661
  }
75585
75662
  const maxGaps = Math.max(runLength - 1, 0);
@@ -75676,6 +75753,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75676
75753
  pmStart: fragmentEl.dataset.pmStart,
75677
75754
  pmEnd: fragmentEl.dataset.pmEnd
75678
75755
  });
75756
+ const hitChainLine = hitChain.find(
75757
+ (el) => el.classList?.contains?.(CLASS_NAMES$1.line) && el.dataset?.pmStart !== void 0 && el.dataset?.pmEnd !== void 0
75758
+ );
75759
+ if (hitChainLine) {
75760
+ log("Using hit chain line directly:", {
75761
+ pmStart: hitChainLine.dataset.pmStart,
75762
+ pmEnd: hitChainLine.dataset.pmEnd
75763
+ });
75764
+ const result2 = processLineElement(hitChainLine, viewX);
75765
+ return result2;
75766
+ }
75679
75767
  const result = processFragment(fragmentEl, viewX, viewY);
75680
75768
  return result;
75681
75769
  }
@@ -75741,7 +75829,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75741
75829
  if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
75742
75830
  return null;
75743
75831
  }
75744
- const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
75832
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
75833
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
75834
+ );
75745
75835
  log(
75746
75836
  "Spans/anchors in line:",
75747
75837
  spanEls.map((el, i2) => {
@@ -75800,6 +75890,77 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75800
75890
  const pos = spanStart + charIndex;
75801
75891
  return pos;
75802
75892
  }
75893
+ function processLineElement(lineEl, viewX) {
75894
+ const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
75895
+ const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
75896
+ const lineRect = lineEl.getBoundingClientRect();
75897
+ log("processLineElement:", {
75898
+ pmStart: lineStart,
75899
+ pmEnd: lineEnd,
75900
+ rect: { top: lineRect.top, bottom: lineRect.bottom, left: lineRect.left, right: lineRect.right }
75901
+ });
75902
+ if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
75903
+ return null;
75904
+ }
75905
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
75906
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
75907
+ );
75908
+ log(
75909
+ "Spans/anchors in line:",
75910
+ spanEls.map((el, i2) => {
75911
+ const rect = el.getBoundingClientRect();
75912
+ return {
75913
+ index: i2,
75914
+ tag: el.tagName,
75915
+ pmStart: el.dataset.pmStart,
75916
+ pmEnd: el.dataset.pmEnd,
75917
+ text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
75918
+ visibility: el.style.visibility,
75919
+ rect: { left: rect.left, right: rect.right, width: rect.width }
75920
+ };
75921
+ })
75922
+ );
75923
+ if (spanEls.length === 0) {
75924
+ return lineStart;
75925
+ }
75926
+ const firstRect = spanEls[0].getBoundingClientRect();
75927
+ if (viewX <= firstRect.left) {
75928
+ return lineStart;
75929
+ }
75930
+ const lastRect = spanEls[spanEls.length - 1].getBoundingClientRect();
75931
+ if (viewX >= lastRect.right) {
75932
+ return lineEnd;
75933
+ }
75934
+ const targetEl = findSpanAtX(spanEls, viewX);
75935
+ if (!targetEl) {
75936
+ return lineStart;
75937
+ }
75938
+ const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
75939
+ const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
75940
+ const targetRect = targetEl.getBoundingClientRect();
75941
+ log("Target element:", {
75942
+ tag: targetEl.tagName,
75943
+ pmStart: spanStart,
75944
+ pmEnd: spanEnd,
75945
+ text: targetEl.textContent?.substring(0, 30),
75946
+ visibility: targetEl.style.visibility,
75947
+ rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
75948
+ });
75949
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
75950
+ return null;
75951
+ }
75952
+ const firstChild = targetEl.firstChild;
75953
+ if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
75954
+ const elRect = targetEl.getBoundingClientRect();
75955
+ const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
75956
+ const snapPos = closerToLeft ? spanStart : spanEnd;
75957
+ return snapPos;
75958
+ }
75959
+ const textNode = firstChild;
75960
+ const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
75961
+ const pos = spanStart + charIndex;
75962
+ return pos;
75963
+ }
75803
75964
  function findLineAtY(lineEls, viewY) {
75804
75965
  if (lineEls.length === 0) {
75805
75966
  return null;
@@ -78690,7 +78851,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
78690
78851
  return `img:${srcHash}:${imgRun.width}x${imgRun.height}`;
78691
78852
  }
78692
78853
  const text2 = normalizeText(
78693
- "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
78854
+ "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? ""
78694
78855
  );
78695
78856
  const bold = "bold" in run2 ? run2.bold : false;
78696
78857
  const italic = "italic" in run2 ? run2.italic : false;
@@ -79402,7 +79563,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79402
79563
  let pmStart = Infinity;
79403
79564
  let pmEnd = 0;
79404
79565
  for (const run2 of block.runs) {
79405
- text2 += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text;
79566
+ text2 += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text;
79406
79567
  if (run2.pmStart !== void 0) {
79407
79568
  pmStart = Math.min(pmStart, run2.pmStart);
79408
79569
  }
@@ -79452,7 +79613,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79452
79613
  return `${italic}${bold}${size2}px ${family}`.trim();
79453
79614
  }
79454
79615
  function runText(run2) {
79455
- return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
79616
+ return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
79456
79617
  }
79457
79618
  function measureRunSliceWidth(run2, fromChar, toChar) {
79458
79619
  const context = getCtx();
@@ -79614,7 +79775,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79614
79775
  for (let i2 = 0; i2 < a2.runs.length; i2 += 1) {
79615
79776
  const runA = a2.runs[i2];
79616
79777
  const runB = b2.runs[i2];
79617
- if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
79778
+ if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
79618
79779
  return false;
79619
79780
  }
79620
79781
  }
@@ -79734,7 +79895,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79734
79895
  parts.push(block.id);
79735
79896
  if (block.kind === "paragraph") {
79736
79897
  for (const run2 of block.runs) {
79737
- if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
79898
+ if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break" && run2.kind !== "fieldAnnotation") {
79738
79899
  parts.push(run2.text ?? "");
79739
79900
  }
79740
79901
  if ("bold" in run2 && run2.bold) parts.push("b");
@@ -80219,6 +80380,255 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80219
80380
  /** P3: Heavy debounce for full document layout */
80220
80381
  [Priority.P3]: 150
80221
80382
  });
80383
+ const DEFAULT_MIME_TYPE$1 = "application/x-field-annotation";
80384
+ const LEGACY_MIME_TYPE = "fieldAnnotation";
80385
+ function parseIntSafe(value) {
80386
+ if (!value) return void 0;
80387
+ const parsed = parseInt(value, 10);
80388
+ return Number.isFinite(parsed) ? parsed : void 0;
80389
+ }
80390
+ function extractFieldAnnotationData(element2) {
80391
+ const dataset = element2.dataset;
80392
+ const attributes = {};
80393
+ for (const key2 in dataset) {
80394
+ const value = dataset[key2];
80395
+ if (value !== void 0) {
80396
+ attributes[key2] = value;
80397
+ }
80398
+ }
80399
+ return {
80400
+ fieldId: dataset.fieldId,
80401
+ fieldType: dataset.fieldType,
80402
+ variant: dataset.variant ?? dataset.type,
80403
+ displayLabel: dataset.displayLabel,
80404
+ pmStart: parseIntSafe(dataset.pmStart),
80405
+ pmEnd: parseIntSafe(dataset.pmEnd),
80406
+ attributes
80407
+ };
80408
+ }
80409
+ class DragHandler {
80410
+ /**
80411
+ * Creates a new DragHandler instance.
80412
+ *
80413
+ * @param container - The DOM container element (typically .superdoc-layout)
80414
+ * @param config - Configuration options and callbacks
80415
+ */
80416
+ constructor(container, config2 = {}) {
80417
+ this.container = container;
80418
+ this.config = config2;
80419
+ this.mimeType = config2.mimeType ?? DEFAULT_MIME_TYPE$1;
80420
+ this.boundHandlers = {
80421
+ dragstart: this.handleDragStart.bind(this),
80422
+ dragover: this.handleDragOver.bind(this),
80423
+ drop: this.handleDrop.bind(this),
80424
+ dragend: this.handleDragEnd.bind(this),
80425
+ dragleave: this.handleDragLeave.bind(this)
80426
+ };
80427
+ this.windowDragoverHandler = this.handleWindowDragOver.bind(this);
80428
+ this.windowDropHandler = this.handleWindowDrop.bind(this);
80429
+ this.attachListeners();
80430
+ }
80431
+ /**
80432
+ * Attaches event listeners to the container and window.
80433
+ */
80434
+ attachListeners() {
80435
+ this.container.addEventListener("dragstart", this.boundHandlers.dragstart);
80436
+ this.container.addEventListener("dragover", this.boundHandlers.dragover);
80437
+ this.container.addEventListener("drop", this.boundHandlers.drop);
80438
+ this.container.addEventListener("dragend", this.boundHandlers.dragend);
80439
+ this.container.addEventListener("dragleave", this.boundHandlers.dragleave);
80440
+ window.addEventListener("dragover", this.windowDragoverHandler, false);
80441
+ window.addEventListener("drop", this.windowDropHandler, false);
80442
+ }
80443
+ /**
80444
+ * Removes event listeners from the container and window.
80445
+ */
80446
+ removeListeners() {
80447
+ this.container.removeEventListener("dragstart", this.boundHandlers.dragstart);
80448
+ this.container.removeEventListener("dragover", this.boundHandlers.dragover);
80449
+ this.container.removeEventListener("drop", this.boundHandlers.drop);
80450
+ this.container.removeEventListener("dragend", this.boundHandlers.dragend);
80451
+ this.container.removeEventListener("dragleave", this.boundHandlers.dragleave);
80452
+ window.removeEventListener("dragover", this.windowDragoverHandler, false);
80453
+ window.removeEventListener("drop", this.windowDropHandler, false);
80454
+ }
80455
+ /**
80456
+ * Handles dragover at window level to allow drops on overlay elements.
80457
+ * This ensures preventDefault is called even when dragging over selection
80458
+ * highlights or other UI elements that sit on top of the layout content.
80459
+ */
80460
+ handleWindowDragOver(event) {
80461
+ if (this.hasFieldAnnotationData(event)) {
80462
+ event.preventDefault();
80463
+ if (event.dataTransfer) {
80464
+ event.dataTransfer.dropEffect = "move";
80465
+ }
80466
+ const target = event.target;
80467
+ if (!this.container.contains(target)) {
80468
+ this.config.onDragOver?.({
80469
+ event,
80470
+ clientX: event.clientX,
80471
+ clientY: event.clientY,
80472
+ hasFieldAnnotation: true
80473
+ });
80474
+ }
80475
+ }
80476
+ }
80477
+ /**
80478
+ * Handles drop at window level to catch drops on overlay elements.
80479
+ * If the drop target is outside the container, we process it here.
80480
+ */
80481
+ handleWindowDrop(event) {
80482
+ if (this.hasFieldAnnotationData(event)) {
80483
+ const target = event.target;
80484
+ if (!this.container.contains(target)) {
80485
+ this.handleDrop(event);
80486
+ }
80487
+ }
80488
+ }
80489
+ /**
80490
+ * Handles the dragstart event.
80491
+ * Sets up dataTransfer with field annotation data and drag image.
80492
+ */
80493
+ handleDragStart(event) {
80494
+ const target = event.target;
80495
+ if (!target?.dataset?.draggable || target.dataset.draggable !== "true") {
80496
+ return;
80497
+ }
80498
+ const data = extractFieldAnnotationData(target);
80499
+ if (event.dataTransfer) {
80500
+ const jsonData = JSON.stringify({
80501
+ attributes: data.attributes,
80502
+ sourceField: data
80503
+ });
80504
+ event.dataTransfer.setData(this.mimeType, jsonData);
80505
+ event.dataTransfer.setData(LEGACY_MIME_TYPE, jsonData);
80506
+ event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
80507
+ event.dataTransfer.setDragImage(target, 0, 0);
80508
+ event.dataTransfer.effectAllowed = "move";
80509
+ }
80510
+ this.config.onDragStart?.({
80511
+ event,
80512
+ element: target,
80513
+ data
80514
+ });
80515
+ }
80516
+ /**
80517
+ * Handles the dragover event.
80518
+ * Provides visual feedback and determines if drop is allowed.
80519
+ */
80520
+ handleDragOver(event) {
80521
+ const hasFieldAnnotation = this.hasFieldAnnotationData(event);
80522
+ if (hasFieldAnnotation) {
80523
+ event.preventDefault();
80524
+ if (event.dataTransfer) {
80525
+ event.dataTransfer.dropEffect = "move";
80526
+ }
80527
+ this.container.classList.add("drag-over");
80528
+ }
80529
+ this.config.onDragOver?.({
80530
+ event,
80531
+ clientX: event.clientX,
80532
+ clientY: event.clientY,
80533
+ hasFieldAnnotation
80534
+ });
80535
+ }
80536
+ /**
80537
+ * Handles the dragleave event.
80538
+ * Removes visual feedback when drag leaves the container.
80539
+ */
80540
+ handleDragLeave(event) {
80541
+ const relatedTarget = event.relatedTarget;
80542
+ if (!relatedTarget || !this.container.contains(relatedTarget)) {
80543
+ this.container.classList.remove("drag-over");
80544
+ }
80545
+ }
80546
+ /**
80547
+ * Handles the drop event.
80548
+ * Maps drop coordinates to ProseMirror position and emits drop event.
80549
+ */
80550
+ handleDrop(event) {
80551
+ this.container.classList.remove("drag-over");
80552
+ if (!this.hasFieldAnnotationData(event)) {
80553
+ return;
80554
+ }
80555
+ event.preventDefault();
80556
+ const data = this.extractDragData(event);
80557
+ if (!data) {
80558
+ return;
80559
+ }
80560
+ const pmPosition = clickToPositionDom(this.container, event.clientX, event.clientY);
80561
+ this.config.onDrop?.({
80562
+ event,
80563
+ data,
80564
+ pmPosition,
80565
+ clientX: event.clientX,
80566
+ clientY: event.clientY
80567
+ });
80568
+ }
80569
+ /**
80570
+ * Handles the dragend event.
80571
+ * Cleans up drag state.
80572
+ */
80573
+ handleDragEnd(event) {
80574
+ this.container.classList.remove("drag-over");
80575
+ this.config.onDragEnd?.(event);
80576
+ }
80577
+ /**
80578
+ * Checks if a drag event contains field annotation data.
80579
+ */
80580
+ hasFieldAnnotationData(event) {
80581
+ if (!event.dataTransfer) {
80582
+ return false;
80583
+ }
80584
+ const types2 = event.dataTransfer.types;
80585
+ return types2.includes(this.mimeType) || types2.includes(LEGACY_MIME_TYPE);
80586
+ }
80587
+ /**
80588
+ * Extracts field annotation data from a drag event's dataTransfer.
80589
+ */
80590
+ extractDragData(event) {
80591
+ if (!event.dataTransfer) {
80592
+ return null;
80593
+ }
80594
+ let jsonData = event.dataTransfer.getData(this.mimeType);
80595
+ if (!jsonData) {
80596
+ jsonData = event.dataTransfer.getData(LEGACY_MIME_TYPE);
80597
+ }
80598
+ if (!jsonData) {
80599
+ return null;
80600
+ }
80601
+ try {
80602
+ const parsed = JSON.parse(jsonData);
80603
+ return parsed.sourceField ?? parsed.attributes ?? parsed;
80604
+ } catch {
80605
+ return null;
80606
+ }
80607
+ }
80608
+ /**
80609
+ * Updates the configuration options.
80610
+ *
80611
+ * @param config - New configuration options to merge
80612
+ */
80613
+ updateConfig(config2) {
80614
+ this.config = { ...this.config, ...config2 };
80615
+ if (config2.mimeType) {
80616
+ this.mimeType = config2.mimeType;
80617
+ }
80618
+ }
80619
+ /**
80620
+ * Destroys the drag handler and removes all event listeners.
80621
+ * Call this when the layout engine is unmounted or the container is removed.
80622
+ */
80623
+ destroy() {
80624
+ this.removeListeners();
80625
+ this.container.classList.remove("drag-over");
80626
+ }
80627
+ }
80628
+ function createDragHandler(container, config2 = {}) {
80629
+ const handler2 = new DragHandler(container, config2);
80630
+ return () => handler2.destroy();
80631
+ }
80222
80632
  const isAtomicFragment = (fragment) => {
80223
80633
  return fragment.kind === "drawing" || fragment.kind === "image";
80224
80634
  };
@@ -80270,7 +80680,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80270
80680
  });
80271
80681
  for (const fragment of fragments) {
80272
80682
  if (fragment.kind !== "para") continue;
80273
- const blockIndex = blocks2.findIndex((block2) => block2.id === fragment.blockId);
80683
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
80274
80684
  if (blockIndex === -1) continue;
80275
80685
  const block = blocks2[blockIndex];
80276
80686
  const measure = measures[blockIndex];
@@ -80297,7 +80707,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80297
80707
  const withinX = point2.x >= fragment.x && point2.x <= fragment.x + fragment.width;
80298
80708
  const withinY = point2.y >= fragment.y && point2.y <= fragment.y + fragment.height;
80299
80709
  if (!withinX || !withinY) continue;
80300
- const blockIndex = blocks2.findIndex((block2) => block2.id === fragment.blockId);
80710
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
80301
80711
  if (blockIndex === -1) continue;
80302
80712
  const block = blocks2[blockIndex];
80303
80713
  const measure = measures[blockIndex];
@@ -80436,7 +80846,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80436
80846
  blockId = fragment.blockId;
80437
80847
  pageIndex = pi;
80438
80848
  column = determineColumn(layout, fragment.x);
80439
- const blockIndex = blocks2.findIndex((b2) => b2.id === fragment.blockId);
80849
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
80440
80850
  if (blockIndex !== -1) {
80441
80851
  const measure = measures[blockIndex];
80442
80852
  if (measure && measure.kind === "paragraph") {
@@ -80586,6 +80996,44 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80586
80996
  });
80587
80997
  return null;
80588
80998
  }
80999
+ function findBlockIndexByFragmentId(blocks2, fragmentBlockId, targetPmRange) {
81000
+ const index2 = blocks2.findIndex(
81001
+ (block) => block.id === fragmentBlockId && block.kind !== "pageBreak" && block.kind !== "sectionBreak"
81002
+ );
81003
+ if (index2 !== -1) {
81004
+ return index2;
81005
+ }
81006
+ const baseBlockId = fragmentBlockId.replace(/-\d+$/, "");
81007
+ if (baseBlockId === fragmentBlockId) {
81008
+ return -1;
81009
+ }
81010
+ const matchingIndices = [];
81011
+ blocks2.forEach((block, idx) => {
81012
+ if (block.id === baseBlockId && block.kind === "paragraph") {
81013
+ matchingIndices.push(idx);
81014
+ }
81015
+ });
81016
+ if (matchingIndices.length === 0) {
81017
+ return -1;
81018
+ }
81019
+ if (matchingIndices.length === 1) {
81020
+ return matchingIndices[0];
81021
+ }
81022
+ if (targetPmRange) {
81023
+ for (const idx of matchingIndices) {
81024
+ const block = blocks2[idx];
81025
+ if (block.kind !== "paragraph") continue;
81026
+ const hasOverlap = block.runs.some((run2) => {
81027
+ if (run2.pmStart == null || run2.pmEnd == null) return false;
81028
+ return run2.pmEnd > targetPmRange.from && run2.pmStart < targetPmRange.to;
81029
+ });
81030
+ if (hasOverlap) {
81031
+ return idx;
81032
+ }
81033
+ }
81034
+ }
81035
+ return matchingIndices[0];
81036
+ }
80589
81037
  function selectionToRects(layout, blocks2, measures, from2, to) {
80590
81038
  if (from2 === to) {
80591
81039
  return [];
@@ -80594,8 +81042,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80594
81042
  layout.pages.forEach((page, pageIndex) => {
80595
81043
  page.fragments.forEach((fragment) => {
80596
81044
  if (fragment.kind === "para") {
80597
- const blockIndex = blocks2.findIndex((block2) => block2.id === fragment.blockId);
80598
- if (blockIndex === -1) return;
81045
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId, { from: from2, to });
81046
+ if (blockIndex === -1) {
81047
+ return;
81048
+ }
80599
81049
  const block = blocks2[blockIndex];
80600
81050
  const measure = measures[blockIndex];
80601
81051
  if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph") {
@@ -80631,7 +81081,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80631
81081
  return;
80632
81082
  }
80633
81083
  if (isAtomicFragment(fragment)) {
80634
- const blockIndex = blocks2.findIndex((block2) => block2.id === fragment.blockId);
81084
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId, { from: from2, to });
80635
81085
  if (blockIndex === -1) return;
80636
81086
  const block = blocks2[blockIndex];
80637
81087
  const pmRange = getAtomicPmRange(fragment, block);
@@ -80652,7 +81102,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80652
81102
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
80653
81103
  const page = layout.pages[pageIndex];
80654
81104
  for (const fragment of page.fragments) {
80655
- const blockIndex = blocks2.findIndex((block2) => block2.id === fragment.blockId);
81105
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
80656
81106
  if (blockIndex === -1) {
80657
81107
  continue;
80658
81108
  }
@@ -80757,7 +81207,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80757
81207
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
80758
81208
  const run2 = block.runs[runIndex];
80759
81209
  if (!run2) continue;
80760
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
81210
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
80761
81211
  const runLength = text2.length;
80762
81212
  const runPmStart = run2.pmStart ?? null;
80763
81213
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
@@ -80781,7 +81231,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80781
81231
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
80782
81232
  const run2 = block.runs[runIndex];
80783
81233
  if (!run2) continue;
80784
- const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
81234
+ const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
80785
81235
  const runTextLength = text2.length;
80786
81236
  const runPmStart = run2.pmStart ?? null;
80787
81237
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runTextLength : null);
@@ -83313,10 +83763,228 @@ ${l}
83313
83763
  .superdoc-layout .track-format-dec.highlighted {
83314
83764
  border-bottom: 2px solid gold;
83315
83765
  }
83766
+ `;
83767
+ const SDT_CONTAINER_STYLES = `
83768
+ /* Document Section - Block-level container with gray border and hover tooltip */
83769
+ .superdoc-document-section {
83770
+ background-color: #fafafa;
83771
+ border: 1px solid #ababab;
83772
+ border-radius: 4px;
83773
+ position: relative;
83774
+ box-sizing: border-box;
83775
+ }
83776
+
83777
+ /* Document section tooltip - positioned above the fragment */
83778
+ .superdoc-document-section__tooltip {
83779
+ position: absolute;
83780
+ top: -19px;
83781
+ left: -1px;
83782
+ max-width: 100px;
83783
+ min-width: 0;
83784
+ height: 18px;
83785
+ border: 1px solid #ababab;
83786
+ border-bottom: none;
83787
+ border-radius: 6px 6px 0 0;
83788
+ padding: 0 8px;
83789
+ align-items: center;
83790
+ font-size: 10px;
83791
+ display: none;
83792
+ z-index: 100;
83793
+ background-color: #fafafa;
83794
+ pointer-events: none;
83795
+ }
83796
+
83797
+ .superdoc-document-section__tooltip span {
83798
+ max-width: 100%;
83799
+ overflow: hidden;
83800
+ white-space: nowrap;
83801
+ text-overflow: ellipsis;
83802
+ }
83803
+
83804
+ /* Show tooltip on hover - adjust border radius to connect with tooltip tab */
83805
+ .superdoc-document-section:hover {
83806
+ border-radius: 0 4px 4px 4px;
83807
+ }
83808
+
83809
+ .superdoc-document-section:hover .superdoc-document-section__tooltip {
83810
+ display: flex;
83811
+ align-items: center;
83812
+ }
83813
+
83814
+ /* Continuation styling: first fragment has top corners, last has bottom corners */
83815
+ .superdoc-document-section[data-sdt-container-start="true"] {
83816
+ border-radius: 4px 4px 0 0;
83817
+ }
83818
+
83819
+ .superdoc-document-section[data-sdt-container-end="true"] {
83820
+ border-radius: 0 0 4px 4px;
83821
+ }
83822
+
83823
+ .superdoc-document-section[data-sdt-container-start="true"][data-sdt-container-end="true"] {
83824
+ border-radius: 4px;
83825
+ }
83826
+
83827
+ .superdoc-document-section[data-sdt-container-start="true"]:hover {
83828
+ border-radius: 0 4px 0 0;
83829
+ }
83830
+
83831
+ /* Middle fragments have no border radius */
83832
+ .superdoc-document-section:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
83833
+ border-radius: 0;
83834
+ border-top: none;
83835
+ }
83836
+
83837
+ /* Structured Content Block - Blue border container */
83838
+ .superdoc-structured-content-block {
83839
+ padding: 1px;
83840
+ box-sizing: border-box;
83841
+ border-radius: 4px;
83842
+ border: 1px solid #629be7;
83843
+ position: relative;
83844
+ }
83845
+
83846
+ /* Structured content drag handle/label - positioned above */
83847
+ .superdoc-structured-content__label {
83848
+ font-size: 10px;
83849
+ align-items: center;
83850
+ justify-content: center;
83851
+ position: absolute;
83852
+ left: 2px;
83853
+ top: -19px;
83854
+ width: calc(100% - 4px);
83855
+ max-width: 110px;
83856
+ min-width: 0;
83857
+ height: 18px;
83858
+ padding: 0 4px;
83859
+ border: 1px solid #629be7;
83860
+ border-bottom: none;
83861
+ border-radius: 6px 6px 0 0;
83862
+ background-color: #629be7dd;
83863
+ box-sizing: border-box;
83864
+ z-index: 10;
83865
+ display: none;
83866
+ pointer-events: none;
83867
+ }
83868
+
83869
+ .superdoc-structured-content__label span {
83870
+ max-width: 100%;
83871
+ overflow: hidden;
83872
+ white-space: nowrap;
83873
+ text-overflow: ellipsis;
83874
+ }
83875
+
83876
+ .superdoc-structured-content-block:hover .superdoc-structured-content__label {
83877
+ display: inline-flex;
83878
+ }
83879
+
83880
+ /* Continuation styling for structured content blocks */
83881
+ .superdoc-structured-content-block[data-sdt-container-start="true"] {
83882
+ border-radius: 4px 4px 0 0;
83883
+ }
83884
+
83885
+ .superdoc-structured-content-block[data-sdt-container-end="true"] {
83886
+ border-radius: 0 0 4px 4px;
83887
+ }
83888
+
83889
+ .superdoc-structured-content-block[data-sdt-container-start="true"][data-sdt-container-end="true"] {
83890
+ border-radius: 4px;
83891
+ }
83892
+
83893
+ .superdoc-structured-content-block:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
83894
+ border-radius: 0;
83895
+ border-top: none;
83896
+ }
83897
+
83898
+ /* Structured Content Inline - Inline wrapper with blue border */
83899
+ .superdoc-structured-content-inline {
83900
+ padding: 1px;
83901
+ box-sizing: border-box;
83902
+ border-radius: 4px;
83903
+ border: 1px solid #629be7;
83904
+ position: relative;
83905
+ display: inline;
83906
+ }
83907
+
83908
+ /* Hover effect for inline structured content */
83909
+ .superdoc-structured-content-inline:hover {
83910
+ background-color: rgba(98, 155, 231, 0.15);
83911
+ border-color: #4a8ad9;
83912
+ }
83913
+
83914
+ /* Inline structured content label - shown on hover */
83915
+ .superdoc-structured-content-inline__label {
83916
+ position: absolute;
83917
+ bottom: calc(100% + 2px);
83918
+ left: 50%;
83919
+ transform: translateX(-50%);
83920
+ font-size: 10px;
83921
+ padding: 2px 6px;
83922
+ background-color: #629be7dd;
83923
+ color: white;
83924
+ border-radius: 4px;
83925
+ white-space: nowrap;
83926
+ z-index: 100;
83927
+ display: none;
83928
+ pointer-events: none;
83929
+ }
83930
+
83931
+ .superdoc-structured-content-inline:hover .superdoc-structured-content-inline__label {
83932
+ display: block;
83933
+ }
83934
+
83935
+ /* Print mode: hide visual styling for SDT containers */
83936
+ @media print {
83937
+ .superdoc-document-section,
83938
+ .superdoc-structured-content-block,
83939
+ .superdoc-structured-content-inline {
83940
+ background: none;
83941
+ border: none;
83942
+ padding: 0;
83943
+ }
83944
+
83945
+ .superdoc-document-section__tooltip,
83946
+ .superdoc-structured-content__label,
83947
+ .superdoc-structured-content-inline__label {
83948
+ display: none !important;
83949
+ }
83950
+ }
83951
+ `;
83952
+ const FIELD_ANNOTATION_STYLES = `
83953
+ /* Field annotation draggable styles */
83954
+ .superdoc-layout .annotation[data-draggable="true"] {
83955
+ cursor: grab;
83956
+ user-select: none;
83957
+ -webkit-user-select: none;
83958
+ }
83959
+
83960
+ .superdoc-layout .annotation[data-draggable="true"]:hover {
83961
+ opacity: 0.9;
83962
+ }
83963
+
83964
+ .superdoc-layout .annotation[data-draggable="true"]:active {
83965
+ cursor: grabbing;
83966
+ }
83967
+
83968
+ /* Drag over indicator for drop targets */
83969
+ .superdoc-layout.drag-over {
83970
+ outline: 2px dashed #b015b3;
83971
+ outline-offset: -2px;
83972
+ }
83973
+
83974
+ /* Drop zone indicator */
83975
+ .superdoc-layout .superdoc-drop-indicator {
83976
+ position: absolute;
83977
+ width: 2px;
83978
+ background-color: #b015b3;
83979
+ pointer-events: none;
83980
+ z-index: 1000;
83981
+ }
83316
83982
  `;
83317
83983
  let printStylesInjected = false;
83318
83984
  let linkStylesInjected = false;
83319
83985
  let trackChangeStylesInjected = false;
83986
+ let sdtContainerStylesInjected = false;
83987
+ let fieldAnnotationStylesInjected = false;
83320
83988
  const ensurePrintStyles = (doc2) => {
83321
83989
  if (printStylesInjected || !doc2) return;
83322
83990
  const styleEl = doc2.createElement("style");
@@ -83341,6 +84009,22 @@ ${l}
83341
84009
  doc2.head?.appendChild(styleEl);
83342
84010
  trackChangeStylesInjected = true;
83343
84011
  };
84012
+ const ensureSdtContainerStyles = (doc2) => {
84013
+ if (sdtContainerStylesInjected || !doc2) return;
84014
+ const styleEl = doc2.createElement("style");
84015
+ styleEl.setAttribute("data-superdoc-sdt-container-styles", "true");
84016
+ styleEl.textContent = SDT_CONTAINER_STYLES;
84017
+ doc2.head?.appendChild(styleEl);
84018
+ sdtContainerStylesInjected = true;
84019
+ };
84020
+ const ensureFieldAnnotationStyles = (doc2) => {
84021
+ if (fieldAnnotationStylesInjected || !doc2) return;
84022
+ const styleEl = doc2.createElement("style");
84023
+ styleEl.setAttribute("data-superdoc-field-annotation-styles", "true");
84024
+ styleEl.textContent = FIELD_ANNOTATION_STYLES;
84025
+ doc2.head?.appendChild(styleEl);
84026
+ fieldAnnotationStylesInjected = true;
84027
+ };
83344
84028
  const ALLOWED_BORDER_STYLES = /* @__PURE__ */ new Set([
83345
84029
  "none",
83346
84030
  "single",
@@ -83670,6 +84354,50 @@ ${l}
83670
84354
  container.appendChild(cellElement);
83671
84355
  }
83672
84356
  };
84357
+ function isStructuredContentMetadata(sdt) {
84358
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
84359
+ }
84360
+ function isDocumentSectionMetadata(sdt) {
84361
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "documentSection";
84362
+ }
84363
+ function getSdtContainerConfig(sdt) {
84364
+ if (isDocumentSectionMetadata(sdt)) {
84365
+ return {
84366
+ className: "superdoc-document-section",
84367
+ labelText: sdt.title ?? "Document section",
84368
+ labelClassName: "superdoc-document-section__tooltip",
84369
+ isStart: true,
84370
+ isEnd: true
84371
+ };
84372
+ }
84373
+ if (isStructuredContentMetadata(sdt) && sdt.scope === "block") {
84374
+ return {
84375
+ className: "superdoc-structured-content-block",
84376
+ labelText: sdt.alias ?? "Structured content",
84377
+ labelClassName: "superdoc-structured-content__label",
84378
+ isStart: true,
84379
+ isEnd: true
84380
+ };
84381
+ }
84382
+ return null;
84383
+ }
84384
+ function applySdtContainerStyling(doc2, container, sdt, containerSdt) {
84385
+ let config2 = getSdtContainerConfig(sdt);
84386
+ if (!config2 && containerSdt) {
84387
+ config2 = getSdtContainerConfig(containerSdt);
84388
+ }
84389
+ if (!config2) return;
84390
+ container.classList.add(config2.className);
84391
+ container.dataset.sdtContainerStart = String(config2.isStart);
84392
+ container.dataset.sdtContainerEnd = String(config2.isEnd);
84393
+ container.style.overflow = "visible";
84394
+ const labelEl = doc2.createElement("div");
84395
+ labelEl.className = config2.labelClassName;
84396
+ const labelText = doc2.createElement("span");
84397
+ labelText.textContent = config2.labelText;
84398
+ labelEl.appendChild(labelText);
84399
+ container.appendChild(labelEl);
84400
+ }
83673
84401
  const renderTableFragment = (deps) => {
83674
84402
  const { doc: doc2, fragment, blockLookup, context, renderLine, applyFragmentFrame, applySdtDataset, applyStyles: applyStyles2 } = deps;
83675
84403
  if (!doc2) {
@@ -83706,6 +84434,7 @@ ${l}
83706
84434
  applyFragmentFrame(container, fragment);
83707
84435
  container.style.height = `${fragment.height}px`;
83708
84436
  applySdtDataset(container, block.attrs?.sdt);
84437
+ applySdtContainerStyling(doc2, container, block.attrs?.sdt);
83709
84438
  container.classList.add("superdoc-table-fragment");
83710
84439
  if (fragment.metadata?.columnBoundaries) {
83711
84440
  const columnCount = measure.columnWidths.length;
@@ -84172,6 +84901,8 @@ ${l}
84172
84901
  ensurePrintStyles(doc2);
84173
84902
  ensureLinkStyles(doc2);
84174
84903
  ensureTrackChangeStyles(doc2);
84904
+ ensureFieldAnnotationStyles(doc2);
84905
+ ensureSdtContainerStyles(doc2);
84175
84906
  mount2.classList.add(CLASS_NAMES.container);
84176
84907
  if (this.mount && this.mount !== mount2) {
84177
84908
  this.resetState();
@@ -84694,7 +85425,8 @@ ${l}
84694
85425
  fragmentEl.classList.add(CLASS_NAMES.fragment);
84695
85426
  const isTocEntry = block.attrs?.isTocEntry;
84696
85427
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
84697
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
85428
+ const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
85429
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
84698
85430
  applyStyles$2(fragmentEl, styles);
84699
85431
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
84700
85432
  if (isTocEntry) {
@@ -84714,6 +85446,7 @@ ${l}
84714
85446
  }
84715
85447
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
84716
85448
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
85449
+ applySdtContainerStyling(this.doc, fragmentEl, block.attrs?.sdt, block.attrs?.containerSdt);
84717
85450
  const dropCapDescriptor = block.attrs?.dropCapDescriptor;
84718
85451
  const dropCapMeasure = measure.dropCap;
84719
85452
  if (dropCapDescriptor && dropCapMeasure && !fragment.continuesFromPrev) {
@@ -84932,6 +85665,7 @@ ${l}
84932
85665
  fragmentEl.dataset.itemId = fragment.itemId;
84933
85666
  const paragraphMetadata = item.paragraph.attrs?.sdt;
84934
85667
  this.applySdtDataset(fragmentEl, paragraphMetadata);
85668
+ applySdtContainerStyling(this.doc, fragmentEl, paragraphMetadata, item.paragraph.attrs?.containerSdt);
84935
85669
  if (fragment.continuesFromPrev) {
84936
85670
  fragmentEl.dataset.continuesFromPrev = "true";
84937
85671
  }
@@ -85703,10 +86437,19 @@ ${l}
85703
86437
  isBreakRun(run2) {
85704
86438
  return run2.kind === "break";
85705
86439
  }
86440
+ /**
86441
+ * Type guard to check if a run is a field annotation run.
86442
+ */
86443
+ isFieldAnnotationRun(run2) {
86444
+ return run2.kind === "fieldAnnotation";
86445
+ }
85706
86446
  renderRun(run2, context, trackedConfig) {
85707
86447
  if (this.isImageRun(run2)) {
85708
86448
  return this.renderImageRun(run2);
85709
86449
  }
86450
+ if (this.isFieldAnnotationRun(run2)) {
86451
+ return this.renderFieldAnnotationRun(run2);
86452
+ }
85710
86453
  if (this.isLineBreakRun(run2)) {
85711
86454
  return null;
85712
86455
  }
@@ -85843,6 +86586,200 @@ ${l}
85843
86586
  }
85844
86587
  return img2;
85845
86588
  }
86589
+ /**
86590
+ * Renders a FieldAnnotationRun as an inline "pill" element matching super-editor's visual appearance.
86591
+ *
86592
+ * Field annotations are styled inline elements that display form fields with:
86593
+ * - Outer span with border, border-radius, padding, and background color
86594
+ * - Inner span containing the displayLabel or type-specific content (image, link, etc.)
86595
+ *
86596
+ * @param run - The FieldAnnotationRun to render containing field configuration and styling
86597
+ * @returns HTMLElement (span) or null if document is not available
86598
+ *
86599
+ * @example
86600
+ * ```typescript
86601
+ * // Text variant
86602
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'text', displayLabel: 'Full Name', fieldColor: '#980043' })
86603
+ * // Returns: <span class="annotation" style="border: 2px solid #b015b3; ..."><span class="annotation-content">Full Name</span></span>
86604
+ *
86605
+ * // Image variant with imageSrc
86606
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'image', displayLabel: 'Photo', imageSrc: 'data:image/png;...' })
86607
+ * // Returns: <span class="annotation"><span class="annotation-content"><img src="..." /></span></span>
86608
+ *
86609
+ * // Link variant
86610
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'link', displayLabel: 'Website', linkUrl: 'https://example.com' })
86611
+ * // Returns: <span class="annotation"><span class="annotation-content"><a href="...">https://example.com</a></span></span>
86612
+ * ```
86613
+ */
86614
+ renderFieldAnnotationRun(run2) {
86615
+ if (!this.doc) {
86616
+ return null;
86617
+ }
86618
+ if (run2.hidden) {
86619
+ const hidden2 = this.doc.createElement("span");
86620
+ hidden2.style.display = "none";
86621
+ if (run2.pmStart != null) hidden2.dataset.pmStart = String(run2.pmStart);
86622
+ if (run2.pmEnd != null) hidden2.dataset.pmEnd = String(run2.pmEnd);
86623
+ return hidden2;
86624
+ }
86625
+ const defaultBorderColor = "#b015b3";
86626
+ const defaultFieldColor = "#980043";
86627
+ const annotation = this.doc.createElement("span");
86628
+ annotation.classList.add("annotation");
86629
+ annotation.setAttribute("aria-label", "Field annotation");
86630
+ const showHighlight = run2.highlighted !== false;
86631
+ if (showHighlight) {
86632
+ const borderColor = run2.borderColor || defaultBorderColor;
86633
+ annotation.style.border = `2px solid ${borderColor}`;
86634
+ annotation.style.borderRadius = "2px";
86635
+ annotation.style.padding = "1px 2px";
86636
+ annotation.style.boxSizing = "border-box";
86637
+ const fieldColor = run2.fieldColor || defaultFieldColor;
86638
+ const bgColor = fieldColor.length === 7 ? `${fieldColor}33` : fieldColor;
86639
+ if (run2.textHighlight) {
86640
+ annotation.style.backgroundColor = run2.textHighlight;
86641
+ } else {
86642
+ annotation.style.backgroundColor = bgColor;
86643
+ }
86644
+ }
86645
+ if (run2.visibility === "hidden") {
86646
+ annotation.style.visibility = "hidden";
86647
+ }
86648
+ if (run2.size) {
86649
+ if (run2.size.width) {
86650
+ annotation.style.width = `${run2.size.width}px`;
86651
+ annotation.style.display = "inline-block";
86652
+ annotation.style.overflow = "hidden";
86653
+ }
86654
+ if (run2.size.height) {
86655
+ annotation.style.height = `${run2.size.height}px`;
86656
+ }
86657
+ }
86658
+ if (run2.fontFamily) {
86659
+ annotation.style.fontFamily = run2.fontFamily;
86660
+ }
86661
+ if (run2.fontSize) {
86662
+ const fontSize2 = typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize;
86663
+ annotation.style.fontSize = fontSize2;
86664
+ }
86665
+ if (run2.textColor) {
86666
+ annotation.style.color = run2.textColor;
86667
+ }
86668
+ if (run2.bold) {
86669
+ annotation.style.fontWeight = "bold";
86670
+ }
86671
+ if (run2.italic) {
86672
+ annotation.style.fontStyle = "italic";
86673
+ }
86674
+ if (run2.underline) {
86675
+ annotation.style.textDecoration = "underline";
86676
+ }
86677
+ annotation.style.zIndex = "1";
86678
+ const content2 = this.doc.createElement("span");
86679
+ content2.classList.add("annotation-content");
86680
+ content2.style.pointerEvents = "none";
86681
+ content2.setAttribute("contenteditable", "false");
86682
+ switch (run2.variant) {
86683
+ case "image":
86684
+ case "signature": {
86685
+ if (run2.imageSrc) {
86686
+ const img2 = this.doc.createElement("img");
86687
+ const isDataUrl = run2.imageSrc.startsWith("data:");
86688
+ if (isDataUrl) {
86689
+ if (run2.imageSrc.length <= MAX_DATA_URL_LENGTH && VALID_IMAGE_DATA_URL.test(run2.imageSrc)) {
86690
+ img2.src = run2.imageSrc;
86691
+ } else {
86692
+ content2.textContent = run2.displayLabel;
86693
+ break;
86694
+ }
86695
+ } else {
86696
+ const sanitized = sanitizeHref(run2.imageSrc);
86697
+ if (sanitized) {
86698
+ img2.src = sanitized.href;
86699
+ } else {
86700
+ content2.textContent = run2.displayLabel;
86701
+ break;
86702
+ }
86703
+ }
86704
+ img2.alt = run2.displayLabel;
86705
+ img2.style.height = "auto";
86706
+ img2.style.maxWidth = "100%";
86707
+ img2.style.pointerEvents = "none";
86708
+ img2.style.verticalAlign = "middle";
86709
+ if (run2.variant === "signature") {
86710
+ img2.style.maxHeight = "28px";
86711
+ }
86712
+ content2.appendChild(img2);
86713
+ annotation.style.display = "inline-block";
86714
+ content2.style.display = "inline-block";
86715
+ } else {
86716
+ content2.textContent = run2.displayLabel || (run2.variant === "signature" ? "Signature" : "");
86717
+ }
86718
+ break;
86719
+ }
86720
+ case "link": {
86721
+ if (run2.linkUrl) {
86722
+ const link2 = this.doc.createElement("a");
86723
+ const sanitized = sanitizeHref(run2.linkUrl);
86724
+ if (sanitized) {
86725
+ link2.href = sanitized.href;
86726
+ link2.target = "_blank";
86727
+ link2.rel = "noopener noreferrer";
86728
+ link2.textContent = run2.linkUrl;
86729
+ link2.style.textDecoration = "none";
86730
+ content2.style.pointerEvents = "all";
86731
+ content2.appendChild(link2);
86732
+ } else {
86733
+ content2.textContent = run2.displayLabel;
86734
+ }
86735
+ } else {
86736
+ content2.textContent = run2.displayLabel;
86737
+ }
86738
+ break;
86739
+ }
86740
+ case "html": {
86741
+ if (run2.rawHtml && typeof run2.rawHtml === "string") {
86742
+ content2.textContent = run2.displayLabel;
86743
+ annotation.style.display = "inline-block";
86744
+ content2.style.display = "inline-block";
86745
+ } else {
86746
+ content2.textContent = run2.displayLabel;
86747
+ }
86748
+ break;
86749
+ }
86750
+ case "text":
86751
+ case "checkbox":
86752
+ default: {
86753
+ content2.textContent = run2.displayLabel;
86754
+ break;
86755
+ }
86756
+ }
86757
+ annotation.appendChild(content2);
86758
+ annotation.dataset.type = run2.variant;
86759
+ if (run2.fieldId) {
86760
+ annotation.dataset.fieldId = run2.fieldId;
86761
+ }
86762
+ if (run2.fieldType) {
86763
+ annotation.dataset.fieldType = run2.fieldType;
86764
+ }
86765
+ annotation.draggable = true;
86766
+ annotation.dataset.draggable = "true";
86767
+ if (run2.displayLabel) {
86768
+ annotation.dataset.displayLabel = run2.displayLabel;
86769
+ }
86770
+ if (run2.variant) {
86771
+ annotation.dataset.variant = run2.variant;
86772
+ }
86773
+ assertPmPositions(run2, "field annotation run");
86774
+ if (run2.pmStart != null) {
86775
+ annotation.dataset.pmStart = String(run2.pmStart);
86776
+ }
86777
+ if (run2.pmEnd != null) {
86778
+ annotation.dataset.pmEnd = String(run2.pmEnd);
86779
+ }
86780
+ this.applySdtDataset(annotation, run2.sdt);
86781
+ return annotation;
86782
+ }
85846
86783
  /**
85847
86784
  * Renders a single line of a paragraph block.
85848
86785
  *
@@ -86020,6 +86957,22 @@ ${l}
86020
86957
  if (this.isBreakRun(baseRun)) {
86021
86958
  continue;
86022
86959
  }
86960
+ if (this.isFieldAnnotationRun(baseRun)) {
86961
+ const elem = this.renderRun(baseRun, context, trackedConfig);
86962
+ if (elem) {
86963
+ if (styleId) {
86964
+ elem.setAttribute("styleid", styleId);
86965
+ }
86966
+ const runSegments2 = segmentsByRun.get(runIndex);
86967
+ const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
86968
+ const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
86969
+ elem.style.position = "absolute";
86970
+ elem.style.left = `${segX}px`;
86971
+ el.appendChild(elem);
86972
+ cumulativeX = segX + segWidth;
86973
+ }
86974
+ continue;
86975
+ }
86023
86976
  const runSegments = segmentsByRun.get(runIndex);
86024
86977
  if (!runSegments || runSegments.length === 0) {
86025
86978
  continue;
@@ -86065,7 +87018,22 @@ ${l}
86065
87018
  });
86066
87019
  }
86067
87020
  } else {
87021
+ let currentInlineSdtWrapper = null;
87022
+ let currentInlineSdtId = null;
87023
+ const closeCurrentWrapper = () => {
87024
+ if (currentInlineSdtWrapper) {
87025
+ el.appendChild(currentInlineSdtWrapper);
87026
+ currentInlineSdtWrapper = null;
87027
+ currentInlineSdtId = null;
87028
+ }
87029
+ };
86068
87030
  runsForLine.forEach((run2) => {
87031
+ const runSdt = run2.sdt;
87032
+ const isInlineSdt = runSdt?.type === "structuredContent" && runSdt?.scope === "inline";
87033
+ const runSdtId = isInlineSdt && runSdt?.id ? String(runSdt.id) : null;
87034
+ if (runSdtId !== currentInlineSdtId) {
87035
+ closeCurrentWrapper();
87036
+ }
86069
87037
  if (run2.kind === "tab") {
86070
87038
  const tabEl = this.doc.createElement("span");
86071
87039
  tabEl.classList.add("superdoc-tab");
@@ -86093,9 +87061,37 @@ ${l}
86093
87061
  if (styleId) {
86094
87062
  elem.setAttribute("styleid", styleId);
86095
87063
  }
86096
- el.appendChild(elem);
87064
+ if (isInlineSdt && runSdtId && this.doc) {
87065
+ if (!currentInlineSdtWrapper) {
87066
+ currentInlineSdtWrapper = this.doc.createElement("span");
87067
+ currentInlineSdtWrapper.className = "superdoc-structured-content-inline";
87068
+ currentInlineSdtId = runSdtId;
87069
+ this.applySdtDataset(currentInlineSdtWrapper, runSdt);
87070
+ const alias = runSdt?.alias || "Inline content";
87071
+ const labelEl = this.doc.createElement("span");
87072
+ labelEl.className = "superdoc-structured-content-inline__label";
87073
+ labelEl.textContent = alias;
87074
+ currentInlineSdtWrapper.appendChild(labelEl);
87075
+ }
87076
+ const wrapperPmStart = currentInlineSdtWrapper.dataset.pmStart;
87077
+ const wrapperPmEnd = currentInlineSdtWrapper.dataset.pmEnd;
87078
+ if (run2.pmStart != null) {
87079
+ if (!wrapperPmStart || run2.pmStart < parseInt(wrapperPmStart, 10)) {
87080
+ currentInlineSdtWrapper.dataset.pmStart = String(run2.pmStart);
87081
+ }
87082
+ }
87083
+ if (run2.pmEnd != null) {
87084
+ if (!wrapperPmEnd || run2.pmEnd > parseInt(wrapperPmEnd, 10)) {
87085
+ currentInlineSdtWrapper.dataset.pmEnd = String(run2.pmEnd);
87086
+ }
87087
+ }
87088
+ currentInlineSdtWrapper.appendChild(elem);
87089
+ } else {
87090
+ el.appendChild(elem);
87091
+ }
86097
87092
  }
86098
87093
  });
87094
+ closeCurrentWrapper();
86099
87095
  }
86100
87096
  const anchors = el.querySelectorAll("a[href]");
86101
87097
  anchors.forEach((anchor) => {
@@ -86603,7 +87599,7 @@ ${l}
86603
87599
  return block.id;
86604
87600
  };
86605
87601
  const applyRunStyles = (element2, run2, _isLink = false) => {
86606
- if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
87602
+ if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
86607
87603
  return;
86608
87604
  }
86609
87605
  element2.style.fontFamily = run2.fontFamily;
@@ -86763,6 +87759,10 @@ ${l}
86763
87759
  result.push(run2);
86764
87760
  continue;
86765
87761
  }
87762
+ if (run2.kind === "fieldAnnotation") {
87763
+ result.push(run2);
87764
+ continue;
87765
+ }
86766
87766
  if (!("text" in run2)) {
86767
87767
  continue;
86768
87768
  }
@@ -87078,6 +88078,10 @@ ${l}
87078
88078
  const TAB_EPSILON = 0.1;
87079
88079
  const DEFAULT_DECIMAL_SEPARATOR = ".";
87080
88080
  const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
88081
+ const FIELD_ANNOTATION_PILL_PADDING = 8;
88082
+ const FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2;
88083
+ const FIELD_ANNOTATION_VERTICAL_PADDING = 6;
88084
+ const DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16;
87081
88085
  const roundValue = (value) => value;
87082
88086
  function getCanvasContext() {
87083
88087
  if (!canvasContext) {
@@ -87157,6 +88161,9 @@ ${l}
87157
88161
  function isLineBreakRun(run2) {
87158
88162
  return run2.kind === "lineBreak";
87159
88163
  }
88164
+ function isFieldAnnotationRun(run2) {
88165
+ return run2.kind === "fieldAnnotation";
88166
+ }
87160
88167
  async function measureBlock(block, constraints) {
87161
88168
  const normalized = normalizeConstraints(constraints);
87162
88169
  if (block.kind === "drawing") {
@@ -87523,6 +88530,92 @@ ${l}
87523
88530
  lastAppliedTabAlign = null;
87524
88531
  continue;
87525
88532
  }
88533
+ if (isFieldAnnotationRun(run2)) {
88534
+ const displayText = run2.displayLabel || "";
88535
+ 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;
88536
+ const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
88537
+ const fontWeight = run2.bold ? "bold" : "normal";
88538
+ const fontStyle = run2.italic ? "italic" : "normal";
88539
+ const annotationFont = `${fontStyle} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
88540
+ ctx2.font = annotationFont;
88541
+ const textWidth = displayText ? ctx2.measureText(displayText).width : 0;
88542
+ const annotationWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
88543
+ const annotationHeight = annotationFontSize * FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER + FIELD_ANNOTATION_VERTICAL_PADDING;
88544
+ let annotationStartX;
88545
+ if (pendingTabAlignment && currentLine) {
88546
+ annotationStartX = alignPendingTabForWidth(annotationWidth);
88547
+ }
88548
+ if (!currentLine) {
88549
+ currentLine = {
88550
+ fromRun: runIndex,
88551
+ fromChar: 0,
88552
+ toRun: runIndex,
88553
+ toChar: 1,
88554
+ // Field annotations are atomic units
88555
+ width: annotationWidth,
88556
+ maxFontSize: annotationHeight,
88557
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
88558
+ segments: [
88559
+ {
88560
+ runIndex,
88561
+ fromChar: 0,
88562
+ toChar: 1,
88563
+ width: annotationWidth,
88564
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
88565
+ }
88566
+ ]
88567
+ };
88568
+ continue;
88569
+ }
88570
+ if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
88571
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
88572
+ const completedLine = {
88573
+ ...currentLine,
88574
+ ...metrics
88575
+ };
88576
+ addBarTabsToLine(completedLine);
88577
+ lines.push(completedLine);
88578
+ tabStopCursor = 0;
88579
+ pendingTabAlignment = null;
88580
+ lastAppliedTabAlign = null;
88581
+ currentLine = {
88582
+ fromRun: runIndex,
88583
+ fromChar: 0,
88584
+ toRun: runIndex,
88585
+ toChar: 1,
88586
+ width: annotationWidth,
88587
+ maxFontSize: annotationHeight,
88588
+ maxWidth: getEffectiveWidth(contentWidth),
88589
+ segments: [
88590
+ {
88591
+ runIndex,
88592
+ fromChar: 0,
88593
+ toChar: 1,
88594
+ width: annotationWidth
88595
+ }
88596
+ ]
88597
+ };
88598
+ } else {
88599
+ currentLine.toRun = runIndex;
88600
+ currentLine.toChar = 1;
88601
+ currentLine.width = roundValue(currentLine.width + annotationWidth);
88602
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, annotationHeight);
88603
+ if (!currentLine.segments) currentLine.segments = [];
88604
+ currentLine.segments.push({
88605
+ runIndex,
88606
+ fromChar: 0,
88607
+ toChar: 1,
88608
+ width: annotationWidth,
88609
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
88610
+ });
88611
+ }
88612
+ const tabAlign = lastAppliedTabAlign;
88613
+ if (tabAlign && currentLine && tabAlign.val === "end") {
88614
+ currentLine.width = roundValue(tabAlign.target);
88615
+ }
88616
+ lastAppliedTabAlign = null;
88617
+ continue;
88618
+ }
87526
88619
  if (!("text" in run2) || !("fontSize" in run2)) {
87527
88620
  continue;
87528
88621
  }
@@ -89487,6 +90580,16 @@ ${l}
89487
90580
  }
89488
90581
  return false;
89489
90582
  }
90583
+ const CommentMarkName = "commentMark";
90584
+ const TrackInsertMarkName = "trackInsert";
90585
+ const TrackDeleteMarkName = "trackDelete";
90586
+ const TrackFormatMarkName = "trackFormat";
90587
+ function isValidFieldAnnotationAttributes(attrs) {
90588
+ if (!attrs || typeof attrs !== "object") return false;
90589
+ const a2 = attrs;
90590
+ return typeof a2.fieldId === "string" && typeof a2.fieldType === "string" && typeof a2.displayLabel === "string" && typeof a2.type === "string";
90591
+ }
90592
+ const FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation";
89490
90593
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
89491
90594
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
89492
90595
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -89512,6 +90615,7 @@ ${l}
89512
90615
  __privateAdd$1(this, _layoutOptions);
89513
90616
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
89514
90617
  __privateAdd$1(this, _domPainter, null);
90618
+ __privateAdd$1(this, _dragHandlerCleanup, null);
89515
90619
  __privateAdd$1(this, _layoutError, null);
89516
90620
  __privateAdd$1(this, _layoutErrorState, "healthy");
89517
90621
  __privateAdd$1(this, _errorBanner, null);
@@ -89570,8 +90674,12 @@ ${l}
89570
90674
  if (event.button !== 0) {
89571
90675
  return;
89572
90676
  }
90677
+ const target = event.target;
90678
+ const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
89573
90679
  if (!__privateGet$1(this, _layoutState).layout) {
89574
- event.preventDefault();
90680
+ if (!isDraggableAnnotation) {
90681
+ event.preventDefault();
90682
+ }
89575
90683
  if (document.activeElement instanceof HTMLElement) {
89576
90684
  document.activeElement.blur();
89577
90685
  }
@@ -89580,10 +90688,10 @@ ${l}
89580
90688
  return;
89581
90689
  }
89582
90690
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
89583
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
89584
- if (doc22) {
90691
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
90692
+ if (doc222) {
89585
90693
  try {
89586
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
90694
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
89587
90695
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89588
90696
  } catch (error) {
89589
90697
  if (process$1$1.env.NODE_ENV === "development") {
@@ -89619,7 +90727,7 @@ ${l}
89619
90727
  if (headerFooterRegion) {
89620
90728
  return;
89621
90729
  }
89622
- const hit = clickToPosition(
90730
+ const rawHit = clickToPosition(
89623
90731
  __privateGet$1(this, _layoutState).layout,
89624
90732
  __privateGet$1(this, _layoutState).blocks,
89625
90733
  __privateGet$1(this, _layoutState).measures,
@@ -89628,7 +90736,11 @@ ${l}
89628
90736
  event.clientX,
89629
90737
  event.clientY
89630
90738
  );
89631
- event.preventDefault();
90739
+ const doc22 = __privateGet$1(this, _editor3).state?.doc;
90740
+ const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
90741
+ if (!isDraggableAnnotation) {
90742
+ event.preventDefault();
90743
+ }
89632
90744
  if (!hit) {
89633
90745
  if (document.activeElement instanceof HTMLElement) {
89634
90746
  document.activeElement.blur();
@@ -89636,10 +90748,10 @@ ${l}
89636
90748
  const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
89637
90749
  if (editorDom2) {
89638
90750
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
89639
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
89640
- if (doc22) {
90751
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
90752
+ if (doc222) {
89641
90753
  try {
89642
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
90754
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
89643
90755
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89644
90756
  } catch (error) {
89645
90757
  if (process$1$1.env.NODE_ENV === "development") {
@@ -89660,9 +90772,9 @@ ${l}
89660
90772
  hit.pos
89661
90773
  );
89662
90774
  if (fragmentHit && (fragmentHit.fragment.kind === "image" || fragmentHit.fragment.kind === "drawing")) {
89663
- const doc22 = __privateGet$1(this, _editor3).state.doc;
90775
+ const doc222 = __privateGet$1(this, _editor3).state.doc;
89664
90776
  try {
89665
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc22, hit.pos));
90777
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc222, hit.pos));
89666
90778
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89667
90779
  if (__privateGet$1(this, _lastSelectedImageBlockId) && __privateGet$1(this, _lastSelectedImageBlockId) !== fragmentHit.fragment.blockId) {
89668
90780
  this.emit("imageDeselected", { blockId: __privateGet$1(this, _lastSelectedImageBlockId) });
@@ -89753,8 +90865,8 @@ ${l}
89753
90865
  }
89754
90866
  }
89755
90867
  if (!handledByDepth) {
89756
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
89757
90868
  try {
90869
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
89758
90870
  __privateGet$1(this, _editor3).view?.dispatch(tr);
89759
90871
  } catch {
89760
90872
  }
@@ -89829,6 +90941,90 @@ ${l}
89829
90941
  }
89830
90942
  __privateSet(this, _isDragging, false);
89831
90943
  });
90944
+ __privateAdd$1(this, _handleDragOver, (event) => {
90945
+ const activeEditor = this.getActiveEditor();
90946
+ if (!activeEditor?.isEditable) {
90947
+ return;
90948
+ }
90949
+ event.preventDefault();
90950
+ if (event.dataTransfer) {
90951
+ event.dataTransfer.dropEffect = "copy";
90952
+ }
90953
+ const dt = event.dataTransfer;
90954
+ const hasFieldAnnotation = dt?.types?.includes(FIELD_ANNOTATION_DATA_TYPE) || Boolean(dt?.getData?.(FIELD_ANNOTATION_DATA_TYPE));
90955
+ if (!hasFieldAnnotation) {
90956
+ return;
90957
+ }
90958
+ const hit = this.hitTest(event.clientX, event.clientY);
90959
+ const doc22 = activeEditor.state?.doc;
90960
+ if (!hit || !doc22) {
90961
+ return;
90962
+ }
90963
+ const pos = Math.min(Math.max(hit.pos, 1), doc22.content.size);
90964
+ const currentSelection = activeEditor.state.selection;
90965
+ const isSameCursor = currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos;
90966
+ if (isSameCursor) {
90967
+ return;
90968
+ }
90969
+ try {
90970
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc22, pos)).setMeta("addToHistory", false);
90971
+ activeEditor.view?.dispatch(tr);
90972
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
90973
+ } catch (error) {
90974
+ if (process$1$1.env.NODE_ENV === "development") {
90975
+ console.debug("[PresentationEditor] Drag position update skipped:", error);
90976
+ }
90977
+ }
90978
+ });
90979
+ __privateAdd$1(this, _handleDrop, (event) => {
90980
+ const activeEditor = this.getActiveEditor();
90981
+ if (!activeEditor?.isEditable) {
90982
+ return;
90983
+ }
90984
+ if (event.dataTransfer?.types?.includes("application/x-field-annotation")) {
90985
+ return;
90986
+ }
90987
+ event.preventDefault();
90988
+ event.stopPropagation();
90989
+ const fieldAnnotationData = event.dataTransfer?.getData(FIELD_ANNOTATION_DATA_TYPE);
90990
+ if (!fieldAnnotationData) {
90991
+ return;
90992
+ }
90993
+ const hit = this.hitTest(event.clientX, event.clientY);
90994
+ const selection = activeEditor.state?.selection;
90995
+ const fallbackPos = selection?.from ?? activeEditor.state?.doc?.content.size ?? null;
90996
+ const pos = hit?.pos ?? fallbackPos;
90997
+ if (pos == null) {
90998
+ return;
90999
+ }
91000
+ let parsedData = null;
91001
+ try {
91002
+ parsedData = JSON.parse(fieldAnnotationData);
91003
+ } catch {
91004
+ return;
91005
+ }
91006
+ const { attributes, sourceField } = parsedData ?? {};
91007
+ activeEditor.emit?.("fieldAnnotationDropped", {
91008
+ sourceField,
91009
+ editor: activeEditor,
91010
+ coordinates: hit,
91011
+ pos
91012
+ });
91013
+ if (attributes && isValidFieldAnnotationAttributes(attributes)) {
91014
+ activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
91015
+ const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
91016
+ const tr = activeEditor.state?.tr.setSelection(TextSelection$1.create(activeEditor.state.doc, posAfter));
91017
+ if (tr) {
91018
+ activeEditor.view?.dispatch(tr);
91019
+ }
91020
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
91021
+ }
91022
+ const editorDom = activeEditor.view?.dom;
91023
+ if (editorDom) {
91024
+ editorDom.focus();
91025
+ activeEditor.view?.focus();
91026
+ }
91027
+ });
89832
91028
  __privateAdd$1(this, _handleDoubleClick, (event) => {
89833
91029
  if (event.button !== 0) return;
89834
91030
  if (!__privateGet$1(this, _layoutState).layout) return;
@@ -90018,6 +91214,7 @@ ${l}
90018
91214
  __privateMethod$1(this, _PresentationEditor_instances, applyZoom_fn).call(this);
90019
91215
  __privateMethod$1(this, _PresentationEditor_instances, setupEditorListeners_fn).call(this);
90020
91216
  __privateMethod$1(this, _PresentationEditor_instances, setupPointerHandlers_fn).call(this);
91217
+ __privateMethod$1(this, _PresentationEditor_instances, setupDragHandlers_fn).call(this);
90021
91218
  __privateMethod$1(this, _PresentationEditor_instances, setupInputBridge_fn).call(this);
90022
91219
  __privateMethod$1(this, _PresentationEditor_instances, syncTrackedChangesPreferences_fn).call(this);
90023
91220
  if (options.documentId) {
@@ -90729,6 +91926,7 @@ ${l}
90729
91926
  * Safe to call during partial initialization.
90730
91927
  */
90731
91928
  destroy() {
91929
+ var _a2;
90732
91930
  if (__privateGet$1(this, _rafHandle) != null) {
90733
91931
  __privateMethod$1(this, _PresentationEditor_instances, safeCleanup_fn).call(this, () => {
90734
91932
  const win = __privateGet$1(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
@@ -90750,6 +91948,8 @@ ${l}
90750
91948
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
90751
91949
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
90752
91950
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
91951
+ __privateGet$1(this, _viewportHost)?.removeEventListener("dragover", __privateGet$1(this, _handleDragOver));
91952
+ __privateGet$1(this, _viewportHost)?.removeEventListener("drop", __privateGet$1(this, _handleDrop));
90753
91953
  __privateGet$1(this, _visibleHost)?.removeEventListener("keydown", __privateGet$1(this, _handleKeyDown));
90754
91954
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
90755
91955
  __privateGet$1(this, _inputBridge)?.destroy();
@@ -90788,6 +91988,8 @@ ${l}
90788
91988
  __privateSet(this, _session, { mode: "body" });
90789
91989
  __privateSet(this, _activeHeaderFooterEditor, null);
90790
91990
  __privateSet(this, _domPainter, null);
91991
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
91992
+ __privateSet(this, _dragHandlerCleanup, null);
90791
91993
  __privateGet$1(this, _selectionOverlay2)?.remove();
90792
91994
  __privateGet$1(this, _painterHost)?.remove();
90793
91995
  __privateGet$1(this, _hiddenHost)?.remove();
@@ -90815,6 +92017,7 @@ ${l}
90815
92017
  _layoutOptions = /* @__PURE__ */ new WeakMap();
90816
92018
  _layoutState = /* @__PURE__ */ new WeakMap();
90817
92019
  _domPainter = /* @__PURE__ */ new WeakMap();
92020
+ _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
90818
92021
  _layoutError = /* @__PURE__ */ new WeakMap();
90819
92022
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
90820
92023
  _errorBanner = /* @__PURE__ */ new WeakMap();
@@ -90870,6 +92073,33 @@ ${l}
90870
92073
  _remoteCursorRafHandle = /* @__PURE__ */ new WeakMap();
90871
92074
  _scrollTimeout = /* @__PURE__ */ new WeakMap();
90872
92075
  _PresentationEditor_instances = /* @__PURE__ */ new WeakSet();
92076
+ collectCommentPositions_fn = function() {
92077
+ const editorState = __privateGet$1(this, _editor3)?.state;
92078
+ if (!editorState) return {};
92079
+ const doc2 = editorState.doc;
92080
+ const trackChangeMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
92081
+ const pmPositions = {};
92082
+ doc2.descendants((node2, pos) => {
92083
+ const marks = node2.marks || [];
92084
+ for (const mark2 of marks) {
92085
+ let threadId;
92086
+ if (mark2.type.name === CommentMarkName) {
92087
+ threadId = mark2.attrs.commentId || mark2.attrs.importedId;
92088
+ } else if (trackChangeMarks.includes(mark2.type.name)) {
92089
+ threadId = mark2.attrs.id;
92090
+ }
92091
+ if (!threadId) continue;
92092
+ const nodeEnd = pos + node2.nodeSize;
92093
+ if (!pmPositions[threadId]) {
92094
+ pmPositions[threadId] = { threadId, start: pos, end: nodeEnd };
92095
+ } else {
92096
+ pmPositions[threadId].start = Math.min(pmPositions[threadId].start, pos);
92097
+ pmPositions[threadId].end = Math.max(pmPositions[threadId].end, nodeEnd);
92098
+ }
92099
+ }
92100
+ });
92101
+ return pmPositions;
92102
+ };
90873
92103
  aggregateLayoutBounds_fn = function(rects) {
90874
92104
  if (!rects.length) return null;
90875
92105
  const top2 = Math.min(...rects.map((rect) => rect.top));
@@ -91198,8 +92428,99 @@ ${l}
91198
92428
  __privateGet$1(this, _viewportHost).addEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
91199
92429
  __privateGet$1(this, _viewportHost).addEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
91200
92430
  __privateGet$1(this, _viewportHost).addEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
92431
+ __privateGet$1(this, _viewportHost).addEventListener("dragover", __privateGet$1(this, _handleDragOver));
92432
+ __privateGet$1(this, _viewportHost).addEventListener("drop", __privateGet$1(this, _handleDrop));
91201
92433
  __privateGet$1(this, _visibleHost).addEventListener("keydown", __privateGet$1(this, _handleKeyDown));
91202
92434
  };
92435
+ setupDragHandlers_fn = function() {
92436
+ var _a2;
92437
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
92438
+ __privateSet(this, _dragHandlerCleanup, null);
92439
+ __privateSet(this, _dragHandlerCleanup, createDragHandler(__privateGet$1(this, _painterHost), {
92440
+ onDragOver: (event) => {
92441
+ if (!event.hasFieldAnnotation || event.event.clientX === 0) {
92442
+ return;
92443
+ }
92444
+ const activeEditor = this.getActiveEditor();
92445
+ if (!activeEditor?.isEditable) {
92446
+ return;
92447
+ }
92448
+ const hit = this.hitTest(event.clientX, event.clientY);
92449
+ const doc2 = activeEditor.state?.doc;
92450
+ if (!hit || !doc2) {
92451
+ return;
92452
+ }
92453
+ const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
92454
+ const currentSelection = activeEditor.state.selection;
92455
+ if (currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos) {
92456
+ return;
92457
+ }
92458
+ try {
92459
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc2, pos)).setMeta("addToHistory", false);
92460
+ activeEditor.view?.dispatch(tr);
92461
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
92462
+ } catch {
92463
+ }
92464
+ },
92465
+ onDrop: (event) => {
92466
+ event.event.preventDefault();
92467
+ event.event.stopPropagation();
92468
+ if (event.pmPosition === null) {
92469
+ return;
92470
+ }
92471
+ const activeEditor = this.getActiveEditor();
92472
+ const { state: state2, view } = activeEditor;
92473
+ if (!state2 || !view) {
92474
+ return;
92475
+ }
92476
+ const fieldId = event.data.fieldId;
92477
+ if (fieldId) {
92478
+ const targetPos = event.pmPosition;
92479
+ let sourceStart = null;
92480
+ let sourceEnd = null;
92481
+ let sourceNode = null;
92482
+ state2.doc.descendants((node2, pos) => {
92483
+ if (node2.type.name === "fieldAnnotation" && node2.attrs.fieldId === fieldId) {
92484
+ sourceStart = pos;
92485
+ sourceEnd = pos + node2.nodeSize;
92486
+ sourceNode = node2;
92487
+ return false;
92488
+ }
92489
+ return true;
92490
+ });
92491
+ if (sourceStart === null || sourceEnd === null || !sourceNode) {
92492
+ return;
92493
+ }
92494
+ if (targetPos >= sourceStart && targetPos <= sourceEnd) {
92495
+ return;
92496
+ }
92497
+ const tr = state2.tr;
92498
+ tr.delete(sourceStart, sourceEnd);
92499
+ const mappedTarget = tr.mapping.map(targetPos);
92500
+ if (mappedTarget < 0 || mappedTarget > tr.doc.content.size) {
92501
+ return;
92502
+ }
92503
+ tr.insert(mappedTarget, sourceNode);
92504
+ tr.setMeta("uiEvent", "drop");
92505
+ view.dispatch(tr);
92506
+ return;
92507
+ }
92508
+ const attrs = event.data.attributes;
92509
+ if (attrs && isValidFieldAnnotationAttributes(attrs)) {
92510
+ const inserted = activeEditor.commands?.addFieldAnnotation?.(event.pmPosition, attrs, true);
92511
+ if (inserted) {
92512
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
92513
+ }
92514
+ return;
92515
+ }
92516
+ activeEditor.emit("fieldAnnotationDropped", {
92517
+ sourceField: event.data,
92518
+ editor: activeEditor,
92519
+ coordinates: { pos: event.pmPosition }
92520
+ });
92521
+ }
92522
+ }));
92523
+ };
91203
92524
  setupInputBridge_fn = function() {
91204
92525
  __privateGet$1(this, _inputBridge)?.destroy();
91205
92526
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
@@ -91417,6 +92738,8 @@ ${l}
91417
92738
  _handlePointerMove = /* @__PURE__ */ new WeakMap();
91418
92739
  _handlePointerLeave = /* @__PURE__ */ new WeakMap();
91419
92740
  _handlePointerUp = /* @__PURE__ */ new WeakMap();
92741
+ _handleDragOver = /* @__PURE__ */ new WeakMap();
92742
+ _handleDrop = /* @__PURE__ */ new WeakMap();
91420
92743
  _handleDoubleClick = /* @__PURE__ */ new WeakMap();
91421
92744
  _handleKeyDown = /* @__PURE__ */ new WeakMap();
91422
92745
  focusHeaderFooterShortcut_fn = function(kind) {
@@ -91587,6 +92910,11 @@ ${l}
91587
92910
  const payload = { layout, blocks: blocks2, measures, metrics };
91588
92911
  this.emit("layoutUpdated", payload);
91589
92912
  this.emit("paginationUpdate", payload);
92913
+ const commentPositions = __privateMethod$1(this, _PresentationEditor_instances, collectCommentPositions_fn).call(this);
92914
+ const positionKeys = Object.keys(commentPositions);
92915
+ if (positionKeys.length > 0) {
92916
+ this.emit("commentPositions", { positions: commentPositions });
92917
+ }
91590
92918
  if (__privateGet$1(this, _telemetryEmitter) && metrics) {
91591
92919
  __privateGet$1(this, _telemetryEmitter).call(this, { type: "layout", data: { layout, blocks: blocks2, measures, metrics } });
91592
92920
  }
@@ -97053,6 +98381,7 @@ ${l}
97053
98381
  return ["p", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
97054
98382
  },
97055
98383
  addNodeView() {
98384
+ if (this.editor.options?.mode !== "docx" || !this.editor.converter) return null;
97056
98385
  if (shouldSkipNodeView(this.editor)) return null;
97057
98386
  return ({ node: node2, editor, getPos, decorations, extensionAttrs }) => {
97058
98387
  return new ParagraphNodeView(node2, editor, getPos, decorations, extensionAttrs);
@@ -97295,7 +98624,7 @@ ${l}
97295
98624
  }
97296
98625
  });
97297
98626
  const CommentsMark = Mark.create({
97298
- name: CommentMarkName,
98627
+ name: CommentMarkName$1,
97299
98628
  group: "comments",
97300
98629
  excludes: "",
97301
98630
  addOptions() {
@@ -97314,10 +98643,10 @@ ${l}
97314
98643
  };
97315
98644
  },
97316
98645
  parseDOM() {
97317
- return [{ tag: CommentMarkName }];
98646
+ return [{ tag: CommentMarkName$1 }];
97318
98647
  },
97319
98648
  renderDOM({ htmlAttributes }) {
97320
- return [CommentMarkName, Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
98649
+ return [CommentMarkName$1, Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
97321
98650
  }
97322
98651
  });
97323
98652
  let cache$2 = /* @__PURE__ */ new WeakMap();
@@ -107501,7 +108830,7 @@ ${l}
107501
108830
  }
107502
108831
  const trackInsertClass = "track-insert";
107503
108832
  const TrackInsert = Mark.create({
107504
- name: TrackInsertMarkName,
108833
+ name: TrackInsertMarkName$1,
107505
108834
  group: "track",
107506
108835
  inclusive: false,
107507
108836
  addOptions() {
@@ -107578,7 +108907,7 @@ ${l}
107578
108907
  });
107579
108908
  const trackDeleteClass = "track-delete";
107580
108909
  const TrackDelete = Mark.create({
107581
- name: TrackDeleteMarkName,
108910
+ name: TrackDeleteMarkName$1,
107582
108911
  group: "track",
107583
108912
  inclusive: false,
107584
108913
  addOptions() {
@@ -107687,7 +109016,7 @@ ${l}
107687
109016
  }, Symbol.toStringTag, { value: "Module" }));
107688
109017
  const trackFormatClass = "track-format";
107689
109018
  const TrackFormat = Mark.create({
107690
- name: TrackFormatMarkName,
109019
+ name: TrackFormatMarkName$1,
107691
109020
  group: "track",
107692
109021
  inclusive: false,
107693
109022
  addOptions() {
@@ -107901,7 +109230,7 @@ ${l}
107901
109230
  tr.setMeta("inputType", "acceptReject");
107902
109231
  const map2 = new Mapping();
107903
109232
  doc2.nodesBetween(from2, to, (node2, pos) => {
107904
- if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName)) {
109233
+ if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName$1)) {
107905
109234
  const deletionStep = new ReplaceStep(
107906
109235
  map2.map(Math.max(pos, from2)),
107907
109236
  map2.map(Math.min(pos + node2.nodeSize, to)),
@@ -107909,8 +109238,8 @@ ${l}
107909
109238
  );
107910
109239
  tr.step(deletionStep);
107911
109240
  map2.appendMap(deletionStep.getMap());
107912
- } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName)) {
107913
- const insertionMark = node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName);
109241
+ } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName$1)) {
109242
+ const insertionMark = node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName$1);
107914
109243
  tr.step(
107915
109244
  new RemoveMarkStep(
107916
109245
  map2.map(Math.max(pos, from2)),
@@ -107918,8 +109247,8 @@ ${l}
107918
109247
  insertionMark
107919
109248
  )
107920
109249
  );
107921
- } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName)) {
107922
- const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
109250
+ } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName$1)) {
109251
+ const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName$1);
107923
109252
  tr.step(
107924
109253
  new RemoveMarkStep(
107925
109254
  map2.map(Math.max(pos, from2)),
@@ -107941,8 +109270,8 @@ ${l}
107941
109270
  tr.setMeta("inputType", "acceptReject");
107942
109271
  const map2 = new Mapping();
107943
109272
  doc2.nodesBetween(from2, to, (node2, pos) => {
107944
- if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName)) {
107945
- const deletionMark = node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName);
109273
+ if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName$1)) {
109274
+ const deletionMark = node2.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName$1);
107946
109275
  tr.step(
107947
109276
  new RemoveMarkStep(
107948
109277
  map2.map(Math.max(pos, from2)),
@@ -107950,7 +109279,7 @@ ${l}
107950
109279
  deletionMark
107951
109280
  )
107952
109281
  );
107953
- } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName)) {
109282
+ } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackInsertMarkName$1)) {
107954
109283
  const deletionStep = new ReplaceStep(
107955
109284
  map2.map(Math.max(pos, from2)),
107956
109285
  map2.map(Math.min(pos + node2.nodeSize, to)),
@@ -107958,8 +109287,8 @@ ${l}
107958
109287
  );
107959
109288
  tr.step(deletionStep);
107960
109289
  map2.appendMap(deletionStep.getMap());
107961
- } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName)) {
107962
- const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
109290
+ } else if (node2.marks && node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName$1)) {
109291
+ const formatChangeMark = node2.marks.find((mark2) => mark2.type.name === TrackFormatMarkName$1);
107963
109292
  formatChangeMark.attrs.before.forEach((oldMark) => {
107964
109293
  tr.step(
107965
109294
  new AddMarkStep(
@@ -108135,7 +109464,7 @@ ${l}
108135
109464
  const hasContentBetween = state2.doc.textBetween(left2.from, right2.to, "\n").length > getSegmentSize(left2) + getSegmentSize(right2);
108136
109465
  return !hasContentBetween;
108137
109466
  };
108138
- const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName && secondType === TrackInsertMarkName || firstType === TrackInsertMarkName && secondType === TrackDeleteMarkName;
109467
+ const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName$1 && secondType === TrackInsertMarkName$1 || firstType === TrackInsertMarkName$1 && secondType === TrackDeleteMarkName$1;
108139
109468
  const linkedBefore = [];
108140
109469
  const linkedAfter = [];
108141
109470
  const collectDirection = (direction, collection) => {
@@ -144530,26 +145859,14 @@ ${style2}
144530
145859
  const firstGroupRendered = ref(false);
144531
145860
  const verticalOffset = ref(0);
144532
145861
  const commentsRenderKey = ref(0);
145862
+ const measurementTimeoutId = ref(null);
144533
145863
  const getCommentPosition = computed(() => (comment2) => {
144534
145864
  if (!floatingCommentsContainer.value) return { top: "0px" };
144535
- floatingCommentsContainer.value.getBoundingClientRect();
144536
145865
  if (typeof comment2.top !== "number" || isNaN(comment2.top)) {
144537
145866
  return { display: "none" };
144538
145867
  }
144539
145868
  return { top: `${comment2.top}px` };
144540
145869
  });
144541
- const findScrollParent = (element2) => {
144542
- if (!element2) return window;
144543
- let parent = element2.parentNode;
144544
- while (parent && parent !== document) {
144545
- const style2 = getComputedStyle(parent);
144546
- if (/(auto|scroll|overlay)/.test(style2.overflow + style2.overflowY + style2.overflowX)) {
144547
- return parent;
144548
- }
144549
- parent = parent.parentNode;
144550
- }
144551
- return window;
144552
- };
144553
145870
  const handleDialog = (dialog) => {
144554
145871
  if (!dialog) return;
144555
145872
  const { elementRef, commentId } = dialog;
@@ -144557,44 +145874,68 @@ ${style2}
144557
145874
  nextTick(() => {
144558
145875
  const id = commentId;
144559
145876
  if (renderedSizes.value.some((item) => item.id == id)) return;
144560
- const editorBounds = props.parent.getBoundingClientRect();
144561
145877
  const comment2 = getFloatingComments.value.find((c2) => c2.commentId === id || c2.importedId == id);
144562
145878
  const positionKey = id || comment2?.importedId;
144563
- let position2 = editorCommentPositions.value[positionKey]?.bounds || {};
145879
+ const positionEntry = editorCommentPositions.value[positionKey];
145880
+ const position2 = positionEntry?.bounds || {};
144564
145881
  if (props.currentDocument.type === "application/pdf") {
144565
145882
  Object.entries(comment2.selection?.selectionBounds).forEach(([key2, value]) => {
144566
145883
  position2[key2] = Number(value);
144567
145884
  });
144568
- position2.top += editorBounds.top;
144569
145885
  }
144570
145886
  if (!position2) return;
144571
- const scrollParent = findScrollParent(props.parent);
144572
- scrollParent === window ? window.scrollY : scrollParent.scrollTop;
144573
145887
  const bounds = elementRef.value?.getBoundingClientRect();
145888
+ const top2 = Number(position2.top);
145889
+ if (!Number.isFinite(top2)) return;
144574
145890
  const placement = {
144575
145891
  id,
144576
- top: position2.top - editorBounds.top,
145892
+ top: top2,
144577
145893
  height: bounds.height,
144578
145894
  commentRef: comment2,
144579
- elementRef
145895
+ elementRef,
145896
+ pageIndex: positionEntry?.pageIndex ?? 0
144580
145897
  };
144581
145898
  renderedSizes.value.push(placement);
144582
145899
  });
144583
145900
  };
144584
145901
  const processLocations = async () => {
144585
- let currentBottom = 0;
144586
- renderedSizes.value.sort((a2, b2) => a2.top - b2.top).forEach((comment2) => {
144587
- if (comment2.top <= currentBottom + 15) {
144588
- comment2.top = currentBottom + 15;
144589
- }
144590
- currentBottom = comment2.top + comment2.height;
145902
+ const groupedByPage = renderedSizes.value.reduce((acc, comment2) => {
145903
+ const key2 = comment2.pageIndex ?? 0;
145904
+ if (!acc[key2]) acc[key2] = [];
145905
+ acc[key2].push(comment2);
145906
+ return acc;
145907
+ }, {});
145908
+ Object.values(groupedByPage).forEach((comments) => {
145909
+ comments.sort((a2, b2) => a2.top - b2.top).forEach((comment2, idx, arr) => {
145910
+ if (idx === 0) return;
145911
+ const prev = arr[idx - 1];
145912
+ const minTop = prev.top + prev.height + 15;
145913
+ if (comment2.top < minTop) {
145914
+ comment2.top = minTop;
145915
+ }
145916
+ });
144591
145917
  });
144592
145918
  await nextTick();
144593
145919
  firstGroupRendered.value = true;
144594
145920
  };
144595
145921
  watchEffect(() => {
144596
- if (renderedSizes.value.length === getFloatingComments.value.length) {
145922
+ if (measurementTimeoutId.value) {
145923
+ clearTimeout(measurementTimeoutId.value);
145924
+ measurementTimeoutId.value = null;
145925
+ }
145926
+ const totalComments = getFloatingComments.value.length;
145927
+ const measuredComments = renderedSizes.value.length;
145928
+ if (totalComments === 0) {
145929
+ return;
145930
+ }
145931
+ if (measuredComments === totalComments) {
144597
145932
  nextTick(processLocations);
145933
+ } else if (measuredComments > 0 && !firstGroupRendered.value) {
145934
+ measurementTimeoutId.value = setTimeout(() => {
145935
+ if (!firstGroupRendered.value && renderedSizes.value.length > 0) {
145936
+ processLocations();
145937
+ }
145938
+ }, 100);
144598
145939
  }
144599
145940
  });
144600
145941
  watch(activeComment, (newVal, oldVal) => {
@@ -144617,6 +145958,12 @@ ${style2}
144617
145958
  }, 200);
144618
145959
  });
144619
145960
  });
145961
+ onBeforeUnmount(() => {
145962
+ if (measurementTimeoutId.value) {
145963
+ clearTimeout(measurementTimeoutId.value);
145964
+ measurementTimeoutId.value = null;
145965
+ }
145966
+ });
144620
145967
  return (_ctx, _cache) => {
144621
145968
  return openBlock(), createElementBlock("div", {
144622
145969
  class: "section-wrapper",
@@ -144667,7 +146014,7 @@ ${style2}
144667
146014
  };
144668
146015
  }
144669
146016
  };
144670
- const FloatingComments = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-91de2350"]]);
146017
+ const FloatingComments = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-eab6fbfa"]]);
144671
146018
  const _sfc_main$9 = {
144672
146019
  __name: "TextField",
144673
146020
  props: {
@@ -145422,6 +146769,13 @@ ${style2}
145422
146769
  presentationEditor.onTelemetry((telemetryPayload) => {
145423
146770
  proxy.$superdoc.captureLayoutPipelineEvent(telemetryPayload);
145424
146771
  });
146772
+ presentationEditor.on("commentPositions", ({ positions }) => {
146773
+ const commentsConfig = proxy.$superdoc.config.modules?.comments;
146774
+ if (!commentsConfig || commentsConfig === false) return;
146775
+ if (!positions || Object.keys(positions).length === 0) return;
146776
+ const mappedPositions = presentationEditor.getCommentBounds(positions, layers.value);
146777
+ handleEditorLocationsUpdate(mappedPositions);
146778
+ });
145425
146779
  };
145426
146780
  const onEditorDestroy = () => {
145427
146781
  proxy.$superdoc.broadcastEditorDestroy();
@@ -145968,7 +147322,7 @@ ${style2}
145968
147322
  };
145969
147323
  }
145970
147324
  };
145971
- const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-3fafc837"]]);
147325
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-3c3356b6"]]);
145972
147326
  const createSuperdocVueApp = () => {
145973
147327
  const app = createApp(App);
145974
147328
  const pinia = createPinia();
@@ -146148,7 +147502,7 @@ ${style2}
146148
147502
  this.config.colors = shuffleArray(this.config.colors);
146149
147503
  this.userColorMap = /* @__PURE__ */ new Map();
146150
147504
  this.colorIndex = 0;
146151
- this.version = "1.0.0-beta.31";
147505
+ this.version = "1.0.0-beta.33";
146152
147506
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
146153
147507
  this.superdocId = config2.superdocId || v4();
146154
147508
  this.colors = this.config.colors;
@@ -148592,7 +149946,7 @@ ${style2}
148592
149946
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
148593
149947
  );
148594
149948
  }
148595
- const indexEGVYUeN = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
149949
+ const indexHX4H5xPH = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
148596
149950
  __proto__: null,
148597
149951
  unified
148598
149952
  }, Symbol.toStringTag, { value: "Module" }));