@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
@@ -39793,7 +39793,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39793
39793
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
39794
39794
  const date = new Date(createdDate);
39795
39795
  const unixTimestampMs = date.getTime();
39796
- const parsedComment = nodeListHandler.handler({
39796
+ const parsedElements = nodeListHandler.handler({
39797
39797
  nodes: el.elements,
39798
39798
  nodeListHandler,
39799
39799
  docx,
@@ -39801,7 +39801,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39801
39801
  converter,
39802
39802
  path: [el]
39803
39803
  });
39804
- const { attrs } = parsedComment[0];
39804
+ const { attrs } = parsedElements[0];
39805
39805
  const paraId = attrs["w14:paraId"];
39806
39806
  return {
39807
39807
  commentId: internalId || v4$1(),
@@ -39809,7 +39809,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39809
39809
  creatorName: authorName,
39810
39810
  creatorEmail: authorEmail,
39811
39811
  createdTime: unixTimestampMs,
39812
- textJson: parsedComment[0],
39812
+ textJson: parsedElements[0],
39813
+ elements: parsedElements,
39813
39814
  initials,
39814
39815
  paraId,
39815
39816
  trackedChange,
@@ -39835,7 +39836,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39835
39836
  const { elements = [] } = initialElements[0] ?? {};
39836
39837
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
39837
39838
  return comments.map((comment2) => {
39838
- const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment2.paraId);
39839
+ const extendedDef = commentEx.find((ce2) => {
39840
+ const isIncludedInCommentElements = comment2.elements?.some(
39841
+ (el) => el.attrs?.["w14:paraId"] === ce2.attributes["w15:paraId"]
39842
+ );
39843
+ return isIncludedInCommentElements;
39844
+ });
39839
39845
  if (!extendedDef) return { ...comment2, isDone: comment2.isDone ?? false };
39840
39846
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
39841
39847
  let parentComment;
@@ -41956,7 +41962,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41956
41962
  name: "w16cex:commentExtensible",
41957
41963
  attributes: {
41958
41964
  "w16cex:durableId": newDurableId,
41959
- "w16cex:dateUtc": toIsoNoFractional()
41965
+ "w16cex:dateUtc": toIsoNoFractional(comment2.createdTime)
41960
41966
  }
41961
41967
  };
41962
41968
  extensibleUpdated.elements[0].elements.push(newExtensible);
@@ -42422,7 +42428,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42422
42428
  static getStoredSuperdocVersion(docx) {
42423
42429
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42424
42430
  }
42425
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.98") {
42431
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-next.1") {
42426
42432
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42427
42433
  }
42428
42434
  /**
@@ -53591,7 +53597,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53591
53597
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
53592
53598
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53593
53599
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
53594
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _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, 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;
53600
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _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, 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;
53595
53601
  var GOOD_LEAF_SIZE = 200;
53596
53602
  var RopeSequence = function RopeSequence2() {
53597
53603
  };
@@ -62675,6 +62681,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62675
62681
  const selectAll = () => ({ state: state2, dispatch }) => selectAll$1(state2, dispatch);
62676
62682
  const deleteSelection = () => ({ state: state2, tr, dispatch }) => {
62677
62683
  const { from: from2, to, empty: empty2 } = state2.selection;
62684
+ if (typeof document !== "undefined" && document.getSelection) {
62685
+ const currentDomSelection = document.getSelection();
62686
+ const selectedLength = currentDomSelection?.toString?.().length;
62687
+ const isCollapsed = currentDomSelection?.isCollapsed;
62688
+ if (!isCollapsed && selectedLength === 1) {
62689
+ return false;
62690
+ }
62691
+ }
62678
62692
  if (empty2) {
62679
62693
  return deleteSelection$1(state2, dispatch);
62680
62694
  }
@@ -64974,12 +64988,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64974
64988
  importedId: node2.attrs["w:id"]
64975
64989
  });
64976
64990
  if (type2.name === "commentRangeStart") {
64977
- toMark.push({
64978
- commentId: resolvedCommentId,
64979
- importedId,
64980
- internal,
64981
- start: pos
64982
- });
64991
+ if (!matchingImportedComment?.isDone) {
64992
+ toMark.push({
64993
+ commentId: resolvedCommentId,
64994
+ importedId,
64995
+ internal,
64996
+ start: pos
64997
+ });
64998
+ }
64983
64999
  ensureFallbackComment({
64984
65000
  converter,
64985
65001
  matchingImportedComment,
@@ -67497,7 +67513,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67497
67513
  const shouldSkipNodeView = (editor) => {
67498
67514
  return isHeadless(editor);
67499
67515
  };
67500
- const summaryVersion = "1.0.0-beta.98";
67516
+ const summaryVersion = "1.0.0-next.1";
67501
67517
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67502
67518
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67503
67519
  function mapAttributes(attrs) {
@@ -67857,11 +67873,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67857
67873
  if (!this.options.isNewFile || !this.options.collaborationProvider) return;
67858
67874
  const provider2 = this.options.collaborationProvider;
67859
67875
  const postSyncInit = () => {
67860
- provider2.off("synced", postSyncInit);
67876
+ provider2.off?.("synced", postSyncInit);
67861
67877
  __privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
67862
67878
  };
67863
67879
  if (provider2.synced) __privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
67864
- else provider2.on("synced", postSyncInit);
67880
+ else provider2.on?.("synced", postSyncInit);
67865
67881
  }
67866
67882
  /**
67867
67883
  * Replace content of editor that was created with loadFromSchema option
@@ -68286,7 +68302,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68286
68302
  { default: remarkStringify2 },
68287
68303
  { default: remarkGfm2 }
68288
68304
  ] = await Promise.all([
68289
- Promise.resolve().then(() => indexDg_sTYZK),
68305
+ Promise.resolve().then(() => indexDlj3l0Hk),
68290
68306
  Promise.resolve().then(() => indexDRCvimau),
68291
68307
  Promise.resolve().then(() => indexC_x_N6Uh),
68292
68308
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68491,7 +68507,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68491
68507
  * Process collaboration migrations
68492
68508
  */
68493
68509
  processCollaborationMigrations() {
68494
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.98");
68510
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-next.1");
68495
68511
  if (!this.options.ydoc) return;
68496
68512
  const metaMap = this.options.ydoc.getMap("meta");
68497
68513
  let docVersion = metaMap.get("version");
@@ -71606,6 +71622,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
71606
71622
  if (cellChanged) {
71607
71623
  return {
71608
71624
  ...cell2,
71625
+ // Cast to expected type - hydrateBlock preserves block kinds, just hydrates image sources
71609
71626
  blocks: hydratedBlocks.length > 0 ? hydratedBlocks : cell2.blocks,
71610
71627
  paragraph: hydratedParagraph
71611
71628
  };
@@ -75226,7 +75243,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75226
75243
  };
75227
75244
  }
75228
75245
  const hasValidNumbering = rawNumberingProps && isValidNumberingId(rawNumberingProps.numId);
75229
- if (hasValidNumbering) {
75246
+ if (hasValidNumbering && rawNumberingProps) {
75230
75247
  const numberingProps = rawNumberingProps;
75231
75248
  const numId = numberingProps.numId;
75232
75249
  const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
@@ -75266,6 +75283,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75266
75283
  const resolvedCounterValue = path2[path2.length - 1] ?? counterValue;
75267
75284
  const enrichedNumberingProps = {
75268
75285
  ...numberingProps,
75286
+ numId: numberingProps.numId,
75287
+ ilvl: numberingProps.ilvl,
75269
75288
  path: path2,
75270
75289
  counterValue: resolvedCounterValue
75271
75290
  };
@@ -77362,7 +77381,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77362
77381
  context.nextBlockId,
77363
77382
  context.positions
77364
77383
  );
77365
- if (drawingBlock) {
77384
+ if (drawingBlock && drawingBlock.kind === "drawing") {
77366
77385
  blocks2.push(drawingBlock);
77367
77386
  }
77368
77387
  continue;
@@ -77373,7 +77392,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77373
77392
  context.nextBlockId,
77374
77393
  context.positions
77375
77394
  );
77376
- if (drawingBlock) {
77395
+ if (drawingBlock && drawingBlock.kind === "drawing") {
77377
77396
  blocks2.push(drawingBlock);
77378
77397
  }
77379
77398
  continue;
@@ -77384,7 +77403,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77384
77403
  context.nextBlockId,
77385
77404
  context.positions
77386
77405
  );
77387
- if (drawingBlock) {
77406
+ if (drawingBlock && drawingBlock.kind === "drawing") {
77388
77407
  blocks2.push(drawingBlock);
77389
77408
  }
77390
77409
  continue;
@@ -77395,7 +77414,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77395
77414
  context.nextBlockId,
77396
77415
  context.positions
77397
77416
  );
77398
- if (drawingBlock) {
77417
+ if (drawingBlock && drawingBlock.kind === "drawing") {
77399
77418
  blocks2.push(drawingBlock);
77400
77419
  }
77401
77420
  }
@@ -77850,7 +77869,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77850
77869
  bookmarks2,
77851
77870
  hyperlinkConfig2,
77852
77871
  themeColorsParam ?? themeColors,
77853
- paragraphConverter
77872
+ paragraphConverter,
77873
+ converterCtx ?? converterContext,
77874
+ {
77875
+ listCounterContext: { getListCounter, incrementListCounter, resetListCounter },
77876
+ converters: {
77877
+ paragraphToFlowBlocks: paragraphConverter,
77878
+ imageNodeToBlock,
77879
+ vectorShapeNodeToDrawingBlock,
77880
+ shapeGroupNodeToDrawingBlock,
77881
+ shapeContainerNodeToDrawingBlock,
77882
+ shapeTextboxNodeToDrawingBlock
77883
+ }
77884
+ }
77854
77885
  );
77855
77886
  const handlerContext = {
77856
77887
  blocks: blocks2,
@@ -77871,6 +77902,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77871
77902
  currentParagraphIndex: 0
77872
77903
  },
77873
77904
  converters: {
77905
+ // Type assertion needed due to signature mismatch between actual function and type definition
77874
77906
  paragraphToFlowBlocks: paragraphConverter,
77875
77907
  tableNodeToBlock: tableConverter,
77876
77908
  imageNodeToBlock,
@@ -77966,6 +77998,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77966
77998
  {
77967
77999
  listCounterContext,
77968
78000
  converters: {
78001
+ // Type assertion needed due to signature mismatch between actual function and type definition
77969
78002
  paragraphToFlowBlocks: paragraphToFlowBlocks$1,
77970
78003
  imageNodeToBlock,
77971
78004
  vectorShapeNodeToDrawingBlock,
@@ -77979,7 +78012,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77979
78012
  converterContext
77980
78013
  );
77981
78014
  }
77982
- function tableNodeToBlock(node2, nextBlockId, positions, defaultFont, defaultSize, styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, converterContext) {
78015
+ function tableNodeToBlock(node2, nextBlockId, positions, defaultFont, defaultSize, styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, _paragraphToFlowBlocksParam, converterContext, options) {
77983
78016
  return tableNodeToBlock$1(
77984
78017
  node2,
77985
78018
  nextBlockId,
@@ -77993,8 +78026,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77993
78026
  themeColors,
77994
78027
  paragraphToFlowBlocks,
77995
78028
  converterContext,
77996
- {
78029
+ options ?? {
77997
78030
  converters: {
78031
+ // Type assertion needed due to signature mismatch between actual function and type definition
77998
78032
  paragraphToFlowBlocks: paragraphToFlowBlocks$1,
77999
78033
  imageNodeToBlock,
78000
78034
  vectorShapeNodeToDrawingBlock,
@@ -80574,7 +80608,7 @@ ${l}
80574
80608
  alignItems: "center",
80575
80609
  background: "transparent",
80576
80610
  padding: "0",
80577
- gap: "24px",
80611
+ // gap is set dynamically by renderer based on pageGap option (default: 24px)
80578
80612
  overflowY: "auto"
80579
80613
  };
80580
80614
  const containerStylesHorizontal = {
@@ -80584,7 +80618,7 @@ ${l}
80584
80618
  justifyContent: "safe center",
80585
80619
  background: "transparent",
80586
80620
  padding: "0",
80587
- gap: "20px",
80621
+ // gap is set dynamically by renderer based on pageGap option (default: 20px for horizontal)
80588
80622
  overflowX: "auto",
80589
80623
  minHeight: "100%"
80590
80624
  };
@@ -82282,6 +82316,104 @@ ${l}
82282
82316
  doc2.head?.appendChild(styleEl);
82283
82317
  rulerStylesInjected = true;
82284
82318
  }
82319
+ const hashParagraphBorder$1 = (border) => {
82320
+ const parts = [];
82321
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
82322
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
82323
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
82324
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
82325
+ return parts.join(",");
82326
+ };
82327
+ const hashParagraphBorders$1 = (borders) => {
82328
+ const parts = [];
82329
+ if (borders.top) parts.push(`t:[${hashParagraphBorder$1(borders.top)}]`);
82330
+ if (borders.right) parts.push(`r:[${hashParagraphBorder$1(borders.right)}]`);
82331
+ if (borders.bottom) parts.push(`b:[${hashParagraphBorder$1(borders.bottom)}]`);
82332
+ if (borders.left) parts.push(`l:[${hashParagraphBorder$1(borders.left)}]`);
82333
+ return parts.join(";");
82334
+ };
82335
+ const isNoneBorder$1 = (value) => {
82336
+ return typeof value === "object" && value !== null && "none" in value && value.none === true;
82337
+ };
82338
+ const isBorderSpec$1 = (value) => {
82339
+ return typeof value === "object" && value !== null && !("none" in value);
82340
+ };
82341
+ const hashBorderSpec$1 = (border) => {
82342
+ const parts = [];
82343
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
82344
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
82345
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
82346
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
82347
+ return parts.join(",");
82348
+ };
82349
+ const hashTableBorderValue$1 = (borderValue) => {
82350
+ if (borderValue === void 0) return "";
82351
+ if (borderValue === null) return "null";
82352
+ if (isNoneBorder$1(borderValue)) return "none";
82353
+ if (isBorderSpec$1(borderValue)) {
82354
+ return hashBorderSpec$1(borderValue);
82355
+ }
82356
+ return "";
82357
+ };
82358
+ const hashTableBorders$1 = (borders) => {
82359
+ if (!borders) return "";
82360
+ const parts = [];
82361
+ if (borders.top !== void 0) parts.push(`t:[${hashTableBorderValue$1(borders.top)}]`);
82362
+ if (borders.right !== void 0) parts.push(`r:[${hashTableBorderValue$1(borders.right)}]`);
82363
+ if (borders.bottom !== void 0) parts.push(`b:[${hashTableBorderValue$1(borders.bottom)}]`);
82364
+ if (borders.left !== void 0) parts.push(`l:[${hashTableBorderValue$1(borders.left)}]`);
82365
+ if (borders.insideH !== void 0) parts.push(`ih:[${hashTableBorderValue$1(borders.insideH)}]`);
82366
+ if (borders.insideV !== void 0) parts.push(`iv:[${hashTableBorderValue$1(borders.insideV)}]`);
82367
+ return parts.join(";");
82368
+ };
82369
+ const hashCellBorders$1 = (borders) => {
82370
+ if (!borders) return "";
82371
+ const parts = [];
82372
+ if (borders.top) parts.push(`t:[${hashBorderSpec$1(borders.top)}]`);
82373
+ if (borders.right) parts.push(`r:[${hashBorderSpec$1(borders.right)}]`);
82374
+ if (borders.bottom) parts.push(`b:[${hashBorderSpec$1(borders.bottom)}]`);
82375
+ if (borders.left) parts.push(`l:[${hashBorderSpec$1(borders.left)}]`);
82376
+ return parts.join(";");
82377
+ };
82378
+ const hasStringProp = (run2, prop) => {
82379
+ return prop in run2 && typeof run2[prop] === "string";
82380
+ };
82381
+ const hasNumberProp = (run2, prop) => {
82382
+ return prop in run2 && typeof run2[prop] === "number";
82383
+ };
82384
+ const hasBooleanProp = (run2, prop) => {
82385
+ return prop in run2 && typeof run2[prop] === "boolean";
82386
+ };
82387
+ const getRunStringProp = (run2, prop) => {
82388
+ if (hasStringProp(run2, prop)) {
82389
+ return run2[prop];
82390
+ }
82391
+ return "";
82392
+ };
82393
+ const getRunNumberProp = (run2, prop) => {
82394
+ if (hasNumberProp(run2, prop)) {
82395
+ return run2[prop];
82396
+ }
82397
+ return 0;
82398
+ };
82399
+ const getRunBooleanProp = (run2, prop) => {
82400
+ if (hasBooleanProp(run2, prop)) {
82401
+ return run2[prop];
82402
+ }
82403
+ return false;
82404
+ };
82405
+ const getRunUnderlineStyle = (run2) => {
82406
+ if ("underline" in run2 && run2.underline && typeof run2.underline === "object") {
82407
+ return run2.underline.style ?? "";
82408
+ }
82409
+ return "";
82410
+ };
82411
+ const getRunUnderlineColor = (run2) => {
82412
+ if ("underline" in run2 && run2.underline && typeof run2.underline === "object") {
82413
+ return run2.underline.color ?? "";
82414
+ }
82415
+ return "";
82416
+ };
82285
82417
  function isMinimalWordLayout(value) {
82286
82418
  if (typeof value !== "object" || value === null) {
82287
82419
  return false;
@@ -82332,6 +82464,7 @@ ${l}
82332
82464
  const LIST_MARKER_GAP$1 = 8;
82333
82465
  const DEFAULT_TAB_INTERVAL_PX$1 = 48;
82334
82466
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
82467
+ const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
82335
82468
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
82336
82469
  const COMMENT_INTERNAL_COLOR = "#078383";
82337
82470
  const COMMENT_INACTIVE_ALPHA = "22";
@@ -82461,10 +82594,11 @@ ${l}
82461
82594
  this.totalPages = 0;
82462
82595
  this.linkIdCounter = 0;
82463
82596
  this.pendingTooltips = /* @__PURE__ */ new WeakMap();
82597
+ this.pageGap = 24;
82464
82598
  this.virtualEnabled = false;
82465
82599
  this.virtualWindow = 5;
82466
82600
  this.virtualOverscan = 0;
82467
- this.virtualGap = 72;
82601
+ this.virtualGap = DEFAULT_VIRTUALIZED_PAGE_GAP$1;
82468
82602
  this.virtualPaddingTop = null;
82469
82603
  this.topSpacerEl = null;
82470
82604
  this.bottomSpacerEl = null;
@@ -82483,13 +82617,14 @@ ${l}
82483
82617
  this.blockLookup = this.buildBlockLookup(blocks2, measures);
82484
82618
  this.headerProvider = options.headerProvider;
82485
82619
  this.footerProvider = options.footerProvider;
82620
+ const defaultGap = this.layoutMode === "horizontal" ? 20 : 24;
82621
+ this.pageGap = typeof options.pageGap === "number" && Number.isFinite(options.pageGap) ? Math.max(0, options.pageGap) : defaultGap;
82486
82622
  if (this.layoutMode === "vertical" && options.virtualization?.enabled) {
82487
82623
  this.virtualEnabled = true;
82488
82624
  this.virtualWindow = Math.max(1, options.virtualization.window ?? 5);
82489
82625
  this.virtualOverscan = Math.max(0, options.virtualization.overscan ?? 0);
82490
- if (typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap)) {
82491
- this.virtualGap = Math.max(0, options.virtualization.gap);
82492
- }
82626
+ const hasExplicitVirtualGap = typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap);
82627
+ this.virtualGap = hasExplicitVirtualGap ? Math.max(0, options.virtualization.gap) : DEFAULT_VIRTUALIZED_PAGE_GAP$1;
82493
82628
  if (typeof options.virtualization.paddingTop === "number" && Number.isFinite(options.virtualization.paddingTop)) {
82494
82629
  this.virtualPaddingTop = Math.max(0, options.virtualization.paddingTop);
82495
82630
  }
@@ -82590,6 +82725,7 @@ ${l}
82590
82725
  const mode = this.layoutMode;
82591
82726
  if (mode === "horizontal") {
82592
82727
  applyStyles$2(mount2, containerStylesHorizontal);
82728
+ mount2.style.gap = `${this.pageGap}px`;
82593
82729
  this.renderHorizontal(layout, mount2);
82594
82730
  this.currentLayout = layout;
82595
82731
  this.pageStates = [];
@@ -82612,6 +82748,7 @@ ${l}
82612
82748
  this.changedBlocks.clear();
82613
82749
  return;
82614
82750
  }
82751
+ mount2.style.gap = `${this.pageGap}px`;
82615
82752
  if (!this.currentLayout || this.pageStates.length === 0) {
82616
82753
  this.fullRender(layout);
82617
82754
  } else {
@@ -82936,9 +83073,15 @@ ${l}
82936
83073
  const container = existing ?? this.doc.createElement("div");
82937
83074
  container.className = className;
82938
83075
  container.innerHTML = "";
82939
- const offset2 = data.offset ?? (kind === "footer" ? pageEl.clientHeight - data.height : 0);
83076
+ const baseOffset = data.offset ?? (kind === "footer" ? pageEl.clientHeight - data.height : 0);
82940
83077
  const marginLeft = data.marginLeft ?? 0;
82941
83078
  const marginRight = page.margins?.right ?? 0;
83079
+ let effectiveHeight = data.height;
83080
+ let effectiveOffset = baseOffset;
83081
+ if (kind === "footer" && typeof data.contentHeight === "number" && Number.isFinite(data.contentHeight) && data.contentHeight > 0 && data.contentHeight > data.height) {
83082
+ effectiveHeight = data.contentHeight;
83083
+ effectiveOffset = baseOffset - (data.contentHeight - data.height);
83084
+ }
82942
83085
  container.style.position = "absolute";
82943
83086
  container.style.left = `${marginLeft}px`;
82944
83087
  if (typeof data.contentWidth === "number") {
@@ -82947,8 +83090,8 @@ ${l}
82947
83090
  container.style.width = `calc(100% - ${marginLeft + marginRight}px)`;
82948
83091
  }
82949
83092
  container.style.pointerEvents = "none";
82950
- container.style.height = `${data.height}px`;
82951
- container.style.top = `${Math.max(0, offset2)}px`;
83093
+ container.style.height = `${effectiveHeight}px`;
83094
+ container.style.top = `${Math.max(0, effectiveOffset)}px`;
82952
83095
  container.style.zIndex = "1";
82953
83096
  container.style.overflow = "visible";
82954
83097
  let footerYOffset = 0;
@@ -82957,7 +83100,7 @@ ${l}
82957
83100
  const fragHeight = "height" in f2 && typeof f2.height === "number" ? f2.height : this.estimateFragmentHeight(f2);
82958
83101
  return Math.max(max2, f2.y + Math.max(0, fragHeight));
82959
83102
  }, 0);
82960
- footerYOffset = Math.max(0, data.height - contentHeight);
83103
+ footerYOffset = Math.max(0, effectiveHeight - contentHeight);
82961
83104
  }
82962
83105
  const context = {
82963
83106
  pageNumber: page.number,
@@ -85361,7 +85504,7 @@ ${l}
85361
85504
  attrs.indent?.right ?? "",
85362
85505
  attrs.indent?.firstLine ?? "",
85363
85506
  attrs.indent?.hanging ?? "",
85364
- attrs.borders ? JSON.stringify(attrs.borders) : "",
85507
+ attrs.borders ? hashParagraphBorders$1(attrs.borders) : "",
85365
85508
  attrs.shading?.fill ?? "",
85366
85509
  attrs.shading?.color ?? "",
85367
85510
  attrs.direction ?? "",
@@ -85447,22 +85590,82 @@ ${l}
85447
85590
  hash2 = hashNumber(hash2, cellBlocks.length);
85448
85591
  hash2 = hashNumber(hash2, cell2.rowSpan ?? 1);
85449
85592
  hash2 = hashNumber(hash2, cell2.colSpan ?? 1);
85593
+ if (cell2.attrs) {
85594
+ const cellAttrs = cell2.attrs;
85595
+ if (cellAttrs.borders) {
85596
+ hash2 = hashString(hash2, hashCellBorders$1(cellAttrs.borders));
85597
+ }
85598
+ if (cellAttrs.padding) {
85599
+ const p2 = cellAttrs.padding;
85600
+ hash2 = hashNumber(hash2, p2.top ?? 0);
85601
+ hash2 = hashNumber(hash2, p2.right ?? 0);
85602
+ hash2 = hashNumber(hash2, p2.bottom ?? 0);
85603
+ hash2 = hashNumber(hash2, p2.left ?? 0);
85604
+ }
85605
+ if (cellAttrs.verticalAlign) {
85606
+ hash2 = hashString(hash2, cellAttrs.verticalAlign);
85607
+ }
85608
+ if (cellAttrs.background) {
85609
+ hash2 = hashString(hash2, cellAttrs.background);
85610
+ }
85611
+ }
85450
85612
  for (const cellBlock of cellBlocks) {
85451
85613
  hash2 = hashString(hash2, cellBlock?.kind ?? "unknown");
85452
85614
  if (cellBlock?.kind === "paragraph") {
85453
- const runs2 = cellBlock.runs ?? [];
85615
+ const paragraphBlock = cellBlock;
85616
+ const runs2 = paragraphBlock.runs ?? [];
85454
85617
  hash2 = hashNumber(hash2, runs2.length);
85618
+ const attrs = paragraphBlock.attrs;
85619
+ if (attrs) {
85620
+ hash2 = hashString(hash2, attrs.alignment ?? "");
85621
+ hash2 = hashNumber(hash2, attrs.spacing?.before ?? 0);
85622
+ hash2 = hashNumber(hash2, attrs.spacing?.after ?? 0);
85623
+ hash2 = hashNumber(hash2, attrs.spacing?.line ?? 0);
85624
+ hash2 = hashString(hash2, attrs.spacing?.lineRule ?? "");
85625
+ hash2 = hashNumber(hash2, attrs.indent?.left ?? 0);
85626
+ hash2 = hashNumber(hash2, attrs.indent?.right ?? 0);
85627
+ hash2 = hashNumber(hash2, attrs.indent?.firstLine ?? 0);
85628
+ hash2 = hashNumber(hash2, attrs.indent?.hanging ?? 0);
85629
+ hash2 = hashString(hash2, attrs.shading?.fill ?? "");
85630
+ hash2 = hashString(hash2, attrs.shading?.color ?? "");
85631
+ hash2 = hashString(hash2, attrs.direction ?? "");
85632
+ hash2 = hashString(hash2, attrs.rtl ? "1" : "");
85633
+ if (attrs.borders) {
85634
+ hash2 = hashString(hash2, hashParagraphBorders$1(attrs.borders));
85635
+ }
85636
+ }
85455
85637
  for (const run2 of runs2) {
85456
85638
  if ("text" in run2 && typeof run2.text === "string") {
85457
85639
  hash2 = hashString(hash2, run2.text);
85458
85640
  }
85459
85641
  hash2 = hashNumber(hash2, run2.pmStart ?? -1);
85460
85642
  hash2 = hashNumber(hash2, run2.pmEnd ?? -1);
85643
+ hash2 = hashString(hash2, getRunStringProp(run2, "color"));
85644
+ hash2 = hashString(hash2, getRunStringProp(run2, "highlight"));
85645
+ hash2 = hashString(hash2, getRunBooleanProp(run2, "bold") ? "1" : "");
85646
+ hash2 = hashString(hash2, getRunBooleanProp(run2, "italic") ? "1" : "");
85647
+ hash2 = hashNumber(hash2, getRunNumberProp(run2, "fontSize"));
85648
+ hash2 = hashString(hash2, getRunStringProp(run2, "fontFamily"));
85649
+ hash2 = hashString(hash2, getRunUnderlineStyle(run2));
85650
+ hash2 = hashString(hash2, getRunUnderlineColor(run2));
85651
+ hash2 = hashString(hash2, getRunBooleanProp(run2, "strike") ? "1" : "");
85461
85652
  }
85462
85653
  }
85463
85654
  }
85464
85655
  }
85465
85656
  }
85657
+ if (tableBlock.attrs) {
85658
+ const tblAttrs = tableBlock.attrs;
85659
+ if (tblAttrs.borders) {
85660
+ hash2 = hashString(hash2, hashTableBorders$1(tblAttrs.borders));
85661
+ }
85662
+ if (tblAttrs.borderCollapse) {
85663
+ hash2 = hashString(hash2, tblAttrs.borderCollapse);
85664
+ }
85665
+ if (tblAttrs.cellSpacing !== void 0) {
85666
+ hash2 = hashNumber(hash2, tblAttrs.cellSpacing);
85667
+ }
85668
+ }
85466
85669
  return [block.id, tableBlock.rows.length, hash2.toString(16)].join("|");
85467
85670
  }
85468
85671
  return block.id;
@@ -85796,6 +85999,7 @@ ${l}
85796
85999
  const painter = new DomPainter(options.blocks, options.measures, {
85797
86000
  pageStyles: options.pageStyles,
85798
86001
  layoutMode: options.layoutMode,
86002
+ pageGap: options.pageGap,
85799
86003
  headerProvider: options.headerProvider,
85800
86004
  footerProvider: options.footerProvider,
85801
86005
  virtualization: options.virtualization,
@@ -86214,7 +86418,7 @@ ${l}
86214
86418
  return false;
86215
86419
  }
86216
86420
  const wordLayout = getWordLayoutConfig(block);
86217
- const hasListAttrs = block.attrs?.listItem != null || wordLayout?.marker != null;
86421
+ const hasListAttrs = block.attrs?.listItem != null || block.attrs?.numberingProperties != null || wordLayout?.marker != null;
86218
86422
  if (hasListAttrs) {
86219
86423
  return true;
86220
86424
  }
@@ -86644,7 +86848,7 @@ ${l}
86644
86848
  });
86645
86849
  return nextSectionPropsAtBreak;
86646
86850
  }
86647
- function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight = 0) {
86851
+ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight = 0, maxFooterContentHeight = 0) {
86648
86852
  const next2 = { ...state2 };
86649
86853
  const calcRequiredTopMargin = (headerDistance, baseTop) => {
86650
86854
  if (maxHeaderContentHeight > 0) {
@@ -86652,6 +86856,12 @@ ${l}
86652
86856
  }
86653
86857
  return Math.max(baseTop, headerDistance);
86654
86858
  };
86859
+ const calcRequiredBottomMargin = (footerDistance, baseBottom) => {
86860
+ if (maxFooterContentHeight > 0) {
86861
+ return Math.max(baseBottom, footerDistance + maxFooterContentHeight);
86862
+ }
86863
+ return Math.max(baseBottom, footerDistance);
86864
+ };
86655
86865
  if (block.attrs?.isFirstSection && !next2.hasAnyPages) {
86656
86866
  if (block.pageSize) {
86657
86867
  next2.activePageSize = { w: block.pageSize.w, h: block.pageSize.h };
@@ -86672,7 +86882,7 @@ ${l}
86672
86882
  const footerDistance = Math.max(0, block.margins.footer);
86673
86883
  next2.activeFooterDistance = footerDistance;
86674
86884
  next2.pendingFooterDistance = footerDistance;
86675
- next2.activeBottomMargin = Math.max(baseMargins.bottom, footerDistance);
86885
+ next2.activeBottomMargin = calcRequiredBottomMargin(footerDistance, baseMargins.bottom);
86676
86886
  next2.pendingBottomMargin = next2.activeBottomMargin;
86677
86887
  }
86678
86888
  if (block.columns) {
@@ -86695,8 +86905,14 @@ ${l}
86695
86905
  next2.pendingTopMargin = nextTop;
86696
86906
  next2.pendingHeaderDistance = nextHeader;
86697
86907
  }
86698
- next2.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
86699
- next2.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
86908
+ if (typeof footerPx === "number") {
86909
+ const newFooterDist = Math.max(0, footerPx);
86910
+ next2.pendingFooterDistance = newFooterDist;
86911
+ next2.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, baseMargins.bottom);
86912
+ } else {
86913
+ next2.pendingBottomMargin = nextBottom;
86914
+ next2.pendingFooterDistance = nextFooter;
86915
+ }
86700
86916
  if (block.pageSize) {
86701
86917
  next2.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
86702
86918
  }
@@ -88296,7 +88512,7 @@ ${l}
88296
88512
  if (contentWidth <= 0) {
88297
88513
  throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
88298
88514
  }
88299
- const validateHeaderHeight = (height) => {
88515
+ const validateContentHeight = (height) => {
88300
88516
  if (height === void 0) return 0;
88301
88517
  if (!Number.isFinite(height) || height < 0) return 0;
88302
88518
  return height;
@@ -88304,15 +88520,25 @@ ${l}
88304
88520
  const headerContentHeights = options.headerContentHeights;
88305
88521
  const maxHeaderContentHeight = headerContentHeights ? Math.max(
88306
88522
  0,
88307
- validateHeaderHeight(headerContentHeights.default),
88308
- validateHeaderHeight(headerContentHeights.first),
88309
- validateHeaderHeight(headerContentHeights.even),
88310
- validateHeaderHeight(headerContentHeights.odd)
88523
+ validateContentHeight(headerContentHeights.default),
88524
+ validateContentHeight(headerContentHeights.first),
88525
+ validateContentHeight(headerContentHeights.even),
88526
+ validateContentHeight(headerContentHeights.odd)
88311
88527
  ) : 0;
88312
88528
  const headerDistance = margins.header ?? margins.top;
88313
88529
  const effectiveTopMargin = maxHeaderContentHeight > 0 ? Math.max(margins.top, headerDistance + maxHeaderContentHeight) : margins.top;
88530
+ const footerContentHeights = options.footerContentHeights;
88531
+ const maxFooterContentHeight = footerContentHeights ? Math.max(
88532
+ 0,
88533
+ validateContentHeight(footerContentHeights.default),
88534
+ validateContentHeight(footerContentHeights.first),
88535
+ validateContentHeight(footerContentHeights.even),
88536
+ validateContentHeight(footerContentHeights.odd)
88537
+ ) : 0;
88538
+ const footerDistance = margins.footer ?? margins.bottom;
88539
+ const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
88314
88540
  let activeTopMargin = effectiveTopMargin;
88315
- let activeBottomMargin = margins.bottom;
88541
+ let activeBottomMargin = effectiveBottomMargin;
88316
88542
  let pendingTopMargin = null;
88317
88543
  let pendingBottomMargin = null;
88318
88544
  let activeHeaderDistance = margins.header ?? margins.top;
@@ -88335,7 +88561,7 @@ ${l}
88335
88561
  const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks2);
88336
88562
  const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
88337
88563
  if (typeof scheduleSectionBreak === "function") {
88338
- return scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight);
88564
+ return scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight, maxFooterContentHeight);
88339
88565
  }
88340
88566
  const next2 = { ...state2 };
88341
88567
  if (block.attrs?.isFirstSection && !next2.hasAnyPages) {
@@ -88356,10 +88582,11 @@ ${l}
88356
88582
  next2.pendingTopMargin = next2.activeTopMargin;
88357
88583
  }
88358
88584
  if (block.margins?.footer !== void 0) {
88359
- const footerDistance = Math.max(0, block.margins.footer);
88360
- next2.activeFooterDistance = footerDistance;
88361
- next2.pendingFooterDistance = footerDistance;
88362
- next2.activeBottomMargin = Math.max(baseMargins.bottom, footerDistance);
88585
+ const footerDistance2 = Math.max(0, block.margins.footer);
88586
+ next2.activeFooterDistance = footerDistance2;
88587
+ next2.pendingFooterDistance = footerDistance2;
88588
+ const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
88589
+ next2.activeBottomMargin = Math.max(baseMargins.bottom, requiredBottom);
88363
88590
  next2.pendingBottomMargin = next2.activeBottomMargin;
88364
88591
  }
88365
88592
  if (block.columns) {
@@ -88404,7 +88631,13 @@ ${l}
88404
88631
  } else {
88405
88632
  next2.pendingTopMargin = nextTop;
88406
88633
  }
88407
- next2.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
88634
+ if (typeof footerPx === "number") {
88635
+ const sectionFooter = next2.pendingFooterDistance;
88636
+ const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
88637
+ next2.pendingBottomMargin = Math.max(baseMargins.bottom, requiredBottom);
88638
+ } else {
88639
+ next2.pendingBottomMargin = nextBottom;
88640
+ }
88408
88641
  if (block.pageSize) next2.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
88409
88642
  if (block.orientation) next2.pendingOrientation = block.orientation;
88410
88643
  const sectionType = block.type ?? "continuous";
@@ -89155,10 +89388,6 @@ ${l}
89155
89388
  }
