@harbour-enterprises/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
@@ -18263,9 +18263,9 @@ const canMergeTextNodes = (nodeA, nodeB) => {
18263
18263
  const areAttrsEqual = (attrsA = {}, attrsB = {}) => {
18264
18264
  return objectIncludes(attrsA, attrsB);
18265
18265
  };
18266
- const TrackInsertMarkName = "trackInsert";
18267
- const TrackDeleteMarkName = "trackDelete";
18268
- const TrackFormatMarkName = "trackFormat";
18266
+ const TrackInsertMarkName$1 = "trackInsert";
18267
+ const TrackDeleteMarkName$1 = "trackDelete";
18268
+ const TrackFormatMarkName$1 = "trackFormat";
18269
18269
  const generateV2HandlerEntity = (handlerName, translator2) => ({
18270
18270
  handlerName,
18271
18271
  handler: (params2) => {
@@ -20031,7 +20031,7 @@ function handleStyleChangeMarksV2(rPrChange, currentMarks, params2) {
20031
20031
  const runProperties = translator$1N.encode({ ...params2, nodes: [rPr] });
20032
20032
  submarks = encodeMarksFromRPr(runProperties, params2?.docx);
20033
20033
  }
20034
- return [{ type: TrackFormatMarkName, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20034
+ return [{ type: TrackFormatMarkName$1, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20035
20035
  }
20036
20036
  function handleStyleChangeMarks(rPr, currentMarks) {
20037
20037
  const styleChangeMark = rPr.elements?.find((el) => el.name === "w:rPrChange");
@@ -20046,7 +20046,7 @@ function handleStyleChangeMarks(rPr, currentMarks) {
20046
20046
  authorEmail: attributes["w:authorEmail"]
20047
20047
  };
20048
20048
  const submarks = parseMarks(styleChangeMark);
20049
- return [{ type: TrackFormatMarkName, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20049
+ return [{ type: TrackFormatMarkName$1, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
20050
20050
  }
20051
20051
  function createImportMarks(marks) {
20052
20052
  const textStyleMarksToCombine = marks.filter((mark) => mark.type === "textStyle");
@@ -20484,7 +20484,7 @@ const cloneRuns = (runs = []) => runs.map((run2) => cloneNode(run2));
20484
20484
  const prepareRunTrackingContext = (node = {}) => {
20485
20485
  const marks = Array.isArray(node.marks) ? node.marks : [];
20486
20486
  const trackingMarks = marks.filter(
20487
- (mark) => mark?.type === TrackInsertMarkName || mark?.type === TrackDeleteMarkName
20487
+ (mark) => mark?.type === TrackInsertMarkName$1 || mark?.type === TrackDeleteMarkName$1
20488
20488
  );
20489
20489
  if (!trackingMarks.length) {
20490
20490
  return { runNode: node, trackingMarksByType: /* @__PURE__ */ new Map() };
@@ -20493,7 +20493,7 @@ const prepareRunTrackingContext = (node = {}) => {
20493
20493
  trackingMarks.forEach((mark) => {
20494
20494
  if (mark?.type) trackingMarksByType.set(mark.type, cloneMark(mark));
20495
20495
  });
20496
- const preservedMarks = marks.filter((mark) => mark?.type !== TrackInsertMarkName && mark?.type !== TrackDeleteMarkName).map((mark) => cloneMark(mark));
20496
+ const preservedMarks = marks.filter((mark) => mark?.type !== TrackInsertMarkName$1 && mark?.type !== TrackDeleteMarkName$1).map((mark) => cloneMark(mark));
20497
20497
  const clonedContent = Array.isArray(node.content) ? node.content.map((child) => {
20498
20498
  const childClone = cloneNode(child);
20499
20499
  const childMarks = Array.isArray(childClone.marks) ? childClone.marks.slice() : [];
@@ -20532,8 +20532,8 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
20532
20532
  return runs;
20533
20533
  }
20534
20534
  if (!trackingMarksByType.size) return runs;
20535
- if (trackingMarksByType.has(TrackInsertMarkName)) {
20536
- const mark = trackingMarksByType.get(TrackInsertMarkName);
20535
+ if (trackingMarksByType.has(TrackInsertMarkName$1)) {
20536
+ const mark = trackingMarksByType.get(TrackInsertMarkName$1);
20537
20537
  const clonedRuns = cloneRuns(runs);
20538
20538
  const wrapper = {
20539
20539
  name: "w:ins",
@@ -20550,8 +20550,8 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
20550
20550
  };
20551
20551
  return [wrapper];
20552
20552
  }
20553
- if (trackingMarksByType.has(TrackDeleteMarkName)) {
20554
- const mark = trackingMarksByType.get(TrackDeleteMarkName);
20553
+ if (trackingMarksByType.has(TrackDeleteMarkName$1)) {
20554
+ const mark = trackingMarksByType.get(TrackDeleteMarkName$1);
20555
20555
  const clonedRuns = cloneRuns(runs);
20556
20556
  clonedRuns.forEach(renameTextElementsForDeletion);
20557
20557
  const wrapper = {
@@ -41841,7 +41841,7 @@ const _SuperConverter = class _SuperConverter2 {
41841
41841
  static getStoredSuperdocVersion(docx) {
41842
41842
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
41843
41843
  }
41844
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.31") {
41844
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.33") {
41845
41845
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
41846
41846
  }
41847
41847
  /**
@@ -45147,7 +45147,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45147
45147
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
45148
45148
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45149
45149
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45150
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
45150
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, 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;
45151
45151
  var GOOD_LEAF_SIZE = 200;
45152
45152
  var RopeSequence = function RopeSequence2() {
45153
45153
  };
@@ -55999,13 +55999,13 @@ const findTrackedMarkBetween = ({
55999
55999
  return markFound;
56000
56000
  };
56001
56001
  const markInsertion = ({ tr, from: from2, to, user, date }) => {
56002
- tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName]);
56003
- tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName]);
56002
+ tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName$1]);
56003
+ tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName$1]);
56004
56004
  let trackedMark = findTrackedMarkBetween({
56005
56005
  tr,
56006
56006
  from: from2,
56007
56007
  to,
56008
- markName: TrackInsertMarkName,
56008
+ markName: TrackInsertMarkName$1,
56009
56009
  attrs: { authorEmail: user.email }
56010
56010
  });
56011
56011
  let id;
@@ -56014,7 +56014,7 @@ const markInsertion = ({ tr, from: from2, to, user, date }) => {
56014
56014
  } else {
56015
56015
  id = v4();
56016
56016
  }
56017
- const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName].create({
56017
+ const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName$1].create({
56018
56018
  id,
56019
56019
  author: user.name,
56020
56020
  authorEmail: user.email,
@@ -56040,7 +56040,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56040
56040
  tr,
56041
56041
  from: from2,
56042
56042
  to,
56043
- markName: TrackDeleteMarkName,
56043
+ markName: TrackDeleteMarkName$1,
56044
56044
  attrs: { authorEmail: user.email }
56045
56045
  });
56046
56046
  let id;
@@ -56051,7 +56051,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56051
56051
  } else {
56052
56052
  id = v4();
56053
56053
  }
56054
- const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName].create({
56054
+ const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName$1].create({
56055
56055
  id,
56056
56056
  author: user.name,
56057
56057
  authorEmail: user.email,
@@ -56064,7 +56064,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56064
56064
  if (node.type.name.includes("table")) {
56065
56065
  return;
56066
56066
  }
56067
- if (node.isInline && node.marks.find((mark) => mark.type.name === TrackInsertMarkName && mark.attrs.authorEmail === user.email)) {
56067
+ if (node.isInline && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1 && mark.attrs.authorEmail === user.email)) {
56068
56068
  const removeStep = new ReplaceStep(
56069
56069
  deletionMap.map(Math.max(from2, pos)),
56070
56070
  deletionMap.map(Math.min(to, pos + node.nodeSize)),
@@ -56073,14 +56073,14 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
56073
56073
  if (!tr.maybeStep(removeStep).failed) {
56074
56074
  deletionMap.appendMap(removeStep.getMap());
56075
56075
  }
56076
- } else if (node.isInline && !node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
56076
+ } else if (node.isInline && !node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
56077
56077
  nodes.push(node);
56078
56078
  tr.addMark(
56079
56079
  deletionMap.map(Math.max(from2, pos)),
56080
56080
  deletionMap.map(Math.min(to, pos + node.nodeSize)),
56081
56081
  deletionMark
56082
56082
  );
56083
- } else if (node.attrs.track && !node.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName) && !["bulletList", "orderedList"].includes(node.type.name)) ;
56083
+ } else if (node.attrs.track && !node.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName$1) && !["bulletList", "orderedList"].includes(node.type.name)) ;
56084
56084
  });
56085
56085
  return { deletionMark, deletionMap, nodes };
56086
56086
  };
@@ -56147,7 +56147,7 @@ const getTrackChanges = (state2, id = null) => {
56147
56147
  }
56148
56148
  allInlineNodes.forEach(({ node, pos }) => {
56149
56149
  const { marks } = node;
56150
- const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
56150
+ const trackedMarks = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
56151
56151
  if (marks.length > 0) {
56152
56152
  marks.forEach((mark) => {
56153
56153
  if (trackedMarks.includes(mark.type.name)) {
@@ -56260,7 +56260,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56260
56260
  return DecorationSet.empty;
56261
56261
  }
56262
56262
  trackedChanges.forEach(({ mark, from: from2, to }) => {
56263
- if (mark.type.name === TrackInsertMarkName) {
56263
+ if (mark.type.name === TrackInsertMarkName$1) {
56264
56264
  if (onlyOriginalShown) {
56265
56265
  const decoration = Decoration.inline(from2, to, {
56266
56266
  class: "track-insert-dec hidden"
@@ -56278,7 +56278,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56278
56278
  decorations.push(decoration);
56279
56279
  }
56280
56280
  }
56281
- if (mark.type.name === TrackDeleteMarkName) {
56281
+ if (mark.type.name === TrackDeleteMarkName$1) {
56282
56282
  if (onlyOriginalShown) {
56283
56283
  const decoration = Decoration.inline(from2, to, {
56284
56284
  class: "track-delete-dec normal"
@@ -56310,7 +56310,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56310
56310
  decorations.push(decorationWidget);
56311
56311
  }
56312
56312
  }
56313
- if (mark.type.name === TrackFormatMarkName) {
56313
+ if (mark.type.name === TrackFormatMarkName$1) {
56314
56314
  if (onlyOriginalShown) {
56315
56315
  const decoration = Decoration.inline(from2, to, {
56316
56316
  class: "track-format-dec before"
@@ -56331,7 +56331,7 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
56331
56331
  });
56332
56332
  return DecorationSet.create(state2.doc, decorations);
56333
56333
  };
56334
- const CommentMarkName = "commentMark";
56334
+ const CommentMarkName$1 = "commentMark";
56335
56335
  const resolveCommentMeta = ({ converter, importedId }) => {
56336
56336
  const comments = converter?.comments || [];
56337
56337
  const matchingImportedComment = comments.find((c2) => c2.importedId == importedId);
@@ -56362,7 +56362,7 @@ const ensureFallbackComment = ({ converter, matchingImportedComment, commentId,
56362
56362
  const removeCommentsById = ({ commentId, state: state2, tr, dispatch }) => {
56363
56363
  const positions = getCommentPositionsById(commentId, state2.doc);
56364
56364
  positions.forEach(({ from: from2, to }) => {
56365
- tr.removeMark(from2, to, state2.schema.marks[CommentMarkName]);
56365
+ tr.removeMark(from2, to, state2.schema.marks[CommentMarkName$1]);
56366
56366
  });
56367
56367
  dispatch(tr);
56368
56368
  };
@@ -56370,7 +56370,7 @@ const getCommentPositionsById = (commentId, doc2) => {
56370
56370
  const positions = [];
56371
56371
  doc2.descendants((node, pos) => {
56372
56372
  const { marks } = node;
56373
- const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
56373
+ const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
56374
56374
  if (commentMark) {
56375
56375
  const { attrs } = commentMark;
56376
56376
  const { commentId: currentCommentId } = attrs;
@@ -56390,7 +56390,7 @@ const prepareCommentsForExport = (doc2, tr, schema, comments = []) => {
56390
56390
  const endNodes = [];
56391
56391
  const seen = /* @__PURE__ */ new Set();
56392
56392
  doc2.descendants((node, pos) => {
56393
- const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName) || [];
56393
+ const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName$1) || [];
56394
56394
  commentMarks.forEach((commentMark) => {
56395
56395
  const { attrs = {} } = commentMark;
56396
56396
  const { commentId } = attrs;
@@ -56518,7 +56518,7 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
56518
56518
  importedId,
56519
56519
  internal: itemToMark.internal
56520
56520
  };
56521
- tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
56521
+ tr.addMark(start2, pos + 1, schema.marks[CommentMarkName$1].create(markAttrs));
56522
56522
  toDelete.push({ start: pos, end: pos + 1 });
56523
56523
  } else if (type2.name === "commentReference") {
56524
56524
  toDelete.push({ start: pos, end: pos + 1 });
@@ -56636,7 +56636,7 @@ const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, nod
56636
56636
  existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
56637
56637
  }
56638
56638
  };
56639
- const TRACK_CHANGE_MARKS = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
56639
+ const TRACK_CHANGE_MARKS = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
56640
56640
  const CommentsPluginKey = new PluginKey("comments");
56641
56641
  const CommentsPlugin = Extension.create({
56642
56642
  name: "comments",
@@ -56652,7 +56652,7 @@ const CommentsPlugin = Extension.create({
56652
56652
  tr.addMark(
56653
56653
  $from.pos,
56654
56654
  $to.pos,
56655
- this.editor.schema.marks[CommentMarkName].create({
56655
+ this.editor.schema.marks[CommentMarkName$1].create({
56656
56656
  commentId: resolvedCommentId,
56657
56657
  internal: resolvedInternal
56658
56658
  })
@@ -56692,7 +56692,7 @@ const CommentsPlugin = Extension.create({
56692
56692
  doc2.descendants((node, pos) => {
56693
56693
  if (foundStartNode) return;
56694
56694
  const { marks = [] } = node;
56695
- const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
56695
+ const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
56696
56696
  if (commentMark) {
56697
56697
  const { attrs } = commentMark;
56698
56698
  const wid = attrs.commentId;
@@ -56706,7 +56706,7 @@ const CommentsPlugin = Extension.create({
56706
56706
  tr.addMark(
56707
56707
  foundPos,
56708
56708
  foundPos + foundStartNode.nodeSize,
56709
- this.editor.schema.marks[CommentMarkName].create({
56709
+ this.editor.schema.marks[CommentMarkName$1].create({
56710
56710
  commentId,
56711
56711
  internal: isInternal
56712
56712
  })
@@ -56835,10 +56835,10 @@ const CommentsPlugin = Extension.create({
56835
56835
  prevDoc = doc2;
56836
56836
  shouldUpdate = false;
56837
56837
  const decorations = [];
56838
- const allCommentPositions = onlyActiveThreadChanged ? prevAllCommentPositions : {};
56838
+ const allCommentPositions = {};
56839
56839
  doc2.descendants((node, pos) => {
56840
56840
  const { marks = [] } = node;
56841
- const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName);
56841
+ const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName$1);
56842
56842
  let hasActive = false;
56843
56843
  commentMarks.forEach((commentMark) => {
56844
56844
  const { attrs } = commentMark;
@@ -56964,7 +56964,7 @@ const getActiveCommentId = (doc2, selection) => {
56964
56964
  return;
56965
56965
  }
56966
56966
  const { marks = [] } = node;
56967
- const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
56967
+ const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
56968
56968
  if (commentMark) {
56969
56969
  overlaps.push({
56970
56970
  node,
@@ -56987,7 +56987,7 @@ const getActiveCommentId = (doc2, selection) => {
56987
56987
  }
56988
56988
  });
56989
56989
  const { marks: closestMarks = [] } = closestCommentRangeStart || {};
56990
- const closestCommentMark = closestMarks.find((mark) => mark.type.name === CommentMarkName);
56990
+ const closestCommentMark = closestMarks.find((mark) => mark.type.name === CommentMarkName$1);
56991
56991
  return closestCommentMark?.attrs?.commentId || closestCommentMark?.attrs?.importedId;
56992
56992
  };
56993
56993
  const findTrackedMark = ({
@@ -57037,7 +57037,7 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
57037
57037
  let nodes = step?.slice?.content?.content || [];
57038
57038
  if (!nodes.length) {
57039
57039
  newEditorState.doc.descendants((node) => {
57040
- const hasFormatMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
57040
+ const hasFormatMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
57041
57041
  if (hasFormatMark) {
57042
57042
  nodes = [node];
57043
57043
  return false;
@@ -57062,19 +57062,19 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
57062
57062
  const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion }) => {
57063
57063
  let trackedChangeText = "";
57064
57064
  let deletionText = "";
57065
- if (trackedChangeType === TrackInsertMarkName) {
57065
+ if (trackedChangeType === TrackInsertMarkName$1) {
57066
57066
  trackedChangeText = nodes.reduce((acc, node) => {
57067
57067
  if (!node.marks.find((nodeMark) => nodeMark.type.name === mark.type.name)) return acc;
57068
57068
  acc += node?.text || node?.textContent || "";
57069
57069
  return acc;
57070
57070
  }, "");
57071
57071
  }
57072
- if (trackedChangeType === TrackFormatMarkName) {
57072
+ if (trackedChangeType === TrackFormatMarkName$1) {
57073
57073
  trackedChangeText = translateFormatChangesToEnglish(mark.attrs);
57074
57074
  }
57075
- if (trackedChangeType === TrackDeleteMarkName || isDeletionInsertion) {
57075
+ if (trackedChangeType === TrackDeleteMarkName$1 || isDeletionInsertion) {
57076
57076
  deletionText = nodes.reduce((acc, node) => {
57077
- if (!node.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName)) return acc;
57077
+ if (!node.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName$1)) return acc;
57078
57078
  acc += node?.text || node?.textContent || "";
57079
57079
  return acc;
57080
57080
  }, "");
@@ -57140,7 +57140,7 @@ function findRangeById(doc2, id) {
57140
57140
  if (to === null || pos + node.nodeSize > to) to = pos + node.nodeSize;
57141
57141
  }
57142
57142
  const commentMark = node.marks.find(
57143
- (m2) => m2.type.name === CommentMarkName && (m2.attrs.commentId === id || m2.attrs.importedId === id)
57143
+ (m2) => m2.type.name === CommentMarkName$1 && (m2.attrs.commentId === id || m2.attrs.importedId === id)
57144
57144
  );
57145
57145
  if (commentMark) {
57146
57146
  if (from2 === null || pos < from2) from2 = pos;
@@ -57150,7 +57150,7 @@ function findRangeById(doc2, id) {
57150
57150
  return from2 !== null && to !== null ? { from: from2, to } : null;
57151
57151
  }
57152
57152
  const replaceStep = ({ state: state2, tr, step, newTr, map: map22, user, date, originalStep, originalStepIndex }) => {
57153
- const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName];
57153
+ const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName$1];
57154
57154
  const deletionMark = findMark(state2, deletionMarkSchema, false);
57155
57155
  const positionTo = deletionMark ? deletionMark.to : step.to;
57156
57156
  const newStep = new ReplaceStep(
@@ -57214,17 +57214,17 @@ const addMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) => {
57214
57214
  if (!node.isInline) {
57215
57215
  return;
57216
57216
  }
57217
- if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
57217
+ if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
57218
57218
  return false;
57219
57219
  }
57220
57220
  const existingChangeMark = node.marks.find(
57221
- (mark) => [TrackDeleteMarkName, TrackFormatMarkName].includes(mark.type.name)
57221
+ (mark) => [TrackDeleteMarkName$1, TrackFormatMarkName$1].includes(mark.type.name)
57222
57222
  );
57223
57223
  const wid = existingChangeMark ? existingChangeMark.attrs.id : v4();
57224
57224
  newTr.addMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
57225
57225
  const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
57226
57226
  if (allowedMarks.includes(step.mark.type.name) && !node.marks.find((mark) => mark.type === step.mark.type)) {
57227
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
57227
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
57228
57228
  let after = [];
57229
57229
  let before = [];
57230
57230
  if (formatChangeMark) {
@@ -57260,7 +57260,7 @@ const addMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) => {
57260
57260
  ];
57261
57261
  }
57262
57262
  if (after.length || before.length) {
57263
- const newFormatMark = state2.schema.marks[TrackFormatMarkName].create({
57263
+ const newFormatMark = state2.schema.marks[TrackFormatMarkName$1].create({
57264
57264
  id: wid,
57265
57265
  author: user.name,
57266
57266
  authorEmail: user.email,
@@ -57292,13 +57292,13 @@ const removeMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) =
57292
57292
  if (!node.isInline) {
57293
57293
  return true;
57294
57294
  }
57295
- if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
57295
+ if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
57296
57296
  return false;
57297
57297
  }
57298
57298
  newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
57299
57299
  const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
57300
57300
  if (allowedMarks.includes(step.mark.type.name) && node.marks.find((mark) => mark.type === step.mark.type)) {
57301
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
57301
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
57302
57302
  let after = [];
57303
57303
  let before = [];
57304
57304
  if (formatChangeMark) {
@@ -57326,7 +57326,7 @@ const removeMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) =
57326
57326
  ];
57327
57327
  }
57328
57328
  if (after.length || before.length) {
57329
- const newFormatMark = state2.schema.marks[TrackFormatMarkName].create({
57329
+ const newFormatMark = state2.schema.marks[TrackFormatMarkName$1].create({
57330
57330
  id: v4(),
57331
57331
  author: user.name,
57332
57332
  authorEmail: user.email,
@@ -57407,7 +57407,7 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
57407
57407
  newTr.setMeta("addToHistory", tr.getMeta("addToHistory"));
57408
57408
  }
57409
57409
  if (tr.selectionSet) {
57410
- const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName];
57410
+ const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName$1];
57411
57411
  const deletionMark = findMark(state2, deletionMarkSchema, false);
57412
57412
  if (tr.selection instanceof TextSelection$1 && (tr.selection.from < state2.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
57413
57413
  const caretPos = map22.map(tr.selection.from, -1);
@@ -59014,7 +59014,7 @@ const isHeadless = (editor) => {
59014
59014
  const shouldSkipNodeView = (editor) => {
59015
59015
  return isHeadless(editor);
59016
59016
  };
59017
- const summaryVersion = "1.0.0-beta.31";
59017
+ const summaryVersion = "1.0.0-beta.33";
59018
59018
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59019
59019
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59020
59020
  function mapAttributes(attrs) {
@@ -59803,7 +59803,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
59803
59803
  { default: remarkStringify },
59804
59804
  { default: remarkGfm }
59805
59805
  ] = await Promise.all([
59806
- import("./index-eG-VYUeN-CIuOnW8W.es.js"),
59806
+ import("./index-hX4H5xPH-ChjioDix.es.js"),
59807
59807
  import("./index-DRCvimau-Cw339678.es.js"),
59808
59808
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
59809
59809
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60008,7 +60008,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60008
60008
  * Process collaboration migrations
60009
60009
  */
60010
60010
  processCollaborationMigrations() {
60011
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.31");
60011
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.33");
60012
60012
  if (!this.options.ydoc) return;
60013
60013
  const metaMap = this.options.ydoc.getMap("meta");
60014
60014
  let docVersion = metaMap.get("version");
@@ -65150,7 +65150,27 @@ function handleStructuredContentBlockNode(node, context) {
65150
65150
  blocks.push(block);
65151
65151
  recordBlockKind(block.kind);
65152
65152
  });
65153
- } else if (child.type === "table") ;
65153
+ } else if (child.type === "table") {
65154
+ const tableNodeToBlock2 = converters?.tableNodeToBlock;
65155
+ if (tableNodeToBlock2) {
65156
+ const tableBlock = tableNodeToBlock2(
65157
+ child,
65158
+ nextBlockId,
65159
+ positions,
65160
+ defaultFont,
65161
+ defaultSize,
65162
+ styleContext,
65163
+ trackedChangesConfig,
65164
+ bookmarks,
65165
+ hyperlinkConfig
65166
+ );
65167
+ if (tableBlock) {
65168
+ applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
65169
+ blocks.push(tableBlock);
65170
+ recordBlockKind(tableBlock.kind);
65171
+ }
65172
+ }
65173
+ }
65154
65174
  });
65155
65175
  }
65156
65176
  function processParagraphChild(child, sectionMetadata, context, output, converters) {
@@ -65620,6 +65640,65 @@ function imageNodeToRun(node, positions, activeSdt) {
65620
65640
  }
65621
65641
  return run2;
65622
65642
  }
65643
+ function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
65644
+ const attrs = node.attrs ?? {};
65645
+ const rawVariant = attrs.type ?? fieldMetadata?.variant ?? "text";
65646
+ const validVariants = ["text", "image", "signature", "checkbox", "html", "link"];
65647
+ const variant = validVariants.includes(rawVariant) ? rawVariant : "text";
65648
+ const displayLabel = (typeof attrs.displayLabel === "string" ? attrs.displayLabel : void 0) || (typeof attrs.defaultDisplayLabel === "string" ? attrs.defaultDisplayLabel : void 0) || (typeof fieldMetadata?.displayLabel === "string" ? fieldMetadata.displayLabel : void 0) || (typeof fieldMetadata?.defaultDisplayLabel === "string" ? fieldMetadata.defaultDisplayLabel : void 0) || (typeof attrs.alias === "string" ? attrs.alias : void 0) || (typeof fieldMetadata?.alias === "string" ? fieldMetadata.alias : void 0) || "";
65649
+ const run2 = {
65650
+ kind: "fieldAnnotation",
65651
+ variant,
65652
+ displayLabel
65653
+ };
65654
+ const fieldId = typeof attrs.fieldId === "string" ? attrs.fieldId : fieldMetadata?.fieldId;
65655
+ if (fieldId) run2.fieldId = fieldId;
65656
+ const fieldType = typeof attrs.fieldType === "string" ? attrs.fieldType : fieldMetadata?.fieldType;
65657
+ if (fieldType) run2.fieldType = fieldType;
65658
+ const fieldColor = typeof attrs.fieldColor === "string" ? attrs.fieldColor : fieldMetadata?.fieldColor;
65659
+ if (fieldColor) run2.fieldColor = fieldColor;
65660
+ const borderColor = typeof attrs.borderColor === "string" ? attrs.borderColor : fieldMetadata?.borderColor;
65661
+ if (borderColor) run2.borderColor = borderColor;
65662
+ const highlighted = attrs.highlighted ?? fieldMetadata?.highlighted;
65663
+ if (highlighted === false) run2.highlighted = false;
65664
+ if (attrs.hidden === true || fieldMetadata?.hidden === true) run2.hidden = true;
65665
+ const visibility = attrs.visibility ?? fieldMetadata?.visibility;
65666
+ if (visibility === "hidden") run2.visibility = "hidden";
65667
+ const imageSrc = typeof attrs.imageSrc === "string" ? attrs.imageSrc : fieldMetadata?.imageSrc;
65668
+ if (imageSrc) run2.imageSrc = imageSrc;
65669
+ const linkUrl = typeof attrs.linkUrl === "string" ? attrs.linkUrl : fieldMetadata?.linkUrl;
65670
+ if (linkUrl) run2.linkUrl = linkUrl;
65671
+ const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
65672
+ if (typeof rawHtml === "string") run2.rawHtml = rawHtml;
65673
+ const size2 = attrs.size ?? fieldMetadata?.size;
65674
+ if (size2 && (typeof size2.width === "number" || typeof size2.height === "number")) {
65675
+ run2.size = {
65676
+ width: typeof size2.width === "number" ? size2.width : void 0,
65677
+ height: typeof size2.height === "number" ? size2.height : void 0
65678
+ };
65679
+ }
65680
+ const fontFamily2 = attrs.fontFamily ?? fieldMetadata?.fontFamily;
65681
+ if (typeof fontFamily2 === "string") run2.fontFamily = fontFamily2;
65682
+ const fontSize2 = attrs.fontSize ?? fieldMetadata?.fontSize;
65683
+ if (typeof fontSize2 === "string" || typeof fontSize2 === "number") run2.fontSize = fontSize2;
65684
+ const textColor = attrs.textColor ?? fieldMetadata?.textColor;
65685
+ if (typeof textColor === "string") run2.textColor = textColor;
65686
+ const textHighlight = attrs.textHighlight ?? fieldMetadata?.textHighlight;
65687
+ if (typeof textHighlight === "string") run2.textHighlight = textHighlight;
65688
+ const formatting = fieldMetadata?.formatting;
65689
+ if (attrs.bold === true || formatting?.bold === true) run2.bold = true;
65690
+ if (attrs.italic === true || formatting?.italic === true) run2.italic = true;
65691
+ if (attrs.underline === true || formatting?.underline === true) run2.underline = true;
65692
+ const pos = positions.get(node);
65693
+ if (pos) {
65694
+ run2.pmStart = pos.start;
65695
+ run2.pmEnd = pos.end;
65696
+ }
65697
+ if (fieldMetadata) {
65698
+ run2.sdt = fieldMetadata;
65699
+ }
65700
+ return run2;
65701
+ }
65623
65702
  const isTextRun$1 = (run2) => run2.kind !== "tab";
65624
65703
  const dataAttrsCompatible = (a, b2) => {
65625
65704
  const aAttrs = a.dataAttrs;
@@ -65915,28 +65994,20 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
65915
65994
  }
65916
65995
  if (node.type === "fieldAnnotation") {
65917
65996
  const fieldMetadata = resolveNodeSdtMetadata(node, "fieldAnnotation");
65997
+ let contentText;
65918
65998
  if (Array.isArray(node.content) && node.content.length > 0) {
65919
- node.content.forEach((child) => visitNode(child, inheritedMarks, fieldMetadata ?? activeSdt, activeRunStyleId));
65920
- } else {
65921
- const nodeAttrs = typeof node.attrs === "object" && node.attrs !== null ? node.attrs : {};
65922
- const label = (typeof nodeAttrs.displayLabel === "string" ? nodeAttrs.displayLabel : void 0) || (typeof nodeAttrs.defaultDisplayLabel === "string" ? nodeAttrs.defaultDisplayLabel : void 0) || (typeof nodeAttrs.alias === "string" ? nodeAttrs.alias : void 0) || "";
65923
- if (label && typeof label === "string") {
65924
- const run2 = textNodeToRun(
65925
- { type: "text", text: label },
65926
- positions,
65927
- defaultFont,
65928
- defaultSize,
65929
- inheritedMarks,
65930
- fieldMetadata ?? activeSdt,
65931
- hyperlinkConfig,
65932
- themeColors
65933
- );
65934
- const inlineStyleId = getInlineStyleId(inheritedMarks);
65935
- applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
65936
- applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
65937
- currentRuns.push(run2);
65938
- }
65999
+ const extractText = (n) => {
66000
+ if (n.type === "text" && typeof n.text === "string") return n.text;
66001
+ if (Array.isArray(n.content)) {
66002
+ return n.content.map(extractText).join("");
66003
+ }
66004
+ return "";
66005
+ };
66006
+ contentText = node.content.map(extractText).join("");
65939
66007
  }
66008
+ const nodeForRun = contentText && contentText.length > 0 ? { ...node, attrs: { ...node.attrs ?? {}, displayLabel: contentText } } : node;
66009
+ const run2 = fieldAnnotationNodeToRun(nodeForRun, positions, fieldMetadata);
66010
+ currentRuns.push(run2);
65940
66011
  return;
65941
66012
  }
65942
66013
  if (node.type === "pageReference") {
@@ -66773,9 +66844,9 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
66773
66844
  }
66774
66845
  const attrs = spacingEl.attributes;
66775
66846
  const spacing = {};
66776
- const before = parseIntSafe(attrs["w:before"]);
66777
- const after = parseIntSafe(attrs["w:after"]);
66778
- const line = parseIntSafe(attrs["w:line"]);
66847
+ const before = parseIntSafe$1(attrs["w:before"]);
66848
+ const after = parseIntSafe$1(attrs["w:after"]);
66849
+ const line = parseIntSafe$1(attrs["w:line"]);
66779
66850
  const rawLineRule = attrs["w:lineRule"];
66780
66851
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
66781
66852
  if (before != null) spacing.before = twipsToPx$1(before);
@@ -66790,11 +66861,11 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
66790
66861
  if (lineRule) spacing.lineRule = lineRule;
66791
66862
  const result = Object.keys(spacing).length > 0 ? { spacing } : void 0;
66792
66863
  return result;
66793
- } catch (err) {
66864
+ } catch {
66794
66865
  return void 0;
66795
66866
  }
66796
66867
  };
66797
- const parseIntSafe = (value) => {
66868
+ const parseIntSafe$1 = (value) => {
66798
66869
  if (value == null) return void 0;
66799
66870
  const num = typeof value === "number" ? value : parseInt(String(value), 10);
66800
66871
  return Number.isFinite(num) ? num : void 0;
@@ -67446,7 +67517,7 @@ function getMeasurementContext() {
67446
67517
  return measurementCtx;
67447
67518
  }
67448
67519
  function getRunFontString(run2) {
67449
- if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
67520
+ if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
67450
67521
  return "normal normal 16px Arial";
67451
67522
  }
67452
67523
  const style2 = run2.italic ? "italic" : "normal";
@@ -67477,6 +67548,10 @@ function sliceRunsForLine$1(block, line) {
67477
67548
  result.push(run2);
67478
67549
  continue;
67479
67550
  }
67551
+ if (run2.kind === "fieldAnnotation") {
67552
+ result.push(run2);
67553
+ continue;
67554
+ }
67480
67555
  const text = run2.text ?? "";
67481
67556
  const isFirstRun = runIndex === line.fromRun;
67482
67557
  const isLastRun = runIndex === line.toRun;
@@ -67510,7 +67585,8 @@ function measureCharacterX(block, line, charOffset) {
67510
67585
  1,
67511
67586
  runs2.reduce((sum, run2) => {
67512
67587
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
67513
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
67588
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
67589
+ return sum;
67514
67590
  return sum + (run2.text ?? "").length;
67515
67591
  }, 0)
67516
67592
  );
@@ -67531,7 +67607,7 @@ function measureCharacterX(block, line, charOffset) {
67531
67607
  currentCharOffset += runLength2;
67532
67608
  continue;
67533
67609
  }
67534
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67610
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67535
67611
  const runLength = text.length;
67536
67612
  if (currentCharOffset + runLength >= charOffset) {
67537
67613
  const offsetInRun = charOffset - currentCharOffset;
@@ -67574,7 +67650,7 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
67574
67650
  if (isTabRun$1(run2)) {
67575
67651
  return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
67576
67652
  }
67577
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
67653
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
67578
67654
  return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
67579
67655
  }
67580
67656
  const text = run2.text ?? "";
@@ -67603,7 +67679,7 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
67603
67679
  let lastPm = fallbackPmStart;
67604
67680
  for (const run2 of runs) {
67605
67681
  const isTab = isTabRun$1(run2);
67606
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67682
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67607
67683
  const runLength = isTab ? TAB_CHAR_LENGTH : text.length;
67608
67684
  const runPmStart = typeof run2.pmStart === "number" ? run2.pmStart : null;
67609
67685
  const runPmEnd = typeof run2.pmEnd === "number" ? run2.pmEnd : runPmStart != null ? runPmStart + runLength : null;
@@ -67629,7 +67705,8 @@ function findCharacterAtX(block, line, x2, pmStart) {
67629
67705
  1,
67630
67706
  runs2.reduce((sum, run2) => {
67631
67707
  if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
67632
- if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
67708
+ if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
67709
+ return sum;
67633
67710
  return sum + (run2.text ?? "").length;
67634
67711
  }, 0)
67635
67712
  );
@@ -67664,7 +67741,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
67664
67741
  currentCharOffset += TAB_CHAR_LENGTH;
67665
67742
  continue;
67666
67743
  }
67667
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
67744
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
67668
67745
  const runLength = text.length;
67669
67746
  if (runLength === 0) continue;
67670
67747
  ctx2.font = getRunFontString(run2);
@@ -67704,7 +67781,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
67704
67781
  };
67705
67782
  }
67706
67783
  const computeLetterSpacingWidth = (run2, precedingChars, runLength) => {
67707
- if (isTabRun$1(run2) || "src" in run2 || !("letterSpacing" in run2) || !run2.letterSpacing) {
67784
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "fieldAnnotation" || !("letterSpacing" in run2) || !run2.letterSpacing) {
67708
67785
  return 0;
67709
67786
  }
67710
67787
  const maxGaps = Math.max(runLength - 1, 0);
@@ -67801,6 +67878,17 @@ function clickToPositionDom(domContainer, clientX, clientY) {
67801
67878
  pmStart: fragmentEl.dataset.pmStart,
67802
67879
  pmEnd: fragmentEl.dataset.pmEnd
67803
67880
  });
67881
+ const hitChainLine = hitChain.find(
67882
+ (el) => el.classList?.contains?.(CLASS_NAMES$1.line) && el.dataset?.pmStart !== void 0 && el.dataset?.pmEnd !== void 0
67883
+ );
67884
+ if (hitChainLine) {
67885
+ log("Using hit chain line directly:", {
67886
+ pmStart: hitChainLine.dataset.pmStart,
67887
+ pmEnd: hitChainLine.dataset.pmEnd
67888
+ });
67889
+ const result2 = processLineElement(hitChainLine, viewX);
67890
+ return result2;
67891
+ }
67804
67892
  const result = processFragment(fragmentEl, viewX, viewY);
67805
67893
  return result;
67806
67894
  }
@@ -67866,7 +67954,9 @@ function processFragment(fragmentEl, viewX, viewY) {
67866
67954
  if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
67867
67955
  return null;
67868
67956
  }
67869
- const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
67957
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
67958
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
67959
+ );
67870
67960
  log(
67871
67961
  "Spans/anchors in line:",
67872
67962
  spanEls.map((el, i) => {
@@ -67925,6 +68015,77 @@ function processFragment(fragmentEl, viewX, viewY) {
67925
68015
  const pos = spanStart + charIndex;
67926
68016
  return pos;
67927
68017
  }
68018
+ function processLineElement(lineEl, viewX) {
68019
+ const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
68020
+ const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
68021
+ const lineRect = lineEl.getBoundingClientRect();
68022
+ log("processLineElement:", {
68023
+ pmStart: lineStart,
68024
+ pmEnd: lineEnd,
68025
+ rect: { top: lineRect.top, bottom: lineRect.bottom, left: lineRect.left, right: lineRect.right }
68026
+ });
68027
+ if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
68028
+ return null;
68029
+ }
68030
+ const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
68031
+ (el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
68032
+ );
68033
+ log(
68034
+ "Spans/anchors in line:",
68035
+ spanEls.map((el, i) => {
68036
+ const rect = el.getBoundingClientRect();
68037
+ return {
68038
+ index: i,
68039
+ tag: el.tagName,
68040
+ pmStart: el.dataset.pmStart,
68041
+ pmEnd: el.dataset.pmEnd,
68042
+ text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
68043
+ visibility: el.style.visibility,
68044
+ rect: { left: rect.left, right: rect.right, width: rect.width }
68045
+ };
68046
+ })
68047
+ );
68048
+ if (spanEls.length === 0) {
68049
+ return lineStart;
68050
+ }
68051
+ const firstRect = spanEls[0].getBoundingClientRect();
68052
+ if (viewX <= firstRect.left) {
68053
+ return lineStart;
68054
+ }
68055
+ const lastRect = spanEls[spanEls.length - 1].getBoundingClientRect();
68056
+ if (viewX >= lastRect.right) {
68057
+ return lineEnd;
68058
+ }
68059
+ const targetEl = findSpanAtX(spanEls, viewX);
68060
+ if (!targetEl) {
68061
+ return lineStart;
68062
+ }
68063
+ const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
68064
+ const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
68065
+ const targetRect = targetEl.getBoundingClientRect();
68066
+ log("Target element:", {
68067
+ tag: targetEl.tagName,
68068
+ pmStart: spanStart,
68069
+ pmEnd: spanEnd,
68070
+ text: targetEl.textContent?.substring(0, 30),
68071
+ visibility: targetEl.style.visibility,
68072
+ rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
68073
+ });
68074
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
68075
+ return null;
68076
+ }
68077
+ const firstChild = targetEl.firstChild;
68078
+ if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
68079
+ const elRect = targetEl.getBoundingClientRect();
68080
+ const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
68081
+ const snapPos = closerToLeft ? spanStart : spanEnd;
68082
+ return snapPos;
68083
+ }
68084
+ const textNode = firstChild;
68085
+ const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
68086
+ const pos = spanStart + charIndex;
68087
+ return pos;
68088
+ }
67928
68089
  function findLineAtY(lineEls, viewY) {
67929
68090
  if (lineEls.length === 0) {
67930
68091
  return null;
@@ -70815,7 +70976,7 @@ const hashRuns = (block) => {
70815
70976
  return `img:${srcHash}:${imgRun.width}x${imgRun.height}`;
70816
70977
  }
70817
70978
  const text = normalizeText(
70818
- "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
70979
+ "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? ""
70819
70980
  );
70820
70981
  const bold = "bold" in run2 ? run2.bold : false;
70821
70982
  const italic = "italic" in run2 ? run2.italic : false;
@@ -71527,7 +71688,7 @@ function extractBlockText(block) {
71527
71688
  let pmStart = Infinity;
71528
71689
  let pmEnd = 0;
71529
71690
  for (const run2 of block.runs) {
71530
- text += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text;
71691
+ text += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text;
71531
71692
  if (run2.pmStart !== void 0) {
71532
71693
  pmStart = Math.min(pmStart, run2.pmStart);
71533
71694
  }
@@ -71577,7 +71738,7 @@ function fontString(run2) {
71577
71738
  return `${italic}${bold}${size2}px ${family}`.trim();
71578
71739
  }
71579
71740
  function runText(run2) {
71580
- return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
71741
+ return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
71581
71742
  }
71582
71743
  function measureRunSliceWidth(run2, fromChar, toChar) {
71583
71744
  const context = getCtx();
@@ -71739,7 +71900,7 @@ const paragraphBlocksEqual = (a, b2) => {
71739
71900
  for (let i = 0; i < a.runs.length; i += 1) {
71740
71901
  const runA = a.runs[i];
71741
71902
  const runB = b2.runs[i];
71742
- if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
71903
+ if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
71743
71904
  return false;
71744
71905
  }
71745
71906
  }
@@ -71859,7 +72020,7 @@ function computeHeaderFooterContentHash(blocks) {
71859
72020
  parts.push(block.id);
71860
72021
  if (block.kind === "paragraph") {
71861
72022
  for (const run2 of block.runs) {
71862
- if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
72023
+ if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break" && run2.kind !== "fieldAnnotation") {
71863
72024
  parts.push(run2.text ?? "");
71864
72025
  }
71865
72026
  if ("bold" in run2 && run2.bold) parts.push("b");
@@ -72344,6 +72505,255 @@ var Priority = /* @__PURE__ */ ((Priority2) => {
72344
72505
  /** P3: Heavy debounce for full document layout */
72345
72506
  [Priority.P3]: 150
72346
72507
  });
72508
+ const DEFAULT_MIME_TYPE$1 = "application/x-field-annotation";
72509
+ const LEGACY_MIME_TYPE = "fieldAnnotation";
72510
+ function parseIntSafe(value) {
72511
+ if (!value) return void 0;
72512
+ const parsed = parseInt(value, 10);
72513
+ return Number.isFinite(parsed) ? parsed : void 0;
72514
+ }
72515
+ function extractFieldAnnotationData(element) {
72516
+ const dataset = element.dataset;
72517
+ const attributes = {};
72518
+ for (const key2 in dataset) {
72519
+ const value = dataset[key2];
72520
+ if (value !== void 0) {
72521
+ attributes[key2] = value;
72522
+ }
72523
+ }
72524
+ return {
72525
+ fieldId: dataset.fieldId,
72526
+ fieldType: dataset.fieldType,
72527
+ variant: dataset.variant ?? dataset.type,
72528
+ displayLabel: dataset.displayLabel,
72529
+ pmStart: parseIntSafe(dataset.pmStart),
72530
+ pmEnd: parseIntSafe(dataset.pmEnd),
72531
+ attributes
72532
+ };
72533
+ }
72534
+ class DragHandler {
72535
+ /**
72536
+ * Creates a new DragHandler instance.
72537
+ *
72538
+ * @param container - The DOM container element (typically .superdoc-layout)
72539
+ * @param config - Configuration options and callbacks
72540
+ */
72541
+ constructor(container, config2 = {}) {
72542
+ this.container = container;
72543
+ this.config = config2;
72544
+ this.mimeType = config2.mimeType ?? DEFAULT_MIME_TYPE$1;
72545
+ this.boundHandlers = {
72546
+ dragstart: this.handleDragStart.bind(this),
72547
+ dragover: this.handleDragOver.bind(this),
72548
+ drop: this.handleDrop.bind(this),
72549
+ dragend: this.handleDragEnd.bind(this),
72550
+ dragleave: this.handleDragLeave.bind(this)
72551
+ };
72552
+ this.windowDragoverHandler = this.handleWindowDragOver.bind(this);
72553
+ this.windowDropHandler = this.handleWindowDrop.bind(this);
72554
+ this.attachListeners();
72555
+ }
72556
+ /**
72557
+ * Attaches event listeners to the container and window.
72558
+ */
72559
+ attachListeners() {
72560
+ this.container.addEventListener("dragstart", this.boundHandlers.dragstart);
72561
+ this.container.addEventListener("dragover", this.boundHandlers.dragover);
72562
+ this.container.addEventListener("drop", this.boundHandlers.drop);
72563
+ this.container.addEventListener("dragend", this.boundHandlers.dragend);
72564
+ this.container.addEventListener("dragleave", this.boundHandlers.dragleave);
72565
+ window.addEventListener("dragover", this.windowDragoverHandler, false);
72566
+ window.addEventListener("drop", this.windowDropHandler, false);
72567
+ }
72568
+ /**
72569
+ * Removes event listeners from the container and window.
72570
+ */
72571
+ removeListeners() {
72572
+ this.container.removeEventListener("dragstart", this.boundHandlers.dragstart);
72573
+ this.container.removeEventListener("dragover", this.boundHandlers.dragover);
72574
+ this.container.removeEventListener("drop", this.boundHandlers.drop);
72575
+ this.container.removeEventListener("dragend", this.boundHandlers.dragend);
72576
+ this.container.removeEventListener("dragleave", this.boundHandlers.dragleave);
72577
+ window.removeEventListener("dragover", this.windowDragoverHandler, false);
72578
+ window.removeEventListener("drop", this.windowDropHandler, false);
72579
+ }
72580
+ /**
72581
+ * Handles dragover at window level to allow drops on overlay elements.
72582
+ * This ensures preventDefault is called even when dragging over selection
72583
+ * highlights or other UI elements that sit on top of the layout content.
72584
+ */
72585
+ handleWindowDragOver(event) {
72586
+ if (this.hasFieldAnnotationData(event)) {
72587
+ event.preventDefault();
72588
+ if (event.dataTransfer) {
72589
+ event.dataTransfer.dropEffect = "move";
72590
+ }
72591
+ const target = event.target;
72592
+ if (!this.container.contains(target)) {
72593
+ this.config.onDragOver?.({
72594
+ event,
72595
+ clientX: event.clientX,
72596
+ clientY: event.clientY,
72597
+ hasFieldAnnotation: true
72598
+ });
72599
+ }
72600
+ }
72601
+ }
72602
+ /**
72603
+ * Handles drop at window level to catch drops on overlay elements.
72604
+ * If the drop target is outside the container, we process it here.
72605
+ */
72606
+ handleWindowDrop(event) {
72607
+ if (this.hasFieldAnnotationData(event)) {
72608
+ const target = event.target;
72609
+ if (!this.container.contains(target)) {
72610
+ this.handleDrop(event);
72611
+ }
72612
+ }
72613
+ }
72614
+ /**
72615
+ * Handles the dragstart event.
72616
+ * Sets up dataTransfer with field annotation data and drag image.
72617
+ */
72618
+ handleDragStart(event) {
72619
+ const target = event.target;
72620
+ if (!target?.dataset?.draggable || target.dataset.draggable !== "true") {
72621
+ return;
72622
+ }
72623
+ const data = extractFieldAnnotationData(target);
72624
+ if (event.dataTransfer) {
72625
+ const jsonData = JSON.stringify({
72626
+ attributes: data.attributes,
72627
+ sourceField: data
72628
+ });
72629
+ event.dataTransfer.setData(this.mimeType, jsonData);
72630
+ event.dataTransfer.setData(LEGACY_MIME_TYPE, jsonData);
72631
+ event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
72632
+ event.dataTransfer.setDragImage(target, 0, 0);
72633
+ event.dataTransfer.effectAllowed = "move";
72634
+ }
72635
+ this.config.onDragStart?.({
72636
+ event,
72637
+ element: target,
72638
+ data
72639
+ });
72640
+ }
72641
+ /**
72642
+ * Handles the dragover event.
72643
+ * Provides visual feedback and determines if drop is allowed.
72644
+ */
72645
+ handleDragOver(event) {
72646
+ const hasFieldAnnotation = this.hasFieldAnnotationData(event);
72647
+ if (hasFieldAnnotation) {
72648
+ event.preventDefault();
72649
+ if (event.dataTransfer) {
72650
+ event.dataTransfer.dropEffect = "move";
72651
+ }
72652
+ this.container.classList.add("drag-over");
72653
+ }
72654
+ this.config.onDragOver?.({
72655
+ event,
72656
+ clientX: event.clientX,
72657
+ clientY: event.clientY,
72658
+ hasFieldAnnotation
72659
+ });
72660
+ }
72661
+ /**
72662
+ * Handles the dragleave event.
72663
+ * Removes visual feedback when drag leaves the container.
72664
+ */
72665
+ handleDragLeave(event) {
72666
+ const relatedTarget = event.relatedTarget;
72667
+ if (!relatedTarget || !this.container.contains(relatedTarget)) {
72668
+ this.container.classList.remove("drag-over");
72669
+ }
72670
+ }
72671
+ /**
72672
+ * Handles the drop event.
72673
+ * Maps drop coordinates to ProseMirror position and emits drop event.
72674
+ */
72675
+ handleDrop(event) {
72676
+ this.container.classList.remove("drag-over");
72677
+ if (!this.hasFieldAnnotationData(event)) {
72678
+ return;
72679
+ }
72680
+ event.preventDefault();
72681
+ const data = this.extractDragData(event);
72682
+ if (!data) {
72683
+ return;
72684
+ }
72685
+ const pmPosition = clickToPositionDom(this.container, event.clientX, event.clientY);
72686
+ this.config.onDrop?.({
72687
+ event,
72688
+ data,
72689
+ pmPosition,
72690
+ clientX: event.clientX,
72691
+ clientY: event.clientY
72692
+ });
72693
+ }
72694
+ /**
72695
+ * Handles the dragend event.
72696
+ * Cleans up drag state.
72697
+ */
72698
+ handleDragEnd(event) {
72699
+ this.container.classList.remove("drag-over");
72700
+ this.config.onDragEnd?.(event);
72701
+ }
72702
+ /**
72703
+ * Checks if a drag event contains field annotation data.
72704
+ */
72705
+ hasFieldAnnotationData(event) {
72706
+ if (!event.dataTransfer) {
72707
+ return false;
72708
+ }
72709
+ const types2 = event.dataTransfer.types;
72710
+ return types2.includes(this.mimeType) || types2.includes(LEGACY_MIME_TYPE);
72711
+ }
72712
+ /**
72713
+ * Extracts field annotation data from a drag event's dataTransfer.
72714
+ */
72715
+ extractDragData(event) {
72716
+ if (!event.dataTransfer) {
72717
+ return null;
72718
+ }
72719
+ let jsonData = event.dataTransfer.getData(this.mimeType);
72720
+ if (!jsonData) {
72721
+ jsonData = event.dataTransfer.getData(LEGACY_MIME_TYPE);
72722
+ }
72723
+ if (!jsonData) {
72724
+ return null;
72725
+ }
72726
+ try {
72727
+ const parsed = JSON.parse(jsonData);
72728
+ return parsed.sourceField ?? parsed.attributes ?? parsed;
72729
+ } catch {
72730
+ return null;
72731
+ }
72732
+ }
72733
+ /**
72734
+ * Updates the configuration options.
72735
+ *
72736
+ * @param config - New configuration options to merge
72737
+ */
72738
+ updateConfig(config2) {
72739
+ this.config = { ...this.config, ...config2 };
72740
+ if (config2.mimeType) {
72741
+ this.mimeType = config2.mimeType;
72742
+ }
72743
+ }
72744
+ /**
72745
+ * Destroys the drag handler and removes all event listeners.
72746
+ * Call this when the layout engine is unmounted or the container is removed.
72747
+ */
72748
+ destroy() {
72749
+ this.removeListeners();
72750
+ this.container.classList.remove("drag-over");
72751
+ }
72752
+ }
72753
+ function createDragHandler(container, config2 = {}) {
72754
+ const handler2 = new DragHandler(container, config2);
72755
+ return () => handler2.destroy();
72756
+ }
72347
72757
  const isAtomicFragment = (fragment) => {
72348
72758
  return fragment.kind === "drawing" || fragment.kind === "image";
72349
72759
  };
@@ -72395,7 +72805,7 @@ function hitTestFragment(layout, pageHit, blocks, measures, point) {
72395
72805
  });
72396
72806
  for (const fragment of fragments) {
72397
72807
  if (fragment.kind !== "para") continue;
72398
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
72808
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72399
72809
  if (blockIndex === -1) continue;
72400
72810
  const block = blocks[blockIndex];
72401
72811
  const measure = measures[blockIndex];
@@ -72422,7 +72832,7 @@ const hitTestAtomicFragment = (pageHit, blocks, measures, point) => {
72422
72832
  const withinX = point.x >= fragment.x && point.x <= fragment.x + fragment.width;
72423
72833
  const withinY = point.y >= fragment.y && point.y <= fragment.y + fragment.height;
72424
72834
  if (!withinX || !withinY) continue;
72425
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
72835
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72426
72836
  if (blockIndex === -1) continue;
72427
72837
  const block = blocks[blockIndex];
72428
72838
  const measure = measures[blockIndex];
@@ -72561,7 +72971,7 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
72561
72971
  blockId = fragment.blockId;
72562
72972
  pageIndex = pi;
72563
72973
  column = determineColumn(layout, fragment.x);
72564
- const blockIndex = blocks.findIndex((b2) => b2.id === fragment.blockId);
72974
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72565
72975
  if (blockIndex !== -1) {
72566
72976
  const measure = measures[blockIndex];
72567
72977
  if (measure && measure.kind === "paragraph") {
@@ -72711,6 +73121,44 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
72711
73121
  });
72712
73122
  return null;
72713
73123
  }
73124
+ function findBlockIndexByFragmentId(blocks, fragmentBlockId, targetPmRange) {
73125
+ const index2 = blocks.findIndex(
73126
+ (block) => block.id === fragmentBlockId && block.kind !== "pageBreak" && block.kind !== "sectionBreak"
73127
+ );
73128
+ if (index2 !== -1) {
73129
+ return index2;
73130
+ }
73131
+ const baseBlockId = fragmentBlockId.replace(/-\d+$/, "");
73132
+ if (baseBlockId === fragmentBlockId) {
73133
+ return -1;
73134
+ }
73135
+ const matchingIndices = [];
73136
+ blocks.forEach((block, idx) => {
73137
+ if (block.id === baseBlockId && block.kind === "paragraph") {
73138
+ matchingIndices.push(idx);
73139
+ }
73140
+ });
73141
+ if (matchingIndices.length === 0) {
73142
+ return -1;
73143
+ }
73144
+ if (matchingIndices.length === 1) {
73145
+ return matchingIndices[0];
73146
+ }
73147
+ if (targetPmRange) {
73148
+ for (const idx of matchingIndices) {
73149
+ const block = blocks[idx];
73150
+ if (block.kind !== "paragraph") continue;
73151
+ const hasOverlap = block.runs.some((run2) => {
73152
+ if (run2.pmStart == null || run2.pmEnd == null) return false;
73153
+ return run2.pmEnd > targetPmRange.from && run2.pmStart < targetPmRange.to;
73154
+ });
73155
+ if (hasOverlap) {
73156
+ return idx;
73157
+ }
73158
+ }
73159
+ }
73160
+ return matchingIndices[0];
73161
+ }
72714
73162
  function selectionToRects(layout, blocks, measures, from2, to) {
72715
73163
  if (from2 === to) {
72716
73164
  return [];
@@ -72719,8 +73167,10 @@ function selectionToRects(layout, blocks, measures, from2, to) {
72719
73167
  layout.pages.forEach((page, pageIndex) => {
72720
73168
  page.fragments.forEach((fragment) => {
72721
73169
  if (fragment.kind === "para") {
72722
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
72723
- if (blockIndex === -1) return;
73170
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
73171
+ if (blockIndex === -1) {
73172
+ return;
73173
+ }
72724
73174
  const block = blocks[blockIndex];
72725
73175
  const measure = measures[blockIndex];
72726
73176
  if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph") {
@@ -72756,7 +73206,7 @@ function selectionToRects(layout, blocks, measures, from2, to) {
72756
73206
  return;
72757
73207
  }
72758
73208
  if (isAtomicFragment(fragment)) {
72759
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
73209
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
72760
73210
  if (blockIndex === -1) return;
72761
73211
  const block = blocks[blockIndex];
72762
73212
  const pmRange = getAtomicPmRange(fragment, block);
@@ -72777,7 +73227,7 @@ function getFragmentAtPosition(layout, blocks, measures, pos) {
72777
73227
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
72778
73228
  const page = layout.pages[pageIndex];
72779
73229
  for (const fragment of page.fragments) {
72780
- const blockIndex = blocks.findIndex((block2) => block2.id === fragment.blockId);
73230
+ const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
72781
73231
  if (blockIndex === -1) {
72782
73232
  continue;
72783
73233
  }
@@ -72882,7 +73332,7 @@ function computeLinePmRange$1(block, line) {
72882
73332
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
72883
73333
  const run2 = block.runs[runIndex];
72884
73334
  if (!run2) continue;
72885
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
73335
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
72886
73336
  const runLength = text.length;
72887
73337
  const runPmStart = run2.pmStart ?? null;
72888
73338
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
@@ -72906,7 +73356,7 @@ function pmPosToCharOffset(block, line, pmPos) {
72906
73356
  for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
72907
73357
  const run2 = block.runs[runIndex];
72908
73358
  if (!run2) continue;
72909
- const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
73359
+ const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
72910
73360
  const runTextLength = text.length;
72911
73361
  const runPmStart = run2.pmStart ?? null;
72912
73362
  const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runTextLength : null);
@@ -75439,9 +75889,227 @@ const TRACK_CHANGE_STYLES = `
75439
75889
  border-bottom: 2px solid gold;
75440
75890
  }
75441
75891
  `;
75892
+ const SDT_CONTAINER_STYLES = `
75893
+ /* Document Section - Block-level container with gray border and hover tooltip */
75894
+ .superdoc-document-section {
75895
+ background-color: #fafafa;
75896
+ border: 1px solid #ababab;
75897
+ border-radius: 4px;
75898
+ position: relative;
75899
+ box-sizing: border-box;
75900
+ }
75901
+
75902
+ /* Document section tooltip - positioned above the fragment */
75903
+ .superdoc-document-section__tooltip {
75904
+ position: absolute;
75905
+ top: -19px;
75906
+ left: -1px;
75907
+ max-width: 100px;
75908
+ min-width: 0;
75909
+ height: 18px;
75910
+ border: 1px solid #ababab;
75911
+ border-bottom: none;
75912
+ border-radius: 6px 6px 0 0;
75913
+ padding: 0 8px;
75914
+ align-items: center;
75915
+ font-size: 10px;
75916
+ display: none;
75917
+ z-index: 100;
75918
+ background-color: #fafafa;
75919
+ pointer-events: none;
75920
+ }
75921
+
75922
+ .superdoc-document-section__tooltip span {
75923
+ max-width: 100%;
75924
+ overflow: hidden;
75925
+ white-space: nowrap;
75926
+ text-overflow: ellipsis;
75927
+ }
75928
+
75929
+ /* Show tooltip on hover - adjust border radius to connect with tooltip tab */
75930
+ .superdoc-document-section:hover {
75931
+ border-radius: 0 4px 4px 4px;
75932
+ }
75933
+
75934
+ .superdoc-document-section:hover .superdoc-document-section__tooltip {
75935
+ display: flex;
75936
+ align-items: center;
75937
+ }
75938
+
75939
+ /* Continuation styling: first fragment has top corners, last has bottom corners */
75940
+ .superdoc-document-section[data-sdt-container-start="true"] {
75941
+ border-radius: 4px 4px 0 0;
75942
+ }
75943
+
75944
+ .superdoc-document-section[data-sdt-container-end="true"] {
75945
+ border-radius: 0 0 4px 4px;
75946
+ }
75947
+
75948
+ .superdoc-document-section[data-sdt-container-start="true"][data-sdt-container-end="true"] {
75949
+ border-radius: 4px;
75950
+ }
75951
+
75952
+ .superdoc-document-section[data-sdt-container-start="true"]:hover {
75953
+ border-radius: 0 4px 0 0;
75954
+ }
75955
+
75956
+ /* Middle fragments have no border radius */
75957
+ .superdoc-document-section:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
75958
+ border-radius: 0;
75959
+ border-top: none;
75960
+ }
75961
+
75962
+ /* Structured Content Block - Blue border container */
75963
+ .superdoc-structured-content-block {
75964
+ padding: 1px;
75965
+ box-sizing: border-box;
75966
+ border-radius: 4px;
75967
+ border: 1px solid #629be7;
75968
+ position: relative;
75969
+ }
75970
+
75971
+ /* Structured content drag handle/label - positioned above */
75972
+ .superdoc-structured-content__label {
75973
+ font-size: 10px;
75974
+ align-items: center;
75975
+ justify-content: center;
75976
+ position: absolute;
75977
+ left: 2px;
75978
+ top: -19px;
75979
+ width: calc(100% - 4px);
75980
+ max-width: 110px;
75981
+ min-width: 0;
75982
+ height: 18px;
75983
+ padding: 0 4px;
75984
+ border: 1px solid #629be7;
75985
+ border-bottom: none;
75986
+ border-radius: 6px 6px 0 0;
75987
+ background-color: #629be7dd;
75988
+ box-sizing: border-box;
75989
+ z-index: 10;
75990
+ display: none;
75991
+ pointer-events: none;
75992
+ }
75993
+
75994
+ .superdoc-structured-content__label span {
75995
+ max-width: 100%;
75996
+ overflow: hidden;
75997
+ white-space: nowrap;
75998
+ text-overflow: ellipsis;
75999
+ }
76000
+
76001
+ .superdoc-structured-content-block:hover .superdoc-structured-content__label {
76002
+ display: inline-flex;
76003
+ }
76004
+
76005
+ /* Continuation styling for structured content blocks */
76006
+ .superdoc-structured-content-block[data-sdt-container-start="true"] {
76007
+ border-radius: 4px 4px 0 0;
76008
+ }
76009
+
76010
+ .superdoc-structured-content-block[data-sdt-container-end="true"] {
76011
+ border-radius: 0 0 4px 4px;
76012
+ }
76013
+
76014
+ .superdoc-structured-content-block[data-sdt-container-start="true"][data-sdt-container-end="true"] {
76015
+ border-radius: 4px;
76016
+ }
76017
+
76018
+ .superdoc-structured-content-block:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
76019
+ border-radius: 0;
76020
+ border-top: none;
76021
+ }
76022
+
76023
+ /* Structured Content Inline - Inline wrapper with blue border */
76024
+ .superdoc-structured-content-inline {
76025
+ padding: 1px;
76026
+ box-sizing: border-box;
76027
+ border-radius: 4px;
76028
+ border: 1px solid #629be7;
76029
+ position: relative;
76030
+ display: inline;
76031
+ }
76032
+
76033
+ /* Hover effect for inline structured content */
76034
+ .superdoc-structured-content-inline:hover {
76035
+ background-color: rgba(98, 155, 231, 0.15);
76036
+ border-color: #4a8ad9;
76037
+ }
76038
+
76039
+ /* Inline structured content label - shown on hover */
76040
+ .superdoc-structured-content-inline__label {
76041
+ position: absolute;
76042
+ bottom: calc(100% + 2px);
76043
+ left: 50%;
76044
+ transform: translateX(-50%);
76045
+ font-size: 10px;
76046
+ padding: 2px 6px;
76047
+ background-color: #629be7dd;
76048
+ color: white;
76049
+ border-radius: 4px;
76050
+ white-space: nowrap;
76051
+ z-index: 100;
76052
+ display: none;
76053
+ pointer-events: none;
76054
+ }
76055
+
76056
+ .superdoc-structured-content-inline:hover .superdoc-structured-content-inline__label {
76057
+ display: block;
76058
+ }
76059
+
76060
+ /* Print mode: hide visual styling for SDT containers */
76061
+ @media print {
76062
+ .superdoc-document-section,
76063
+ .superdoc-structured-content-block,
76064
+ .superdoc-structured-content-inline {
76065
+ background: none;
76066
+ border: none;
76067
+ padding: 0;
76068
+ }
76069
+
76070
+ .superdoc-document-section__tooltip,
76071
+ .superdoc-structured-content__label,
76072
+ .superdoc-structured-content-inline__label {
76073
+ display: none !important;
76074
+ }
76075
+ }
76076
+ `;
76077
+ const FIELD_ANNOTATION_STYLES = `
76078
+ /* Field annotation draggable styles */
76079
+ .superdoc-layout .annotation[data-draggable="true"] {
76080
+ cursor: grab;
76081
+ user-select: none;
76082
+ -webkit-user-select: none;
76083
+ }
76084
+
76085
+ .superdoc-layout .annotation[data-draggable="true"]:hover {
76086
+ opacity: 0.9;
76087
+ }
76088
+
76089
+ .superdoc-layout .annotation[data-draggable="true"]:active {
76090
+ cursor: grabbing;
76091
+ }
76092
+
76093
+ /* Drag over indicator for drop targets */
76094
+ .superdoc-layout.drag-over {
76095
+ outline: 2px dashed #b015b3;
76096
+ outline-offset: -2px;
76097
+ }
76098
+
76099
+ /* Drop zone indicator */
76100
+ .superdoc-layout .superdoc-drop-indicator {
76101
+ position: absolute;
76102
+ width: 2px;
76103
+ background-color: #b015b3;
76104
+ pointer-events: none;
76105
+ z-index: 1000;
76106
+ }
76107
+ `;
75442
76108
  let printStylesInjected = false;
75443
76109
  let linkStylesInjected = false;
75444
76110
  let trackChangeStylesInjected = false;
76111
+ let sdtContainerStylesInjected = false;
76112
+ let fieldAnnotationStylesInjected = false;
75445
76113
  const ensurePrintStyles = (doc2) => {
75446
76114
  if (printStylesInjected || !doc2) return;
75447
76115
  const styleEl = doc2.createElement("style");
@@ -75466,6 +76134,22 @@ const ensureTrackChangeStyles = (doc2) => {
75466
76134
  doc2.head?.appendChild(styleEl);
75467
76135
  trackChangeStylesInjected = true;
75468
76136
  };
76137
+ const ensureSdtContainerStyles = (doc2) => {
76138
+ if (sdtContainerStylesInjected || !doc2) return;
76139
+ const styleEl = doc2.createElement("style");
76140
+ styleEl.setAttribute("data-superdoc-sdt-container-styles", "true");
76141
+ styleEl.textContent = SDT_CONTAINER_STYLES;
76142
+ doc2.head?.appendChild(styleEl);
76143
+ sdtContainerStylesInjected = true;
76144
+ };
76145
+ const ensureFieldAnnotationStyles = (doc2) => {
76146
+ if (fieldAnnotationStylesInjected || !doc2) return;
76147
+ const styleEl = doc2.createElement("style");
76148
+ styleEl.setAttribute("data-superdoc-field-annotation-styles", "true");
76149
+ styleEl.textContent = FIELD_ANNOTATION_STYLES;
76150
+ doc2.head?.appendChild(styleEl);
76151
+ fieldAnnotationStylesInjected = true;
76152
+ };
75469
76153
  const ALLOWED_BORDER_STYLES = /* @__PURE__ */ new Set([
75470
76154
  "none",
75471
76155
  "single",
@@ -75795,6 +76479,50 @@ const renderTableRow = (deps) => {
75795
76479
  container.appendChild(cellElement);
75796
76480
  }
75797
76481
  };
76482
+ function isStructuredContentMetadata(sdt) {
76483
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
76484
+ }
76485
+ function isDocumentSectionMetadata(sdt) {
76486
+ return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "documentSection";
76487
+ }
76488
+ function getSdtContainerConfig(sdt) {
76489
+ if (isDocumentSectionMetadata(sdt)) {
76490
+ return {
76491
+ className: "superdoc-document-section",
76492
+ labelText: sdt.title ?? "Document section",
76493
+ labelClassName: "superdoc-document-section__tooltip",
76494
+ isStart: true,
76495
+ isEnd: true
76496
+ };
76497
+ }
76498
+ if (isStructuredContentMetadata(sdt) && sdt.scope === "block") {
76499
+ return {
76500
+ className: "superdoc-structured-content-block",
76501
+ labelText: sdt.alias ?? "Structured content",
76502
+ labelClassName: "superdoc-structured-content__label",
76503
+ isStart: true,
76504
+ isEnd: true
76505
+ };
76506
+ }
76507
+ return null;
76508
+ }
76509
+ function applySdtContainerStyling(doc2, container, sdt, containerSdt) {
76510
+ let config2 = getSdtContainerConfig(sdt);
76511
+ if (!config2 && containerSdt) {
76512
+ config2 = getSdtContainerConfig(containerSdt);
76513
+ }
76514
+ if (!config2) return;
76515
+ container.classList.add(config2.className);
76516
+ container.dataset.sdtContainerStart = String(config2.isStart);
76517
+ container.dataset.sdtContainerEnd = String(config2.isEnd);
76518
+ container.style.overflow = "visible";
76519
+ const labelEl = doc2.createElement("div");
76520
+ labelEl.className = config2.labelClassName;
76521
+ const labelText = doc2.createElement("span");
76522
+ labelText.textContent = config2.labelText;
76523
+ labelEl.appendChild(labelText);
76524
+ container.appendChild(labelEl);
76525
+ }
75798
76526
  const renderTableFragment = (deps) => {
75799
76527
  const { doc: doc2, fragment, blockLookup, context, renderLine, applyFragmentFrame, applySdtDataset, applyStyles: applyStyles2 } = deps;
75800
76528
  if (!doc2) {
@@ -75831,6 +76559,7 @@ const renderTableFragment = (deps) => {
75831
76559
  applyFragmentFrame(container, fragment);
75832
76560
  container.style.height = `${fragment.height}px`;
75833
76561
  applySdtDataset(container, block.attrs?.sdt);
76562
+ applySdtContainerStyling(doc2, container, block.attrs?.sdt);
75834
76563
  container.classList.add("superdoc-table-fragment");
75835
76564
  if (fragment.metadata?.columnBoundaries) {
75836
76565
  const columnCount = measure.columnWidths.length;
@@ -76297,6 +77026,8 @@ const _DomPainter = class _DomPainter2 {
76297
77026
  ensurePrintStyles(doc2);
76298
77027
  ensureLinkStyles(doc2);
76299
77028
  ensureTrackChangeStyles(doc2);
77029
+ ensureFieldAnnotationStyles(doc2);
77030
+ ensureSdtContainerStyles(doc2);
76300
77031
  mount2.classList.add(CLASS_NAMES.container);
76301
77032
  if (this.mount && this.mount !== mount2) {
76302
77033
  this.resetState();
@@ -76819,7 +77550,8 @@ const _DomPainter = class _DomPainter2 {
76819
77550
  fragmentEl.classList.add(CLASS_NAMES.fragment);
76820
77551
  const isTocEntry = block.attrs?.isTocEntry;
76821
77552
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
76822
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
77553
+ const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
77554
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
76823
77555
  applyStyles$2(fragmentEl, styles);
76824
77556
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
76825
77557
  if (isTocEntry) {
@@ -76839,6 +77571,7 @@ const _DomPainter = class _DomPainter2 {
76839
77571
  }
76840
77572
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
76841
77573
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
77574
+ applySdtContainerStyling(this.doc, fragmentEl, block.attrs?.sdt, block.attrs?.containerSdt);
76842
77575
  const dropCapDescriptor = block.attrs?.dropCapDescriptor;
76843
77576
  const dropCapMeasure = measure.dropCap;
76844
77577
  if (dropCapDescriptor && dropCapMeasure && !fragment.continuesFromPrev) {
@@ -77057,6 +77790,7 @@ const _DomPainter = class _DomPainter2 {
77057
77790
  fragmentEl.dataset.itemId = fragment.itemId;
77058
77791
  const paragraphMetadata = item.paragraph.attrs?.sdt;
77059
77792
  this.applySdtDataset(fragmentEl, paragraphMetadata);
77793
+ applySdtContainerStyling(this.doc, fragmentEl, paragraphMetadata, item.paragraph.attrs?.containerSdt);
77060
77794
  if (fragment.continuesFromPrev) {
77061
77795
  fragmentEl.dataset.continuesFromPrev = "true";
77062
77796
  }
@@ -77828,10 +78562,19 @@ const _DomPainter = class _DomPainter2 {
77828
78562
  isBreakRun(run2) {
77829
78563
  return run2.kind === "break";
77830
78564
  }
78565
+ /**
78566
+ * Type guard to check if a run is a field annotation run.
78567
+ */
78568
+ isFieldAnnotationRun(run2) {
78569
+ return run2.kind === "fieldAnnotation";
78570
+ }
77831
78571
  renderRun(run2, context, trackedConfig) {
77832
78572
  if (this.isImageRun(run2)) {
77833
78573
  return this.renderImageRun(run2);
77834
78574
  }
78575
+ if (this.isFieldAnnotationRun(run2)) {
78576
+ return this.renderFieldAnnotationRun(run2);
78577
+ }
77835
78578
  if (this.isLineBreakRun(run2)) {
77836
78579
  return null;
77837
78580
  }
@@ -77968,6 +78711,200 @@ const _DomPainter = class _DomPainter2 {
77968
78711
  }
77969
78712
  return img;
77970
78713
  }
78714
+ /**
78715
+ * Renders a FieldAnnotationRun as an inline "pill" element matching super-editor's visual appearance.
78716
+ *
78717
+ * Field annotations are styled inline elements that display form fields with:
78718
+ * - Outer span with border, border-radius, padding, and background color
78719
+ * - Inner span containing the displayLabel or type-specific content (image, link, etc.)
78720
+ *
78721
+ * @param run - The FieldAnnotationRun to render containing field configuration and styling
78722
+ * @returns HTMLElement (span) or null if document is not available
78723
+ *
78724
+ * @example
78725
+ * ```typescript
78726
+ * // Text variant
78727
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'text', displayLabel: 'Full Name', fieldColor: '#980043' })
78728
+ * // Returns: <span class="annotation" style="border: 2px solid #b015b3; ..."><span class="annotation-content">Full Name</span></span>
78729
+ *
78730
+ * // Image variant with imageSrc
78731
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'image', displayLabel: 'Photo', imageSrc: 'data:image/png;...' })
78732
+ * // Returns: <span class="annotation"><span class="annotation-content"><img src="..." /></span></span>
78733
+ *
78734
+ * // Link variant
78735
+ * renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'link', displayLabel: 'Website', linkUrl: 'https://example.com' })
78736
+ * // Returns: <span class="annotation"><span class="annotation-content"><a href="...">https://example.com</a></span></span>
78737
+ * ```
78738
+ */
78739
+ renderFieldAnnotationRun(run2) {
78740
+ if (!this.doc) {
78741
+ return null;
78742
+ }
78743
+ if (run2.hidden) {
78744
+ const hidden = this.doc.createElement("span");
78745
+ hidden.style.display = "none";
78746
+ if (run2.pmStart != null) hidden.dataset.pmStart = String(run2.pmStart);
78747
+ if (run2.pmEnd != null) hidden.dataset.pmEnd = String(run2.pmEnd);
78748
+ return hidden;
78749
+ }
78750
+ const defaultBorderColor = "#b015b3";
78751
+ const defaultFieldColor = "#980043";
78752
+ const annotation = this.doc.createElement("span");
78753
+ annotation.classList.add("annotation");
78754
+ annotation.setAttribute("aria-label", "Field annotation");
78755
+ const showHighlight = run2.highlighted !== false;
78756
+ if (showHighlight) {
78757
+ const borderColor = run2.borderColor || defaultBorderColor;
78758
+ annotation.style.border = `2px solid ${borderColor}`;
78759
+ annotation.style.borderRadius = "2px";
78760
+ annotation.style.padding = "1px 2px";
78761
+ annotation.style.boxSizing = "border-box";
78762
+ const fieldColor = run2.fieldColor || defaultFieldColor;
78763
+ const bgColor = fieldColor.length === 7 ? `${fieldColor}33` : fieldColor;
78764
+ if (run2.textHighlight) {
78765
+ annotation.style.backgroundColor = run2.textHighlight;
78766
+ } else {
78767
+ annotation.style.backgroundColor = bgColor;
78768
+ }
78769
+ }
78770
+ if (run2.visibility === "hidden") {
78771
+ annotation.style.visibility = "hidden";
78772
+ }
78773
+ if (run2.size) {
78774
+ if (run2.size.width) {
78775
+ annotation.style.width = `${run2.size.width}px`;
78776
+ annotation.style.display = "inline-block";
78777
+ annotation.style.overflow = "hidden";
78778
+ }
78779
+ if (run2.size.height) {
78780
+ annotation.style.height = `${run2.size.height}px`;
78781
+ }
78782
+ }
78783
+ if (run2.fontFamily) {
78784
+ annotation.style.fontFamily = run2.fontFamily;
78785
+ }
78786
+ if (run2.fontSize) {
78787
+ const fontSize2 = typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize;
78788
+ annotation.style.fontSize = fontSize2;
78789
+ }
78790
+ if (run2.textColor) {
78791
+ annotation.style.color = run2.textColor;
78792
+ }
78793
+ if (run2.bold) {
78794
+ annotation.style.fontWeight = "bold";
78795
+ }
78796
+ if (run2.italic) {
78797
+ annotation.style.fontStyle = "italic";
78798
+ }
78799
+ if (run2.underline) {
78800
+ annotation.style.textDecoration = "underline";
78801
+ }
78802
+ annotation.style.zIndex = "1";
78803
+ const content = this.doc.createElement("span");
78804
+ content.classList.add("annotation-content");
78805
+ content.style.pointerEvents = "none";
78806
+ content.setAttribute("contenteditable", "false");
78807
+ switch (run2.variant) {
78808
+ case "image":
78809
+ case "signature": {
78810
+ if (run2.imageSrc) {
78811
+ const img = this.doc.createElement("img");
78812
+ const isDataUrl = run2.imageSrc.startsWith("data:");
78813
+ if (isDataUrl) {
78814
+ if (run2.imageSrc.length <= MAX_DATA_URL_LENGTH && VALID_IMAGE_DATA_URL.test(run2.imageSrc)) {
78815
+ img.src = run2.imageSrc;
78816
+ } else {
78817
+ content.textContent = run2.displayLabel;
78818
+ break;
78819
+ }
78820
+ } else {
78821
+ const sanitized = sanitizeHref(run2.imageSrc);
78822
+ if (sanitized) {
78823
+ img.src = sanitized.href;
78824
+ } else {
78825
+ content.textContent = run2.displayLabel;
78826
+ break;
78827
+ }
78828
+ }
78829
+ img.alt = run2.displayLabel;
78830
+ img.style.height = "auto";
78831
+ img.style.maxWidth = "100%";
78832
+ img.style.pointerEvents = "none";
78833
+ img.style.verticalAlign = "middle";
78834
+ if (run2.variant === "signature") {
78835
+ img.style.maxHeight = "28px";
78836
+ }
78837
+ content.appendChild(img);
78838
+ annotation.style.display = "inline-block";
78839
+ content.style.display = "inline-block";
78840
+ } else {
78841
+ content.textContent = run2.displayLabel || (run2.variant === "signature" ? "Signature" : "");
78842
+ }
78843
+ break;
78844
+ }
78845
+ case "link": {
78846
+ if (run2.linkUrl) {
78847
+ const link = this.doc.createElement("a");
78848
+ const sanitized = sanitizeHref(run2.linkUrl);
78849
+ if (sanitized) {
78850
+ link.href = sanitized.href;
78851
+ link.target = "_blank";
78852
+ link.rel = "noopener noreferrer";
78853
+ link.textContent = run2.linkUrl;
78854
+ link.style.textDecoration = "none";
78855
+ content.style.pointerEvents = "all";
78856
+ content.appendChild(link);
78857
+ } else {
78858
+ content.textContent = run2.displayLabel;
78859
+ }
78860
+ } else {
78861
+ content.textContent = run2.displayLabel;
78862
+ }
78863
+ break;
78864
+ }
78865
+ case "html": {
78866
+ if (run2.rawHtml && typeof run2.rawHtml === "string") {
78867
+ content.textContent = run2.displayLabel;
78868
+ annotation.style.display = "inline-block";
78869
+ content.style.display = "inline-block";
78870
+ } else {
78871
+ content.textContent = run2.displayLabel;
78872
+ }
78873
+ break;
78874
+ }
78875
+ case "text":
78876
+ case "checkbox":
78877
+ default: {
78878
+ content.textContent = run2.displayLabel;
78879
+ break;
78880
+ }
78881
+ }
78882
+ annotation.appendChild(content);
78883
+ annotation.dataset.type = run2.variant;
78884
+ if (run2.fieldId) {
78885
+ annotation.dataset.fieldId = run2.fieldId;
78886
+ }
78887
+ if (run2.fieldType) {
78888
+ annotation.dataset.fieldType = run2.fieldType;
78889
+ }
78890
+ annotation.draggable = true;
78891
+ annotation.dataset.draggable = "true";
78892
+ if (run2.displayLabel) {
78893
+ annotation.dataset.displayLabel = run2.displayLabel;
78894
+ }
78895
+ if (run2.variant) {
78896
+ annotation.dataset.variant = run2.variant;
78897
+ }
78898
+ assertPmPositions(run2, "field annotation run");
78899
+ if (run2.pmStart != null) {
78900
+ annotation.dataset.pmStart = String(run2.pmStart);
78901
+ }
78902
+ if (run2.pmEnd != null) {
78903
+ annotation.dataset.pmEnd = String(run2.pmEnd);
78904
+ }
78905
+ this.applySdtDataset(annotation, run2.sdt);
78906
+ return annotation;
78907
+ }
77971
78908
  /**
77972
78909
  * Renders a single line of a paragraph block.
77973
78910
  *
@@ -78145,6 +79082,22 @@ const _DomPainter = class _DomPainter2 {
78145
79082
  if (this.isBreakRun(baseRun)) {
78146
79083
  continue;
78147
79084
  }
79085
+ if (this.isFieldAnnotationRun(baseRun)) {
79086
+ const elem = this.renderRun(baseRun, context, trackedConfig);
79087
+ if (elem) {
79088
+ if (styleId) {
79089
+ elem.setAttribute("styleid", styleId);
79090
+ }
79091
+ const runSegments2 = segmentsByRun.get(runIndex);
79092
+ const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
79093
+ const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
79094
+ elem.style.position = "absolute";
79095
+ elem.style.left = `${segX}px`;
79096
+ el.appendChild(elem);
79097
+ cumulativeX = segX + segWidth;
79098
+ }
79099
+ continue;
79100
+ }
78148
79101
  const runSegments = segmentsByRun.get(runIndex);
78149
79102
  if (!runSegments || runSegments.length === 0) {
78150
79103
  continue;
@@ -78190,7 +79143,22 @@ const _DomPainter = class _DomPainter2 {
78190
79143
  });
78191
79144
  }
78192
79145
  } else {
79146
+ let currentInlineSdtWrapper = null;
79147
+ let currentInlineSdtId = null;
79148
+ const closeCurrentWrapper = () => {
79149
+ if (currentInlineSdtWrapper) {
79150
+ el.appendChild(currentInlineSdtWrapper);
79151
+ currentInlineSdtWrapper = null;
79152
+ currentInlineSdtId = null;
79153
+ }
79154
+ };
78193
79155
  runsForLine.forEach((run2) => {
79156
+ const runSdt = run2.sdt;
79157
+ const isInlineSdt = runSdt?.type === "structuredContent" && runSdt?.scope === "inline";
79158
+ const runSdtId = isInlineSdt && runSdt?.id ? String(runSdt.id) : null;
79159
+ if (runSdtId !== currentInlineSdtId) {
79160
+ closeCurrentWrapper();
79161
+ }
78194
79162
  if (run2.kind === "tab") {
78195
79163
  const tabEl = this.doc.createElement("span");
78196
79164
  tabEl.classList.add("superdoc-tab");
@@ -78218,9 +79186,37 @@ const _DomPainter = class _DomPainter2 {
78218
79186
  if (styleId) {
78219
79187
  elem.setAttribute("styleid", styleId);
78220
79188
  }
78221
- el.appendChild(elem);
79189
+ if (isInlineSdt && runSdtId && this.doc) {
79190
+ if (!currentInlineSdtWrapper) {
79191
+ currentInlineSdtWrapper = this.doc.createElement("span");
79192
+ currentInlineSdtWrapper.className = "superdoc-structured-content-inline";
79193
+ currentInlineSdtId = runSdtId;
79194
+ this.applySdtDataset(currentInlineSdtWrapper, runSdt);
79195
+ const alias = runSdt?.alias || "Inline content";
79196
+ const labelEl = this.doc.createElement("span");
79197
+ labelEl.className = "superdoc-structured-content-inline__label";
79198
+ labelEl.textContent = alias;
79199
+ currentInlineSdtWrapper.appendChild(labelEl);
79200
+ }
79201
+ const wrapperPmStart = currentInlineSdtWrapper.dataset.pmStart;
79202
+ const wrapperPmEnd = currentInlineSdtWrapper.dataset.pmEnd;
79203
+ if (run2.pmStart != null) {
79204
+ if (!wrapperPmStart || run2.pmStart < parseInt(wrapperPmStart, 10)) {
79205
+ currentInlineSdtWrapper.dataset.pmStart = String(run2.pmStart);
79206
+ }
79207
+ }
79208
+ if (run2.pmEnd != null) {
79209
+ if (!wrapperPmEnd || run2.pmEnd > parseInt(wrapperPmEnd, 10)) {
79210
+ currentInlineSdtWrapper.dataset.pmEnd = String(run2.pmEnd);
79211
+ }
79212
+ }
79213
+ currentInlineSdtWrapper.appendChild(elem);
79214
+ } else {
79215
+ el.appendChild(elem);
79216
+ }
78222
79217
  }
78223
79218
  });
79219
+ closeCurrentWrapper();
78224
79220
  }
78225
79221
  const anchors = el.querySelectorAll("a[href]");
78226
79222
  anchors.forEach((anchor) => {
@@ -78728,7 +79724,7 @@ const deriveBlockVersion = (block) => {
78728
79724
  return block.id;
78729
79725
  };
78730
79726
  const applyRunStyles = (element, run2, _isLink = false) => {
78731
- if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
79727
+ if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
78732
79728
  return;
78733
79729
  }
78734
79730
  element.style.fontFamily = run2.fontFamily;
@@ -78888,6 +79884,10 @@ const sliceRunsForLine = (block, line) => {
78888
79884
  result.push(run2);
78889
79885
  continue;
78890
79886
  }
79887
+ if (run2.kind === "fieldAnnotation") {
79888
+ result.push(run2);
79889
+ continue;
79890
+ }
78891
79891
  if (!("text" in run2)) {
78892
79892
  continue;
78893
79893
  }
@@ -79203,6 +80203,10 @@ const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
79203
80203
  const TAB_EPSILON = 0.1;
79204
80204
  const DEFAULT_DECIMAL_SEPARATOR = ".";
79205
80205
  const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
80206
+ const FIELD_ANNOTATION_PILL_PADDING = 8;
80207
+ const FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2;
80208
+ const FIELD_ANNOTATION_VERTICAL_PADDING = 6;
80209
+ const DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16;
79206
80210
  const roundValue = (value) => value;
79207
80211
  function getCanvasContext() {
79208
80212
  if (!canvasContext) {
@@ -79282,6 +80286,9 @@ function isImageRun(run2) {
79282
80286
  function isLineBreakRun(run2) {
79283
80287
  return run2.kind === "lineBreak";
79284
80288
  }
80289
+ function isFieldAnnotationRun(run2) {
80290
+ return run2.kind === "fieldAnnotation";
80291
+ }
79285
80292
  async function measureBlock(block, constraints) {
79286
80293
  const normalized = normalizeConstraints(constraints);
79287
80294
  if (block.kind === "drawing") {
@@ -79648,6 +80655,92 @@ async function measureParagraphBlock(block, maxWidth) {
79648
80655
  lastAppliedTabAlign = null;
79649
80656
  continue;
79650
80657
  }
80658
+ if (isFieldAnnotationRun(run2)) {
80659
+ const displayText = run2.displayLabel || "";
80660
+ 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;
80661
+ const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
80662
+ const fontWeight = run2.bold ? "bold" : "normal";
80663
+ const fontStyle = run2.italic ? "italic" : "normal";
80664
+ const annotationFont = `${fontStyle} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
80665
+ ctx2.font = annotationFont;
80666
+ const textWidth = displayText ? ctx2.measureText(displayText).width : 0;
80667
+ const annotationWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
80668
+ const annotationHeight = annotationFontSize * FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER + FIELD_ANNOTATION_VERTICAL_PADDING;
80669
+ let annotationStartX;
80670
+ if (pendingTabAlignment && currentLine) {
80671
+ annotationStartX = alignPendingTabForWidth(annotationWidth);
80672
+ }
80673
+ if (!currentLine) {
80674
+ currentLine = {
80675
+ fromRun: runIndex,
80676
+ fromChar: 0,
80677
+ toRun: runIndex,
80678
+ toChar: 1,
80679
+ // Field annotations are atomic units
80680
+ width: annotationWidth,
80681
+ maxFontSize: annotationHeight,
80682
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
80683
+ segments: [
80684
+ {
80685
+ runIndex,
80686
+ fromChar: 0,
80687
+ toChar: 1,
80688
+ width: annotationWidth,
80689
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
80690
+ }
80691
+ ]
80692
+ };
80693
+ continue;
80694
+ }
80695
+ if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
80696
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
80697
+ const completedLine = {
80698
+ ...currentLine,
80699
+ ...metrics
80700
+ };
80701
+ addBarTabsToLine(completedLine);
80702
+ lines.push(completedLine);
80703
+ tabStopCursor = 0;
80704
+ pendingTabAlignment = null;
80705
+ lastAppliedTabAlign = null;
80706
+ currentLine = {
80707
+ fromRun: runIndex,
80708
+ fromChar: 0,
80709
+ toRun: runIndex,
80710
+ toChar: 1,
80711
+ width: annotationWidth,
80712
+ maxFontSize: annotationHeight,
80713
+ maxWidth: getEffectiveWidth(contentWidth),
80714
+ segments: [
80715
+ {
80716
+ runIndex,
80717
+ fromChar: 0,
80718
+ toChar: 1,
80719
+ width: annotationWidth
80720
+ }
80721
+ ]
80722
+ };
80723
+ } else {
80724
+ currentLine.toRun = runIndex;
80725
+ currentLine.toChar = 1;
80726
+ currentLine.width = roundValue(currentLine.width + annotationWidth);
80727
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, annotationHeight);
80728
+ if (!currentLine.segments) currentLine.segments = [];
80729
+ currentLine.segments.push({
80730
+ runIndex,
80731
+ fromChar: 0,
80732
+ toChar: 1,
80733
+ width: annotationWidth,
80734
+ ...annotationStartX !== void 0 ? { x: annotationStartX } : {}
80735
+ });
80736
+ }
80737
+ const tabAlign = lastAppliedTabAlign;
80738
+ if (tabAlign && currentLine && tabAlign.val === "end") {
80739
+ currentLine.width = roundValue(tabAlign.target);
80740
+ }
80741
+ lastAppliedTabAlign = null;
80742
+ continue;
80743
+ }
79651
80744
  if (!("text" in run2) || !("fontSize" in run2)) {
79652
80745
  continue;
79653
80746
  }
@@ -81612,6 +82705,16 @@ function isInRegisteredSurface(event) {
81612
82705
  }
81613
82706
  return false;
81614
82707
  }
82708
+ const CommentMarkName = "commentMark";
82709
+ const TrackInsertMarkName = "trackInsert";
82710
+ const TrackDeleteMarkName = "trackDelete";
82711
+ const TrackFormatMarkName = "trackFormat";
82712
+ function isValidFieldAnnotationAttributes(attrs) {
82713
+ if (!attrs || typeof attrs !== "object") return false;
82714
+ const a = attrs;
82715
+ return typeof a.fieldId === "string" && typeof a.fieldType === "string" && typeof a.displayLabel === "string" && typeof a.type === "string";
82716
+ }
82717
+ const FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation";
81615
82718
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
81616
82719
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
81617
82720
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -81637,6 +82740,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81637
82740
  __privateAdd$1(this, _layoutOptions);
81638
82741
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
81639
82742
  __privateAdd$1(this, _domPainter, null);
82743
+ __privateAdd$1(this, _dragHandlerCleanup, null);
81640
82744
  __privateAdd$1(this, _layoutError, null);
81641
82745
  __privateAdd$1(this, _layoutErrorState, "healthy");
81642
82746
  __privateAdd$1(this, _errorBanner, null);
@@ -81695,8 +82799,12 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81695
82799
  if (event.button !== 0) {
81696
82800
  return;
81697
82801
  }
82802
+ const target = event.target;
82803
+ const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
81698
82804
  if (!__privateGet$1(this, _layoutState).layout) {
81699
- event.preventDefault();
82805
+ if (!isDraggableAnnotation) {
82806
+ event.preventDefault();
82807
+ }
81700
82808
  if (document.activeElement instanceof HTMLElement) {
81701
82809
  document.activeElement.blur();
81702
82810
  }
@@ -81705,10 +82813,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81705
82813
  return;
81706
82814
  }
81707
82815
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
81708
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
81709
- if (doc22) {
82816
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
82817
+ if (doc222) {
81710
82818
  try {
81711
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
82819
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
81712
82820
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81713
82821
  } catch (error) {
81714
82822
  if (process$1$1.env.NODE_ENV === "development") {
@@ -81744,7 +82852,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81744
82852
  if (headerFooterRegion) {
81745
82853
  return;
81746
82854
  }
81747
- const hit = clickToPosition(
82855
+ const rawHit = clickToPosition(
81748
82856
  __privateGet$1(this, _layoutState).layout,
81749
82857
  __privateGet$1(this, _layoutState).blocks,
81750
82858
  __privateGet$1(this, _layoutState).measures,
@@ -81753,7 +82861,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81753
82861
  event.clientX,
81754
82862
  event.clientY
81755
82863
  );
81756
- event.preventDefault();
82864
+ const doc22 = __privateGet$1(this, _editor3).state?.doc;
82865
+ const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
82866
+ if (!isDraggableAnnotation) {
82867
+ event.preventDefault();
82868
+ }
81757
82869
  if (!hit) {
81758
82870
  if (document.activeElement instanceof HTMLElement) {
81759
82871
  document.activeElement.blur();
@@ -81761,10 +82873,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81761
82873
  const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
81762
82874
  if (editorDom2) {
81763
82875
  const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
81764
- const doc22 = __privateGet$1(this, _editor3)?.state?.doc;
81765
- if (doc22) {
82876
+ const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
82877
+ if (doc222) {
81766
82878
  try {
81767
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc22, validPos));
82879
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
81768
82880
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81769
82881
  } catch (error) {
81770
82882
  if (process$1$1.env.NODE_ENV === "development") {
@@ -81785,9 +82897,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81785
82897
  hit.pos
81786
82898
  );
81787
82899
  if (fragmentHit && (fragmentHit.fragment.kind === "image" || fragmentHit.fragment.kind === "drawing")) {
81788
- const doc22 = __privateGet$1(this, _editor3).state.doc;
82900
+ const doc222 = __privateGet$1(this, _editor3).state.doc;
81789
82901
  try {
81790
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc22, hit.pos));
82902
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc222, hit.pos));
81791
82903
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81792
82904
  if (__privateGet$1(this, _lastSelectedImageBlockId) && __privateGet$1(this, _lastSelectedImageBlockId) !== fragmentHit.fragment.blockId) {
81793
82905
  this.emit("imageDeselected", { blockId: __privateGet$1(this, _lastSelectedImageBlockId) });
@@ -81878,8 +82990,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81878
82990
  }
81879
82991
  }
81880
82992
  if (!handledByDepth) {
81881
- const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
81882
82993
  try {
82994
+ const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
81883
82995
  __privateGet$1(this, _editor3).view?.dispatch(tr);
81884
82996
  } catch {
81885
82997
  }
@@ -81954,6 +83066,90 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
81954
83066
  }
81955
83067
  __privateSet(this, _isDragging, false);
81956
83068
  });
83069
+ __privateAdd$1(this, _handleDragOver, (event) => {
83070
+ const activeEditor = this.getActiveEditor();
83071
+ if (!activeEditor?.isEditable) {
83072
+ return;
83073
+ }
83074
+ event.preventDefault();
83075
+ if (event.dataTransfer) {
83076
+ event.dataTransfer.dropEffect = "copy";
83077
+ }
83078
+ const dt = event.dataTransfer;
83079
+ const hasFieldAnnotation = dt?.types?.includes(FIELD_ANNOTATION_DATA_TYPE) || Boolean(dt?.getData?.(FIELD_ANNOTATION_DATA_TYPE));
83080
+ if (!hasFieldAnnotation) {
83081
+ return;
83082
+ }
83083
+ const hit = this.hitTest(event.clientX, event.clientY);
83084
+ const doc22 = activeEditor.state?.doc;
83085
+ if (!hit || !doc22) {
83086
+ return;
83087
+ }
83088
+ const pos = Math.min(Math.max(hit.pos, 1), doc22.content.size);
83089
+ const currentSelection = activeEditor.state.selection;
83090
+ const isSameCursor = currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos;
83091
+ if (isSameCursor) {
83092
+ return;
83093
+ }
83094
+ try {
83095
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc22, pos)).setMeta("addToHistory", false);
83096
+ activeEditor.view?.dispatch(tr);
83097
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
83098
+ } catch (error) {
83099
+ if (process$1$1.env.NODE_ENV === "development") {
83100
+ console.debug("[PresentationEditor] Drag position update skipped:", error);
83101
+ }
83102
+ }
83103
+ });
83104
+ __privateAdd$1(this, _handleDrop, (event) => {
83105
+ const activeEditor = this.getActiveEditor();
83106
+ if (!activeEditor?.isEditable) {
83107
+ return;
83108
+ }
83109
+ if (event.dataTransfer?.types?.includes("application/x-field-annotation")) {
83110
+ return;
83111
+ }
83112
+ event.preventDefault();
83113
+ event.stopPropagation();
83114
+ const fieldAnnotationData = event.dataTransfer?.getData(FIELD_ANNOTATION_DATA_TYPE);
83115
+ if (!fieldAnnotationData) {
83116
+ return;
83117
+ }
83118
+ const hit = this.hitTest(event.clientX, event.clientY);
83119
+ const selection = activeEditor.state?.selection;
83120
+ const fallbackPos = selection?.from ?? activeEditor.state?.doc?.content.size ?? null;
83121
+ const pos = hit?.pos ?? fallbackPos;
83122
+ if (pos == null) {
83123
+ return;
83124
+ }
83125
+ let parsedData = null;
83126
+ try {
83127
+ parsedData = JSON.parse(fieldAnnotationData);
83128
+ } catch {
83129
+ return;
83130
+ }
83131
+ const { attributes, sourceField } = parsedData ?? {};
83132
+ activeEditor.emit?.("fieldAnnotationDropped", {
83133
+ sourceField,
83134
+ editor: activeEditor,
83135
+ coordinates: hit,
83136
+ pos
83137
+ });
83138
+ if (attributes && isValidFieldAnnotationAttributes(attributes)) {
83139
+ activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
83140
+ const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
83141
+ const tr = activeEditor.state?.tr.setSelection(TextSelection$1.create(activeEditor.state.doc, posAfter));
83142
+ if (tr) {
83143
+ activeEditor.view?.dispatch(tr);
83144
+ }
83145
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
83146
+ }
83147
+ const editorDom = activeEditor.view?.dom;
83148
+ if (editorDom) {
83149
+ editorDom.focus();
83150
+ activeEditor.view?.focus();
83151
+ }
83152
+ });
81957
83153
  __privateAdd$1(this, _handleDoubleClick, (event) => {
81958
83154
  if (event.button !== 0) return;
81959
83155
  if (!__privateGet$1(this, _layoutState).layout) return;
@@ -82143,6 +83339,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82143
83339
  __privateMethod$1(this, _PresentationEditor_instances, applyZoom_fn).call(this);
82144
83340
  __privateMethod$1(this, _PresentationEditor_instances, setupEditorListeners_fn).call(this);
82145
83341
  __privateMethod$1(this, _PresentationEditor_instances, setupPointerHandlers_fn).call(this);
83342
+ __privateMethod$1(this, _PresentationEditor_instances, setupDragHandlers_fn).call(this);
82146
83343
  __privateMethod$1(this, _PresentationEditor_instances, setupInputBridge_fn).call(this);
82147
83344
  __privateMethod$1(this, _PresentationEditor_instances, syncTrackedChangesPreferences_fn).call(this);
82148
83345
  if (options.documentId) {
@@ -82854,6 +84051,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82854
84051
  * Safe to call during partial initialization.
82855
84052
  */
82856
84053
  destroy() {
84054
+ var _a2;
82857
84055
  if (__privateGet$1(this, _rafHandle) != null) {
82858
84056
  __privateMethod$1(this, _PresentationEditor_instances, safeCleanup_fn).call(this, () => {
82859
84057
  const win = __privateGet$1(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
@@ -82875,6 +84073,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82875
84073
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
82876
84074
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
82877
84075
  __privateGet$1(this, _viewportHost)?.removeEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
84076
+ __privateGet$1(this, _viewportHost)?.removeEventListener("dragover", __privateGet$1(this, _handleDragOver));
84077
+ __privateGet$1(this, _viewportHost)?.removeEventListener("drop", __privateGet$1(this, _handleDrop));
82878
84078
  __privateGet$1(this, _visibleHost)?.removeEventListener("keydown", __privateGet$1(this, _handleKeyDown));
82879
84079
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
82880
84080
  __privateGet$1(this, _inputBridge)?.destroy();
@@ -82913,6 +84113,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
82913
84113
  __privateSet(this, _session, { mode: "body" });
82914
84114
  __privateSet(this, _activeHeaderFooterEditor, null);
82915
84115
  __privateSet(this, _domPainter, null);
84116
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
84117
+ __privateSet(this, _dragHandlerCleanup, null);
82916
84118
  __privateGet$1(this, _selectionOverlay2)?.remove();
82917
84119
  __privateGet$1(this, _painterHost)?.remove();
82918
84120
  __privateGet$1(this, _hiddenHost)?.remove();
@@ -82940,6 +84142,7 @@ _hiddenHost = /* @__PURE__ */ new WeakMap();
82940
84142
  _layoutOptions = /* @__PURE__ */ new WeakMap();
82941
84143
  _layoutState = /* @__PURE__ */ new WeakMap();
82942
84144
  _domPainter = /* @__PURE__ */ new WeakMap();
84145
+ _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
82943
84146
  _layoutError = /* @__PURE__ */ new WeakMap();
82944
84147
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
82945
84148
  _errorBanner = /* @__PURE__ */ new WeakMap();
@@ -82995,6 +84198,33 @@ _scrollCleanup = /* @__PURE__ */ new WeakMap();
82995
84198
  _remoteCursorRafHandle = /* @__PURE__ */ new WeakMap();
82996
84199
  _scrollTimeout = /* @__PURE__ */ new WeakMap();
82997
84200
  _PresentationEditor_instances = /* @__PURE__ */ new WeakSet();
84201
+ collectCommentPositions_fn = function() {
84202
+ const editorState = __privateGet$1(this, _editor3)?.state;
84203
+ if (!editorState) return {};
84204
+ const doc2 = editorState.doc;
84205
+ const trackChangeMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
84206
+ const pmPositions = {};
84207
+ doc2.descendants((node, pos) => {
84208
+ const marks = node.marks || [];
84209
+ for (const mark of marks) {
84210
+ let threadId;
84211
+ if (mark.type.name === CommentMarkName) {
84212
+ threadId = mark.attrs.commentId || mark.attrs.importedId;
84213
+ } else if (trackChangeMarks.includes(mark.type.name)) {
84214
+ threadId = mark.attrs.id;
84215
+ }
84216
+ if (!threadId) continue;
84217
+ const nodeEnd = pos + node.nodeSize;
84218
+ if (!pmPositions[threadId]) {
84219
+ pmPositions[threadId] = { threadId, start: pos, end: nodeEnd };
84220
+ } else {
84221
+ pmPositions[threadId].start = Math.min(pmPositions[threadId].start, pos);
84222
+ pmPositions[threadId].end = Math.max(pmPositions[threadId].end, nodeEnd);
84223
+ }
84224
+ }
84225
+ });
84226
+ return pmPositions;
84227
+ };
82998
84228
  aggregateLayoutBounds_fn = function(rects) {
82999
84229
  if (!rects.length) return null;
83000
84230
  const top2 = Math.min(...rects.map((rect) => rect.top));
@@ -83323,8 +84553,99 @@ setupPointerHandlers_fn = function() {
83323
84553
  __privateGet$1(this, _viewportHost).addEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
83324
84554
  __privateGet$1(this, _viewportHost).addEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
83325
84555
  __privateGet$1(this, _viewportHost).addEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
84556
+ __privateGet$1(this, _viewportHost).addEventListener("dragover", __privateGet$1(this, _handleDragOver));
84557
+ __privateGet$1(this, _viewportHost).addEventListener("drop", __privateGet$1(this, _handleDrop));
83326
84558
  __privateGet$1(this, _visibleHost).addEventListener("keydown", __privateGet$1(this, _handleKeyDown));
83327
84559
  };
84560
+ setupDragHandlers_fn = function() {
84561
+ var _a2;
84562
+ (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
84563
+ __privateSet(this, _dragHandlerCleanup, null);
84564
+ __privateSet(this, _dragHandlerCleanup, createDragHandler(__privateGet$1(this, _painterHost), {
84565
+ onDragOver: (event) => {
84566
+ if (!event.hasFieldAnnotation || event.event.clientX === 0) {
84567
+ return;
84568
+ }
84569
+ const activeEditor = this.getActiveEditor();
84570
+ if (!activeEditor?.isEditable) {
84571
+ return;
84572
+ }
84573
+ const hit = this.hitTest(event.clientX, event.clientY);
84574
+ const doc2 = activeEditor.state?.doc;
84575
+ if (!hit || !doc2) {
84576
+ return;
84577
+ }
84578
+ const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
84579
+ const currentSelection = activeEditor.state.selection;
84580
+ if (currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos) {
84581
+ return;
84582
+ }
84583
+ try {
84584
+ const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc2, pos)).setMeta("addToHistory", false);
84585
+ activeEditor.view?.dispatch(tr);
84586
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
84587
+ } catch {
84588
+ }
84589
+ },
84590
+ onDrop: (event) => {
84591
+ event.event.preventDefault();
84592
+ event.event.stopPropagation();
84593
+ if (event.pmPosition === null) {
84594
+ return;
84595
+ }
84596
+ const activeEditor = this.getActiveEditor();
84597
+ const { state: state2, view } = activeEditor;
84598
+ if (!state2 || !view) {
84599
+ return;
84600
+ }
84601
+ const fieldId = event.data.fieldId;
84602
+ if (fieldId) {
84603
+ const targetPos = event.pmPosition;
84604
+ let sourceStart = null;
84605
+ let sourceEnd = null;
84606
+ let sourceNode = null;
84607
+ state2.doc.descendants((node, pos) => {
84608
+ if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
84609
+ sourceStart = pos;
84610
+ sourceEnd = pos + node.nodeSize;
84611
+ sourceNode = node;
84612
+ return false;
84613
+ }
84614
+ return true;
84615
+ });
84616
+ if (sourceStart === null || sourceEnd === null || !sourceNode) {
84617
+ return;
84618
+ }
84619
+ if (targetPos >= sourceStart && targetPos <= sourceEnd) {
84620
+ return;
84621
+ }
84622
+ const tr = state2.tr;
84623
+ tr.delete(sourceStart, sourceEnd);
84624
+ const mappedTarget = tr.mapping.map(targetPos);
84625
+ if (mappedTarget < 0 || mappedTarget > tr.doc.content.size) {
84626
+ return;
84627
+ }
84628
+ tr.insert(mappedTarget, sourceNode);
84629
+ tr.setMeta("uiEvent", "drop");
84630
+ view.dispatch(tr);
84631
+ return;
84632
+ }
84633
+ const attrs = event.data.attributes;
84634
+ if (attrs && isValidFieldAnnotationAttributes(attrs)) {
84635
+ const inserted = activeEditor.commands?.addFieldAnnotation?.(event.pmPosition, attrs, true);
84636
+ if (inserted) {
84637
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
84638
+ }
84639
+ return;
84640
+ }
84641
+ activeEditor.emit("fieldAnnotationDropped", {
84642
+ sourceField: event.data,
84643
+ editor: activeEditor,
84644
+ coordinates: { pos: event.pmPosition }
84645
+ });
84646
+ }
84647
+ }));
84648
+ };
83328
84649
  setupInputBridge_fn = function() {
83329
84650
  __privateGet$1(this, _inputBridge)?.destroy();
83330
84651
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
@@ -83542,6 +84863,8 @@ isWordCharacter_fn = function(char) {
83542
84863
  _handlePointerMove = /* @__PURE__ */ new WeakMap();
83543
84864
  _handlePointerLeave = /* @__PURE__ */ new WeakMap();
83544
84865
  _handlePointerUp = /* @__PURE__ */ new WeakMap();
84866
+ _handleDragOver = /* @__PURE__ */ new WeakMap();
84867
+ _handleDrop = /* @__PURE__ */ new WeakMap();
83545
84868
  _handleDoubleClick = /* @__PURE__ */ new WeakMap();
83546
84869
  _handleKeyDown = /* @__PURE__ */ new WeakMap();
83547
84870
  focusHeaderFooterShortcut_fn = function(kind) {
@@ -83712,6 +85035,11 @@ rerender_fn = async function() {
83712
85035
  const payload = { layout, blocks, measures, metrics };
83713
85036
  this.emit("layoutUpdated", payload);
83714
85037
  this.emit("paginationUpdate", payload);
85038
+ const commentPositions = __privateMethod$1(this, _PresentationEditor_instances, collectCommentPositions_fn).call(this);
85039
+ const positionKeys = Object.keys(commentPositions);
85040
+ if (positionKeys.length > 0) {
85041
+ this.emit("commentPositions", { positions: commentPositions });
85042
+ }
83715
85043
  if (__privateGet$1(this, _telemetryEmitter) && metrics) {
83716
85044
  __privateGet$1(this, _telemetryEmitter).call(this, { type: "layout", data: { layout, blocks, measures, metrics } });
83717
85045
  }
@@ -89178,6 +90506,7 @@ const Paragraph = OxmlNode.create({
89178
90506
  return ["p", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
89179
90507
  },
89180
90508
  addNodeView() {
90509
+ if (this.editor.options?.mode !== "docx" || !this.editor.converter) return null;
89181
90510
  if (shouldSkipNodeView(this.editor)) return null;
89182
90511
  return ({ node, editor, getPos, decorations, extensionAttrs }) => {
89183
90512
  return new ParagraphNodeView(node, editor, getPos, decorations, extensionAttrs);
@@ -89420,7 +90749,7 @@ const CommentReference = Node$1.create({
89420
90749
  }
89421
90750
  });
89422
90751
  const CommentsMark = Mark2.create({
89423
- name: CommentMarkName,
90752
+ name: CommentMarkName$1,
89424
90753
  group: "comments",
89425
90754
  excludes: "",
89426
90755
  addOptions() {
@@ -89439,10 +90768,10 @@ const CommentsMark = Mark2.create({
89439
90768
  };
89440
90769
  },
89441
90770
  parseDOM() {
89442
- return [{ tag: CommentMarkName }];
90771
+ return [{ tag: CommentMarkName$1 }];
89443
90772
  },
89444
90773
  renderDOM({ htmlAttributes }) {
89445
- return [CommentMarkName, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
90774
+ return [CommentMarkName$1, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
89446
90775
  }
89447
90776
  });
89448
90777
  let cache$2 = /* @__PURE__ */ new WeakMap();
@@ -99626,7 +100955,7 @@ function addLinkRelationship({ editor, href }) {
99626
100955
  }
99627
100956
  const trackInsertClass = "track-insert";
99628
100957
  const TrackInsert = Mark2.create({
99629
- name: TrackInsertMarkName,
100958
+ name: TrackInsertMarkName$1,
99630
100959
  group: "track",
99631
100960
  inclusive: false,
99632
100961
  addOptions() {
@@ -99703,7 +101032,7 @@ const TrackInsert = Mark2.create({
99703
101032
  });
99704
101033
  const trackDeleteClass = "track-delete";
99705
101034
  const TrackDelete = Mark2.create({
99706
- name: TrackDeleteMarkName,
101035
+ name: TrackDeleteMarkName$1,
99707
101036
  group: "track",
99708
101037
  inclusive: false,
99709
101038
  addOptions() {
@@ -99812,7 +101141,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
99812
101141
  }, Symbol.toStringTag, { value: "Module" }));
99813
101142
  const trackFormatClass = "track-format";
99814
101143
  const TrackFormat = Mark2.create({
99815
- name: TrackFormatMarkName,
101144
+ name: TrackFormatMarkName$1,
99816
101145
  group: "track",
99817
101146
  inclusive: false,
99818
101147
  addOptions() {
@@ -100026,7 +101355,7 @@ const TrackChanges = Extension.create({
100026
101355
  tr.setMeta("inputType", "acceptReject");
100027
101356
  const map22 = new Mapping();
100028
101357
  doc2.nodesBetween(from2, to, (node, pos) => {
100029
- if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
101358
+ if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
100030
101359
  const deletionStep = new ReplaceStep(
100031
101360
  map22.map(Math.max(pos, from2)),
100032
101361
  map22.map(Math.min(pos + node.nodeSize, to)),
@@ -100034,8 +101363,8 @@ const TrackChanges = Extension.create({
100034
101363
  );
100035
101364
  tr.step(deletionStep);
100036
101365
  map22.appendMap(deletionStep.getMap());
100037
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName)) {
100038
- const insertionMark = node.marks.find((mark) => mark.type.name === TrackInsertMarkName);
101366
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1)) {
101367
+ const insertionMark = node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1);
100039
101368
  tr.step(
100040
101369
  new RemoveMarkStep(
100041
101370
  map22.map(Math.max(pos, from2)),
@@ -100043,8 +101372,8 @@ const TrackChanges = Extension.create({
100043
101372
  insertionMark
100044
101373
  )
100045
101374
  );
100046
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName)) {
100047
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
101375
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1)) {
101376
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
100048
101377
  tr.step(
100049
101378
  new RemoveMarkStep(
100050
101379
  map22.map(Math.max(pos, from2)),
@@ -100066,8 +101395,8 @@ const TrackChanges = Extension.create({
100066
101395
  tr.setMeta("inputType", "acceptReject");
100067
101396
  const map22 = new Mapping();
100068
101397
  doc2.nodesBetween(from2, to, (node, pos) => {
100069
- if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
100070
- const deletionMark = node.marks.find((mark) => mark.type.name === TrackDeleteMarkName);
101398
+ if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
101399
+ const deletionMark = node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1);
100071
101400
  tr.step(
100072
101401
  new RemoveMarkStep(
100073
101402
  map22.map(Math.max(pos, from2)),
@@ -100075,7 +101404,7 @@ const TrackChanges = Extension.create({
100075
101404
  deletionMark
100076
101405
  )
100077
101406
  );
100078
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName)) {
101407
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1)) {
100079
101408
  const deletionStep = new ReplaceStep(
100080
101409
  map22.map(Math.max(pos, from2)),
100081
101410
  map22.map(Math.min(pos + node.nodeSize, to)),
@@ -100083,8 +101412,8 @@ const TrackChanges = Extension.create({
100083
101412
  );
100084
101413
  tr.step(deletionStep);
100085
101414
  map22.appendMap(deletionStep.getMap());
100086
- } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName)) {
100087
- const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
101415
+ } else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1)) {
101416
+ const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
100088
101417
  formatChangeMark.attrs.before.forEach((oldMark) => {
100089
101418
  tr.step(
100090
101419
  new AddMarkStep(
@@ -100260,7 +101589,7 @@ const getChangesByIdToResolve = (state2, id) => {
100260
101589
  const hasContentBetween = state2.doc.textBetween(left2.from, right2.to, "\n").length > getSegmentSize(left2) + getSegmentSize(right2);
100261
101590
  return !hasContentBetween;
100262
101591
  };
100263
- const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName && secondType === TrackInsertMarkName || firstType === TrackInsertMarkName && secondType === TrackDeleteMarkName;
101592
+ const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName$1 && secondType === TrackInsertMarkName$1 || firstType === TrackInsertMarkName$1 && secondType === TrackDeleteMarkName$1;
100264
101593
  const linkedBefore = [];
100265
101594
  const linkedAfter = [];
100266
101595
  const collectDirection = (direction, collection) => {