@harbour-enterprises/superdoc 1.0.0-beta.98 → 1.0.0-next.1

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 (29) hide show
  1. package/dist/chunks/{PdfViewer-1_KffD-j.es.js → PdfViewer-BKujh9gl.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-D1Ot32kX.cjs → PdfViewer-Cu04k0JZ.cjs} +1 -1
  3. package/dist/chunks/{index-CUO7gEi8.cjs → index-CZ4149Px.cjs} +5 -14
  4. package/dist/chunks/{index-CP2_WwLA.es.js → index-Cl0tjE1C.es.js} +5 -14
  5. package/dist/chunks/{index-Dg_sTYZK-D20z8mus.es.js → index-Dlj3l0Hk-BuYH_UIe.es.js} +1 -1
  6. package/dist/chunks/{index-Dg_sTYZK-DYDzxoXL.cjs → index-Dlj3l0Hk-CJ0YBOja.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-DN_dgBH0.cjs → super-editor.es-CjRtsxTt.cjs} +1102 -187
  8. package/dist/chunks/{super-editor.es-3dJOUw65.es.js → super-editor.es-D0WByw5h.es.js} +1102 -187
  9. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  10. package/dist/style.css +6 -6
  11. package/dist/super-editor/ai-writer.es.js +2 -2
  12. package/dist/super-editor/chunks/{converter-Oj-eTB79.js → converter-BS4FD8AG.js} +12 -6
  13. package/dist/super-editor/chunks/{docx-zipper-Dl188zQ3.js → docx-zipper-DpiCpt0d.js} +1 -1
  14. package/dist/super-editor/chunks/{editor-DBXoaaWP.js → editor-BeacbTQe.js} +1092 -179
  15. package/dist/super-editor/chunks/{index-Dg_sTYZK.js → index-Dlj3l0Hk.js} +1 -1
  16. package/dist/super-editor/chunks/{toolbar-PlGGj0Ew.js → toolbar-BNQDvBCn.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/super-editor.es.js +10 -10
  22. package/dist/super-editor/toolbar.es.js +2 -2
  23. package/dist/super-editor.cjs +1 -1
  24. package/dist/super-editor.es.js +1 -1
  25. package/dist/superdoc.cjs +2 -2
  26. package/dist/superdoc.es.js +2 -2
  27. package/dist/superdoc.umd.js +1106 -200
  28. package/dist/superdoc.umd.js.map +1 -1
  29. package/package.json +10 -1
@@ -9,11 +9,11 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- 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, hideDimmingOverlay_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, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_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, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_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, computeExpectedSectionType_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, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_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, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_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;
12
+ 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, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _pageGeometryHelper, _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, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_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, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_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, computeExpectedSectionType_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, computeAnchorMap_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_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, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_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;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-Oj-eTB79.js";
16
- import { D as DocxZipper } from "./docx-zipper-Dl188zQ3.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-BS4FD8AG.js";
16
+ import { D as DocxZipper } from "./docx-zipper-DpiCpt0d.js";
17
17
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
@@ -9098,6 +9098,14 @@ const toggleNode = (typeOrName, toggleTypeOrName, attrs = {}) => ({ state, comma
9098
9098
  const selectAll = () => ({ state, dispatch }) => selectAll$1(state, dispatch);
9099
9099
  const deleteSelection = () => ({ state, tr, dispatch }) => {
9100
9100
  const { from: from2, to, empty: empty2 } = state.selection;
9101
+ if (typeof document !== "undefined" && document.getSelection) {
9102
+ const currentDomSelection = document.getSelection();
9103
+ const selectedLength = currentDomSelection?.toString?.().length;
9104
+ const isCollapsed = currentDomSelection?.isCollapsed;
9105
+ if (!isCollapsed && selectedLength === 1) {
9106
+ return false;
9107
+ }
9108
+ }
9101
9109
  if (empty2) {
9102
9110
  return deleteSelection$1(state, dispatch);
9103
9111
  }
@@ -11406,12 +11414,14 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
11406
11414
  importedId: node.attrs["w:id"]
11407
11415
  });
11408
11416
  if (type.name === "commentRangeStart") {
11409
- toMark.push({
11410
- commentId: resolvedCommentId,
11411
- importedId,
11412
- internal,
11413
- start: pos
11414
- });
11417
+ if (!matchingImportedComment?.isDone) {
11418
+ toMark.push({
11419
+ commentId: resolvedCommentId,
11420
+ importedId,
11421
+ internal,
11422
+ start: pos
11423
+ });
11424
+ }
11415
11425
  ensureFallbackComment({
11416
11426
  converter,
11417
11427
  matchingImportedComment,
@@ -13952,7 +13962,7 @@ const isHeadless = (editor) => {
13952
13962
  const shouldSkipNodeView = (editor) => {
13953
13963
  return isHeadless(editor);
13954
13964
  };
13955
- const summaryVersion = "1.0.0-beta.98";
13965
+ const summaryVersion = "1.0.0-next.1";
13956
13966
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
13957
13967
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
13958
13968
  function mapAttributes(attrs) {
@@ -14315,11 +14325,11 @@ const _Editor = class _Editor extends EventEmitter {
14315
14325
  if (!this.options.isNewFile || !this.options.collaborationProvider) return;
14316
14326
  const provider = this.options.collaborationProvider;
14317
14327
  const postSyncInit = () => {
14318
- provider.off("synced", postSyncInit);
14328
+ provider.off?.("synced", postSyncInit);
14319
14329
  __privateMethod(this, _Editor_instances, insertNewFileData_fn).call(this);
14320
14330
  };
14321
14331
  if (provider.synced) __privateMethod(this, _Editor_instances, insertNewFileData_fn).call(this);
14322
- else provider.on("synced", postSyncInit);
14332
+ else provider.on?.("synced", postSyncInit);
14323
14333
  }
14324
14334
  /**
14325
14335
  * Replace content of editor that was created with loadFromSchema option
@@ -14744,7 +14754,7 @@ const _Editor = class _Editor extends EventEmitter {
14744
14754
  { default: remarkStringify },
14745
14755
  { default: remarkGfm }
14746
14756
  ] = await Promise.all([
14747
- import("./index-Dg_sTYZK.js"),
14757
+ import("./index-Dlj3l0Hk.js"),
14748
14758
  import("./index-DRCvimau.js"),
14749
14759
  import("./index-C_x_N6Uh.js"),
14750
14760
  import("./index-D_sWOSiG.js"),
@@ -14949,7 +14959,7 @@ const _Editor = class _Editor extends EventEmitter {
14949
14959
  * Process collaboration migrations
14950
14960
  */
14951
14961
  processCollaborationMigrations() {
14952
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.98");
14962
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-next.1");
14953
14963
  if (!this.options.ydoc) return;
14954
14964
  const metaMap = this.options.ydoc.getMap("meta");
14955
14965
  let docVersion = metaMap.get("version");
@@ -18152,6 +18162,7 @@ function hydrateImageBlocks(blocks, mediaFiles) {
18152
18162
  if (cellChanged) {
18153
18163
  return {
18154
18164
  ...cell,
18165
+ // Cast to expected type - hydrateBlock preserves block kinds, just hydrates image sources
18155
18166
  blocks: hydratedBlocks.length > 0 ? hydratedBlocks : cell.blocks,
18156
18167
  paragraph: hydratedParagraph
18157
18168
  };
@@ -21772,7 +21783,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
21772
21783
  };
21773
21784
  }
21774
21785
  const hasValidNumbering = rawNumberingProps && isValidNumberingId(rawNumberingProps.numId);
21775
- if (hasValidNumbering) {
21786
+ if (hasValidNumbering && rawNumberingProps) {
21776
21787
  const numberingProps = rawNumberingProps;
21777
21788
  const numId = numberingProps.numId;
21778
21789
  const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
@@ -21812,6 +21823,8 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
21812
21823
  const resolvedCounterValue = path[path.length - 1] ?? counterValue;
21813
21824
  const enrichedNumberingProps = {
21814
21825
  ...numberingProps,
21826
+ numId: numberingProps.numId,
21827
+ ilvl: numberingProps.ilvl,
21815
21828
  path,
21816
21829
  counterValue: resolvedCounterValue
21817
21830
  };
@@ -23908,7 +23921,7 @@ const parseTableCell = (args) => {
23908
23921
  context.nextBlockId,
23909
23922
  context.positions
23910
23923
  );
23911
- if (drawingBlock) {
23924
+ if (drawingBlock && drawingBlock.kind === "drawing") {
23912
23925
  blocks.push(drawingBlock);
23913
23926
  }
23914
23927
  continue;
@@ -23919,7 +23932,7 @@ const parseTableCell = (args) => {
23919
23932
  context.nextBlockId,
23920
23933
  context.positions
23921
23934
  );
23922
- if (drawingBlock) {
23935
+ if (drawingBlock && drawingBlock.kind === "drawing") {
23923
23936
  blocks.push(drawingBlock);
23924
23937
  }
23925
23938
  continue;
@@ -23930,7 +23943,7 @@ const parseTableCell = (args) => {
23930
23943
  context.nextBlockId,
23931
23944
  context.positions
23932
23945
  );
23933
- if (drawingBlock) {
23946
+ if (drawingBlock && drawingBlock.kind === "drawing") {
23934
23947
  blocks.push(drawingBlock);
23935
23948
  }
23936
23949
  continue;
@@ -23941,7 +23954,7 @@ const parseTableCell = (args) => {
23941
23954
  context.nextBlockId,
23942
23955
  context.positions
23943
23956
  );
23944
- if (drawingBlock) {
23957
+ if (drawingBlock && drawingBlock.kind === "drawing") {
23945
23958
  blocks.push(drawingBlock);
23946
23959
  }
23947
23960
  }
@@ -24396,7 +24409,19 @@ function toFlowBlocks(pmDoc, options) {
24396
24409
  bookmarks2,
24397
24410
  hyperlinkConfig2,
24398
24411
  themeColorsParam ?? themeColors,
24399
- paragraphConverter
24412
+ paragraphConverter,
24413
+ converterCtx ?? converterContext,
24414
+ {
24415
+ listCounterContext: { getListCounter, incrementListCounter, resetListCounter },
24416
+ converters: {
24417
+ paragraphToFlowBlocks: paragraphConverter,
24418
+ imageNodeToBlock,
24419
+ vectorShapeNodeToDrawingBlock,
24420
+ shapeGroupNodeToDrawingBlock,
24421
+ shapeContainerNodeToDrawingBlock,
24422
+ shapeTextboxNodeToDrawingBlock
24423
+ }
24424
+ }
24400
24425
  );
24401
24426
  const handlerContext = {
24402
24427
  blocks,
@@ -24417,6 +24442,7 @@ function toFlowBlocks(pmDoc, options) {
24417
24442
  currentParagraphIndex: 0
24418
24443
  },
24419
24444
  converters: {
24445
+ // Type assertion needed due to signature mismatch between actual function and type definition
24420
24446
  paragraphToFlowBlocks: paragraphConverter,
24421
24447
  tableNodeToBlock: tableConverter,
24422
24448
  imageNodeToBlock,
@@ -24512,6 +24538,7 @@ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaul
24512
24538
  {
24513
24539
  listCounterContext,
24514
24540
  converters: {
24541
+ // Type assertion needed due to signature mismatch between actual function and type definition
24515
24542
  paragraphToFlowBlocks: paragraphToFlowBlocks$1,
24516
24543
  imageNodeToBlock,
24517
24544
  vectorShapeNodeToDrawingBlock,
@@ -24525,7 +24552,7 @@ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaul
24525
24552
  converterContext
24526
24553
  );
24527
24554
  }
24528
- function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize, styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, converterContext) {
24555
+ function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize, styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, _paragraphToFlowBlocksParam, converterContext, options) {
24529
24556
  return tableNodeToBlock$1(
24530
24557
  node,
24531
24558
  nextBlockId,
@@ -24539,8 +24566,9 @@ function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize
24539
24566
  themeColors,
24540
24567
  paragraphToFlowBlocks,
24541
24568
  converterContext,
24542
- {
24569
+ options ?? {
24543
24570
  converters: {
24571
+ // Type assertion needed due to signature mismatch between actual function and type definition
24544
24572
  paragraphToFlowBlocks: paragraphToFlowBlocks$1,
24545
24573
  imageNodeToBlock,
24546
24574
  vectorShapeNodeToDrawingBlock,
@@ -27120,7 +27148,7 @@ const containerStyles = {
27120
27148
  alignItems: "center",
27121
27149
  background: "transparent",
27122
27150
  padding: "0",
27123
- gap: "24px",
27151
+ // gap is set dynamically by renderer based on pageGap option (default: 24px)
27124
27152
  overflowY: "auto"
27125
27153
  };
27126
27154
  const containerStylesHorizontal = {
@@ -27130,7 +27158,7 @@ const containerStylesHorizontal = {
27130
27158
  justifyContent: "safe center",
27131
27159
  background: "transparent",
27132
27160
  padding: "0",
27133
- gap: "20px",
27161
+ // gap is set dynamically by renderer based on pageGap option (default: 20px for horizontal)
27134
27162
  overflowX: "auto",
27135
27163
  minHeight: "100%"
27136
27164
  };
@@ -28828,6 +28856,104 @@ function ensureRulerStyles(doc2) {
28828
28856
  doc2.head?.appendChild(styleEl);
28829
28857
  rulerStylesInjected = true;
28830
28858
  }
28859
+ const hashParagraphBorder$1 = (border) => {
28860
+ const parts = [];
28861
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
28862
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
28863
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
28864
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
28865
+ return parts.join(",");
28866
+ };
28867
+ const hashParagraphBorders$1 = (borders) => {
28868
+ const parts = [];
28869
+ if (borders.top) parts.push(`t:[${hashParagraphBorder$1(borders.top)}]`);
28870
+ if (borders.right) parts.push(`r:[${hashParagraphBorder$1(borders.right)}]`);
28871
+ if (borders.bottom) parts.push(`b:[${hashParagraphBorder$1(borders.bottom)}]`);
28872
+ if (borders.left) parts.push(`l:[${hashParagraphBorder$1(borders.left)}]`);
28873
+ return parts.join(";");
28874
+ };
28875
+ const isNoneBorder$1 = (value) => {
28876
+ return typeof value === "object" && value !== null && "none" in value && value.none === true;
28877
+ };
28878
+ const isBorderSpec$1 = (value) => {
28879
+ return typeof value === "object" && value !== null && !("none" in value);
28880
+ };
28881
+ const hashBorderSpec$1 = (border) => {
28882
+ const parts = [];
28883
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
28884
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
28885
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
28886
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
28887
+ return parts.join(",");
28888
+ };
28889
+ const hashTableBorderValue$1 = (borderValue) => {
28890
+ if (borderValue === void 0) return "";
28891
+ if (borderValue === null) return "null";
28892
+ if (isNoneBorder$1(borderValue)) return "none";
28893
+ if (isBorderSpec$1(borderValue)) {
28894
+ return hashBorderSpec$1(borderValue);
28895
+ }
28896
+ return "";
28897
+ };
28898
+ const hashTableBorders$1 = (borders) => {
28899
+ if (!borders) return "";
28900
+ const parts = [];
28901
+ if (borders.top !== void 0) parts.push(`t:[${hashTableBorderValue$1(borders.top)}]`);
28902
+ if (borders.right !== void 0) parts.push(`r:[${hashTableBorderValue$1(borders.right)}]`);
28903
+ if (borders.bottom !== void 0) parts.push(`b:[${hashTableBorderValue$1(borders.bottom)}]`);
28904
+ if (borders.left !== void 0) parts.push(`l:[${hashTableBorderValue$1(borders.left)}]`);
28905
+ if (borders.insideH !== void 0) parts.push(`ih:[${hashTableBorderValue$1(borders.insideH)}]`);
28906
+ if (borders.insideV !== void 0) parts.push(`iv:[${hashTableBorderValue$1(borders.insideV)}]`);
28907
+ return parts.join(";");
28908
+ };
28909
+ const hashCellBorders$1 = (borders) => {
28910
+ if (!borders) return "";
28911
+ const parts = [];
28912
+ if (borders.top) parts.push(`t:[${hashBorderSpec$1(borders.top)}]`);
28913
+ if (borders.right) parts.push(`r:[${hashBorderSpec$1(borders.right)}]`);
28914
+ if (borders.bottom) parts.push(`b:[${hashBorderSpec$1(borders.bottom)}]`);
28915
+ if (borders.left) parts.push(`l:[${hashBorderSpec$1(borders.left)}]`);
28916
+ return parts.join(";");
28917
+ };
28918
+ const hasStringProp = (run, prop) => {
28919
+ return prop in run && typeof run[prop] === "string";
28920
+ };
28921
+ const hasNumberProp = (run, prop) => {
28922
+ return prop in run && typeof run[prop] === "number";
28923
+ };
28924
+ const hasBooleanProp = (run, prop) => {
28925
+ return prop in run && typeof run[prop] === "boolean";
28926
+ };
28927
+ const getRunStringProp = (run, prop) => {
28928
+ if (hasStringProp(run, prop)) {
28929
+ return run[prop];
28930
+ }
28931
+ return "";
28932
+ };
28933
+ const getRunNumberProp = (run, prop) => {
28934
+ if (hasNumberProp(run, prop)) {
28935
+ return run[prop];
28936
+ }
28937
+ return 0;
28938
+ };
28939
+ const getRunBooleanProp = (run, prop) => {
28940
+ if (hasBooleanProp(run, prop)) {
28941
+ return run[prop];
28942
+ }
28943
+ return false;
28944
+ };
28945
+ const getRunUnderlineStyle = (run) => {
28946
+ if ("underline" in run && run.underline && typeof run.underline === "object") {
28947
+ return run.underline.style ?? "";
28948
+ }
28949
+ return "";
28950
+ };
28951
+ const getRunUnderlineColor = (run) => {
28952
+ if ("underline" in run && run.underline && typeof run.underline === "object") {
28953
+ return run.underline.color ?? "";
28954
+ }
28955
+ return "";
28956
+ };
28831
28957
  function isMinimalWordLayout(value) {
28832
28958
  if (typeof value !== "object" || value === null) {
28833
28959
  return false;
@@ -28878,6 +29004,7 @@ function isMinimalWordLayout(value) {
28878
29004
  const LIST_MARKER_GAP$1 = 8;
28879
29005
  const DEFAULT_TAB_INTERVAL_PX$1 = 48;
28880
29006
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
29007
+ const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
28881
29008
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
28882
29009
  const COMMENT_INTERNAL_COLOR = "#078383";
28883
29010
  const COMMENT_INACTIVE_ALPHA = "22";
@@ -29007,10 +29134,11 @@ const _DomPainter = class _DomPainter {
29007
29134
  this.totalPages = 0;
29008
29135
  this.linkIdCounter = 0;
29009
29136
  this.pendingTooltips = /* @__PURE__ */ new WeakMap();
29137
+ this.pageGap = 24;
29010
29138
  this.virtualEnabled = false;
29011
29139
  this.virtualWindow = 5;
29012
29140
  this.virtualOverscan = 0;
29013
- this.virtualGap = 72;
29141
+ this.virtualGap = DEFAULT_VIRTUALIZED_PAGE_GAP$1;
29014
29142
  this.virtualPaddingTop = null;
29015
29143
  this.topSpacerEl = null;
29016
29144
  this.bottomSpacerEl = null;
@@ -29029,13 +29157,14 @@ const _DomPainter = class _DomPainter {
29029
29157
  this.blockLookup = this.buildBlockLookup(blocks, measures);
29030
29158
  this.headerProvider = options.headerProvider;
29031
29159
  this.footerProvider = options.footerProvider;
29160
+ const defaultGap = this.layoutMode === "horizontal" ? 20 : 24;
29161
+ this.pageGap = typeof options.pageGap === "number" && Number.isFinite(options.pageGap) ? Math.max(0, options.pageGap) : defaultGap;
29032
29162
  if (this.layoutMode === "vertical" && options.virtualization?.enabled) {
29033
29163
  this.virtualEnabled = true;
29034
29164
  this.virtualWindow = Math.max(1, options.virtualization.window ?? 5);
29035
29165
  this.virtualOverscan = Math.max(0, options.virtualization.overscan ?? 0);
29036
- if (typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap)) {
29037
- this.virtualGap = Math.max(0, options.virtualization.gap);
29038
- }
29166
+ const hasExplicitVirtualGap = typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap);
29167
+ this.virtualGap = hasExplicitVirtualGap ? Math.max(0, options.virtualization.gap) : DEFAULT_VIRTUALIZED_PAGE_GAP$1;
29039
29168
  if (typeof options.virtualization.paddingTop === "number" && Number.isFinite(options.virtualization.paddingTop)) {
29040
29169
  this.virtualPaddingTop = Math.max(0, options.virtualization.paddingTop);
29041
29170
  }
@@ -29136,6 +29265,7 @@ const _DomPainter = class _DomPainter {
29136
29265
  const mode = this.layoutMode;
29137
29266
  if (mode === "horizontal") {
29138
29267
  applyStyles$2(mount, containerStylesHorizontal);
29268
+ mount.style.gap = `${this.pageGap}px`;
29139
29269
  this.renderHorizontal(layout, mount);
29140
29270
  this.currentLayout = layout;
29141
29271
  this.pageStates = [];
@@ -29158,6 +29288,7 @@ const _DomPainter = class _DomPainter {
29158
29288
  this.changedBlocks.clear();
29159
29289
  return;
29160
29290
  }
29291
+ mount.style.gap = `${this.pageGap}px`;
29161
29292
  if (!this.currentLayout || this.pageStates.length === 0) {
29162
29293
  this.fullRender(layout);
29163
29294
  } else {
@@ -29482,9 +29613,15 @@ const _DomPainter = class _DomPainter {
29482
29613
  const container = existing ?? this.doc.createElement("div");
29483
29614
  container.className = className;
29484
29615
  container.innerHTML = "";
29485
- const offset2 = data.offset ?? (kind === "footer" ? pageEl.clientHeight - data.height : 0);
29616
+ const baseOffset = data.offset ?? (kind === "footer" ? pageEl.clientHeight - data.height : 0);
29486
29617
  const marginLeft = data.marginLeft ?? 0;
29487
29618
  const marginRight = page.margins?.right ?? 0;
29619
+ let effectiveHeight = data.height;
29620
+ let effectiveOffset = baseOffset;
29621
+ if (kind === "footer" && typeof data.contentHeight === "number" && Number.isFinite(data.contentHeight) && data.contentHeight > 0 && data.contentHeight > data.height) {
29622
+ effectiveHeight = data.contentHeight;
29623
+ effectiveOffset = baseOffset - (data.contentHeight - data.height);
29624
+ }
29488
29625
  container.style.position = "absolute";
29489
29626
  container.style.left = `${marginLeft}px`;
29490
29627
  if (typeof data.contentWidth === "number") {
@@ -29493,8 +29630,8 @@ const _DomPainter = class _DomPainter {
29493
29630
  container.style.width = `calc(100% - ${marginLeft + marginRight}px)`;
29494
29631
  }
29495
29632
  container.style.pointerEvents = "none";
29496
- container.style.height = `${data.height}px`;
29497
- container.style.top = `${Math.max(0, offset2)}px`;
29633
+ container.style.height = `${effectiveHeight}px`;
29634
+ container.style.top = `${Math.max(0, effectiveOffset)}px`;
29498
29635
  container.style.zIndex = "1";
29499
29636
  container.style.overflow = "visible";
29500
29637
  let footerYOffset = 0;
@@ -29503,7 +29640,7 @@ const _DomPainter = class _DomPainter {
29503
29640
  const fragHeight = "height" in f2 && typeof f2.height === "number" ? f2.height : this.estimateFragmentHeight(f2);
29504
29641
  return Math.max(max2, f2.y + Math.max(0, fragHeight));
29505
29642
  }, 0);
29506
- footerYOffset = Math.max(0, data.height - contentHeight);
29643
+ footerYOffset = Math.max(0, effectiveHeight - contentHeight);
29507
29644
  }
29508
29645
  const context = {
29509
29646
  pageNumber: page.number,
@@ -31907,7 +32044,7 @@ const deriveBlockVersion = (block) => {
31907
32044
  attrs.indent?.right ?? "",
31908
32045
  attrs.indent?.firstLine ?? "",
31909
32046
  attrs.indent?.hanging ?? "",
31910
- attrs.borders ? JSON.stringify(attrs.borders) : "",
32047
+ attrs.borders ? hashParagraphBorders$1(attrs.borders) : "",
31911
32048
  attrs.shading?.fill ?? "",
31912
32049
  attrs.shading?.color ?? "",
31913
32050
  attrs.direction ?? "",
@@ -31993,22 +32130,82 @@ const deriveBlockVersion = (block) => {
31993
32130
  hash2 = hashNumber(hash2, cellBlocks.length);
31994
32131
  hash2 = hashNumber(hash2, cell.rowSpan ?? 1);
31995
32132
  hash2 = hashNumber(hash2, cell.colSpan ?? 1);
32133
+ if (cell.attrs) {
32134
+ const cellAttrs = cell.attrs;
32135
+ if (cellAttrs.borders) {
32136
+ hash2 = hashString(hash2, hashCellBorders$1(cellAttrs.borders));
32137
+ }
32138
+ if (cellAttrs.padding) {
32139
+ const p = cellAttrs.padding;
32140
+ hash2 = hashNumber(hash2, p.top ?? 0);
32141
+ hash2 = hashNumber(hash2, p.right ?? 0);
32142
+ hash2 = hashNumber(hash2, p.bottom ?? 0);
32143
+ hash2 = hashNumber(hash2, p.left ?? 0);
32144
+ }
32145
+ if (cellAttrs.verticalAlign) {
32146
+ hash2 = hashString(hash2, cellAttrs.verticalAlign);
32147
+ }
32148
+ if (cellAttrs.background) {
32149
+ hash2 = hashString(hash2, cellAttrs.background);
32150
+ }
32151
+ }
31996
32152
  for (const cellBlock of cellBlocks) {
31997
32153
  hash2 = hashString(hash2, cellBlock?.kind ?? "unknown");
31998
32154
  if (cellBlock?.kind === "paragraph") {
31999
- const runs = cellBlock.runs ?? [];
32155
+ const paragraphBlock = cellBlock;
32156
+ const runs = paragraphBlock.runs ?? [];
32000
32157
  hash2 = hashNumber(hash2, runs.length);
32158
+ const attrs = paragraphBlock.attrs;
32159
+ if (attrs) {
32160
+ hash2 = hashString(hash2, attrs.alignment ?? "");
32161
+ hash2 = hashNumber(hash2, attrs.spacing?.before ?? 0);
32162
+ hash2 = hashNumber(hash2, attrs.spacing?.after ?? 0);
32163
+ hash2 = hashNumber(hash2, attrs.spacing?.line ?? 0);
32164
+ hash2 = hashString(hash2, attrs.spacing?.lineRule ?? "");
32165
+ hash2 = hashNumber(hash2, attrs.indent?.left ?? 0);
32166
+ hash2 = hashNumber(hash2, attrs.indent?.right ?? 0);
32167
+ hash2 = hashNumber(hash2, attrs.indent?.firstLine ?? 0);
32168
+ hash2 = hashNumber(hash2, attrs.indent?.hanging ?? 0);
32169
+ hash2 = hashString(hash2, attrs.shading?.fill ?? "");
32170
+ hash2 = hashString(hash2, attrs.shading?.color ?? "");
32171
+ hash2 = hashString(hash2, attrs.direction ?? "");
32172
+ hash2 = hashString(hash2, attrs.rtl ? "1" : "");
32173
+ if (attrs.borders) {
32174
+ hash2 = hashString(hash2, hashParagraphBorders$1(attrs.borders));
32175
+ }
32176
+ }
32001
32177
  for (const run of runs) {
32002
32178
  if ("text" in run && typeof run.text === "string") {
32003
32179
  hash2 = hashString(hash2, run.text);
32004
32180
  }
32005
32181
  hash2 = hashNumber(hash2, run.pmStart ?? -1);
32006
32182
  hash2 = hashNumber(hash2, run.pmEnd ?? -1);
32183
+ hash2 = hashString(hash2, getRunStringProp(run, "color"));
32184
+ hash2 = hashString(hash2, getRunStringProp(run, "highlight"));
32185
+ hash2 = hashString(hash2, getRunBooleanProp(run, "bold") ? "1" : "");
32186
+ hash2 = hashString(hash2, getRunBooleanProp(run, "italic") ? "1" : "");
32187
+ hash2 = hashNumber(hash2, getRunNumberProp(run, "fontSize"));
32188
+ hash2 = hashString(hash2, getRunStringProp(run, "fontFamily"));
32189
+ hash2 = hashString(hash2, getRunUnderlineStyle(run));
32190
+ hash2 = hashString(hash2, getRunUnderlineColor(run));
32191
+ hash2 = hashString(hash2, getRunBooleanProp(run, "strike") ? "1" : "");
32007
32192
  }
32008
32193
  }
32009
32194
  }
32010
32195
  }
32011
32196
  }
32197
+ if (tableBlock.attrs) {
32198
+ const tblAttrs = tableBlock.attrs;
32199
+ if (tblAttrs.borders) {
32200
+ hash2 = hashString(hash2, hashTableBorders$1(tblAttrs.borders));
32201
+ }
32202
+ if (tblAttrs.borderCollapse) {
32203
+ hash2 = hashString(hash2, tblAttrs.borderCollapse);
32204
+ }
32205
+ if (tblAttrs.cellSpacing !== void 0) {
32206
+ hash2 = hashNumber(hash2, tblAttrs.cellSpacing);
32207
+ }
32208
+ }
32012
32209
  return [block.id, tableBlock.rows.length, hash2.toString(16)].join("|");
32013
32210
  }
32014
32211
  return block.id;
@@ -32342,6 +32539,7 @@ const createDomPainter = (options) => {
32342
32539
  const painter = new DomPainter(options.blocks, options.measures, {
32343
32540
  pageStyles: options.pageStyles,
32344
32541
  layoutMode: options.layoutMode,
32542
+ pageGap: options.pageGap,
32345
32543
  headerProvider: options.headerProvider,
32346
32544
  footerProvider: options.footerProvider,
32347
32545
  virtualization: options.virtualization,
@@ -32760,7 +32958,7 @@ function isListItem(markerWidth, block) {
32760
32958
  return false;
32761
32959
  }
32762
32960
  const wordLayout = getWordLayoutConfig(block);
32763
- const hasListAttrs = block.attrs?.listItem != null || wordLayout?.marker != null;
32961
+ const hasListAttrs = block.attrs?.listItem != null || block.attrs?.numberingProperties != null || wordLayout?.marker != null;
32764
32962
  if (hasListAttrs) {
32765
32963
  return true;
32766
32964
  }
@@ -33190,7 +33388,7 @@ function computeNextSectionPropsAtBreak(blocks) {
33190
33388
  });
33191
33389
  return nextSectionPropsAtBreak;
33192
33390
  }
33193
- function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight = 0) {
33391
+ function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight = 0, maxFooterContentHeight = 0) {
33194
33392
  const next = { ...state };
33195
33393
  const calcRequiredTopMargin = (headerDistance, baseTop) => {
33196
33394
  if (maxHeaderContentHeight > 0) {
@@ -33198,6 +33396,12 @@ function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight
33198
33396
  }
33199
33397
  return Math.max(baseTop, headerDistance);
33200
33398
  };
33399
+ const calcRequiredBottomMargin = (footerDistance, baseBottom) => {
33400
+ if (maxFooterContentHeight > 0) {
33401
+ return Math.max(baseBottom, footerDistance + maxFooterContentHeight);
33402
+ }
33403
+ return Math.max(baseBottom, footerDistance);
33404
+ };
33201
33405
  if (block.attrs?.isFirstSection && !next.hasAnyPages) {
33202
33406
  if (block.pageSize) {
33203
33407
  next.activePageSize = { w: block.pageSize.w, h: block.pageSize.h };
@@ -33218,7 +33422,7 @@ function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight
33218
33422
  const footerDistance = Math.max(0, block.margins.footer);
33219
33423
  next.activeFooterDistance = footerDistance;
33220
33424
  next.pendingFooterDistance = footerDistance;
33221
- next.activeBottomMargin = Math.max(baseMargins.bottom, footerDistance);
33425
+ next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, baseMargins.bottom);
33222
33426
  next.pendingBottomMargin = next.activeBottomMargin;
33223
33427
  }
33224
33428
  if (block.columns) {
@@ -33241,8 +33445,14 @@ function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight
33241
33445
  next.pendingTopMargin = nextTop;
33242
33446
  next.pendingHeaderDistance = nextHeader;
33243
33447
  }
33244
- next.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
33245
- next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
33448
+ if (typeof footerPx === "number") {
33449
+ const newFooterDist = Math.max(0, footerPx);
33450
+ next.pendingFooterDistance = newFooterDist;
33451
+ next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, baseMargins.bottom);
33452
+ } else {
33453
+ next.pendingBottomMargin = nextBottom;
33454
+ next.pendingFooterDistance = nextFooter;
33455
+ }
33246
33456
  if (block.pageSize) {
33247
33457
  next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
33248
33458
  }
@@ -34842,7 +35052,7 @@ function layoutDocument(blocks, measures, options = {}) {
34842
35052
  if (contentWidth <= 0) {
34843
35053
  throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
34844
35054
  }
34845
- const validateHeaderHeight = (height) => {
35055
+ const validateContentHeight = (height) => {
34846
35056
  if (height === void 0) return 0;
34847
35057
  if (!Number.isFinite(height) || height < 0) return 0;
34848
35058
  return height;
@@ -34850,15 +35060,25 @@ function layoutDocument(blocks, measures, options = {}) {
34850
35060
  const headerContentHeights = options.headerContentHeights;
34851
35061
  const maxHeaderContentHeight = headerContentHeights ? Math.max(
34852
35062
  0,
34853
- validateHeaderHeight(headerContentHeights.default),
34854
- validateHeaderHeight(headerContentHeights.first),
34855
- validateHeaderHeight(headerContentHeights.even),
34856
- validateHeaderHeight(headerContentHeights.odd)
35063
+ validateContentHeight(headerContentHeights.default),
35064
+ validateContentHeight(headerContentHeights.first),
35065
+ validateContentHeight(headerContentHeights.even),
35066
+ validateContentHeight(headerContentHeights.odd)
34857
35067
  ) : 0;
34858
35068
  const headerDistance = margins.header ?? margins.top;
34859
35069
  const effectiveTopMargin = maxHeaderContentHeight > 0 ? Math.max(margins.top, headerDistance + maxHeaderContentHeight) : margins.top;
35070
+ const footerContentHeights = options.footerContentHeights;
35071
+ const maxFooterContentHeight = footerContentHeights ? Math.max(
35072
+ 0,
35073
+ validateContentHeight(footerContentHeights.default),
35074
+ validateContentHeight(footerContentHeights.first),
35075
+ validateContentHeight(footerContentHeights.even),
35076
+ validateContentHeight(footerContentHeights.odd)
35077
+ ) : 0;
35078
+ const footerDistance = margins.footer ?? margins.bottom;
35079
+ const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
34860
35080
  let activeTopMargin = effectiveTopMargin;
34861
- let activeBottomMargin = margins.bottom;
35081
+ let activeBottomMargin = effectiveBottomMargin;
34862
35082
  let pendingTopMargin = null;
34863
35083
  let pendingBottomMargin = null;
34864
35084
  let activeHeaderDistance = margins.header ?? margins.top;
@@ -34881,7 +35101,7 @@ function layoutDocument(blocks, measures, options = {}) {
34881
35101
  const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
34882
35102
  const scheduleSectionBreakCompat = (block, state, baseMargins) => {
34883
35103
  if (typeof scheduleSectionBreak === "function") {
34884
- return scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight);
35104
+ return scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight, maxFooterContentHeight);
34885
35105
  }
34886
35106
  const next = { ...state };
34887
35107
  if (block.attrs?.isFirstSection && !next.hasAnyPages) {
@@ -34902,10 +35122,11 @@ function layoutDocument(blocks, measures, options = {}) {
34902
35122
  next.pendingTopMargin = next.activeTopMargin;
34903
35123
  }
34904
35124
  if (block.margins?.footer !== void 0) {
34905
- const footerDistance = Math.max(0, block.margins.footer);
34906
- next.activeFooterDistance = footerDistance;
34907
- next.pendingFooterDistance = footerDistance;
34908
- next.activeBottomMargin = Math.max(baseMargins.bottom, footerDistance);
35125
+ const footerDistance2 = Math.max(0, block.margins.footer);
35126
+ next.activeFooterDistance = footerDistance2;
35127
+ next.pendingFooterDistance = footerDistance2;
35128
+ const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
35129
+ next.activeBottomMargin = Math.max(baseMargins.bottom, requiredBottom);
34909
35130
  next.pendingBottomMargin = next.activeBottomMargin;
34910
35131
  }
34911
35132
  if (block.columns) {
@@ -34950,7 +35171,13 @@ function layoutDocument(blocks, measures, options = {}) {
34950
35171
  } else {
34951
35172
  next.pendingTopMargin = nextTop;
34952
35173
  }
34953
- next.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
35174
+ if (typeof footerPx === "number") {
35175
+ const sectionFooter = next.pendingFooterDistance;
35176
+ const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
35177
+ next.pendingBottomMargin = Math.max(baseMargins.bottom, requiredBottom);
35178
+ } else {
35179
+ next.pendingBottomMargin = nextBottom;
35180
+ }
34954
35181
  if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
34955
35182
  if (block.orientation) next.pendingOrientation = block.orientation;
34956
35183
  const sectionType = block.type ?? "continuous";
@@ -35701,10 +35928,6 @@ const resolveTrackedChangesEnabled = (attrs, defaultEnabled = true) => {
35701
35928
  }
35702
35929
  return attrs.trackedChangesEnabled !== false;
35703
35930
  };
35704
- const MAX_CACHE_SIZE$1 = 1e4;
35705
- const BYTES_PER_ENTRY_ESTIMATE = 5e3;
35706
- const NORMALIZED_WHITESPACE = /\s+/g;
35707
- const normalizeText = (text) => text.replace(NORMALIZED_WHITESPACE, " ");
35708
35931
  const hashParagraphBorder = (border) => {
35709
35932
  const parts = [];
35710
35933
  if (border.style !== void 0) parts.push(`s:${border.style}`);
@@ -35721,6 +35944,53 @@ const hashParagraphBorders = (borders) => {
35721
35944
  if (borders.left) parts.push(`l:[${hashParagraphBorder(borders.left)}]`);
35722
35945
  return parts.join(";");
35723
35946
  };
35947
+ function isNoneBorder(value) {
35948
+ return typeof value === "object" && value !== null && "none" in value && value.none === true;
35949
+ }
35950
+ function isBorderSpec(value) {
35951
+ return typeof value === "object" && value !== null && !("none" in value);
35952
+ }
35953
+ const hashBorderSpec = (border) => {
35954
+ const parts = [];
35955
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
35956
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
35957
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
35958
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
35959
+ return parts.join(",");
35960
+ };
35961
+ const hashTableBorderValue = (borderValue) => {
35962
+ if (borderValue === void 0) return "";
35963
+ if (borderValue === null) return "null";
35964
+ if (isNoneBorder(borderValue)) return "none";
35965
+ if (isBorderSpec(borderValue)) {
35966
+ return hashBorderSpec(borderValue);
35967
+ }
35968
+ return "";
35969
+ };
35970
+ const hashTableBorders = (borders) => {
35971
+ if (!borders) return "";
35972
+ const parts = [];
35973
+ if (borders.top !== void 0) parts.push(`t:[${hashTableBorderValue(borders.top)}]`);
35974
+ if (borders.right !== void 0) parts.push(`r:[${hashTableBorderValue(borders.right)}]`);
35975
+ if (borders.bottom !== void 0) parts.push(`b:[${hashTableBorderValue(borders.bottom)}]`);
35976
+ if (borders.left !== void 0) parts.push(`l:[${hashTableBorderValue(borders.left)}]`);
35977
+ if (borders.insideH !== void 0) parts.push(`ih:[${hashTableBorderValue(borders.insideH)}]`);
35978
+ if (borders.insideV !== void 0) parts.push(`iv:[${hashTableBorderValue(borders.insideV)}]`);
35979
+ return parts.join(";");
35980
+ };
35981
+ const hashCellBorders = (borders) => {
35982
+ if (!borders) return "";
35983
+ const parts = [];
35984
+ if (borders.top) parts.push(`t:[${hashBorderSpec(borders.top)}]`);
35985
+ if (borders.right) parts.push(`r:[${hashBorderSpec(borders.right)}]`);
35986
+ if (borders.bottom) parts.push(`b:[${hashBorderSpec(borders.bottom)}]`);
35987
+ if (borders.left) parts.push(`l:[${hashBorderSpec(borders.left)}]`);
35988
+ return parts.join(";");
35989
+ };
35990
+ const MAX_CACHE_SIZE$1 = 1e4;
35991
+ const BYTES_PER_ENTRY_ESTIMATE = 5e3;
35992
+ const NORMALIZED_WHITESPACE = /\s+/g;
35993
+ const normalizeText = (text) => text.replace(NORMALIZED_WHITESPACE, " ");
35724
35994
  const hashParagraphFrame = (frame) => {
35725
35995
  const parts = [];
35726
35996
  if (frame.wrap !== void 0) parts.push(`w:${frame.wrap}`);
@@ -35744,6 +36014,26 @@ const hashRuns = (block) => {
35744
36014
  continue;
35745
36015
  }
35746
36016
  for (const cell of row.cells) {
36017
+ if (cell.attrs) {
36018
+ const cellAttrs = cell.attrs;
36019
+ const cellAttrParts = [];
36020
+ if (cellAttrs.borders) {
36021
+ cellAttrParts.push(`cb:${hashCellBorders(cellAttrs.borders)}`);
36022
+ }
36023
+ if (cellAttrs.padding) {
36024
+ const p = cellAttrs.padding;
36025
+ cellAttrParts.push(`cp:${p.top ?? 0}:${p.right ?? 0}:${p.bottom ?? 0}:${p.left ?? 0}`);
36026
+ }
36027
+ if (cellAttrs.verticalAlign) {
36028
+ cellAttrParts.push(`va:${cellAttrs.verticalAlign}`);
36029
+ }
36030
+ if (cellAttrs.background) {
36031
+ cellAttrParts.push(`bg:${cellAttrs.background}`);
36032
+ }
36033
+ if (cellAttrParts.length > 0) {
36034
+ cellHashes.push(`ca:${cellAttrParts.join(":")}`);
36035
+ }
36036
+ }
35747
36037
  const cellBlocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
35748
36038
  for (const cellBlock of cellBlocks) {
35749
36039
  const paragraphBlock = cellBlock;
@@ -35757,12 +36047,14 @@ const hashRuns = (block) => {
35757
36047
  const color = "color" in run ? run.color : void 0;
35758
36048
  const fontSize = "fontSize" in run ? run.fontSize : void 0;
35759
36049
  const fontFamily = "fontFamily" in run ? run.fontFamily : void 0;
36050
+ const highlight = "highlight" in run ? run.highlight : void 0;
35760
36051
  const marks = [
35761
36052
  bold ? "b" : "",
35762
36053
  italic ? "i" : "",
35763
36054
  color ?? "",
35764
36055
  fontSize !== void 0 ? `fs:${fontSize}` : "",
35765
- fontFamily ? `ff:${fontFamily}` : ""
36056
+ fontFamily ? `ff:${fontFamily}` : "",
36057
+ highlight ? `hl:${highlight}` : ""
35766
36058
  ].join("");
35767
36059
  let trackedKey = "";
35768
36060
  if (hasTrackedChange(run)) {
@@ -35773,11 +36065,60 @@ const hashRuns = (block) => {
35773
36065
  }
35774
36066
  cellHashes.push(`${text}:${marks}${trackedKey}`);
35775
36067
  }
36068
+ if (paragraphBlock.attrs) {
36069
+ const attrs = paragraphBlock.attrs;
36070
+ const parts = [];
36071
+ if (attrs.alignment) parts.push(`al:${attrs.alignment}`);
36072
+ if (attrs.spacing) {
36073
+ const s2 = attrs.spacing;
36074
+ if (s2.before !== void 0) parts.push(`sb:${s2.before}`);
36075
+ if (s2.after !== void 0) parts.push(`sa:${s2.after}`);
36076
+ if (s2.line !== void 0) parts.push(`sl:${s2.line}`);
36077
+ if (s2.lineRule) parts.push(`sr:${s2.lineRule}`);
36078
+ }
36079
+ if (attrs.indent) {
36080
+ const ind = attrs.indent;
36081
+ if (ind.left !== void 0) parts.push(`il:${ind.left}`);
36082
+ if (ind.right !== void 0) parts.push(`ir:${ind.right}`);
36083
+ if (ind.firstLine !== void 0) parts.push(`if:${ind.firstLine}`);
36084
+ if (ind.hanging !== void 0) parts.push(`ih:${ind.hanging}`);
36085
+ }
36086
+ if (attrs.borders) {
36087
+ parts.push(`br:${hashParagraphBorders(attrs.borders)}`);
36088
+ }
36089
+ if (attrs.shading) {
36090
+ const sh = attrs.shading;
36091
+ if (sh.fill) parts.push(`shf:${sh.fill}`);
36092
+ if (sh.color) parts.push(`shc:${sh.color}`);
36093
+ }
36094
+ if (attrs.direction) parts.push(`dir:${attrs.direction}`);
36095
+ if (attrs.rtl) parts.push("rtl");
36096
+ if (parts.length > 0) {
36097
+ cellHashes.push(`pa:${parts.join(":")}`);
36098
+ }
36099
+ }
35776
36100
  }
35777
36101
  }
35778
36102
  }
36103
+ let tableAttrsKey = "";
36104
+ if (tableBlock.attrs) {
36105
+ const tblAttrs = tableBlock.attrs;
36106
+ const tableAttrParts = [];
36107
+ if (tblAttrs.borders) {
36108
+ tableAttrParts.push(`tb:${hashTableBorders(tblAttrs.borders)}`);
36109
+ }
36110
+ if (tblAttrs.borderCollapse) {
36111
+ tableAttrParts.push(`bc:${tblAttrs.borderCollapse}`);
36112
+ }
36113
+ if (tblAttrs.cellSpacing !== void 0) {
36114
+ tableAttrParts.push(`cs:${tblAttrs.cellSpacing}`);
36115
+ }
36116
+ if (tableAttrParts.length > 0) {
36117
+ tableAttrsKey = `|ta:${tableAttrParts.join(":")}`;
36118
+ }
36119
+ }
35779
36120
  const contentHash = cellHashes.join("|");
35780
- return `${block.id}:table:${contentHash}`;
36121
+ return `${block.id}:table:${contentHash}${tableAttrsKey}`;
35781
36122
  }
35782
36123
  if (block.kind !== "paragraph") return block.id;
35783
36124
  const trackedMode = block.attrs && "trackedChangesMode" in block.attrs && block.attrs.trackedChangesMode || "review";
@@ -35796,12 +36137,14 @@ const hashRuns = (block) => {
35796
36137
  const color = "color" in run ? run.color : void 0;
35797
36138
  const fontSize = "fontSize" in run ? run.fontSize : void 0;
35798
36139
  const fontFamily = "fontFamily" in run ? run.fontFamily : void 0;
36140
+ const highlight = "highlight" in run ? run.highlight : void 0;
35799
36141
  const marks = [
35800
36142
  bold ? "b" : "",
35801
36143
  italic ? "i" : "",
35802
36144
  color ?? "",
35803
36145
  fontSize !== void 0 ? `fs:${fontSize}` : "",
35804
- fontFamily ? `ff:${fontFamily}` : ""
36146
+ fontFamily ? `ff:${fontFamily}` : "",
36147
+ highlight ? `hl:${highlight}` : ""
35805
36148
  ].join("");
35806
36149
  let trackedKey = "";
35807
36150
  if (hasTrackedChange(run)) {
@@ -36928,7 +37271,7 @@ const paragraphBlocksEqual = (a, b) => {
36928
37271
  for (let i = 0; i < a.runs.length; i += 1) {
36929
37272
  const runA = a.runs[i];
36930
37273
  const runB = b.runs[i];
36931
- 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) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
37274
+ 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) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || ("highlight" in runA ? runA.highlight : void 0) !== ("highlight" in runB ? runB.highlight : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
36932
37275
  return false;
36933
37276
  }
36934
37277
  }
@@ -37297,17 +37640,67 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
37297
37640
  for (const [type, value] of Object.entries(preHeaderLayouts)) {
37298
37641
  if (!isValidHeaderType(type)) continue;
37299
37642
  if (value?.layout && typeof value.layout.height === "number") {
37300
- headerContentHeights[type] = value.layout.height;
37643
+ const height = value.layout.height;
37644
+ if (Number.isFinite(height) && height >= 0) {
37645
+ headerContentHeights[type] = height;
37646
+ }
37301
37647
  }
37302
37648
  }
37303
37649
  const hfPreEnd = performance.now();
37304
37650
  perfLog(`[Perf] 4.1.5 Pre-layout headers for height: ${(hfPreEnd - hfPreStart).toFixed(2)}ms`);
37305
37651
  }
37652
+ let footerContentHeights;
37653
+ if (headerFooter?.constraints && headerFooter.footerBlocks) {
37654
+ const footerPreStart = performance.now();
37655
+ const measureFn = headerFooter.measure ?? measureBlock2;
37656
+ if (!headerFooter.headerBlocks) {
37657
+ invalidateHeaderFooterCache(
37658
+ headerMeasureCache,
37659
+ headerFooterCacheState,
37660
+ headerFooter.headerBlocks,
37661
+ headerFooter.footerBlocks,
37662
+ headerFooter.constraints,
37663
+ options.sectionMetadata
37664
+ );
37665
+ }
37666
+ const FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT = 1;
37667
+ try {
37668
+ const preFooterLayouts = await layoutHeaderFooterWithCache(
37669
+ headerFooter.footerBlocks,
37670
+ headerFooter.constraints,
37671
+ measureFn,
37672
+ headerMeasureCache,
37673
+ FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
37674
+ void 0
37675
+ // No page resolver needed for height calculation
37676
+ );
37677
+ const isValidFooterType = (key2) => {
37678
+ return ["default", "first", "even", "odd"].includes(key2);
37679
+ };
37680
+ footerContentHeights = {};
37681
+ for (const [type, value] of Object.entries(preFooterLayouts)) {
37682
+ if (!isValidFooterType(type)) continue;
37683
+ if (value?.layout && typeof value.layout.height === "number") {
37684
+ const height = value.layout.height;
37685
+ if (Number.isFinite(height) && height >= 0) {
37686
+ footerContentHeights[type] = height;
37687
+ }
37688
+ }
37689
+ }
37690
+ } catch (error) {
37691
+ console.error("[Layout] Footer pre-layout failed:", error);
37692
+ footerContentHeights = void 0;
37693
+ }
37694
+ const footerPreEnd = performance.now();
37695
+ perfLog(`[Perf] 4.1.6 Pre-layout footers for height: ${(footerPreEnd - footerPreStart).toFixed(2)}ms`);
37696
+ }
37306
37697
  const layoutStart = performance.now();
37307
37698
  let layout = layoutDocument(nextBlocks, measures, {
37308
37699
  ...options,
37309
37700
  headerContentHeights,
37310
37701
  // Pass header heights to prevent overlap
37702
+ footerContentHeights,
37703
+ // Pass footer heights to prevent overlap
37311
37704
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
37312
37705
  });
37313
37706
  const layoutEnd = performance.now();
@@ -37356,6 +37749,8 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
37356
37749
  ...options,
37357
37750
  headerContentHeights,
37358
37751
  // Pass header heights to prevent overlap
37752
+ footerContentHeights,
37753
+ // Pass footer heights to prevent overlap
37359
37754
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
37360
37755
  });
37361
37756
  const relayoutEnd = performance.now();
@@ -37522,6 +37917,285 @@ async function remeasureAffectedBlocks(blocks, measures, affectedBlockIds, const
37522
37917
  }
37523
37918
  return updatedMeasures;
37524
37919
  }
37920
+ class PageGeometryHelper {
37921
+ /**
37922
+ * Creates a new PageGeometryHelper instance.
37923
+ *
37924
+ * @param config - Page geometry configuration
37925
+ */
37926
+ constructor(config) {
37927
+ this.cache = null;
37928
+ this.config = config;
37929
+ }
37930
+ /**
37931
+ * Updates the layout and invalidates the cache.
37932
+ *
37933
+ * Call this whenever the layout changes (new pages, different heights, etc.)
37934
+ *
37935
+ * @param layout - New layout data
37936
+ * @param pageGap - Optional new page gap (if not provided, uses current gap)
37937
+ */
37938
+ updateLayout(layout, pageGap) {
37939
+ this.config.layout = layout;
37940
+ if (pageGap !== void 0) {
37941
+ this.config.pageGap = pageGap;
37942
+ }
37943
+ this.cache = null;
37944
+ }
37945
+ /**
37946
+ * Updates the page gap and invalidates the cache.
37947
+ *
37948
+ * @param pageGap - New gap between pages in pixels
37949
+ */
37950
+ updatePageGap(pageGap) {
37951
+ if (this.config.pageGap !== pageGap) {
37952
+ this.config.pageGap = pageGap;
37953
+ this.cache = null;
37954
+ }
37955
+ }
37956
+ /**
37957
+ * Gets the cumulative Y position (top edge) of a page in container space.
37958
+ *
37959
+ * The returned value is the distance from the top of the container to the
37960
+ * top of the specified page, accounting for all previous pages and gaps.
37961
+ *
37962
+ * @param pageIndex - Zero-based page index
37963
+ * @returns Y position in pixels, or 0 if page index is invalid
37964
+ *
37965
+ * @example
37966
+ * ```typescript
37967
+ * // Get Y position of page 0 (first page)
37968
+ * const y0 = helper.getPageTop(0); // Returns 0
37969
+ *
37970
+ * // Get Y position of page 2 (third page)
37971
+ * // Assumes page 0 height = 1000, page 1 height = 1200, gap = 24
37972
+ * const y2 = helper.getPageTop(2); // Returns 1000 + 24 + 1200 + 24 = 2248
37973
+ * ```
37974
+ */
37975
+ getPageTop(pageIndex) {
37976
+ this.ensureCache();
37977
+ if (pageIndex < 0 || pageIndex >= this.cache.cumulativeY.length) {
37978
+ return 0;
37979
+ }
37980
+ return this.cache.cumulativeY[pageIndex];
37981
+ }
37982
+ /**
37983
+ * Gets the height of a specific page.
37984
+ *
37985
+ * Uses per-page height if available (from layout.pages[i].size?.h),
37986
+ * otherwise falls back to layout.pageSize.h.
37987
+ *
37988
+ * @param pageIndex - Zero-based page index
37989
+ * @returns Page height in pixels, or 0 if page index is invalid
37990
+ *
37991
+ * @example
37992
+ * ```typescript
37993
+ * const height = helper.getPageHeight(0); // Returns page-specific height
37994
+ * ```
37995
+ */
37996
+ getPageHeight(pageIndex) {
37997
+ this.ensureCache();
37998
+ if (pageIndex < 0 || pageIndex >= this.cache.pageHeights.length) {
37999
+ return 0;
38000
+ }
38001
+ return this.cache.pageHeights[pageIndex];
38002
+ }
38003
+ /**
38004
+ * Gets the gap between pages.
38005
+ *
38006
+ * @returns Gap in pixels
38007
+ *
38008
+ * @example
38009
+ * ```typescript
38010
+ * const gap = helper.getPageGap(); // Returns 24
38011
+ * ```
38012
+ */
38013
+ getPageGap() {
38014
+ this.ensureCache();
38015
+ return this.cache.pageGap;
38016
+ }
38017
+ /**
38018
+ * Gets the total height of all pages including gaps.
38019
+ *
38020
+ * Total height = sum of all page heights + (pageCount - 1) * gap
38021
+ *
38022
+ * @returns Total height in pixels
38023
+ *
38024
+ * @example
38025
+ * ```typescript
38026
+ * // 3 pages: heights [1000, 1200, 1000], gap = 24
38027
+ * const total = helper.getTotalHeight();
38028
+ * // Returns 1000 + 24 + 1200 + 24 + 1000 = 3248
38029
+ * ```
38030
+ */
38031
+ getTotalHeight() {
38032
+ this.ensureCache();
38033
+ return this.cache.totalHeight;
38034
+ }
38035
+ /**
38036
+ * Gets the number of pages in the layout.
38037
+ *
38038
+ * @returns Page count
38039
+ */
38040
+ getPageCount() {
38041
+ return this.config.layout.pages.length;
38042
+ }
38043
+ /**
38044
+ * Finds the page index containing a given Y coordinate.
38045
+ *
38046
+ * This performs a linear search through cached cumulative positions.
38047
+ * For large documents, consider adding binary search optimization.
38048
+ *
38049
+ * @param containerY - Y coordinate in container space
38050
+ * @returns Page index, or null if Y is outside all pages
38051
+ *
38052
+ * @example
38053
+ * ```typescript
38054
+ * // Find which page contains Y = 1500
38055
+ * const pageIndex = helper.getPageIndexAtY(1500);
38056
+ * // Returns 1 (second page) if first page ends at Y=1024
38057
+ * ```
38058
+ */
38059
+ getPageIndexAtY(containerY) {
38060
+ this.ensureCache();
38061
+ const cache2 = this.cache;
38062
+ for (let i = 0; i < cache2.cumulativeY.length; i++) {
38063
+ const pageTop = cache2.cumulativeY[i];
38064
+ const pageBottom = pageTop + cache2.pageHeights[i];
38065
+ if (containerY >= pageTop && containerY < pageBottom) {
38066
+ return i;
38067
+ }
38068
+ }
38069
+ return null;
38070
+ }
38071
+ /**
38072
+ * Finds the nearest page index to a given Y coordinate (snap-to-nearest).
38073
+ *
38074
+ * Returns the page containing Y when inside a page; otherwise returns the
38075
+ * closest page based on distance to page center. Useful for dragging through
38076
+ * page gaps where getPageIndexAtY would return null.
38077
+ *
38078
+ * @param containerY - Y coordinate in container space
38079
+ * @returns Nearest page index, or null if there are no pages
38080
+ */
38081
+ getNearestPageIndex(containerY) {
38082
+ this.ensureCache();
38083
+ const cache2 = this.cache;
38084
+ const pageCount = cache2.pageHeights.length;
38085
+ if (pageCount === 0) return null;
38086
+ const direct = this.getPageIndexAtY(containerY);
38087
+ if (direct !== null) return direct;
38088
+ let nearestIndex = 0;
38089
+ let nearestDistance = Infinity;
38090
+ for (let i = 0; i < pageCount; i++) {
38091
+ const top2 = cache2.cumulativeY[i];
38092
+ const height = cache2.pageHeights[i];
38093
+ const center = top2 + height / 2;
38094
+ const distance = Math.abs(containerY - center);
38095
+ if (distance < nearestDistance) {
38096
+ nearestDistance = distance;
38097
+ nearestIndex = i;
38098
+ }
38099
+ }
38100
+ return nearestIndex;
38101
+ }
38102
+ /**
38103
+ * Ensures the cache is built and up-to-date.
38104
+ * Validates cache state and rebuilds if needed.
38105
+ * @private
38106
+ * @throws Never throws - handles errors gracefully with fallback values
38107
+ */
38108
+ ensureCache() {
38109
+ if (this.cache !== null) {
38110
+ if (!Array.isArray(this.cache.cumulativeY) || !Array.isArray(this.cache.pageHeights)) {
38111
+ console.warn("[PageGeometryHelper] Cache corruption detected, rebuilding cache");
38112
+ this.cache = null;
38113
+ } else {
38114
+ return;
38115
+ }
38116
+ }
38117
+ this.buildCache();
38118
+ }
38119
+ /**
38120
+ * Builds the geometry cache from current layout data.
38121
+ * Handles errors gracefully by providing fallback values.
38122
+ * @private
38123
+ * @throws Never throws - catches all errors and provides safe defaults
38124
+ */
38125
+ buildCache() {
38126
+ try {
38127
+ const layout = this.config.layout;
38128
+ if (!layout || !Array.isArray(layout.pages)) {
38129
+ throw new Error("Invalid layout: missing or invalid pages array");
38130
+ }
38131
+ const pageGap = this.config.pageGap ?? layout.pageGap ?? 0;
38132
+ const pageCount = layout.pages.length;
38133
+ if (!Number.isFinite(pageGap) || pageGap < 0) {
38134
+ throw new Error(`Invalid pageGap: ${pageGap} (must be non-negative finite number)`);
38135
+ }
38136
+ const cumulativeY = new Array(pageCount);
38137
+ const pageHeights = new Array(pageCount);
38138
+ let currentY = 0;
38139
+ for (let i = 0; i < pageCount; i++) {
38140
+ const page = layout.pages[i];
38141
+ if (!page) {
38142
+ throw new Error(`Invalid page at index ${i}: page is null or undefined`);
38143
+ }
38144
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
38145
+ if (!Number.isFinite(pageHeight) || pageHeight < 0) {
38146
+ throw new Error(`Invalid page height at index ${i}: ${pageHeight} (must be non-negative finite number)`);
38147
+ }
38148
+ cumulativeY[i] = currentY;
38149
+ pageHeights[i] = pageHeight;
38150
+ currentY += pageHeight;
38151
+ if (i < pageCount - 1) {
38152
+ currentY += pageGap;
38153
+ }
38154
+ }
38155
+ const totalHeight = currentY;
38156
+ this.cache = {
38157
+ cumulativeY,
38158
+ pageHeights,
38159
+ pageGap,
38160
+ totalHeight,
38161
+ layoutVersion: 0
38162
+ // Placeholder for future version tracking
38163
+ };
38164
+ } catch (error) {
38165
+ const errorMessage = error instanceof Error ? error.message : String(error);
38166
+ console.error(`[PageGeometryHelper] Cache build failed: ${errorMessage}. Using fallback empty cache.`);
38167
+ this.cache = {
38168
+ cumulativeY: [],
38169
+ pageHeights: [],
38170
+ pageGap: 0,
38171
+ totalHeight: 0,
38172
+ layoutVersion: 0
38173
+ };
38174
+ }
38175
+ }
38176
+ /**
38177
+ * Clears the cache, forcing recalculation on next access.
38178
+ * Useful for testing or manual cache invalidation.
38179
+ */
38180
+ clearCache() {
38181
+ this.cache = null;
38182
+ }
38183
+ /**
38184
+ * Gets debug information about the current cache state.
38185
+ * @internal
38186
+ */
38187
+ getDebugInfo() {
38188
+ this.ensureCache();
38189
+ return {
38190
+ isCached: this.cache !== null,
38191
+ pageCount: this.config.layout.pages.length,
38192
+ pageGap: this.cache.pageGap,
38193
+ totalHeight: this.cache.totalHeight,
38194
+ cumulativeY: [...this.cache.cumulativeY],
38195
+ pageHeights: [...this.cache.pageHeights]
38196
+ };
38197
+ }
38198
+ }
37525
38199
  var Priority = /* @__PURE__ */ ((Priority2) => {
37526
38200
  Priority2[Priority2["P0"] = 0] = "P0";
37527
38201
  Priority2[Priority2["P1"] = 1] = "P1";
@@ -37815,18 +38489,41 @@ const rangesOverlap = (startA, endA, startB, endB) => {
37815
38489
  const effectiveEndA = endA ?? startA + 1;
37816
38490
  return effectiveEndA > startB && startA < endB;
37817
38491
  };
37818
- function hitTestPage(layout, point) {
38492
+ function hitTestPage(layout, point, geometryHelper) {
38493
+ if (geometryHelper) {
38494
+ const pageIndex = geometryHelper.getPageIndexAtY(point.y);
38495
+ if (pageIndex !== null) {
38496
+ return { pageIndex, page: layout.pages[pageIndex] };
38497
+ }
38498
+ const nearest = geometryHelper.getNearestPageIndex(point.y);
38499
+ if (nearest !== null) {
38500
+ return { pageIndex: nearest, page: layout.pages[nearest] };
38501
+ }
38502
+ return null;
38503
+ }
37819
38504
  const pageGap = layout.pageGap ?? 0;
37820
38505
  let cursorY = 0;
38506
+ let nearestIndex = null;
38507
+ let nearestDistance = Infinity;
37821
38508
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
37822
38509
  const page = layout.pages[pageIndex];
38510
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
37823
38511
  const top2 = cursorY;
37824
- const bottom2 = top2 + layout.pageSize.h;
38512
+ const bottom2 = top2 + pageHeight;
37825
38513
  if (point.y >= top2 && point.y < bottom2) {
37826
38514
  return { pageIndex, page };
37827
38515
  }
38516
+ const center = top2 + pageHeight / 2;
38517
+ const distance = Math.abs(point.y - center);
38518
+ if (distance < nearestDistance) {
38519
+ nearestDistance = distance;
38520
+ nearestIndex = pageIndex;
38521
+ }
37828
38522
  cursorY = bottom2 + pageGap;
37829
38523
  }
38524
+ if (nearestIndex !== null) {
38525
+ return { pageIndex: nearestIndex, page: layout.pages[nearestIndex] };
38526
+ }
37830
38527
  return null;
37831
38528
  }
37832
38529
  function hitTestFragment(layout, pageHit, blocks, measures, point) {
@@ -37987,7 +38684,7 @@ const hitTestTableFragment = (pageHit, blocks, measures, point) => {
37987
38684
  }
37988
38685
  return null;
37989
38686
  };
37990
- function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY) {
38687
+ function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY, geometryHelper) {
37991
38688
  logClickStage("log", "entry", {
37992
38689
  pages: layout.pages.length
37993
38690
  });
@@ -38030,75 +38727,132 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
38030
38727
  return { pos: domPos, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
38031
38728
  }
38032
38729
  }
38033
- const pageHit = hitTestPage(layout, containerPoint);
38730
+ const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
38034
38731
  if (!pageHit) {
38035
38732
  return null;
38036
38733
  }
38037
- const pageGap = layout.pageGap ?? 0;
38734
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
38038
38735
  const pageRelativePoint = {
38039
38736
  x: containerPoint.x,
38040
- y: containerPoint.y - pageHit.pageIndex * (layout.pageSize.h + pageGap)
38737
+ y: containerPoint.y - pageTopY
38041
38738
  };
38042
38739
  logClickStage("log", "page-hit", {
38043
38740
  pageIndex: pageHit.pageIndex
38044
38741
  });
38045
- const fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
38742
+ let fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
38743
+ if (!fragmentHit) {
38744
+ const page = pageHit.page;
38745
+ const fragments = page.fragments.filter(
38746
+ (f2) => f2 != null && typeof f2 === "object"
38747
+ );
38748
+ if (fragments.length > 0) {
38749
+ let nearest = null;
38750
+ let nearestDist = Infinity;
38751
+ for (const frag of fragments) {
38752
+ const top2 = frag.y;
38753
+ const bottom2 = frag.y + frag.height;
38754
+ let dist;
38755
+ if (pageRelativePoint.y < top2) {
38756
+ dist = top2 - pageRelativePoint.y;
38757
+ } else if (pageRelativePoint.y > bottom2) {
38758
+ dist = pageRelativePoint.y - bottom2;
38759
+ } else {
38760
+ dist = 0;
38761
+ }
38762
+ if (dist < nearestDist) {
38763
+ nearestDist = dist;
38764
+ nearest = frag;
38765
+ }
38766
+ }
38767
+ if (nearest) {
38768
+ const blockIndex = findBlockIndexByFragmentId(blocks, nearest.blockId);
38769
+ if (blockIndex !== -1) {
38770
+ const block = blocks[blockIndex];
38771
+ const measure = measures[blockIndex];
38772
+ if (block && measure) {
38773
+ fragmentHit = {
38774
+ fragment: nearest,
38775
+ block,
38776
+ measure,
38777
+ pageIndex: pageHit.pageIndex,
38778
+ pageY: 0
38779
+ };
38780
+ }
38781
+ }
38782
+ }
38783
+ }
38784
+ }
38046
38785
  if (fragmentHit) {
38047
38786
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
38048
- if (fragment.kind !== "para" || measure.kind !== "paragraph" || block.kind !== "paragraph") {
38049
- logClickStage("warn", "fragment-type-mismatch", {
38050
- fragmentKind: fragment.kind,
38051
- measureKind: measure.kind,
38052
- blockKind: block.kind
38787
+ if (fragment.kind === "para" && measure.kind === "paragraph" && block.kind === "paragraph") {
38788
+ const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
38789
+ if (lineIndex == null) {
38790
+ logClickStage("warn", "no-line", {
38791
+ blockId: fragment.blockId
38792
+ });
38793
+ return null;
38794
+ }
38795
+ const line = measure.lines[lineIndex];
38796
+ const isRTL = isRtlBlock(block);
38797
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
38798
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
38799
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
38800
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
38801
+ const totalIndent = paraIndentLeft + paraIndentRight;
38802
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
38803
+ if (totalIndent > fragment.width) {
38804
+ console.warn(
38805
+ `[clickToPosition] Paragraph indents (${totalIndent}px) exceed fragment width (${fragment.width}px) for block ${fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`
38806
+ );
38807
+ }
38808
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
38809
+ const isListItem3 = markerWidth > 0;
38810
+ const alignmentOverride = isListItem3 ? "left" : void 0;
38811
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
38812
+ if (pos == null) {
38813
+ logClickStage("warn", "no-position", {
38814
+ blockId: fragment.blockId
38815
+ });
38816
+ return null;
38817
+ }
38818
+ const column = determineColumn(layout, fragment.x);
38819
+ logPositionDebug({
38820
+ blockId: fragment.blockId,
38821
+ x: pageRelativePoint.x - fragment.x
38053
38822
  });
38054
- return null;
38055
- }
38056
- const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
38057
- if (lineIndex == null) {
38058
- logClickStage("warn", "no-line", {
38823
+ logClickStage("log", "success", {
38059
38824
  blockId: fragment.blockId
38060
38825
  });
38061
- return null;
38062
- }
38063
- const line = measure.lines[lineIndex];
38064
- const isRTL = isRtlBlock(block);
38065
- const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
38066
- const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
38067
- const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
38068
- const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
38069
- const totalIndent = paraIndentLeft + paraIndentRight;
38070
- const availableWidth = Math.max(0, fragment.width - totalIndent);
38071
- if (totalIndent > fragment.width) {
38072
- console.warn(
38073
- `[clickToPosition] Paragraph indents (${totalIndent}px) exceed fragment width (${fragment.width}px) for block ${fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`
38074
- );
38826
+ return {
38827
+ pos,
38828
+ blockId: fragment.blockId,
38829
+ pageIndex,
38830
+ column,
38831
+ lineIndex
38832
+ // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
38833
+ };
38075
38834
  }
38076
- const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
38077
- const isListItem3 = markerWidth > 0;
38078
- const alignmentOverride = isListItem3 ? "left" : void 0;
38079
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
38080
- if (pos == null) {
38081
- logClickStage("warn", "no-position", {
38082
- blockId: fragment.blockId
38835
+ if (isAtomicFragment(fragment)) {
38836
+ const pmRange = getAtomicPmRange(fragment, block);
38837
+ const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
38838
+ if (pos == null) {
38839
+ logClickStage("warn", "atomic-without-range", {
38840
+ fragmentId: fragment.blockId
38841
+ });
38842
+ return null;
38843
+ }
38844
+ logClickStage("log", "success", {
38845
+ blockId: fragment.blockId,
38846
+ column: determineColumn(layout, fragment.x)
38083
38847
  });
38084
- return null;
38848
+ return {
38849
+ pos,
38850
+ blockId: fragment.blockId,
38851
+ pageIndex,
38852
+ column: determineColumn(layout, fragment.x),
38853
+ lineIndex: -1
38854
+ };
38085
38855
  }
38086
- const column = determineColumn(layout, fragment.x);
38087
- logPositionDebug({
38088
- blockId: fragment.blockId,
38089
- x: pageRelativePoint.x - fragment.x
38090
- });
38091
- logClickStage("log", "success", {
38092
- blockId: fragment.blockId
38093
- });
38094
- return {
38095
- pos,
38096
- blockId: fragment.blockId,
38097
- pageIndex,
38098
- column,
38099
- lineIndex
38100
- // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
38101
- };
38102
38856
  }
38103
38857
  const tableHit = hitTestTableFragment(pageHit, blocks, measures, pageRelativePoint);
38104
38858
  if (tableHit) {
@@ -38248,12 +39002,22 @@ const sumLineHeights = (measure, fromLine, toLine) => {
38248
39002
  }
38249
39003
  return height;
38250
39004
  };
38251
- function selectionToRects(layout, blocks, measures, from2, to) {
39005
+ const calculatePageTopFallback = (layout, pageIndex) => {
39006
+ const pageGap = layout.pageGap ?? 0;
39007
+ let y = 0;
39008
+ for (let i = 0; i < pageIndex; i++) {
39009
+ const pageHeight = layout.pages[i]?.size?.h ?? layout.pageSize.h;
39010
+ y += pageHeight + pageGap;
39011
+ }
39012
+ return y;
39013
+ };
39014
+ function selectionToRects(layout, blocks, measures, from2, to, geometryHelper) {
38252
39015
  if (from2 === to) {
38253
39016
  return [];
38254
39017
  }
38255
39018
  const rects = [];
38256
39019
  layout.pages.forEach((page, pageIndex) => {
39020
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageIndex) : calculatePageTopFallback(layout, pageIndex);
38257
39021
  page.fragments.forEach((fragment) => {
38258
39022
  if (fragment.kind === "para") {
38259
39023
  const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
@@ -38295,12 +39059,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38295
39059
  wordLayout
38296
39060
  });
38297
39061
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
38298
- const rectWidth = Math.max(1, Math.abs(endX - startX));
39062
+ const rectWidth = Math.max(
39063
+ 1,
39064
+ Math.min(Math.abs(endX - startX), line.width)
39065
+ // clamp to line width to prevent runaway widths
39066
+ );
38299
39067
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
38300
39068
  const rectY = fragment.y + lineOffset;
38301
39069
  rects.push({
38302
39070
  x: rectX,
38303
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
39071
+ y: rectY + pageTopY,
38304
39072
  width: rectWidth,
38305
39073
  height: line.lineHeight,
38306
39074
  pageIndex
@@ -38428,12 +39196,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38428
39196
  wordLayout: cellWordLayout
38429
39197
  });
38430
39198
  const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
38431
- const rectWidth = Math.max(1, Math.abs(endX - startX));
39199
+ const rectWidth = Math.max(
39200
+ 1,
39201
+ Math.min(Math.abs(endX - startX), line.width)
39202
+ // clamp to line width to prevent runaway widths
39203
+ );
38432
39204
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
38433
39205
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
38434
39206
  rects.push({
38435
39207
  x: rectX,
38436
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
39208
+ y: rectY + pageTopY,
38437
39209
  width: rectWidth,
38438
39210
  height: line.lineHeight,
38439
39211
  pageIndex
@@ -38462,7 +39234,7 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38462
39234
  if (!rangesOverlap(pmRange.pmStart, pmRange.pmEnd, from2, to)) return;
38463
39235
  rects.push({
38464
39236
  x: fragment.x,
38465
- y: fragment.y + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
39237
+ y: fragment.y + pageTopY,
38466
39238
  width: fragment.width,
38467
39239
  height: fragment.height,
38468
39240
  pageIndex
@@ -39578,7 +40350,7 @@ async function measureParagraphBlock(block, maxWidth) {
39578
40350
  const wordEndWithSpace = charPosInRun + (isLastWord ? word.length : word.length + 1);
39579
40351
  const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
39580
40352
  if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
39581
- if (currentLine && currentLine.width > 0 && currentLine.segments.length > 0) {
40353
+ if (currentLine && currentLine.width > 0 && currentLine.segments && currentLine.segments.length > 0) {
39582
40354
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39583
40355
  const { spaceCount: _sc, ...lineBase } = currentLine;
39584
40356
  const completedLine = { ...lineBase, ...metrics };
@@ -39589,7 +40361,7 @@ async function measureParagraphBlock(block, maxWidth) {
39589
40361
  currentLine = null;
39590
40362
  }
39591
40363
  const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
39592
- const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
40364
+ const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
39593
40365
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
39594
40366
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
39595
40367
  const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run);
@@ -39600,7 +40372,7 @@ async function measureParagraphBlock(block, maxWidth) {
39600
40372
  const chunkEndChar = chunkCharOffset + chunk.text.length;
39601
40373
  const isLastChunk = chunkIndex === chunks.length - 1;
39602
40374
  const isFirstChunk = chunkIndex === 0;
39603
- if (isFirstChunk && hasTabOnlyLine && currentLine) {
40375
+ if (isFirstChunk && hasTabOnlyLine && currentLine && currentLine.segments) {
39604
40376
  currentLine.toRun = runIndex;
39605
40377
  currentLine.toChar = chunkEndChar;
39606
40378
  currentLine.width = roundValue(currentLine.width + chunk.width);
@@ -40433,6 +41205,7 @@ const createHeaderFooterEditor = ({
40433
41205
  const fontSizeInPixles = fontSizePt * 1.3333;
40434
41206
  const lineHeight = fontSizeInPixles * 1.2;
40435
41207
  applyStyleIsolationClass(editorContainer);
41208
+ const isFooter = type === "footer";
40436
41209
  Object.assign(editorContainer.style, {
40437
41210
  padding: "0",
40438
41211
  margin: "0",
@@ -40447,7 +41220,7 @@ const createHeaderFooterEditor = ({
40447
41220
  fontFamily: fontFamilyCss || typeface,
40448
41221
  fontSize: `${fontSizeInPixles}px`,
40449
41222
  lineHeight: `${lineHeight}px`,
40450
- overflow: "hidden",
41223
+ overflow: isFooter ? "visible" : "hidden",
40451
41224
  pointerEvents: "auto",
40452
41225
  // Critical: enables click interaction
40453
41226
  backgroundColor: "white"
@@ -41585,6 +42358,7 @@ class EditorOverlayManager {
41585
42358
  const editorContainer = __privateGet(this, _activeEditorHost).querySelector(".super-editor");
41586
42359
  if (editorContainer instanceof HTMLElement) {
41587
42360
  editorContainer.style.top = "0";
42361
+ editorContainer.style.transform = "";
41588
42362
  }
41589
42363
  }
41590
42364
  }
@@ -41818,6 +42592,7 @@ const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
41818
42592
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
41819
42593
  const DEFAULT_VIRTUALIZED_PAGE_GAP = 72;
41820
42594
  const DEFAULT_PAGE_GAP = 24;
42595
+ const DEFAULT_HORIZONTAL_PAGE_GAP = 20;
41821
42596
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
41822
42597
  const MULTI_CLICK_TIME_THRESHOLD_MS = 400;
41823
42598
  const MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5;
@@ -41841,6 +42616,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
41841
42616
  __privateAdd(this, _layoutOptions);
41842
42617
  __privateAdd(this, _layoutState, { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() });
41843
42618
  __privateAdd(this, _domPainter, null);
42619
+ __privateAdd(this, _pageGeometryHelper, null);
41844
42620
  __privateAdd(this, _dragHandlerCleanup, null);
41845
42621
  __privateAdd(this, _layoutError, null);
41846
42622
  __privateAdd(this, _layoutErrorState, "healthy");
@@ -42009,7 +42785,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
42009
42785
  { x, y },
42010
42786
  __privateGet(this, _viewportHost),
42011
42787
  event.clientX,
42012
- event.clientY
42788
+ event.clientY,
42789
+ __privateGet(this, _pageGeometryHelper) ?? void 0
42013
42790
  );
42014
42791
  const doc2 = __privateGet(this, _editor3).state?.doc;
42015
42792
  const hit = rawHit && doc2 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc2.content.size)) } : rawHit;
@@ -42208,7 +42985,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
42208
42985
  { x: normalized.x, y: normalized.y },
42209
42986
  __privateGet(this, _viewportHost),
42210
42987
  event.clientX,
42211
- event.clientY
42988
+ event.clientY,
42989
+ __privateGet(this, _pageGeometryHelper) ?? void 0
42212
42990
  );
42213
42991
  if (!hit) return;
42214
42992
  const currentTableHit = __privateMethod(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
@@ -43098,7 +43876,14 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43098
43876
  return __privateMethod(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
43099
43877
  }
43100
43878
  if (!__privateGet(this, _layoutState).layout) return [];
43101
- const rects = selectionToRects(__privateGet(this, _layoutState).layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, start2, end2) ?? [];
43879
+ const rects = selectionToRects(
43880
+ __privateGet(this, _layoutState).layout,
43881
+ __privateGet(this, _layoutState).blocks,
43882
+ __privateGet(this, _layoutState).measures,
43883
+ start2,
43884
+ end2,
43885
+ __privateGet(this, _pageGeometryHelper) ?? void 0
43886
+ ) ?? [];
43102
43887
  return rects;
43103
43888
  };
43104
43889
  const rawRects = layoutRectSource();
@@ -43363,6 +44148,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43363
44148
  };
43364
44149
  }
43365
44150
  __privateSet(this, _domPainter, null);
44151
+ __privateSet(this, _pageGeometryHelper, null);
43366
44152
  __privateSet(this, _pendingDocChange, true);
43367
44153
  __privateMethod(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
43368
44154
  }
@@ -43395,7 +44181,16 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43395
44181
  x: localX,
43396
44182
  y: headerPageIndex * headerPageHeight + (localY - headerPageIndex * headerPageHeight)
43397
44183
  };
43398
- const hit2 = clickToPosition(context.layout, context.blocks, context.measures, headerPoint) ?? null;
44184
+ const hit2 = clickToPosition(
44185
+ context.layout,
44186
+ context.blocks,
44187
+ context.measures,
44188
+ headerPoint,
44189
+ void 0,
44190
+ void 0,
44191
+ void 0,
44192
+ void 0
44193
+ ) ?? null;
43399
44194
  return hit2;
43400
44195
  }
43401
44196
  if (!__privateGet(this, _layoutState).layout) {
@@ -43408,7 +44203,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43408
44203
  normalized,
43409
44204
  __privateGet(this, _viewportHost),
43410
44205
  clientX,
43411
- clientY
44206
+ clientY,
44207
+ __privateGet(this, _pageGeometryHelper) ?? void 0
43412
44208
  ) ?? null;
43413
44209
  return hit;
43414
44210
  }
@@ -43631,6 +44427,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43631
44427
  __privateSet(this, _session, { mode: "body" });
43632
44428
  __privateSet(this, _activeHeaderFooterEditor, null);
43633
44429
  __privateSet(this, _domPainter, null);
44430
+ __privateSet(this, _pageGeometryHelper, null);
43634
44431
  (_a = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a.call(this);
43635
44432
  __privateSet(this, _dragHandlerCleanup, null);
43636
44433
  __privateGet(this, _selectionOverlay2)?.remove();
@@ -43684,7 +44481,14 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43684
44481
  if (!normalized) return false;
43685
44482
  const pmPos = __privateGet(this, _layoutState).bookmarks.get(normalized);
43686
44483
  if (pmPos == null) return false;
43687
- const rects = selectionToRects(layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, pmPos, pmPos + 1) ?? [];
44484
+ const rects = selectionToRects(
44485
+ layout,
44486
+ __privateGet(this, _layoutState).blocks,
44487
+ __privateGet(this, _layoutState).measures,
44488
+ pmPos,
44489
+ pmPos + 1,
44490
+ __privateGet(this, _pageGeometryHelper) ?? void 0
44491
+ ) ?? [];
43688
44492
  const rect = rects[0];
43689
44493
  let pageIndex = rect?.pageIndex ?? null;
43690
44494
  if (pageIndex == null) {
@@ -43748,6 +44552,7 @@ _hiddenHost = new WeakMap();
43748
44552
  _layoutOptions = new WeakMap();
43749
44553
  _layoutState = new WeakMap();
43750
44554
  _domPainter = new WeakMap();
44555
+ _pageGeometryHelper = new WeakMap();
43751
44556
  _dragHandlerCleanup = new WeakMap();
43752
44557
  _layoutError = new WeakMap();
43753
44558
  _layoutErrorState = new WeakMap();
@@ -44032,18 +44837,19 @@ normalizeAwarenessStates_fn = function() {
44032
44837
  const normalized = /* @__PURE__ */ new Map();
44033
44838
  states?.forEach((aw, clientId) => {
44034
44839
  if (clientId === provider.awareness?.clientID) return;
44035
- if (!aw.cursor) return;
44840
+ const awState = aw;
44841
+ if (!awState.cursor) return;
44036
44842
  try {
44037
44843
  const anchor = relativePositionToAbsolutePosition(
44038
44844
  ystate.doc,
44039
44845
  ystate.type,
44040
- Y.createRelativePositionFromJSON(aw.cursor.anchor),
44846
+ Y.createRelativePositionFromJSON(awState.cursor.anchor),
44041
44847
  ystate.binding.mapping
44042
44848
  );
44043
44849
  const head = relativePositionToAbsolutePosition(
44044
44850
  ystate.doc,
44045
44851
  ystate.type,
44046
- Y.createRelativePositionFromJSON(aw.cursor.head),
44852
+ Y.createRelativePositionFromJSON(awState.cursor.head),
44047
44853
  ystate.binding.mapping
44048
44854
  );
44049
44855
  if (anchor === null || head === null) return;
@@ -44055,9 +44861,9 @@ normalizeAwarenessStates_fn = function() {
44055
44861
  normalized.set(clientId, {
44056
44862
  clientId,
44057
44863
  user: {
44058
- name: aw.user?.name,
44059
- email: aw.user?.email,
44060
- color: aw.user?.color || __privateMethod(this, _PresentationEditor_instances, getFallbackColor_fn).call(this, clientId)
44864
+ name: awState.user?.name,
44865
+ email: awState.user?.email,
44866
+ color: awState.user?.color || __privateMethod(this, _PresentationEditor_instances, getFallbackColor_fn).call(this, clientId)
44061
44867
  },
44062
44868
  anchor: clampedAnchor,
44063
44869
  head: clampedHead,
@@ -44379,7 +45185,7 @@ renderRemoteSelection_fn = function(cursor) {
44379
45185
  if (!layout || !blocks || !measures) return;
44380
45186
  const start2 = Math.min(cursor.anchor, cursor.head);
44381
45187
  const end2 = Math.max(cursor.anchor, cursor.head);
44382
- const rects = selectionToRects(layout, blocks, measures, start2, end2) ?? [];
45188
+ const rects = selectionToRects(layout, blocks, measures, start2, end2, __privateGet(this, _pageGeometryHelper) ?? void 0) ?? [];
44383
45189
  const color = __privateMethod(this, _PresentationEditor_instances, getValidatedColor_fn).call(this, cursor);
44384
45190
  const opacity = __privateGet(this, _layoutOptions).presence?.highlightOpacity ?? 0.35;
44385
45191
  const pageHeight = layout.pageSize?.h ?? __privateGet(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
@@ -44872,15 +45678,25 @@ hitTestTable_fn = function(normalizedX, normalizedY) {
44872
45678
  const configuredPageSize = __privateGet(this, _layoutOptions).pageSize ?? DEFAULT_PAGE_SIZE;
44873
45679
  let pageY = 0;
44874
45680
  let pageHit = null;
44875
- for (let i = 0; i < layout.pages.length; i++) {
44876
- const page = layout.pages[i];
44877
- const pageHeight = page.size?.h ?? configuredPageSize.h;
44878
- const gap = __privateGet(this, _layoutOptions).virtualization?.gap ?? DEFAULT_PAGE_GAP;
44879
- if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
44880
- pageHit = { pageIndex: i, page };
44881
- break;
45681
+ const geometryHelper = __privateGet(this, _pageGeometryHelper);
45682
+ if (geometryHelper) {
45683
+ const idx = geometryHelper.getPageIndexAtY(normalizedY) ?? geometryHelper.getNearestPageIndex(normalizedY);
45684
+ if (idx != null && layout.pages[idx]) {
45685
+ pageHit = { pageIndex: idx, page: layout.pages[idx] };
45686
+ pageY = geometryHelper.getPageTop(idx);
45687
+ }
45688
+ }
45689
+ if (!pageHit) {
45690
+ const gap = layout.pageGap ?? __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
45691
+ for (let i = 0; i < layout.pages.length; i++) {
45692
+ const page = layout.pages[i];
45693
+ const pageHeight = page.size?.h ?? configuredPageSize.h;
45694
+ if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
45695
+ pageHit = { pageIndex: i, page };
45696
+ break;
45697
+ }
45698
+ pageY += pageHeight + gap;
44882
45699
  }
44883
- pageY += pageHeight + gap;
44884
45700
  }
44885
45701
  if (!pageHit) {
44886
45702
  return null;
@@ -45192,12 +46008,7 @@ rerender_fn = async function() {
45192
46008
  return;
45193
46009
  }
45194
46010
  ({ layout, measures } = result);
45195
- if (__privateGet(this, _layoutOptions).virtualization?.enabled) {
45196
- const gap = __privateGet(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP;
45197
- layout.pageGap = Math.max(0, gap);
45198
- } else {
45199
- layout.pageGap = DEFAULT_PAGE_GAP;
45200
- }
46011
+ layout.pageGap = __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
45201
46012
  headerLayouts = result.headers;
45202
46013
  footerLayouts = result.footers;
45203
46014
  } catch (error) {
@@ -45214,6 +46025,17 @@ rerender_fn = async function() {
45214
46025
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
45215
46026
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
45216
46027
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
46028
+ if (__privateGet(this, _layoutState).layout) {
46029
+ const pageGap = __privateGet(this, _layoutState).layout.pageGap ?? __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
46030
+ if (!__privateGet(this, _pageGeometryHelper)) {
46031
+ __privateSet(this, _pageGeometryHelper, new PageGeometryHelper({
46032
+ layout: __privateGet(this, _layoutState).layout,
46033
+ pageGap
46034
+ }));
46035
+ } else {
46036
+ __privateGet(this, _pageGeometryHelper).updateLayout(__privateGet(this, _layoutState).layout, pageGap);
46037
+ }
46038
+ }
45217
46039
  await __privateMethod(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
45218
46040
  __privateMethod(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
45219
46041
  const painter = __privateMethod(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks, measures);
@@ -45283,7 +46105,8 @@ ensurePainter_fn = function(blocks, measures) {
45283
46105
  pageStyles: __privateGet(this, _layoutOptions).pageStyles,
45284
46106
  headerProvider: __privateGet(this, _headerDecorationProvider),
45285
46107
  footerProvider: __privateGet(this, _footerDecorationProvider),
45286
- ruler: __privateGet(this, _layoutOptions).ruler
46108
+ ruler: __privateGet(this, _layoutOptions).ruler,
46109
+ pageGap: __privateGet(this, _layoutState).layout?.pageGap ?? __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this)
45287
46110
  }));
45288
46111
  }
45289
46112
  return __privateGet(this, _domPainter);
@@ -45438,7 +46261,14 @@ updateSelection_fn = function() {
45438
46261
  }
45439
46262
  return;
45440
46263
  }
45441
- const rects = selectionToRects(layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, from2, to) ?? [];
46264
+ const rects = selectionToRects(
46265
+ layout,
46266
+ __privateGet(this, _layoutState).blocks,
46267
+ __privateGet(this, _layoutState).measures,
46268
+ from2,
46269
+ to,
46270
+ __privateGet(this, _pageGeometryHelper) ?? void 0
46271
+ ) ?? [];
45442
46272
  let domStart = null;
45443
46273
  let domEnd = null;
45444
46274
  try {
@@ -45452,7 +46282,9 @@ updateSelection_fn = function() {
45452
46282
  const correctedRects = __privateMethod(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
45453
46283
  try {
45454
46284
  __privateGet(this, _localSelectionLayer).innerHTML = "";
45455
- __privateMethod(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
46285
+ if (correctedRects.length > 0) {
46286
+ __privateMethod(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
46287
+ }
45456
46288
  } catch (error) {
45457
46289
  if (process$1.env.NODE_ENV === "development") {
45458
46290
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -45644,8 +46476,10 @@ createDecorationProvider_fn = function(kind, layout) {
45644
46476
  const pageHeight2 = page?.size?.h ?? layout.pageSize?.h ?? __privateGet(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
45645
46477
  const margins2 = pageMargins ?? layout.pages[0]?.margins ?? __privateGet(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
45646
46478
  const box2 = __privateMethod(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, kind, margins2, pageHeight2);
46479
+ const layoutMinY2 = rIdLayout.layout.minY ?? 0;
46480
+ const normalizedFragments2 = layoutMinY2 < 0 ? fragments2.map((f2) => ({ ...f2, y: f2.y - layoutMinY2 })) : fragments2;
45647
46481
  return {
45648
- fragments: fragments2,
46482
+ fragments: normalizedFragments2,
45649
46483
  height: box2.height,
45650
46484
  contentHeight: rIdLayout.layout.height ?? box2.height,
45651
46485
  offset: box2.offset,
@@ -45653,6 +46487,7 @@ createDecorationProvider_fn = function(kind, layout) {
45653
46487
  contentWidth: box2.width,
45654
46488
  headerId: sectionRId,
45655
46489
  sectionType: headerFooterType,
46490
+ minY: layoutMinY2,
45656
46491
  box: {
45657
46492
  x: box2.x,
45658
46493
  y: box2.offset,
@@ -45685,8 +46520,10 @@ createDecorationProvider_fn = function(kind, layout) {
45685
46520
  const box = __privateMethod(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, kind, margins, pageHeight);
45686
46521
  const fallbackId = __privateGet(this, _headerFooterManager)?.getVariantId(kind, headerFooterType);
45687
46522
  const finalHeaderId = sectionRId ?? fallbackId ?? void 0;
46523
+ const layoutMinY = variant.layout.minY ?? 0;
46524
+ const normalizedFragments = layoutMinY < 0 ? fragments.map((f2) => ({ ...f2, y: f2.y - layoutMinY })) : fragments;
45688
46525
  return {
45689
- fragments,
46526
+ fragments: normalizedFragments,
45690
46527
  height: box.height,
45691
46528
  contentHeight: variant.layout.height ?? box.height,
45692
46529
  offset: box.offset,
@@ -45694,6 +46531,7 @@ createDecorationProvider_fn = function(kind, layout) {
45694
46531
  contentWidth: box.width,
45695
46532
  headerId: finalHeaderId,
45696
46533
  sectionType: headerFooterType,
46534
+ minY: layoutMinY,
45697
46535
  box: {
45698
46536
  x: box.x,
45699
46537
  y: box.offset,
@@ -45838,7 +46676,9 @@ rebuildHeaderFooterRegions_fn = function(layout) {
45838
46676
  localX: footerPayload?.hitRegion?.x ?? footerBox.x,
45839
46677
  localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
45840
46678
  width: footerPayload?.hitRegion?.width ?? footerBox.width,
45841
- height: footerPayload?.hitRegion?.height ?? footerBox.height
46679
+ height: footerPayload?.hitRegion?.height ?? footerBox.height,
46680
+ contentHeight: footerPayload?.contentHeight,
46681
+ minY: footerPayload?.minY
45842
46682
  });
45843
46683
  });
45844
46684
  };
@@ -45968,6 +46808,18 @@ enterHeaderFooterMode_fn = async function(region) {
45968
46808
  });
45969
46809
  return;
45970
46810
  }
46811
+ if (region.kind === "footer") {
46812
+ const editorContainer = editorHost.firstElementChild;
46813
+ if (editorContainer instanceof HTMLElement) {
46814
+ editorContainer.style.overflow = "visible";
46815
+ if (region.minY != null && region.minY < 0) {
46816
+ const shiftDown = Math.abs(region.minY);
46817
+ editorContainer.style.transform = `translateY(${shiftDown}px)`;
46818
+ } else {
46819
+ editorContainer.style.transform = "";
46820
+ }
46821
+ }
46822
+ }
45971
46823
  try {
45972
46824
  editor.setEditable(true);
45973
46825
  editor.setOptions({ documentMode: "editing" });
@@ -46285,6 +47137,19 @@ waitForPageMount_fn = async function(pageIndex, options = {}) {
46285
47137
  checkPage();
46286
47138
  });
46287
47139
  };
47140
+ /**
47141
+ * Get effective page gap based on layout mode and virtualization settings.
47142
+ * Keeps painter, layout, and geometry in sync.
47143
+ */
47144
+ getEffectivePageGap_fn = function() {
47145
+ if (__privateGet(this, _layoutOptions).virtualization?.enabled) {
47146
+ return Math.max(0, __privateGet(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP);
47147
+ }
47148
+ if (__privateGet(this, _layoutOptions).layoutMode === "horizontal") {
47149
+ return DEFAULT_HORIZONTAL_PAGE_GAP;
47150
+ }
47151
+ return DEFAULT_PAGE_GAP;
47152
+ };
46288
47153
  getBodyPageHeight_fn = function() {
46289
47154
  return __privateGet(this, _layoutState).layout?.pageSize?.h ?? __privateGet(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
46290
47155
  };
@@ -46337,7 +47202,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
46337
47202
  dy: domStart.y - layoutY
46338
47203
  };
46339
47204
  }
46340
- return rects.map((rect, idx) => {
47205
+ const corrected = rects.map((rect, idx) => {
46341
47206
  const delta = pageDelta[rect.pageIndex];
46342
47207
  let adjustedX = delta ? rect.x + delta.dx : rect.x;
46343
47208
  let adjustedY = delta ? rect.y + delta.dy : rect.y;
@@ -46352,6 +47217,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
46352
47217
  }
46353
47218
  if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
46354
47219
  const endX = domEnd.x;
47220
+ adjustedX = Math.min(adjustedX, endX);
46355
47221
  adjustedWidth = Math.max(1, endX - adjustedX);
46356
47222
  }
46357
47223
  return {
@@ -46361,6 +47227,29 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
46361
47227
  width: adjustedWidth
46362
47228
  };
46363
47229
  });
47230
+ const MAX_DELTA_PX = 12;
47231
+ let invalid = false;
47232
+ if (domStart && corrected[0]) {
47233
+ const dx = Math.abs(corrected[0].x - domStart.x);
47234
+ const dy = Math.abs(corrected[0].y - domStart.y);
47235
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
47236
+ }
47237
+ if (domEnd && corrected[corrected.length - 1]) {
47238
+ const last = corrected[corrected.length - 1];
47239
+ const dx = Math.abs(last.x + last.width - domEnd.x);
47240
+ const dy = Math.abs(last.y - domEnd.y);
47241
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
47242
+ }
47243
+ if (invalid) {
47244
+ console.warn("[SelectionOverlay] Suppressing selection render due to large DOM/Layout mismatch", {
47245
+ domStart,
47246
+ domEnd,
47247
+ rectStart: corrected[0],
47248
+ rectEnd: corrected[corrected.length - 1]
47249
+ });
47250
+ return [];
47251
+ }
47252
+ return corrected;
46364
47253
  };
46365
47254
  /**
46366
47255
  * Renders visual highlighting for CellSelection (multiple table cells selected).
@@ -46678,7 +47567,7 @@ computeHeaderFooterSelectionRects_fn = function(from2, to) {
46678
47567
  return [];
46679
47568
  }
46680
47569
  if (!bodyLayout) return [];
46681
- const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to) ?? [];
47570
+ const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to, void 0) ?? [];
46682
47571
  const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
46683
47572
  const bodyPageHeight = __privateMethod(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
46684
47573
  return rects.map((rect) => {
@@ -47070,8 +47959,8 @@ computeCaretLayoutRectGeometry_fn = function(pos, includeDomFallback = true) {
47070
47959
  const zoom2 = __privateGet(this, _layoutOptions).zoom ?? 1;
47071
47960
  let domCaretX2 = null;
47072
47961
  let domCaretY2 = null;
47073
- const spanEls2 = pageEl2?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
47074
- for (const spanEl of spanEls2) {
47962
+ const spanEls2 = pageEl2?.querySelectorAll("span[data-pm-start][data-pm-end]");
47963
+ for (const spanEl of Array.from(spanEls2 ?? [])) {
47075
47964
  const pmStart = Number(spanEl.dataset.pmStart);
47076
47965
  const pmEnd = Number(spanEl.dataset.pmEnd);
47077
47966
  if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
@@ -47123,8 +48012,8 @@ computeCaretLayoutRectGeometry_fn = function(pos, includeDomFallback = true) {
47123
48012
  const zoom = __privateGet(this, _layoutOptions).zoom ?? 1;
47124
48013
  let domCaretX = null;
47125
48014
  let domCaretY = null;
47126
- const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
47127
- for (const spanEl of spanEls) {
48015
+ const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]");
48016
+ for (const spanEl of Array.from(spanEls ?? [])) {
47128
48017
  const pmStart = Number(spanEl.dataset.pmStart);
47129
48018
  const pmEnd = Number(spanEl.dataset.pmEnd);
47130
48019
  if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
@@ -47365,7 +48254,14 @@ getCurrentPageIndex_fn = function() {
47365
48254
  if (!layout || !selection) {
47366
48255
  return 0;
47367
48256
  }
47368
- const rects = selectionToRects(layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, selection.from, selection.to) ?? [];
48257
+ const rects = selectionToRects(
48258
+ layout,
48259
+ __privateGet(this, _layoutState).blocks,
48260
+ __privateGet(this, _layoutState).measures,
48261
+ selection.from,
48262
+ selection.to,
48263
+ __privateGet(this, _pageGeometryHelper) ?? void 0
48264
+ ) ?? [];
47369
48265
  if (rects.length > 0) {
47370
48266
  return rects[0]?.pageIndex ?? 0;
47371
48267
  }
@@ -52930,14 +53826,19 @@ const createCell = (cellType, cellContent = null) => {
52930
53826
  }
52931
53827
  return cellType.createAndFill();
52932
53828
  };
52933
- const createTableBorders = ({ size = 0.66665, color = "#000000" } = {}) => {
53829
+ const createTableBorders = (borderSpec = {}) => {
53830
+ borderSpec = {
53831
+ size: 0.66665,
53832
+ color: "#000000",
53833
+ ...borderSpec
53834
+ };
52934
53835
  return {
52935
- top: { size, color },
52936
- left: { size, color },
52937
- bottom: { size, color },
52938
- right: { size, color },
52939
- insideH: { size, color },
52940
- insideV: { size, color }
53836
+ top: borderSpec,
53837
+ left: borderSpec,
53838
+ bottom: borderSpec,
53839
+ right: borderSpec,
53840
+ insideH: borderSpec,
53841
+ insideV: borderSpec
52941
53842
  };
52942
53843
  };
52943
53844
  const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent = null) => {
@@ -53065,12 +53966,17 @@ const deleteTableWhenSelected = ({ editor }) => {
53065
53966
  editor.commands.deleteTable();
53066
53967
  return true;
53067
53968
  };
53068
- const createCellBorders = ({ size = 0.66665, color = "#000000" } = {}) => {
53969
+ const createCellBorders = (borderSpec = {}) => {
53970
+ borderSpec = {
53971
+ size: 0.66665,
53972
+ color: "#000000",
53973
+ ...borderSpec
53974
+ };
53069
53975
  return {
53070
- top: { size, color },
53071
- left: { size, color },
53072
- bottom: { size, color },
53073
- right: { size, color }
53976
+ top: borderSpec,
53977
+ left: borderSpec,
53978
+ bottom: borderSpec,
53979
+ right: borderSpec
53074
53980
  };
53075
53981
  };
53076
53982
  function cellAround($pos) {
@@ -53837,13 +54743,20 @@ const Table = Node$1.create({
53837
54743
  if (["tableCell", "tableHeader"].includes(node.type.name)) {
53838
54744
  tr.setNodeMarkup(pos, void 0, {
53839
54745
  ...node.attrs,
53840
- borders: createCellBorders({ size: 0 })
54746
+ borders: createCellBorders({ size: 0, space: 0, val: "none", color: "auto" })
53841
54747
  });
53842
54748
  }
53843
54749
  });
53844
54750
  tr.setNodeMarkup(table.pos, void 0, {
53845
54751
  ...table.node.attrs,
53846
- borders: createTableBorders({ size: 0 })
54752
+ borders: createTableBorders({ size: 0 }),
54753
+ // TODO: This works around the issue that table borders are duplicated between
54754
+ // the attributes of the table and the tableProperties attribute.
54755
+ // This can be removed when the redundancy is eliminated.
54756
+ tableProperties: {
54757
+ ...table.node.attrs.tableProperties,
54758
+ borders: createTableBorders({ size: 0, space: 0, val: "none", color: "auto" })
54759
+ }
53847
54760
  });
53848
54761
  return true;
53849
54762
  }