89156
89389
  return attrs.trackedChangesEnabled !== false;
89157
89390
  };
89158
- const MAX_CACHE_SIZE$1 = 1e4;
89159
- const BYTES_PER_ENTRY_ESTIMATE = 5e3;
89160
- const NORMALIZED_WHITESPACE = /\s+/g;
89161
- const normalizeText = (text2) => text2.replace(NORMALIZED_WHITESPACE, " ");
89162
89391
  const hashParagraphBorder = (border) => {
89163
89392
  const parts = [];
89164
89393
  if (border.style !== void 0) parts.push(`s:${border.style}`);
@@ -89175,6 +89404,53 @@ ${l}
89175
89404
  if (borders.left) parts.push(`l:[${hashParagraphBorder(borders.left)}]`);
89176
89405
  return parts.join(";");
89177
89406
  };
89407
+ function isNoneBorder(value) {
89408
+ return typeof value === "object" && value !== null && "none" in value && value.none === true;
89409
+ }
89410
+ function isBorderSpec(value) {
89411
+ return typeof value === "object" && value !== null && !("none" in value);
89412
+ }
89413
+ const hashBorderSpec = (border) => {
89414
+ const parts = [];
89415
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
89416
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
89417
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
89418
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
89419
+ return parts.join(",");
89420
+ };
89421
+ const hashTableBorderValue = (borderValue) => {
89422
+ if (borderValue === void 0) return "";
89423
+ if (borderValue === null) return "null";
89424
+ if (isNoneBorder(borderValue)) return "none";
89425
+ if (isBorderSpec(borderValue)) {
89426
+ return hashBorderSpec(borderValue);
89427
+ }
89428
+ return "";
89429
+ };
89430
+ const hashTableBorders = (borders) => {
89431
+ if (!borders) return "";
89432
+ const parts = [];
89433
+ if (borders.top !== void 0) parts.push(`t:[${hashTableBorderValue(borders.top)}]`);
89434
+ if (borders.right !== void 0) parts.push(`r:[${hashTableBorderValue(borders.right)}]`);
89435
+ if (borders.bottom !== void 0) parts.push(`b:[${hashTableBorderValue(borders.bottom)}]`);
89436
+ if (borders.left !== void 0) parts.push(`l:[${hashTableBorderValue(borders.left)}]`);
89437
+ if (borders.insideH !== void 0) parts.push(`ih:[${hashTableBorderValue(borders.insideH)}]`);
89438
+ if (borders.insideV !== void 0) parts.push(`iv:[${hashTableBorderValue(borders.insideV)}]`);
89439
+ return parts.join(";");
89440
+ };
89441
+ const hashCellBorders = (borders) => {
89442
+ if (!borders) return "";
89443
+ const parts = [];
89444
+ if (borders.top) parts.push(`t:[${hashBorderSpec(borders.top)}]`);
89445
+ if (borders.right) parts.push(`r:[${hashBorderSpec(borders.right)}]`);
89446
+ if (borders.bottom) parts.push(`b:[${hashBorderSpec(borders.bottom)}]`);
89447
+ if (borders.left) parts.push(`l:[${hashBorderSpec(borders.left)}]`);
89448
+ return parts.join(";");
89449
+ };
89450
+ const MAX_CACHE_SIZE$1 = 1e4;
89451
+ const BYTES_PER_ENTRY_ESTIMATE = 5e3;
89452
+ const NORMALIZED_WHITESPACE = /\s+/g;
89453
+ const normalizeText = (text2) => text2.replace(NORMALIZED_WHITESPACE, " ");
89178
89454
  const hashParagraphFrame = (frame) => {
89179
89455
  const parts = [];
89180
89456
  if (frame.wrap !== void 0) parts.push(`w:${frame.wrap}`);
@@ -89198,6 +89474,26 @@ ${l}
89198
89474
  continue;
89199
89475
  }
