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
@@ -18280,9 +18280,9 @@ const canMergeTextNodes = (nodeA, nodeB) => {
18280
18280
  const areAttrsEqual = (attrsA = {}, attrsB = {}) => {
18281
18281
  return objectIncludes(attrsA, attrsB);
18282
18282
  };
18283
- const TrackInsertMarkName = "trackInsert";
18284
- const TrackDeleteMarkName = "trackDelete";
18285
- const TrackFormatMarkName = "trackFormat";
18283
+ const TrackInsertMarkName$1 = "trackInsert";
18284
+ const TrackDeleteMarkName$1 = "trackDelete";
18285
+ const TrackFormatMarkName$1 = "trackFormat";
18286
18286
  const generateV2HandlerEntity = (handlerName, translator2) => ({
18287
18287
  handlerName,
18288
18288
  handler: (params2) => {
@@ -20048,7 +20048,7 @@ function handleStyleChangeMarksV2(rPrChange, currentMarks, params2) {
20048
20048
  const runProperties = translator$1N.encode({ ...params2, nodes: [rPr] });
20049
20049
  submarks = encodeMarksFromRPr(runProperties, params2?.docx);
20050
20050
  }
20051
- return [{ type: TrackFormatMarkName, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20051
+ return [{ type: TrackFormatMarkName$1, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20052
20052
  }
20053
20053
  function handleStyleChangeMarks(rPr, currentMarks) {
20054
20054
  const styleChangeMark = rPr.elements?.find((el) => el.name === "w:rPrChange");
@@ -20063,7 +20063,7 @@ function handleStyleChangeMarks(rPr, currentMarks) {
20063
20063
  authorEmail: attributes["w:authorEmail"]
20064
20064
  };
20065
20065
  const submarks = parseMarks(styleChangeMark);
20066
- return [{ type: TrackFormatMarkName, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20066
+ return [{ type: TrackFormatMarkName$1, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20067
20067
  }
20068
20068
  function createImportMarks(marks) {
20069
20069
  const textStyleMarksToCombine = marks.filter((mark) => mark.type === "textStyle");
@@ -20501,7 +20501,7 @@ const cloneRuns = (runs = []) => runs.map((run2) => cloneNode(run2));
20501
20501
  const prepareRunTrackingContext = (node = {}) => {
20502
20502
  const marks = Array.isArray(node.marks) ? node.marks : [];
20503
20503
  const trackingMarks = marks.filter(
20504
- (mark) => mark?.type === TrackInsertMarkName || mark?.type === TrackDeleteMarkName
20504
+ (mark) => mark?.type === TrackInsertMarkName$1 || mark?.type === TrackDeleteMarkName$1
20505
20505
  );
20506
20506
  if (!trackingMarks.length) {
20507
20507
  return { runNode: node, trackingMarksByType: /* @__PURE__ */ new Map() };
@@ -20510,7 +20510,7 @@ const prepareRunTrackingContext = (node = {}) => {
20510
20510
  trackingMarks.forEach((mark) => {
20511
20511
  if (mark?.type) trackingMarksByType.set(mark.type, cloneMark(mark));
20512
20512
  });
20513
- const preservedMarks = marks.filter((mark) => mark?.type !== TrackInsertMarkName && mark?.type !== TrackDeleteMarkName).map((mark) => cloneMark(mark));
20513
+ const preservedMarks = marks.filter((mark) => mark?.type !== TrackInsertMarkName$1 && mark?.type !== TrackDeleteMarkName$1).map((mark) => cloneMark(mark));
20514
20514
  const clonedContent = Array.isArray(node.content) ? node.content.map((child) => {
20515
20515
  const childClone = cloneNode(child);
20516
20516
  const childMarks = Array.isArray(childClone.marks) ? childClone.marks.slice() : [];
@@ -20549,8 +20549,8 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
20549
20549
  return runs;
20550
20550
  }
20551
20551
  if (!trackingMarksByType.size) return runs;
20552
- if (trackingMarksByType.has(TrackInsertMarkName)) {
20553
- const mark = trackingMarksByType.get(TrackInsertMarkName);
20552
+ if (trackingMarksByType.has(TrackInsertMarkName$1)) {
20553
+ const mark = trackingMarksByType.get(TrackInsertMarkName$1);
20554
20554
  const clonedRuns = cloneRuns(runs);
20555
20555
  const wrapper = {
20556
20556
  name: "w:ins",
@@ -20567,8 +20567,8 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
20567
20567
  };
20568
20568
  return [wrapper];
20569
20569
  }
20570
- if (trackingMarksByType.has(TrackDeleteMarkName)) {
20571
- const mark = trackingMarksByType.get(TrackDeleteMarkName);
20570
+ if (trackingMarksByType.has(TrackDeleteMarkName$1)) {
20571
+ const mark = trackingMarksByType.get(TrackDeleteMarkName$1);
20572
20572
  const clonedRuns = cloneRuns(runs);
20573
20573
  clonedRuns.forEach(renameTextElementsForDeletion);
20574
20574
  const wrapper = {
@@ -41858,7 +41858,7 @@ const _SuperConverter = class _SuperConverter2 {
41858
41858
  static getStoredSuperdocVersion(docx) {
41859
41859
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
41860
41860
  }
41861
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.31") {
41861
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.33") {
41862
41862
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
41863
41863
  }
41864
41864
  /**
@@ -45164,7 +45164,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45164
45164
  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);
45165
45165
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45166
45166
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45167
- 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;
45167
+ 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;
45168
45168
  var GOOD_LEAF_SIZE = 200;
45169
45169
  var RopeSequence = function RopeSequence2() {
45170
45170
  };
@@ -56016,13 +56016,13 @@ const findTrackedMarkBetween = ({
56016
56016
  return markFound;
56017
56017
  };
56018
56018
  const markInsertion = ({ tr, from: from2, to, user, date }) => {
56019
- tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName]);
56020
- tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName]);
56019
+ tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName$1]);
56020
+ tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName$1]);
56021
56021
  let trackedMark = findTrackedMarkBetween({
56022
56022
  tr,
56023
56023
  from: from2,
56024
56024
  to,
56025
- markName: TrackInsertMarkName,
56025
+ markName: TrackInsertMarkName$1,
56026
56026
  attrs: { authorEmail: user.email }
56027
56027
  });
56028
56028
  let id;
@@ -56031,7 +56031,7 @@ const markInsertion = ({ tr, from: from2, to, user, date }) => {
56031
56031
  } else {
56032
56032
  id = v4();
56033
56033
  }
56034
- const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName].create({
56034
+ const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName$1].create({
56035
56035
  id,
56036
56036
  author: user.name,
56037
56037
  authorEmail: user.email,
@@ -56057,7 +56057,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56057
56057
  tr,
56058
56058
  from: from2,
56059
56059
  to,
56060
- markName: TrackDeleteMarkName,
56060
+ markName: TrackDeleteMarkName$1,
56061
56061
  attrs: { authorEmail: user.email }
56062
56062
  });
56063
56063
  let id;
@@ -56068,7 +56068,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56068
56068
  } else {
56069
56069
  id = v4();
56070
56070
  }
56071
- const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName].create({
56071
+ const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName$1].create({
56072
56072
  id,
56073
56073
  author: user.name,
56074
56074
  authorEmail: user.email,
@@ -56081,7 +56081,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56081
56081
  if (node.type.name.includes("table")) {
56082
56082
  return;
56083
56083
  }
56084
- if (node.isInline && node.marks.find((mark) => mark.type.name === TrackInsertMarkName && mark.attrs.authorEmail === user.email)) {
56084
+ if (node.isInline && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1 && mark.attrs.authorEmail === user.email)) {
56085
56085
  const removeStep = new ReplaceStep(
56086
56086
  deletionMap.map(Math.max(from2, pos)),
56087
56087
  deletionMap.map(Math.min(to, pos + node.nodeSize)),
@@ -56090,14 +56090,14 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56090
56090
  if (!tr.maybeStep(removeStep).failed) {
56091
56091
  deletionMap.appendMap(removeStep.getMap());
56092
56092
  }
56093
- } else if (node.isInline && !node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
56093
+ } else if (node.isInline && !node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
56094
56094
  nodes.push(node);
56095
56095
  tr.addMark(
56096
56096
  deletionMap.map(Math.max(from2, pos)),
56097
56097
  deletionMap.map(Math.min(to, pos + node.nodeSize)),
56098
56098
  deletionMark
56099
56099
  );
56100
- } else if (node.attrs.track && !node.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName) && !["bulletList", "orderedList"].includes(node.type.name)) ;
56100
+ } else if (node.attrs.track && !node.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName$1) && !["bulletList", "orderedList"].includes(node.type.name)) ;
56101
56101
  });
56102
56102
  return { deletionMark, deletionMap, nodes };
56103
56103
  };
@@ -56164,7 +56164,7 @@ const getTrackChanges = (state2, id = null) => {
56164
56164
  }
56165
56165
  allInlineNodes.forEach(({ node, pos }) => {
56166
56166
  const { marks } = node;
56167
- const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
56167
+ const trackedMarks = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
56168
56168
  if (marks.length > 0) {
56169
56169
  marks.forEach((mark) => {
56170
56170
  if (trackedMarks.includes(mark.type.name)) {
@@ -56277,7 +56277,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56277
56277
  return DecorationSet.empty;
56278
56278
  }
56279
56279
  trackedChanges.forEach(({ mark, from: from2, to }) => {
56280
- if (mark.type.name === TrackInsertMarkName) {
56280
+ if (mark.type.name === TrackInsertMarkName$1) {
56281
56281
  if (onlyOriginalShown) {
56282
56282
  const decoration = Decoration.inline(from2, to, {
56283
56283
  class: "track-insert-dec hidden"
@@ -56295,7 +56295,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56295
56295
  decorations.push(decoration);
56296
56296
  }
56297
56297
  }
56298
- if (mark.type.name === TrackDeleteMarkName) {
56298
+ if (mark.type.name === TrackDeleteMarkName$1) {
56299
56299
  if (onlyOriginalShown) {
56300
56300
  const decoration = Decoration.inline(from2, to, {
56301
56301
  class: "track-delete-dec normal"
@@ -56327,7 +56327,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56327
56327
  decorations.push(decorationWidget);
56328
56328
  }
56329
56329
  }
56330
- if (mark.type.name === TrackFormatMarkName) {
56330
+ if (mark.type.name === TrackFormatMarkName$1) {
56331
56331
  if (onlyOriginalShown) {
56332
56332
  const decoration = Decoration.inline(from2, to, {
56333
56333
  class: "track-format-dec before"
@@ -56348,7 +56348,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56348
56348
  });
56349
56349
  return DecorationSet.create(state2.doc, decorations);
56350
56350
  };
56351
- const CommentMarkName = "commentMark";
56351
+ const CommentMarkName$1 = "commentMark";
56352
56352
  const resolveCommentMeta = ({ converter, importedId }) => {
56353
56353
  const comments = converter?.comments || [];
56354
56354
  const matchingImportedComment = comments.find((c2) => c2.importedId == importedId);
@@ -56379,7 +56379,7 @@ const ensureFallbackComment = ({ converter, matchingImportedComment, commentId,
56379
56379
  const removeCommentsById = ({ commentId, state: state2, tr, dispatch }) => {
56380
56380
  const positions = getCommentPositionsById(commentId, state2.doc);
56381
56381
  positions.forEach(({ from: from2, to }) => {
56382
- tr.removeMark(from2, to, state2.schema.marks[CommentMarkName]);
56382
+ tr.removeMark(from2, to, state2.schema.marks[CommentMarkName$1]);
56383
56383
  });
56384
56384
  dispatch(tr);
56385
56385
  };
@@ -56387,7 +56387,7 @@ const getCommentPositionsById = (commentId, doc2) => {
56387
56387
  const positions = [];
56388
56388
  doc2.descendants((node, pos) => {
56389
56389
  const { marks } = node;
56390
- const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
56390
+ const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
56391
56391
  if (commentMark) {
56392
56392
  const { attrs } = commentMark;
56393
56393
  const { commentId: currentCommentId } = attrs;
@@ -56407,7 +56407,7 @@ const prepareCommentsForExport = (doc2, tr, schema, comments = []) => {
56407
56407
  const endNodes = [];
56408
56408
  const seen = /* @__PURE__ */ new Set();
56409
56409
  doc2.descendants((node, pos) => {
56410
- const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName) || [];
56410
+ const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName$1) || [];
56411
56411
  commentMarks.forEach((commentMark) => {
56412
56412
  const { attrs = {} } = commentMark;
56413
56413
  const { commentId } = attrs;
@@ -56535,7 +56535,7 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
56535
56535
  importedId,
56536
56536
  internal: itemToMark.internal
56537
56537
  };
56538
- tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
56538
+ tr.addMark(start2, pos + 1, schema.marks[CommentMarkName$1].create(markAttrs));
56539
56539
  toDelete.push({ start: pos, end: pos + 1 });
56540
56540
  } else if (type2.name === "commentReference") {
56541
56541
  toDelete.push({ start: pos, end: pos + 1 });
@@ -56653,7 +56653,7 @@ const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, nod
56653
56653
  existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
56654
56654
  }
56655
56655
  };
56656
- const TRACK_CHANGE_MARKS = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
56656
+ const TRACK_CHANGE_MARKS = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
56657
56657
  const CommentsPluginKey = new PluginKey("comments");
56658
56658
  const CommentsPlugin = Extension.create({
56659
56659
  name: "comments",
@@ -56669,7 +56669,7 @@ const CommentsPlugin = Extension.create({
56669
56669
  tr.addMark(
56670
56670
  $from.pos,
56671
56671
  $to.pos,
56672
- this.editor.schema.marks[CommentMarkName].create({
56672
+ this.editor.schema.marks[CommentMarkName$1].create({
56673
56673
  commentId: resolvedCommentId,
56674
56674
  internal: resolvedInternal
56675
56675
  })
@@ -56709,7 +56709,7 @@ const CommentsPlugin = Extension.create({
56709
56709
  doc2.descendants((node, pos) => {
56710
56710
  if (foundStartNode) return;
56711
56711
  const { marks = [] } = node;
56712
- const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
56712
+ const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
56713
56713
  if (commentMark) {
56714
56714
  const { attrs } = commentMark;
56715
56715
  const wid = attrs.commentId;
@@ -56723,7 +56723,7 @@ const CommentsPlugin = Extension.create({
56723
56723
  tr.addMark(
56724
56724
  foundPos,
56725
56725
  foundPos + foundStartNode.nodeSize,
56726
- this.editor.schema.marks[CommentMarkName].create({
56726
+ this.editor.schema.marks[CommentMarkName$1].create({
56727
56727
  commentId,
56728
56728
  internal: isInternal
56729
56729
  })
@@ -56852,10 +56852,10 @@ const CommentsPlugin = Extension.create({
56852
56852
  prevDoc = doc2;
56853
56853
  shouldUpdate = false;
56854
56854
  const decorations = [];
56855
- const allCommentPositions = onlyActiveThreadChanged ? prevAllCommentPositions : {};
56855
+ const allCommentPositions = {};
56856
56856
  doc2.descendants((node, pos) => {
56857
56857
  const { marks = [] } = node;
56858
- const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName);
56858
+ const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName$1);
56859
56859
  let hasActive = false;
56860
56860
  commentMarks.forEach((commentMark) => {
56861
56861
  const { attrs } = commentMark;
@@ -56981,7 +56981,7 @@ const getActiveCommentId = (doc2, selection) => {
56981
56981
  return;
56982
56982
  }
56983
56983
  const { marks = [] } = node;
56984
- const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
56984
+ const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
56985
56985
  if (commentMark) {
56986
56986
  overlaps.push({
56987
56987
  node,
@@ -57004,7 +57004,7 @@ const getActiveCommentId = (doc2, selection) => {
57004
57004
  }
57005
57005
  });
57006
57006
  const { marks: closestMarks = [] } = closestCommentRangeStart || {};
57007
- const closestCommentMark = closestMarks.find((mark) => mark.type.name === CommentMarkName);
57007
+ const closestCommentMark = closestMarks.find((mark) => mark.type.name === CommentMarkName$1);
57008
57008
  return closestCommentMark?.attrs?.commentId || closestCommentMark?.attrs?.importedId;
57009
57009
  };
57010
57010
  const findTrackedMark = ({
@@ -57054,7 +57054,7 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
57054
57054
  let nodes = step?.slice?.content?.content || [];
57055
57055
  if (!nodes.length) {
57056
57056
  newEditorState.doc.descendants((node) => {
57057
- const hasFormatMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
57057
+ const hasFormatMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
57058
57058
  if (hasFormatMark) {
57059
57059
  nodes = [node];
57060
57060
  return false;
@@ -57079,19 +57079,19 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
57079
57079
  const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion }) => {
57080
57080
  let trackedChangeText = "";
57081
57081
  let deletionText = "";
57082
- if (trackedChangeType === TrackInsertMarkName) {
57082
+ if (trackedChangeType === TrackInsertMarkName$1) {
57083
57083
  trackedChangeText = nodes.reduce((acc, node) => {
57084
57084
  if (!node.marks.find((nodeMark) => nodeMark.type.name === mark.type.name)) return acc;
57085
57085
  acc += node?.text || node?.textContent || "";
57086
57086
  return acc;
57087
57087
  }, "");
57088
57088
  }
57089
- if (trackedChangeType === TrackFormatMarkName) {
57089
+ if (trackedChangeType === TrackFormatMarkName$1) {
57090
57090
  trackedChangeText = translateFormatChangesToEnglish(mark.attrs);
57091
57091
  }
57092
- if (trackedChangeType === TrackDeleteMarkName || isDeletionInsertion) {
57092
+ if (trackedChangeType === TrackDeleteMarkName$1 || isDeletionInsertion) {
57093
57093
  deletionText = nodes.reduce((acc, node) => {
57094
- if (!node.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName)) return acc;
57094
+ if (!node.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName$1)) return acc;
57095
57095
  acc += node?.text || node?.textContent || "";
57096
57096
  return acc;
57097
57097
  }, "");
@@ -57157,7 +57157,7 @@ function findRangeById(doc2, id) {
57157
57157
  if (to === null || pos + node.nodeSize > to) to = pos + node.nodeSize;
57158
57158
  }
57159
57159
  const commentMark = node.marks.find(
57160
- (m2) => m2.type.name === CommentMarkName && (m2.attrs.commentId === id || m2.attrs.importedId === id)
57160
+ (m2) => m2.type.name === CommentMarkName$1 && (m2.attrs.commentId === id || m2.attrs.importedId === id)
57161
57161
  );
57162
57162
  if (commentMark) {
57163
57163
  if (from2 === null || pos < from2) from2 = pos;
@@ -57167,7 +57167,7 @@ function findRangeById(doc2, id) {
57167
57167
  return from2 !== null && to !== null ? { from: from2, to } : null;
57168
57168
  }
57169
57169
  const replaceStep = ({ state: state2, tr, step, newTr, map: map22, user, date, originalStep, originalStepIndex }) => {
57170
- const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName];
57170
+ const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName$1];
57171
57171
  const deletionMark = findMark(state2, deletionMarkSchema, false);
57172
57172
  const positionTo = deletionMark ? deletionMark.to : step.to;
57173
57173
  const newStep = new ReplaceStep(
@@ -57231,17 +57231,17 @@ const addMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) => {
57231
57231
  if (!node.isInline) {
57232
57232
  return;
57233
57233
  }
57234
- if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
57234
+ if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
57235
57235
  return false;
57236
57236
  }
57237
57237
  const existingChangeMark = node.marks.find(
57238
- (mark) => [TrackDeleteMarkName, TrackFormatMarkName].includes(mark.type.name)
57238
+ (mark) => [TrackDeleteMarkName$1, TrackFormatMarkName$1].includes(mark.type.name)
57239
57239
  );
57240
57240
  const wid = existingChangeMark ? existingChangeMark.attrs.id : v4();
57241
57241
  newTr.addMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
57242
57242
  const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
57243
57243
  if (allowedMarks.includes(step.mark.type.name) && !node.marks.find((mark) => mark.type === step.mark.type)) {
57244
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
57244
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
57245
57245
  let after = [];
57246
57246
  let before = [];
57247
57247
  if (formatChangeMark) {
@@ -57277,7 +57277,7 @@ const addMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) => {
57277
57277
  ];
57278
57278
  }
57279
57279
  if (after.length || before.length) {
57280
- const newFormatMark = state2.schema.marks[TrackFormatMarkName].create({
57280
+ const newFormatMark = state2.schema.marks[TrackFormatMarkName$1].create({
57281
57281
  id: wid,
57282
57282
  author: user.name,
57283
57283
  authorEmail: user.email,
@@ -57309,13 +57309,13 @@ const removeMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) =
57309
57309
  if (!node.isInline) {
57310
57310
  return true;
57311
57311
  }
57312
- if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
57312
+ if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
57313
57313
  return false;
57314
57314
  }
57315
57315
  newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
57316
57316
  const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
57317
57317
  if (allowedMarks.includes(step.mark.type.name) && node.marks.find((mark) => mark.type === step.mark.type)) {
57318
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
57318
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
57319
57319
  let after = [];
57320
57320
  let before = [];
57321
57321
  if (formatChangeMark) {
@@ -57343,7 +57343,7 @@ const removeMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) =
57343
57343
  ];
57344
57344
  }
57345
57345
  if (after.length || before.length) {
57346
- const newFormatMark = state2.schema.marks[TrackFormatMarkName].create({
57346
+ const newFormatMark = state2.schema.marks[TrackFormatMarkName$1].create({
57347
57347
  id: v4(),
57348
57348
  author: user.name,
57349
57349
  authorEmail: user.email,
@@ -57424,7 +57424,7 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
57424
57424
  newTr.setMeta("addToHistory", tr.getMeta("addToHistory"));
57425
57425
  }
57426
57426
  if (tr.selectionSet) {
57427
- const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName];
57427
+ const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName$1];
57428
57428
  const deletionMark = findMark(state2, deletionMarkSchema, false);
57429
57429
  if (tr.selection instanceof TextSelection$1 && (tr.selection.from < state2.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
57430
57430
  const caretPos = map22.map(tr.selection.from, -1);
@@ -59031,7 +59031,7 @@ const isHeadless = (editor) => {
59031
59031
  const shouldSkipNodeView = (editor) => {
59032
59032
  return isHeadless(editor);
59033
59033
  };
59034
- const summaryVersion = "1.0.0-beta.31";
59034
+ const summaryVersion = "1.0.0-beta.33";
59035
59035
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59036
59036
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59037
59037
  function mapAttributes(attrs) {
@@ -59820,7 +59820,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
59820
59820
  { default: remarkStringify },
59821
59821
  { default: remarkGfm }
59822
59822
  ] = await Promise.all([
59823
- Promise.resolve().then(() => require("./index-eG-VYUeN-CG3M1n5T.cjs")),
59823
+ Promise.resolve().then(() => require("./index-hX4H5xPH-DfkQd7UH.cjs")),
59824
59824
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
59825
59825
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
59826
59826
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60025,7 +60025,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60025
60025
  * Process collaboration migrations
60026
60026
  */
60027
60027
  processCollaborationMigrations() {
60028
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.31");
60028
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.33");
60029
60029
  if (!this.options.ydoc) return;
60030
60030
  const metaMap = this.options.ydoc.getMap("meta");
60031
60031
  let docVersion = metaMap.get("version");
@@ -65167,7 +65167,27 @@ function handleStructuredContentBlockNode(node, context) {
65167
65167
  blocks.push(block);
65168
65168
  recordBlockKind(block.kind);
65169
65169
  });
65170
- } else if (child.type === "table") ;
65170
+ } else if (child.type === "table") {
65171
+ const tableNodeToBlock2 = converters?.tableNodeToBlock;
65172
+ if (tableNodeToBlock2) {
65173
+ const tableBlock = tableNodeToBlock2(
65174
+ child,
65175
+ nextBlockId,
65176
+ positions,
65177
+ defaultFont,
65178
+ defaultSize,
65179
+ styleContext,
65180
+ trackedChangesConfig,
65181
+ bookmarks,
65182
+ hyperlinkConfig
65183
+ );
65184
+ if (tableBlock) {
65185
+ applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
65186
+ blocks.push(tableBlock);
65187
+ recordBlockKind(tableBlock.kind);
65188
+ }
65189
+ }
65190
+ }
65171
65191
  });
65172
65192
  }
65173
65193
  function processParagraphChild(child, sectionMetadata, context, output, converters) {
@@ -65637,6 +65657,65 @@ function imageNodeToRun(node, positions, activeSdt) {
65637
65657
  }
65638
65658
  return run2;
65639
65659
  }
65660
+ function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
65661
+ const attrs = node.attrs ?? {};
65662
+ const rawVariant = attrs.type ?? fieldMetadata?.variant ?? "text";
65663
+ const validVariants = ["text", "image", "signature", "checkbox", "html", "link"];
65664
+ const variant = validVariants.includes(rawVariant) ? rawVariant : "text";
65665
+ 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) || "";
65666
+ const run2 = {
65667
+ kind: "fieldAnnotation",
65668
+ variant,
65669
+ displayLabel
65670
+ };
65671
+ const fieldId = typeof attrs.fieldId === "string" ? attrs.fieldId : fieldMetadata?.fieldId;
65672
+ if (fieldId) run2.fieldId = fieldId;
65673
+ const fieldType = typeof attrs.fieldType === "string" ? attrs.fieldType : fieldMetadata?.fieldType;
65674
+ if (fieldType) run2.fieldType = fieldType;
65675
+ const fieldColor = typeof attrs.fieldColor === "string" ? attrs.fieldColor : fieldMetadata?.fieldColor;
65676
+ if (fieldColor) run2.fieldColor = fieldColor;
65677
+ const borderColor = typeof attrs.borderColor === "string" ? attrs.borderColor : fieldMetadata?.borderColor;
65678
+ if (borderColor) run2.borderColor = borderColor;
65679
+ const highlighted = attrs.highlighted ?? fieldMetadata?.highlighted;
65680
+ if (highlighted === false) run2.highlighted = false;
65681
+ if (attrs.hidden === true || fieldMetadata?.hidden === true) run2.hidden = true;
65682
+ const visibility = attrs.visibility ?? fieldMetadata?.visibility;
65683
+ if (visibility === "hidden") run2.visibility = "hidden";
65684
+ const imageSrc = typeof attrs.imageSrc === "string" ? attrs.imageSrc : fieldMetadata?.imageSrc;
65685
+ if (imageSrc) run2.imageSrc = imageSrc;
65686
+ const linkUrl = typeof attrs.linkUrl === "string" ? attrs.linkUrl : fieldMetadata?.linkUrl;
65687
+ if (linkUrl) run2.linkUrl = linkUrl;
65688
+ const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
65689
+ if (typeof rawHtml === "string") run2.rawHtml = rawHtml;
65690
+ const size2 = attrs.size ?? fieldMetadata?.size;
65691
+ if (size2 && (typeof size2.width === "number" || typeof size2.height === "number")) {
65692
+ run2.size = {
65693
+ width: typeof size2.width === "number" ? size2.width : void 0,
65694
+ height: typeof size2.height === "number" ? size2.height : void 0
65695
+ };
65696
+ }
65697
+ const fontFamily2 = attrs.fontFamily ?? fieldMetadata?.fontFamily;
65698
+ if (typeof fontFamily2 === "string") run2.fontFamily = fontFamily2;
65699
+ const fontSize2 = attrs.fontSize ?? fieldMetadata?.fontSize;
65700
+ if (typeof fontSize2 === "string" || typeof fontSize2 === "number") run2.fontSize = fontSize2;
65701
+ const textColor = attrs.textColor ?? fieldMetadata?.textColor;
65702
+ if (typeof textColor === "string") run2.textColor = textColor;
65703
+ const textHighlight = attrs.textHighlight ?? fieldMetadata?.textHighlight;
65704
+ if (typeof textHighlight === "string") run2.textHighlight = textHighlight;
65705
+ const formatting = fieldMetadata?.formatting;
65706
+ if (attrs.bold === true || formatting?.bold === true) run2.bold = true;
65707
+ if (attrs.italic === true || formatting?.italic === true) run2.italic = true;
65708
+ if (attrs.underline === true || formatting?.underline === true) run2.underline = true;
65709
+ const pos = positions.get(node);
65710
+ if (pos) {
65711
+ run2.pmStart = pos.start;
65712
+ run2.pmEnd = pos.end;
65713
+ }
65714
+ if (fieldMetadata) {
65715
+ run2.sdt = fieldMetadata;
65716
+ }
65717
+ return run2;
65718
+ }
65640
65719
  const isTextRun$1 = (run2) => run2.kind !== "tab";
65641
65720
  const dataAttrsCompatible = (a, b2) => {
65642
65721
  const aAttrs = a.dataAttrs;
@@ -65932,28 +66011,20 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
65932
66011
  }
65933
66012
  if (node.type === "fieldAnnotation") {
65934
66013
  const fieldMetadata = resolveNodeSdtMetadata(node, "fieldAnnotation");
66014
+ let contentText;
65935
66015
  if (Array.isArray(node.content) && node.content.length > 0) {
65936
- node.content.forEach((child) => visitNode(child, inheritedMarks, fieldMetadata ?? activeSdt, activeRunStyleId));
65937
- } else {
65938
- const nodeAttrs = typeof node.attrs === "object" && node.attrs !== null ? node.attrs : {};
65939
- 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) || "";
65940
- if (label && typeof label === "string") {
65941
- const run2 = textNodeToRun(
65942
- { type: "text", text: label },
65943
- positions,
65944
- defaultFont,
65945
- defaultSize,
65946
- inheritedMarks,
65947
- fieldMetadata ?? activeSdt,
65948
- hyperlinkConfig,
65949
- themeColors
65950
- );
65951
- const inlineStyleId = getInlineStyleId(inheritedMarks);
65952
- applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
65953
- applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
65954
- currentRuns.push(run2);
65955
- }
66016
+ const extractText = (n) => {
66017
+ if (n.type === "text" && typeof n.text === "string") return n.text;
66018
+ if (Array.isArray(n.content)) {
66019
+ return n.content.map(extractText).join("");
66020
+ }
66021
+ return "";
66022
+ };
66023
+ contentText = node.content.map(extractText).join("");
65956
66024
  }
66025
+ const nodeForRun = contentText && contentText.length > 0 ? { ...node, attrs: { ...node.attrs ?? {}, displayLabel: contentText } } : node;
66026
+ const run2 = fieldAnnotationNodeToRun(nodeForRun, positions, fieldMetadata);
66027
+ currentRuns.push(run2);
65957
66028
  return;
65958
66029
  }
65959
66030
  if (node.type === "pageReference") {
@@ -66790,9 +66861,9 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
66790
66861
  }
66791
66862
  const attrs = spacingEl.attributes;
66792
66863
  const spacing = {};
66793
- const before = parseIntSafe(attrs["w:before"]);
66794
- const after = parseIntSafe(attrs["w:after"]);
66795
- const line = parseIntSafe(attrs["w:line"]);
66864
+ const before = parseIntSafe$1(attrs["w:before"]);
66865
+ const after = parseIntSafe$1(attrs["w:after"]);
66866
+ const line = parseIntSafe$1(attrs["w:line"]);
66796
66867
  const rawLineRule = attrs["w:lineRule"];
66797
66868
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
66798
66869
  if (before != null) spacing.before = twipsToPx$1(before);
@@ -66807,11 +66878,11 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
66807
66878
  if (lineRule) spacing.lineRule = lineRule;
66808
66879
  const result = Object.keys(spacing).length > 0 ? { spacing } : void 0;
66809
66880
  return result;
66810
- } catch (err) {
66881
+ } catch {
66811
66882
  return void 0;
66812
66883
  }
66813
66884
  };
66814
- const parseIntSafe = (value) => {
66885
+ const parseIntSafe$1 = (value) => {
66815
66886
  if (value == null) return void 0;
66816
66887
  const num = typeof value === "number" ? value : parseInt(String(value), 10);
66817
66888
  return Number.isFinite(num) ? num : void 0;
@@ -67463,7 +67534,7 @@ function getMeasurementContext() {
67463
67534
  return measurementCtx;
67464
67535
  }
67465
67536
  function getRunFontString(run2) {
67466
- if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
67537
+ if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
67467
67538
  return "normal normal 16px Arial";
67468
67539
  }
67469
67540
  const style2 = run2.italic ? "italic" : "normal";
@@ -67494,6 +67565,10 @@ function sliceRunsForLine$1(block, line) {
67494
67565
  result.push(run2);
67495
67566
  continue;
67496
67567
  }
67568
+ if (run2.kind === "fieldAnnotation") {
67569
+ result.push(run2);
67570
+ continue;
67571
+ }
67497
67572
  const text = run2.text ?? "";
67498
67573
  const isFirstRun = runIndex === line.fromRun;
67499
67574
  const isLastRun = runIndex === line.toRun;
@@ -67527,7 +67602,8 @@ function measureCharacterX(block, line, charOffset) {
67527
67602
  1,
67528
67603
  runs2.reduce((sum, run2) => {
67529
67604
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
67530
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
67605
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
67606
+ return sum;
67531
67607
  return sum + (run2.text ?? "").length;
67532
67608
  }, 0)
67533
67609
  );
@@ -67548,7 +67624,7 @@ function measureCharacterX(block, line, charOffset) {
67548
67624
  currentCharOffset += runLength2;
67549
67625
  continue;
67550
67626
  }
67551
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67627
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67552
67628
  const runLength = text.length;
67553
67629
  if (currentCharOffset + runLength >= charOffset) {
67554
67630
  const offsetInRun = charOffset - currentCharOffset;
@@ -67591,7 +67667,7 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
67591
67667
  if (isTabRun$1(run2)) {
67592
67668
  return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
67593
67669
  }
67594
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
67670
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
67595
67671
  return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
67596
67672
  }
67597
67673
  const text = run2.text ?? "";
@@ -67620,7 +67696,7 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
67620
67696
  let lastPm = fallbackPmStart;
67621
67697
  for (const run2 of runs) {
67622
67698
  const isTab = isTabRun$1(run2);
67623
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67699
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67624
67700
  const runLength = isTab ? TAB_CHAR_LENGTH : text.length;
67625
67701
  const runPmStart = typeof run2.pmStart === "number" ? run2.pmStart : null;
67626
67702
  const runPmEnd = typeof run2.pmEnd === "number" ? run2.pmEnd : runPmStart != null ? runPmStart + runLength : null;
@@ -67646,7 +67722,8 @@ function findCharacterAtX(block, line, x2, pmStart) {
67646
67722
  1,
67647
67723
  runs2.reduce((sum, run2) => {
67648
67724
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
67649
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
67725
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
67726
+ return sum;
67650
67727
  return sum + (run2.text ?? "").length;
67651
67728
  }, 0)
67652
67729
  );
@@ -67681,7 +67758,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
67681
67758
  currentCharOffset += TAB_CHAR_LENGTH;
67682
67759
  continue;
67683
67760
  }
67684
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67761
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67685
67762
  const runLength = text.length;
67686
67763
  if (runLength === 0) continue;
67687
67764
  ctx2.font = getRunFontString(run2);
@@ -67721,7 +67798,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
67721
67798
  };
67722
67799
  }
67723
67800
  const computeLetterSpacingWidth = (run2, precedingChars, runLength) => {
67724
- if (isTabRun$1(run2) || "src" in run2 || !("letterSpacing" in run2) || !run2.letterSpacing) {
67801
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "fieldAnnotation" || !("letterSpacing" in run2) || !run2.letterSpacing) {
67725
67802
  return 0;
67726
67803
  }
67727
67804
  const maxGaps = Math.max(runLength - 1, 0);
@@ -67818,6 +67895,17 @@ function clickToPositionDom(domContainer, clientX, clientY) {
67818
67895
  pmStart: fragmentEl.dataset.pmStart,
67819
67896
  pmEnd: fragmentEl.dataset.pmEnd
67820
67897
  });
67898
+ const hitChainLine = hitChain.find(
67899
+ (el) => el.classList?.contains?.(CLASS_NAMES$1.line) && el.dataset?.pmStart !== void 0 && el.dataset?.pmEnd !== void 0
67900
+ );
67901
+ if (hitChainLine) {
67902
+ log("Using hit chain line directly:", {
67903
+ pmStart: hitChainLine.dataset.pmStart,
67904
+ pmEnd: hitChainLine.dataset.pmEnd
67905
+ });
67906
+ const result2 = processLineElement(hitChainLine, viewX);
67907
+ return result2;
67908
+ }
67821
67909
  const result = processFragment(fragmentEl, viewX, viewY);
67822
67910
  return result;
67823
67911
  }
@@ -67883,7 +67971,9 @@ function processFragment(fragmentEl, viewX, viewY) {
67883
67971
  if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
67884
67972
  return null;
67885
67973
  }
67886
- const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
67974
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
67975
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
67976
+ );
67887
67977
  log(
67888
67978
  "Spans/anchors in line:",
67889
67979
  spanEls.map((el, i) => {
@@ -67942,6 +68032,77 @@ function processFragment(fragmentEl, viewX, viewY) {
67942
68032
  const pos = spanStart + charIndex;
67943
68033
  return pos;
67944
68034
  }
68035
+ function processLineElement(lineEl, viewX) {
68036
+ const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
68037
+ const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
68038
+ const lineRect = lineEl.getBoundingClientRect();
68039
+ log("processLineElement:", {
68040
+ pmStart: lineStart,
68041
+ pmEnd: lineEnd,
68042
+ rect: { top: lineRect.top, bottom: lineRect.bottom, left: lineRect.left, right: lineRect.right }
68043
+ });
68044
+ if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
68045
+ return null;
68046
+ }
68047
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
68048
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
68049
+ );
68050
+ log(
68051
+ "Spans/anchors in line:",
68052
+ spanEls.map((el, i) => {
68053
+ const rect = el.getBoundingClientRect();
68054
+ return {
68055
+ index: i,
68056
+ tag: el.tagName,
68057
+ pmStart: el.dataset.pmStart,
68058
+ pmEnd: el.dataset.pmEnd,
68059
+ text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
68060
+ visibility: el.style.visibility,
68061
+ rect: { left: rect.left, right: rect.right, width: rect.width }
68062
+ };
68063
+ })
68064
+ );
68065
+ if (spanEls.length === 0) {
68066
+ return lineStart;
68067
+ }
68068
+ const firstRect = spanEls[0].getBoundingClientRect();
68069
+ if (viewX <= firstRect.left) {
68070
+ return lineStart;
68071
+ }
68072
+ const lastRect = spanEls[spanEls.length - 1].getBoundingClientRect();
68073
+ if (viewX >= lastRect.right) {
68074
+ return lineEnd;
68075
+ }
68076
+ const targetEl = findSpanAtX(spanEls, viewX);
68077
+ if (!targetEl) {
68078
+ return lineStart;
68079
+ }
68080
+ const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
68081
+ const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
68082
+ const targetRect = targetEl.getBoundingClientRect();
68083
+ log("Target element:", {
68084
+ tag: targetEl.tagName,
68085
+ pmStart: spanStart,
68086
+ pmEnd: spanEnd,
68087
+ text: targetEl.textContent?.substring(0, 30),
68088
+ visibility: targetEl.style.visibility,
68089
+ rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
68090
+ });
68091
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
68092
+ return null;
68093
+ }
68094
+ const firstChild = targetEl.firstChild;
68095
+ if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
68096
+ const elRect = targetEl.getBoundingClientRect();
68097
+ const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
68098
+ const snapPos = closerToLeft ? spanStart : spanEnd;
68099
+ return snapPos;
68100
+ }
68101
+ const textNode = firstChild;
68102
+ const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
68103
+ const pos = spanStart + charIndex;
68104
+ return pos;
68105
+ }
67945
68106
  function findLineAtY(lineEls, viewY) {
67946
68107
  if (lineEls.length === 0) {
67947
68108
  return null;
@@ -70832,7 +70993,7 @@ const hashRuns = (block) => {
70832
70993
  return `img:${srcHash}:${imgRun.width}x${imgRun.height}`;
70833
70994
  }
70834
70995
  const text = normalizeText(
70835
- "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
70996
+ "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? ""
70836
70997
  );
70837
70998
  const bold = "bold" in run2 ? run2.bold : false;
70838
70999
  const italic = "italic" in run2 ? run2.italic : false;
@@ -71544,7 +71705,7 @@ function extractBlockText(block) {
71544
71705
  let pmStart = Infinity;
71545
71706
  let pmEnd = 0;
71546
71707
  for (const run2 of block.runs) {
71547
- text += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text;
71708
+ text += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text;
71548
71709
  if (run2.pmStart !== void 0) {
71549
71710
  pmStart = Math.min(pmStart, run2.pmStart);
71550
71711
  }
@@ -71594,7 +71755,7 @@ function fontString(run2) {
71594
71755
  return `${italic}${bold}${size2}px ${family}`.trim();
71595
71756
  }
71596
71757
  function runText(run2) {
71597
- return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
71758
+ return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
71598
71759
  }
71599
71760
  function measureRunSliceWidth(run2, fromChar, toChar) {
71600
71761
  const context = getCtx();
@@ -71756,7 +71917,7 @@ const paragraphBlocksEqual = (a, b2) => {
71756
71917
  for (let i = 0; i < a.runs.length; i += 1) {
71757
71918
  const runA = a.runs[i];
71758
71919
  const runB = b2.runs[i];
71759
- 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)) {
71920
+ 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)) {
71760
71921
  return false;
71761
71922
  }
71762
71923
  }
@@ -71876,7 +72037,7 @@ function computeHeaderFooterContentHash(blocks) {
71876
72037
  parts.push(block.id);
71877
72038
  if (block.kind === "paragraph") {
71878
72039
  for (const run2 of block.runs) {
71879
- if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
72040
+ if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break" && run2.kind !== "fieldAnnotation") {
71880
72041
  parts.push(run2.text ?? "");
71881
72042
  }
71882
72043
  if ("bold" in run2 && run2.bold) parts.push("b");
@@ -72361,6 +72522,255 @@ var Priority = /* @__PURE__ */ ((Priority2) => {
72361
72522
  /** P3: Heavy debounce for full document layout */
72362
72523
  [Priority.P3]: 150
72363
72524
  });
72525
+ const DEFAULT_MIME_TYPE$1 = "application/x-field-annotation";
72526
+ const LEGACY_MIME_TYPE = "fieldAnnotation";
72527
+ function parseIntSafe(value) {
72528
+ if (!value) return void 0;
72529
+ const parsed = parseInt(value, 10);
72530
+ return Number.isFinite(parsed) ? parsed : void 0;
72531
+ }
72532
+ function extractFieldAnnotationData(element) {
72533
+ const dataset = element.dataset;
72534
+ const attributes = {};
72535
+ for (const key2 in dataset) {
72536
+ const value = dataset[key2];
72537
+ if (value !== void 0) {
72538
+ attributes[key2] = value;
72539
+ }
72540
+ }
72541
+ return {
72542
+ fieldId: dataset.fieldId,
72543
+ fieldType: dataset.fieldType,
72544
+ variant: dataset.variant ?? dataset.type,
72545
+ displayLabel: dataset.displayLabel,
72546
+ pmStart: parseIntSafe(dataset.pmStart),
72547
+ pmEnd: parseIntSafe(dataset.pmEnd),
72548
+ attributes
72549
+ };
72550
+ }
72551
+ class DragHandler {
72552
+ /**
72553
+ * Creates a new DragHandler instance.
72554
+ *
72555
+ * @param container - The DOM container element (typically .superdoc-layout)
72556
+ * @param config - Configuration options and callbacks
72557
+ */
72558
+ constructor(container, config2 = {}) {
72559
+ this.container = container;
72560
+ this.config = config2;
72561
+ this.mimeType = config2.mimeType ?? DEFAULT_MIME_TYPE$1;
72562
+ this.boundHandlers = {
72563
+ dragstart: this.handleDragStart.bind(this),
72564
+ dragover: this.handleDragOver.bind(this),
72565
+ drop: this.handleDrop.bind(this),
72566
+ dragend: this.handleDragEnd.bind(this),
72567
+ dragleave: this.handleDragLeave.bind(this)
72568
+ };
72569
+ this.windowDragoverHandler = this.handleWindowDragOver.bind(this);
72570
+ this.windowDropHandler = this.handleWindowDrop.bind(this);
72571
+ this.attachListeners();
72572
+ }
72573
+ /**
72574
+ * Attaches event listeners to the container and window.
72575
+ */
72576
+ attachListeners() {
72577
+ this.container.addEventListener("dragstart", this.boundHandlers.dragstart);
72578
+ this.container.addEventListener("dragover", this.boundHandlers.dragover);
72579
+ this.container.addEventListener("drop", this.boundHandlers.drop);
72580
+ this.container.addEventListener("dragend", this.boundHandlers.dragend);
72581
+ this.container.addEventListener("dragleave", this.boundHandlers.dragleave);
72582
+ window.addEventListener("dragover", this.windowDragoverHandler, false);
72583
+ window.addEventListener("drop", this.windowDropHandler, false);
72584
+ }
72585
+ /**
72586
+ * Removes event listeners from the container and window.
72587
+ */
72588
+ removeListeners() {
72589
+ this.container.removeEventListener("dragstart", this.boundHandlers.dragstart);
72590
+ this.container.removeEventListener("dragover", this.boundHandlers.dragover);
72591
+ this.container.removeEventListener("drop", this.boundHandlers.drop);
72592
+ this.container.removeEventListener("dragend", this.boundHandlers.dragend);
72593
+ this.container.removeEventListener("dragleave", this.boundHandlers.dragleave);
72594
+ window.removeEventListener("dragover", this.windowDragoverHandler, false);
72595
+ window.removeEventListener("drop", this.windowDropHandler, false);
72596
+ }
72597
+ /**
72598
+ * Handles dragover at window level to allow drops on overlay elements.
72599
+ * This ensures preventDefault is called even when dragging over selection
72600
+ * highlights or other UI elements that sit on top of the layout content.
72601
+ */
72602
+ handleWindowDragOver(event) {
72603
+ if (this.hasFieldAnnotationData(event)) {
72604
+ event.preventDefault();
72605
+ if (event.dataTransfer) {
72606
+ event.dataTransfer.dropEffect = "move";
72607
+ }
72608
+ const target = event.target;
72609
+ if (!this.container.contains(target)) {
72610
+ this.config.onDragOver?.({
72611
+ event,
72612
+ clientX: event.clientX,
72613
+ clientY: event.clientY,
72614
+ hasFieldAnnotation: true
72615
+ });
72616
+ }
72617
+ }
72618
+ }
72619
+ /**
72620
+ * Handles drop at window level to catch drops on overlay elements.
72621
+ * If the drop target is outside the container, we process it here.
72622
+ */
72623
+ handleWindowDrop(event) {
72624
+ if (this.hasFieldAnnotationData(event)) {
72625
+ const target = event.target;
72626
+ if (!this.container.contains(target)) {
72627
+ this.handleDrop(event);
72628
+ }
72629
+ }
72630
+ }
72631
+ /**
72632
+ * Handles the dragstart event.
72633
+ * Sets up dataTransfer with field annotation data and drag image.
72634
+ */
72635
+ handleDragStart(event) {
72636
+ const target = event.target;
72637
+ if (!target?.dataset?.draggable || target.dataset.draggable !== "true") {
72638
+ return;
72639
+ }
72640
+ const data = extractFieldAnnotationData(target);
72641
+ if (event.dataTransfer) {
72642
+ const jsonData = JSON.stringify({
72643
+ attributes: data.attributes,
72644
+ sourceField: data
72645
+ });
72646
+ event.dataTransfer.setData(this.mimeType, jsonData);
72647
+ event.dataTransfer.setData(LEGACY_MIME_TYPE, jsonData);
72648
+ event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
72649
+ event.dataTransfer.setDragImage(target, 0, 0);
72650
+ event.dataTransfer.effectAllowed = "move";
72651
+ }
72652
+ this.config.onDragStart?.({
72653
+ event,
72654
+ element: target,
72655
+ data
72656
+ });
72657
+ }
72658
+ /**
72659
+ * Handles the dragover event.
72660
+ * Provides visual feedback and determines if drop is allowed.
72661
+ */
72662
+ handleDragOver(event) {
72663
+ const hasFieldAnnotation = this.hasFieldAnnotationData(event);
72664
+ if (hasFieldAnnotation) {
72665
+ event.preventDefault();
72666
+ if (event.dataTransfer) {
72667
+ event.dataTransfer.dropEffect = "move";
72668
+ }
72669
+ this.container.classList.add("drag-over");
72670
+ }
72671
+ this.config.onDragOver?.({
72672
+ event,
72673
+ clientX: event.clientX,
72674
+ clientY: event.clientY,
72675
+ hasFieldAnnotation
72676
+ });
72677
+ }
72678
+ /**
72679
+ * Handles the dragleave event.
72680
+ * Removes visual feedback when drag leaves the container.
72681
+ */
72682
+ handleDragLeave(event) {
72683
+ const relatedTarget = event.relatedTarget;
72684
+ if (!relatedTarget || !this.container.contains(relatedTarget)) {
72685
+ this.container.classList.remove("drag-over");
72686
+ }
72687
+ }
72688
+ /**
72689
+ * Handles the drop event.
72690
+ * Maps drop coordinates to ProseMirror position and emits drop event.
72691
+ */
72692
+ handleDrop(event) {
72693
+ this.container.classList.remove("drag-over");
72694
+ if (!this.hasFieldAnnotationData(event)) {
72695
+ return;
72696
+ }
72697
+ event.preventDefault();
72698
+ const data = this.extractDragData(event);
72699
+ if (!data) {
72700
+ return;
72701
+ }
72702
+ const pmPosition = clickToPositionDom(this.container, event.clientX, event.clientY);
72703
+ this.config.onDrop?.({
72704
+ event,
72705
+ data,
72706
+ pmPosition,
72707
+ clientX: event.clientX,
72708
+ clientY: event.clientY
72709
+ });
72710
+ }
72711
+ /**
72712
+ * Handles the dragend event.
72713
+ * Cleans up drag state.
72714
+ */
72715
+ handleDragEnd(event) {
72716
+ this.container.classList.remove("drag-over");
72717
+ this.config.onDragEnd?.(event);
72718
+ }
72719
+ /**
72720
+ * Checks if a drag event contains field annotation data.
72721
+ */
72722
+ hasFieldAnnotationData(event) {
72723
+ if (!event.dataTransfer) {
72724
+ return false;
72725
+ }
72726
+ const types2 = event.dataTransfer.types;
72727
+ return types2.includes(this.mimeType) || types2.includes(LEGACY_MIME_TYPE);
72728
+ }
72729
+ /**
72730
+ * Extracts field annotation data from a drag event's dataTransfer.
72731
+ */
72732
+ extractDragData(event) {
72733
+ if (!event.dataTransfer) {
72734
+ return null;
72735
+ }
72736
+ let jsonData = event.dataTransfer.getData(this.mimeType);
72737
+ if (!jsonData) {
72738
+ jsonData = event.dataTransfer.getData(LEGACY_MIME_TYPE);
72739
+ }
72740
+ if (!jsonData) {
72741
+ return null;
72742
+ }
72743
+ try {
72744
+ const parsed = JSON.parse(jsonData);
72745
+ return parsed.sourceField ?? parsed.attributes ?? parsed;
72746
+ } catch {
72747
+ return null;
72748
+ }
72749
+ }
72750
+ /**
72751
+ * Updates the configuration options.
72752
+ *
72753
+ * @param config - New configuration options to merge
72754
+ */
72755
+ updateConfig(config2) {
72756
+ this.config = { ...this.config, ...config2 };
72757
+ if (config2.mimeType) {
72758
+ this.mimeType = config2.mimeType;
72759
+ }
72760
+ }
72761
+ /**
72762
+ * Destroys the drag handler and removes all event listeners.
72763
+ * Call this when the layout engine is unmounted or the container is removed.
72764
+ */
72765
+ destroy() {
72766
+ this.removeListeners();
72767
+ this.container.classList.remove("drag-over");
72768
+ }
72769
+ }
72770
+ function createDragHandler(container, config2 = {}) {
72771
+ const handler2 = new DragHandler(container, config2);
72772
+ return () => handler2.destroy();
72773
+ }
72364
72774
  const isAtomicFragment = (fragment) => {
72365
72775
  return fragment.kind === "drawing" || fragment.kind === "image";
72366
72776
  };
@@ -72412,7 +72822,7 @@ function hitTestFragment(layout, pageHit, blocks, measures, point) {
72412
72822
  });
72413
72823
  for (const fragment of fragments) {
72414
72824
  if (fragment.kind !== "para") continue;
72415
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
72825
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72416
72826
  if (blockIndex === -1) continue;
72417
72827
  const block = blocks[blockIndex];
72418
72828
  const measure = measures[blockIndex];
@@ -72439,7 +72849,7 @@ const hitTestAtomicFragment = (pageHit, blocks, measures, point) => {
72439
72849
  const withinX = point.x >= fragment.x && point.x <= fragment.x + fragment.width;
72440
72850
  const withinY = point.y >= fragment.y && point.y <= fragment.y + fragment.height;
72441
72851
  if (!withinX || !withinY) continue;
72442
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
72852
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72443
72853
  if (blockIndex === -1) continue;
72444
72854
  const block = blocks[blockIndex];
72445
72855
  const measure = measures[blockIndex];
@@ -72578,7 +72988,7 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
72578
72988
  blockId = fragment.blockId;
72579
72989
  pageIndex = pi;
72580
72990
  column = determineColumn(layout, fragment.x);
72581
- const blockIndex = blocks.findIndex((b2) => b2.id === fragment.blockId);
72991
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72582
72992
  if (blockIndex !== -1) {
72583
72993
  const measure = measures[blockIndex];
72584
72994
  if (measure && measure.kind === "paragraph") {
@@ -72728,6 +73138,44 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
72728
73138
  });
72729
73139
  return null;
72730
73140
  }
73141
+ function findBlockIndexByFragmentId(blocks, fragmentBlockId, targetPmRange) {
73142
+ const index2 = blocks.findIndex(
73143
+ (block) => block.id === fragmentBlockId && block.kind !== "pageBreak" && block.kind !== "sectionBreak"
73144
+ );
73145
+ if (index2 !== -1) {
73146
+ return index2;
73147
+ }
73148
+ const baseBlockId = fragmentBlockId.replace(/-\d+$/, "");
73149
+ if (baseBlockId === fragmentBlockId) {
73150
+ return -1;
73151
+ }
73152
+ const matchingIndices = [];
73153
+ blocks.forEach((block, idx) => {
73154
+ if (block.id === baseBlockId && block.kind === "paragraph") {
73155
+ matchingIndices.push(idx);
73156
+ }
73157
+ });
73158
+ if (matchingIndices.length === 0) {
73159
+ return -1;
73160
+ }
73161
+ if (matchingIndices.length === 1) {
73162
+ return matchingIndices[0];
73163
+ }
73164
+ if (targetPmRange) {
73165
+ for (const idx of matchingIndices) {
73166
+ const block = blocks[idx];
73167
+ if (block.kind !== "paragraph") continue;
73168
+ const hasOverlap = block.runs.some((run2) => {
73169
+ if (run2.pmStart == null || run2.pmEnd == null) return false;
73170
+ return run2.pmEnd > targetPmRange.from && run2.pmStart < targetPmRange.to;
73171
+ });
73172
+ if (hasOverlap) {
73173
+ return idx;
73174
+ }
73175
+ }
73176
+ }
73177
+ return matchingIndices[0];
73178
+ }
72731
73179
  function selectionToRects(layout, blocks, measures, from2, to) {
72732
73180
  if (from2 === to) {
72733
73181
  return [];
@@ -72736,8 +73184,10 @@ function selectionToRects(layout, blocks, measures, from2, to) {
72736
73184
  layout.pages.forEach((page, pageIndex) => {
72737
73185
  page.fragments.forEach((fragment) => {
72738
73186
  if (fragment.kind === "para") {
72739
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
72740
- if (blockIndex === -1) return;
73187
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
73188
+ if (blockIndex === -1) {
73189
+ return;
73190
+ }
72741
73191
  const block = blocks[blockIndex];
72742
73192
  const measure = measures[blockIndex];
72743
73193
  if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph") {
@@ -72773,7 +73223,7 @@ function selectionToRects(layout, blocks, measures, from2, to) {
72773
73223
  return;
72774
73224
  }
72775
73225
  if (isAtomicFragment(fragment)) {
72776
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
73226
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
72777
73227
  if (blockIndex === -1) return;
72778
73228
  const block = blocks[blockIndex];
72779
73229
  const pmRange = getAtomicPmRange(fragment, block);
@@ -72794,7 +73244,7 @@ function getFragmentAtPosition(layout, blocks, measures, pos) {
72794
73244
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
72795
73245
  const page = layout.pages[pageIndex];
72796
73246
  for (const fragment of page.fragments) {
72797
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
73247
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72798
73248
  if (blockIndex === -1) {
72799
73249
  continue;
72800
73250
  }
@@ -72899,7 +73349,7 @@ function computeLinePmRange$1(block, line) {
72899
73349
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
72900
73350
  const run2 = block.runs[runIndex];
72901
73351
  if (!run2) continue;
72902
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
73352
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
72903
73353
  const runLength = text.length;
72904
73354
  const runPmStart = run2.pmStart ?? null;
72905
73355
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
@@ -72923,7 +73373,7 @@ function pmPosToCharOffset(block, line, pmPos) {
72923
73373
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
72924
73374
  const run2 = block.runs[runIndex];
72925
73375
  if (!run2) continue;
72926
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
73376
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
72927
73377
  const runTextLength = text.length;
72928
73378
  const runPmStart = run2.pmStart ?? null;
72929
73379
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runTextLength : null);
@@ -75456,9 +75906,227 @@ const TRACK_CHANGE_STYLES = `
75456
75906
  border-bottom: 2px solid gold;
75457
75907
  }
75458
75908
  `;
75909
+ const SDT_CONTAINER_STYLES = `
75910
+ /* Document Section - Block-level container with gray border and hover tooltip */
75911
+ .superdoc-document-section {
75912
+ background-color: #fafafa;
75913
+ border: 1px solid #ababab;
75914
+ border-radius: 4px;
75915
+ position: relative;
75916
+ box-sizing: border-box;
75917
+ }
75918
+
75919
+ /* Document section tooltip - positioned above the fragment */
75920
+ .superdoc-document-section__tooltip {
75921
+ position: absolute;
75922
+ top: -19px;
75923
+ left: -1px;
75924
+ max-width: 100px;
75925
+ min-width: 0;
75926
+ height: 18px;
75927
+ border: 1px solid #ababab;
75928
+ border-bottom: none;
75929
+ border-radius: 6px 6px 0 0;
75930
+ padding: 0 8px;
75931
+ align-items: center;
75932
+ font-size: 10px;
75933
+ display: none;
75934
+ z-index: 100;
75935
+ background-color: #fafafa;
75936
+ pointer-events: none;
75937
+ }
75938
+
75939
+ .superdoc-document-section__tooltip span {
75940
+ max-width: 100%;
75941
+ overflow: hidden;
75942
+ white-space: nowrap;
75943
+ text-overflow: ellipsis;
75944
+ }
75945
+
75946
+ /* Show tooltip on hover - adjust border radius to connect with tooltip tab */
75947
+ .superdoc-document-section:hover {
75948
+ border-radius: 0 4px 4px 4px;
75949
+ }
75950
+
75951
+ .superdoc-document-section:hover .superdoc-document-section__tooltip {
75952
+ display: flex;
75953
+ align-items: center;
75954
+ }
75955
+
75956
+ /* Continuation styling: first fragment has top corners, last has bottom corners */
75957
+ .superdoc-document-section[data-sdt-container-start="true"] {
75958
+ border-radius: 4px 4px 0 0;
75959
+ }
75960
+
75961
+ .superdoc-document-section[data-sdt-container-end="true"] {
75962
+ border-radius: 0 0 4px 4px;
75963
+ }
75964
+
75965
+ .superdoc-document-section[data-sdt-container-start="true"][data-sdt-container-end="true"] {
75966
+ border-radius: 4px;
75967
+ }
75968
+
75969
+ .superdoc-document-section[data-sdt-container-start="true"]:hover {
75970
+ border-radius: 0 4px 0 0;
75971
+ }
75972
+
75973
+ /* Middle fragments have no border radius */
75974
+ .superdoc-document-section:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
75975
+ border-radius: 0;
75976
+ border-top: none;
75977
+ }
75978
+
75979
+ /* Structured Content Block - Blue border container */
75980
+ .superdoc-structured-content-block {
75981
+ padding: 1px;
75982
+ box-sizing: border-box;
75983
+ border-radius: 4px;
75984
+ border: 1px solid #629be7;
75985
+ position: relative;
75986
+ }
75987
+
75988
+ /* Structured content drag handle/label - positioned above */
75989
+ .superdoc-structured-content__label {
75990
+ font-size: 10px;
75991
+ align-items: center;
75992
+ justify-content: center;
75993
+ position: absolute;
75994
+ left: 2px;
75995
+ top: -19px;
75996
+ width: calc(100% - 4px);
75997
+ max-width: 110px;
75998
+ min-width: 0;
75999
+ height: 18px;
76000
+ padding: 0 4px;
76001
+ border: 1px solid #629be7;
76002
+ border-bottom: none;
76003
+ border-radius: 6px 6px 0 0;
76004
+ background-color: #629be7dd;
76005
+ box-sizing: border-box;
76006
+ z-index: 10;
76007
+ display: none;
76008
+ pointer-events: none;
76009
+ }
76010
+
76011
+ .superdoc-structured-content__label span {
76012
+ max-width: 100%;
76013
+ overflow: hidden;
76014
+ white-space: nowrap;
76015
+ text-overflow: ellipsis;
76016
+ }
76017
+
76018
+ .superdoc-structured-content-block:hover .superdoc-structured-content__label {
76019
+ display: inline-flex;
76020
+ }
76021
+
76022
+ /* Continuation styling for structured content blocks */
76023
+ .superdoc-structured-content-block[data-sdt-container-start="true"] {
76024
+ border-radius: 4px 4px 0 0;
76025
+ }
76026
+
76027
+ .superdoc-structured-content-block[data-sdt-container-end="true"] {
76028
+ border-radius: 0 0 4px 4px;
76029
+ }
76030
+
76031
+ .superdoc-structured-content-block[data-sdt-container-start="true"][data-sdt-container-end="true"] {
76032
+ border-radius: 4px;
76033
+ }
76034
+
76035
+ .superdoc-structured-content-block:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
76036
+ border-radius: 0;
76037
+ border-top: none;
76038
+ }
76039
+
76040
+ /* Structured Content Inline - Inline wrapper with blue border */
76041
+ .superdoc-structured-content-inline {
76042
+ padding: 1px;
76043
+ box-sizing: border-box;
76044
+ border-radius: 4px;
76045
+ border: 1px solid #629be7;
76046
+ position: relative;
76047
+ display: inline;
76048
+ }
76049
+
76050
+ /* Hover effect for inline structured content */
76051
+ .superdoc-structured-content-inline:hover {
76052
+ background-color: rgba(98, 155, 231, 0.15);
76053
+ border-color: #4a8ad9;
76054
+ }
76055
+
76056
+ /* Inline structured content label - shown on hover */
76057
+ .superdoc-structured-content-inline__label {
76058
+ position: absolute;
76059
+ bottom: calc(100% + 2px);
76060
+ left: 50%;
76061
+ transform: translateX(-50%);
76062
+ font-size: 10px;
76063
+ padding: 2px 6px;
76064
+ background-color: #629be7dd;
76065
+ color: white;
76066
+ border-radius: 4px;
76067
+ white-space: nowrap;
76068
+ z-index: 100;
76069
+ display: none;
76070
+ pointer-events: none;
76071
+ }
76072
+
76073
+ .superdoc-structured-content-inline:hover .superdoc-structured-content-inline__label {
76074
+ display: block;
76075
+ }
76076
+
76077
+ /* Print mode: hide visual styling for SDT containers */
76078
+ @media print {
76079
+ .superdoc-document-section,
76080
+ .superdoc-structured-content-block,
76081
+ .superdoc-structured-content-inline {
76082
+ background: none;
76083
+ border: none;
76084
+ padding: 0;
76085
+ }
76086
+
76087
+ .superdoc-document-section__tooltip,
76088
+ .superdoc-structured-content__label,
76089
+ .superdoc-structured-content-inline__label {
76090
+ display: none !important;
76091
+ }
76092
+ }
76093
+ `;
76094
+ const FIELD_ANNOTATION_STYLES = `
76095
+ /* Field annotation draggable styles */
76096
+ .superdoc-layout .annotation[data-draggable="true"] {
76097
+ cursor: grab;
76098
+ user-select: none;
76099
+ -webkit-user-select: none;
76100
+ }
76101
+
76102
+ .superdoc-layout .annotation[data-draggable="true"]:hover {
76103
+ opacity: 0.9;
76104
+ }
76105
+
76106
+ .superdoc-layout .annotation[data-draggable="true"]:active {
76107
+ cursor: grabbing;
76108
+ }
76109
+
76110
+ /* Drag over indicator for drop targets */
76111
+ .superdoc-layout.drag-over {
76112
+ outline: 2px dashed #b015b3;
76113
+ outline-offset: -2px;
76114
+ }
76115
+
76116
+ /* Drop zone indicator */
76117
+ .superdoc-layout .superdoc-drop-indicator {
76118
+ position: absolute;
76119
+ width: 2px;
76120
+ background-color: #b015b3;
76121
+ pointer-events: none;
76122
+ z-index: 1000;
76123
+ }
76124
+ `;
75459
76125
  let printStylesInjected = false;
75460
76126
  let linkStylesInjected = false;
75461
76127
  let trackChangeStylesInjected = false;
76128
+ let sdtContainerStylesInjected = false;
76129
+ let fieldAnnotationStylesInjected = false;
75462
76130
  const ensurePrintStyles = (doc2) => {
75463
76131
  if (printStylesInjected || !doc2) return;
75464
76132
  const styleEl = doc2.createElement("style");
@@ -75483,6 +76151,22 @@ const ensureTrackChangeStyles = (doc2) => {
75483
76151
  doc2.head?.appendChild(styleEl);
75484
76152
  trackChangeStylesInjected = true;
75485
76153
  };
76154
+ const ensureSdtContainerStyles = (doc2) => {
76155
+ if (sdtContainerStylesInjected || !doc2) return;
76156
+ const styleEl = doc2.createElement("style");
76157
+ styleEl.setAttribute("data-superdoc-sdt-container-styles", "true");
76158
+ styleEl.textContent = SDT_CONTAINER_STYLES;
76159
+ doc2.head?.appendChild(styleEl);
76160
+ sdtContainerStylesInjected = true;
76161
+ };
76162
+ const ensureFieldAnnotationStyles = (doc2) => {
76163
+ if (fieldAnnotationStylesInjected || !doc2) return;
76164
+ const styleEl = doc2.createElement("style");
76165
+ styleEl.setAttribute("data-superdoc-field-annotation-styles", "true");
76166
+ styleEl.textContent = FIELD_ANNOTATION_STYLES;
76167
+ doc2.head?.appendChild(styleEl);
76168
+ fieldAnnotationStylesInjected = true;
76169
+ };
75486
76170
  const ALLOWED_BORDER_STYLES = /* @__PURE__ */ new Set([
75487
76171
  "none",
75488
76172
  "single",
@@ -75812,6 +76496,50 @@ const renderTableRow = (deps) => {
75812
76496
  container.appendChild(cellElement);
75813
76497
  }
75814
76498
  };
76499
+ function isStructuredContentMetadata(sdt) {
76500
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
76501
+ }
76502
+ function isDocumentSectionMetadata(sdt) {
76503
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "documentSection";
76504
+ }
76505
+ function getSdtContainerConfig(sdt) {
76506
+ if (isDocumentSectionMetadata(sdt)) {
76507
+ return {
76508
+ className: "superdoc-document-section",
76509
+ labelText: sdt.title ?? "Document section",
76510
+ labelClassName: "superdoc-document-section__tooltip",
76511
+ isStart: true,
76512
+ isEnd: true
76513
+ };
76514
+ }
76515
+ if (isStructuredContentMetadata(sdt) && sdt.scope === "block") {
76516
+ return {
76517
+ className: "superdoc-structured-content-block",
76518
+ labelText: sdt.alias ?? "Structured content",
76519
+ labelClassName: "superdoc-structured-content__label",
76520
+ isStart: true,
76521
+ isEnd: true
76522
+ };
76523
+ }
76524
+ return null;
76525
+ }
76526
+ function applySdtContainerStyling(doc2, container, sdt, containerSdt) {
76527
+ let config2 = getSdtContainerConfig(sdt);
76528
+ if (!config2 && containerSdt) {
76529
+ config2 = getSdtContainerConfig(containerSdt);
76530
+ }
76531
+ if (!config2) return;
76532
+ container.classList.add(config2.className);
76533
+ container.dataset.sdtContainerStart = String(config2.isStart);
76534
+ container.dataset.sdtContainerEnd = String(config2.isEnd);
76535
+ container.style.overflow = "visible";
76536
+ const labelEl = doc2.createElement("div");
76537
+ labelEl.className = config2.labelClassName;
76538
+ const labelText = doc2.createElement("span");
76539
+ labelText.textContent = config2.labelText;
76540
+ labelEl.appendChild(labelText);
76541
+ container.appendChild(labelEl);
76542
+ }
75815
76543
  const renderTableFragment = (deps) => {
75816
76544
  const { doc: doc2, fragment, blockLookup, context, renderLine, applyFragmentFrame, applySdtDataset, applyStyles: applyStyles2 } = deps;
75817
76545
  if (!doc2) {
@@ -75848,6 +76576,7 @@ const renderTableFragment = (deps) => {
75848
76576
  applyFragmentFrame(container, fragment);
75849
76577
  container.style.height = `${fragment.height}px`;
75850
76578
  applySdtDataset(container, block.attrs?.sdt);
76579
+ applySdtContainerStyling(doc2, container, block.attrs?.sdt);
75851
76580
  container.classList.add("superdoc-table-fragment");
75852
76581
  if (fragment.metadata?.columnBoundaries) {
75853
76582
  const columnCount = measure.columnWidths.length;
@@ -76314,6 +77043,8 @@ const _DomPainter = class _DomPainter2 {
76314
77043
  ensurePrintStyles(doc2);
76315
77044
  ensureLinkStyles(doc2);
76316
77045
  ensureTrackChangeStyles(doc2);
77046
+ ensureFieldAnnotationStyles(doc2);
77047
+ ensureSdtContainerStyles(doc2);
76317
77048
  mount2.classList.add(CLASS_NAMES.container);
76318
77049
  if (this.mount && this.mount !== mount2) {
76319
77050
  this.resetState();
@@ -76836,7 +77567,8 @@ const _DomPainter = class _DomPainter2 {
76836
77567
  fragmentEl.classList.add(CLASS_NAMES.fragment);
76837
77568
  const isTocEntry = block.attrs?.isTocEntry;
76838
77569
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
76839
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
77570
+ const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
77571
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
76840
77572
  applyStyles$2(fragmentEl, styles);
76841
77573
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
76842
77574
  if (isTocEntry) {
@@ -76856,6 +77588,7 @@ const _DomPainter = class _DomPainter2 {
76856
77588
  }
76857
77589
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
76858
77590
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
77591
+ applySdtContainerStyling(this.doc, fragmentEl, block.attrs?.sdt, block.attrs?.containerSdt);
76859
77592
  const dropCapDescriptor = block.attrs?.dropCapDescriptor;
76860
77593
  const dropCapMeasure = measure.dropCap;
76861
77594
  if (dropCapDescriptor && dropCapMeasure && !fragment.continuesFromPrev) {
@@ -77074,6 +77807,7 @@ const _DomPainter = class _DomPainter2 {
77074
77807
  fragmentEl.dataset.itemId = fragment.itemId;
77075
77808
  const paragraphMetadata = item.paragraph.attrs?.sdt;
77076
77809
  this.applySdtDataset(fragmentEl, paragraphMetadata);
77810
+ applySdtContainerStyling(this.doc, fragmentEl, paragraphMetadata, item.paragraph.attrs?.containerSdt);
77077
77811
  if (fragment.continuesFromPrev) {
77078
77812
  fragmentEl.dataset.continuesFromPrev = "true";
77079
77813
  }
@@ -77845,10 +78579,19 @@ const _DomPainter = class _DomPainter2 {
77845
78579
  isBreakRun(run2) {
77846
78580
  return run2.kind === "break";
77847
78581
  }
78582
+ /**
78583
+ * Type guard to check if a run is a field annotation run.
78584
+ */
78585
+ isFieldAnnotationRun(run2) {
78586
+ return run2.kind === "fieldAnnotation";
78587
+ }
77848
78588
  renderRun(run2, context, trackedConfig) {
77849
78589
  if (this.isImageRun(run2)) {
77850
78590
  return this.renderImageRun(run2);
77851
78591
  }
78592
+ if (this.isFieldAnnotationRun(run2)) {
78593
+ return this.renderFieldAnnotationRun(run2);
78594
+ }
77852
78595
  if (this.isLineBreakRun(run2)) {
77853
78596
  return null;
77854
78597
  }
@@ -77985,6 +78728,200 @@ const _DomPainter = class _DomPainter2 {
77985
78728
  }
77986
78729
  return img;
77987
78730
  }
78731
+ /**
78732
+ * Renders a FieldAnnotationRun as an inline "pill" element matching super-editor's visual appearance.
78733
+ *
78734
+ * Field annotations are styled inline elements that display form fields with:
78735
+ * - Outer span with border, border-radius, padding, and background color
78736
+ * - Inner span containing the displayLabel or type-specific content (image, link, etc.)
78737
+ *
78738
+ * @param run - The FieldAnnotationRun to render containing field configuration and styling
78739
+ * @returns HTMLElement (span) or null if document is not available
78740
+ *
78741
+ * @example
78742
+ * ```typescript
78743
+ * // Text variant
78744
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'text', displayLabel: 'Full Name', fieldColor: '#980043' })
78745
+ * // Returns: <span class="annotation" style="border: 2px solid #b015b3; ..."><span class="annotation-content">Full Name</span></span>
78746
+ *
78747
+ * // Image variant with imageSrc
78748
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'image', displayLabel: 'Photo', imageSrc: 'data:image/png;...' })
78749
+ * // Returns: <span class="annotation"><span class="annotation-content"><img src="..." /></span></span>
78750
+ *
78751
+ * // Link variant
78752
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'link', displayLabel: 'Website', linkUrl: 'https://example.com' })
78753
+ * // Returns: <span class="annotation"><span class="annotation-content"><a href="...">https://example.com</a></span></span>
78754
+ * ```
78755
+ */
78756
+ renderFieldAnnotationRun(run2) {
78757
+ if (!this.doc) {
78758
+ return null;
78759
+ }
78760
+ if (run2.hidden) {
78761
+ const hidden = this.doc.createElement("span");
78762
+ hidden.style.display = "none";
78763
+ if (run2.pmStart != null) hidden.dataset.pmStart = String(run2.pmStart);
78764
+ if (run2.pmEnd != null) hidden.dataset.pmEnd = String(run2.pmEnd);
78765
+ return hidden;
78766
+ }
78767
+ const defaultBorderColor = "#b015b3";
78768
+ const defaultFieldColor = "#980043";
78769
+ const annotation = this.doc.createElement("span");
78770
+ annotation.classList.add("annotation");
78771
+ annotation.setAttribute("aria-label", "Field annotation");
78772
+ const showHighlight = run2.highlighted !== false;
78773
+ if (showHighlight) {
78774
+ const borderColor = run2.borderColor || defaultBorderColor;
78775
+ annotation.style.border = `2px solid ${borderColor}`;
78776
+ annotation.style.borderRadius = "2px";
78777
+ annotation.style.padding = "1px 2px";
78778
+ annotation.style.boxSizing = "border-box";
78779
+ const fieldColor = run2.fieldColor || defaultFieldColor;
78780
+ const bgColor = fieldColor.length === 7 ? `${fieldColor}33` : fieldColor;
78781
+ if (run2.textHighlight) {
78782
+ annotation.style.backgroundColor = run2.textHighlight;
78783
+ } else {
78784
+ annotation.style.backgroundColor = bgColor;
78785
+ }
78786
+ }
78787
+ if (run2.visibility === "hidden") {
78788
+ annotation.style.visibility = "hidden";
78789
+ }
78790
+ if (run2.size) {
78791
+ if (run2.size.width) {
78792
+ annotation.style.width = `${run2.size.width}px`;
78793
+ annotation.style.display = "inline-block";
78794
+ annotation.style.overflow = "hidden";
78795
+ }
78796
+ if (run2.size.height) {
78797
+ annotation.style.height = `${run2.size.height}px`;
78798
+ }
78799
+ }
78800
+ if (run2.fontFamily) {
78801
+ annotation.style.fontFamily = run2.fontFamily;
78802
+ }
78803
+ if (run2.fontSize) {
78804
+ const fontSize2 = typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize;
78805
+ annotation.style.fontSize = fontSize2;
78806
+ }
78807
+ if (run2.textColor) {
78808
+ annotation.style.color = run2.textColor;
78809
+ }
78810
+ if (run2.bold) {
78811
+ annotation.style.fontWeight = "bold";
78812
+ }
78813
+ if (run2.italic) {
78814
+ annotation.style.fontStyle = "italic";
78815
+ }
78816
+ if (run2.underline) {
78817
+ annotation.style.textDecoration = "underline";
78818
+ }
78819
+ annotation.style.zIndex = "1";
78820
+ const content = this.doc.createElement("span");
78821
+ content.classList.add("annotation-content");
78822
+ content.style.pointerEvents = "none";
78823
+ content.setAttribute("contenteditable", "false");
78824
+ switch (run2.variant) {
78825
+ case "image":
78826
+ case "signature": {
78827
+ if (run2.imageSrc) {
78828
+ const img = this.doc.createElement("img");
78829
+ const isDataUrl = run2.imageSrc.startsWith("data:");
78830
+ if (isDataUrl) {
78831
+ if (run2.imageSrc.length <= MAX_DATA_URL_LENGTH && VALID_IMAGE_DATA_URL.test(run2.imageSrc)) {
78832
+ img.src = run2.imageSrc;
78833
+ } else {
78834
+ content.textContent = run2.displayLabel;
78835
+ break;
78836
+ }
78837
+ } else {
78838
+ const sanitized = sanitizeHref(run2.imageSrc);
78839
+ if (sanitized) {
78840
+ img.src = sanitized.href;
78841
+ } else {
78842
+ content.textContent = run2.displayLabel;
78843
+ break;
78844
+ }
78845
+ }
78846
+ img.alt = run2.displayLabel;
78847
+ img.style.height = "auto";
78848
+ img.style.maxWidth = "100%";
78849
+ img.style.pointerEvents = "none";
78850
+ img.style.verticalAlign = "middle";
78851
+ if (run2.variant === "signature") {
78852
+ img.style.maxHeight = "28px";
78853
+ }
78854
+ content.appendChild(img);
78855
+ annotation.style.display = "inline-block";
78856
+ content.style.display = "inline-block";
78857
+ } else {
78858
+ content.textContent = run2.displayLabel || (run2.variant === "signature" ? "Signature" : "");
78859
+ }
78860
+ break;
78861
+ }
78862
+ case "link": {
78863
+ if (run2.linkUrl) {
78864
+ const link = this.doc.createElement("a");
78865
+ const sanitized = sanitizeHref(run2.linkUrl);
78866
+ if (sanitized) {
78867
+ link.href = sanitized.href;
78868
+ link.target = "_blank";
78869
+ link.rel = "noopener noreferrer";
78870
+ link.textContent = run2.linkUrl;
78871
+ link.style.textDecoration = "none";
78872
+ content.style.pointerEvents = "all";
78873
+ content.appendChild(link);
78874
+ } else {
78875
+ content.textContent = run2.displayLabel;
78876
+ }
78877
+ } else {
78878
+ content.textContent = run2.displayLabel;
78879
+ }
78880
+ break;
78881
+ }
78882
+ case "html": {
78883
+ if (run2.rawHtml && typeof run2.rawHtml === "string") {
78884
+ content.textContent = run2.displayLabel;
78885
+ annotation.style.display = "inline-block";
78886
+ content.style.display = "inline-block";
78887
+ } else {
78888
+ content.textContent = run2.displayLabel;
78889
+ }
78890
+ break;
78891
+ }
78892
+ case "text":
78893
+ case "checkbox":
78894
+ default: {
78895
+ content.textContent = run2.displayLabel;
78896
+ break;
78897
+ }
78898
+ }
78899
+ annotation.appendChild(content);
78900
+ annotation.dataset.type = run2.variant;
78901
+ if (run2.fieldId) {
78902
+ annotation.dataset.fieldId = run2.fieldId;
78903
+ }
78904
+ if (run2.fieldType) {
78905
+ annotation.dataset.fieldType = run2.fieldType;
78906
+ }
78907
+ annotation.draggable = true;
78908
+ annotation.dataset.draggable = "true";
78909
+ if (run2.displayLabel) {
78910
+ annotation.dataset.displayLabel = run2.displayLabel;
78911
+ }
78912
+ if (run2.variant) {
78913
+ annotation.dataset.variant = run2.variant;
78914
+ }
78915
+ assertPmPositions(run2, "field annotation run");
78916
+ if (run2.pmStart != null) {
78917
+ annotation.dataset.pmStart = String(run2.pmStart);
78918
+ }
78919
+ if (run2.pmEnd != null) {
78920
+ annotation.dataset.pmEnd = String(run2.pmEnd);
78921
+ }
78922
+ this.applySdtDataset(annotation, run2.sdt);
78923
+ return annotation;
78924
+ }
77988
78925
  /**
77989
78926
  * Renders a single line of a paragraph block.
77990
78927
  *
@@ -78162,6 +79099,22 @@ const _DomPainter = class _DomPainter2 {
78162
79099
  if (this.isBreakRun(baseRun)) {
78163
79100
  continue;
78164
79101
  }
79102
+ if (this.isFieldAnnotationRun(baseRun)) {
79103
+ const elem = this.renderRun(baseRun, context, trackedConfig);
79104
+ if (elem) {
79105
+ if (styleId) {
79106
+ elem.setAttribute("styleid", styleId);
79107
+ }
79108
+ const runSegments2 = segmentsByRun.get(runIndex);
79109
+ const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
79110
+ const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
79111
+ elem.style.position = "absolute";
79112
+ elem.style.left = `${segX}px`;
79113
+ el.appendChild(elem);
79114
+ cumulativeX = segX + segWidth;
79115
+ }
79116
+ continue;
79117
+ }
78165
79118
  const runSegments = segmentsByRun.get(runIndex);
78166
79119
  if (!runSegments || runSegments.length === 0) {
78167
79120
  continue;
@@ -78207,7 +79160,22 @@ const _DomPainter = class _DomPainter2 {
78207
79160
  });
78208
79161
  }
78209
79162
  } else {
79163
+ let currentInlineSdtWrapper = null;
79164
+ let currentInlineSdtId = null;
79165
+ const closeCurrentWrapper = () => {
79166
+ if (currentInlineSdtWrapper) {
79167
+ el.appendChild(currentInlineSdtWrapper);
79168
+ currentInlineSdtWrapper = null;
79169
+ currentInlineSdtId = null;
79170
+ }
79171
+ };
78210
79172
  runsForLine.forEach((run2) => {
79173
+ const runSdt = run2.sdt;
79174
+ const isInlineSdt = runSdt?.type === "structuredContent" && runSdt?.scope === "inline";
79175
+ const runSdtId = isInlineSdt && runSdt?.id ? String(runSdt.id) : null;
79176
+ if (runSdtId !== currentInlineSdtId) {
79177
+ closeCurrentWrapper();
79178
+ }
78211
79179
  if (run2.kind === "tab") {
78212
79180
  const tabEl = this.doc.createElement("span");
78213
79181
  tabEl.classList.add("superdoc-tab");
@@ -78235,9 +79203,37 @@ const _DomPainter = class _DomPainter2 {
78235
79203
  if (styleId) {
78236
79204
  elem.setAttribute("styleid", styleId);
78237
79205
  }
78238
- el.appendChild(elem);
79206
+ if (isInlineSdt && runSdtId && this.doc) {
79207
+ if (!currentInlineSdtWrapper) {
79208
+ currentInlineSdtWrapper = this.doc.createElement("span");
79209
+ currentInlineSdtWrapper.className = "superdoc-structured-content-inline";
79210
+ currentInlineSdtId = runSdtId;
79211
+ this.applySdtDataset(currentInlineSdtWrapper, runSdt);
79212
+ const alias = runSdt?.alias || "Inline content";
79213
+ const labelEl = this.doc.createElement("span");
79214
+ labelEl.className = "superdoc-structured-content-inline__label";
79215
+ labelEl.textContent = alias;
79216
+ currentInlineSdtWrapper.appendChild(labelEl);
79217
+ }
79218
+ const wrapperPmStart = currentInlineSdtWrapper.dataset.pmStart;
79219
+ const wrapperPmEnd = currentInlineSdtWrapper.dataset.pmEnd;
79220
+ if (run2.pmStart != null) {
79221
+ if (!wrapperPmStart || run2.pmStart < parseInt(wrapperPmStart, 10)) {
79222
+ currentInlineSdtWrapper.dataset.pmStart = String(run2.pmStart);
79223
+ }
79224
+ }
79225
+ if (run2.pmEnd != null) {
79226
+ if (!wrapperPmEnd || run2.pmEnd > parseInt(wrapperPmEnd, 10)) {
79227
+ currentInlineSdtWrapper.dataset.pmEnd = String(run2.pmEnd);
79228
+ }
79229
+ }
79230
+ currentInlineSdtWrapper.appendChild(elem);
79231
+ } else {
79232
+ el.appendChild(elem);
79233
+ }
78239
79234
  }
78240
79235
  });
79236
+ closeCurrentWrapper();
78241
79237
  }
78242
79238
  const anchors = el.querySelectorAll("a[href]");
78243
79239
  anchors.forEach((anchor) => {
@@ -78745,7 +79741,7 @@ const deriveBlockVersion = (block) => {
78745
79741
  return block.id;
78746
79742
  };
78747
79743
  const applyRunStyles = (element, run2, _isLink = false) => {
78748
- if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
79744
+ if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
78749
79745
  return;
78750
79746
  }
78751
79747
  element.style.fontFamily = run2.fontFamily;
@@ -78905,6 +79901,10 @@ const sliceRunsForLine = (block, line) => {
78905
79901
  result.push(run2);
78906
79902
  continue;
78907
79903
  }
79904
+ if (run2.kind === "fieldAnnotation") {
79905
+ result.push(run2);
79906
+ continue;
79907
+ }
78908
79908
  if (!("text" in run2)) {
78909
79909
  continue;
78910
79910
  }
@@ -79220,6 +80220,10 @@ const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
79220
80220
  const TAB_EPSILON = 0.1;
79221
80221
  const DEFAULT_DECIMAL_SEPARATOR = ".";
79222
80222
  const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
80223
+ const FIELD_ANNOTATION_PILL_PADDING = 8;
80224
+ const FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2;
80225
+ const FIELD_ANNOTATION_VERTICAL_PADDING = 6;
80226
+ const DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16;
79223
80227
  const roundValue = (value) => value;
79224
80228
  function getCanvasContext() {
79225
80229
  if (!canvasContext) {
@@ -79299,6 +80303,9 @@ function isImageRun(run2) {
79299
80303
  function isLineBreakRun(run2) {
79300
80304
  return run2.kind === "lineBreak";
79301
80305
  }
80306
+ function isFieldAnnotationRun(run2) {
80307
+ return run2.kind === "fieldAnnotation";
80308
+ }
79302
80309
  async function measureBlock(block, constraints) {
79303
80310
  const normalized = normalizeConstraints(constraints);
79304
80311
  if (block.kind === "drawing") {
@@ -79665,6 +80672,92 @@ async function measureParagraphBlock(block, maxWidth) {
79665
80672
  lastAppliedTabAlign = null;
79666
80673
  continue;
79667
80674
  }
80675
+ if (isFieldAnnotationRun(run2)) {
80676
+ const displayText = run2.displayLabel || "";
80677
+ 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;
80678
+ const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
80679
+ const fontWeight = run2.bold ? "bold" : "normal";
80680
+ const fontStyle = run2.italic ? "italic" : "normal";
80681
+ const annotationFont = `${fontStyle} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
80682
+ ctx2.font = annotationFont;
80683
+ const textWidth = displayText ? ctx2.measureText(displayText).width : 0;
80684
+ const annotationWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
80685
+ const annotationHeight = annotationFontSize * FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER + FIELD_ANNOTATION_VERTICAL_PADDING;
80686
+ let annotationStartX;
80687
+ if (pendingTabAlignment && currentLine) {
80688
+ annotationStartX = alignPendingTabForWidth(annotationWidth);
80689
+ }
80690
+ if (!currentLine) {
80691
+ currentLine = {
80692
+ fromRun: runIndex,
80693
+ fromChar: 0,
80694
+ toRun: runIndex,
80695
+ toChar: 1,
80696
+ // Field annotations are atomic units
80697
+ width: annotationWidth,
80698
+ maxFontSize: annotationHeight,
80699
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
80700
+ segments: [
80701
+ {
80702
+ runIndex,
80703
+ fromChar: 0,
80704
+ toChar: 1,
80705
+ width: annotationWidth,
80706
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
80707
+ }
80708
+ ]
80709
+ };
80710
+ continue;
80711
+ }
80712
+ if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
80713
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
80714
+ const completedLine = {
80715
+ ...currentLine,
80716
+ ...metrics
80717
+ };
80718
+ addBarTabsToLine(completedLine);
80719
+ lines.push(completedLine);
80720
+ tabStopCursor = 0;
80721
+ pendingTabAlignment = null;
80722
+ lastAppliedTabAlign = null;
80723
+ currentLine = {
80724
+ fromRun: runIndex,
80725
+ fromChar: 0,
80726
+ toRun: runIndex,
80727
+ toChar: 1,
80728
+ width: annotationWidth,
80729
+ maxFontSize: annotationHeight,
80730
+ maxWidth: getEffectiveWidth(contentWidth),
80731
+ segments: [
80732
+ {
80733
+ runIndex,
80734
+ fromChar: 0,
80735
+ toChar: 1,
80736
+ width: annotationWidth
80737
+ }
80738
+ ]
80739
+ };
80740
+ } else {
80741
+ currentLine.toRun = runIndex;
80742
+ currentLine.toChar = 1;
80743
+ currentLine.width = roundValue(currentLine.width + annotationWidth);
80744
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, annotationHeight);
80745
+ if (!currentLine.segments) currentLine.segments = [];
80746
+ currentLine.segments.push({
80747
+ runIndex,
80748
+ fromChar: 0,
80749
+ toChar: 1,
80750
+ width: annotationWidth,
80751
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
80752
+ });
80753
+ }
80754
+ const tabAlign = lastAppliedTabAlign;
80755
+ if (tabAlign && currentLine && tabAlign.val === "end") {
80756
+ currentLine.width = roundValue(tabAlign.target);
80757
+ }
80758
+ lastAppliedTabAlign = null;
80759
+ continue;
80760
+ }
79668
80761
  if (!("text" in run2) || !("fontSize" in run2)) {
79669
80762
  continue;
79670
80763
  }
@@ -81629,6 +82722,16 @@ function isInRegisteredSurface(event) {
81629
82722
  }
81630
82723
  return false;
81631
82724
  }
82725
+ const CommentMarkName = "commentMark";
82726
+ const TrackInsertMarkName = "trackInsert";
82727
+ const TrackDeleteMarkName = "trackDelete";
82728
+ const TrackFormatMarkName = "trackFormat";
82729
+ function isValidFieldAnnotationAttributes(attrs) {
82730
+ if (!attrs || typeof attrs !== "object") return false;
82731
+ const a = attrs;
82732
+ return typeof a.fieldId === "string" && typeof a.fieldType === "string" && typeof a.displayLabel === "string" && typeof a.type === "string";
82733
+ }
82734
+ const FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation";
81632
82735
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
81633
82736
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
81634
82737
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -81654,6 +82757,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81654
82757
  __privateAdd$1(this, _layoutOptions);
81655
82758
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
81656
82759
  __privateAdd$1(this, _domPainter, null);
82760
+ __privateAdd$1(this, _dragHandlerCleanup, null);
81657
82761
  __privateAdd$1(this, _layoutError, null);
81658
82762
  __privateAdd$1(this, _layoutErrorState, "healthy");
81659
82763
  __privateAdd$1(this, _errorBanner, null);
@@ -81712,8 +82816,12 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81712
82816
  if (event.button !== 0) {
81713
82817
  return;
81714
82818
  }
82819
+ const target = event.target;
82820
+ const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
81715
82821
  if (!__privateGet$1(this, _layoutState).layout) {
81716
- event.preventDefault();
82822
+ if (!isDraggableAnnotation) {
82823
+ event.preventDefault();
82824
+ }
81717
82825
  if (document.activeElement instanceof HTMLElement) {
81718
82826
  document.activeElement.blur();
81719
82827
  }
@@ -81722,10 +82830,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81722
82830
  return;
81723
82831
  }
81724
82832
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
81725
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
81726
- if (doc22) {
82833
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
82834
+ if (doc222) {
81727
82835
  try {
81728
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
82836
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
81729
82837
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81730
82838
  } catch (error) {
81731
82839
  if (process$1$1.env.NODE_ENV === "development") {
@@ -81761,7 +82869,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81761
82869
  if (headerFooterRegion) {
81762
82870
  return;
81763
82871
  }
81764
- const hit = clickToPosition(
82872
+ const rawHit = clickToPosition(
81765
82873
  __privateGet$1(this, _layoutState).layout,
81766
82874
  __privateGet$1(this, _layoutState).blocks,
81767
82875
  __privateGet$1(this, _layoutState).measures,
@@ -81770,7 +82878,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81770
82878
  event.clientX,
81771
82879
  event.clientY
81772
82880
  );
81773
- event.preventDefault();
82881
+ const doc22 = __privateGet$1(this, _editor3).state?.doc;
82882
+ const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
82883
+ if (!isDraggableAnnotation) {
82884
+ event.preventDefault();
82885
+ }
81774
82886
  if (!hit) {
81775
82887
  if (document.activeElement instanceof HTMLElement) {
81776
82888
  document.activeElement.blur();
@@ -81778,10 +82890,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81778
82890
  const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
81779
82891
  if (editorDom2) {
81780
82892
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
81781
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
81782
- if (doc22) {
82893
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
82894
+ if (doc222) {
81783
82895
  try {
81784
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
82896
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
81785
82897
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81786
82898
  } catch (error) {
81787
82899
  if (process$1$1.env.NODE_ENV === "development") {
@@ -81802,9 +82914,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81802
82914
  hit.pos
81803
82915
  );
81804
82916
  if (fragmentHit && (fragmentHit.fragment.kind === "image" || fragmentHit.fragment.kind === "drawing")) {
81805
- const doc22 = __privateGet$1(this, _editor3).state.doc;
82917
+ const doc222 = __privateGet$1(this, _editor3).state.doc;
81806
82918
  try {
81807
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc22, hit.pos));
82919
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc222, hit.pos));
81808
82920
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81809
82921
  if (__privateGet$1(this, _lastSelectedImageBlockId) && __privateGet$1(this, _lastSelectedImageBlockId) !== fragmentHit.fragment.blockId) {
81810
82922
  this.emit("imageDeselected", { blockId: __privateGet$1(this, _lastSelectedImageBlockId) });
@@ -81895,8 +83007,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81895
83007
  }
81896
83008
  }
81897
83009
  if (!handledByDepth) {
81898
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
81899
83010
  try {
83011
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
81900
83012
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81901
83013
  } catch {
81902
83014
  }
@@ -81971,6 +83083,90 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81971
83083
  }
81972
83084
  __privateSet(this, _isDragging, false);
81973
83085
  });
83086
+ __privateAdd$1(this, _handleDragOver, (event) => {
83087
+ const activeEditor = this.getActiveEditor();
83088
+ if (!activeEditor?.isEditable) {
83089
+ return;
83090
+ }
83091
+ event.preventDefault();
83092
+ if (event.dataTransfer) {
83093
+ event.dataTransfer.dropEffect = "copy";
83094
+ }
83095
+ const dt = event.dataTransfer;
83096
+ const hasFieldAnnotation = dt?.types?.includes(FIELD_ANNOTATION_DATA_TYPE) || Boolean(dt?.getData?.(FIELD_ANNOTATION_DATA_TYPE));
83097
+ if (!hasFieldAnnotation) {
83098
+ return;
83099
+ }
83100
+ const hit = this.hitTest(event.clientX, event.clientY);
83101
+ const doc22 = activeEditor.state?.doc;
83102
+ if (!hit || !doc22) {
83103
+ return;
83104
+ }
83105
+ const pos = Math.min(Math.max(hit.pos, 1), doc22.content.size);
83106
+ const currentSelection = activeEditor.state.selection;
83107
+ const isSameCursor = currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos;
83108
+ if (isSameCursor) {
83109
+ return;
83110
+ }
83111
+ try {
83112
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc22, pos)).setMeta("addToHistory", false);
83113
+ activeEditor.view?.dispatch(tr);
83114
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
83115
+ } catch (error) {
83116
+ if (process$1$1.env.NODE_ENV === "development") {
83117
+ console.debug("[PresentationEditor] Drag position update skipped:", error);
83118
+ }
83119
+ }
83120
+ });
83121
+ __privateAdd$1(this, _handleDrop, (event) => {
83122
+ const activeEditor = this.getActiveEditor();
83123
+ if (!activeEditor?.isEditable) {
83124
+ return;
83125
+ }
83126
+ if (event.dataTransfer?.types?.includes("application/x-field-annotation")) {
83127
+ return;
83128
+ }
83129
+ event.preventDefault();
83130
+ event.stopPropagation();
83131
+ const fieldAnnotationData = event.dataTransfer?.getData(FIELD_ANNOTATION_DATA_TYPE);
83132
+ if (!fieldAnnotationData) {
83133
+ return;
83134
+ }
83135
+ const hit = this.hitTest(event.clientX, event.clientY);
83136
+ const selection = activeEditor.state?.selection;
83137
+ const fallbackPos = selection?.from ?? activeEditor.state?.doc?.content.size ?? null;
83138
+ const pos = hit?.pos ?? fallbackPos;
83139
+ if (pos == null) {
83140
+ return;
83141
+ }
83142
+ let parsedData = null;
83143
+ try {
83144
+ parsedData = JSON.parse(fieldAnnotationData);
83145
+ } catch {
83146
+ return;
83147
+ }
83148
+ const { attributes, sourceField } = parsedData ?? {};
83149
+ activeEditor.emit?.("fieldAnnotationDropped", {
83150
+ sourceField,
83151
+ editor: activeEditor,
83152
+ coordinates: hit,
83153
+ pos
83154
+ });
83155
+ if (attributes && isValidFieldAnnotationAttributes(attributes)) {
83156
+ activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
83157
+ const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
83158
+ const tr = activeEditor.state?.tr.setSelection(TextSelection$1.create(activeEditor.state.doc, posAfter));
83159
+ if (tr) {
83160
+ activeEditor.view?.dispatch(tr);
83161
+ }
83162
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
83163
+ }
83164
+ const editorDom = activeEditor.view?.dom;
83165
+ if (editorDom) {
83166
+ editorDom.focus();
83167
+ activeEditor.view?.focus();
83168
+ }
83169
+ });
81974
83170
  __privateAdd$1(this, _handleDoubleClick, (event) => {
81975
83171
  if (event.button !== 0) return;
81976
83172
  if (!__privateGet$1(this, _layoutState).layout) return;
@@ -82160,6 +83356,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82160
83356
  __privateMethod$1(this, _PresentationEditor_instances, applyZoom_fn).call(this);
82161
83357
  __privateMethod$1(this, _PresentationEditor_instances, setupEditorListeners_fn).call(this);
82162
83358
  __privateMethod$1(this, _PresentationEditor_instances, setupPointerHandlers_fn).call(this);
83359
+ __privateMethod$1(this, _PresentationEditor_instances, setupDragHandlers_fn).call(this);
82163
83360
  __privateMethod$1(this, _PresentationEditor_instances, setupInputBridge_fn).call(this);
82164
83361
  __privateMethod$1(this, _PresentationEditor_instances, syncTrackedChangesPreferences_fn).call(this);
82165
83362
  if (options.documentId) {
@@ -82871,6 +84068,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82871
84068
  * Safe to call during partial initialization.
82872
84069
  */
82873
84070
  destroy() {
84071
+ var _a2;
82874
84072
  if (__privateGet$1(this, _rafHandle) != null) {
82875
84073
  __privateMethod$1(this, _PresentationEditor_instances, safeCleanup_fn).call(this, () => {
82876
84074
  const win = __privateGet$1(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
@@ -82892,6 +84090,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82892
84090
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
82893
84091
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
82894
84092
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
84093
+ __privateGet$1(this, _viewportHost)?.removeEventListener("dragover", __privateGet$1(this, _handleDragOver));
84094
+ __privateGet$1(this, _viewportHost)?.removeEventListener("drop", __privateGet$1(this, _handleDrop));
82895
84095
  __privateGet$1(this, _visibleHost)?.removeEventListener("keydown", __privateGet$1(this, _handleKeyDown));
82896
84096
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
82897
84097
  __privateGet$1(this, _inputBridge)?.destroy();
@@ -82930,6 +84130,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82930
84130
  __privateSet(this, _session, { mode: "body" });
82931
84131
  __privateSet(this, _activeHeaderFooterEditor, null);
82932
84132
  __privateSet(this, _domPainter, null);
84133
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
84134
+ __privateSet(this, _dragHandlerCleanup, null);
82933
84135
  __privateGet$1(this, _selectionOverlay2)?.remove();
82934
84136
  __privateGet$1(this, _painterHost)?.remove();
82935
84137
  __privateGet$1(this, _hiddenHost)?.remove();
@@ -82957,6 +84159,7 @@ _hiddenHost = /* @__PURE__ */ new WeakMap();
82957
84159
  _layoutOptions = /* @__PURE__ */ new WeakMap();
82958
84160
  _layoutState = /* @__PURE__ */ new WeakMap();
82959
84161
  _domPainter = /* @__PURE__ */ new WeakMap();
84162
+ _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
82960
84163
  _layoutError = /* @__PURE__ */ new WeakMap();
82961
84164
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
82962
84165
  _errorBanner = /* @__PURE__ */ new WeakMap();
@@ -83012,6 +84215,33 @@ _scrollCleanup = /* @__PURE__ */ new WeakMap();
83012
84215
  _remoteCursorRafHandle = /* @__PURE__ */ new WeakMap();
83013
84216
  _scrollTimeout = /* @__PURE__ */ new WeakMap();
83014
84217
  _PresentationEditor_instances = /* @__PURE__ */ new WeakSet();
84218
+ collectCommentPositions_fn = function() {
84219
+ const editorState = __privateGet$1(this, _editor3)?.state;
84220
+ if (!editorState) return {};
84221
+ const doc2 = editorState.doc;
84222
+ const trackChangeMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
84223
+ const pmPositions = {};
84224
+ doc2.descendants((node, pos) => {
84225
+ const marks = node.marks || [];
84226
+ for (const mark of marks) {
84227
+ let threadId;
84228
+ if (mark.type.name === CommentMarkName) {
84229
+ threadId = mark.attrs.commentId || mark.attrs.importedId;
84230
+ } else if (trackChangeMarks.includes(mark.type.name)) {
84231
+ threadId = mark.attrs.id;
84232
+ }
84233
+ if (!threadId) continue;
84234
+ const nodeEnd = pos + node.nodeSize;
84235
+ if (!pmPositions[threadId]) {
84236
+ pmPositions[threadId] = { threadId, start: pos, end: nodeEnd };
84237
+ } else {
84238
+ pmPositions[threadId].start = Math.min(pmPositions[threadId].start, pos);
84239
+ pmPositions[threadId].end = Math.max(pmPositions[threadId].end, nodeEnd);
84240
+ }
84241
+ }
84242
+ });
84243
+ return pmPositions;
84244
+ };
83015
84245
  aggregateLayoutBounds_fn = function(rects) {
83016
84246
  if (!rects.length) return null;
83017
84247
  const top2 = Math.min(...rects.map((rect) => rect.top));
@@ -83340,8 +84570,99 @@ setupPointerHandlers_fn = function() {
83340
84570
  __privateGet$1(this, _viewportHost).addEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
83341
84571
  __privateGet$1(this, _viewportHost).addEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
83342
84572
  __privateGet$1(this, _viewportHost).addEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
84573
+ __privateGet$1(this, _viewportHost).addEventListener("dragover", __privateGet$1(this, _handleDragOver));
84574
+ __privateGet$1(this, _viewportHost).addEventListener("drop", __privateGet$1(this, _handleDrop));
83343
84575
  __privateGet$1(this, _visibleHost).addEventListener("keydown", __privateGet$1(this, _handleKeyDown));
83344
84576
  };
84577
+ setupDragHandlers_fn = function() {
84578
+ var _a2;
84579
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
84580
+ __privateSet(this, _dragHandlerCleanup, null);
84581
+ __privateSet(this, _dragHandlerCleanup, createDragHandler(__privateGet$1(this, _painterHost), {
84582
+ onDragOver: (event) => {
84583
+ if (!event.hasFieldAnnotation || event.event.clientX === 0) {
84584
+ return;
84585
+ }
84586
+ const activeEditor = this.getActiveEditor();
84587
+ if (!activeEditor?.isEditable) {
84588
+ return;
84589
+ }
84590
+ const hit = this.hitTest(event.clientX, event.clientY);
84591
+ const doc2 = activeEditor.state?.doc;
84592
+ if (!hit || !doc2) {
84593
+ return;
84594
+ }
84595
+ const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
84596
+ const currentSelection = activeEditor.state.selection;
84597
+ if (currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos) {
84598
+ return;
84599
+ }
84600
+ try {
84601
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc2, pos)).setMeta("addToHistory", false);
84602
+ activeEditor.view?.dispatch(tr);
84603
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
84604
+ } catch {
84605
+ }
84606
+ },
84607
+ onDrop: (event) => {
84608
+ event.event.preventDefault();
84609
+ event.event.stopPropagation();
84610
+ if (event.pmPosition === null) {
84611
+ return;
84612
+ }
84613
+ const activeEditor = this.getActiveEditor();
84614
+ const { state: state2, view } = activeEditor;
84615
+ if (!state2 || !view) {
84616
+ return;
84617
+ }
84618
+ const fieldId = event.data.fieldId;
84619
+ if (fieldId) {
84620
+ const targetPos = event.pmPosition;
84621
+ let sourceStart = null;
84622
+ let sourceEnd = null;
84623
+ let sourceNode = null;
84624
+ state2.doc.descendants((node, pos) => {
84625
+ if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
84626
+ sourceStart = pos;
84627
+ sourceEnd = pos + node.nodeSize;
84628
+ sourceNode = node;
84629
+ return false;
84630
+ }
84631
+ return true;
84632
+ });
84633
+ if (sourceStart === null || sourceEnd === null || !sourceNode) {
84634
+ return;
84635
+ }
84636
+ if (targetPos >= sourceStart && targetPos <= sourceEnd) {
84637
+ return;
84638
+ }
84639
+ const tr = state2.tr;
84640
+ tr.delete(sourceStart, sourceEnd);
84641
+ const mappedTarget = tr.mapping.map(targetPos);
84642
+ if (mappedTarget < 0 || mappedTarget > tr.doc.content.size) {
84643
+ return;
84644
+ }
84645
+ tr.insert(mappedTarget, sourceNode);
84646
+ tr.setMeta("uiEvent", "drop");
84647
+ view.dispatch(tr);
84648
+ return;
84649
+ }
84650
+ const attrs = event.data.attributes;
84651
+ if (attrs && isValidFieldAnnotationAttributes(attrs)) {
84652
+ const inserted = activeEditor.commands?.addFieldAnnotation?.(event.pmPosition, attrs, true);
84653
+ if (inserted) {
84654
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
84655
+ }
84656
+ return;
84657
+ }
84658
+ activeEditor.emit("fieldAnnotationDropped", {
84659
+ sourceField: event.data,
84660
+ editor: activeEditor,
84661
+ coordinates: { pos: event.pmPosition }
84662
+ });
84663
+ }
84664
+ }));
84665
+ };
83345
84666
  setupInputBridge_fn = function() {
83346
84667
  __privateGet$1(this, _inputBridge)?.destroy();
83347
84668
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
@@ -83559,6 +84880,8 @@ isWordCharacter_fn = function(char) {
83559
84880
  _handlePointerMove = /* @__PURE__ */ new WeakMap();
83560
84881
  _handlePointerLeave = /* @__PURE__ */ new WeakMap();
83561
84882
  _handlePointerUp = /* @__PURE__ */ new WeakMap();
84883
+ _handleDragOver = /* @__PURE__ */ new WeakMap();
84884
+ _handleDrop = /* @__PURE__ */ new WeakMap();
83562
84885
  _handleDoubleClick = /* @__PURE__ */ new WeakMap();
83563
84886
  _handleKeyDown = /* @__PURE__ */ new WeakMap();
83564
84887
  focusHeaderFooterShortcut_fn = function(kind) {
@@ -83729,6 +85052,11 @@ rerender_fn = async function() {
83729
85052
  const payload = { layout, blocks, measures, metrics };
83730
85053
  this.emit("layoutUpdated", payload);
83731
85054
  this.emit("paginationUpdate", payload);
85055
+ const commentPositions = __privateMethod$1(this, _PresentationEditor_instances, collectCommentPositions_fn).call(this);
85056
+ const positionKeys = Object.keys(commentPositions);
85057
+ if (positionKeys.length > 0) {
85058
+ this.emit("commentPositions", { positions: commentPositions });
85059
+ }
83732
85060
  if (__privateGet$1(this, _telemetryEmitter) && metrics) {
83733
85061
  __privateGet$1(this, _telemetryEmitter).call(this, { type: "layout", data: { layout, blocks, measures, metrics } });
83734
85062
  }
@@ -89195,6 +90523,7 @@ const Paragraph = OxmlNode.create({
89195
90523
  return ["p", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
89196
90524
  },
89197
90525
  addNodeView() {
90526
+ if (this.editor.options?.mode !== "docx" || !this.editor.converter) return null;
89198
90527
  if (shouldSkipNodeView(this.editor)) return null;
89199
90528
  return ({ node, editor, getPos, decorations, extensionAttrs }) => {
89200
90529
  return new ParagraphNodeView(node, editor, getPos, decorations, extensionAttrs);
@@ -89437,7 +90766,7 @@ const CommentReference = Node$1.create({
89437
90766
  }
89438
90767
  });
89439
90768
  const CommentsMark = Mark2.create({
89440
- name: CommentMarkName,
90769
+ name: CommentMarkName$1,
89441
90770
  group: "comments",
89442
90771
  excludes: "",
89443
90772
  addOptions() {
@@ -89456,10 +90785,10 @@ const CommentsMark = Mark2.create({
89456
90785
  };
89457
90786
  },
89458
90787
  parseDOM() {
89459
- return [{ tag: CommentMarkName }];
90788
+ return [{ tag: CommentMarkName$1 }];
89460
90789
  },
89461
90790
  renderDOM({ htmlAttributes }) {
89462
- return [CommentMarkName, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
90791
+ return [CommentMarkName$1, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
89463
90792
  }
89464
90793
  });
89465
90794
  let cache$2 = /* @__PURE__ */ new WeakMap();
@@ -99643,7 +100972,7 @@ function addLinkRelationship({ editor, href }) {
99643
100972
  }
99644
100973
  const trackInsertClass = "track-insert";
99645
100974
  const TrackInsert = Mark2.create({
99646
- name: TrackInsertMarkName,
100975
+ name: TrackInsertMarkName$1,
99647
100976
  group: "track",
99648
100977
  inclusive: false,
99649
100978
  addOptions() {
@@ -99720,7 +101049,7 @@ const TrackInsert = Mark2.create({
99720
101049
  });
99721
101050
  const trackDeleteClass = "track-delete";
99722
101051
  const TrackDelete = Mark2.create({
99723
- name: TrackDeleteMarkName,
101052
+ name: TrackDeleteMarkName$1,
99724
101053
  group: "track",
99725
101054
  inclusive: false,
99726
101055
  addOptions() {
@@ -99829,7 +101158,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
99829
101158
  }, Symbol.toStringTag, { value: "Module" }));
99830
101159
  const trackFormatClass = "track-format";
99831
101160
  const TrackFormat = Mark2.create({
99832
- name: TrackFormatMarkName,
101161
+ name: TrackFormatMarkName$1,
99833
101162
  group: "track",
99834
101163
  inclusive: false,
99835
101164
  addOptions() {
@@ -100043,7 +101372,7 @@ const TrackChanges = Extension.create({
100043
101372
  tr.setMeta("inputType", "acceptReject");
100044
101373
  const map22 = new Mapping();
100045
101374
  doc2.nodesBetween(from2, to, (node, pos) => {
100046
- if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
101375
+ if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
100047
101376
  const deletionStep = new ReplaceStep(
100048
101377
  map22.map(Math.max(pos, from2)),
100049
101378
  map22.map(Math.min(pos + node.nodeSize, to)),
@@ -100051,8 +101380,8 @@ const TrackChanges = Extension.create({
100051
101380
  );
100052
101381
  tr.step(deletionStep);
100053
101382
  map22.appendMap(deletionStep.getMap());
100054
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName)) {
100055
- const insertionMark = node.marks.find((mark) => mark.type.name === TrackInsertMarkName);
101383
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1)) {
101384
+ const insertionMark = node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1);
100056
101385
  tr.step(
100057
101386
  new RemoveMarkStep(
100058
101387
  map22.map(Math.max(pos, from2)),
@@ -100060,8 +101389,8 @@ const TrackChanges = Extension.create({
100060
101389
  insertionMark
100061
101390
  )
100062
101391
  );
100063
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName)) {
100064
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
101392
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1)) {
101393
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
100065
101394
  tr.step(
100066
101395
  new RemoveMarkStep(
100067
101396
  map22.map(Math.max(pos, from2)),
@@ -100083,8 +101412,8 @@ const TrackChanges = Extension.create({
100083
101412
  tr.setMeta("inputType", "acceptReject");
100084
101413
  const map22 = new Mapping();
100085
101414
  doc2.nodesBetween(from2, to, (node, pos) => {
100086
- if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
100087
- const deletionMark = node.marks.find((mark) => mark.type.name === TrackDeleteMarkName);
101415
+ if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
101416
+ const deletionMark = node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1);
100088
101417
  tr.step(
100089
101418
  new RemoveMarkStep(
100090
101419
  map22.map(Math.max(pos, from2)),
@@ -100092,7 +101421,7 @@ const TrackChanges = Extension.create({
100092
101421
  deletionMark
100093
101422
  )
100094
101423
  );
100095
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName)) {
101424
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1)) {
100096
101425
  const deletionStep = new ReplaceStep(
100097
101426
  map22.map(Math.max(pos, from2)),
100098
101427
  map22.map(Math.min(pos + node.nodeSize, to)),
@@ -100100,8 +101429,8 @@ const TrackChanges = Extension.create({
100100
101429
  );
100101
101430
  tr.step(deletionStep);
100102
101431
  map22.appendMap(deletionStep.getMap());
100103
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName)) {
100104
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
101432
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1)) {
101433
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
100105
101434
  formatChangeMark.attrs.before.forEach((oldMark) => {
100106
101435
  tr.step(
100107
101436
  new AddMarkStep(
@@ -100277,7 +101606,7 @@ const getChangesByIdToResolve = (state2, id) => {
100277
101606
  const hasContentBetween = state2.doc.textBetween(left2.from, right2.to, "\n").length > getSegmentSize(left2) + getSegmentSize(right2);
100278
101607
  return !hasContentBetween;
100279
101608
  };
100280
- const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName && secondType === TrackInsertMarkName || firstType === TrackInsertMarkName && secondType === TrackDeleteMarkName;
101609
+ const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName$1 && secondType === TrackInsertMarkName$1 || firstType === TrackInsertMarkName$1 && secondType === TrackDeleteMarkName$1;
100281
101610
  const linkedBefore = [];
100282
101611
  const linkedAfter = [];
100283
101612
  const collectDirection = (direction, collection) => {