@harbour-enterprises/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
@@ -24996,24 +24996,32 @@
24996
24996
  const DRAWING_XML_TAG = "w:drawing";
24997
24997
  const SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
24998
24998
  const GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
24999
+ const normalizeTargetPath = (targetPath = "") => {
25000
+ if (!targetPath) return targetPath;
25001
+ const trimmed = targetPath.replace(/^\/+/, "");
25002
+ if (trimmed.startsWith("word/")) return trimmed;
25003
+ if (trimmed.startsWith("media/")) return `word/${trimmed}`;
25004
+ return `word/${trimmed}`;
25005
+ };
24999
25006
  const DEFAULT_SHAPE_WIDTH = 100;
25000
25007
  const DEFAULT_SHAPE_HEIGHT = 100;
25001
25008
  function handleImageNode$1(node2, params2, isAnchor) {
25009
+ if (!node2) return null;
25002
25010
  const { docx, filename } = params2;
25003
- const { attributes } = node2;
25011
+ const attributes = node2?.attributes || {};
25004
25012
  const padding = {
25005
- top: emuToPixels(attributes["distT"]),
25006
- bottom: emuToPixels(attributes["distB"]),
25007
- left: emuToPixels(attributes["distL"]),
25008
- right: emuToPixels(attributes["distR"])
25013
+ top: emuToPixels(attributes?.["distT"]),
25014
+ bottom: emuToPixels(attributes?.["distB"]),
25015
+ left: emuToPixels(attributes?.["distL"]),
25016
+ right: emuToPixels(attributes?.["distR"])
25009
25017
  };
25010
- const extent = node2.elements.find((el) => el.name === "wp:extent");
25018
+ const extent = node2?.elements?.find((el) => el.name === "wp:extent");
25011
25019
  const size2 = {
25012
25020
  width: emuToPixels(extent?.attributes?.cx),
25013
25021
  height: emuToPixels(extent?.attributes?.cy)
25014
25022
  };
25015
25023
  let transformData = {};
25016
- const effectExtent = node2.elements.find((el) => el.name === "wp:effectExtent");
25024
+ const effectExtent = node2?.elements?.find((el) => el.name === "wp:effectExtent");
25017
25025
  if (effectExtent) {
25018
25026
  const sanitizeEmuValue = (value) => {
25019
25027
  if (value === null || value === void 0) return 0;
@@ -25027,12 +25035,12 @@
25027
25035
  bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["b"]))
25028
25036
  };
25029
25037
  }
25030
- const positionHTag = node2.elements.find((el) => el.name === "wp:positionH");
25031
- const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
25038
+ const positionHTag = node2?.elements?.find((el) => el.name === "wp:positionH");
25039
+ const positionH = positionHTag?.elements?.find((el) => el.name === "wp:posOffset");
25032
25040
  const positionHValue = emuToPixels(positionH?.elements[0]?.text);
25033
25041
  const hRelativeFrom = positionHTag?.attributes?.relativeFrom;
25034
- const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
25035
- const positionVTag = node2.elements.find((el) => el.name === "wp:positionV");
25042
+ const alignH = positionHTag?.elements?.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
25043
+ const positionVTag = node2?.elements?.find((el) => el.name === "wp:positionV");
25036
25044
  const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
25037
25045
  const positionVValue = emuToPixels(positionV?.elements[0]?.text);
25038
25046
  const vRelativeFrom = positionVTag?.attributes?.relativeFrom;
@@ -25042,8 +25050,8 @@
25042
25050
  top: positionVValue
25043
25051
  };
25044
25052
  const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1 || attributes["simplePos"] === true;
25045
- const simplePosNode = node2.elements.find((el) => el.name === "wp:simplePos");
25046
- const wrapNode = isAnchor ? node2.elements.find(
25053
+ const simplePosNode = node2?.elements?.find((el) => el.name === "wp:simplePos");
25054
+ const wrapNode = isAnchor ? node2?.elements?.find(
25047
25055
  (el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
25048
25056
  ) : null;
25049
25057
  const wrap2 = isAnchor ? { type: wrapNode?.name.slice(7) || "None", attrs: {} } : { type: "Inline" };
@@ -25164,9 +25172,8 @@
25164
25172
  if (!rel) return null;
25165
25173
  const { attributes: relAttributes } = rel;
25166
25174
  const targetPath = relAttributes["Target"];
25167
- let path2 = `word/${targetPath}`;
25168
- if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path2 = targetPath.substring(1);
25169
- const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
25175
+ const path2 = normalizeTargetPath(targetPath);
25176
+ const extension = path2.substring(path2.lastIndexOf(".") + 1);
25170
25177
  return {
25171
25178
  type: "image",
25172
25179
  attrs: {
@@ -25184,8 +25191,8 @@
25184
25191
  transformData,
25185
25192
  ...useSimplePos && {
25186
25193
  simplePos: {
25187
- x: simplePosNode.attributes?.x,
25188
- y: simplePosNode.attributes?.y
25194
+ x: simplePosNode?.attributes?.x,
25195
+ y: simplePosNode?.attributes?.y
25189
25196
  }
25190
25197
  },
25191
25198
  wrap: wrap2,
@@ -25195,12 +25202,12 @@
25195
25202
  wrapTopAndBottom: wrap2.type === "TopAndBottom",
25196
25203
  shouldStretch,
25197
25204
  originalPadding: {
25198
- distT: attributes["distT"],
25199
- distB: attributes["distB"],
25200
- distL: attributes["distL"],
25201
- distR: attributes["distR"]
25205
+ distT: attributes?.["distT"],
25206
+ distB: attributes?.["distB"],
25207
+ distL: attributes?.["distL"],
25208
+ distR: attributes?.["distR"]
25202
25209
  },
25203
- originalAttributes: node2.attributes,
25210
+ originalAttributes: node2?.attributes || {},
25204
25211
  rId: relAttributes["Id"]
25205
25212
  }
25206
25213
  };
@@ -25364,11 +25371,8 @@
25364
25371
  const { elements } = relationships || [];
25365
25372
  const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
25366
25373
  if (!rel) return null;
25367
- const targetPath = rel.attributes?.["Target"];
25368
- let path2 = `word/${targetPath}`;
25369
- if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) {
25370
- path2 = targetPath.substring(1);
25371
- }
25374
+ const targetPath = normalizeTargetPath(rel.attributes?.["Target"]);
25375
+ const path2 = targetPath;
25372
25376
  const nvPicPr = pic.elements?.find((el) => el.name === "pic:nvPicPr");
25373
25377
  const cNvPr = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPr");
25374
25378
  const picId = cNvPr?.attributes?.["id"];
@@ -36389,7 +36393,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36389
36393
  static getStoredSuperdocVersion(docx) {
36390
36394
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
36391
36395
  }
36392
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.21") {
36396
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.23") {
36393
36397
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36394
36398
  }