89200
89476
  for (const cell2 of row2.cells) {
89477
+ if (cell2.attrs) {
89478
+ const cellAttrs = cell2.attrs;
89479
+ const cellAttrParts = [];
89480
+ if (cellAttrs.borders) {
89481
+ cellAttrParts.push(`cb:${hashCellBorders(cellAttrs.borders)}`);
89482
+ }
89483
+ if (cellAttrs.padding) {
89484
+ const p2 = cellAttrs.padding;
89485
+ cellAttrParts.push(`cp:${p2.top ?? 0}:${p2.right ?? 0}:${p2.bottom ?? 0}:${p2.left ?? 0}`);
89486
+ }
89487
+ if (cellAttrs.verticalAlign) {
89488
+ cellAttrParts.push(`va:${cellAttrs.verticalAlign}`);
89489
+ }
89490
+ if (cellAttrs.background) {
89491
+ cellAttrParts.push(`bg:${cellAttrs.background}`);
89492
+ }
89493
+ if (cellAttrParts.length > 0) {
89494
+ cellHashes.push(`ca:${cellAttrParts.join(":")}`);
89495
+ }
89496
+ }
89201
89497
  const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
89202
89498
  for (const cellBlock of cellBlocks) {
89203
89499
  const paragraphBlock = cellBlock;
@@ -89211,12 +89507,14 @@ ${l}
89211
89507
  const color2 = "color" in run2 ? run2.color : void 0;
89212
89508
  const fontSize2 = "fontSize" in run2 ? run2.fontSize : void 0;
89213
89509
  const fontFamily2 = "fontFamily" in run2 ? run2.fontFamily : void 0;
89510
+ const highlight = "highlight" in run2 ? run2.highlight : void 0;
89214
89511
  const marks = [
89215
89512
  bold ? "b" : "",
89216
89513
  italic ? "i" : "",
89217
89514
  color2 ?? "",
89218
89515
  fontSize2 !== void 0 ? `fs:${fontSize2}` : "",
89219
- fontFamily2 ? `ff:${fontFamily2}` : ""
89516
+ fontFamily2 ? `ff:${fontFamily2}` : "",
89517
+ highlight ? `hl:${highlight}` : ""
89220
89518
  ].join("");
89221
89519
  let trackedKey = "";
89222
89520
  if (hasTrackedChange(run2)) {
@@ -89227,11 +89525,60 @@ ${l}
89227
89525
  }
89228
89526
  cellHashes.push(`${text2}:${marks}${trackedKey}`);
89229
89527
  }
89528
+ if (paragraphBlock.attrs) {
89529
+ const attrs = paragraphBlock.attrs;
89530
+ const parts = [];
89531
+ if (attrs.alignment) parts.push(`al:${attrs.alignment}`);
89532
+ if (attrs.spacing) {
89533
+ const s2 = attrs.spacing;
89534
+ if (s2.before !== void 0) parts.push(`sb:${s2.before}`);
89535
+ if (s2.after !== void 0) parts.push(`sa:${s2.after}`);
89536
+ if (s2.line !== void 0) parts.push(`sl:${s2.line}`);
89537
+ if (s2.lineRule) parts.push(`sr:${s2.lineRule}`);
89538
+ }
89539
+ if (attrs.indent) {
89540
+ const ind = attrs.indent;
89541
+ if (ind.left !== void 0) parts.push(`il:${ind.left}`);
89542
+ if (ind.right !== void 0) parts.push(`ir:${ind.right}`);
89543
+ if (ind.firstLine !== void 0) parts.push(`if:${ind.firstLine}`);
89544
+ if (ind.hanging !== void 0) parts.push(`ih:${ind.hanging}`);
89545
+ }
89546
+ if (attrs.borders) {
89547
+ parts.push(`br:${hashParagraphBorders(attrs.borders)}`);
89548
+ }
89549
+ if (attrs.shading) {
89550
+ const sh = attrs.shading;
89551
+ if (sh.fill) parts.push(`shf:${sh.fill}`);
89552
+ if (sh.color) parts.push(`shc:${sh.color}`);
89553
+ }
89554
+ if (attrs.direction) parts.push(`dir:${attrs.direction}`);
89555
+ if (attrs.rtl) parts.push("rtl");
89556
+ if (parts.length > 0) {
89557
+ cellHashes.push(`pa:${parts.join(":")}`);
89558
+ }
89559
+ }
89230
89560
  }
