superdoc 1.0.0-beta.21 → 1.0.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/chunks/{PdfViewer-CqAQvFv3.cjs → PdfViewer-C9mryfp4.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-CEwbF85g.es.js → PdfViewer-umOKwA1g.es.js} +1 -1
  3. package/dist/chunks/{index-DSuc12CK-Dpg5Hd9W.cjs → index-DYBG7Xab-CoI6fike.cjs} +1 -1
  4. package/dist/chunks/{index-DSuc12CK-DH_DeF0B.es.js → index-DYBG7Xab-mIeLdlWI.es.js} +1 -1
  5. package/dist/chunks/{index-BFobqgP4.es.js → index-DyY842H4.es.js} +7 -5
  6. package/dist/chunks/{index-Dy-eAVHL.cjs → index-Q-l_lwcU.cjs} +7 -5
  7. package/dist/chunks/{super-editor.es-C2UuUFg3.cjs → super-editor.es-49DW4_-r.cjs} +445 -135
  8. package/dist/chunks/{super-editor.es-B5YJmpPg.es.js → super-editor.es-Cj9Sb-Qv.es.js} +445 -135
  9. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-Cw0V00On.js → converter-DJyfDFNm.js} +38 -34
  12. package/dist/super-editor/chunks/{docx-zipper-D7k6lS5l.js → docx-zipper-C-9Tqy8I.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-CDWzRc4H.js → editor-f37DOCIX.js} +415 -108
  14. package/dist/super-editor/chunks/{index-DSuc12CK.js → index-DYBG7Xab.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-CHJspeuY.js → toolbar-Devgq8w3.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/super-editor.es.js +6 -6
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +451 -139
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -24995,24 +24995,32 @@ function extractGradientFill(gradFill) {
24995
24995
  const DRAWING_XML_TAG = "w:drawing";
24996
24996
  const SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
24997
24997
  const GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
24998
+ const normalizeTargetPath = (targetPath = "") => {
24999
+ if (!targetPath) return targetPath;
25000
+ const trimmed = targetPath.replace(/^\/+/, "");
25001
+ if (trimmed.startsWith("word/")) return trimmed;
25002
+ if (trimmed.startsWith("media/")) return `word/${trimmed}`;
25003
+ return `word/${trimmed}`;
25004
+ };
24998
25005
  const DEFAULT_SHAPE_WIDTH = 100;
24999
25006
  const DEFAULT_SHAPE_HEIGHT = 100;
25000
25007
  function handleImageNode$1(node, params2, isAnchor) {
25008
+ if (!node) return null;
25001
25009
  const { docx, filename } = params2;
25002
- const { attributes } = node;
25010
+ const attributes = node?.attributes || {};
25003
25011
  const padding = {
25004
- top: emuToPixels(attributes["distT"]),
25005
- bottom: emuToPixels(attributes["distB"]),
25006
- left: emuToPixels(attributes["distL"]),
25007
- right: emuToPixels(attributes["distR"])
25012
+ top: emuToPixels(attributes?.["distT"]),
25013
+ bottom: emuToPixels(attributes?.["distB"]),
25014
+ left: emuToPixels(attributes?.["distL"]),
25015
+ right: emuToPixels(attributes?.["distR"])
25008
25016
  };
25009
- const extent = node.elements.find((el) => el.name === "wp:extent");
25017
+ const extent = node?.elements?.find((el) => el.name === "wp:extent");
25010
25018
  const size2 = {
25011
25019
  width: emuToPixels(extent?.attributes?.cx),
25012
25020
  height: emuToPixels(extent?.attributes?.cy)
25013
25021
  };
25014
25022
  let transformData = {};
25015
- const effectExtent = node.elements.find((el) => el.name === "wp:effectExtent");
25023
+ const effectExtent = node?.elements?.find((el) => el.name === "wp:effectExtent");
25016
25024
  if (effectExtent) {
25017
25025
  const sanitizeEmuValue = (value) => {
25018
25026
  if (value === null || value === void 0) return 0;
@@ -25026,12 +25034,12 @@ function handleImageNode$1(node, params2, isAnchor) {
25026
25034
  bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["b"]))
25027
25035
  };
25028
25036
  }
25029
- const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
25030
- const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
25037
+ const positionHTag = node?.elements?.find((el) => el.name === "wp:positionH");
25038
+ const positionH = positionHTag?.elements?.find((el) => el.name === "wp:posOffset");
25031
25039
  const positionHValue = emuToPixels(positionH?.elements[0]?.text);
25032
25040
  const hRelativeFrom = positionHTag?.attributes?.relativeFrom;
25033
- const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
25034
- const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
25041
+ const alignH = positionHTag?.elements?.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
25042
+ const positionVTag = node?.elements?.find((el) => el.name === "wp:positionV");
25035
25043
  const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
25036
25044
  const positionVValue = emuToPixels(positionV?.elements[0]?.text);
25037
25045
  const vRelativeFrom = positionVTag?.attributes?.relativeFrom;
@@ -25041,8 +25049,8 @@ function handleImageNode$1(node, params2, isAnchor) {
25041
25049
  top: positionVValue
25042
25050
  };
25043
25051
  const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1 || attributes["simplePos"] === true;
25044
- const simplePosNode = node.elements.find((el) => el.name === "wp:simplePos");
25045
- const wrapNode = isAnchor ? node.elements.find(
25052
+ const simplePosNode = node?.elements?.find((el) => el.name === "wp:simplePos");
25053
+ const wrapNode = isAnchor ? node?.elements?.find(
25046
25054
  (el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
25047
25055
  ) : null;
25048
25056
  const wrap2 = isAnchor ? { type: wrapNode?.name.slice(7) || "None", attrs: {} } : { type: "Inline" };
@@ -25163,9 +25171,8 @@ function handleImageNode$1(node, params2, isAnchor) {
25163
25171
  if (!rel) return null;
25164
25172
  const { attributes: relAttributes } = rel;
25165
25173
  const targetPath = relAttributes["Target"];
25166
- let path = `word/${targetPath}`;
25167
- if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
25168
- const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
25174
+ const path = normalizeTargetPath(targetPath);
25175
+ const extension = path.substring(path.lastIndexOf(".") + 1);
25169
25176
  return {
25170
25177
  type: "image",
25171
25178
  attrs: {
@@ -25183,8 +25190,8 @@ function handleImageNode$1(node, params2, isAnchor) {
25183
25190
  transformData,
25184
25191
  ...useSimplePos && {
25185
25192
  simplePos: {
25186
- x: simplePosNode.attributes?.x,
25187
- y: simplePosNode.attributes?.y
25193
+ x: simplePosNode?.attributes?.x,
25194
+ y: simplePosNode?.attributes?.y
25188
25195
  }
25189
25196
  },
25190
25197
  wrap: wrap2,
@@ -25194,12 +25201,12 @@ function handleImageNode$1(node, params2, isAnchor) {
25194
25201
  wrapTopAndBottom: wrap2.type === "TopAndBottom",
25195
25202
  shouldStretch,
25196
25203
  originalPadding: {
25197
- distT: attributes["distT"],
25198
- distB: attributes["distB"],
25199
- distL: attributes["distL"],
25200
- distR: attributes["distR"]
25204
+ distT: attributes?.["distT"],
25205
+ distB: attributes?.["distB"],
25206
+ distL: attributes?.["distL"],
25207
+ distR: attributes?.["distR"]
25201
25208
  },
25202
- originalAttributes: node.attributes,
25209
+ originalAttributes: node?.attributes || {},
25203
25210
  rId: relAttributes["Id"]
25204
25211
  }
25205
25212
  };
@@ -25363,11 +25370,8 @@ const handleShapeGroup = (params2, node, graphicData, size2, padding, marginOffs
25363
25370
  const { elements } = relationships || [];
25364
25371
  const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
25365
25372
  if (!rel) return null;
25366
- const targetPath = rel.attributes?.["Target"];
25367
- let path = `word/${targetPath}`;
25368
- if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) {
25369
- path = targetPath.substring(1);
25370
- }
25373
+ const targetPath = normalizeTargetPath(rel.attributes?.["Target"]);
25374
+ const path = targetPath;
25371
25375
  const nvPicPr = pic.elements?.find((el) => el.name === "pic:nvPicPr");
25372
25376
  const cNvPr = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPr");
25373
25377
  const picId = cNvPr?.attributes?.["id"];
@@ -36388,7 +36392,7 @@ const _SuperConverter = class _SuperConverter2 {
36388
36392
  static getStoredSuperdocVersion(docx) {
36389
36393
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
36390
36394
  }
36391
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.21") {
36395
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.23") {
36392
36396
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36393
36397
  }
36394
36398
  /**
@@ -39694,7 +39698,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
39694
39698
  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);
39695
39699
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
39696
39700
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
39697
- 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, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _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;
39701
+ 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, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
39698
39702
  var GOOD_LEAF_SIZE = 200;
39699
39703
  var RopeSequence = function RopeSequence2() {
39700
39704
  };
@@ -49596,6 +49600,59 @@ function skipTab(dir) {
49596
49600
  return true;
49597
49601
  };
49598
49602
  }
49603
+ const decreaseListIndent = () => ({ editor, tr, dispatch }) => {
49604
+ const handled = changeListLevel(-1, editor, tr);
49605
+ if (handled && dispatch) {
49606
+ dispatch(tr);
49607
+ }
49608
+ return handled;
49609
+ };
49610
+ const removeNumberingProperties = ({ checkType = "startParagraph" } = {}) => (props) => {
49611
+ const { tr, state: state2, editor, dispatch } = props;
49612
+ const { node: paragraph, pos } = findParentNode(isList)(state2.selection) || {};
49613
+ if (!paragraph) return false;
49614
+ if (checkType === "empty" && !isVisuallyEmptyParagraph(paragraph)) return false;
49615
+ if (checkType === "startParagraph") {
49616
+ const { $from, empty: empty2 } = state2.selection;
49617
+ if ((!empty2 || $from.parentOffset !== 0) && !isVisuallyEmptyParagraph(paragraph)) return false;
49618
+ }
49619
+ const ilvl = getResolvedParagraphProperties(paragraph).numberingProperties.ilvl;
49620
+ if (ilvl > 0) {
49621
+ const outdented = decreaseListIndent()(props);
49622
+ if (outdented) {
49623
+ tr.scrollIntoView();
49624
+ }
49625
+ return outdented;
49626
+ } else {
49627
+ updateNumberingProperties(null, paragraph, pos, editor, tr);
49628
+ }
49629
+ if (dispatch) dispatch(tr);
49630
+ return true;
49631
+ };
49632
+ function isVisuallyEmptyParagraph(node) {
49633
+ if (!node || node.type.name !== "paragraph") return false;
49634
+ let hasHardBreak = false;
49635
+ node.descendants((n) => {
49636
+ if (n.type && n.type.name === "hardBreak") {
49637
+ hasHardBreak = true;
49638
+ return false;
49639
+ }
49640
+ return true;
49641
+ });
49642
+ if (hasHardBreak) return false;
49643
+ const text = (node.textContent || "").replace(/\u200b/g, "").trim();
49644
+ if (text.length > 0) return false;
49645
+ let hasInlineLeaf = false;
49646
+ node.descendants((n) => {
49647
+ if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak" && n.type?.name !== "run") {
49648
+ hasInlineLeaf = true;
49649
+ return false;
49650
+ }
49651
+ return true;
49652
+ });
49653
+ if (hasInlineLeaf) return false;
49654
+ return true;
49655
+ }
49599
49656
  const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
49600
49657
  let predicate;
49601
49658
  if (listType === "orderedList") {
@@ -49615,19 +49672,22 @@ const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
49615
49672
  const { from: from2, to } = selection;
49616
49673
  let firstListNode = null;
49617
49674
  let hasNonListParagraphs = false;
49618
- let paragraphsInSelection = [];
49675
+ let allParagraphsInSelection = [];
49619
49676
  state2.doc.nodesBetween(from2, to, (node, pos) => {
49620
49677
  if (node.type.name === "paragraph") {
49621
- paragraphsInSelection.push({ node, pos });
49622
- if (!firstListNode && predicate(node)) {
49623
- firstListNode = node;
49624
- } else if (!predicate(node)) {
49625
- hasNonListParagraphs = true;
49626
- }
49678
+ allParagraphsInSelection.push({ node, pos });
49627
49679
  return false;
49628
49680
  }
49629
49681
  return true;
49630
49682
  });
49683
+ let paragraphsInSelection = allParagraphsInSelection.length === 1 ? allParagraphsInSelection : allParagraphsInSelection.filter(({ node }) => !isVisuallyEmptyParagraph(node));
49684
+ for (const { node } of paragraphsInSelection) {
49685
+ if (!firstListNode && predicate(node)) {
49686
+ firstListNode = node;
49687
+ } else if (!predicate(node)) {
49688
+ hasNonListParagraphs = true;
49689
+ }
49690
+ }
49631
49691
  if (!firstListNode && from2 > 0) {
49632
49692
  const $from = state2.doc.resolve(from2);
49633
49693
  const parentIndex = $from.index(-1);
@@ -49671,11 +49731,30 @@ const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
49671
49731
  }
49672
49732
  updateNumberingProperties(sharedNumberingProperties, node, pos, editor, tr);
49673
49733
  }
49674
- const newTo = tr.mapping.map(to);
49675
- if (newTo >= 0 && newTo <= tr.doc.content.size) {
49676
- try {
49677
- tr.setSelection(state2.selection.constructor.near(tr.doc.resolve(newTo)));
49678
- } catch {
49734
+ if (paragraphsInSelection.length > 0) {
49735
+ const firstPara = paragraphsInSelection[0];
49736
+ const lastPara = paragraphsInSelection[paragraphsInSelection.length - 1];
49737
+ const mappedFirstPos = tr.mapping.map(firstPara.pos);
49738
+ const mappedLastPos = tr.mapping.map(lastPara.pos);
49739
+ const $firstPos = tr.doc.resolve(mappedFirstPos);
49740
+ const $lastPos = tr.doc.resolve(mappedLastPos);
49741
+ const firstNode = $firstPos.nodeAfter;
49742
+ const lastNode = $lastPos.nodeAfter;
49743
+ if (firstNode && lastNode) {
49744
+ let selFrom = mappedFirstPos + 1;
49745
+ let selTo = mappedLastPos + lastNode.nodeSize - 1;
49746
+ if (firstNode.firstChild && firstNode.firstChild.type.name === "run") {
49747
+ selFrom = mappedFirstPos + 2;
49748
+ }
49749
+ if (lastNode.lastChild && lastNode.lastChild.type.name === "run") {
49750
+ selTo = mappedLastPos + lastNode.nodeSize - 2;
49751
+ }
49752
+ if (selFrom >= 0 && selTo <= tr.doc.content.size && selFrom <= selTo) {
49753
+ try {
49754
+ tr.setSelection(TextSelection$1.create(tr.doc, selFrom, selTo));
49755
+ } catch {
49756
+ }
49757
+ }
49679
49758
  }
49680
49759
  }
49681
49760
  if (dispatch) dispatch(tr);
@@ -49688,59 +49767,6 @@ const increaseListIndent = () => ({ editor, tr, dispatch }) => {
49688
49767
  }
49689
49768
  return handled;
49690
49769
  };
49691
- const decreaseListIndent = () => ({ editor, tr, dispatch }) => {
49692
- const handled = changeListLevel(-1, editor, tr);
49693
- if (handled && dispatch) {
49694
- dispatch(tr);
49695
- }
49696
- return handled;
49697
- };
49698
- const removeNumberingProperties = ({ checkType = "startParagraph" } = {}) => (props) => {
49699
- const { tr, state: state2, editor, dispatch } = props;
49700
- const { node: paragraph, pos } = findParentNode(isList)(state2.selection) || {};
49701
- if (!paragraph) return false;
49702
- if (checkType === "empty" && !isVisuallyEmptyParagraph(paragraph)) return false;
49703
- if (checkType === "startParagraph") {
49704
- const { $from, empty: empty2 } = state2.selection;
49705
- if ((!empty2 || $from.parentOffset !== 0) && !isVisuallyEmptyParagraph(paragraph)) return false;
49706
- }
49707
- const ilvl = getResolvedParagraphProperties(paragraph).numberingProperties.ilvl;
49708
- if (ilvl > 0) {
49709
- const outdented = decreaseListIndent()(props);
49710
- if (outdented) {
49711
- tr.scrollIntoView();
49712
- }
49713
- return outdented;
49714
- } else {
49715
- updateNumberingProperties(null, paragraph, pos, editor, tr);
49716
- }
49717
- if (dispatch) dispatch(tr);
49718
- return true;
49719
- };
49720
- function isVisuallyEmptyParagraph(node) {
49721
- if (!node || node.type.name !== "paragraph") return false;
49722
- let hasHardBreak = false;
49723
- node.descendants((n) => {
49724
- if (n.type && n.type.name === "hardBreak") {
49725
- hasHardBreak = true;
49726
- return false;
49727
- }
49728
- return true;
49729
- });
49730
- if (hasHardBreak) return false;
49731
- const text = (node.textContent || "").replace(/\u200b/g, "").trim();
49732
- if (text.length > 0) return false;
49733
- let hasInlineLeaf = false;
49734
- node.descendants((n) => {
49735
- if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak" && n.type?.name !== "run") {
49736
- hasInlineLeaf = true;
49737
- return false;
49738
- }
49739
- return true;
49740
- });
49741
- if (hasInlineLeaf) return false;
49742
- return true;
49743
- }
49744
49770
  const restoreSelection = () => ({ editor, state: state2, tr }) => {
49745
49771
  if (editor.options.lastSelection) {
49746
49772
  const selectionTr = tr.setSelection(
@@ -49823,6 +49849,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
49823
49849
  insertTabCharacter,
49824
49850
  insertTabNode,
49825
49851
  isStyleTokenEnabled,
49852
+ isVisuallyEmptyParagraph,
49826
49853
  joinBackward,
49827
49854
  joinDown,
49828
49855
  joinForward,
@@ -49941,12 +49968,38 @@ const Keymap = Extension.create({
49941
49968
  const Editable = Extension.create({
49942
49969
  name: "editable",
49943
49970
  addPmPlugins() {
49971
+ const editor = this.editor;
49944
49972
  const editablePlugin = new Plugin({
49945
49973
  key: new PluginKey("editable"),
49946
49974
  props: {
49947
- editable: () => {
49948
- return this.editor.options.editable;
49949
- }
49975
+ editable: () => editor.options.editable,
49976
+ handleDOMEvents: {
49977
+ beforeinput: (_view, event) => {
49978
+ if (!editor.options.editable) {
49979
+ event.preventDefault();
49980
+ return true;
49981
+ }
49982
+ return false;
49983
+ },
49984
+ mousedown: (_view, event) => {
49985
+ if (!editor.options.editable) {
49986
+ event.preventDefault();
49987
+ return true;
49988
+ }
49989
+ return false;
49990
+ },
49991
+ focus: (view, event) => {
49992
+ if (!editor.options.editable) {
49993
+ event.preventDefault();
49994
+ view.dom.blur();
49995
+ return true;
49996
+ }
49997
+ return false;
49998
+ }
49999
+ },
50000
+ handleClick: () => !editor.options.editable,
50001
+ handleDoubleClick: () => !editor.options.editable,
50002
+ handleTripleClick: () => !editor.options.editable
49950
50003
  }
49951
50004
  });
49952
50005
  return [editablePlugin];
@@ -53504,7 +53557,7 @@ const isHeadless = (editor) => {
53504
53557
  const shouldSkipNodeView = (editor) => {
53505
53558
  return isHeadless(editor);
53506
53559
  };
53507
- const summaryVersion = "1.0.0-beta.21";
53560
+ const summaryVersion = "1.0.0-beta.23";
53508
53561
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
53509
53562
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
53510
53563
  function mapAttributes(attrs) {
@@ -53909,10 +53962,23 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
53909
53962
  this.view.updateState(this.state);
53910
53963
  }
53911
53964
  /**
53912
- * Set whether the editor is editable
53965
+ * Set whether the editor is editable.
53966
+ *
53967
+ * When setting to non-editable, this method:
53968
+ * - Forces ProseMirror to re-evaluate the editable prop from the Editable plugin
53969
+ * - Blurs the editor to remove the cursor
53970
+ *
53971
+ * @param editable - Whether the editor should accept user input (default: true)
53972
+ * @param emitUpdate - Whether to emit an update event after changing editability (default: true)
53913
53973
  */
53914
53974
  setEditable(editable = true, emitUpdate = true) {
53915
53975
  this.setOptions({ editable });
53976
+ if (this.view) {
53977
+ this.view.setProps({});
53978
+ if (!editable && this.view.dom) {
53979
+ this.view.dom.blur();
53980
+ }
53981
+ }
53916
53982
  if (emitUpdate) {
53917
53983
  this.emit("update", { editor: this, transaction: this.state.tr });
53918
53984
  }
@@ -54280,7 +54346,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54280
54346
  { default: remarkStringify },
54281
54347
  { default: remarkGfm }
54282
54348
  ] = await Promise.all([
54283
- Promise.resolve().then(() => require("./index-DSuc12CK-Dpg5Hd9W.cjs")),
54349
+ Promise.resolve().then(() => require("./index-DYBG7Xab-CoI6fike.cjs")),
54284
54350
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
54285
54351
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
54286
54352
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -54485,7 +54551,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54485
54551
  * Process collaboration migrations
54486
54552
  */
54487
54553
  processCollaborationMigrations() {
54488
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.21");
54554
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.23");
54489
54555
  if (!this.options.ydoc) return;
54490
54556
  const metaMap = this.options.ydoc.getMap("meta");
54491
54557
  let docVersion = metaMap.get("version");
@@ -56937,6 +57003,11 @@ const normalizeAlignment = (value) => {
56937
57003
  case "right":
56938
57004
  case "justify":
56939
57005
  return value;
57006
+ case "both":
57007
+ case "distribute":
57008
+ case "numTab":
57009
+ case "thaiDistribute":
57010
+ return "justify";
56940
57011
  case "end":
56941
57012
  return "right";
56942
57013
  case "start":
@@ -59151,6 +59222,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
59151
59222
  } else if (computed2.paragraph.alignment) {
59152
59223
  paragraphAttrs.alignment = computed2.paragraph.alignment;
59153
59224
  }
59225
+ const isJustified = paragraphAttrs.alignment === "justify" || paragraphAttrs.alignment === "both";
59226
+ const hasFirstLineIndent = normalizedIndent?.firstLine && normalizedIndent.firstLine > 0;
59227
+ if (isJustified && hasFirstLineIndent) {
59228
+ paragraphAttrs.suppressFirstLineIndent = true;
59229
+ }
59154
59230
  const spacingPx = spacingPtToPx(spacing, normalizedSpacing);
59155
59231
  if (spacingPx) paragraphAttrs.spacing = spacingPx;
59156
59232
  if (normalizedSpacing?.beforeAutospacing != null || normalizedSpacing?.afterAutospacing != null) {
@@ -59368,7 +59444,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
59368
59444
  }
59369
59445
  }
59370
59446
  paragraphAttrs.wordLayout = wordLayout;
59371
- if (enrichedNumberingProps.resolvedLevelIndent) {
59447
+ if (enrichedNumberingProps.resolvedLevelIndent && !hasExplicitIndent) {
59372
59448
  const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
59373
59449
  paragraphAttrs.indent = {
59374
59450
  ...paragraphAttrs.indent,
@@ -62734,8 +62810,14 @@ function computeNextSectionPropsAtBreak(blocks) {
62734
62810
  });
62735
62811
  return nextSectionPropsAtBreak;
62736
62812
  }
62737
- function scheduleSectionBreak(block, state2, baseMargins) {
62813
+ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight = 0) {
62738
62814
  const next = { ...state2 };
62815
+ const calcRequiredTopMargin = (headerDistance, baseTop) => {
62816
+ if (maxHeaderContentHeight > 0) {
62817
+ return Math.max(baseTop, headerDistance + maxHeaderContentHeight);
62818
+ }
62819
+ return Math.max(baseTop, headerDistance);
62820
+ };
62739
62821
  if (block.attrs?.isFirstSection && !next.hasAnyPages) {
62740
62822
  if (block.pageSize) {
62741
62823
  next.activePageSize = { w: block.pageSize.w, h: block.pageSize.h };
@@ -62749,7 +62831,7 @@ function scheduleSectionBreak(block, state2, baseMargins) {
62749
62831
  const headerDistance = Math.max(0, block.margins.header);
62750
62832
  next.activeHeaderDistance = headerDistance;
62751
62833
  next.pendingHeaderDistance = headerDistance;
62752
- next.activeTopMargin = Math.max(baseMargins.top, headerDistance);
62834
+ next.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
62753
62835
  next.pendingTopMargin = next.activeTopMargin;
62754
62836
  }
62755
62837
  if (block.margins?.footer !== void 0) {
@@ -62771,9 +62853,15 @@ function scheduleSectionBreak(block, state2, baseMargins) {
62771
62853
  const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
62772
62854
  const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
62773
62855
  const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
62774
- next.pendingTopMargin = typeof headerPx === "number" ? Math.max(baseMargins.top, headerPx) : nextTop;
62856
+ if (typeof headerPx === "number") {
62857
+ const newHeaderDist = Math.max(0, headerPx);
62858
+ next.pendingHeaderDistance = newHeaderDist;
62859
+ next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, baseMargins.top);
62860
+ } else {
62861
+ next.pendingTopMargin = nextTop;
62862
+ next.pendingHeaderDistance = nextHeader;
62863
+ }
62775
62864
  next.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
62776
- next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
62777
62865
  next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
62778
62866
  if (block.pageSize) {
62779
62867
  next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
@@ -64238,7 +64326,22 @@ function layoutDocument(blocks, measures, options = {}) {
64238
64326
  if (contentWidth <= 0) {
64239
64327
  throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
64240
64328
  }
64241
- let activeTopMargin = margins.top;
64329
+ const validateHeaderHeight = (height) => {
64330
+ if (height === void 0) return 0;
64331
+ if (!Number.isFinite(height) || height < 0) return 0;
64332
+ return height;
64333
+ };
64334
+ const headerContentHeights = options.headerContentHeights;
64335
+ const maxHeaderContentHeight = headerContentHeights ? Math.max(
64336
+ 0,
64337
+ validateHeaderHeight(headerContentHeights.default),
64338
+ validateHeaderHeight(headerContentHeights.first),
64339
+ validateHeaderHeight(headerContentHeights.even),
64340
+ validateHeaderHeight(headerContentHeights.odd)
64341
+ ) : 0;
64342
+ const headerDistance = margins.header ?? margins.top;
64343
+ const effectiveTopMargin = maxHeaderContentHeight > 0 ? Math.max(margins.top, headerDistance + maxHeaderContentHeight) : margins.top;
64344
+ let activeTopMargin = effectiveTopMargin;
64242
64345
  let activeBottomMargin = margins.bottom;
64243
64346
  let pendingTopMargin = null;
64244
64347
  let pendingBottomMargin = null;
@@ -64262,7 +64365,7 @@ function layoutDocument(blocks, measures, options = {}) {
64262
64365
  const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
64263
64366
  const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
64264
64367
  if (typeof scheduleSectionBreak === "function") {
64265
- return scheduleSectionBreak(block, state2, baseMargins);
64368
+ return scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight);
64266
64369
  }
64267
64370
  const next = { ...state2 };
64268
64371
  if (block.attrs?.isFirstSection && !next.hasAnyPages) {
@@ -64275,10 +64378,11 @@ function layoutDocument(blocks, measures, options = {}) {
64275
64378
  next.pendingOrientation = null;
64276
64379
  }
64277
64380
  if (block.margins?.header !== void 0) {
64278
- const headerDistance = Math.max(0, block.margins.header);
64279
- next.activeHeaderDistance = headerDistance;
64280
- next.pendingHeaderDistance = headerDistance;
64281
- next.activeTopMargin = Math.max(baseMargins.top, headerDistance);
64381
+ const headerDist = Math.max(0, block.margins.header);
64382
+ next.activeHeaderDistance = headerDist;
64383
+ next.pendingHeaderDistance = headerDist;
64384
+ const requiredTop = maxHeaderContentHeight > 0 ? headerDist + maxHeaderContentHeight : headerDist;
64385
+ next.activeTopMargin = Math.max(baseMargins.top, requiredTop);
64282
64386
  next.pendingTopMargin = next.activeTopMargin;
64283
64387
  }
64284
64388
  if (block.margins?.footer !== void 0) {
@@ -64315,14 +64419,22 @@ function layoutDocument(blocks, measures, options = {}) {
64315
64419
  }
64316
64420
  const headerPx = block.margins?.header;
64317
64421
  const footerPx = block.margins?.footer;
64422
+ const topPx = block.margins?.top;
64318
64423
  const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
64319
64424
  const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
64320
64425
  const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
64321
64426
  const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
64322
- next.pendingTopMargin = typeof headerPx === "number" ? Math.max(baseMargins.top, headerPx) : nextTop;
64323
- next.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
64324
64427
  next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
64325
64428
  next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
64429
+ if (typeof headerPx === "number" || typeof topPx === "number") {
64430
+ const sectionTop = topPx ?? baseMargins.top;
64431
+ const sectionHeader = next.pendingHeaderDistance;
64432
+ const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
64433
+ next.pendingTopMargin = Math.max(sectionTop, requiredTop);
64434
+ } else {
64435
+ next.pendingTopMargin = nextTop;
64436
+ }
64437
+ next.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
64326
64438
  if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
64327
64439
  if (block.orientation) next.pendingOrientation = block.orientation;
64328
64440
  const sectionType = block.type ?? "continuous";
@@ -65073,7 +65185,7 @@ const resolveTrackedChangesEnabled = (attrs, defaultEnabled = true) => {
65073
65185
  }
65074
65186
  return attrs.trackedChangesEnabled !== false;
65075
65187
  };
65076
- const MAX_CACHE_SIZE = 1e4;
65188
+ const MAX_CACHE_SIZE$1 = 1e4;
65077
65189
  const BYTES_PER_ENTRY_ESTIMATE = 5e3;
65078
65190
  const NORMALIZED_WHITESPACE = /\s+/g;
65079
65191
  const normalizeText = (text) => text.replace(NORMALIZED_WHITESPACE, " ");
@@ -65173,7 +65285,7 @@ class MeasureCache {
65173
65285
  if (this.cache.has(key2)) {
65174
65286
  this.cache.delete(key2);
65175
65287
  }
65176
- if (this.cache.size >= MAX_CACHE_SIZE) {
65288
+ if (this.cache.size >= MAX_CACHE_SIZE$1) {
65177
65289
  const oldestKey = this.cache.keys().next().value;
65178
65290
  if (oldestKey !== void 0) {
65179
65291
  this.cache.delete(oldestKey);
@@ -65247,13 +65359,13 @@ class MeasureCache {
65247
65359
  * Get maximum cache size
65248
65360
  */
65249
65361
  getMaxSize() {
65250
- return MAX_CACHE_SIZE;
65362
+ return MAX_CACHE_SIZE$1;
65251
65363
  }
65252
65364
  /**
65253
65365
  * Check if cache is near capacity
65254
65366
  */
65255
65367
  isNearCapacity(threshold = 0.9) {
65256
- return this.cache.size >= MAX_CACHE_SIZE * threshold;
65368
+ return this.cache.size >= MAX_CACHE_SIZE$1 * threshold;
65257
65369
  }
65258
65370
  /**
65259
65371
  * Update size statistics
@@ -66265,9 +66377,46 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
66265
66377
  perfLog(
66266
66378
  `[Perf] 4.1 Measure all blocks: ${(measureEnd - measureStart).toFixed(2)}ms (${cacheMisses} measured, ${cacheHits} cached)`
66267
66379
  );
66380
+ let headerContentHeights;
66381
+ if (headerFooter?.constraints && headerFooter.headerBlocks) {
66382
+ const hfPreStart = performance.now();
66383
+ const measureFn = headerFooter.measure ?? measureBlock2;
66384
+ invalidateHeaderFooterCache(
66385
+ headerMeasureCache,
66386
+ headerFooterCacheState,
66387
+ headerFooter.headerBlocks,
66388
+ headerFooter.footerBlocks,
66389
+ headerFooter.constraints,
66390
+ options.sectionMetadata
66391
+ );
66392
+ const HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT = 1;
66393
+ const preHeaderLayouts = await layoutHeaderFooterWithCache(
66394
+ headerFooter.headerBlocks,
66395
+ headerFooter.constraints,
66396
+ measureFn,
66397
+ headerMeasureCache,
66398
+ HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
66399
+ void 0
66400
+ // No page resolver needed for height calculation
66401
+ );
66402
+ const isValidHeaderType = (key2) => {
66403
+ return ["default", "first", "even", "odd"].includes(key2);
66404
+ };
66405
+ headerContentHeights = {};
66406
+ for (const [type2, value] of Object.entries(preHeaderLayouts)) {
66407
+ if (!isValidHeaderType(type2)) continue;
66408
+ if (value?.layout && typeof value.layout.height === "number") {
66409
+ headerContentHeights[type2] = value.layout.height;
66410
+ }
66411
+ }
66412
+ const hfPreEnd = performance.now();
66413
+ perfLog(`[Perf] 4.1.5 Pre-layout headers for height: ${(hfPreEnd - hfPreStart).toFixed(2)}ms`);
66414
+ }
66268
66415
  const layoutStart = performance.now();
66269
66416
  let layout = layoutDocument(nextBlocks, measures, {
66270
66417
  ...options,
66418
+ headerContentHeights,
66419
+ // Pass header heights to prevent overlap
66271
66420
  remeasureParagraph: (block, maxWidth) => remeasureParagraph(block, maxWidth)
66272
66421
  });
66273
66422
  const layoutEnd = performance.now();
@@ -66314,6 +66463,8 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
66314
66463
  const relayoutStart = performance.now();
66315
66464
  layout = layoutDocument(currentBlocks, currentMeasures, {
66316
66465
  ...options,
66466
+ headerContentHeights,
66467
+ // Pass header heights to prevent overlap
66317
66468
  remeasureParagraph: (block, maxWidth) => remeasureParagraph(block, maxWidth)
66318
66469
  });
66319
66470
  const relayoutEnd = performance.now();
@@ -69363,7 +69514,12 @@ const lineStyles = (lineHeight2) => ({
69363
69514
  height: `${lineHeight2}px`,
69364
69515
  position: "relative",
69365
69516
  display: "block",
69366
- whiteSpace: "pre"
69517
+ whiteSpace: "pre",
69518
+ // Allow text to overflow the line container as a safety net.
69519
+ // The primary fix uses accurate font metrics from Canvas API, but this
69520
+ // provides defense-in-depth against any remaining sub-pixel rendering
69521
+ // differences between measurement and display.
69522
+ overflow: "visible"
69367
69523
  });
69368
69524
  const PRINT_STYLES = `
69369
69525
  @media print {
@@ -70929,7 +71085,8 @@ const _DomPainter = class _DomPainter2 {
70929
71085
  const paraIndent = block.attrs?.indent;
70930
71086
  const paraIndentLeft = paraIndent?.left ?? 0;
70931
71087
  const paraIndentRight = paraIndent?.right ?? 0;
70932
- const firstLineOffset = (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
71088
+ const suppressFirstLineIndent = block.attrs?.suppressFirstLineIndent === true;
71089
+ const firstLineOffset = suppressFirstLineIndent ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
70933
71090
  lines.forEach((line, index2) => {
70934
71091
  const lineEl = this.renderLine(block, line, context);
70935
71092
  const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
@@ -72556,9 +72713,36 @@ const fragmentSignature = (fragment, lookup2) => {
72556
72713
  }
72557
72714
  return base2;
72558
72715
  };
72716
+ const hasListMarkerProperties = (attrs) => {
72717
+ if (!attrs || typeof attrs !== "object") return false;
72718
+ const obj = attrs;
72719
+ if (!obj.numberingProperties || typeof obj.numberingProperties !== "object") return false;
72720
+ const numProps = obj.numberingProperties;
72721
+ if ("numId" in numProps) {
72722
+ const numId = numProps.numId;
72723
+ if (typeof numId !== "number" && typeof numId !== "string") return false;
72724
+ }
72725
+ if ("ilvl" in numProps) {
72726
+ const ilvl = numProps.ilvl;
72727
+ if (typeof ilvl !== "number") return false;
72728
+ }
72729
+ if ("wordLayout" in obj && obj.wordLayout !== void 0) {
72730
+ if (typeof obj.wordLayout !== "object" || obj.wordLayout === null) return false;
72731
+ const wordLayout = obj.wordLayout;
72732
+ if ("marker" in wordLayout && wordLayout.marker !== void 0) {
72733
+ if (typeof wordLayout.marker !== "object" || wordLayout.marker === null) return false;
72734
+ const marker = wordLayout.marker;
72735
+ if ("markerText" in marker && marker.markerText !== void 0) {
72736
+ if (typeof marker.markerText !== "string") return false;
72737
+ }
72738
+ }
72739
+ }
72740
+ return true;
72741
+ };
72559
72742
  const deriveBlockVersion = (block) => {
72560
72743
  if (block.kind === "paragraph") {
72561
- return block.runs.map((run2) => {
72744
+ const markerVersion = hasListMarkerProperties(block.attrs) ? `marker:${block.attrs.numberingProperties.numId ?? ""}:${block.attrs.numberingProperties.ilvl ?? 0}:${block.attrs.wordLayout?.marker?.markerText ?? ""}` : "";
72745
+ const runsVersion = block.runs.map((run2) => {
72562
72746
  if (run2.kind === "image") {
72563
72747
  const imgRun = run2;
72564
72748
  return [
@@ -72601,6 +72785,7 @@ const deriveBlockVersion = (block) => {
72601
72785
  textRun.token ?? ""
72602
72786
  ].join(",");
72603
72787
  }).join("|");
72788
+ return markerVersion ? `${markerVersion}|${runsVersion}` : runsVersion;
72604
72789
  }
72605
72790
  if (block.kind === "list") {
72606
72791
  return block.items.map((item) => `${item.id}:${item.marker.text}:${deriveBlockVersion(item.paragraph)}`).join("|");
@@ -73090,6 +73275,61 @@ function evictIfNeeded() {
73090
73275
  cache$1.delete(oldestKey);
73091
73276
  }
73092
73277
  }
73278
+ const fontMetricsCache = /* @__PURE__ */ new Map();
73279
+ const MAX_CACHE_SIZE = 1e3;
73280
+ const METRICS_TEST_STRING = "MHgypbdlÁÉÍ";
73281
+ function getFontKey(fontInfo) {
73282
+ return `${fontInfo.fontFamily}|${fontInfo.fontSize}|${fontInfo.bold ?? false}|${fontInfo.italic ?? false}`;
73283
+ }
73284
+ function buildFontStringForMetrics(fontInfo, mode, fonts) {
73285
+ const parts = [];
73286
+ if (fontInfo.italic) parts.push("italic");
73287
+ if (fontInfo.bold) parts.push("bold");
73288
+ parts.push(`${fontInfo.fontSize}px`);
73289
+ {
73290
+ parts.push(fontInfo.fontFamily);
73291
+ }
73292
+ return parts.join(" ");
73293
+ }
73294
+ function getFontMetrics(ctx2, fontInfo, mode, fonts) {
73295
+ if (!ctx2 || typeof ctx2 !== "object") {
73296
+ throw new TypeError("Canvas context must be a valid CanvasRenderingContext2D object");
73297
+ }
73298
+ if (typeof fontInfo.fontSize !== "number" || !Number.isFinite(fontInfo.fontSize) || fontInfo.fontSize <= 0) {
73299
+ throw new TypeError(
73300
+ `Font size must be a positive finite number, got: ${typeof fontInfo.fontSize === "number" ? fontInfo.fontSize : typeof fontInfo.fontSize}`
73301
+ );
73302
+ }
73303
+ if (typeof fontInfo.fontFamily !== "string" || fontInfo.fontFamily.trim().length === 0) {
73304
+ throw new TypeError("Font family must be a non-empty string");
73305
+ }
73306
+ const key2 = getFontKey(fontInfo);
73307
+ const cached = fontMetricsCache.get(key2);
73308
+ if (cached) {
73309
+ return cached;
73310
+ }
73311
+ const font = buildFontStringForMetrics(fontInfo);
73312
+ ctx2.font = font;
73313
+ const textMetrics = ctx2.measureText(METRICS_TEST_STRING);
73314
+ let ascent;
73315
+ let descent;
73316
+ if (typeof textMetrics.actualBoundingBoxAscent === "number" && typeof textMetrics.actualBoundingBoxDescent === "number" && textMetrics.actualBoundingBoxAscent > 0) {
73317
+ ascent = textMetrics.actualBoundingBoxAscent;
73318
+ descent = textMetrics.actualBoundingBoxDescent;
73319
+ } else {
73320
+ ascent = fontInfo.fontSize * 0.8;
73321
+ descent = fontInfo.fontSize * 0.2;
73322
+ }
73323
+ const result = { ascent, descent };
73324
+ if (fontMetricsCache.size >= MAX_CACHE_SIZE) {
73325
+ const firstKey = fontMetricsCache.keys().next().value;
73326
+ if (firstKey) {
73327
+ fontMetricsCache.delete(firstKey);
73328
+ }
73329
+ }
73330
+ fontMetricsCache.set(key2, result);
73331
+ return result;
73332
+ }
73093
73333
  const { computeTabStops } = Engines;
73094
73334
  let canvasContext = null;
73095
73335
  const DEFAULT_TAB_INTERVAL_TWIPS = 720;
@@ -73137,10 +73377,20 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
73137
73377
  return Math.max(advanceWidth, paintedWidth);
73138
73378
  }
73139
73379
  const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
73140
- function calculateTypographyMetrics(fontSize2, spacing) {
73141
- const ascent = roundValue(fontSize2 * 0.8);
73142
- const descent = roundValue(fontSize2 * 0.2);
73143
- const baseLineHeight = Math.max(fontSize2, MIN_SINGLE_LINE_PX);
73380
+ const LINE_HEIGHT_SAFETY_MARGIN_PX = 1;
73381
+ function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
73382
+ let ascent;
73383
+ let descent;
73384
+ if (fontInfo) {
73385
+ const ctx2 = getCanvasContext();
73386
+ const metrics = getFontMetrics(ctx2, fontInfo);
73387
+ ascent = roundValue(metrics.ascent);
73388
+ descent = roundValue(metrics.descent);
73389
+ } else {
73390
+ ascent = roundValue(fontSize2 * 0.8);
73391
+ descent = roundValue(fontSize2 * 0.2);
73392
+ }
73393
+ const baseLineHeight = Math.max(ascent + descent + LINE_HEIGHT_SAFETY_MARGIN_PX, MIN_SINGLE_LINE_PX);
73144
73394
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
73145
73395
  return {
73146
73396
  ascent,
@@ -73148,6 +73398,20 @@ function calculateTypographyMetrics(fontSize2, spacing) {
73148
73398
  lineHeight: lineHeight2
73149
73399
  };
73150
73400
  }
73401
+ function getFontInfoFromRun(run2) {
73402
+ return {
73403
+ fontFamily: run2.fontFamily,
73404
+ fontSize: run2.fontSize,
73405
+ bold: run2.bold,
73406
+ italic: run2.italic
73407
+ };
73408
+ }
73409
+ function updateMaxFontInfo(currentMaxSize, currentMaxInfo, newRun) {
73410
+ if (newRun.fontSize >= currentMaxSize) {
73411
+ return getFontInfoFromRun(newRun);
73412
+ }
73413
+ return currentMaxInfo;
73414
+ }
73151
73415
  function isTabRun(run2) {
73152
73416
  return run2.kind === "tab";
73153
73417
  }
@@ -73193,7 +73457,8 @@ async function measureParagraphBlock(block, maxWidth) {
73193
73457
  const indentRight = sanitizePositive(indent?.right);
73194
73458
  const firstLine = indent?.firstLine ?? 0;
73195
73459
  const hanging = indent?.hanging ?? 0;
73196
- const firstLineOffset = firstLine - hanging;
73460
+ const suppressFirstLine = block.attrs?.suppressFirstLineIndent === true;
73461
+ const firstLineOffset = suppressFirstLine ? 0 : firstLine - hanging;
73197
73462
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
73198
73463
  const initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
73199
73464
  const tabStops = buildTabStopsPx(
@@ -73329,7 +73594,7 @@ async function measureParagraphBlock(block, maxWidth) {
73329
73594
  const run2 = runsToProcess[runIndex];
73330
73595
  if (run2.kind === "break") {
73331
73596
  if (currentLine) {
73332
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
73597
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
73333
73598
  const completedLine = { ...currentLine, ...metrics };
73334
73599
  addBarTabsToLine(completedLine);
73335
73600
  lines.push(completedLine);
@@ -73359,7 +73624,7 @@ async function measureParagraphBlock(block, maxWidth) {
73359
73624
  }
73360
73625
  if (isLineBreakRun(run2)) {
73361
73626
  if (currentLine) {
73362
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
73627
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
73363
73628
  const completedLine = {
73364
73629
  ...currentLine,
73365
73630
  ...metrics
@@ -73472,7 +73737,7 @@ async function measureParagraphBlock(block, maxWidth) {
73472
73737
  }
73473
73738
  const appliedTabAlign = lastAppliedTabAlign;
73474
73739
  if (currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
73475
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
73740
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
73476
73741
  const completedLine = {
73477
73742
  ...currentLine,
73478
73743
  ...metrics
@@ -73560,6 +73825,7 @@ async function measureParagraphBlock(block, maxWidth) {
73560
73825
  toChar: wordEndNoSpace,
73561
73826
  width: wordOnlyWidth,
73562
73827
  maxFontSize: run2.fontSize,
73828
+ maxFontInfo: getFontInfoFromRun(run2),
73563
73829
  maxWidth: getEffectiveWidth(initialAvailableWidth),
73564
73830
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
73565
73831
  };
@@ -73576,7 +73842,7 @@ async function measureParagraphBlock(block, maxWidth) {
73576
73842
  const isTocEntry = block.attrs?.isTocEntry;
73577
73843
  const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
73578
73844
  if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0 && !isTocEntry) {
73579
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
73845
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
73580
73846
  const completedLine = {
73581
73847
  ...currentLine,
73582
73848
  ...metrics
@@ -73592,6 +73858,7 @@ async function measureParagraphBlock(block, maxWidth) {
73592
73858
  toChar: wordEndNoSpace,
73593
73859
  width: wordOnlyWidth,
73594
73860
  maxFontSize: run2.fontSize,
73861
+ maxFontInfo: getFontInfoFromRun(run2),
73595
73862
  maxWidth: getEffectiveWidth(contentWidth),
73596
73863
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
73597
73864
  };
@@ -73607,9 +73874,10 @@ async function measureParagraphBlock(block, maxWidth) {
73607
73874
  if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
73608
73875
  currentLine.toChar = wordEndNoSpace;
73609
73876
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
73877
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
73610
73878
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
73611
73879
  appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, segmentStartX);
73612
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
73880
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
73613
73881
  const completedLine = { ...currentLine, ...metrics };
73614
73882
  addBarTabsToLine(completedLine);
73615
73883
  lines.push(completedLine);
@@ -73626,6 +73894,7 @@ async function measureParagraphBlock(block, maxWidth) {
73626
73894
  currentLine.width = roundValue(
73627
73895
  currentLine.width + boundarySpacing + wordCommitWidth + (isLastWord ? 0 : run2.letterSpacing ?? 0)
73628
73896
  );
73897
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
73629
73898
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
73630
73899
  appendSegment(currentLine.segments, runIndex, wordStartChar, newToChar, wordCommitWidth, explicitX);
73631
73900
  }
@@ -73648,6 +73917,7 @@ async function measureParagraphBlock(block, maxWidth) {
73648
73917
  toChar: charPosInRun,
73649
73918
  width: 0,
73650
73919
  maxFontSize: run2.fontSize,
73920
+ maxFontInfo: getFontInfoFromRun(run2),
73651
73921
  maxWidth: getEffectiveWidth(initialAvailableWidth),
73652
73922
  segments: []
73653
73923
  };
@@ -73657,6 +73927,7 @@ async function measureParagraphBlock(block, maxWidth) {
73657
73927
  tabStopCursor = nextIndex;
73658
73928
  const tabAdvance = Math.max(0, target - currentLine.width);
73659
73929
  currentLine.width = roundValue(currentLine.width + tabAdvance);
73930
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
73660
73931
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
73661
73932
  currentLine.toRun = runIndex;
73662
73933
  currentLine.toChar = charPosInRun;
@@ -73693,7 +73964,7 @@ async function measureParagraphBlock(block, maxWidth) {
73693
73964
  lines.push(fallbackLine);
73694
73965
  }
73695
73966
  if (currentLine) {
73696
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
73967
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
73697
73968
  const finalLine = {
73698
73969
  ...currentLine,
73699
73970
  ...metrics
@@ -77104,7 +77375,12 @@ setupPointerHandlers_fn = function() {
77104
77375
  setupInputBridge_fn = function() {
77105
77376
  __privateGet$1(this, _inputBridge)?.destroy();
77106
77377
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
77107
- __privateSet(this, _inputBridge, new PresentationInputBridge(win, __privateGet$1(this, _visibleHost), () => __privateMethod$1(this, _PresentationEditor_instances, getActiveDomTarget_fn).call(this)));
77378
+ __privateSet(this, _inputBridge, new PresentationInputBridge(
77379
+ win,
77380
+ __privateGet$1(this, _visibleHost),
77381
+ () => __privateMethod$1(this, _PresentationEditor_instances, getActiveDomTarget_fn).call(this),
77382
+ () => __privateGet$1(this, _documentMode) !== "viewing"
77383
+ ));
77108
77384
  __privateGet$1(this, _inputBridge).bind();
77109
77385
  };
77110
77386
  initHeaderFooterRegistry_fn = function() {
@@ -77492,6 +77768,10 @@ updateSelection_fn = function() {
77492
77768
  if (!__privateGet$1(this, _localSelectionLayer)) {
77493
77769
  return;
77494
77770
  }
77771
+ if (__privateGet$1(this, _documentMode) === "viewing") {
77772
+ __privateGet$1(this, _localSelectionLayer).innerHTML = "";
77773
+ return;
77774
+ }
77495
77775
  const layout = __privateGet$1(this, _layoutState).layout;
77496
77776
  const selection = this.getActiveEditor().state?.selection;
77497
77777
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
@@ -78797,11 +79077,27 @@ _PresentationEditor.CURSOR_STYLES = {
78797
79077
  };
78798
79078
  let PresentationEditor = _PresentationEditor;
78799
79079
  class PresentationInputBridge {
78800
- constructor(windowRoot, layoutSurface, getTargetDom, onTargetChanged, options) {
79080
+ /**
79081
+ * Creates a new PresentationInputBridge that forwards user input events from the visible layout
79082
+ * surface to the hidden editor DOM. This enables input handling when the actual editor is not
79083
+ * directly visible to the user.
79084
+ *
79085
+ * @param windowRoot - The window object containing the layout surface and editor target
79086
+ * @param layoutSurface - The visible HTML element that receives user input events (e.g., keyboard, mouse)
79087
+ * @param getTargetDom - Callback that returns the hidden editor's DOM element where events should be forwarded
79088
+ * @param isEditable - Callback that returns whether the editor is in an editable mode (editing/suggesting).
79089
+ * When this returns false (e.g., in viewing mode), keyboard, text, and composition
79090
+ * events will not be forwarded to prevent document modification.
79091
+ * @param onTargetChanged - Optional callback invoked when the target editor DOM element changes
79092
+ * @param options - Optional configuration including:
79093
+ * - useWindowFallback: Whether to attach window-level event listeners as fallback
79094
+ */
79095
+ constructor(windowRoot, layoutSurface, getTargetDom, isEditable, onTargetChanged, options) {
78801
79096
  __privateAdd$1(this, _PresentationInputBridge_instances);
78802
79097
  __privateAdd$1(this, _windowRoot);
78803
79098
  __privateAdd$1(this, _layoutSurfaces);
78804
79099
  __privateAdd$1(this, _getTargetDom);
79100
+ __privateAdd$1(this, _isEditable);
78805
79101
  __privateAdd$1(this, _onTargetChanged);
78806
79102
  __privateAdd$1(this, _listeners);
78807
79103
  __privateAdd$1(this, _currentTarget, null);
@@ -78810,6 +79106,7 @@ class PresentationInputBridge {
78810
79106
  __privateSet(this, _windowRoot, windowRoot);
78811
79107
  __privateSet(this, _layoutSurfaces, /* @__PURE__ */ new Set([layoutSurface]));
78812
79108
  __privateSet(this, _getTargetDom, getTargetDom);
79109
+ __privateSet(this, _isEditable, isEditable);
78813
79110
  __privateSet(this, _onTargetChanged, onTargetChanged);
78814
79111
  __privateSet(this, _listeners, []);
78815
79112
  __privateSet(this, _useWindowFallback, options?.useWindowFallback ?? false);
@@ -78876,6 +79173,7 @@ class PresentationInputBridge {
78876
79173
  _windowRoot = /* @__PURE__ */ new WeakMap();
78877
79174
  _layoutSurfaces = /* @__PURE__ */ new WeakMap();
78878
79175
  _getTargetDom = /* @__PURE__ */ new WeakMap();
79176
+ _isEditable = /* @__PURE__ */ new WeakMap();
78879
79177
  _onTargetChanged = /* @__PURE__ */ new WeakMap();
78880
79178
  _listeners = /* @__PURE__ */ new WeakMap();
78881
79179
  _currentTarget = /* @__PURE__ */ new WeakMap();
@@ -78906,6 +79204,9 @@ dispatchToTarget_fn = function(originalEvent, synthetic) {
78906
79204
  }
78907
79205
  };
78908
79206
  forwardKeyboardEvent_fn = function(event) {
79207
+ if (!__privateGet$1(this, _isEditable).call(this)) {
79208
+ return;
79209
+ }
78909
79210
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
78910
79211
  return;
78911
79212
  }
@@ -78933,6 +79234,9 @@ forwardKeyboardEvent_fn = function(event) {
78933
79234
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
78934
79235
  };
78935
79236
  forwardTextEvent_fn = function(event) {
79237
+ if (!__privateGet$1(this, _isEditable).call(this)) {
79238
+ return;
79239
+ }
78936
79240
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
78937
79241
  return;
78938
79242
  }
@@ -78963,6 +79267,9 @@ forwardTextEvent_fn = function(event) {
78963
79267
  });
78964
79268
  };
78965
79269
  forwardCompositionEvent_fn = function(event) {
79270
+ if (!__privateGet$1(this, _isEditable).call(this)) {
79271
+ return;
79272
+ }
78966
79273
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
78967
79274
  return;
78968
79275
  }
@@ -78982,6 +79289,9 @@ forwardCompositionEvent_fn = function(event) {
78982
79289
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
78983
79290
  };
78984
79291
  forwardContextMenu_fn = function(event) {
79292
+ if (!__privateGet$1(this, _isEditable).call(this)) {
79293
+ return;
79294
+ }
78985
79295
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
78986
79296
  return;
78987
79297
  }