36395
36399
  /**
@@ -47552,7 +47556,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
47552
47556
  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);
47553
47557
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
47554
47558
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
47555
- 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;
47559
+ 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;
47556
47560
  var GOOD_LEAF_SIZE = 200;
47557
47561
  var RopeSequence = function RopeSequence2() {
47558
47562
  };
@@ -57454,6 +57458,59 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57454
57458
  return true;
57455
57459
  };
57456
57460
  }
57461
+ const decreaseListIndent = () => ({ editor, tr, dispatch }) => {
57462
+ const handled = changeListLevel(-1, editor, tr);
57463
+ if (handled && dispatch) {
57464
+ dispatch(tr);
57465
+ }
57466
+ return handled;
57467
+ };
57468
+ const removeNumberingProperties = ({ checkType = "startParagraph" } = {}) => (props) => {
57469
+ const { tr, state: state2, editor, dispatch } = props;
57470
+ const { node: paragraph2, pos } = findParentNode(isList)(state2.selection) || {};
57471
+ if (!paragraph2) return false;
57472
+ if (checkType === "empty" && !isVisuallyEmptyParagraph(paragraph2)) return false;
57473
+ if (checkType === "startParagraph") {
57474
+ const { $from, empty: empty2 } = state2.selection;
57475
+ if ((!empty2 || $from.parentOffset !== 0) && !isVisuallyEmptyParagraph(paragraph2)) return false;
57476
+ }
57477
+ const ilvl = getResolvedParagraphProperties(paragraph2).numberingProperties.ilvl;
57478
+ if (ilvl > 0) {
57479
+ const outdented = decreaseListIndent()(props);
57480
+ if (outdented) {
57481
+ tr.scrollIntoView();
57482
+ }
57483
+ return outdented;
57484
+ } else {
57485
+ updateNumberingProperties(null, paragraph2, pos, editor, tr);
57486
+ }
57487
+ if (dispatch) dispatch(tr);
57488
+ return true;
57489
+ };
57490
+ function isVisuallyEmptyParagraph(node2) {
57491
+ if (!node2 || node2.type.name !== "paragraph") return false;
57492
+ let hasHardBreak = false;
57493
+ node2.descendants((n) => {
57494
+ if (n.type && n.type.name === "hardBreak") {
57495
+ hasHardBreak = true;
57496
+ return false;
57497
+ }
57498
+ return true;
57499
+ });
57500
+ if (hasHardBreak) return false;
57501
+ const text2 = (node2.textContent || "").replace(/\u200b/g, "").trim();
57502
+ if (text2.length > 0) return false;
57503
+ let hasInlineLeaf = false;
57504
+ node2.descendants((n) => {
57505
+ if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak" && n.type?.name !== "run") {
57506
+ hasInlineLeaf = true;
57507
+ return false;
57508
+ }
57509
+ return true;
57510
+ });
57511
+ if (hasInlineLeaf) return false;
57512
+ return true;
57513
+ }
57457
57514
  const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
57458
57515
  let predicate;
57459
57516
  if (listType === "orderedList") {
@@ -57473,19 +57530,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57473
57530
  const { from: from2, to } = selection;
57474
57531
  let firstListNode = null;
57475
57532
  let hasNonListParagraphs = false;
57476
- let paragraphsInSelection = [];
57533
+ let allParagraphsInSelection = [];
57477
57534
  state2.doc.nodesBetween(from2, to, (node2, pos) => {
57478
57535
  if (node2.type.name === "paragraph") {
57479
- paragraphsInSelection.push({ node: node2, pos });
57480
- if (!firstListNode && predicate(node2)) {
57481
- firstListNode = node2;
57482
- } else if (!predicate(node2)) {
57483
- hasNonListParagraphs = true;
57484
- }
57536
+ allParagraphsInSelection.push({ node: node2, pos });
57485
57537
  return false;
57486
57538
  }
57487
57539
  return true;
57488
57540
  });
57541
+ let paragraphsInSelection = allParagraphsInSelection.length === 1 ? allParagraphsInSelection : allParagraphsInSelection.filter(({ node: node2 }) => !isVisuallyEmptyParagraph(node2));
57542
+ for (const { node: node2 } of paragraphsInSelection) {
57543
+ if (!firstListNode && predicate(node2)) {
57544
+ firstListNode = node2;
57545
+ } else if (!predicate(node2)) {
57546
+ hasNonListParagraphs = true;
57547
+ }
57548
+ }
57489
57549
  if (!firstListNode && from2 > 0) {
57490
57550
  const $from = state2.doc.resolve(from2);
57491
57551
  const parentIndex = $from.index(-1);
@@ -57529,11 +57589,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57529
57589
  }
57530
57590
  updateNumberingProperties(sharedNumberingProperties, node2, pos, editor, tr);
57531
57591
  }
57532
- const newTo = tr.mapping.map(to);
57533
- if (newTo >= 0 && newTo <= tr.doc.content.size) {
57534
- try {
57535
- tr.setSelection(state2.selection.constructor.near(tr.doc.resolve(newTo)));
57536
- } catch {
57592
+ if (paragraphsInSelection.length > 0) {
57593
+ const firstPara = paragraphsInSelection[0];
57594
+ const lastPara = paragraphsInSelection[paragraphsInSelection.length - 1];
57595
+ const mappedFirstPos = tr.mapping.map(firstPara.pos);
57596
+ const mappedLastPos = tr.mapping.map(lastPara.pos);
57597
+ const $firstPos = tr.doc.resolve(mappedFirstPos);
57598
+ const $lastPos = tr.doc.resolve(mappedLastPos);
57599
+ const firstNode = $firstPos.nodeAfter;
57600
+ const lastNode = $lastPos.nodeAfter;
57601
+ if (firstNode && lastNode) {
57602
+ let selFrom = mappedFirstPos + 1;
57603
+ let selTo = mappedLastPos + lastNode.nodeSize - 1;
57604
+ if (firstNode.firstChild && firstNode.firstChild.type.name === "run") {
57605
+ selFrom = mappedFirstPos + 2;
57606
+ }
57607
+ if (lastNode.lastChild && lastNode.lastChild.type.name === "run") {
57608
+ selTo = mappedLastPos + lastNode.nodeSize - 2;
57609
+ }
57610
+ if (selFrom >= 0 && selTo <= tr.doc.content.size && selFrom <= selTo) {
57611
+ try {
57612
+ tr.setSelection(TextSelection$1.create(tr.doc, selFrom, selTo));
57613
+ } catch {
57614
+ }
57615
+ }
57537
57616
  }
57538
57617
  }
57539
57618
  if (dispatch) dispatch(tr);
@@ -57546,59 +57625,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57546
57625
  }
57547
57626
  return handled;
57548
57627
  };
57549
- const decreaseListIndent = () => ({ editor, tr, dispatch }) => {
57550
- const handled = changeListLevel(-1, editor, tr);
57551
- if (handled && dispatch) {
57552
- dispatch(tr);
57553
- }
57554
- return handled;
57555
- };
57556
- const removeNumberingProperties = ({ checkType = "startParagraph" } = {}) => (props) => {
57557
- const { tr, state: state2, editor, dispatch } = props;
57558
- const { node: paragraph2, pos } = findParentNode(isList)(state2.selection) || {};
57559
- if (!paragraph2) return false;
57560
- if (checkType === "empty" && !isVisuallyEmptyParagraph(paragraph2)) return false;
57561
- if (checkType === "startParagraph") {
57562
- const { $from, empty: empty2 } = state2.selection;
57563
- if ((!empty2 || $from.parentOffset !== 0) && !isVisuallyEmptyParagraph(paragraph2)) return false;
57564
- }
57565
- const ilvl = getResolvedParagraphProperties(paragraph2).numberingProperties.ilvl;
57566
- if (ilvl > 0) {
57567
- const outdented = decreaseListIndent()(props);
57568
- if (outdented) {
57569
- tr.scrollIntoView();
57570
- }
57571
- return outdented;
57572
- } else {
57573
- updateNumberingProperties(null, paragraph2, pos, editor, tr);
57574
- }
57575
- if (dispatch) dispatch(tr);
57576
- return true;
57577
- };
57578
- function isVisuallyEmptyParagraph(node2) {
57579
- if (!node2 || node2.type.name !== "paragraph") return false;
57580
- let hasHardBreak = false;
57581
- node2.descendants((n) => {
57582
- if (n.type && n.type.name === "hardBreak") {
57583
- hasHardBreak = true;
57584
- return false;
57585
- }
57586
- return true;
57587
- });
57588
- if (hasHardBreak) return false;
57589
- const text2 = (node2.textContent || "").replace(/\u200b/g, "").trim();
57590
- if (text2.length > 0) return false;
57591
- let hasInlineLeaf = false;
57592
- node2.descendants((n) => {
57593
- if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak" && n.type?.name !== "run") {
57594
- hasInlineLeaf = true;
57595
- return false;
57596
- }
57597
- return true;
57598
- });
57599
- if (hasInlineLeaf) return false;
57600
- return true;
57601
- }
57602
57628
  const restoreSelection = () => ({ editor, state: state2, tr }) => {
57603
57629
  if (editor.options.lastSelection) {
57604
57630
  const selectionTr = tr.setSelection(
@@ -57681,6 +57707,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57681
57707
  insertTabCharacter,
57682
57708
  insertTabNode,
57683
57709
  isStyleTokenEnabled,
57710
+ isVisuallyEmptyParagraph,
57684
57711
  joinBackward,
57685
57712
  joinDown,
57686
57713
  joinForward,
@@ -57799,12 +57826,38 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57799
57826
  const Editable = Extension.create({
57800
57827
  name: "editable",
57801
57828
  addPmPlugins() {
57829
+ const editor = this.editor;
57802
57830
  const editablePlugin = new Plugin({
57803
57831
  key: new PluginKey("editable"),
57804
57832
  props: {
57805
- editable: () => {
57806
- return this.editor.options.editable;
57807
- }
57833
+ editable: () => editor.options.editable,
57834
+ handleDOMEvents: {
57835
+ beforeinput: (_view, event) => {
57836
+ if (!editor.options.editable) {
57837
+ event.preventDefault();
57838
+ return true;
57839
+ }
57840
+ return false;
57841
+ },
57842
+ mousedown: (_view, event) => {
57843
+ if (!editor.options.editable) {
57844
+ event.preventDefault();
57845
+ return true;
57846
+ }
57847
+ return false;
57848
+ },
57849
+ focus: (view, event) => {
57850
+ if (!editor.options.editable) {
57851
+ event.preventDefault();
57852
+ view.dom.blur();
57853
+ return true;
57854
+ }
57855
+ return false;
57856
+ }
57857
+ },
57858
+ handleClick: () => !editor.options.editable,
57859
+ handleDoubleClick: () => !editor.options.editable,
57860
+ handleTripleClick: () => !editor.options.editable
57808
57861
  }
57809
57862
  });
57810
57863
  return [editablePlugin];
@@ -61362,7 +61415,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61362
61415
  const shouldSkipNodeView = (editor) => {
61363
61416
  return isHeadless(editor);
61364
61417
  };
61365
- const summaryVersion = "1.0.0-beta.21";
61418
+ const summaryVersion = "1.0.0-beta.23";
61366
61419
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
61367
61420
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
61368
61421
  function mapAttributes(attrs) {
@@ -61767,10 +61820,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61767
61820
  this.view.updateState(this.state);
61768
61821
  }
61769
61822
  /**
61770
- * Set whether the editor is editable
61823
+ * Set whether the editor is editable.
61824
+ *
61825
+ * When setting to non-editable, this method:
61826
+ * - Forces ProseMirror to re-evaluate the editable prop from the Editable plugin
61827
+ * - Blurs the editor to remove the cursor
61828
+ *
61829
+ * @param editable - Whether the editor should accept user input (default: true)
61830
+ * @param emitUpdate - Whether to emit an update event after changing editability (default: true)
61771
61831
  */