89231
89561
  }
89232
89562
  }
89563
+ let tableAttrsKey = "";
89564
+ if (tableBlock.attrs) {
89565
+ const tblAttrs = tableBlock.attrs;
89566
+ const tableAttrParts = [];
89567
+ if (tblAttrs.borders) {
89568
+ tableAttrParts.push(`tb:${hashTableBorders(tblAttrs.borders)}`);
89569
+ }
89570
+ if (tblAttrs.borderCollapse) {
89571
+ tableAttrParts.push(`bc:${tblAttrs.borderCollapse}`);
89572
+ }
89573
+ if (tblAttrs.cellSpacing !== void 0) {
89574
+ tableAttrParts.push(`cs:${tblAttrs.cellSpacing}`);
89575
+ }
89576
+ if (tableAttrParts.length > 0) {
89577
+ tableAttrsKey = `|ta:${tableAttrParts.join(":")}`;
89578
+ }
89579
+ }
89233
89580
  const contentHash = cellHashes.join("|");
89234
- return `${block.id}:table:${contentHash}`;
89581
+ return `${block.id}:table:${contentHash}${tableAttrsKey}`;
89235
89582
  }
89236
89583
  if (block.kind !== "paragraph") return block.id;
89237
89584
  const trackedMode = block.attrs && "trackedChangesMode" in block.attrs && block.attrs.trackedChangesMode || "review";
@@ -89250,12 +89597,14 @@ ${l}
89250
89597
  const color2 = "color" in run2 ? run2.color : void 0;
89251
89598
  const fontSize2 = "fontSize" in run2 ? run2.fontSize : void 0;
89252
89599
  const fontFamily2 = "fontFamily" in run2 ? run2.fontFamily : void 0;
89600
+ const highlight = "highlight" in run2 ? run2.highlight : void 0;
89253
89601
  const marks = [
89254
89602
  bold ? "b" : "",
89255
89603
  italic ? "i" : "",
89256
89604
  color2 ?? "",
89257
89605
  fontSize2 !== void 0 ? `fs:${fontSize2}` : "",
89258
- fontFamily2 ? `ff:${fontFamily2}` : ""
89606
+ fontFamily2 ? `ff:${fontFamily2}` : "",
89607
+ highlight ? `hl:${highlight}` : ""
89259
89608
  ].join("");
89260
89609
  let trackedKey = "";
89261
89610
  if (hasTrackedChange(run2)) {
@@ -90382,7 +90731,7 @@ ${l}
90382
90731
  for (let i2 = 0; i2 < a2.runs.length; i2 += 1) {
90383
90732
  const runA = a2.runs[i2];
90384
90733
  const runB = b2.runs[i2];
90385
- 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)) {
90734
+ 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)) {
90386
90735
  return false;
90387
90736
  }
90388
90737
  }
@@ -90751,17 +91100,67 @@ ${l}
90751
91100
  for (const [type2, value] of Object.entries(preHeaderLayouts)) {
90752
91101
  if (!isValidHeaderType(type2)) continue;
90753
91102
  if (value?.layout && typeof value.layout.height === "number") {
90754
- headerContentHeights[type2] = value.layout.height;
91103
+ const height = value.layout.height;
91104
+ if (Number.isFinite(height) && height >= 0) {
91105
+ headerContentHeights[type2] = height;
91106
+ }
90755
91107
  }
90756
91108
  }
90757
91109
  const hfPreEnd = performance.now();
90758
91110
  perfLog(`[Perf] 4.1.5 Pre-layout headers for height: ${(hfPreEnd - hfPreStart).toFixed(2)}ms`);
90759
91111
  }
91112
+ let footerContentHeights;
91113
+ if (headerFooter?.constraints && headerFooter.footerBlocks) {
91114
+ const footerPreStart = performance.now();
91115
+ const measureFn = headerFooter.measure ?? measureBlock2;
91116
+ if (!headerFooter.headerBlocks) {
91117
+ invalidateHeaderFooterCache(
91118
+ headerMeasureCache,
91119
+ headerFooterCacheState,
91120
+ headerFooter.headerBlocks,
91121
+ headerFooter.footerBlocks,
91122
+ headerFooter.constraints,
91123
+ options.sectionMetadata
91124
+ );
91125
+ }
91126
+ const FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT = 1;
91127
+ try {
91128
+ const preFooterLayouts = await layoutHeaderFooterWithCache(
91129
+ headerFooter.footerBlocks,
91130
+ headerFooter.constraints,
91131
+ measureFn,
91132
+ headerMeasureCache,
91133
+ FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
91134
+ void 0
91135
+ // No page resolver needed for height calculation
91136
+ );
91137
+ const isValidFooterType = (key2) => {
91138
+ return ["default", "first", "even", "odd"].includes(key2);
91139
+ };
91140
+ footerContentHeights = {};
91141
+ for (const [type2, value] of Object.entries(preFooterLayouts)) {
91142
+ if (!isValidFooterType(type2)) continue;
91143
+ if (value?.layout && typeof value.layout.height === "number") {
91144
+ const height = value.layout.height;
91145
+ if (Number.isFinite(height) && height >= 0) {
91146
+ footerContentHeights[type2] = height;
91147
+ }
91148
+ }
91149
+ }
91150
+ } catch (error) {
91151
+ console.error("[Layout] Footer pre-layout failed:", error);
91152
+ footerContentHeights = void 0;
91153
+ }
91154
+ const footerPreEnd = performance.now();
91155
+ perfLog(`[Perf] 4.1.6 Pre-layout footers for height: ${(footerPreEnd - footerPreStart).toFixed(2)}ms`);
91156
+ }
90760
91157
  const layoutStart = performance.now();
90761
91158
  let layout = layoutDocument(nextBlocks, measures, {
90762
91159
  ...options,
90763
91160
  headerContentHeights,
90764
91161
  // Pass header heights to prevent overlap
91162
+ footerContentHeights,
91163
+ // Pass footer heights to prevent overlap
90765
91164
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
90766
91165
  });
90767
91166
  const layoutEnd = performance.now();
@@ -90810,6 +91209,8 @@ ${l}
90810
91209
  ...options,
90811
91210
  headerContentHeights,
90812
91211
  // Pass header heights to prevent overlap
91212
+ footerContentHeights,
91213
+ // Pass footer heights to prevent overlap
90813
91214
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
90814
91215
  });
90815
91216
  const relayoutEnd = performance.now();
@@ -90976,6 +91377,285 @@ ${l}
90976
91377
  }
90977
91378
  return updatedMeasures;
90978
91379
  }
