@harbour-enterprises/superdoc 1.0.0-beta.96 → 1.0.0-beta.98

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 (27) hide show
  1. package/dist/chunks/{PdfViewer-Cdp1WJ9e.es.js → PdfViewer-1_KffD-j.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-BGTfnD4T.cjs → PdfViewer-D1Ot32kX.cjs} +1 -1
  3. package/dist/chunks/{index-BV9YtiyI.es.js → index-CP2_WwLA.es.js} +3 -3
  4. package/dist/chunks/{index-C-IS20yQ.cjs → index-CUO7gEi8.cjs} +3 -3
  5. package/dist/chunks/{index-lfdM_gm7-_EQjLyqH.es.js → index-Dg_sTYZK-D20z8mus.es.js} +1 -1
  6. package/dist/chunks/{index-lfdM_gm7-qtx-V4oF.cjs → index-Dg_sTYZK-DYDzxoXL.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-De2XS3A1.es.js → super-editor.es-3dJOUw65.es.js} +281 -201
  8. package/dist/chunks/{super-editor.es-D2zn943K.cjs → super-editor.es-DN_dgBH0.cjs} +281 -201
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-B29ATZFC.js → converter-Oj-eTB79.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-BPktKUBx.js → docx-zipper-Dl188zQ3.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-BRHMYtPA.js → editor-DBXoaaWP.js} +282 -202
  13. package/dist/super-editor/chunks/{index-lfdM_gm7.js → index-Dg_sTYZK.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-CB2cJCLh.js → toolbar-PlGGj0Ew.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +283 -203
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -12,8 +12,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-B29ATZFC.js";
16
- import { D as DocxZipper } from "./docx-zipper-BPktKUBx.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-Oj-eTB79.js";
16
+ import { D as DocxZipper } from "./docx-zipper-Dl188zQ3.js";
17
17
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
@@ -13952,7 +13952,7 @@ const isHeadless = (editor) => {
13952
13952
  const shouldSkipNodeView = (editor) => {
13953
13953
  return isHeadless(editor);
13954
13954
  };
13955
- const summaryVersion = "1.0.0-beta.96";
13955
+ const summaryVersion = "1.0.0-beta.98";
13956
13956
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
13957
13957
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
13958
13958
  function mapAttributes(attrs) {
@@ -14744,7 +14744,7 @@ const _Editor = class _Editor extends EventEmitter {
14744
14744
  { default: remarkStringify },
14745
14745
  { default: remarkGfm }
14746
14746
  ] = await Promise.all([
14747
- import("./index-lfdM_gm7.js"),
14747
+ import("./index-Dg_sTYZK.js"),
14748
14748
  import("./index-DRCvimau.js"),
14749
14749
  import("./index-C_x_N6Uh.js"),
14750
14750
  import("./index-D_sWOSiG.js"),
@@ -14949,7 +14949,7 @@ const _Editor = class _Editor extends EventEmitter {
14949
14949
  * Process collaboration migrations
14950
14950
  */
14951
14951
  processCollaborationMigrations() {
14952
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.96");
14952
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.98");
14953
14953
  if (!this.options.ydoc) return;
14954
14954
  const metaMap = this.options.ydoc.getMap("meta");
14955
14955
  let docVersion = metaMap.get("version");
@@ -17361,12 +17361,12 @@ var SectionType = /* @__PURE__ */ ((SectionType2) => {
17361
17361
  })(SectionType || {});
17362
17362
  const DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage";
17363
17363
  const DEFAULT_BODY_SECTION_TYPE = "continuous";
17364
- const TWIPS_PER_INCH$3 = 1440;
17365
- const PX_PER_INCH$2 = 96;
17364
+ const TWIPS_PER_INCH$4 = 1440;
17365
+ const PX_PER_INCH$3 = 96;
17366
17366
  const DEFAULT_COLUMN_GAP_INCHES = 0.5;
17367
17367
  function twipsToPixels$1(twips) {
17368
17368
  const n = Number(twips);
17369
- return Number.isFinite(n) ? n / TWIPS_PER_INCH$3 * PX_PER_INCH$2 : void 0;
17369
+ return Number.isFinite(n) ? n / TWIPS_PER_INCH$4 * PX_PER_INCH$3 : void 0;
17370
17370
  }
17371
17371
  function parseColumnCount(rawValue) {
17372
17372
  if (rawValue == null) return 1;
@@ -17376,7 +17376,7 @@ function parseColumnCount(rawValue) {
17376
17376
  function parseColumnGap(gapTwips) {
17377
17377
  if (gapTwips == null) return DEFAULT_COLUMN_GAP_INCHES;
17378
17378
  const gap = Number(gapTwips);
17379
- return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$3 : DEFAULT_COLUMN_GAP_INCHES;
17379
+ return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$4 : DEFAULT_COLUMN_GAP_INCHES;
17380
17380
  }
17381
17381
  function extractNormalizedMargins(attrs) {
17382
17382
  const sectionMargins = attrs.sectionMargins;
@@ -17415,14 +17415,15 @@ function extractPageSizeAndOrientation(elements) {
17415
17415
  return { pageSizePx, orientation };
17416
17416
  }
17417
17417
  function extractFallbackMargins(elements, currentHeader, currentFooter) {
17418
- if (currentHeader !== void 0 && currentFooter !== void 0) {
17419
- return { headerPx: currentHeader, footerPx: currentFooter };
17420
- }
17421
17418
  const pgMar = elements.find((el) => el?.name === "w:pgMar");
17422
17419
  const a = pgMar?.attributes || {};
17423
17420
  return {
17424
17421
  headerPx: currentHeader ?? (a["w:header"] != null ? twipsToPixels$1(a["w:header"]) : void 0),
17425
- footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0)
17422
+ footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0),
17423
+ topPx: a["w:top"] != null ? twipsToPixels$1(a["w:top"]) : void 0,
17424
+ rightPx: a["w:right"] != null ? twipsToPixels$1(a["w:right"]) : void 0,
17425
+ bottomPx: a["w:bottom"] != null ? twipsToPixels$1(a["w:bottom"]) : void 0,
17426
+ leftPx: a["w:left"] != null ? twipsToPixels$1(a["w:left"]) : void 0
17426
17427
  };
17427
17428
  }
17428
17429
  function extractHeaderFooterRefs(elements, refName) {
@@ -17460,7 +17461,7 @@ function extractColumns(elements) {
17460
17461
  const gapInches = parseColumnGap(cols.attributes["w:space"]);
17461
17462
  return {
17462
17463
  count,
17463
- gap: gapInches * PX_PER_INCH$2
17464
+ gap: gapInches * PX_PER_INCH$3
17464
17465
  };
17465
17466
  }
17466
17467
  function extractVerticalAlign(elements) {
@@ -17483,7 +17484,10 @@ function extractSectionData(para) {
17483
17484
  const type = extractSectionType(sectPrElements);
17484
17485
  const { pageSizePx, orientation } = extractPageSizeAndOrientation(sectPrElements);
17485
17486
  const titlePg = sectPrElements.some((el) => el?.name === "w:titlePg");
17486
- ({ headerPx, footerPx } = extractFallbackMargins(sectPrElements, headerPx, footerPx));
17487
+ const fallbackMargins = extractFallbackMargins(sectPrElements, headerPx, footerPx);
17488
+ headerPx = fallbackMargins.headerPx;
17489
+ footerPx = fallbackMargins.footerPx;
17490
+ const { topPx, rightPx, bottomPx, leftPx } = fallbackMargins;
17487
17491
  const headerRefs = extractHeaderFooterRefs(sectPrElements, "w:headerReference");
17488
17492
  const footerRefs = extractHeaderFooterRefs(sectPrElements, "w:footerReference");
17489
17493
  const numbering = extractPageNumbering(sectPrElements);
@@ -17492,6 +17496,10 @@ function extractSectionData(para) {
17492
17496
  return {
17493
17497
  headerPx,
17494
17498
  footerPx,
17499
+ topPx,
17500
+ rightPx,
17501
+ bottomPx,
17502
+ leftPx,
17495
17503
  type,
17496
17504
  pageSizePx,
17497
17505
  orientation,
@@ -17603,7 +17611,14 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
17603
17611
  startParagraphIndex: currentStart,
17604
17612
  endParagraphIndex: item.index,
17605
17613
  sectPr,
17606
- margins: sectionData.headerPx != null || sectionData.footerPx != null ? { header: sectionData.headerPx ?? 0, footer: sectionData.footerPx ?? 0 } : null,
17614
+ margins: sectionData.headerPx != null || sectionData.footerPx != null ? {
17615
+ header: sectionData.headerPx ?? 0,
17616
+ footer: sectionData.footerPx ?? 0,
17617
+ top: sectionData.topPx,
17618
+ right: sectionData.rightPx,
17619
+ bottom: sectionData.bottomPx,
17620
+ left: sectionData.leftPx
17621
+ } : null,
17607
17622
  pageSize: sectionData.pageSizePx ?? null,
17608
17623
  orientation: sectionData.orientation ?? null,
17609
17624
  columns: sectionData.columnsPx ?? null,
@@ -17645,7 +17660,14 @@ function createFinalSectionFromBodySectPr(bodySectPr, currentStart, totalParagra
17645
17660
  startParagraphIndex: currentStart,
17646
17661
  endParagraphIndex: totalParagraphs - 1,
17647
17662
  sectPr: bodySectPr,
17648
- margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? { header: bodySectionData.headerPx ?? 0, footer: bodySectionData.footerPx ?? 0 } : null,
17663
+ margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? {
17664
+ header: bodySectionData.headerPx ?? 0,
17665
+ footer: bodySectionData.footerPx ?? 0,
17666
+ top: bodySectionData.topPx,
17667
+ right: bodySectionData.rightPx,
17668
+ bottom: bodySectionData.bottomPx,
17669
+ left: bodySectionData.leftPx
17670
+ } : null,
17649
17671
  pageSize: bodySectionData.pageSizePx ?? null,
17650
17672
  orientation: bodySectionData.orientation ?? null,
17651
17673
  columns: bodySectionData.columnsPx ?? null,
@@ -17696,8 +17718,8 @@ function analyzeSectionRanges(doc2, bodySectPr) {
17696
17718
  }
17697
17719
  return ranges;
17698
17720
  }
17699
- const TWIPS_PER_INCH$2 = 1440;
17700
- const PX_PER_INCH$1 = 96;
17721
+ const TWIPS_PER_INCH$3 = 1440;
17722
+ const PX_PER_INCH$2 = 96;
17701
17723
  const PX_PER_PT = 96 / 72;
17702
17724
  SectionType.NEXT_PAGE;
17703
17725
  SectionType.CONTINUOUS;
@@ -17836,7 +17858,7 @@ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarks
17836
17858
  }
17837
17859
  return filtered;
17838
17860
  };
17839
- const twipsToPx$1 = (value) => value / TWIPS_PER_INCH$2 * PX_PER_INCH$1;
17861
+ const twipsToPx$2 = (value) => value / TWIPS_PER_INCH$3 * PX_PER_INCH$2;
17840
17862
  const ptToPx = (pt) => {
17841
17863
  if (pt == null || !Number.isFinite(pt)) return void 0;
17842
17864
  return pt * PX_PER_PT;
@@ -19346,8 +19368,8 @@ const normalizeParagraphSpacing = (value) => {
19346
19368
  const beforeAutospacing = toBooleanFlag(source.beforeAutospacing ?? source.beforeAutoSpacing);
19347
19369
  const afterAutospacing = toBooleanFlag(source.afterAutospacing ?? source.afterAutoSpacing);
19348
19370
  const contextualSpacing = toBooleanFlag(source.contextualSpacing);
19349
- const before = beforeRaw != null ? twipsToPx$1(beforeRaw) : pickNumber(source.lineSpaceBefore);
19350
- const after = afterRaw != null ? twipsToPx$1(afterRaw) : pickNumber(source.lineSpaceAfter);
19371
+ const before = beforeRaw != null ? twipsToPx$2(beforeRaw) : pickNumber(source.lineSpaceBefore);
19372
+ const after = afterRaw != null ? twipsToPx$2(afterRaw) : pickNumber(source.lineSpaceAfter);
19351
19373
  const line = normalizeLineValue(lineRaw, lineRule);
19352
19374
  if (before != null) spacing.before = before;
19353
19375
  if (after != null) spacing.after = after;
@@ -19377,9 +19399,9 @@ const normalizeLineValue = (value, lineRule) => {
19377
19399
  if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
19378
19400
  return value;
19379
19401
  }
19380
- return twipsToPx$1(value);
19402
+ return twipsToPx$2(value);
19381
19403
  }
19382
- return twipsToPx$1(value);
19404
+ return twipsToPx$2(value);
19383
19405
  };
19384
19406
  const normalizeLineRule = (value) => {
19385
19407
  if (value === "auto" || value === "exact" || value === "atLeast") {
@@ -19416,7 +19438,7 @@ const normalizeParagraphIndent = (value) => {
19416
19438
  if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
19417
19439
  return num;
19418
19440
  }
19419
- return twipsToPx$1(Number(num));
19441
+ return twipsToPx$2(Number(num));
19420
19442
  };
19421
19443
  const left2 = convert(pickNumber(source.left));
19422
19444
  const right2 = convert(pickNumber(source.right));
@@ -19996,9 +20018,9 @@ const buildFontCss = (run) => {
19996
20018
  const family = run.fontFamily ?? "Times New Roman";
19997
20019
  return `${style}${weight}${size} ${family}`;
19998
20020
  };
19999
- const TWIPS_PER_INCH$1 = 1440;
20021
+ const TWIPS_PER_INCH$2 = 1440;
20000
20022
  const PIXELS_PER_INCH = 96;
20001
- const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$1 / PIXELS_PER_INCH);
20023
+ const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$2 / PIXELS_PER_INCH);
20002
20024
  const PIXELS_PER_TWIP = 1 / TWIPS_PER_PIXEL;
20003
20025
  const toFiniteNumber = (value) => {
20004
20026
  if (value == null) return null;
@@ -21022,7 +21044,7 @@ const extractMarkerRun = (lvl) => {
21022
21044
  }
21023
21045
  const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
21024
21046
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
21025
- run.letterSpacing = twipsToPx$1(spacingTwips);
21047
+ run.letterSpacing = twipsToPx$2(spacingTwips);
21026
21048
  }
21027
21049
  return Object.keys(run).length ? run : void 0;
21028
21050
  };
@@ -21246,10 +21268,19 @@ const buildNumberingPath = (numId, ilvl, counterValue, listCounterContext) => {
21246
21268
  const convertIndentTwipsToPx = (indent) => {
21247
21269
  if (!indent) return void 0;
21248
21270
  const result = {};
21249
- if (isFiniteNumber(indent.left)) result.left = twipsToPx$1(Number(indent.left));
21250
- if (isFiniteNumber(indent.right)) result.right = twipsToPx$1(Number(indent.right));
21251
- if (isFiniteNumber(indent.firstLine)) result.firstLine = twipsToPx$1(Number(indent.firstLine));
21252
- if (isFiniteNumber(indent.hanging)) result.hanging = twipsToPx$1(Number(indent.hanging));
21271
+ const toNum = (v) => {
21272
+ if (typeof v === "string" && v.trim() !== "" && isFinite(Number(v))) return Number(v);
21273
+ if (isFiniteNumber(v)) return Number(v);
21274
+ return void 0;
21275
+ };
21276
+ const left2 = toNum(indent.left);
21277
+ const right2 = toNum(indent.right);
21278
+ const firstLine = toNum(indent.firstLine);
21279
+ const hanging = toNum(indent.hanging);
21280
+ if (left2 != null) result.left = twipsToPx$2(left2);
21281
+ if (right2 != null) result.right = twipsToPx$2(right2);
21282
+ if (firstLine != null) result.firstLine = twipsToPx$2(firstLine);
21283
+ if (hanging != null) result.hanging = twipsToPx$2(hanging);
21253
21284
  return Object.keys(result).length > 0 ? result : void 0;
21254
21285
  };
21255
21286
  const toAdapterNumberingProps = (value) => {
@@ -21274,7 +21305,7 @@ const toResolvedTabStops = (tabs) => {
21274
21305
  if (!stop || typeof stop.pos !== "number") continue;
21275
21306
  const alignment = normalizeResolvedTabAlignment(stop.val);
21276
21307
  if (!alignment) continue;
21277
- const position = twipsToPx$1(stop.pos);
21308
+ const position = twipsToPx$2(stop.pos);
21278
21309
  if (!Number.isFinite(position)) continue;
21279
21310
  const resolvedStop = {
21280
21311
  position,
@@ -21715,9 +21746,9 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
21715
21746
  const vAnchor = asString2(framePr["w:vAnchor"] ?? framePr.vAnchor);
21716
21747
  if (vAnchor) frame.vAnchor = vAnchor;
21717
21748
  const xTwips = pickNumber(framePr["w:x"] ?? framePr.x);
21718
- if (xTwips != null) frame.x = twipsToPx$1(xTwips);
21749
+ if (xTwips != null) frame.x = twipsToPx$2(xTwips);
21719
21750
  const yTwips = pickNumber(framePr["w:y"] ?? framePr.y);
21720
- if (yTwips != null) frame.y = twipsToPx$1(yTwips);
21751
+ if (yTwips != null) frame.y = twipsToPx$2(yTwips);
21721
21752
  if (Object.keys(frame).length > 0) {
21722
21753
  paragraphAttrs.frame = frame;
21723
21754
  }
@@ -21805,7 +21836,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
21805
21836
  }
21806
21837
  }
21807
21838
  }
21808
- const wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
21839
+ let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
21840
+ if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
21841
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
21842
+ const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
21843
+ if (firstLinePx > 0) {
21844
+ wordLayout = {
21845
+ // Treat as first-line-indent mode: text starts after the marker+firstLine offset.
21846
+ firstLineIndentMode: true,
21847
+ textStartPx: firstLinePx
21848
+ };
21849
+ }
21850
+ }
21851
+ if (wordLayout && (!wordLayout.textStartPx || !Number.isFinite(wordLayout.textStartPx)) && enrichedNumberingProps.resolvedLevelIndent) {
21852
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
21853
+ const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
21854
+ if (firstLinePx > 0) {
21855
+ wordLayout = {
21856
+ ...wordLayout,
21857
+ firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
21858
+ textStartPx: firstLinePx
21859
+ };
21860
+ }
21861
+ }
21809
21862
  if (wordLayout) {
21810
21863
  if (wordLayout.marker) {
21811
21864
  if (listRendering?.markerText) {
@@ -23716,7 +23769,7 @@ const measurementToPx = (value) => {
23716
23769
  const entry = value;
23717
23770
  if (typeof entry.value !== "number") return void 0;
23718
23771
  if (!entry.type || entry.type === "px" || entry.type === "pixel") return entry.value;
23719
- if (entry.type === "dxa") return twipsToPx$1(entry.value);
23772
+ if (entry.type === "dxa") return twipsToPx$2(entry.value);
23720
23773
  return void 0;
23721
23774
  };
23722
23775
  const normalizeTableWidth = (value) => {
@@ -23728,7 +23781,7 @@ const normalizeTableWidth = (value) => {
23728
23781
  return { width: raw, type: measurement.type ?? "px" };
23729
23782
  }
23730
23783
  if (measurement.type === "dxa") {
23731
- return { width: twipsToPx$1(raw), type: "px" };
23784
+ return { width: twipsToPx$2(raw), type: "px" };
23732
23785
  }
23733
23786
  return { width: raw, type: measurement.type };
23734
23787
  };
@@ -23756,13 +23809,13 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
23756
23809
  const line = parseIntSafe$1(attrs["w:line"]);
23757
23810
  const rawLineRule = attrs["w:lineRule"];
23758
23811
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
23759
- if (before != null) spacing.before = twipsToPx$1(before);
23760
- if (after != null) spacing.after = twipsToPx$1(after);
23812
+ if (before != null) spacing.before = twipsToPx$2(before);
23813
+ if (after != null) spacing.after = twipsToPx$2(after);
23761
23814
  if (line != null) {
23762
23815
  if (lineRule === "auto") {
23763
23816
  spacing.line = line / 240;
23764
23817
  } else {
23765
- spacing.line = twipsToPx$1(line);
23818
+ spacing.line = twipsToPx$2(line);
23766
23819
  }
23767
23820
  }
23768
23821
  if (lineRule) spacing.lineRule = lineRule;
@@ -23788,7 +23841,7 @@ const normalizeRowHeight = (rowProps) => {
23788
23841
  if (rawValue == null) return void 0;
23789
23842
  const rawRule = heightObj.rule ?? heightObj.hRule;
23790
23843
  const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
23791
- const valuePx = twipsToPx$1(rawValue);
23844
+ const valuePx = twipsToPx$2(rawValue);
23792
23845
  return {
23793
23846
  value: valuePx,
23794
23847
  rule
@@ -23893,41 +23946,6 @@ const parseTableCell = (args) => {
23893
23946
  }
23894
23947
  }
23895
23948
  }
23896
- try {
23897
- const blockSummaries = blocks.map((b) => {
23898
- if (b.kind === "paragraph") {
23899
- const runs = b.runs ?? [];
23900
- const attrs = b.attrs ?? {};
23901
- return {
23902
- kind: "paragraph",
23903
- runKinds: runs.map((r2) => r2.kind ?? "text"),
23904
- runCount: runs.length,
23905
- runPreview: runs.map((r2) => {
23906
- const kind = r2.kind ?? "text";
23907
- if (kind === "image") {
23908
- const img = r2;
23909
- return { kind, src: img.src, width: img.width, height: img.height };
23910
- }
23911
- return { kind };
23912
- }),
23913
- hasNumbering: Boolean(attrs.numberingProperties),
23914
- markerText: attrs.wordLayout?.marker?.markerText
23915
- };
23916
- }
23917
- return { kind: b.kind };
23918
- });
23919
- console.log(
23920
- "[tableNodeToBlock.parseTableCell] cell contents",
23921
- JSON.stringify({
23922
- cellIndex,
23923
- rowIndex,
23924
- cellIdPreview: `cell-${rowIndex}-${cellIndex}`,
23925
- childTypes: cellNode.content.map((c) => c?.type),
23926
- blocks: blockSummaries
23927
- })
23928
- );
23929
- } catch {
23930
- }
23931
23949
  if (blocks.length === 0) {
23932
23950
  return null;
23933
23951
  }
@@ -24038,10 +24056,10 @@ function extractFloatingTableAnchorWrap(node) {
24038
24056
  anchor.alignV = floatingProps.tblpYSpec;
24039
24057
  }
24040
24058
  if (floatingProps.tblpX !== void 0) {
24041
- anchor.offsetH = twipsToPx$1(floatingProps.tblpX);
24059
+ anchor.offsetH = twipsToPx$2(floatingProps.tblpX);
24042
24060
  }
24043
24061
  if (floatingProps.tblpY !== void 0) {
24044
- anchor.offsetV = twipsToPx$1(floatingProps.tblpY);
24062
+ anchor.offsetV = twipsToPx$2(floatingProps.tblpY);
24045
24063
  }
24046
24064
  const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
24047
24065
  const wrap = {
@@ -24052,16 +24070,16 @@ function extractFloatingTableAnchorWrap(node) {
24052
24070
  };
24053
24071
  if (hasDistances) {
24054
24072
  if (floatingProps.topFromText !== void 0) {
24055
- wrap.distTop = twipsToPx$1(floatingProps.topFromText);
24073
+ wrap.distTop = twipsToPx$2(floatingProps.topFromText);
24056
24074
  }
24057
24075
  if (floatingProps.bottomFromText !== void 0) {
24058
- wrap.distBottom = twipsToPx$1(floatingProps.bottomFromText);
24076
+ wrap.distBottom = twipsToPx$2(floatingProps.bottomFromText);
24059
24077
  }
24060
24078
  if (floatingProps.leftFromText !== void 0) {
24061
- wrap.distLeft = twipsToPx$1(floatingProps.leftFromText);
24079
+ wrap.distLeft = twipsToPx$2(floatingProps.leftFromText);
24062
24080
  }
24063
24081
  if (floatingProps.rightFromText !== void 0) {
24064
- wrap.distRight = twipsToPx$1(floatingProps.rightFromText);
24082
+ wrap.distRight = twipsToPx$2(floatingProps.rightFromText);
24065
24083
  }
24066
24084
  }
24067
24085
  return { anchor, wrap };
@@ -27792,20 +27810,6 @@ const renderTableCell = (deps) => {
27792
27810
  }
27793
27811
  const cellBlocks = cell?.blocks ?? (cell?.paragraph ? [cell.paragraph] : []);
27794
27812
  const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
27795
- try {
27796
- console.log(
27797
- "[DomPainter.renderTableCell] cell render input",
27798
- JSON.stringify({
27799
- cellId: cell?.id,
27800
- blockKinds: cellBlocks.map((b) => b.kind),
27801
- measureKinds: blockMeasures.map((m) => m.kind),
27802
- width: cellMeasure?.width,
27803
- height: cellMeasure?.height,
27804
- rowHeight
27805
- })
27806
- );
27807
- } catch {
27808
- }
27809
27813
  if (cellBlocks.length > 0 && blockMeasures.length > 0) {
27810
27814
  const content = doc2.createElement("div");
27811
27815
  content.style.position = "relative";
@@ -27838,15 +27842,6 @@ const renderTableCell = (deps) => {
27838
27842
  const blockMeasure = blockMeasures[i];
27839
27843
  const block = cellBlocks[i];
27840
27844
  if (blockMeasure.kind === "image" && block?.kind === "image") {
27841
- console.log(
27842
- "[DomPainter.renderTableCell] rendering image block in cell",
27843
- JSON.stringify({
27844
- cellId: cell?.id,
27845
- blockId: block.id,
27846
- width: blockMeasure.width,
27847
- height: blockMeasure.height
27848
- })
27849
- );
27850
27845
  const imageWrapper = doc2.createElement("div");
27851
27846
  imageWrapper.style.position = "relative";
27852
27847
  imageWrapper.style.width = `${blockMeasure.width}px`;
@@ -27869,16 +27864,6 @@ const renderTableCell = (deps) => {
27869
27864
  continue;
27870
27865
  }
27871
27866
  if (blockMeasure.kind === "drawing" && block?.kind === "drawing") {
27872
- console.log(
27873
- "[DomPainter.renderTableCell] rendering drawing block in cell",
27874
- JSON.stringify({
27875
- cellId: cell?.id,
27876
- blockId: block.id,
27877
- drawingKind: block.drawingKind,
27878
- width: blockMeasure.width,
27879
- height: blockMeasure.height
27880
- })
27881
- );
27882
27867
  const drawingWrapper = doc2.createElement("div");
27883
27868
  drawingWrapper.style.position = "relative";
27884
27869
  drawingWrapper.style.width = `${blockMeasure.width}px`;
@@ -27921,20 +27906,6 @@ const renderTableCell = (deps) => {
27921
27906
  continue;
27922
27907
  }
27923
27908
  if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
27924
- try {
27925
- const runKinds = (block.runs ?? []).map((r2) => r2.kind ?? "text");
27926
- const imageRuns = (block.runs ?? []).filter((r2) => r2.kind === "image").map((r2) => ({ src: r2.src }));
27927
- console.log(
27928
- "[DomPainter.renderTableCell] rendering paragraph block in cell",
27929
- JSON.stringify({
27930
- cellId: cell?.id,
27931
- blockId: block.id,
27932
- runKinds,
27933
- imageRuns
27934
- })
27935
- );
27936
- } catch {
27937
- }
27938
27909
  const paragraphMeasure = blockMeasure;
27939
27910
  const lines = paragraphMeasure.lines;
27940
27911
  const blockLineCount = lines?.length || 0;
@@ -29749,7 +29720,9 @@ const _DomPainter = class _DomPainter {
29749
29720
  const isTocEntry = block.attrs?.isTocEntry;
29750
29721
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
29751
29722
  const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
29752
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
29723
+ const paraIndentForOverflow = block.attrs?.indent;
29724
+ const hasNegativeIndent = (paraIndentForOverflow?.left ?? 0) < 0 || (paraIndentForOverflow?.right ?? 0) < 0;
29725
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer || hasNegativeIndent ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
29753
29726
  applyStyles$2(fragmentEl, styles);
29754
29727
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
29755
29728
  if (isTocEntry) {
@@ -29778,6 +29751,8 @@ const _DomPainter = class _DomPainter {
29778
29751
  }
29779
29752
  if (fragmentEl.style.paddingLeft) fragmentEl.style.removeProperty("padding-left");
29780
29753
  if (fragmentEl.style.paddingRight) fragmentEl.style.removeProperty("padding-right");
29754
+ if (fragmentEl.style.marginLeft) fragmentEl.style.removeProperty("margin-left");
29755
+ if (fragmentEl.style.marginRight) fragmentEl.style.removeProperty("margin-right");
29781
29756
  if (fragmentEl.style.textIndent) fragmentEl.style.removeProperty("text-indent");
29782
29757
  const paraIndent = block.attrs?.indent;
29783
29758
  const paraIndentLeft = paraIndent?.left ?? 0;
@@ -29806,16 +29781,22 @@ const _DomPainter = class _DomPainter {
29806
29781
  if (!isListFirstLine) {
29807
29782
  if (hasExplicitSegmentPositioning) {
29808
29783
  if (isFirstLine && firstLineOffset !== 0) {
29809
- const adjustedPadding = paraIndentLeft + firstLineOffset;
29810
- lineEl.style.paddingLeft = `${adjustedPadding}px`;
29784
+ const effectiveLeftIndent = paraIndentLeft < 0 ? 0 : paraIndentLeft;
29785
+ const adjustedPadding = effectiveLeftIndent + firstLineOffset;
29786
+ if (adjustedPadding > 0) {
29787
+ lineEl.style.paddingLeft = `${adjustedPadding}px`;
29788
+ }
29811
29789
  }
29812
- } else if (paraIndentLeft) {
29790
+ } else if (paraIndentLeft && paraIndentLeft > 0) {
29813
29791
  lineEl.style.paddingLeft = `${paraIndentLeft}px`;
29792
+ } else if (!isFirstLine && paraIndent?.hanging && paraIndent.hanging > 0) {
29793
+ lineEl.style.paddingLeft = `${paraIndent.hanging}px`;
29814
29794
  }
29815
29795
  }
29816
- if (paraIndentRight) {
29796
+ if (paraIndentRight && paraIndentRight > 0) {
29817
29797
  lineEl.style.paddingRight = `${paraIndentRight}px`;
29818
29798
  }
29799
+ const hasNegativeLeftIndent = paraIndentLeft != null && paraIndentLeft < 0;
29819
29800
  if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
29820
29801
  if (!hasExplicitSegmentPositioning) {
29821
29802
  lineEl.style.textIndent = `${firstLineOffset}px`;
@@ -31234,7 +31215,7 @@ const _DomPainter = class _DomPainter {
31234
31215
  }
31235
31216
  const runsForLine = sliceRunsForLine(block, line);
31236
31217
  const trackedConfig = this.resolveTrackedChangesConfig(block);
31237
- const textSlices = runsForLine.length > 0 ? runsForLine.filter((r2) => (r2.kind === "text" || r2.kind === void 0) && "text" in r2 && r2.text != null).map((r2) => r2.text) : gatherTextSlicesForLine(block, line);
31218
+ runsForLine.length > 0 ? runsForLine.filter((r2) => (r2.kind === "text" || r2.kind === void 0) && "text" in r2 && r2.text != null).map((r2) => r2.text) : gatherTextSlicesForLine(block, line);
31238
31219
  if (runsForLine.length === 0) {
31239
31220
  const span = this.doc.createElement("span");
31240
31221
  span.innerHTML = "&nbsp;";
@@ -31281,19 +31262,7 @@ const _DomPainter = class _DomPainter {
31281
31262
  });
31282
31263
  }
31283
31264
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
31284
- const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
31285
- const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
31286
- if (shouldJustify) {
31287
- const spaceCount = textSlices.reduce(
31288
- (sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
31289
- 0
31290
- );
31291
- const slack = availableWidth - line.width;
31292
- if (spaceCount > 0 && slack !== 0) {
31293
- const spacingPerSpace = slack / spaceCount;
31294
- el.style.wordSpacing = `${spacingPerSpace}px`;
31295
- }
31296
- }
31265
+ availableWidthOverride ?? line.maxWidth ?? line.width;
31297
31266
  if (hasExplicitPositioning && line.segments) {
31298
31267
  const paraIndent = block.attrs?.indent;
31299
31268
  const indentLeft = paraIndent?.left ?? 0;
@@ -32112,15 +32081,18 @@ const applyParagraphBlockStyles = (element, attrs) => {
32112
32081
  }
32113
32082
  const indent = attrs.indent;
32114
32083
  if (indent) {
32115
- if (indent.left) {
32084
+ if (indent.left && indent.left > 0) {
32116
32085
  element.style.paddingLeft = `${indent.left}px`;
32117
32086
  }
32118
- if (indent.right) {
32087
+ if (indent.right && indent.right > 0) {
32119
32088
  element.style.paddingRight = `${indent.right}px`;
32120
32089
  }
32121
- const textIndent = (indent.firstLine ?? 0) - (indent.hanging ?? 0);
32122
- if (textIndent) {
32123
- element.style.textIndent = `${textIndent}px`;
32090
+ const hasNegativeLeftIndent = indent.left != null && indent.left < 0;
32091
+ if (!hasNegativeLeftIndent) {
32092
+ const textIndent = (indent.firstLine ?? 0) - (indent.hanging ?? 0);
32093
+ if (textIndent) {
32094
+ element.style.textIndent = `${textIndent}px`;
32095
+ }
32124
32096
  }
32125
32097
  }
32126
32098
  applyParagraphBorderStyles(element, attrs.borders);
@@ -33482,20 +33454,6 @@ const asSafeNumber = (value) => {
33482
33454
  }
33483
33455
  return value;
33484
33456
  };
33485
- function calculateFirstLineIndent(block, measure) {
33486
- const wordLayout = block.attrs?.wordLayout;
33487
- if (!wordLayout?.firstLineIndentMode) {
33488
- return 0;
33489
- }
33490
- if (!wordLayout.marker || !measure.marker) {
33491
- return 0;
33492
- }
33493
- const markerWidthRaw = measure.marker.markerWidth ?? wordLayout.marker.markerBoxWidthPx ?? 0;
33494
- const markerWidth = Number.isFinite(markerWidthRaw) && markerWidthRaw >= 0 ? markerWidthRaw : 0;
33495
- const gutterWidthRaw = measure.marker.gutterWidth ?? 0;
33496
- const gutterWidth = Number.isFinite(gutterWidthRaw) && gutterWidthRaw >= 0 ? gutterWidthRaw : 0;
33497
- return markerWidth + gutterWidth;
33498
- }
33499
33457
  function layoutParagraphBlock(ctx2, anchors) {
33500
33458
  const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx2;
33501
33459
  const remeasureParagraph2 = ctx2.remeasureParagraph;
@@ -33617,10 +33575,25 @@ function layoutParagraphBlock(ctx2, anchors) {
33617
33575
  }
33618
33576
  let lines = normalizeLines(measure);
33619
33577
  const measurementWidth = lines[0]?.maxWidth;
33578
+ const paraIndent = block.attrs?.indent;
33579
+ const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
33580
+ const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
33581
+ const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
33582
+ const negativeRightIndent = indentRight < 0 ? indentRight : 0;
33583
+ const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
33620
33584
  let didRemeasureForColumnWidth = false;
33621
- if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > columnWidth) {
33622
- const firstLineIndent = calculateFirstLineIndent(block, measure);
33623
- const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
33585
+ if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
33586
+ let firstLineIndent = 0;
33587
+ const wordLayout = block.attrs?.wordLayout;
33588
+ if (wordLayout?.marker && measure.marker) {
33589
+ const markerJustification = wordLayout.marker.justification ?? "left";
33590
+ if (markerJustification === "left") {
33591
+ const markerWidth = measure.marker.markerWidth ?? 0;
33592
+ const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
33593
+ firstLineIndent = markerWidth + gutterWidth;
33594
+ }
33595
+ }
33596
+ const newMeasure = remeasureParagraph2(block, remeasureWidth, firstLineIndent);
33624
33597
  lines = normalizeLines(newMeasure);
33625
33598
  didRemeasureForColumnWidth = true;
33626
33599
  }
@@ -33699,9 +33672,19 @@ function layoutParagraphBlock(ctx2, anchors) {
33699
33672
  }
33700
33673
  tempY += lineHeight;
33701
33674
  }
33702
- if (narrowestWidth < columnWidth) {
33703
- const firstLineIndent = calculateFirstLineIndent(block, measure);
33704
- const newMeasure = remeasureParagraph2(block, narrowestWidth, firstLineIndent);
33675
+ const narrowestRemeasureWidth = Math.max(1, narrowestWidth - indentLeft - indentRight);
33676
+ if (narrowestRemeasureWidth < remeasureWidth) {
33677
+ let firstLineIndent = 0;
33678
+ const wordLayout = block.attrs?.wordLayout;
33679
+ if (wordLayout?.marker && measure.marker) {
33680
+ const markerJustification = wordLayout.marker.justification ?? "left";
33681
+ if (markerJustification === "left") {
33682
+ const markerWidth = measure.marker.markerWidth ?? 0;
33683
+ const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
33684
+ firstLineIndent = markerWidth + gutterWidth;
33685
+ }
33686
+ }
33687
+ const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
33705
33688
  lines = normalizeLines(newMeasure);
33706
33689
  didRemeasureForFloats = true;
33707
33690
  }
@@ -33755,14 +33738,16 @@ function layoutParagraphBlock(ctx2, anchors) {
33755
33738
  }
33756
33739
  const slice2 = sliceLines(lines, fromLine, state.contentBottom - state.cursorY);
33757
33740
  const fragmentHeight = slice2.height;
33741
+ const adjustedX = columnX(state.columnIndex) + offsetX + negativeLeftIndent;
33742
+ const adjustedWidth = effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
33758
33743
  const fragment = {
33759
33744
  kind: "para",
33760
33745
  blockId: block.id,
33761
33746
  fromLine,
33762
33747
  toLine: slice2.toLine,
33763
- x: columnX(state.columnIndex) + offsetX,
33748
+ x: adjustedX,
33764
33749
  y: state.cursorY,
33765
- width: effectiveColumnWidth,
33750
+ width: adjustedWidth,
33766
33751
  ...computeFragmentPmRange(block, lines, fromLine, slice2.toLine)
33767
33752
  };
33768
33753
  if (didRemeasureForColumnWidth) {
@@ -36615,7 +36600,13 @@ function getCtx() {
36615
36600
  return ctx;
36616
36601
  }
36617
36602
  function isTextRun(run) {
36618
- return run.kind === "tab" ? false : true;
36603
+ if (run.kind === "tab" || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation") {
36604
+ return false;
36605
+ }
36606
+ if ("src" in run) {
36607
+ return false;
36608
+ }
36609
+ return true;
36619
36610
  }
36620
36611
  function fontString(run) {
36621
36612
  const textRun = isTextRun(run) ? run : null;
@@ -36628,6 +36619,42 @@ function fontString(run) {
36628
36619
  function runText(run) {
36629
36620
  return "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
36630
36621
  }
36622
+ const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
36623
+ const TWIPS_PER_INCH$1 = 1440;
36624
+ const PX_PER_INCH$1 = 96;
36625
+ const TWIPS_PER_PX$1 = TWIPS_PER_INCH$1 / PX_PER_INCH$1;
36626
+ const TAB_EPSILON$1 = 0.1;
36627
+ const WIDTH_FUDGE_PX = 0.5;
36628
+ const twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$1;
36629
+ const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
36630
+ const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
36631
+ const paragraphIndentTwips = {
36632
+ left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
36633
+ right: pxToTwips$1(Math.max(0, indent?.right ?? 0)),
36634
+ firstLine: pxToTwips$1(Math.max(0, indent?.firstLine ?? 0)),
36635
+ hanging: pxToTwips$1(Math.max(0, indent?.hanging ?? 0))
36636
+ };
36637
+ const stops = computeTabStops$1({
36638
+ explicitStops: tabs ?? [],
36639
+ defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
36640
+ paragraphIndent: paragraphIndentTwips
36641
+ });
36642
+ return stops.map((stop) => ({
36643
+ pos: twipsToPx$1(stop.pos),
36644
+ val: stop.val,
36645
+ leader: stop.leader
36646
+ }));
36647
+ };
36648
+ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
36649
+ let index2 = startIndex;
36650
+ while (index2 < tabStops.length && tabStops[index2].pos <= currentX + TAB_EPSILON$1) {
36651
+ index2 += 1;
36652
+ }
36653
+ if (index2 < tabStops.length) {
36654
+ return { target: tabStops[index2].pos, nextIndex: index2 + 1 };
36655
+ }
36656
+ return { target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1), nextIndex: index2 };
36657
+ };
36631
36658
  function measureRunSliceWidth(run, fromChar, toChar) {
36632
36659
  const context = getCtx();
36633
36660
  const text = runText(run).slice(fromChar, toChar);
@@ -36651,13 +36678,38 @@ function lineHeightForRuns(runs, fromRun, toRun) {
36651
36678
  return maxSize2 * 1.2;
36652
36679
  }
36653
36680
  function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
36681
+ if (!Number.isFinite(maxWidth) || maxWidth <= 0) {
36682
+ throw new Error(`remeasureParagraph: maxWidth must be a positive number, got ${maxWidth}`);
36683
+ }
36684
+ if (!Number.isFinite(firstLineIndent)) {
36685
+ throw new Error(`remeasureParagraph: firstLineIndent must be a finite number, got ${firstLineIndent}`);
36686
+ }
36687
+ if (!block) {
36688
+ throw new Error("remeasureParagraph: block must be defined");
36689
+ }
36690
+ if (!Array.isArray(block.runs)) {
36691
+ throw new Error(`remeasureParagraph: block.runs must be an array, got ${typeof block.runs}`);
36692
+ }
36654
36693
  const runs = block.runs ?? [];
36655
36694
  const lines = [];
36695
+ const attrs = block.attrs;
36696
+ const indent = attrs?.indent;
36697
+ const wordLayout = attrs?.wordLayout;
36698
+ const indentLeft = Math.max(0, indent?.left ?? 0);
36699
+ const indentRight = Math.max(0, indent?.right ?? 0);
36700
+ const indentFirstLine = Math.max(0, indent?.firstLine ?? 0);
36701
+ const indentHanging = Math.max(0, indent?.hanging ?? 0);
36702
+ const rawFirstLineOffset = Math.max(0, firstLineIndent || indentFirstLine - indentHanging);
36703
+ const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
36704
+ const textStartPx = wordLayout?.textStartPx;
36705
+ const treatAsHanging = textStartPx && indentLeft === 0 && indentHanging === 0;
36706
+ const firstLineWidth = typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - textStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
36707
+ const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
36656
36708
  let currentRun = 0;
36657
36709
  let currentChar = 0;
36658
36710
  while (currentRun < runs.length) {
36659
36711
  const isFirstLine = lines.length === 0;
36660
- const effectiveMaxWidth = isFirstLine ? maxWidth - firstLineIndent : maxWidth;
36712
+ const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
36661
36713
  const startRun = currentRun;
36662
36714
  const startChar = currentChar;
36663
36715
  let width = 0;
@@ -36665,13 +36717,26 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
36665
36717
  let lastBreakChar = -1;
36666
36718
  let endRun = currentRun;
36667
36719
  let endChar = currentChar;
36720
+ let tabStopCursor = 0;
36721
+ let didBreakInThisLine = false;
36668
36722
  for (let r2 = currentRun; r2 < runs.length; r2 += 1) {
36669
36723
  const run = runs[r2];
36724
+ if (run.kind === "tab") {
36725
+ const { target, nextIndex } = getNextTabStopPx$1(width, tabStops, tabStopCursor);
36726
+ const tabAdvance = Math.max(0, target - width);
36727
+ width += tabAdvance;
36728
+ tabStopCursor = nextIndex;
36729
+ endRun = r2;
36730
+ endChar = 1;
36731
+ lastBreakRun = r2;
36732
+ lastBreakChar = 1;
36733
+ continue;
36734
+ }
36670
36735
  const text = runText(run);
36671
36736
  const start2 = r2 === currentRun ? currentChar : 0;
36672
36737
  for (let c = start2; c < text.length; c += 1) {
36673
36738
  const w = measureRunSliceWidth(run, c, c + 1);
36674
- if (width + w > effectiveMaxWidth && width > 0) {
36739
+ if (width + w > effectiveMaxWidth - WIDTH_FUDGE_PX && width > 0) {
36675
36740
  if (lastBreakRun >= 0) {
36676
36741
  endRun = lastBreakRun;
36677
36742
  endChar = lastBreakChar;
@@ -36679,6 +36744,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
36679
36744
  endRun = r2;
36680
36745
  endChar = c;
36681
36746
  }
36747
+ didBreakInThisLine = true;
36682
36748
  break;
36683
36749
  }
36684
36750
  width += w;
@@ -36690,9 +36756,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
36690
36756
  lastBreakChar = c + 1;
36691
36757
  }
36692
36758
  }
36693
- if (endRun !== r2 || endRun === r2 && (r2 === lastBreakRun ? endChar === lastBreakChar : false)) {
36694
- break;
36695
- }
36759
+ if (didBreakInThisLine) break;
36696
36760
  }
36697
36761
  if (startRun === endRun && startChar === endChar) {
36698
36762
  endRun = startRun;
@@ -36706,11 +36770,15 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
36706
36770
  width,
36707
36771
  ascent: 0,
36708
36772
  descent: 0,
36709
- lineHeight: lineHeightForRuns(runs, startRun, endRun)
36773
+ lineHeight: lineHeightForRuns(runs, startRun, endRun),
36774
+ maxWidth: effectiveMaxWidth
36710
36775
  };
36711
36776
  lines.push(line);
36712
36777
  currentRun = endRun;
36713
36778
  currentChar = endChar;
36779
+ if (currentRun >= runs.length) {
36780
+ break;
36781
+ }
36714
36782
  if (currentChar >= runText(runs[currentRun]).length) {
36715
36783
  currentRun += 1;
36716
36784
  currentChar = 0;
@@ -37387,9 +37455,15 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
37387
37455
  }
37388
37456
  const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
37389
37457
  const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
37458
+ const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
37390
37459
  function resolveMeasurementConstraints(options) {
37391
37460
  const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
37392
- const margins = options.margins ?? DEFAULT_MARGINS$1;
37461
+ const margins = {
37462
+ top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
37463
+ right: normalizeMargin(options.margins?.right, DEFAULT_MARGINS$1.right),
37464
+ bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
37465
+ left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
37466
+ };
37393
37467
  const contentWidth = pageSize.w - (margins.left + margins.right);
37394
37468
  const contentHeight = pageSize.h - (margins.top + margins.bottom);
37395
37469
  const columns = options.columns;
@@ -38923,12 +38997,12 @@ async function measureBlock(block, constraints) {
38923
38997
  async function measureParagraphBlock(block, maxWidth) {
38924
38998
  const ctx2 = getCanvasContext();
38925
38999
  const wordLayout = block.attrs?.wordLayout;
38926
- const WIDTH_FUDGE_PX = 0.5;
39000
+ const WIDTH_FUDGE_PX2 = 0.5;
38927
39001
  const lines = [];
38928
39002
  const indent = block.attrs?.indent;
38929
39003
  const spacing = block.attrs?.spacing;
38930
- const indentLeft = sanitizePositive(indent?.left);
38931
- const indentRight = sanitizePositive(indent?.right);
39004
+ const indentLeft = sanitizeIndent(indent?.left);
39005
+ const indentRight = sanitizeIndent(indent?.right);
38932
39006
  const firstLine = indent?.firstLine ?? 0;
38933
39007
  const hanging = indent?.hanging ?? 0;
38934
39008
  const isWordLayoutList = Boolean(wordLayout?.marker);
@@ -38937,6 +39011,7 @@ async function measureParagraphBlock(block, maxWidth) {
38937
39011
  const clampedFirstLineOffset = Math.max(0, rawFirstLineOffset);
38938
39012
  const firstLineOffset = isWordLayoutList ? 0 : clampedFirstLineOffset;
38939
39013
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
39014
+ const bodyContentWidth = contentWidth;
38940
39015
  let initialAvailableWidth;
38941
39016
  const textStartPx = wordLayout?.textStartPx;
38942
39017
  if (typeof textStartPx === "number" && textStartPx > indentLeft) {
@@ -39131,7 +39206,7 @@ async function measureParagraphBlock(block, maxWidth) {
39131
39206
  lines.push(emptyLine);
39132
39207
  }
39133
39208
  const hadPreviousLine = lines.length > 0;
39134
- const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(contentWidth) : getEffectiveWidth(initialAvailableWidth);
39209
+ const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(bodyContentWidth) : getEffectiveWidth(initialAvailableWidth);
39135
39210
  currentLine = {
39136
39211
  fromRun: runIndex,
39137
39212
  fromChar: 0,
@@ -39242,7 +39317,7 @@ async function measureParagraphBlock(block, maxWidth) {
39242
39317
  toChar: 1,
39243
39318
  width: imageWidth,
39244
39319
  maxFontSize: imageHeight,
39245
- maxWidth: getEffectiveWidth(contentWidth),
39320
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39246
39321
  spaceCount: 0,
39247
39322
  segments: [
39248
39323
  {
@@ -39331,7 +39406,7 @@ async function measureParagraphBlock(block, maxWidth) {
39331
39406
  toChar: 1,
39332
39407
  width: annotationWidth,
39333
39408
  maxFontSize: annotationHeight,
39334
- maxWidth: getEffectiveWidth(contentWidth),
39409
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39335
39410
  spaceCount: 0,
39336
39411
  segments: [
39337
39412
  {
@@ -39393,7 +39468,7 @@ async function measureParagraphBlock(block, maxWidth) {
39393
39468
  };
39394
39469
  } else {
39395
39470
  const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
39396
- if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
39471
+ if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
39397
39472
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39398
39473
  const { spaceCount: _sc, ...lineBase } = currentLine;
39399
39474
  const completedLine = {
@@ -39413,7 +39488,7 @@ async function measureParagraphBlock(block, maxWidth) {
39413
39488
  width: spacesWidth,
39414
39489
  maxFontSize: run.fontSize,
39415
39490
  maxFontInfo: getFontInfoFromRun(run),
39416
- maxWidth: getEffectiveWidth(contentWidth),
39491
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39417
39492
  segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }],
39418
39493
  spaceCount: spacesLength
39419
39494
  };
@@ -39459,7 +39534,7 @@ async function measureParagraphBlock(block, maxWidth) {
39459
39534
  };
39460
39535
  } else {
39461
39536
  const boundarySpacing2 = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
39462
- if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
39537
+ if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
39463
39538
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39464
39539
  const { spaceCount: _sc, ...lineBase } = currentLine;
39465
39540
  const completedLine = { ...lineBase, ...metrics };
@@ -39476,7 +39551,7 @@ async function measureParagraphBlock(block, maxWidth) {
39476
39551
  width: singleSpaceWidth,
39477
39552
  maxFontSize: run.fontSize,
39478
39553
  maxFontInfo: getFontInfoFromRun(run),
39479
- maxWidth: getEffectiveWidth(contentWidth),
39554
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39480
39555
  segments: [{ runIndex, fromChar: spaceStartChar, toChar: spaceEndChar, width: singleSpaceWidth }],
39481
39556
  spaceCount: 1
39482
39557
  };
@@ -39517,7 +39592,7 @@ async function measureParagraphBlock(block, maxWidth) {
39517
39592
  const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
39518
39593
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
39519
39594
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
39520
- const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run);
39595
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run);
39521
39596
  let chunkCharOffset = wordStartChar;
39522
39597
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
39523
39598
  const chunk = chunks[chunkIndex];
@@ -39539,7 +39614,7 @@ async function measureParagraphBlock(block, maxWidth) {
39539
39614
  });
39540
39615
  if (isLastChunk) {
39541
39616
  const ls = run.letterSpacing ?? 0;
39542
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39617
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
39543
39618
  currentLine.toChar = wordEndWithSpace;
39544
39619
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
39545
39620
  charPosInRun = wordEndWithSpace;
@@ -39571,7 +39646,7 @@ async function measureParagraphBlock(block, maxWidth) {
39571
39646
  spaceCount: 0
39572
39647
  };
39573
39648
  const ls = run.letterSpacing ?? 0;
39574
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39649
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
39575
39650
  currentLine.toChar = wordEndWithSpace;
39576
39651
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
39577
39652
  charPosInRun = wordEndWithSpace;
@@ -39613,7 +39688,7 @@ async function measureParagraphBlock(block, maxWidth) {
39613
39688
  spaceCount: 0
39614
39689
  };
39615
39690
  const ls = run.letterSpacing ?? 0;
39616
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39691
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
39617
39692
  currentLine.toChar = wordEndWithSpace;
39618
39693
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
39619
39694
  charPosInRun = wordEndWithSpace;
@@ -39628,7 +39703,7 @@ async function measureParagraphBlock(block, maxWidth) {
39628
39703
  const justifyAlignment = block.attrs?.alignment === "justify";
39629
39704
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
39630
39705
  (isLastWord ? 0 : run.letterSpacing ?? 0);
39631
- const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX;
39706
+ const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
39632
39707
  let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
39633
39708
  let compressedWidth = null;
39634
39709
  if (shouldBreak && justifyAlignment) {
@@ -39669,11 +39744,11 @@ async function measureParagraphBlock(block, maxWidth) {
39669
39744
  width: wordOnlyWidth,
39670
39745
  maxFontSize: run.fontSize,
39671
39746
  maxFontInfo: getFontInfoFromRun(run),
39672
- maxWidth: getEffectiveWidth(contentWidth),
39747
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39673
39748
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
39674
39749
  spaceCount: 0
39675
39750
  };
39676
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39751
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
39677
39752
  currentLine.toChar = wordEndWithSpace;
39678
39753
  currentLine.width = roundValue(currentLine.width + spaceWidth + (run.letterSpacing ?? 0));
39679
39754
  charPosInRun = wordEndWithSpace;
@@ -39683,7 +39758,7 @@ async function measureParagraphBlock(block, maxWidth) {
39683
39758
  }
39684
39759
  } else {
39685
39760
  currentLine.toRun = runIndex;
39686
- if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
39761
+ if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2) {
39687
39762
  currentLine.toChar = wordEndNoSpace;
39688
39763
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
39689
39764
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
@@ -40234,6 +40309,7 @@ const resolveLineHeight = (spacing, baseLineHeight) => {
40234
40309
  return Math.max(baseLineHeight, raw);
40235
40310
  };
40236
40311
  const sanitizePositive = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
40312
+ const sanitizeIndent = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
40237
40313
  const sanitizeDecimalSeparator = (value) => {
40238
40314
  if (value === ",") return ",";
40239
40315
  return DEFAULT_DECIMAL_SEPARATOR;
@@ -45391,6 +45467,10 @@ resolveLayoutOptions_fn = function(blocks, sectionMetadata) {
45391
45467
  const pageSize = firstSection?.pageSize ?? defaults.pageSize;
45392
45468
  const margins = {
45393
45469
  ...defaults.margins,
45470
+ ...firstSection?.margins?.top != null ? { top: firstSection.margins.top } : {},
45471
+ ...firstSection?.margins?.right != null ? { right: firstSection.margins.right } : {},
45472
+ ...firstSection?.margins?.bottom != null ? { bottom: firstSection.margins.bottom } : {},
45473
+ ...firstSection?.margins?.left != null ? { left: firstSection.margins.left } : {},
45394
45474
  ...firstSection?.margins?.header != null ? { header: firstSection.margins.header } : {},
45395
45475
  ...firstSection?.margins?.footer != null ? { footer: firstSection.margins.footer } : {}
45396
45476
  };