61772
61832
  setEditable(editable = true, emitUpdate = true) {
61773
61833
  this.setOptions({ editable });
61834
+ if (this.view) {
61835
+ this.view.setProps({});
61836
+ if (!editable && this.view.dom) {
61837
+ this.view.dom.blur();
61838
+ }
61839
+ }
61774
61840
  if (emitUpdate) {
61775
61841
  this.emit("update", { editor: this, transaction: this.state.tr });
61776
61842
  }
@@ -62138,7 +62204,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62138
62204
  { default: remarkStringify2 },
62139
62205
  { default: remarkGfm2 }
62140
62206
  ] = await Promise.all([
62141
- Promise.resolve().then(() => indexDSuc12CK),
62207
+ Promise.resolve().then(() => indexDYBG7Xab),
62142
62208
  Promise.resolve().then(() => indexDRCvimau),
62143
62209
  Promise.resolve().then(() => indexC_x_N6Uh),
62144
62210
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -62343,7 +62409,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62343
62409
  * Process collaboration migrations
62344
62410
  */
62345
62411
  processCollaborationMigrations() {
62346
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.21");
62412
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.23");
62347
62413
  if (!this.options.ydoc) return;
62348
62414
  const metaMap = this.options.ydoc.getMap("meta");
62349
62415
  let docVersion = metaMap.get("version");
@@ -64795,6 +64861,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64795
64861
  case "right":
64796
64862
  case "justify":
64797
64863
  return value;
64864
+ case "both":
64865
+ case "distribute":
64866
+ case "numTab":
64867
+ case "thaiDistribute":
64868
+ return "justify";
64798
64869
  case "end":
64799
64870
  return "right";
64800
64871
  case "start":
@@ -67009,6 +67080,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67009
67080
  } else if (computed2.paragraph.alignment) {
67010
67081
  paragraphAttrs.alignment = computed2.paragraph.alignment;
67011
67082
  }
67083
+ const isJustified = paragraphAttrs.alignment === "justify" || paragraphAttrs.alignment === "both";
67084
+ const hasFirstLineIndent = normalizedIndent?.firstLine && normalizedIndent.firstLine > 0;
67085
+ if (isJustified && hasFirstLineIndent) {
67086
+ paragraphAttrs.suppressFirstLineIndent = true;
67087
+ }
67012
67088
  const spacingPx = spacingPtToPx(spacing, normalizedSpacing);
67013
67089
  if (spacingPx) paragraphAttrs.spacing = spacingPx;
67014
67090
  if (normalizedSpacing?.beforeAutospacing != null || normalizedSpacing?.afterAutospacing != null) {
@@ -67226,7 +67302,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67226
67302
  }
67227
67303
  }
67228
67304
  paragraphAttrs.wordLayout = wordLayout;
67229
- if (enrichedNumberingProps.resolvedLevelIndent) {
67305
+ if (enrichedNumberingProps.resolvedLevelIndent && !hasExplicitIndent) {
67230
67306
  const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
67231
67307
  paragraphAttrs.indent = {
67232
67308
  ...paragraphAttrs.indent,
@@ -70592,8 +70668,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70592
70668
  });
70593
70669
  return nextSectionPropsAtBreak;
70594
70670
  }
70595
- function scheduleSectionBreak(block, state2, baseMargins) {
70671
+ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight = 0) {
70596
70672
  const next2 = { ...state2 };
70673
+ const calcRequiredTopMargin = (headerDistance, baseTop) => {
70674
+ if (maxHeaderContentHeight > 0) {
70675
+ return Math.max(baseTop, headerDistance + maxHeaderContentHeight);
70676
+ }
70677
+ return Math.max(baseTop, headerDistance);
70678
+ };
70597
70679
  if (block.attrs?.isFirstSection && !next2.hasAnyPages) {
70598
70680
  if (block.pageSize) {
70599
70681
  next2.activePageSize = { w: block.pageSize.w, h: block.pageSize.h };
@@ -70607,7 +70689,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70607
70689
  const headerDistance = Math.max(0, block.margins.header);
70608
70690
  next2.activeHeaderDistance = headerDistance;
70609
70691
  next2.pendingHeaderDistance = headerDistance;
70610
- next2.activeTopMargin = Math.max(baseMargins.top, headerDistance);
70692
+ next2.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
70611
70693
  next2.pendingTopMargin = next2.activeTopMargin;
70612
70694
  }
70613
70695
  if (block.margins?.footer !== void 0) {
@@ -70629,9 +70711,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70629
70711
  const nextBottom = next2.pendingBottomMargin ?? next2.activeBottomMargin;
70630
70712
  const nextHeader = next2.pendingHeaderDistance ?? next2.activeHeaderDistance;
70631
70713
  const nextFooter = next2.pendingFooterDistance ?? next2.activeFooterDistance;
70632
- next2.pendingTopMargin = typeof headerPx === "number" ? Math.max(baseMargins.top, headerPx) : nextTop;
70714
+ if (typeof headerPx === "number") {
70715
+ const newHeaderDist = Math.max(0, headerPx);
70716
+ next2.pendingHeaderDistance = newHeaderDist;
70717
+ next2.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, baseMargins.top);
70718
+ } else {
70719
+ next2.pendingTopMargin = nextTop;
70720
+ next2.pendingHeaderDistance = nextHeader;
70721
+ }
70633
70722
  next2.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
70634
- next2.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
70635
70723
  next2.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
70636
70724
  if (block.pageSize) {
70637
70725
  next2.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
@@ -72096,7 +72184,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72096
72184
  if (contentWidth <= 0) {
72097
72185
  throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
72098
72186
  }
72099
- let activeTopMargin = margins.top;
72187
+ const validateHeaderHeight = (height) => {
72188
+ if (height === void 0) return 0;
72189
+ if (!Number.isFinite(height) || height < 0) return 0;
72190
+ return height;
72191
+ };
72192
+ const headerContentHeights = options.headerContentHeights;
72193
+ const maxHeaderContentHeight = headerContentHeights ? Math.max(
72194
+ 0,
72195
+ validateHeaderHeight(headerContentHeights.default),
72196
+ validateHeaderHeight(headerContentHeights.first),
72197
+ validateHeaderHeight(headerContentHeights.even),
72198
+ validateHeaderHeight(headerContentHeights.odd)
72199
+ ) : 0;
72200
+ const headerDistance = margins.header ?? margins.top;
72201
+ const effectiveTopMargin = maxHeaderContentHeight > 0 ? Math.max(margins.top, headerDistance + maxHeaderContentHeight) : margins.top;
72202
+ let activeTopMargin = effectiveTopMargin;
72100
72203
  let activeBottomMargin = margins.bottom;
72101
72204
  let pendingTopMargin = null;
72102
72205
  let pendingBottomMargin = null;
@@ -72120,7 +72223,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72120
72223
  const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks2);
72121
72224
  const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
72122
72225
  if (typeof scheduleSectionBreak === "function") {
72123
- return scheduleSectionBreak(block, state2, baseMargins);
72226
+ return scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight);
72124
72227
  }
72125
72228
  const next2 = { ...state2 };
72126
72229
  if (block.attrs?.isFirstSection && !next2.hasAnyPages) {
@@ -72133,10 +72236,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72133
72236
  next2.pendingOrientation = null;
72134
72237
  }
72135
72238
  if (block.margins?.header !== void 0) {
72136
- const headerDistance = Math.max(0, block.margins.header);
72137
- next2.activeHeaderDistance = headerDistance;
72138
- next2.pendingHeaderDistance = headerDistance;
72139
- next2.activeTopMargin = Math.max(baseMargins.top, headerDistance);
72239
+ const headerDist = Math.max(0, block.margins.header);
72240
+ next2.activeHeaderDistance = headerDist;
72241
+ next2.pendingHeaderDistance = headerDist;
72242
+ const requiredTop = maxHeaderContentHeight > 0 ? headerDist + maxHeaderContentHeight : headerDist;
72243
+ next2.activeTopMargin = Math.max(baseMargins.top, requiredTop);
72140
72244
  next2.pendingTopMargin = next2.activeTopMargin;
72141
72245
  }
72142
72246
  if (block.margins?.footer !== void 0) {
@@ -72173,14 +72277,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72173
72277
  }
72174
72278
  const headerPx = block.margins?.header;
72175
72279
  const footerPx = block.margins?.footer;
72280
+ const topPx = block.margins?.top;
72176
72281
  const nextTop = next2.pendingTopMargin ?? next2.activeTopMargin;
72177
72282
  const nextBottom = next2.pendingBottomMargin ?? next2.activeBottomMargin;
72178
72283
  const nextHeader = next2.pendingHeaderDistance ?? next2.activeHeaderDistance;
72179
72284
  const nextFooter = next2.pendingFooterDistance ?? next2.activeFooterDistance;
72180
- next2.pendingTopMargin = typeof headerPx === "number" ? Math.max(baseMargins.top, headerPx) : nextTop;
72181
- next2.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
72182
72285
  next2.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
72183
72286
  next2.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
72287
+ if (typeof headerPx === "number" || typeof topPx === "number") {
72288
+ const sectionTop = topPx ?? baseMargins.top;
72289
+ const sectionHeader = next2.pendingHeaderDistance;
72290
+ const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
72291
+ next2.pendingTopMargin = Math.max(sectionTop, requiredTop);
72292
+ } else {
72293
+ next2.pendingTopMargin = nextTop;
72294
+ }
72295
+ next2.pendingBottomMargin = typeof footerPx === "number" ? Math.max(baseMargins.bottom, footerPx) : nextBottom;
72184
72296
  if (block.pageSize) next2.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
72185
72297
  if (block.orientation) next2.pendingOrientation = block.orientation;
72186
72298
  const sectionType = block.type ?? "continuous";
@@ -72931,7 +73043,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72931
73043
  }
72932
73044
  return attrs.trackedChangesEnabled !== false;
72933
73045
  };