91380
+ class PageGeometryHelper {
91381
+ /**
91382
+ * Creates a new PageGeometryHelper instance.
91383
+ *
91384
+ * @param config - Page geometry configuration
91385
+ */
91386
+ constructor(config2) {
91387
+ this.cache = null;
91388
+ this.config = config2;
91389
+ }
91390
+ /**
91391
+ * Updates the layout and invalidates the cache.
91392
+ *
91393
+ * Call this whenever the layout changes (new pages, different heights, etc.)
91394
+ *
91395
+ * @param layout - New layout data
91396
+ * @param pageGap - Optional new page gap (if not provided, uses current gap)
91397
+ */
91398
+ updateLayout(layout, pageGap) {
91399
+ this.config.layout = layout;
91400
+ if (pageGap !== void 0) {
91401
+ this.config.pageGap = pageGap;
91402
+ }
91403
+ this.cache = null;
91404
+ }
91405
+ /**
91406
+ * Updates the page gap and invalidates the cache.
91407
+ *
91408
+ * @param pageGap - New gap between pages in pixels
91409
+ */
91410
+ updatePageGap(pageGap) {
91411
+ if (this.config.pageGap !== pageGap) {
91412
+ this.config.pageGap = pageGap;
91413
+ this.cache = null;
91414
+ }
91415
+ }
91416
+ /**
91417
+ * Gets the cumulative Y position (top edge) of a page in container space.
91418
+ *
91419
+ * The returned value is the distance from the top of the container to the
91420
+ * top of the specified page, accounting for all previous pages and gaps.
91421
+ *
91422
+ * @param pageIndex - Zero-based page index
91423
+ * @returns Y position in pixels, or 0 if page index is invalid
91424
+ *
91425
+ * @example
91426
+ * ```typescript
91427
+ * // Get Y position of page 0 (first page)
91428
+ * const y0 = helper.getPageTop(0); // Returns 0
91429
+ *
91430
+ * // Get Y position of page 2 (third page)
91431
+ * // Assumes page 0 height = 1000, page 1 height = 1200, gap = 24
91432
+ * const y2 = helper.getPageTop(2); // Returns 1000 + 24 + 1200 + 24 = 2248
91433
+ * ```
91434
+ */
91435
+ getPageTop(pageIndex) {
91436
+ this.ensureCache();
91437
+ if (pageIndex < 0 || pageIndex >= this.cache.cumulativeY.length) {
91438
+ return 0;
91439
+ }
91440
+ return this.cache.cumulativeY[pageIndex];
91441
+ }
91442
+ /**
91443
+ * Gets the height of a specific page.
91444
+ *
91445
+ * Uses per-page height if available (from layout.pages[i].size?.h),
91446
+ * otherwise falls back to layout.pageSize.h.
91447
+ *
91448
+ * @param pageIndex - Zero-based page index
91449
+ * @returns Page height in pixels, or 0 if page index is invalid
91450
+ *
91451
+ * @example
91452
+ * ```typescript
91453
+ * const height = helper.getPageHeight(0); // Returns page-specific height
91454
+ * ```
91455
+ */
91456
+ getPageHeight(pageIndex) {
91457
+ this.ensureCache();
91458
+ if (pageIndex < 0 || pageIndex >= this.cache.pageHeights.length) {
91459
+ return 0;
91460
+ }
91461
+ return this.cache.pageHeights[pageIndex];
91462
+ }
91463
+ /**
91464
+ * Gets the gap between pages.
91465
+ *
91466
+ * @returns Gap in pixels
91467
+ *
91468
+ * @example
91469
+ * ```typescript
91470
+ * const gap = helper.getPageGap(); // Returns 24
91471
+ * ```
91472
+ */
91473
+ getPageGap() {
91474
+ this.ensureCache();
91475
+ return this.cache.pageGap;
91476
+ }
91477
+ /**
91478
+ * Gets the total height of all pages including gaps.
91479
+ *
91480
+ * Total height = sum of all page heights + (pageCount - 1) * gap
91481
+ *
91482
+ * @returns Total height in pixels
91483
+ *
91484
+ * @example
91485
+ * ```typescript
91486
+ * // 3 pages: heights [1000, 1200, 1000], gap = 24
91487
+ * const total = helper.getTotalHeight();
91488
+ * // Returns 1000 + 24 + 1200 + 24 + 1000 = 3248
91489
+ * ```
91490
+ */
91491
+ getTotalHeight() {
91492
+ this.ensureCache();
91493
+ return this.cache.totalHeight;
91494
+ }
91495
+ /**
91496
+ * Gets the number of pages in the layout.
91497
+ *
91498
+ * @returns Page count
91499
+ */
91500
+ getPageCount() {
91501
+ return this.config.layout.pages.length;
91502
+ }
91503
+ /**
91504
+ * Finds the page index containing a given Y coordinate.
91505
+ *
91506
+ * This performs a linear search through cached cumulative positions.
91507
+ * For large documents, consider adding binary search optimization.
91508
+ *
91509
+ * @param containerY - Y coordinate in container space
91510
+ * @returns Page index, or null if Y is outside all pages
91511
+ *
91512
+ * @example
91513
+ * ```typescript
91514
+ * // Find which page contains Y = 1500
91515
+ * const pageIndex = helper.getPageIndexAtY(1500);
91516
+ * // Returns 1 (second page) if first page ends at Y=1024
91517
+ * ```
91518
+ */
91519
+ getPageIndexAtY(containerY) {
91520
+ this.ensureCache();
91521
+ const cache2 = this.cache;
91522
+ for (let i2 = 0; i2 < cache2.cumulativeY.length; i2++) {
91523
+ const pageTop = cache2.cumulativeY[i2];
91524
+ const pageBottom = pageTop + cache2.pageHeights[i2];
91525
+ if (containerY >= pageTop && containerY < pageBottom) {
91526
+ return i2;
91527
+ }
91528
+ }
91529
+ return null;
91530
+ }
91531
+ /**
91532
+ * Finds the nearest page index to a given Y coordinate (snap-to-nearest).
91533
+ *
91534
+ * Returns the page containing Y when inside a page; otherwise returns the
91535
+ * closest page based on distance to page center. Useful for dragging through
91536
+ * page gaps where getPageIndexAtY would return null.
91537
+ *
91538
+ * @param containerY - Y coordinate in container space
91539
+ * @returns Nearest page index, or null if there are no pages
91540
+ */
91541
+ getNearestPageIndex(containerY) {
91542
+ this.ensureCache();
91543
+ const cache2 = this.cache;
91544
+ const pageCount = cache2.pageHeights.length;
91545
+ if (pageCount === 0) return null;
91546
+ const direct = this.getPageIndexAtY(containerY);
91547
+ if (direct !== null) return direct;
91548
+ let nearestIndex = 0;
91549
+ let nearestDistance = Infinity;
91550
+ for (let i2 = 0; i2 < pageCount; i2++) {
91551
+ const top2 = cache2.cumulativeY[i2];
91552
+ const height = cache2.pageHeights[i2];
91553
+ const center = top2 + height / 2;
91554
+ const distance = Math.abs(containerY - center);
91555
+ if (distance < nearestDistance) {
91556
+ nearestDistance = distance;
91557
+ nearestIndex = i2;
91558
+ }
91559
+ }
91560
+ return nearestIndex;
91561
+ }
91562
+ /**
91563
+ * Ensures the cache is built and up-to-date.
91564
+ * Validates cache state and rebuilds if needed.
91565
+ * @private
91566
+ * @throws Never throws - handles errors gracefully with fallback values
91567
+ */
91568
+ ensureCache() {
91569
+ if (this.cache !== null) {
91570
+ if (!Array.isArray(this.cache.cumulativeY) || !Array.isArray(this.cache.pageHeights)) {
91571
+ console.warn("[PageGeometryHelper] Cache corruption detected, rebuilding cache");
91572
+ this.cache = null;
91573
+ } else {
91574
+ return;
91575
+ }
91576
+ }
91577
+ this.buildCache();
91578
+ }
91579
+ /**
91580
+ * Builds the geometry cache from current layout data.
91581
+ * Handles errors gracefully by providing fallback values.
91582
+ * @private
91583
+ * @throws Never throws - catches all errors and provides safe defaults
91584
+ */
91585
+ buildCache() {
91586
+ try {
91587
+ const layout = this.config.layout;
91588
+ if (!layout || !Array.isArray(layout.pages)) {
91589
+ throw new Error("Invalid layout: missing or invalid pages array");
91590
+ }
91591
+ const pageGap = this.config.pageGap ?? layout.pageGap ?? 0;
91592
+ const pageCount = layout.pages.length;
91593
+ if (!Number.isFinite(pageGap) || pageGap < 0) {
91594
+ throw new Error(`Invalid pageGap: ${pageGap} (must be non-negative finite number)`);
91595
+ }
91596
+ const cumulativeY = new Array(pageCount);
91597
+ const pageHeights = new Array(pageCount);
91598
+ let currentY = 0;
91599
+ for (let i2 = 0; i2 < pageCount; i2++) {
91600
+ const page = layout.pages[i2];
91601
+ if (!page) {
91602
+ throw new Error(`Invalid page at index ${i2}: page is null or undefined`);
91603
+ }
91604
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
91605
+ if (!Number.isFinite(pageHeight) || pageHeight < 0) {
91606
+ throw new Error(`Invalid page height at index ${i2}: ${pageHeight} (must be non-negative finite number)`);
91607
+ }
91608
+ cumulativeY[i2] = currentY;
91609
+ pageHeights[i2] = pageHeight;
91610
+ currentY += pageHeight;
91611
+ if (i2 < pageCount - 1) {
91612
+ currentY += pageGap;
91613
+ }
91614
+ }
91615
+ const totalHeight = currentY;
91616
+ this.cache = {
91617
+ cumulativeY,
91618
+ pageHeights,
91619
+ pageGap,
91620
+ totalHeight,
91621
+ layoutVersion: 0
91622
+ // Placeholder for future version tracking
91623
+ };
91624
+ } catch (error) {
91625
+ const errorMessage = error instanceof Error ? error.message : String(error);
91626
+ console.error(`[PageGeometryHelper] Cache build failed: ${errorMessage}. Using fallback empty cache.`);
91627
+ this.cache = {
91628
+ cumulativeY: [],
91629
+ pageHeights: [],
91630
+ pageGap: 0,
91631
+ totalHeight: 0,
91632
+ layoutVersion: 0
91633
+ };
91634
+ }
91635
+ }
91636
+ /**
91637
+ * Clears the cache, forcing recalculation on next access.
91638
+ * Useful for testing or manual cache invalidation.
91639
+ */
91640
+ clearCache() {
91641
+ this.cache = null;
91642
+ }
91643
+ /**
91644
+ * Gets debug information about the current cache state.
91645
+ * @internal
91646
+ */
91647
+ getDebugInfo() {
91648
+ this.ensureCache();
91649
+ return {
91650
+ isCached: this.cache !== null,
91651
+ pageCount: this.config.layout.pages.length,
91652
+ pageGap: this.cache.pageGap,
91653
+ totalHeight: this.cache.totalHeight,
91654
+ cumulativeY: [...this.cache.cumulativeY],
91655
+ pageHeights: [...this.cache.pageHeights]
91656
+ };
91657
+ }
91658
+ }
90979
91659
  var Priority = /* @__PURE__ */ ((Priority2) => {
90980
91660
  Priority2[Priority2["P0"] = 0] = "P0";
90981
91661
  Priority2[Priority2["P1"] = 1] = "P1";
@@ -91269,18 +91949,41 @@ ${l}
91269
91949
  const effectiveEndA = endA ?? startA + 1;
91270
91950
  return effectiveEndA > startB && startA < endB;
91271
91951
  };
91272
- function hitTestPage(layout, point2) {
91952
+ function hitTestPage(layout, point2, geometryHelper) {
91953
+ if (geometryHelper) {
91954
+ const pageIndex = geometryHelper.getPageIndexAtY(point2.y);
91955
+ if (pageIndex !== null) {
91956
+ return { pageIndex, page: layout.pages[pageIndex] };
91957
+ }
91958
+ const nearest = geometryHelper.getNearestPageIndex(point2.y);
91959
+ if (nearest !== null) {
91960
+ return { pageIndex: nearest, page: layout.pages[nearest] };
91961
+ }
91962
+ return null;
91963
+ }
91273
91964
  const pageGap = layout.pageGap ?? 0;
91274
91965
  let cursorY = 0;
91966
+ let nearestIndex = null;
91967
+ let nearestDistance = Infinity;
91275
91968
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
91276
91969
  const page = layout.pages[pageIndex];
91970
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
91277
91971
  const top2 = cursorY;
91278
- const bottom2 = top2 + layout.pageSize.h;
91972
+ const bottom2 = top2 + pageHeight;
91279
91973
  if (point2.y >= top2 && point2.y < bottom2) {
91280
91974
  return { pageIndex, page };
91281
91975
  }
91976
+ const center = top2 + pageHeight / 2;
91977
+ const distance = Math.abs(point2.y - center);
91978
+ if (distance < nearestDistance) {
91979
+ nearestDistance = distance;
91980
+ nearestIndex = pageIndex;
91981
+ }
91282
91982
  cursorY = bottom2 + pageGap;
91283
91983
  }
91984
+ if (nearestIndex !== null) {
91985
+ return { pageIndex: nearestIndex, page: layout.pages[nearestIndex] };
91986
+ }
91284
91987
  return null;
91285
91988
  }
91286
91989
  function hitTestFragment(layout, pageHit, blocks2, measures, point2) {
@@ -91441,7 +92144,7 @@ ${l}
91441
92144
  }
91442
92145
  return null;
91443
92146
  };
91444
- function clickToPosition(layout, blocks2, measures, containerPoint, domContainer, clientX, clientY) {
92147
+ function clickToPosition(layout, blocks2, measures, containerPoint, domContainer, clientX, clientY, geometryHelper) {
91445
92148
  logClickStage("log", "entry", {
91446
92149
  pages: layout.pages.length
91447
92150
  });
@@ -91484,75 +92187,132 @@ ${l}
91484
92187
  return { pos: domPos, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
91485
92188
  }
91486
92189
  }
91487
- const pageHit = hitTestPage(layout, containerPoint);
92190
+ const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
91488
92191
  if (!pageHit) {
91489
92192
  return null;
91490
92193
  }
91491
- const pageGap = layout.pageGap ?? 0;
92194
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
91492
92195
  const pageRelativePoint = {
91493
92196
  x: containerPoint.x,
91494
- y: containerPoint.y - pageHit.pageIndex * (layout.pageSize.h + pageGap)
92197
+ y: containerPoint.y - pageTopY
91495
92198
  };
91496
92199
  logClickStage("log", "page-hit", {
91497
92200
  pageIndex: pageHit.pageIndex
91498
92201
  });
91499
- const fragmentHit = hitTestFragment(layout, pageHit, blocks2, measures, pageRelativePoint);
92202
+ let fragmentHit = hitTestFragment(layout, pageHit, blocks2, measures, pageRelativePoint);
92203
+ if (!fragmentHit) {
92204
+ const page = pageHit.page;
92205
+ const fragments = page.fragments.filter(
92206
+ (f2) => f2 != null && typeof f2 === "object"
92207
+ );
92208
+ if (fragments.length > 0) {
92209
+ let nearest = null;
92210
+ let nearestDist = Infinity;
92211
+ for (const frag of fragments) {
92212
+ const top2 = frag.y;
92213
+ const bottom2 = frag.y + frag.height;
92214
+ let dist2;
92215
+ if (pageRelativePoint.y < top2) {
92216
+ dist2 = top2 - pageRelativePoint.y;
92217
+ } else if (pageRelativePoint.y > bottom2) {
92218
+ dist2 = pageRelativePoint.y - bottom2;
92219
+ } else {
92220
+ dist2 = 0;
92221
+ }
92222
+ if (dist2 < nearestDist) {
92223
+ nearestDist = dist2;
92224
+ nearest = frag;
92225
+ }
92226
+ }
92227
+ if (nearest) {
92228
+ const blockIndex = findBlockIndexByFragmentId(blocks2, nearest.blockId);
92229
+ if (blockIndex !== -1) {
92230
+ const block = blocks2[blockIndex];
92231
+ const measure = measures[blockIndex];
92232
+ if (block && measure) {
92233
+ fragmentHit = {
92234
+ fragment: nearest,
92235
+ block,
92236
+ measure,
92237
+ pageIndex: pageHit.pageIndex,
92238
+ pageY: 0
92239
+ };
92240
+ }
92241
+ }
92242
+ }
92243
+ }
92244
+ }
91500
92245
  if (fragmentHit) {
91501
92246
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
91502
- if (fragment.kind !== "para" || measure.kind !== "paragraph" || block.kind !== "paragraph") {
91503
- logClickStage("warn", "fragment-type-mismatch", {
91504
- fragmentKind: fragment.kind,
91505
- measureKind: measure.kind,
91506
- blockKind: block.kind
92247
+ if (fragment.kind === "para" && measure.kind === "paragraph" && block.kind === "paragraph") {
92248
+ const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
92249
+ if (lineIndex == null) {
92250
+ logClickStage("warn", "no-line", {
92251
+ blockId: fragment.blockId
92252
+ });
92253
+ return null;
92254
+ }
92255
+ const line = measure.lines[lineIndex];
92256
+ const isRTL = isRtlBlock(block);
92257
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
92258
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
92259
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
92260
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
92261
+ const totalIndent = paraIndentLeft + paraIndentRight;
92262
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
92263
+ if (totalIndent > fragment.width) {
92264
+ console.warn(
92265
+ `[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.`
92266
+ );
92267
+ }
92268
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
92269
+ const isListItem3 = markerWidth > 0;
92270
+ const alignmentOverride = isListItem3 ? "left" : void 0;
92271
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
92272
+ if (pos == null) {
92273
+ logClickStage("warn", "no-position", {
92274
+ blockId: fragment.blockId
92275
+ });
92276
+ return null;
92277
+ }
92278
+ const column = determineColumn(layout, fragment.x);
92279
+ logPositionDebug({
92280
+ blockId: fragment.blockId,
92281
+ x: pageRelativePoint.x - fragment.x
91507
92282
  });
91508
- return null;
91509
- }
91510
- const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
91511
- if (lineIndex == null) {
91512
- logClickStage("warn", "no-line", {
92283
+ logClickStage("log", "success", {
91513
92284
  blockId: fragment.blockId
91514
92285
  });
91515
- return null;
91516
- }
91517
- const line = measure.lines[lineIndex];
91518
- const isRTL = isRtlBlock(block);
91519
- const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
91520
- const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
91521
- const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
91522
- const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
91523
- const totalIndent = paraIndentLeft + paraIndentRight;
91524
- const availableWidth = Math.max(0, fragment.width - totalIndent);
91525
- if (totalIndent > fragment.width) {
91526
- console.warn(
91527
- `[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.`
91528
- );
92286
+ return {
92287
+ pos,
92288
+ blockId: fragment.blockId,
92289
+ pageIndex,
92290
+ column,
92291
+ lineIndex
92292
+ // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
92293
+ };
91529
92294
  }
91530
- const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
91531
- const isListItem3 = markerWidth > 0;
91532
- const alignmentOverride = isListItem3 ? "left" : void 0;
91533
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
91534
- if (pos == null) {
91535
- logClickStage("warn", "no-position", {
91536
- blockId: fragment.blockId
92295
+ if (isAtomicFragment(fragment)) {
92296
+ const pmRange = getAtomicPmRange(fragment, block);
92297
+ const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
92298
+ if (pos == null) {
92299
+ logClickStage("warn", "atomic-without-range", {
92300
+ fragmentId: fragment.blockId
92301
+ });
92302
+ return null;
92303
+ }
92304
+ logClickStage("log", "success", {
92305
+ blockId: fragment.blockId,
92306
+ column: determineColumn(layout, fragment.x)
91537
92307
  });
91538
- return null;
92308
+ return {
92309
+ pos,
92310
+ blockId: fragment.blockId,
92311
+ pageIndex,
92312
+ column: determineColumn(layout, fragment.x),
92313
+ lineIndex: -1
92314
+ };
91539
92315
  }
91540
- const column = determineColumn(layout, fragment.x);
91541
- logPositionDebug({
91542
- blockId: fragment.blockId,
91543
- x: pageRelativePoint.x - fragment.x
91544
- });
91545
- logClickStage("log", "success", {
91546
- blockId: fragment.blockId
91547
- });
91548
- return {
91549
- pos,
91550
- blockId: fragment.blockId,
91551
- pageIndex,
91552
- column,
91553
- lineIndex
91554
- // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
91555
- };
91556
92316
  }
91557
92317
  const tableHit = hitTestTableFragment(pageHit, blocks2, measures, pageRelativePoint);
91558
92318
  if (tableHit) {
@@ -91702,12 +92462,22 @@ ${l}
91702
92462
  }
91703
92463
  return height;
91704
92464
  };
91705
- function selectionToRects(layout, blocks2, measures, from2, to) {
92465
+ const calculatePageTopFallback = (layout, pageIndex) => {
92466
+ const pageGap = layout.pageGap ?? 0;
92467
+ let y2 = 0;
92468
+ for (let i2 = 0; i2 < pageIndex; i2++) {
92469
+ const pageHeight = layout.pages[i2]?.size?.h ?? layout.pageSize.h;
92470
+ y2 += pageHeight + pageGap;
92471
+ }
92472
+ return y2;
92473
+ };
92474
+ function selectionToRects(layout, blocks2, measures, from2, to, geometryHelper) {
91706
92475
  if (from2 === to) {
91707
92476
  return [];
91708
92477
  }
91709
92478
  const rects = [];
91710
92479
  layout.pages.forEach((page, pageIndex) => {
92480
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageIndex) : calculatePageTopFallback(layout, pageIndex);
91711
92481
  page.fragments.forEach((fragment) => {
91712
92482
  if (fragment.kind === "para") {
91713
92483
  const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId, { from: from2, to });
@@ -91749,12 +92519,16 @@ ${l}
91749
92519
  wordLayout
91750
92520
  });
91751
92521
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
91752
- const rectWidth = Math.max(1, Math.abs(endX - startX));
92522
+ const rectWidth = Math.max(
92523
+ 1,
92524
+ Math.min(Math.abs(endX - startX), line.width)
92525
+ // clamp to line width to prevent runaway widths
92526
+ );
91753
92527
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
91754
92528
  const rectY = fragment.y + lineOffset;
91755
92529
  rects.push({
91756
92530
  x: rectX,
91757
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92531
+ y: rectY + pageTopY,
91758
92532
  width: rectWidth,
91759
92533
  height: line.lineHeight,
91760
92534
  pageIndex
@@ -91882,12 +92656,16 @@ ${l}
91882
92656
  wordLayout: cellWordLayout
91883
92657
  });
91884
92658
  const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
91885
- const rectWidth = Math.max(1, Math.abs(endX - startX));
92659
+ const rectWidth = Math.max(
92660
+ 1,
92661
+ Math.min(Math.abs(endX - startX), line.width)
92662
+ // clamp to line width to prevent runaway widths
92663
+ );
91886
92664
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
91887
92665
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
91888
92666
  rects.push({
91889
92667
  x: rectX,
91890
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92668
+ y: rectY + pageTopY,
91891
92669
  width: rectWidth,
91892
92670
  height: line.lineHeight,
91893
92671
  pageIndex
@@ -91916,7 +92694,7 @@ ${l}
91916
92694
  if (!rangesOverlap(pmRange.pmStart, pmRange.pmEnd, from2, to)) return;
91917
92695
  rects.push({
91918
92696
  x: fragment.x,
91919
- y: fragment.y + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92697
+ y: fragment.y + pageTopY,
91920
92698
  width: fragment.width,
91921
92699
  height: fragment.height,
91922
92700
  pageIndex
@@ -93032,7 +93810,7 @@ ${l}
93032
93810
  const wordEndWithSpace = charPosInRun + (isLastWord ? word.length : word.length + 1);
93033
93811
  const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
93034
93812
  if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
93035
- if (currentLine && currentLine.width > 0 && currentLine.segments.length > 0) {
93813
+ if (currentLine && currentLine.width > 0 && currentLine.segments && currentLine.segments.length > 0) {
93036
93814
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
93037
93815
  const { spaceCount: _sc, ...lineBase } = currentLine;
93038
93816
  const completedLine = { ...lineBase, ...metrics };
@@ -93043,7 +93821,7 @@ ${l}
93043
93821
  currentLine = null;
93044
93822
  }
93045
93823
  const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
93046
- const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
93824
+ const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
93047
93825
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
93048
93826
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
93049
93827
  const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
@@ -93054,7 +93832,7 @@ ${l}
93054
93832
  const chunkEndChar = chunkCharOffset + chunk.text.length;
93055
93833
  const isLastChunk = chunkIndex === chunks.length - 1;
93056
93834
  const isFirstChunk = chunkIndex === 0;
93057
- if (isFirstChunk && hasTabOnlyLine && currentLine) {
93835
+ if (isFirstChunk && hasTabOnlyLine && currentLine && currentLine.segments) {
93058
93836
  currentLine.toRun = runIndex;
93059
93837
  currentLine.toChar = chunkEndChar;
93060
93838
  currentLine.width = roundValue(currentLine.width + chunk.width);
@@ -93887,6 +94665,7 @@ ${l}
93887
94665
  const fontSizeInPixles = fontSizePt * 1.3333;
93888
94666
  const lineHeight2 = fontSizeInPixles * 1.2;
93889
94667
  applyStyleIsolationClass(editorContainer);
94668
+ const isFooter = type2 === "footer";
93890
94669
  Object.assign(editorContainer.style, {
93891
94670
  padding: "0",
93892
94671
  margin: "0",
@@ -93901,7 +94680,7 @@ ${l}
93901
94680
  fontFamily: fontFamilyCss || typeface,
93902
94681
  fontSize: `${fontSizeInPixles}px`,
93903
94682
  lineHeight: `${lineHeight2}px`,
93904
- overflow: "hidden",
94683
+ overflow: isFooter ? "visible" : "hidden",
93905
94684
  pointerEvents: "auto",
93906
94685
  // Critical: enables click interaction
93907
94686
  backgroundColor: "white"
@@ -94980,6 +95759,7 @@ ${l}
94980
95759
  const editorContainer = __privateGet$1(this, _activeEditorHost).querySelector(".super-editor");
94981
95760
  if (editorContainer instanceof HTMLElement) {
94982
95761
  editorContainer.style.top = "0";
95762
+ editorContainer.style.transform = "";
94983
95763
  }
94984
95764
  }
94985
95765
  }
@@ -95155,6 +95935,7 @@ ${l}
95155
95935
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
95156
95936
  const DEFAULT_VIRTUALIZED_PAGE_GAP = 72;
95157
95937
  const DEFAULT_PAGE_GAP = 24;
95938
+ const DEFAULT_HORIZONTAL_PAGE_GAP = 20;
95158
95939
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
95159
95940
  const MULTI_CLICK_TIME_THRESHOLD_MS = 400;
95160
95941
  const MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5;
@@ -95178,6 +95959,7 @@ ${l}
95178
95959
  __privateAdd$1(this, _layoutOptions);
95179
95960
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() });
95180
95961
  __privateAdd$1(this, _domPainter, null);
95962
+ __privateAdd$1(this, _pageGeometryHelper, null);
95181
95963
  __privateAdd$1(this, _dragHandlerCleanup, null);
95182
95964
  __privateAdd$1(this, _layoutError, null);
95183
95965
  __privateAdd$1(this, _layoutErrorState, "healthy");
@@ -95330,7 +96112,8 @@ ${l}
95330
96112
  { x: x2, y: y2 },
95331
96113
  __privateGet$1(this, _viewportHost),
95332
96114
  event.clientX,
95333
- event.clientY
96115
+ event.clientY,
96116
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
95334
96117
  );
95335
96118
  const doc22 = __privateGet$1(this, _editor3).state?.doc;
95336
96119
  const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
@@ -95529,7 +96312,8 @@ ${l}
95529
96312
  { x: normalized.x, y: normalized.y },
95530
96313
  __privateGet$1(this, _viewportHost),
95531
96314
  event.clientX,
95532
- event.clientY
96315
+ event.clientY,
96316
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
95533
96317
  );
95534
96318
  if (!hit) return;
95535
96319
  const currentTableHit = __privateMethod$1(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
@@ -96376,7 +97160,14 @@ ${l}
96376
97160
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
96377
97161
  }
96378
97162
  if (!__privateGet$1(this, _layoutState).layout) return [];
96379
- const rects = selectionToRects(__privateGet$1(this, _layoutState).layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, start2, end2) ?? [];
97163
+ const rects = selectionToRects(
97164
+ __privateGet$1(this, _layoutState).layout,
97165
+ __privateGet$1(this, _layoutState).blocks,
97166
+ __privateGet$1(this, _layoutState).measures,
97167
+ start2,
97168
+ end2,
97169
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
97170
+ ) ?? [];
96380
97171
  return rects;
96381
97172
  };
96382
97173
  const rawRects = layoutRectSource();
@@ -96641,6 +97432,7 @@ ${l}
96641
97432
  };
96642
97433
  }
96643
97434
  __privateSet(this, _domPainter, null);
97435
+ __privateSet(this, _pageGeometryHelper, null);
96644
97436
  __privateSet(this, _pendingDocChange, true);
96645
97437
  __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
96646
97438
  }
@@ -96673,7 +97465,16 @@ ${l}
96673
97465
  x: localX,
96674
97466
  y: headerPageIndex * headerPageHeight + (localY - headerPageIndex * headerPageHeight)
96675
97467
  };
96676
- const hit2 = clickToPosition(context.layout, context.blocks, context.measures, headerPoint) ?? null;
97468
+ const hit2 = clickToPosition(
97469
+ context.layout,
97470
+ context.blocks,
97471
+ context.measures,
97472
+ headerPoint,
97473
+ void 0,
97474
+ void 0,
97475
+ void 0,
97476
+ void 0
97477
+ ) ?? null;
96677
97478
  return hit2;
96678
97479
  }
96679
97480
  if (!__privateGet$1(this, _layoutState).layout) {
@@ -96686,7 +97487,8 @@ ${l}
96686
97487
  normalized,
96687
97488
  __privateGet$1(this, _viewportHost),
96688
97489
  clientX,
96689
- clientY
97490
+ clientY,
97491
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
96690
97492
  ) ?? null;
96691
97493
  return hit;
96692
97494
  }
@@ -96909,6 +97711,7 @@ ${l}
96909
97711
  __privateSet(this, _session, { mode: "body" });
96910
97712
  __privateSet(this, _activeHeaderFooterEditor, null);
96911
97713
  __privateSet(this, _domPainter, null);
97714
+ __privateSet(this, _pageGeometryHelper, null);
96912
97715
  (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
96913
97716
  __privateSet(this, _dragHandlerCleanup, null);
96914
97717
  __privateGet$1(this, _selectionOverlay2)?.remove();
@@ -96962,7 +97765,14 @@ ${l}
96962
97765
  if (!normalized) return false;
96963
97766
  const pmPos = __privateGet$1(this, _layoutState).bookmarks.get(normalized);
96964
97767
  if (pmPos == null) return false;
96965
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pmPos, pmPos + 1) ?? [];
97768
+ const rects = selectionToRects(
97769
+ layout,
97770
+ __privateGet$1(this, _layoutState).blocks,
97771
+ __privateGet$1(this, _layoutState).measures,
97772
+ pmPos,
97773
+ pmPos + 1,
97774
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
97775
+ ) ?? [];
96966
97776
  const rect = rects[0];
96967
97777
  let pageIndex = rect?.pageIndex ?? null;
96968
97778
  if (pageIndex == null) {
@@ -97026,6 +97836,7 @@ ${l}
97026
97836
  _layoutOptions = /* @__PURE__ */ new WeakMap();
97027
97837
  _layoutState = /* @__PURE__ */ new WeakMap();
97028
97838
  _domPainter = /* @__PURE__ */ new WeakMap();
97839
+ _pageGeometryHelper = /* @__PURE__ */ new WeakMap();
97029
97840
  _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
97030
97841
  _layoutError = /* @__PURE__ */ new WeakMap();
97031
97842
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
@@ -97258,18 +98069,19 @@ ${l}
97258
98069
  const normalized = /* @__PURE__ */ new Map();
97259
98070
  states?.forEach((aw, clientId) => {
97260
98071
  if (clientId === provider2.awareness?.clientID) return;
97261
- if (!aw.cursor) return;
98072
+ const awState = aw;
98073
+ if (!awState.cursor) return;
97262
98074
  try {
97263
98075
  const anchor = relativePositionToAbsolutePosition(
97264
98076
  ystate.doc,
97265
98077
  ystate.type,
97266
- Y__namespace.createRelativePositionFromJSON(aw.cursor.anchor),
98078
+ Y__namespace.createRelativePositionFromJSON(awState.cursor.anchor),
97267
98079
  ystate.binding.mapping
97268
98080
  );
97269
98081
  const head = relativePositionToAbsolutePosition(
97270
98082
  ystate.doc,
97271
98083
  ystate.type,
97272
- Y__namespace.createRelativePositionFromJSON(aw.cursor.head),
98084
+ Y__namespace.createRelativePositionFromJSON(awState.cursor.head),
97273
98085
  ystate.binding.mapping
97274
98086
  );
97275
98087
  if (anchor === null || head === null) return;
@@ -97281,9 +98093,9 @@ ${l}
97281
98093
  normalized.set(clientId, {
97282
98094
  clientId,
97283
98095
  user: {
97284
- name: aw.user?.name,
97285
- email: aw.user?.email,
97286
- color: aw.user?.color || __privateMethod$1(this, _PresentationEditor_instances, getFallbackColor_fn).call(this, clientId)
98096
+ name: awState.user?.name,
98097
+ email: awState.user?.email,
98098
+ color: awState.user?.color || __privateMethod$1(this, _PresentationEditor_instances, getFallbackColor_fn).call(this, clientId)
97287
98099
  },
97288
98100
  anchor: clampedAnchor,
97289
98101
  head: clampedHead,
@@ -97484,7 +98296,7 @@ ${l}
97484
98296
  if (!layout || !blocks2 || !measures) return;
97485
98297
  const start2 = Math.min(cursor.anchor, cursor.head);
97486
98298
  const end2 = Math.max(cursor.anchor, cursor.head);
97487
- const rects = selectionToRects(layout, blocks2, measures, start2, end2) ?? [];
98299
+ const rects = selectionToRects(layout, blocks2, measures, start2, end2, __privateGet$1(this, _pageGeometryHelper) ?? void 0) ?? [];
97488
98300
  const color2 = __privateMethod$1(this, _PresentationEditor_instances, getValidatedColor_fn).call(this, cursor);
97489
98301
  const opacity = __privateGet$1(this, _layoutOptions).presence?.highlightOpacity ?? 0.35;
97490
98302
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
@@ -97844,15 +98656,25 @@ ${l}
97844
98656
  const configuredPageSize = __privateGet$1(this, _layoutOptions).pageSize ?? DEFAULT_PAGE_SIZE;
97845
98657
  let pageY = 0;
97846
98658
  let pageHit = null;
97847
- for (let i2 = 0; i2 < layout.pages.length; i2++) {
97848
- const page = layout.pages[i2];
97849
- const pageHeight = page.size?.h ?? configuredPageSize.h;
97850
- const gap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? DEFAULT_PAGE_GAP;
97851
- if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
97852
- pageHit = { pageIndex: i2, page };
97853
- break;
98659
+ const geometryHelper = __privateGet$1(this, _pageGeometryHelper);
98660
+ if (geometryHelper) {
98661
+ const idx = geometryHelper.getPageIndexAtY(normalizedY) ?? geometryHelper.getNearestPageIndex(normalizedY);
98662
+ if (idx != null && layout.pages[idx]) {
98663
+ pageHit = { pageIndex: idx, page: layout.pages[idx] };
98664
+ pageY = geometryHelper.getPageTop(idx);
98665
+ }
98666
+ }
98667
+ if (!pageHit) {
98668
+ const gap = layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98669
+ for (let i2 = 0; i2 < layout.pages.length; i2++) {
98670
+ const page = layout.pages[i2];
98671
+ const pageHeight = page.size?.h ?? configuredPageSize.h;
98672
+ if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
98673
+ pageHit = { pageIndex: i2, page };
98674
+ break;
98675
+ }
98676
+ pageY += pageHeight + gap;
97854
98677
  }
97855
- pageY += pageHeight + gap;
97856
98678
  }
97857
98679
  if (!pageHit) {
97858
98680
  return null;
@@ -98104,12 +98926,7 @@ ${l}
98104
98926
  return;
98105
98927
  }
98106
98928
  ({ layout, measures } = result);
98107
- if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
98108
- const gap = __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP;
98109
- layout.pageGap = Math.max(0, gap);
98110
- } else {
98111
- layout.pageGap = DEFAULT_PAGE_GAP;
98112
- }
98929
+ layout.pageGap = __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98113
98930
  headerLayouts = result.headers;
98114
98931
  footerLayouts = result.footers;
98115
98932
  } catch (error) {
@@ -98126,6 +98943,17 @@ ${l}
98126
98943
  __privateSet(this, _layoutState, { blocks: blocks2, measures, layout, bookmarks, anchorMap });
98127
98944
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
98128
98945
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
98946
+ if (__privateGet$1(this, _layoutState).layout) {
98947
+ const pageGap = __privateGet$1(this, _layoutState).layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98948
+ if (!__privateGet$1(this, _pageGeometryHelper)) {
98949
+ __privateSet(this, _pageGeometryHelper, new PageGeometryHelper({
98950
+ layout: __privateGet$1(this, _layoutState).layout,
98951
+ pageGap
98952
+ }));
98953
+ } else {
98954
+ __privateGet$1(this, _pageGeometryHelper).updateLayout(__privateGet$1(this, _layoutState).layout, pageGap);
98955
+ }
98956
+ }
98129
98957
  await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
98130
98958
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
98131
98959
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks2, measures);
@@ -98195,7 +99023,8 @@ ${l}
98195
99023
  pageStyles: __privateGet$1(this, _layoutOptions).pageStyles,
98196
99024
  headerProvider: __privateGet$1(this, _headerDecorationProvider),
98197
99025
  footerProvider: __privateGet$1(this, _footerDecorationProvider),
98198
- ruler: __privateGet$1(this, _layoutOptions).ruler
99026
+ ruler: __privateGet$1(this, _layoutOptions).ruler,
99027
+ pageGap: __privateGet$1(this, _layoutState).layout?.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this)
98199
99028
  }));
98200
99029
  }
98201
99030
  return __privateGet$1(this, _domPainter);
@@ -98283,7 +99112,14 @@ ${l}
98283
99112
  }
98284
99113
  return;
98285
99114
  }
98286
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
99115
+ const rects = selectionToRects(
99116
+ layout,
99117
+ __privateGet$1(this, _layoutState).blocks,
99118
+ __privateGet$1(this, _layoutState).measures,
99119
+ from2,
99120
+ to,
99121
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
99122
+ ) ?? [];
98287
99123
  let domStart = null;
98288
99124
  let domEnd = null;
98289
99125
  try {
@@ -98297,7 +99133,9 @@ ${l}
98297
99133
  const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
98298
99134
  try {
98299
99135
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
98300
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
99136
+ if (correctedRects.length > 0) {
99137
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
99138
+ }
98301
99139
  } catch (error) {
98302
99140
  if (process$1$1.env.NODE_ENV === "development") {
98303
99141
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -98489,8 +99327,10 @@ ${l}
98489
99327
  const pageHeight2 = page?.size?.h ?? layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
98490
99328
  const margins2 = pageMargins ?? layout.pages[0]?.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
98491
99329
  const box2 = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, kind, margins2, pageHeight2);
99330
+ const layoutMinY2 = rIdLayout.layout.minY ?? 0;
99331
+ const normalizedFragments2 = layoutMinY2 < 0 ? fragments2.map((f2) => ({ ...f2, y: f2.y - layoutMinY2 })) : fragments2;
98492
99332
  return {
98493
- fragments: fragments2,
99333
+ fragments: normalizedFragments2,
98494
99334
  height: box2.height,
98495
99335
  contentHeight: rIdLayout.layout.height ?? box2.height,
98496
99336
  offset: box2.offset,
@@ -98498,6 +99338,7 @@ ${l}
98498
99338
  contentWidth: box2.width,
98499
99339
  headerId: sectionRId,
98500
99340
  sectionType: headerFooterType,
99341
+ minY: layoutMinY2,
98501
99342
  box: {
98502
99343
  x: box2.x,
98503
99344
  y: box2.offset,
@@ -98530,8 +99371,10 @@ ${l}
98530
99371
  const box = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, kind, margins, pageHeight);
98531
99372
  const fallbackId = __privateGet$1(this, _headerFooterManager)?.getVariantId(kind, headerFooterType);
98532
99373
  const finalHeaderId = sectionRId ?? fallbackId ?? void 0;
99374
+ const layoutMinY = variant.layout.minY ?? 0;
99375
+ const normalizedFragments = layoutMinY < 0 ? fragments.map((f2) => ({ ...f2, y: f2.y - layoutMinY })) : fragments;
98533
99376
  return {
98534
- fragments,
99377
+ fragments: normalizedFragments,
98535
99378
  height: box.height,
98536
99379
  contentHeight: variant.layout.height ?? box.height,
98537
99380
  offset: box.offset,
@@ -98539,6 +99382,7 @@ ${l}
98539
99382
  contentWidth: box.width,
98540
99383
  headerId: finalHeaderId,
98541
99384
  sectionType: headerFooterType,
99385
+ minY: layoutMinY,
98542
99386
  box: {
98543
99387
  x: box.x,
98544
99388
  y: box.offset,
@@ -98653,7 +99497,9 @@ ${l}
98653
99497
  localX: footerPayload?.hitRegion?.x ?? footerBox.x,
98654
99498
  localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
98655
99499
  width: footerPayload?.hitRegion?.width ?? footerBox.width,
98656
- height: footerPayload?.hitRegion?.height ?? footerBox.height
99500
+ height: footerPayload?.hitRegion?.height ?? footerBox.height,
99501
+ contentHeight: footerPayload?.contentHeight,
99502
+ minY: footerPayload?.minY
98657
99503
  });
98658
99504
  });
98659
99505
  };
@@ -98783,6 +99629,18 @@ ${l}
98783
99629
  });
98784
99630
  return;
98785
99631
  }
99632
+ if (region.kind === "footer") {
99633
+ const editorContainer = editorHost.firstElementChild;
99634
+ if (editorContainer instanceof HTMLElement) {
99635
+ editorContainer.style.overflow = "visible";
99636
+ if (region.minY != null && region.minY < 0) {
99637
+ const shiftDown = Math.abs(region.minY);
99638
+ editorContainer.style.transform = `translateY(${shiftDown}px)`;
99639
+ } else {
99640
+ editorContainer.style.transform = "";
99641
+ }
99642
+ }
99643
+ }
98786
99644
  try {
98787
99645
  editor.setEditable(true);
98788
99646
  editor.setOptions({ documentMode: "editing" });
@@ -99065,6 +99923,15 @@ ${l}
99065
99923
  checkPage();
99066
99924
  });