72934
- const MAX_CACHE_SIZE = 1e4;
73046
+ const MAX_CACHE_SIZE$1 = 1e4;
72935
73047
  const BYTES_PER_ENTRY_ESTIMATE = 5e3;
72936
73048
  const NORMALIZED_WHITESPACE = /\s+/g;
72937
73049
  const normalizeText = (text2) => text2.replace(NORMALIZED_WHITESPACE, " ");
@@ -73031,7 +73143,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73031
73143
  if (this.cache.has(key2)) {
73032
73144
  this.cache.delete(key2);
73033
73145
  }
73034
- if (this.cache.size >= MAX_CACHE_SIZE) {
73146
+ if (this.cache.size >= MAX_CACHE_SIZE$1) {
73035
73147
  const oldestKey = this.cache.keys().next().value;
73036
73148
  if (oldestKey !== void 0) {
73037
73149
  this.cache.delete(oldestKey);
@@ -73105,13 +73217,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73105
73217
  * Get maximum cache size
73106
73218
  */
73107
73219
  getMaxSize() {
73108
- return MAX_CACHE_SIZE;
73220
+ return MAX_CACHE_SIZE$1;
73109
73221
  }
73110
73222
  /**
73111
73223
  * Check if cache is near capacity
73112
73224
  */
73113
73225
  isNearCapacity(threshold = 0.9) {
73114
- return this.cache.size >= MAX_CACHE_SIZE * threshold;
73226
+ return this.cache.size >= MAX_CACHE_SIZE$1 * threshold;
73115
73227
  }
73116
73228
  /**
73117
73229
  * Update size statistics
@@ -74123,9 +74235,46 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74123
74235
  perfLog(
74124
74236
  `[Perf] 4.1 Measure all blocks: ${(measureEnd - measureStart).toFixed(2)}ms (${cacheMisses} measured, ${cacheHits} cached)`
74125
74237
  );
74238
+ let headerContentHeights;
74239
+ if (headerFooter?.constraints && headerFooter.headerBlocks) {
74240
+ const hfPreStart = performance.now();
74241
+ const measureFn = headerFooter.measure ?? measureBlock2;
74242
+ invalidateHeaderFooterCache(
74243
+ headerMeasureCache,
74244
+ headerFooterCacheState,
74245
+ headerFooter.headerBlocks,
74246
+ headerFooter.footerBlocks,
74247
+ headerFooter.constraints,
74248
+ options.sectionMetadata
74249
+ );
74250
+ const HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT = 1;
74251
+ const preHeaderLayouts = await layoutHeaderFooterWithCache(
74252
+ headerFooter.headerBlocks,
74253
+ headerFooter.constraints,
74254
+ measureFn,
74255
+ headerMeasureCache,
74256
+ HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
74257
+ void 0
74258
+ // No page resolver needed for height calculation
74259
+ );
74260
+ const isValidHeaderType = (key2) => {
74261
+ return ["default", "first", "even", "odd"].includes(key2);
74262
+ };
74263
+ headerContentHeights = {};
74264
+ for (const [type2, value] of Object.entries(preHeaderLayouts)) {
74265
+ if (!isValidHeaderType(type2)) continue;
74266
+ if (value?.layout && typeof value.layout.height === "number") {
74267
+ headerContentHeights[type2] = value.layout.height;
74268
+ }
74269
+ }
74270
+ const hfPreEnd = performance.now();
74271
+ perfLog(`[Perf] 4.1.5 Pre-layout headers for height: ${(hfPreEnd - hfPreStart).toFixed(2)}ms`);
74272
+ }
74126
74273
  const layoutStart = performance.now();
74127
74274
  let layout = layoutDocument(nextBlocks, measures, {
74128
74275
  ...options,
74276
+ headerContentHeights,
74277
+ // Pass header heights to prevent overlap
74129
74278
  remeasureParagraph: (block, maxWidth) => remeasureParagraph(block, maxWidth)
74130
74279
  });
74131
74280
  const layoutEnd = performance.now();
@@ -74172,6 +74321,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74172
74321
  const relayoutStart = performance.now();
74173
74322
  layout = layoutDocument(currentBlocks, currentMeasures, {
74174
74323
  ...options,
74324
+ headerContentHeights,
74325
+ // Pass header heights to prevent overlap
74175
74326
  remeasureParagraph: (block, maxWidth) => remeasureParagraph(block, maxWidth)
74176
74327
  });
74177
74328
  const relayoutEnd = performance.now();
@@ -77221,7 +77372,12 @@ ${l}
77221
77372
  height: `${lineHeight2}px`,
77222
77373
  position: "relative",
77223
77374
  display: "block",
77224
- whiteSpace: "pre"
77375
+ whiteSpace: "pre",
77376
+ // Allow text to overflow the line container as a safety net.
77377
+ // The primary fix uses accurate font metrics from Canvas API, but this
77378
+ // provides defense-in-depth against any remaining sub-pixel rendering
77379
+ // differences between measurement and display.
77380
+ overflow: "visible"
77225
77381
  });
77226
77382
  const PRINT_STYLES = `
77227
77383
  @media print {
@@ -78787,7 +78943,8 @@ ${l}
78787
78943
  const paraIndent = block.attrs?.indent;
78788
78944
  const paraIndentLeft = paraIndent?.left ?? 0;
78789
78945
  const paraIndentRight = paraIndent?.right ?? 0;
78790
- const firstLineOffset = (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
78946
+ const suppressFirstLineIndent = block.attrs?.suppressFirstLineIndent === true;
78947
+ const firstLineOffset = suppressFirstLineIndent ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
78791
78948
  lines.forEach((line, index2) => {
78792
78949
  const lineEl = this.renderLine(block, line, context);
78793
78950
  const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
@@ -80414,9 +80571,36 @@ ${l}
80414
80571
  }
80415
80572
  return base2;
80416
80573
  };
80574
+ const hasListMarkerProperties = (attrs) => {
80575
+ if (!attrs || typeof attrs !== "object") return false;
80576
+ const obj = attrs;
80577
+ if (!obj.numberingProperties || typeof obj.numberingProperties !== "object") return false;
80578
+ const numProps = obj.numberingProperties;
80579
+ if ("numId" in numProps) {
80580
+ const numId = numProps.numId;
80581
+ if (typeof numId !== "number" && typeof numId !== "string") return false;
80582
+ }
80583
+ if ("ilvl" in numProps) {
80584
+ const ilvl = numProps.ilvl;
80585
+ if (typeof ilvl !== "number") return false;
80586
+ }
80587
+ if ("wordLayout" in obj && obj.wordLayout !== void 0) {
80588
+ if (typeof obj.wordLayout !== "object" || obj.wordLayout === null) return false;
80589
+ const wordLayout = obj.wordLayout;
80590
+ if ("marker" in wordLayout && wordLayout.marker !== void 0) {
80591
+ if (typeof wordLayout.marker !== "object" || wordLayout.marker === null) return false;
80592
+ const marker = wordLayout.marker;
80593
+ if ("markerText" in marker && marker.markerText !== void 0) {
80594
+ if (typeof marker.markerText !== "string") return false;
80595
+ }
80596
+ }
80597
+ }
80598
+ return true;
80599
+ };
80417
80600
  const deriveBlockVersion = (block) => {
80418
80601
  if (block.kind === "paragraph") {
80419
- return block.runs.map((run2) => {
80602
+ const markerVersion = hasListMarkerProperties(block.attrs) ? `marker:${block.attrs.numberingProperties.numId ?? ""}:${block.attrs.numberingProperties.ilvl ?? 0}:${block.attrs.wordLayout?.marker?.markerText ?? ""}` : "";
80603
+ const runsVersion = block.runs.map((run2) => {
80420
80604
  if (run2.kind === "image") {
80421
80605
  const imgRun = run2;
80422
80606
  return [
@@ -80459,6 +80643,7 @@ ${l}
80459
80643
  textRun.token ?? ""
80460
80644
  ].join(",");
80461
80645
  }).join("|");
80646
+ return markerVersion ? `${markerVersion}|${runsVersion}` : runsVersion;
80462
80647
  }
80463
80648
  if (block.kind === "list") {
80464
80649
  return block.items.map((item) => `${item.id}:${item.marker.text}:${deriveBlockVersion(item.paragraph)}`).join("|");
@@ -80948,6 +81133,61 @@ ${l}
80948
81133
  cache$1$1.delete(oldestKey);
80949
81134
  }
80950
81135
  }
81136
+ const fontMetricsCache = /* @__PURE__ */ new Map();
81137
+ const MAX_CACHE_SIZE = 1e3;
81138
+ const METRICS_TEST_STRING = "MHgypbdlÁÉÍ";
81139
+ function getFontKey(fontInfo) {
81140
+ return `${fontInfo.fontFamily}|${fontInfo.fontSize}|${fontInfo.bold ?? false}|${fontInfo.italic ?? false}`;
81141
+ }
81142
+ function buildFontStringForMetrics(fontInfo, mode, fonts) {
81143
+ const parts = [];
81144
+ if (fontInfo.italic) parts.push("italic");
81145
+ if (fontInfo.bold) parts.push("bold");
81146
+ parts.push(`${fontInfo.fontSize}px`);
81147
+ {
81148
+ parts.push(fontInfo.fontFamily);
81149
+ }
81150
+ return parts.join(" ");
81151
+ }
81152
+ function getFontMetrics(ctx2, fontInfo, mode, fonts) {
81153
+ if (!ctx2 || typeof ctx2 !== "object") {
81154
+ throw new TypeError("Canvas context must be a valid CanvasRenderingContext2D object");
81155
+ }
81156
+ if (typeof fontInfo.fontSize !== "number" || !Number.isFinite(fontInfo.fontSize) || fontInfo.fontSize <= 0) {
81157
+ throw new TypeError(
81158
+ `Font size must be a positive finite number, got: ${typeof fontInfo.fontSize === "number" ? fontInfo.fontSize : typeof fontInfo.fontSize}`
81159
+ );
81160
+ }
81161
+ if (typeof fontInfo.fontFamily !== "string" || fontInfo.fontFamily.trim().length === 0) {
81162
+ throw new TypeError("Font family must be a non-empty string");
81163
+ }
81164
+ const key2 = getFontKey(fontInfo);
81165
+ const cached = fontMetricsCache.get(key2);
81166
+ if (cached) {
81167
+ return cached;
81168
+ }
81169
+ const font = buildFontStringForMetrics(fontInfo);
81170
+ ctx2.font = font;
81171
+ const textMetrics = ctx2.measureText(METRICS_TEST_STRING);
81172
+ let ascent;
81173
+ let descent;
81174
+ if (typeof textMetrics.actualBoundingBoxAscent === "number" && typeof textMetrics.actualBoundingBoxDescent === "number" && textMetrics.actualBoundingBoxAscent > 0) {
81175
+ ascent = textMetrics.actualBoundingBoxAscent;
81176
+ descent = textMetrics.actualBoundingBoxDescent;
81177
+ } else {
81178
+ ascent = fontInfo.fontSize * 0.8;
81179
+ descent = fontInfo.fontSize * 0.2;
81180
+ }
81181
+ const result = { ascent, descent };
81182
+ if (fontMetricsCache.size >= MAX_CACHE_SIZE) {
81183
+ const firstKey = fontMetricsCache.keys().next().value;
81184
+ if (firstKey) {
81185
+ fontMetricsCache.delete(firstKey);
81186
+ }
81187
+ }
81188
+ fontMetricsCache.set(key2, result);
81189
+ return result;
81190
+ }
80951
81191
  const { computeTabStops } = Engines;
80952
81192
  let canvasContext = null;
80953
81193
  const DEFAULT_TAB_INTERVAL_TWIPS = 720;
@@ -80995,10 +81235,20 @@ ${l}
80995
81235
  return Math.max(advanceWidth, paintedWidth);
80996
81236
  }
80997
81237
  const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
80998
- function calculateTypographyMetrics(fontSize2, spacing) {
80999
- const ascent = roundValue(fontSize2 * 0.8);
81000
- const descent = roundValue(fontSize2 * 0.2);
81001
- const baseLineHeight = Math.max(fontSize2, MIN_SINGLE_LINE_PX);
81238
+ const LINE_HEIGHT_SAFETY_MARGIN_PX = 1;
81239
+ function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
81240
+ let ascent;
81241
+ let descent;
81242
+ if (fontInfo) {
81243
+ const ctx2 = getCanvasContext();
81244
+ const metrics = getFontMetrics(ctx2, fontInfo);
81245
+ ascent = roundValue(metrics.ascent);
81246
+ descent = roundValue(metrics.descent);
81247
+ } else {
81248
+ ascent = roundValue(fontSize2 * 0.8);
81249
+ descent = roundValue(fontSize2 * 0.2);
81250
+ }
81251
+ const baseLineHeight = Math.max(ascent + descent + LINE_HEIGHT_SAFETY_MARGIN_PX, MIN_SINGLE_LINE_PX);
81002
81252
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
81003
81253
  return {
81004
81254
  ascent,
@@ -81006,6 +81256,20 @@ ${l}
81006
81256
  lineHeight: lineHeight2
81007
81257
  };
81008
81258
  }
81259
+ function getFontInfoFromRun(run2) {
81260
+ return {
81261
+ fontFamily: run2.fontFamily,
81262
+ fontSize: run2.fontSize,
81263
+ bold: run2.bold,
81264
+ italic: run2.italic
81265
+ };
81266
+ }
81267
+ function updateMaxFontInfo(currentMaxSize, currentMaxInfo, newRun) {
81268
+ if (newRun.fontSize >= currentMaxSize) {
81269
+ return getFontInfoFromRun(newRun);
81270
+ }
81271
+ return currentMaxInfo;
81272
+ }
81009
81273
  function isTabRun(run2) {
81010
81274
  return run2.kind === "tab";
81011
81275
  }
@@ -81051,7 +81315,8 @@ ${l}
81051
81315
  const indentRight = sanitizePositive(indent2?.right);
81052
81316
  const firstLine = indent2?.firstLine ?? 0;
81053
81317
  const hanging = indent2?.hanging ?? 0;
81054
- const firstLineOffset = firstLine - hanging;
81318
+ const suppressFirstLine = block.attrs?.suppressFirstLineIndent === true;
81319
+ const firstLineOffset = suppressFirstLine ? 0 : firstLine - hanging;
81055
81320
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
81056
81321
  const initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
81057
81322
  const tabStops = buildTabStopsPx(
@@ -81187,7 +81452,7 @@ ${l}
81187
81452
  const run2 = runsToProcess[runIndex];
81188
81453
  if (run2.kind === "break") {
81189
81454
  if (currentLine) {
81190
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
81455
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81191
81456
  const completedLine = { ...currentLine, ...metrics };
81192
81457
  addBarTabsToLine(completedLine);
81193
81458
  lines.push(completedLine);
@@ -81217,7 +81482,7 @@ ${l}
81217
81482
  }
81218
81483
  if (isLineBreakRun(run2)) {
81219
81484
  if (currentLine) {
81220
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
81485
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81221
81486
  const completedLine = {
81222
81487
  ...currentLine,
81223
81488
  ...metrics
@@ -81330,7 +81595,7 @@ ${l}
81330
81595
  }
81331
81596
  const appliedTabAlign = lastAppliedTabAlign;
81332
81597
  if (currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
81333
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
81598
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81334
81599
  const completedLine = {
81335
81600
  ...currentLine,
81336
81601
  ...metrics
@@ -81418,6 +81683,7 @@ ${l}
81418
81683
  toChar: wordEndNoSpace,
81419
81684
  width: wordOnlyWidth,
81420
81685
  maxFontSize: run2.fontSize,
81686
+ maxFontInfo: getFontInfoFromRun(run2),
81421
81687
  maxWidth: getEffectiveWidth(initialAvailableWidth),
81422
81688
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
81423
81689
  };
@@ -81434,7 +81700,7 @@ ${l}
81434
81700
  const isTocEntry = block.attrs?.isTocEntry;
81435
81701
  const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
81436
81702
  if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0 && !isTocEntry) {
81437
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
81703
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81438
81704
  const completedLine = {
81439
81705
  ...currentLine,
81440
81706
  ...metrics
@@ -81450,6 +81716,7 @@ ${l}
81450
81716
  toChar: wordEndNoSpace,
81451
81717
  width: wordOnlyWidth,
81452
81718
  maxFontSize: run2.fontSize,
81719
+ maxFontInfo: getFontInfoFromRun(run2),
81453
81720
  maxWidth: getEffectiveWidth(contentWidth),
81454
81721
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
81455
81722
  };
@@ -81465,9 +81732,10 @@ ${l}
81465
81732
  if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
81466
81733
  currentLine.toChar = wordEndNoSpace;
81467
81734
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
81735
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
81468
81736
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
81469
81737
  appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, segmentStartX);
81470
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
81738
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81471
81739
  const completedLine = { ...currentLine, ...metrics };
81472
81740
  addBarTabsToLine(completedLine);
81473
81741
  lines.push(completedLine);
@@ -81484,6 +81752,7 @@ ${l}
81484
81752
  currentLine.width = roundValue(
81485
81753
  currentLine.width + boundarySpacing + wordCommitWidth + (isLastWord ? 0 : run2.letterSpacing ?? 0)
81486
81754
  );
81755
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
81487
81756
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
81488
81757
  appendSegment(currentLine.segments, runIndex, wordStartChar, newToChar, wordCommitWidth, explicitX);
81489
81758
  }
@@ -81506,6 +81775,7 @@ ${l}
81506
81775
  toChar: charPosInRun,
81507
81776
  width: 0,
81508
81777
  maxFontSize: run2.fontSize,
81778
+ maxFontInfo: getFontInfoFromRun(run2),
81509
81779
  maxWidth: getEffectiveWidth(initialAvailableWidth),
81510
81780
  segments: []
81511
81781
  };
@@ -81515,6 +81785,7 @@ ${l}
81515
81785
  tabStopCursor = nextIndex;
81516
81786
  const tabAdvance = Math.max(0, target - currentLine.width);
81517
81787
  currentLine.width = roundValue(currentLine.width + tabAdvance);
81788
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
81518
81789
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
81519
81790
  currentLine.toRun = runIndex;
81520
81791
  currentLine.toChar = charPosInRun;
@@ -81551,7 +81822,7 @@ ${l}
81551
81822
  lines.push(fallbackLine);
81552
81823
  }
81553
81824
  if (currentLine) {
81554
- const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
81825
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81555
81826
  const finalLine = {
81556
81827
  ...currentLine,
81557
81828
  ...metrics
@@ -84962,7 +85233,12 @@ ${l}
84962
85233
  setupInputBridge_fn = function() {
84963
85234
  __privateGet$1(this, _inputBridge)?.destroy();
84964
85235
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
84965
- __privateSet(this, _inputBridge, new PresentationInputBridge(win, __privateGet$1(this, _visibleHost), () => __privateMethod$1(this, _PresentationEditor_instances, getActiveDomTarget_fn).call(this)));
85236
+ __privateSet(this, _inputBridge, new PresentationInputBridge(
85237
+ win,
85238
+ __privateGet$1(this, _visibleHost),
85239
+ () => __privateMethod$1(this, _PresentationEditor_instances, getActiveDomTarget_fn).call(this),
85240
+ () => __privateGet$1(this, _documentMode) !== "viewing"
85241
+ ));
84966
85242
  __privateGet$1(this, _inputBridge).bind();
84967
85243
  };
84968
85244
  initHeaderFooterRegistry_fn = function() {
@@ -85350,6 +85626,10 @@ ${l}
85350
85626
  if (!__privateGet$1(this, _localSelectionLayer)) {
85351
85627
  return;
85352
85628
  }
85629
+ if (__privateGet$1(this, _documentMode) === "viewing") {
85630
+ __privateGet$1(this, _localSelectionLayer).innerHTML = "";
85631
+ return;
85632
+ }
85353
85633
  const layout = __privateGet$1(this, _layoutState).layout;
85354
85634
  const selection = this.getActiveEditor().state?.selection;
85355
85635
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
@@ -86655,11 +86935,27 @@ ${l}
86655
86935
  };
86656
86936
  let PresentationEditor = _PresentationEditor;
86657
86937
  class PresentationInputBridge {
86658
- constructor(windowRoot, layoutSurface, getTargetDom, onTargetChanged, options) {
86938
+ /**
86939
+ * Creates a new PresentationInputBridge that forwards user input events from the visible layout
86940
+ * surface to the hidden editor DOM. This enables input handling when the actual editor is not
86941
+ * directly visible to the user.
86942
+ *
86943
+ * @param windowRoot - The window object containing the layout surface and editor target
86944
+ * @param layoutSurface - The visible HTML element that receives user input events (e.g., keyboard, mouse)
86945
+ * @param getTargetDom - Callback that returns the hidden editor's DOM element where events should be forwarded
86946
+ * @param isEditable - Callback that returns whether the editor is in an editable mode (editing/suggesting).
86947
+ * When this returns false (e.g., in viewing mode), keyboard, text, and composition
86948
+ * events will not be forwarded to prevent document modification.
86949
+ * @param onTargetChanged - Optional callback invoked when the target editor DOM element changes
86950
+ * @param options - Optional configuration including:
86951
+ * - useWindowFallback: Whether to attach window-level event listeners as fallback
86952
+ */
86953
+ constructor(windowRoot, layoutSurface, getTargetDom, isEditable, onTargetChanged, options) {
86659
86954
  __privateAdd$1(this, _PresentationInputBridge_instances);
86660
86955
  __privateAdd$1(this, _windowRoot);
86661
86956
  __privateAdd$1(this, _layoutSurfaces);
86662
86957
  __privateAdd$1(this, _getTargetDom);
86958
+ __privateAdd$1(this, _isEditable);
86663
86959
  __privateAdd$1(this, _onTargetChanged);
86664
86960
  __privateAdd$1(this, _listeners);
86665
86961
  __privateAdd$1(this, _currentTarget, null);
@@ -86668,6 +86964,7 @@ ${l}
86668
86964
  __privateSet(this, _windowRoot, windowRoot);
86669
86965
  __privateSet(this, _layoutSurfaces, /* @__PURE__ */ new Set([layoutSurface]));
86670
86966
  __privateSet(this, _getTargetDom, getTargetDom);
86967
+ __privateSet(this, _isEditable, isEditable);
86671
86968
  __privateSet(this, _onTargetChanged, onTargetChanged);
86672
86969
  __privateSet(this, _listeners, []);
86673
86970
  __privateSet(this, _useWindowFallback, options?.useWindowFallback ?? false);
@@ -86734,6 +87031,7 @@ ${l}
86734
87031
  _windowRoot = /* @__PURE__ */ new WeakMap();
86735
87032
  _layoutSurfaces = /* @__PURE__ */ new WeakMap();
86736
87033
  _getTargetDom = /* @__PURE__ */ new WeakMap();
87034
+ _isEditable = /* @__PURE__ */ new WeakMap();
86737
87035
  _onTargetChanged = /* @__PURE__ */ new WeakMap();
86738
87036
  _listeners = /* @__PURE__ */ new WeakMap();
86739
87037
  _currentTarget = /* @__PURE__ */ new WeakMap();
@@ -86764,6 +87062,9 @@ ${l}
86764
87062
  }
86765
87063
  };
86766
87064
  forwardKeyboardEvent_fn = function(event) {
87065
+ if (!__privateGet$1(this, _isEditable).call(this)) {
87066
+ return;
87067
+ }
86767
87068
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86768
87069
  return;
86769
87070
  }
@@ -86791,6 +87092,9 @@ ${l}
86791
87092
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
86792
87093
  };
86793
87094
  forwardTextEvent_fn = function(event) {
87095
+ if (!__privateGet$1(this, _isEditable).call(this)) {
87096
+ return;
87097
+ }
86794
87098
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86795
87099
  return;
86796
87100
  }
@@ -86821,6 +87125,9 @@ ${l}
86821
87125
  });
86822
87126
  };
86823
87127
  forwardCompositionEvent_fn = function(event) {
87128
+ if (!__privateGet$1(this, _isEditable).call(this)) {
87129
+ return;
87130
+ }
86824
87131
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86825
87132
  return;
86826
87133
  }
@@ -86840,6 +87147,9 @@ ${l}
86840
87147
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
86841
87148
  };
86842
87149
  forwardContextMenu_fn = function(event) {
87150
+ if (!__privateGet$1(this, _isEditable).call(this)) {
87151
+ return;
87152
+ }
86843
87153
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86844
87154
  return;
86845
87155
  }
@@ -139836,7 +140146,7 @@ ${style2}
139836
140146
  this.config.colors = shuffleArray(this.config.colors);
139837
140147
  this.userColorMap = /* @__PURE__ */ new Map();
139838
140148
  this.colorIndex = 0;
139839
- this.version = "1.0.0-beta.21";
140149
+ this.version = "1.0.0-beta.23";
139840
140150
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
139841
140151
  this.superdocId = config2.superdocId || v4();
139842
140152
  this.colors = this.config.colors;
@@ -140247,7 +140557,9 @@ ${style2}
140247
140557
  editing: () => this.#setModeEditing(),
140248
140558
  suggesting: () => this.#setModeSuggesting()
140249
140559
  };
140250
- if (types2[type2]) types2[type2]();
140560
+ if (types2[type2]) {
140561
+ types2[type2]();
140562
+ }
140251
140563
  }
140252
140564
  /**
140253
140565
  * Set the document mode on a document's editor (PresentationEditor or Editor).
@@ -140319,7 +140631,7 @@ ${style2}
140319
140631
  }
140320
140632
  #setModeViewing() {
140321
140633
  this.toolbar.activeEditor = null;
140322
- this.setTrackedChangesPreferences({ mode: "final", enabled: false });
140634
+ this.setTrackedChangesPreferences({ mode: "original", enabled: false });
140323
140635
  this.superdocStore.documents.forEach((doc2) => {
140324
140636
  doc2.removeComments();
140325
140637
  this.#applyDocumentMode(doc2, "viewing");
@@ -142279,7 +142591,7 @@ ${style2}
142279
142591
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
142280
142592
  );
142281
142593
  }
142282
- const indexDSuc12CK = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
142594
+ const indexDYBG7Xab = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
142283
142595
  __proto__: null,
142284
142596
  unified
142285
142597
  }, Symbol.toStringTag, { value: "Module" }));