99067
99925
  };
99926
+ getEffectivePageGap_fn = function() {
99927
+ if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
99928
+ return Math.max(0, __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP);
99929
+ }
99930
+ if (__privateGet$1(this, _layoutOptions).layoutMode === "horizontal") {
99931
+ return DEFAULT_HORIZONTAL_PAGE_GAP;
99932
+ }
99933
+ return DEFAULT_PAGE_GAP;
99934
+ };
99068
99935
  getBodyPageHeight_fn = function() {
99069
99936
  return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
99070
99937
  };
@@ -99088,7 +99955,7 @@ ${l}
99088
99955
  dy: domStart.y - layoutY
99089
99956
  };
99090
99957
  }
99091
- return rects.map((rect, idx) => {
99958
+ const corrected = rects.map((rect, idx) => {
99092
99959
  const delta = pageDelta[rect.pageIndex];
99093
99960
  let adjustedX = delta ? rect.x + delta.dx : rect.x;
99094
99961
  let adjustedY = delta ? rect.y + delta.dy : rect.y;
@@ -99103,6 +99970,7 @@ ${l}
99103
99970
  }
99104
99971
  if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
99105
99972
  const endX = domEnd.x;
99973
+ adjustedX = Math.min(adjustedX, endX);
99106
99974
  adjustedWidth = Math.max(1, endX - adjustedX);
99107
99975
  }
99108
99976
  return {
@@ -99112,6 +99980,29 @@ ${l}
99112
99980
  width: adjustedWidth
99113
99981
  };
99114
99982
  });
99983
+ const MAX_DELTA_PX = 12;
99984
+ let invalid2 = false;
99985
+ if (domStart && corrected[0]) {
99986
+ const dx = Math.abs(corrected[0].x - domStart.x);
99987
+ const dy = Math.abs(corrected[0].y - domStart.y);
99988
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid2 = true;
99989
+ }
99990
+ if (domEnd && corrected[corrected.length - 1]) {
99991
+ const last = corrected[corrected.length - 1];
99992
+ const dx = Math.abs(last.x + last.width - domEnd.x);
99993
+ const dy = Math.abs(last.y - domEnd.y);
99994
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid2 = true;
99995
+ }
99996
+ if (invalid2) {
99997
+ console.warn("[SelectionOverlay] Suppressing selection render due to large DOM/Layout mismatch", {
99998
+ domStart,
99999
+ domEnd,
100000
+ rectStart: corrected[0],
100001
+ rectEnd: corrected[corrected.length - 1]
100002
+ });
100003
+ return [];
100004
+ }
100005
+ return corrected;
99115
100006
  };
99116
100007
  renderCellSelectionOverlay_fn = function(selection, layout) {
99117
100008
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
@@ -99395,7 +100286,7 @@ ${l}
99395
100286
  return [];
99396
100287
  }
99397
100288
  if (!bodyLayout) return [];
99398
- const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to) ?? [];
100289
+ const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to, void 0) ?? [];
99399
100290
  const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
99400
100291
  const bodyPageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
99401
100292
  return rects.map((rect) => {
@@ -99678,8 +100569,8 @@ ${l}
99678
100569
  const zoom2 = __privateGet$1(this, _layoutOptions).zoom ?? 1;
99679
100570
  let domCaretX2 = null;
99680
100571
  let domCaretY2 = null;
99681
- const spanEls2 = pageEl2?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
99682
- for (const spanEl of spanEls2) {
100572
+ const spanEls2 = pageEl2?.querySelectorAll("span[data-pm-start][data-pm-end]");
100573
+ for (const spanEl of Array.from(spanEls2 ?? [])) {
99683
100574
  const pmStart = Number(spanEl.dataset.pmStart);
99684
100575
  const pmEnd = Number(spanEl.dataset.pmEnd);
99685
100576
  if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
@@ -99731,8 +100622,8 @@ ${l}
99731
100622
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
99732
100623
  let domCaretX = null;
99733
100624
  let domCaretY = null;
99734
- const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
99735
- for (const spanEl of spanEls) {
100625
+ const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]");
100626
+ for (const spanEl of Array.from(spanEls ?? [])) {
99736
100627
  const pmStart = Number(spanEl.dataset.pmStart);
99737
100628
  const pmEnd = Number(spanEl.dataset.pmEnd);
99738
100629
  if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
@@ -99862,7 +100753,14 @@ ${l}
99862
100753
  if (!layout || !selection) {
99863
100754
  return 0;
99864
100755
  }
99865
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, selection.from, selection.to) ?? [];
100756
+ const rects = selectionToRects(
100757
+ layout,
100758
+ __privateGet$1(this, _layoutState).blocks,
100759
+ __privateGet$1(this, _layoutState).measures,
100760
+ selection.from,
100761
+ selection.to,
100762
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
100763
+ ) ?? [];
99866
100764
  if (rects.length > 0) {
99867
100765
  return rects[0]?.pageIndex ?? 0;
99868
100766
  }
@@ -105294,14 +106192,19 @@ ${l}
105294
106192
  }
105295
106193
  return cellType.createAndFill();
105296
106194
  };
105297
- const createTableBorders = ({ size: size2 = 0.66665, color: color2 = "#000000" } = {}) => {
106195
+ const createTableBorders = (borderSpec = {}) => {
106196
+ borderSpec = {
106197
+ size: 0.66665,
106198
+ color: "#000000",
106199
+ ...borderSpec
106200
+ };
105298
106201
  return {
105299
- top: { size: size2, color: color2 },
105300
- left: { size: size2, color: color2 },
105301
- bottom: { size: size2, color: color2 },
105302
- right: { size: size2, color: color2 },
105303
- insideH: { size: size2, color: color2 },
105304
- insideV: { size: size2, color: color2 }
106202
+ top: borderSpec,
106203
+ left: borderSpec,
106204
+ bottom: borderSpec,
106205
+ right: borderSpec,
106206
+ insideH: borderSpec,
106207
+ insideV: borderSpec
105305
106208
  };
105306
106209
  };
105307
106210
  const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent = null) => {
@@ -105429,12 +106332,17 @@ ${l}
105429
106332
  editor.commands.deleteTable();
105430
106333
  return true;
105431
106334
  };
105432
- const createCellBorders = ({ size: size2 = 0.66665, color: color2 = "#000000" } = {}) => {
106335
+ const createCellBorders = (borderSpec = {}) => {
106336
+ borderSpec = {
106337
+ size: 0.66665,
106338
+ color: "#000000",
106339
+ ...borderSpec
106340
+ };
105433
106341
  return {
105434
- top: { size: size2, color: color2 },
105435
- left: { size: size2, color: color2 },
105436
- bottom: { size: size2, color: color2 },
105437
- right: { size: size2, color: color2 }
106342
+ top: borderSpec,
106343
+ left: borderSpec,
106344
+ bottom: borderSpec,
106345
+ right: borderSpec
105438
106346
  };
105439
106347
  };
105440
106348
  function cellAround($pos) {
@@ -106201,13 +107109,20 @@ ${l}
106201
107109
  if (["tableCell", "tableHeader"].includes(node2.type.name)) {
106202
107110
  tr.setNodeMarkup(pos, void 0, {
106203
107111
  ...node2.attrs,
106204
- borders: createCellBorders({ size: 0 })
107112
+ borders: createCellBorders({ size: 0, space: 0, val: "none", color: "auto" })
106205
107113
  });
106206
107114
  }
106207
107115
  });
106208
107116
  tr.setNodeMarkup(table2.pos, void 0, {
106209
107117
  ...table2.node.attrs,
106210
- borders: createTableBorders({ size: 0 })
107118
+ borders: createTableBorders({ size: 0 }),
107119
+ // TODO: This works around the issue that table borders are duplicated between
107120
+ // the attributes of the table and the tableProperties attribute.
107121
+ // This can be removed when the redundancy is eliminated.
107122
+ tableProperties: {
107123
+ ...table2.node.attrs.tableProperties,
107124
+ borders: createTableBorders({ size: 0, space: 0, val: "none", color: "auto" })
107125
+ }
106211
107126
  });
106212
107127
  return true;
106213
107128
  }
@@ -130209,7 +131124,7 @@ ${style2}
130209
131124
  }
130210
131125
  },
130211
131126
  {
130212
- label: toolbarTexts2.transparentBorders,
131127
+ label: toolbarTexts2.removeBorders,
130213
131128
  command: "deleteCellAndTableBorders",
130214
131129
  icon: toolbarIcons2.deleteBorders,
130215
131130
  bottomBorder: true,
@@ -130790,7 +131705,7 @@ ${style2}
130790
131705
  deleteRow: "Delete row",
130791
131706
  deleteColumn: "Delete column",
130792
131707
  deleteTable: "Delete table",
130793
- transparentBorders: "Transparent borders",
131708
+ removeBorders: "Remove borders",
130794
131709
  mergeCells: "Merge cells",
130795
131710
  splitCell: "Split cell",
130796
131711
  fixTables: "Fix tables",
@@ -131828,7 +132743,7 @@ ${style2}
131828
132743
  deleteRow: "Delete row",
131829
132744
  deleteColumn: "Delete column",
131830
132745
  deleteTable: "Delete table",
131831
- transparentBorders: "Transparent borders",
132746
+ removeBorders: "Remove borders",
131832
132747
  mergeCells: "Merge cells",
131833
132748
  splitCell: "Split cell",
131834
132749
  fixTables: "Fix tables",
@@ -131911,7 +132826,7 @@ ${style2}
131911
132826
  }
131912
132827
  },
131913
132828
  {
131914
- label: TEXTS.transparentBorders,
132829
+ label: TEXTS.removeBorders,
131915
132830
  command: "deleteCellAndTableBorders",
131916
132831
  icon: ICONS.deleteBorders,
131917
132832
  bottomBorder: true,
@@ -150458,19 +151373,10 @@ ${style2}
150458
151373
  measurementTimeoutId.value = null;
150459
151374
  }
150460
151375
  const totalComments = getFloatingComments.value.length;
150461
- const measuredComments = renderedSizes.value.length;
150462
151376
  if (totalComments === 0) {
150463
151377
  return;
150464
151378
  }
150465
- if (measuredComments === totalComments) {
150466
- nextTick(processLocations);
150467
- } else if (measuredComments > 0 && !firstGroupRendered.value) {
150468
- measurementTimeoutId.value = setTimeout(() => {
150469
- if (!firstGroupRendered.value && renderedSizes.value.length > 0) {
150470
- processLocations();
150471
- }
150472
- }, 100);
150473
- }
151379
+ nextTick(processLocations);
150474
151380
  });
150475
151381
  watch(activeComment, (newVal, oldVal) => {
150476
151382
  nextTick(() => {
@@ -150548,7 +151454,7 @@ ${style2}
150548
151454
  };
150549
151455
  }
150550
151456
  };
150551
- const FloatingComments = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-eab6fbfa"]]);
151457
+ const FloatingComments = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-6905dd07"]]);
150552
151458
  const _sfc_main$9 = {
150553
151459
  __name: "TextField",
150554
151460
  props: {
@@ -152065,7 +152971,7 @@ ${style2}
152065
152971
  this.config.colors = shuffleArray(this.config.colors);
152066
152972
  this.userColorMap = /* @__PURE__ */ new Map();
152067
152973
  this.colorIndex = 0;
152068
- this.version = "1.0.0-beta.98";
152974
+ this.version = "1.0.0-next.1";
152069
152975
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
152070
152976
  this.superdocId = config2.superdocId || v4();
152071
152977
  this.colors = this.config.colors;
@@ -154537,7 +155443,7 @@ ${style2}
154537
155443
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
154538
155444
  );
154539
155445
  }
154540
- const indexDg_sTYZK = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
155446
+ const indexDlj3l0Hk = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
154541
155447
  __proto__: null,
154542
155448
  unified
154543
155449
  }, Symbol.toStringTag, { value: "Module" }));