superdoc 2.0.0-next.1 → 2.0.0-next.3

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-BDQHgDVD.es.js → PdfViewer-4xn9rggA.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-Cun5Zr8u.cjs → PdfViewer-C6tuSJXA.cjs} +1 -1
  3. package/dist/chunks/{index-CGAmeAEK.es.js → index-CSZ7bAL7.es.js} +3 -3
  4. package/dist/chunks/{index-if-EH8uU.cjs → index-k0xTe_8v.cjs} +3 -3
  5. package/dist/chunks/{index-Dq6vXk74-Vm-euNb7.cjs → index-lLnrqNSJ-CMJxa5vJ.cjs} +1 -1
  6. package/dist/chunks/{index-Dq6vXk74-CQD7nLbH.es.js → index-lLnrqNSJ-DoACeFqL.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-DyaHVXrq.es.js → super-editor.es-B1DZfUz0.es.js} +558 -132
  8. package/dist/chunks/{super-editor.es-CwNpXZzP.cjs → super-editor.es-BY4paJvP.cjs} +558 -132
  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-BtoNJWI9.js → converter-Bd6dIe0l.js} +1 -1
  12. package/dist/super-editor/chunks/{docx-zipper-CLkDdGOr.js → docx-zipper-Dzdi5pfi.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-COH8793Z.js → editor-C3sjGwAb.js} +568 -149
  14. package/dist/super-editor/chunks/{index-Dq6vXk74.js → index-lLnrqNSJ.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-Ca-BPuJ2.js → toolbar-Bn20lflQ.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 +28 -14
  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 +560 -134
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -12,8 +12,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _a, _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, _currentEpoch, _mapsByFromEpoch, _maxEpochsToKeep, _EpochPositionMapper_instances, pruneByCurrentEpoch_fn, _entries, _windowRoot, _getPainterHost, _onRebuild, _observer, _rebuildScheduled, _rebuildRafId, _docEpoch, _layoutEpoch, _layoutUpdating, _pending, _scheduled, _rafHandle, _scheduler, _SelectionSyncCoordinator_instances, isSafeToRender_fn, maybeSchedule_fn, cancelScheduledRender_fn, _windowRoot2, _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, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _pageGeometryHelper, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionSync, _remoteCursorUpdateScheduled, _epochMapper, _layoutEpoch2, _domPositionIndex, _domIndexObserverManager, _debugLastPointer, _debugLastHit, _pendingMarginClick, _rafHandle2, _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, _a11ySelectionAnnounceTimeout, _a11yLastAnnouncedSelectionKey, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _dragAnchorPageIndex, _isDragging, _dragExtensionMode, _dragLastPointer, _dragLastRawHit, _dragUsedPageNotMountedFallback, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, wrapHiddenEditorFocus_fn, collectCommentPositions_fn, updateSelectionDebugHud_fn, computePendingMarginClick_fn, aggregateLayoutBounds_fn, rebuildDomPositionIndex_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_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, _handlePointerMove, _handlePointerLeave, _handleVisibleHostFocusIn, _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, syncHiddenEditorA11yAttributes_fn, scheduleA11ySelectionAnnouncement_fn, announceSelectionNow_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, isSelectionAwareVirtualizationEnabled_fn, updateSelectionVirtualizationPins_fn, finalizeDragSelectionWithDom_fn, scrollPageIntoView_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderCellSelectionOverlay_fn, renderHoverRegion_fn, clearHoverRegion_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, applyZoom_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeSelectionRectsFromDom_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_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$2, 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-BtoNJWI9.js";
16
- import { D as DocxZipper } from "./docx-zipper-CLkDdGOr.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$2, 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-Bd6dIe0l.js";
16
+ import { D as DocxZipper } from "./docx-zipper-Dzdi5pfi.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() {
@@ -14815,7 +14815,7 @@ const isHeadless = (editor) => {
14815
14815
  const shouldSkipNodeView = (editor) => {
14816
14816
  return isHeadless(editor);
14817
14817
  };
14818
- const summaryVersion = "2.0.0-next.1";
14818
+ const summaryVersion = "2.0.0-next.3";
14819
14819
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
14820
14820
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
14821
14821
  function mapAttributes(attrs) {
@@ -15607,7 +15607,7 @@ const _Editor = class _Editor extends EventEmitter {
15607
15607
  { default: remarkStringify },
15608
15608
  { default: remarkGfm }
15609
15609
  ] = await Promise.all([
15610
- import("./index-Dq6vXk74.js"),
15610
+ import("./index-lLnrqNSJ.js"),
15611
15611
  import("./index-DRCvimau.js"),
15612
15612
  import("./index-C_x_N6Uh.js"),
15613
15613
  import("./index-D_sWOSiG.js"),
@@ -15812,7 +15812,7 @@ const _Editor = class _Editor extends EventEmitter {
15812
15812
  * Process collaboration migrations
15813
15813
  */
15814
15814
  processCollaborationMigrations() {
15815
- console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.1");
15815
+ console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.3");
15816
15816
  if (!this.options.ydoc) return;
15817
15817
  const metaMap = this.options.ydoc.getMap("meta");
15818
15818
  let docVersion = metaMap.get("version");
@@ -23152,7 +23152,7 @@ function isMinimalWordLayout(value) {
23152
23152
  return true;
23153
23153
  }
23154
23154
  const LIST_MARKER_GAP$2 = 8;
23155
- const DEFAULT_TAB_INTERVAL_PX$1 = 48;
23155
+ const DEFAULT_TAB_INTERVAL_PX$2 = 48;
23156
23156
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
23157
23157
  const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
23158
23158
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
@@ -24079,6 +24079,7 @@ const _DomPainter = class _DomPainter {
24079
24079
  const block = lookup.block;
24080
24080
  const measure = lookup.measure;
24081
24081
  const wordLayout = isMinimalWordLayout(block.attrs?.wordLayout) ? block.attrs.wordLayout : void 0;
24082
+ const alignment = block.attrs?.alignment;
24082
24083
  const fragmentEl = this.doc.createElement("div");
24083
24084
  fragmentEl.classList.add(CLASS_NAMES$1.fragment);
24084
24085
  const isTocEntry = block.attrs?.isTocEntry;
@@ -24157,7 +24158,7 @@ const _DomPainter = class _DomPainter {
24157
24158
  const textStart = paraIndentLeft + firstLine;
24158
24159
  tabWidth = textStart - currentPos;
24159
24160
  if (tabWidth <= 0) {
24160
- tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
24161
+ tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
24161
24162
  } else if (tabWidth < LIST_MARKER_GAP$2) {
24162
24163
  tabWidth = LIST_MARKER_GAP$2;
24163
24164
  }
@@ -24184,6 +24185,21 @@ const _DomPainter = class _DomPainter {
24184
24185
  let availableWidthOverride = line.maxWidth != null ? Math.min(line.maxWidth, fallbackAvailableWidth) : fallbackAvailableWidth;
24185
24186
  if (index2 === 0 && listFirstLineMarkerTabWidth != null) {
24186
24187
  availableWidthOverride = fragment.width - listFirstLineMarkerTabWidth - Math.max(0, paraIndentRight);
24188
+ if (alignment === "justify" || alignment === "both") {
24189
+ console.log(
24190
+ "[justify-debug][painter-firstline-available]",
24191
+ JSON.stringify({
24192
+ blockId: block.id,
24193
+ fragmentWidth: fragment.width,
24194
+ markerTabWidth: listFirstLineMarkerTabWidth,
24195
+ paraIndentRight,
24196
+ availableWidthOverride,
24197
+ lineMaxWidth: line.maxWidth ?? null,
24198
+ lineWidth: line.width,
24199
+ lineNaturalWidth: line.naturalWidth ?? null
24200
+ })
24201
+ );
24202
+ }
24187
24203
  }
24188
24204
  const isLastLineOfFragment = index2 === lines.length - 1;
24189
24205
  const isLastLineOfParagraph = isLastLineOfFragment && !fragment.continuesOnNext;
@@ -24309,7 +24325,7 @@ const _DomPainter = class _DomPainter {
24309
24325
  const textStart = paraIndentLeft + firstLine;
24310
24326
  tabWidth = textStart - currentPos;
24311
24327
  if (tabWidth <= 0) {
24312
- tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
24328
+ tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
24313
24329
  } else if (tabWidth < LIST_MARKER_GAP$2) {
24314
24330
  tabWidth = LIST_MARKER_GAP$2;
24315
24331
  }
@@ -25843,6 +25859,23 @@ const _DomPainter = class _DomPainter {
25843
25859
  if (spacingPerSpace !== 0) {
25844
25860
  el.style.wordSpacing = `${spacingPerSpace}px`;
25845
25861
  }
25862
+ if (justifyShouldApply && spacingPerSpace < 0) {
25863
+ console.log(
25864
+ "[justify-debug][painter-wordspacing-negative]",
25865
+ JSON.stringify({
25866
+ blockId: block.id,
25867
+ lineIndex: lineIndex ?? null,
25868
+ alignment: alignment ?? null,
25869
+ availableWidth,
25870
+ lineWidth,
25871
+ lineMaxWidth: line.maxWidth ?? null,
25872
+ lineNaturalWidth: line.naturalWidth ?? null,
25873
+ spaceCount,
25874
+ hasExplicitPositioning: Boolean(hasExplicitPositioning),
25875
+ skipJustify: Boolean(skipJustify)
25876
+ })
25877
+ );
25878
+ }
25846
25879
  if (hasExplicitPositioning && line.segments) {
25847
25880
  const paraIndent = block.attrs?.indent;
25848
25881
  const indentLeft = paraIndent?.left ?? 0;
@@ -28036,6 +28069,28 @@ let measurementCtx = null;
28036
28069
  const TAB_CHAR_LENGTH = 1;
28037
28070
  const SPACE_CHARS = SPACE_CHARS$1;
28038
28071
  const isTabRun$1 = (run) => run?.kind === "tab";
28072
+ const isWordChar$3 = (char) => {
28073
+ if (!char) return false;
28074
+ const code = char.charCodeAt(0);
28075
+ return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
28076
+ };
28077
+ const capitalizeText$2 = (text) => {
28078
+ if (!text) return text;
28079
+ let result = "";
28080
+ for (let i = 0; i < text.length; i += 1) {
28081
+ const prevChar = i > 0 ? text[i - 1] : "";
28082
+ const ch = text[i];
28083
+ result += isWordChar$3(ch) && !isWordChar$3(prevChar) ? ch.toUpperCase() : ch;
28084
+ }
28085
+ return result;
28086
+ };
28087
+ const applyTextTransform$2 = (text, transform) => {
28088
+ if (!text || !transform || transform === "none") return text;
28089
+ if (transform === "uppercase") return text.toUpperCase();
28090
+ if (transform === "lowercase") return text.toLowerCase();
28091
+ if (transform === "capitalize") return capitalizeText$2(text);
28092
+ return text;
28093
+ };
28039
28094
  function getMeasurementContext() {
28040
28095
  if (measurementCtx) return measurementCtx;
28041
28096
  if (typeof document === "undefined") {
@@ -28211,17 +28266,18 @@ function measureCharacterX(block, line, charOffset, availableWidthOverride, alig
28211
28266
  }
28212
28267
  const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
28213
28268
  const runLength = text.length;
28269
+ const displayText = applyTextTransform$2(text, run.textTransform);
28214
28270
  if (currentCharOffset + runLength >= charOffset) {
28215
28271
  const offsetInRun = charOffset - currentCharOffset;
28216
28272
  ctx2.font = getRunFontString(run);
28217
- const textUpToTarget = text.slice(0, offsetInRun);
28273
+ const textUpToTarget = displayText.slice(0, offsetInRun);
28218
28274
  const measured2 = ctx2.measureText(textUpToTarget);
28219
28275
  const spacingWidth = computeLetterSpacingWidth(run, offsetInRun, runLength);
28220
- const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(textUpToTarget) : 0;
28276
+ const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(text.slice(0, offsetInRun)) : 0;
28221
28277
  return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
28222
28278
  }
28223
28279
  ctx2.font = getRunFontString(run);
28224
- const measured = ctx2.measureText(text);
28280
+ const measured = ctx2.measureText(displayText);
28225
28281
  const runLetterSpacing = computeLetterSpacingWidth(run, runLength, runLength);
28226
28282
  const spacesInRun = justify.extraPerSpace !== 0 ? countSpaces(text) : 0;
28227
28283
  currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
@@ -28260,8 +28316,9 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
28260
28316
  return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
28261
28317
  }
28262
28318
  const text = run.text ?? "";
28263
- const segmentText = text.slice(segment.fromChar, segment.toChar);
28264
- const textUpToTarget = segmentText.slice(0, offsetInSegment);
28319
+ const displayText = applyTextTransform$2(text, run.textTransform);
28320
+ const displaySegmentText = displayText.slice(segment.fromChar, segment.toChar);
28321
+ const textUpToTarget = displaySegmentText.slice(0, offsetInSegment);
28265
28322
  ctx2.font = getRunFontString(run);
28266
28323
  const measured = ctx2.measureText(textUpToTarget);
28267
28324
  const spacingWidth = computeLetterSpacingWidth(run, offsetInSegment, segmentChars);
@@ -28357,12 +28414,13 @@ function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, align
28357
28414
  }
28358
28415
  const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
28359
28416
  const runLength = text.length;
28417
+ const displayText = applyTextTransform$2(text, run.textTransform);
28360
28418
  if (runLength === 0) continue;
28361
28419
  ctx2.font = getRunFontString(run);
28362
28420
  for (let i = 0; i <= runLength; i++) {
28363
- const textUpToChar = text.slice(0, i);
28421
+ const textUpToChar = displayText.slice(0, i);
28364
28422
  const measured2 = ctx2.measureText(textUpToChar);
28365
- const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToChar) : 0;
28423
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text.slice(0, i)) : 0;
28366
28424
  const charX = currentX + measured2.width + computeLetterSpacingWidth(run, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
28367
28425
  if (charX >= safeX) {
28368
28426
  if (i === 0) {
@@ -28372,7 +28430,7 @@ function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, align
28372
28430
  pmPosition: pmPosition3
28373
28431
  };
28374
28432
  }
28375
- const prevText = text.slice(0, i - 1);
28433
+ const prevText = displayText.slice(0, i - 1);
28376
28434
  const prevMeasured = ctx2.measureText(prevText);
28377
28435
  const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run, i - 1, runLength);
28378
28436
  const distToPrev = Math.abs(safeX - prevX);
@@ -28385,7 +28443,7 @@ function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, align
28385
28443
  };
28386
28444
  }
28387
28445
  }
28388
- const measured = ctx2.measureText(text);
28446
+ const measured = ctx2.measureText(displayText);
28389
28447
  const runLetterSpacing = computeLetterSpacingWidth(run, runLength, runLength);
28390
28448
  const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
28391
28449
  currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
@@ -28816,6 +28874,83 @@ function findCharIndexAtX(textNode, container, targetX) {
28816
28874
  }
28817
28875
  return index2;
28818
28876
  }
28877
+ const LIST_MARKER_GAP$1 = 8;
28878
+ const MIN_MARKER_GUTTER = 24;
28879
+ const DEFAULT_LIST_INDENT_BASE_PX = 24;
28880
+ const DEFAULT_LIST_INDENT_STEP_PX = 24;
28881
+ const DEFAULT_LIST_HANGING_PX$1 = 18;
28882
+ const SPACE_SUFFIX_GAP_PX = 4;
28883
+ const DEFAULT_TAB_INTERVAL_PX$1 = 48;
28884
+ function resolveListTextStartPx(wordLayout, indentLeft, firstLine, hanging, measureMarkerText) {
28885
+ const marker = wordLayout?.marker;
28886
+ if (!marker) {
28887
+ const textStartPx = wordLayout?.firstLineIndentMode === true && typeof wordLayout.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
28888
+ return textStartPx;
28889
+ }
28890
+ const markerBoxWidth = typeof marker.markerBoxWidthPx === "number" && Number.isFinite(marker.markerBoxWidthPx) ? marker.markerBoxWidthPx : 0;
28891
+ let markerTextWidth = typeof marker.glyphWidthPx === "number" && Number.isFinite(marker.glyphWidthPx) ? marker.glyphWidthPx : void 0;
28892
+ if (markerTextWidth == null && marker.markerText) {
28893
+ markerTextWidth = measureMarkerText(marker.markerText, marker);
28894
+ }
28895
+ if (!Number.isFinite(markerTextWidth) || markerTextWidth < 0) {
28896
+ markerTextWidth = markerBoxWidth;
28897
+ }
28898
+ markerTextWidth = Math.max(0, markerTextWidth);
28899
+ let markerStartPos;
28900
+ if (wordLayout?.firstLineIndentMode === true && Number.isFinite(marker.markerX)) {
28901
+ markerStartPos = marker.markerX;
28902
+ } else {
28903
+ markerStartPos = indentLeft - hanging + firstLine;
28904
+ }
28905
+ if (!Number.isFinite(markerStartPos)) {
28906
+ markerStartPos = 0;
28907
+ }
28908
+ const currentPos = markerStartPos + markerTextWidth;
28909
+ const suffix = marker.suffix ?? "tab";
28910
+ if (suffix === "space") {
28911
+ return markerStartPos + markerTextWidth + SPACE_SUFFIX_GAP_PX;
28912
+ }
28913
+ if (suffix === "nothing") {
28914
+ return markerStartPos + markerTextWidth;
28915
+ }
28916
+ const markerJustification = marker.justification ?? "left";
28917
+ if (markerJustification !== "left") {
28918
+ const gutterWidth = typeof marker.gutterWidthPx === "number" && Number.isFinite(marker.gutterWidthPx) && marker.gutterWidthPx > 0 ? marker.gutterWidthPx : LIST_MARKER_GAP$1;
28919
+ return markerStartPos + markerTextWidth + Math.max(gutterWidth, LIST_MARKER_GAP$1);
28920
+ }
28921
+ if (wordLayout?.firstLineIndentMode === true) {
28922
+ let targetTabStop;
28923
+ if (Array.isArray(wordLayout.tabsPx)) {
28924
+ for (const tab of wordLayout.tabsPx) {
28925
+ if (typeof tab === "number" && tab > currentPos) {
28926
+ targetTabStop = tab;
28927
+ break;
28928
+ }
28929
+ }
28930
+ }
28931
+ const textStartTarget = typeof marker.textStartX === "number" && Number.isFinite(marker.textStartX) ? marker.textStartX : wordLayout.textStartPx;
28932
+ let tabWidth2;
28933
+ if (targetTabStop !== void 0) {
28934
+ tabWidth2 = targetTabStop - currentPos;
28935
+ } else if (textStartTarget !== void 0 && Number.isFinite(textStartTarget) && textStartTarget > currentPos) {
28936
+ tabWidth2 = textStartTarget - currentPos;
28937
+ } else {
28938
+ tabWidth2 = LIST_MARKER_GAP$1;
28939
+ }
28940
+ if (tabWidth2 < LIST_MARKER_GAP$1) {
28941
+ tabWidth2 = LIST_MARKER_GAP$1;
28942
+ }
28943
+ return markerStartPos + markerTextWidth + tabWidth2;
28944
+ }
28945
+ const textStart = indentLeft + firstLine;
28946
+ let tabWidth = textStart - currentPos;
28947
+ if (tabWidth <= 0) {
28948
+ tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
28949
+ } else if (tabWidth < LIST_MARKER_GAP$1) {
28950
+ tabWidth = LIST_MARKER_GAP$1;
28951
+ }
28952
+ return markerStartPos + markerTextWidth + tabWidth;
28953
+ }
28819
28954
  function getWordLayoutConfig(block) {
28820
28955
  if (!block || block.kind !== "paragraph") {
28821
28956
  return void 0;
@@ -28848,9 +28983,16 @@ function calculateTextStartIndent(params2) {
28848
28983
  const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
28849
28984
  let indentAdjust = paraIndentLeft;
28850
28985
  if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
28986
+ const resolvedTextStart = resolveListTextStartPx(
28987
+ wordLayout,
28988
+ paraIndentLeft,
28989
+ Math.max(firstLineIndent, 0),
28990
+ Math.max(hangingIndent, 0),
28991
+ () => markerWidth
28992
+ // Use provided markerWidth since we don't have canvas access here
28993
+ );
28851
28994
  const textStartFallback = paraIndentLeft + Math.max(firstLineIndent, 0) + markerWidth;
28852
- const markerTextStartX = wordLayout?.marker?.textStartX;
28853
- indentAdjust = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : textStartFallback;
28995
+ indentAdjust = typeof resolvedTextStart === "number" && Number.isFinite(resolvedTextStart) ? resolvedTextStart : textStartFallback;
28854
28996
  } else if (isFirstLine && !isListItem2) {
28855
28997
  indentAdjust += firstLineOffset;
28856
28998
  }
@@ -29006,7 +29148,10 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
29006
29148
  }
29007
29149
  function createFloatingObjectManager(columns, margins, pageWidth) {
29008
29150
  const zones = [];
29009
- const marginLeft = Math.max(0, margins?.left ?? 0);
29151
+ let currentColumns = columns;
29152
+ let currentMargins = margins;
29153
+ let currentPageWidth = pageWidth;
29154
+ let marginLeft = Math.max(0, currentMargins?.left ?? 0);
29010
29155
  return {
29011
29156
  registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
29012
29157
  if (!drawingBlock.anchor?.isAnchored) {
@@ -29019,7 +29164,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
29019
29164
  }
29020
29165
  const objectWidth = measure.width ?? 0;
29021
29166
  const objectHeight = measure.height ?? 0;
29022
- const x = computeAnchorX(anchor, columnIndex, columns, objectWidth, margins, pageWidth);
29167
+ const x = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
29023
29168
  const y = anchorY + (anchor.offsetV ?? 0);
29024
29169
  const zone = {
29025
29170
  imageBlockId: drawingBlock.id,
@@ -29053,7 +29198,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
29053
29198
  }
29054
29199
  const tableWidth = measure.totalWidth ?? 0;
29055
29200
  const tableHeight = measure.totalHeight ?? 0;
29056
- const x = computeTableAnchorX(anchor, columnIndex, columns, tableWidth, margins, pageWidth);
29201
+ const x = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
29057
29202
  const y = anchorY + (anchor.offsetV ?? 0);
29058
29203
  const zone = {
29059
29204
  imageBlockId: tableBlock.id,
@@ -29101,7 +29246,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
29101
29246
  }
29102
29247
  const leftFloats = [];
29103
29248
  const rightFloats = [];
29104
- const columnOrigin = marginLeft + columnIndex * (columns.width + columns.gap);
29249
+ const columnOrigin = marginLeft + columnIndex * (currentColumns.width + currentColumns.gap);
29105
29250
  const columnCenter = columnOrigin + baseWidth / 2;
29106
29251
  for (const zone of wrappingZones) {
29107
29252
  if (zone.wrapMode === "left") {
@@ -29140,6 +29285,22 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
29140
29285
  },
29141
29286
  clear() {
29142
29287
  zones.length = 0;
29288
+ },
29289
+ /**
29290
+ * Update layout context used for positioning and wrapping (columns, margins, page width).
29291
+ * This method should be called when the layout configuration changes (e.g., section breaks,
29292
+ * column changes, page size changes) to ensure floating objects are positioned and wrapped
29293
+ * correctly relative to the new layout boundaries.
29294
+ *
29295
+ * @param nextColumns - Column layout configuration (width, gap, count)
29296
+ * @param nextMargins - Optional page margins (left, right) in pixels
29297
+ * @param nextPageWidth - Optional total page width in pixels
29298
+ */
29299
+ setLayoutContext(nextColumns, nextMargins, nextPageWidth) {
29300
+ currentColumns = nextColumns;
29301
+ currentMargins = nextMargins;
29302
+ currentPageWidth = nextPageWidth;
29303
+ marginLeft = Math.max(0, currentMargins?.left ?? 0);
29143
29304
  }
29144
29305
  };
29145
29306
  }
@@ -29239,7 +29400,14 @@ function computeNextSectionPropsAtBreak(blocks) {
29239
29400
  const props = {};
29240
29401
  if (source.kind !== "sectionBreak") return props;
29241
29402
  if (source.margins) {
29242
- props.margins = { header: source.margins.header, footer: source.margins.footer };
29403
+ props.margins = {
29404
+ header: source.margins.header,
29405
+ footer: source.margins.footer,
29406
+ top: source.margins.top,
29407
+ right: source.margins.right,
29408
+ bottom: source.margins.bottom,
29409
+ left: source.margins.left
29410
+ };
29243
29411
  }
29244
29412
  if (source.pageSize) {
29245
29413
  props.pageSize = { w: source.pageSize.w, h: source.pageSize.h };
@@ -29287,20 +29455,36 @@ function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight
29287
29455
  next.activeOrientation = block.orientation;
29288
29456
  next.pendingOrientation = null;
29289
29457
  }
29458
+ const headerDistance = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
29459
+ const footerDistance = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
29460
+ const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
29461
+ const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
29290
29462
  if (block.margins?.header !== void 0) {
29291
- const headerDistance = Math.max(0, block.margins.header);
29292
29463
  next.activeHeaderDistance = headerDistance;
29293
29464
  next.pendingHeaderDistance = headerDistance;
29294
- next.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
29295
- next.pendingTopMargin = next.activeTopMargin;
29296
29465
  }
29297
29466
  if (block.margins?.footer !== void 0) {
29298
- const footerDistance = Math.max(0, block.margins.footer);
29299
29467
  next.activeFooterDistance = footerDistance;
29300
29468
  next.pendingFooterDistance = footerDistance;
29301
- next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, baseMargins.bottom);
29469
+ }
29470
+ if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
29471
+ next.activeTopMargin = calcRequiredTopMargin(headerDistance, sectionTop);
29472
+ next.pendingTopMargin = next.activeTopMargin;
29473
+ }
29474
+ if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
29475
+ next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, sectionBottom);
29302
29476
  next.pendingBottomMargin = next.activeBottomMargin;
29303
29477
  }
29478
+ if (block.margins?.left !== void 0) {
29479
+ const leftMargin = Math.max(0, block.margins.left);
29480
+ next.activeLeftMargin = leftMargin;
29481
+ next.pendingLeftMargin = leftMargin;
29482
+ }
29483
+ if (block.margins?.right !== void 0) {
29484
+ const rightMargin = Math.max(0, block.margins.right);
29485
+ next.activeRightMargin = rightMargin;
29486
+ next.pendingRightMargin = rightMargin;
29487
+ }
29304
29488
  if (block.columns) {
29305
29489
  next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
29306
29490
  next.pendingColumns = null;
@@ -29309,26 +29493,42 @@ function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight
29309
29493
  }
29310
29494
  const headerPx = block.margins?.header;
29311
29495
  const footerPx = block.margins?.footer;
29496
+ const topPx = block.margins?.top;
29497
+ const bottomPx = block.margins?.bottom;
29312
29498
  const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
29313
29499
  const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
29500
+ const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
29501
+ const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
29314
29502
  const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
29315
29503
  const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
29316
- if (typeof headerPx === "number") {
29317
- const newHeaderDist = Math.max(0, headerPx);
29504
+ if (typeof headerPx === "number" || typeof topPx === "number") {
29505
+ const newHeaderDist = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
29506
+ const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
29318
29507
  next.pendingHeaderDistance = newHeaderDist;
29319
- next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, baseMargins.top);
29508
+ next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, sectionTop);
29320
29509
  } else {
29321
29510
  next.pendingTopMargin = nextTop;
29322
29511
  next.pendingHeaderDistance = nextHeader;
29323
29512
  }
29324
- if (typeof footerPx === "number") {
29325
- const newFooterDist = Math.max(0, footerPx);
29513
+ if (typeof footerPx === "number" || typeof bottomPx === "number") {
29514
+ const newFooterDist = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
29515
+ const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
29326
29516
  next.pendingFooterDistance = newFooterDist;
29327
- next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, baseMargins.bottom);
29517
+ next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, sectionBottom);
29328
29518
  } else {
29329
29519
  next.pendingBottomMargin = nextBottom;
29330
29520
  next.pendingFooterDistance = nextFooter;
29331
29521
  }
29522
+ if (typeof block.margins?.left === "number") {
29523
+ next.pendingLeftMargin = Math.max(0, block.margins.left);
29524
+ } else {
29525
+ next.pendingLeftMargin = nextLeft;
29526
+ }
29527
+ if (typeof block.margins?.right === "number") {
29528
+ next.pendingRightMargin = Math.max(0, block.margins.right);
29529
+ } else {
29530
+ next.pendingRightMargin = nextRight;
29531
+ }
29332
29532
  if (block.pageSize) {
29333
29533
  next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
29334
29534
  }
@@ -29388,6 +29588,12 @@ function applyPendingToActive(state) {
29388
29588
  if (next.pendingBottomMargin != null) {
29389
29589
  next.activeBottomMargin = next.pendingBottomMargin;
29390
29590
  }
29591
+ if (next.pendingLeftMargin != null) {
29592
+ next.activeLeftMargin = next.pendingLeftMargin;
29593
+ }
29594
+ if (next.pendingRightMargin != null) {
29595
+ next.activeRightMargin = next.pendingRightMargin;
29596
+ }
29391
29597
  if (next.pendingHeaderDistance != null) {
29392
29598
  next.activeHeaderDistance = next.pendingHeaderDistance;
29393
29599
  }
@@ -29405,6 +29611,8 @@ function applyPendingToActive(state) {
29405
29611
  }
29406
29612
  next.pendingTopMargin = null;
29407
29613
  next.pendingBottomMargin = null;
29614
+ next.pendingLeftMargin = null;
29615
+ next.pendingRightMargin = null;
29408
29616
  next.pendingHeaderDistance = null;
29409
29617
  next.pendingFooterDistance = null;
29410
29618
  next.pendingPageSize = null;
@@ -29633,7 +29841,8 @@ function layoutParagraphBlock(ctx2, anchors) {
29633
29841
  if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
29634
29842
  const firstLineIndent = calculateFirstLineIndent(block, measure);
29635
29843
  const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
29636
- lines = normalizeLines(newMeasure);
29844
+ const newLines = normalizeLines(newMeasure);
29845
+ lines = newLines;
29637
29846
  didRemeasureForColumnWidth = true;
29638
29847
  }
29639
29848
  let fromLine = 0;
@@ -29715,7 +29924,8 @@ function layoutParagraphBlock(ctx2, anchors) {
29715
29924
  if (narrowestRemeasureWidth < remeasureWidth) {
29716
29925
  const firstLineIndent = calculateFirstLineIndent(block, measure);
29717
29926
  const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
29718
- lines = normalizeLines(newMeasure);
29927
+ const newLines = normalizeLines(newMeasure);
29928
+ lines = newLines;
29719
29929
  didRemeasureForFloats = true;
29720
29930
  }
29721
29931
  }
@@ -30872,8 +31082,8 @@ function layoutDocument(blocks, measures, options = {}) {
30872
31082
  header: options.margins?.header ?? options.margins?.top ?? DEFAULT_MARGINS$2.top,
30873
31083
  footer: options.margins?.footer ?? options.margins?.bottom ?? DEFAULT_MARGINS$2.bottom
30874
31084
  };
30875
- const contentWidth = pageSize.w - (margins.left + margins.right);
30876
- if (contentWidth <= 0) {
31085
+ const baseContentWidth = pageSize.w - (margins.left + margins.right);
31086
+ if (baseContentWidth <= 0) {
30877
31087
  throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
30878
31088
  }
30879
31089
  const validateContentHeight = (height) => {
@@ -30903,8 +31113,12 @@ function layoutDocument(blocks, measures, options = {}) {
30903
31113
  const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
30904
31114
  let activeTopMargin = effectiveTopMargin;
30905
31115
  let activeBottomMargin = effectiveBottomMargin;
31116
+ let activeLeftMargin = margins.left;
31117
+ let activeRightMargin = margins.right;
30906
31118
  let pendingTopMargin = null;
30907
31119
  let pendingBottomMargin = null;
31120
+ let pendingLeftMargin = null;
31121
+ let pendingRightMargin = null;
30908
31122
  let activeHeaderDistance = margins.header ?? margins.top;
30909
31123
  let pendingHeaderDistance = null;
30910
31124
  let activeFooterDistance = margins.footer ?? margins.bottom;
@@ -30917,10 +31131,11 @@ function layoutDocument(blocks, measures, options = {}) {
30917
31131
  let pendingOrientation = null;
30918
31132
  let activeVAlign = null;
30919
31133
  let pendingVAlign = null;
31134
+ const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
30920
31135
  const floatManager = createFloatingObjectManager(
30921
- normalizeColumns(activeColumns, contentWidth),
30922
- { left: margins.left, right: margins.right },
30923
- pageSize.w
31136
+ normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
31137
+ { left: activeLeftMargin, right: activeRightMargin },
31138
+ activePageSize.w
30924
31139
  );
30925
31140
  const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
30926
31141
  const scheduleSectionBreakCompat = (block, state, baseMargins) => {
@@ -30937,22 +31152,38 @@ function layoutDocument(blocks, measures, options = {}) {
30937
31152
  next.activeOrientation = block.orientation;
30938
31153
  next.pendingOrientation = null;
30939
31154
  }
31155
+ const headerDistance2 = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
31156
+ const footerDistance2 = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
31157
+ const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
31158
+ const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
30940
31159
  if (block.margins?.header !== void 0) {
30941
- const headerDist = Math.max(0, block.margins.header);
30942
- next.activeHeaderDistance = headerDist;
30943
- next.pendingHeaderDistance = headerDist;
30944
- const requiredTop = maxHeaderContentHeight > 0 ? headerDist + maxHeaderContentHeight : headerDist;
30945
- next.activeTopMargin = Math.max(baseMargins.top, requiredTop);
30946
- next.pendingTopMargin = next.activeTopMargin;
31160
+ next.activeHeaderDistance = headerDistance2;
31161
+ next.pendingHeaderDistance = headerDistance2;
30947
31162
  }
30948
31163
  if (block.margins?.footer !== void 0) {
30949
- const footerDistance2 = Math.max(0, block.margins.footer);
30950
31164
  next.activeFooterDistance = footerDistance2;
30951
31165
  next.pendingFooterDistance = footerDistance2;
31166
+ }
31167
+ if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
31168
+ const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
31169
+ next.activeTopMargin = Math.max(sectionTop, requiredTop);
31170
+ next.pendingTopMargin = next.activeTopMargin;
31171
+ }
31172
+ if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
30952
31173
  const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
30953
- next.activeBottomMargin = Math.max(baseMargins.bottom, requiredBottom);
31174
+ next.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
30954
31175
  next.pendingBottomMargin = next.activeBottomMargin;
30955
31176
  }
31177
+ if (block.margins?.left !== void 0) {
31178
+ const leftMargin = Math.max(0, block.margins.left);
31179
+ next.activeLeftMargin = leftMargin;
31180
+ next.pendingLeftMargin = leftMargin;
31181
+ }
31182
+ if (block.margins?.right !== void 0) {
31183
+ const rightMargin = Math.max(0, block.margins.right);
31184
+ next.activeRightMargin = rightMargin;
31185
+ next.pendingRightMargin = rightMargin;
31186
+ }
30956
31187
  if (block.columns) {
30957
31188
  next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
30958
31189
  next.pendingColumns = null;
@@ -30981,27 +31212,35 @@ function layoutDocument(blocks, measures, options = {}) {
30981
31212
  const headerPx = block.margins?.header;
30982
31213
  const footerPx = block.margins?.footer;
30983
31214
  const topPx = block.margins?.top;
31215
+ const bottomPx = block.margins?.bottom;
31216
+ const leftPx = block.margins?.left;
31217
+ const rightPx = block.margins?.right;
30984
31218
  const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
30985
31219
  const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
31220
+ const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
31221
+ const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
30986
31222
  const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
30987
31223
  const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
30988
31224
  next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
30989
31225
  next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
30990
31226
  if (typeof headerPx === "number" || typeof topPx === "number") {
30991
- const sectionTop = topPx ?? baseMargins.top;
31227
+ const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
30992
31228
  const sectionHeader = next.pendingHeaderDistance;
30993
31229
  const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
30994
31230
  next.pendingTopMargin = Math.max(sectionTop, requiredTop);
30995
31231
  } else {
30996
31232
  next.pendingTopMargin = nextTop;
30997
31233
  }
30998
- if (typeof footerPx === "number") {
31234
+ if (typeof footerPx === "number" || typeof bottomPx === "number") {
30999
31235
  const sectionFooter = next.pendingFooterDistance;
31236
+ const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
31000
31237
  const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
31001
- next.pendingBottomMargin = Math.max(baseMargins.bottom, requiredBottom);
31238
+ next.pendingBottomMargin = Math.max(sectionBottom, requiredBottom);
31002
31239
  } else {
31003
31240
  next.pendingBottomMargin = nextBottom;
31004
31241
  }
31242
+ next.pendingLeftMargin = typeof leftPx === "number" ? Math.max(0, leftPx) : nextLeft;
31243
+ next.pendingRightMargin = typeof rightPx === "number" ? Math.max(0, rightPx) : nextRight;
31005
31244
  if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
31006
31245
  if (block.orientation) next.pendingOrientation = block.orientation;
31007
31246
  const sectionType = block.type ?? "continuous";
@@ -31086,7 +31325,7 @@ function layoutDocument(blocks, measures, options = {}) {
31086
31325
  let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
31087
31326
  let pendingSectionIndex = null;
31088
31327
  const paginator = createPaginator({
31089
- margins: { left: margins.left, right: margins.right },
31328
+ margins: paginatorMargins,
31090
31329
  getActiveTopMargin: () => activeTopMargin,
31091
31330
  getActiveBottomMargin: () => activeBottomMargin,
31092
31331
  getActiveHeaderDistance: () => activeHeaderDistance,
@@ -31101,8 +31340,12 @@ function layoutDocument(blocks, measures, options = {}) {
31101
31340
  const applied = applyPendingToActive({
31102
31341
  activeTopMargin,
31103
31342
  activeBottomMargin,
31343
+ activeLeftMargin,
31344
+ activeRightMargin,
31104
31345
  pendingTopMargin,
31105
31346
  pendingBottomMargin,
31347
+ pendingLeftMargin,
31348
+ pendingRightMargin,
31106
31349
  activeHeaderDistance,
31107
31350
  activeFooterDistance,
31108
31351
  pendingHeaderDistance,
@@ -31117,8 +31360,12 @@ function layoutDocument(blocks, measures, options = {}) {
31117
31360
  });
31118
31361
  activeTopMargin = applied.activeTopMargin;
31119
31362
  activeBottomMargin = applied.activeBottomMargin;
31363
+ activeLeftMargin = applied.activeLeftMargin;
31364
+ activeRightMargin = applied.activeRightMargin;
31120
31365
  pendingTopMargin = applied.pendingTopMargin;
31121
31366
  pendingBottomMargin = applied.pendingBottomMargin;
31367
+ pendingLeftMargin = applied.pendingLeftMargin;
31368
+ pendingRightMargin = applied.pendingRightMargin;
31122
31369
  activeHeaderDistance = applied.activeHeaderDistance;
31123
31370
  activeFooterDistance = applied.activeFooterDistance;
31124
31371
  pendingHeaderDistance = applied.pendingHeaderDistance;
@@ -31130,6 +31377,14 @@ function layoutDocument(blocks, measures, options = {}) {
31130
31377
  activeOrientation = applied.activeOrientation;
31131
31378
  pendingOrientation = applied.pendingOrientation;
31132
31379
  cachedColumnsState.state = null;
31380
+ paginatorMargins.left = activeLeftMargin;
31381
+ paginatorMargins.right = activeRightMargin;
31382
+ const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
31383
+ floatManager.setLayoutContext(
31384
+ normalizeColumns(activeColumns, contentWidth),
31385
+ { left: activeLeftMargin, right: activeRightMargin },
31386
+ activePageSize.w
31387
+ );
31133
31388
  if (pendingNumbering) {
31134
31389
  if (pendingNumbering.format) activeNumberFormat = pendingNumbering.format;
31135
31390
  if (typeof pendingNumbering.start === "number" && Number.isFinite(pendingNumbering.start)) {
@@ -31174,7 +31429,7 @@ function layoutDocument(blocks, measures, options = {}) {
31174
31429
  const getActiveColumnsForState = paginator.getActiveColumnsForState;
31175
31430
  let cachedColumnsState = { state: null, constraintIndex: -2, contentWidth: -1, colsConfig: null, normalized: null };
31176
31431
  const getCurrentColumns = () => {
31177
- const currentContentWidth = activePageSize.w - (margins.left + margins.right);
31432
+ const currentContentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
31178
31433
  const state = states[states.length - 1] ?? null;
31179
31434
  const colsConfig = state ? getActiveColumnsForState(state) : activeColumns;
31180
31435
  const constraintIndex = state ? state.activeConstraintIndex : -1;
@@ -31207,6 +31462,12 @@ function layoutDocument(blocks, measures, options = {}) {
31207
31462
  layoutLog(` Current page: ${state.page.number}, cursorY: ${state.cursorY}`);
31208
31463
  activeColumns = newColumns;
31209
31464
  cachedColumnsState.state = null;
31465
+ const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
31466
+ floatManager.setLayoutContext(
31467
+ normalizeColumns(activeColumns, contentWidth),
31468
+ { left: activeLeftMargin, right: activeRightMargin },
31469
+ activePageSize.w
31470
+ );
31210
31471
  };
31211
31472
  const anchoredByParagraph = collectAnchoredDrawings(blocks, measures);
31212
31473
  const anchoredTablesByParagraph = collectAnchoredTables(blocks, measures);
@@ -31238,10 +31499,10 @@ function layoutDocument(blocks, measures, options = {}) {
31238
31499
  if (alignV === "top") {
31239
31500
  anchorY = offsetV;
31240
31501
  } else if (alignV === "bottom") {
31241
- const pageHeight = contentBottom + margins.bottom;
31502
+ const pageHeight = contentBottom + (state.page.margins?.bottom ?? activeBottomMargin);
31242
31503
  anchorY = pageHeight - imageHeight + offsetV;
31243
31504
  } else if (alignV === "center") {
31244
- const pageHeight = contentBottom + margins.bottom;
31505
+ const pageHeight = contentBottom + (state.page.margins?.bottom ?? activeBottomMargin);
31245
31506
  anchorY = (pageHeight - imageHeight) / 2 + offsetV;
31246
31507
  } else {
31247
31508
  anchorY = offsetV;
@@ -31252,11 +31513,11 @@ function layoutDocument(blocks, measures, options = {}) {
31252
31513
  const anchorX = entry.block.anchor ? computeAnchorX(
31253
31514
  entry.block.anchor,
31254
31515
  state.columnIndex,
31255
- normalizeColumns(activeColumns, contentWidth),
31516
+ normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
31256
31517
  entry.measure.width,
31257
- { left: margins.left, right: margins.right },
31518
+ { left: activeLeftMargin, right: activeRightMargin },
31258
31519
  activePageSize.w
31259
- ) : margins.left;
31520
+ ) : activeLeftMargin;
31260
31521
  floatManager.registerDrawing(entry.block, entry.measure, anchorY, state.columnIndex, state.page.number);
31261
31522
  preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state.page.number });
31262
31523
  }
@@ -31294,8 +31555,12 @@ function layoutDocument(blocks, measures, options = {}) {
31294
31555
  const sectionState = {
31295
31556
  activeTopMargin,
31296
31557
  activeBottomMargin,
31558
+ activeLeftMargin,
31559
+ activeRightMargin,
31297
31560
  pendingTopMargin,
31298
31561
  pendingBottomMargin,
31562
+ pendingLeftMargin,
31563
+ pendingRightMargin,
31299
31564
  activeHeaderDistance,
31300
31565
  activeFooterDistance,
31301
31566
  pendingHeaderDistance,
@@ -31329,8 +31594,12 @@ function layoutDocument(blocks, measures, options = {}) {
31329
31594
  layoutLog(`[Layout] ========== END SECTION BREAK ==========`);
31330
31595
  activeTopMargin = updatedState.activeTopMargin;
31331
31596
  activeBottomMargin = updatedState.activeBottomMargin;
31597
+ activeLeftMargin = updatedState.activeLeftMargin;
31598
+ activeRightMargin = updatedState.activeRightMargin;
31332
31599
  pendingTopMargin = updatedState.pendingTopMargin;
31333
31600
  pendingBottomMargin = updatedState.pendingBottomMargin;
31601
+ pendingLeftMargin = updatedState.pendingLeftMargin;
31602
+ pendingRightMargin = updatedState.pendingRightMargin;
31334
31603
  activeHeaderDistance = updatedState.activeHeaderDistance;
31335
31604
  activeFooterDistance = updatedState.activeFooterDistance;
31336
31605
  pendingHeaderDistance = updatedState.pendingHeaderDistance;
@@ -31468,8 +31737,8 @@ function layoutDocument(blocks, measures, options = {}) {
31468
31737
  pageMargins: {
31469
31738
  top: activeTopMargin,
31470
31739
  bottom: activeBottomMargin,
31471
- left: margins.left,
31472
- right: margins.right
31740
+ left: activeLeftMargin,
31741
+ right: activeRightMargin
31473
31742
  },
31474
31743
  columns: getCurrentColumns(),
31475
31744
  placedAnchoredIds
@@ -31491,9 +31760,9 @@ function layoutDocument(blocks, measures, options = {}) {
31491
31760
  const cols = getCurrentColumns();
31492
31761
  let maxWidth;
31493
31762
  if (relativeFrom === "page") {
31494
- maxWidth = cols.count === 1 ? activePageSize.w - margins.left - margins.right : activePageSize.w;
31763
+ maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
31495
31764
  } else if (relativeFrom === "margin") {
31496
- maxWidth = activePageSize.w - margins.left - margins.right;
31765
+ maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
31497
31766
  } else {
31498
31767
  maxWidth = cols.width;
31499
31768
  }
@@ -32680,11 +32949,11 @@ function findWordBoundaries(blocks, pos) {
32680
32949
  if (text.length === 0) return null;
32681
32950
  const clampedPos = Math.max(0, Math.min(localPos, text.length));
32682
32951
  let wordStart = clampedPos;
32683
- while (wordStart > 0 && isWordChar(text[wordStart - 1])) {
32952
+ while (wordStart > 0 && isWordChar$2(text[wordStart - 1])) {
32684
32953
  wordStart--;
32685
32954
  }
32686
32955
  let wordEnd = clampedPos;
32687
- while (wordEnd < text.length && isWordChar(text[wordEnd])) {
32956
+ while (wordEnd < text.length && isWordChar$2(text[wordEnd])) {
32688
32957
  wordEnd++;
32689
32958
  }
32690
32959
  if (wordStart === wordEnd) {
@@ -32747,7 +33016,7 @@ function findBlockAtPosition(blocks, pos) {
32747
33016
  }
32748
33017
  return null;
32749
33018
  }
32750
- function isWordChar(char) {
33019
+ function isWordChar$2(char) {
32751
33020
  return /[\p{L}\p{N}_]/u.test(char);
32752
33021
  }
32753
33022
  function isWhitespace(char) {
@@ -32782,6 +33051,29 @@ function fontString(run) {
32782
33051
  function runText(run) {
32783
33052
  return "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
32784
33053
  }
33054
+ const isWordChar$1 = (char) => {
33055
+ if (!char) return false;
33056
+ const code = char.charCodeAt(0);
33057
+ return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
33058
+ };
33059
+ const capitalizeText$1 = (text, fullText, startOffset) => {
33060
+ if (!text) return text;
33061
+ const hasFullText = typeof startOffset === "number" && fullText != null;
33062
+ let result = "";
33063
+ for (let i = 0; i < text.length; i += 1) {
33064
+ const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
33065
+ const ch = text[i];
33066
+ result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
33067
+ }
33068
+ return result;
33069
+ };
33070
+ const applyTextTransform$1 = (text, transform, fullText, startOffset) => {
33071
+ if (!text || !transform || transform === "none") return text;
33072
+ if (transform === "uppercase") return text.toUpperCase();
33073
+ if (transform === "lowercase") return text.toLowerCase();
33074
+ if (transform === "capitalize") return capitalizeText$1(text, fullText, startOffset);
33075
+ return text;
33076
+ };
32785
33077
  const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
32786
33078
  const TWIPS_PER_INCH$4 = 1440;
32787
33079
  const PX_PER_INCH$3 = 96;
@@ -32790,6 +33082,13 @@ const TAB_EPSILON$1 = 0.1;
32790
33082
  const WIDTH_FUDGE_PX = 0.5;
32791
33083
  const twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$1;
32792
33084
  const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
33085
+ const markerFontString = (run) => {
33086
+ const size2 = run?.fontSize ?? 16;
33087
+ const family = run?.fontFamily ?? "Arial";
33088
+ const italic = run?.italic ? "italic " : "";
33089
+ const bold = run?.bold ? "bold " : "";
33090
+ return `${italic}${bold}${size2}px ${family}`.trim();
33091
+ };
32793
33092
  const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
32794
33093
  const paragraphIndentTwips = {
32795
33094
  left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
@@ -32820,7 +33119,8 @@ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
32820
33119
  };
32821
33120
  function measureRunSliceWidth(run, fromChar, toChar) {
32822
33121
  const context = getCtx();
32823
- const text = runText(run).slice(fromChar, toChar);
33122
+ const fullText = runText(run);
33123
+ const text = applyTextTransform$1(fullText.slice(fromChar, toChar), run.textTransform, fullText, fromChar);
32824
33124
  if (!context) {
32825
33125
  const textRun = isTextRun$2(run) ? run : null;
32826
33126
  const size2 = textRun?.fontSize ?? 16;
@@ -32866,8 +33166,21 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
32866
33166
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
32867
33167
  const markerTextStartX = wordLayout?.marker?.textStartX;
32868
33168
  const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
32869
- const treatAsHanging = textStartPx && indentLeft === 0 && indentHanging === 0;
32870
- const firstLineWidth = typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - textStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
33169
+ const resolvedTextStartPx = resolveListTextStartPx(
33170
+ wordLayout,
33171
+ indentLeft,
33172
+ indentFirstLine,
33173
+ indentHanging,
33174
+ (markerText, marker) => {
33175
+ const context = getCtx();
33176
+ if (!context) return 0;
33177
+ context.font = markerFontString(marker.run);
33178
+ return context.measureText(markerText).width;
33179
+ }
33180
+ );
33181
+ const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
33182
+ const treatAsHanging = !wordLayout?.marker && effectiveTextStartPx && indentLeft === 0 && indentHanging === 0;
33183
+ const firstLineWidth = typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - effectiveTextStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
32871
33184
  const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
32872
33185
  let currentRun = 0;
32873
33186
  let currentChar = 0;
@@ -33407,7 +33720,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
33407
33720
  if (dirty.deletedBlockIds.length > 0) {
33408
33721
  measureCache.invalidate(dirty.deletedBlockIds);
33409
33722
  }
33410
- const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options);
33723
+ const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options, nextBlocks);
33411
33724
  if (measurementWidth <= 0 || measurementHeight <= 0) {
33412
33725
  throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
33413
33726
  }
@@ -33676,7 +33989,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
33676
33989
  const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
33677
33990
  const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
33678
33991
  const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
33679
- function resolveMeasurementConstraints(options) {
33992
+ function resolveMeasurementConstraints(options, blocks) {
33680
33993
  const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
33681
33994
  const margins = {
33682
33995
  top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
@@ -33684,23 +33997,41 @@ function resolveMeasurementConstraints(options) {
33684
33997
  bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
33685
33998
  left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
33686
33999
  };
33687
- const contentWidth = pageSize.w - (margins.left + margins.right);
33688
- const contentHeight = pageSize.h - (margins.top + margins.bottom);
33689
- const columns = options.columns;
33690
- if (columns && columns.count > 1) {
34000
+ const baseContentWidth = pageSize.w - (margins.left + margins.right);
34001
+ const baseContentHeight = pageSize.h - (margins.top + margins.bottom);
34002
+ const computeColumnWidth = (contentWidth, columns) => {
34003
+ if (!columns || columns.count <= 1) return contentWidth;
33691
34004
  const gap = Math.max(0, columns.gap ?? 0);
33692
34005
  const totalGap = gap * (columns.count - 1);
33693
- const columnWidth = (contentWidth - totalGap) / columns.count;
33694
- if (columnWidth > 0) {
33695
- return {
33696
- measurementWidth: columnWidth,
33697
- measurementHeight: contentHeight
34006
+ return (contentWidth - totalGap) / columns.count;
34007
+ };
34008
+ let measurementWidth = computeColumnWidth(baseContentWidth, options.columns);
34009
+ let measurementHeight = baseContentHeight;
34010
+ if (blocks && blocks.length > 0) {
34011
+ for (const block of blocks) {
34012
+ if (block.kind !== "sectionBreak") continue;
34013
+ const sectionPageSize = block.pageSize ?? pageSize;
34014
+ const sectionMargins = {
34015
+ top: normalizeMargin(block.margins?.top, margins.top),
34016
+ right: normalizeMargin(block.margins?.right, margins.right),
34017
+ bottom: normalizeMargin(block.margins?.bottom, margins.bottom),
34018
+ left: normalizeMargin(block.margins?.left, margins.left)
33698
34019
  };
34020
+ const contentWidth = sectionPageSize.w - (sectionMargins.left + sectionMargins.right);
34021
+ const contentHeight = sectionPageSize.h - (sectionMargins.top + sectionMargins.bottom);
34022
+ if (contentWidth <= 0 || contentHeight <= 0) continue;
34023
+ const columnWidth = computeColumnWidth(contentWidth, block.columns ?? options.columns);
34024
+ if (columnWidth > measurementWidth) {
34025
+ measurementWidth = columnWidth;
34026
+ }
34027
+ if (contentHeight > measurementHeight) {
34028
+ measurementHeight = contentHeight;
34029
+ }
33699
34030
  }
33700
34031
  }
33701
34032
  return {
33702
- measurementWidth: contentWidth,
33703
- measurementHeight: contentHeight
34033
+ measurementWidth,
34034
+ measurementHeight
33704
34035
  };
33705
34036
  }
33706
34037
  const serializeHeaderFooterResults = (kind, batch) => {
@@ -35767,6 +36098,7 @@ function isInRegisteredSurface(event) {
35767
36098
  }
35768
36099
  return false;
35769
36100
  }
36101
+ const SLASH_MENU_HANDLED_FLAG = "__sdHandledBySlashMenu";
35770
36102
  class PresentationInputBridge {
35771
36103
  /**
35772
36104
  * Creates a new PresentationInputBridge that forwards user input events from the visible layout
@@ -36002,9 +36334,19 @@ forwardCompositionEvent_fn = function(event) {
36002
36334
  /**
36003
36335
  * Forwards context menu events to the hidden editor.
36004
36336
  *
36337
+ * Checks if the SlashMenu component has already handled the event by inspecting
36338
+ * the SLASH_MENU_HANDLED_FLAG. If the flag is set, the event is not forwarded,
36339
+ * preventing duplicate context menu handling. This coordination allows SlashMenu
36340
+ * to intercept right-clicks in the capture phase and prevent the default editor
36341
+ * context menu from appearing.
36342
+ *
36005
36343
  * @param event - The context menu event from the layout surface
36006
36344
  */
36007
36345
  forwardContextMenu_fn = function(event) {
36346
+ const handledBySlashMenu = Boolean(event[SLASH_MENU_HANDLED_FLAG]);
36347
+ if (handledBySlashMenu) {
36348
+ return;
36349
+ }
36008
36350
  if (!__privateGet(this, _isEditable).call(this)) {
36009
36351
  return;
36010
36352
  }
@@ -39736,8 +40078,8 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
39736
40078
  }
39737
40079
  return void 0;
39738
40080
  }
39739
- const DEFAULT_LIST_HANGING_PX$1 = 18;
39740
- const LIST_MARKER_GAP$1 = 8;
40081
+ const DEFAULT_LIST_HANGING_PX = 18;
40082
+ const LIST_MARKER_GAP = 8;
39741
40083
  const DEFAULT_BULLET_GLYPH = "•";
39742
40084
  const DEFAULT_DECIMAL_PATTERN = "%1.";
39743
40085
  const ASCII_UPPERCASE_A = 65;
@@ -40148,7 +40490,7 @@ function computeWordParagraphLayout(input) {
40148
40490
  let markerBoxWidthPx;
40149
40491
  let markerX;
40150
40492
  if (hasFirstLineIndent) {
40151
- markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP$1 : DEFAULT_LIST_HANGING_PX$1;
40493
+ markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
40152
40494
  markerX = indentLeftPx + (firstLinePx ?? 0);
40153
40495
  layout.textStartPx = markerX + markerBoxWidthPx;
40154
40496
  layout.hangingPx = 0;
@@ -40248,12 +40590,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
40248
40590
  let markerBox = Math.max(hangingPxRaw || 0, 0);
40249
40591
  if (markerBox <= 0) {
40250
40592
  if (glyphWidthPx != null && glyphWidthPx > 0) {
40251
- markerBox = glyphWidthPx + LIST_MARKER_GAP$1;
40593
+ markerBox = glyphWidthPx + LIST_MARKER_GAP;
40252
40594
  } else {
40253
- markerBox = DEFAULT_LIST_HANGING_PX$1;
40595
+ markerBox = DEFAULT_LIST_HANGING_PX;
40254
40596
  }
40255
- } else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP$1 > markerBox) {
40256
- markerBox = glyphWidthPx + LIST_MARKER_GAP$1;
40597
+ } else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
40598
+ markerBox = glyphWidthPx + LIST_MARKER_GAP;
40257
40599
  }
40258
40600
  return markerBox;
40259
40601
  };
@@ -40273,7 +40615,7 @@ const buildMarkerLayout = ({
40273
40615
  textStartX: textStartPx,
40274
40616
  baselineOffsetPx: markerRun.baselineShift ?? 0,
40275
40617
  // Gutter is the small gap between marker and text, not the full marker box width
40276
- gutterWidthPx: LIST_MARKER_GAP$1,
40618
+ gutterWidthPx: LIST_MARKER_GAP,
40277
40619
  justification: numbering.lvlJc ?? "left",
40278
40620
  suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
40279
40621
  run: markerRun,
@@ -40965,6 +41307,31 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
40965
41307
  return null;
40966
41308
  }
40967
41309
  };
41310
+ const normalizeWordLayoutForIndent = (wordLayout, paragraphIndent) => {
41311
+ const resolvedIndent = wordLayout.resolvedIndent ?? paragraphIndent ?? {};
41312
+ const indentLeft = isFiniteNumber(resolvedIndent.left) ? resolvedIndent.left : 0;
41313
+ const firstLine = isFiniteNumber(resolvedIndent.firstLine) ? resolvedIndent.firstLine : 0;
41314
+ const hanging = isFiniteNumber(resolvedIndent.hanging) ? resolvedIndent.hanging : 0;
41315
+ const shouldFirstLineIndentMode = firstLine > 0 && !hanging;
41316
+ if (wordLayout.firstLineIndentMode === true && !shouldFirstLineIndentMode) {
41317
+ wordLayout.firstLineIndentMode = false;
41318
+ }
41319
+ if (wordLayout.firstLineIndentMode === true) {
41320
+ if (isFiniteNumber(wordLayout.textStartPx)) {
41321
+ if (wordLayout.marker && (!isFiniteNumber(wordLayout.marker.textStartX) || wordLayout.marker.textStartX !== wordLayout.textStartPx)) {
41322
+ wordLayout.marker.textStartX = wordLayout.textStartPx;
41323
+ }
41324
+ } else if (wordLayout.marker && isFiniteNumber(wordLayout.marker.textStartX)) {
41325
+ wordLayout.textStartPx = wordLayout.marker.textStartX;
41326
+ }
41327
+ } else {
41328
+ wordLayout.textStartPx = indentLeft;
41329
+ if (wordLayout.marker) {
41330
+ wordLayout.marker.textStartX = indentLeft;
41331
+ }
41332
+ }
41333
+ return wordLayout;
41334
+ };
40968
41335
  const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
40969
41336
  const attrs = para.attrs ?? {};
40970
41337
  const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
@@ -41287,8 +41654,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
41287
41654
  let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
41288
41655
  if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
41289
41656
  const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
41290
- const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
41291
- if (firstLinePx > 0) {
41657
+ const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
41658
+ const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
41659
+ const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
41660
+ const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
41661
+ if (firstLinePx > 0 && !hangingPx) {
41292
41662
  wordLayout = {
41293
41663
  // Treat as first-line-indent mode: text starts after the marker+firstLine offset.
41294
41664
  firstLineIndentMode: true,
@@ -41296,10 +41666,13 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
41296
41666
  };
41297
41667
  }
41298
41668
  }
41299
- if (wordLayout && (!wordLayout.textStartPx || !Number.isFinite(wordLayout.textStartPx)) && enrichedNumberingProps.resolvedLevelIndent) {
41669
+ if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
41300
41670
  const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
41301
- const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
41302
- if (firstLinePx > 0) {
41671
+ const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
41672
+ const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
41673
+ const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
41674
+ const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
41675
+ if (firstLinePx > 0 && !hangingPx) {
41303
41676
  wordLayout = {
41304
41677
  ...wordLayout,
41305
41678
  firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
@@ -41319,6 +41692,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
41319
41692
  wordLayout.marker.suffix = listRendering.suffix;
41320
41693
  }
41321
41694
  }
41695
+ wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
41322
41696
  paragraphAttrs.wordLayout = wordLayout;
41323
41697
  }
41324
41698
  if (enrichedNumberingProps.resolvedLevelIndent) {
@@ -45552,11 +45926,6 @@ function initHeaderFooterRegistry({
45552
45926
  cleanups
45553
45927
  };
45554
45928
  }
45555
- const LIST_MARKER_GAP = 8;
45556
- const MIN_MARKER_GUTTER = 24;
45557
- const DEFAULT_LIST_INDENT_BASE_PX = 24;
45558
- const DEFAULT_LIST_INDENT_STEP_PX = 24;
45559
- const DEFAULT_LIST_HANGING_PX = 18;
45560
45929
  function calculateRotatedBounds(input) {
45561
45930
  const width = Math.max(0, input.width);
45562
45931
  const height = Math.max(0, input.height);
@@ -45820,8 +46189,25 @@ async function measureParagraphBlock(block, maxWidth) {
45820
46189
  const rawTextStartPx = wordLayout?.textStartPx;
45821
46190
  const markerTextStartX = wordLayout?.marker?.textStartX;
45822
46191
  const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
45823
- if (typeof textStartPx === "number" && textStartPx > indentLeft) {
45824
- initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
46192
+ const resolvedTextStartPx = resolveListTextStartPx(
46193
+ wordLayout,
46194
+ indentLeft,
46195
+ firstLine,
46196
+ hanging,
46197
+ (markerText, marker) => {
46198
+ const markerRun = {
46199
+ fontFamily: toCssFontFamily(marker.run?.fontFamily) ?? marker.run?.fontFamily ?? "Arial",
46200
+ fontSize: marker.run?.fontSize ?? 16,
46201
+ bold: marker.run?.bold ?? false,
46202
+ italic: marker.run?.italic ?? false
46203
+ };
46204
+ const { font: markerFont } = buildFontString(markerRun);
46205
+ return measureText(markerText, markerFont, ctx2);
46206
+ }
46207
+ );
46208
+ const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
46209
+ if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft) {
46210
+ initialAvailableWidth = Math.max(1, maxWidth - effectiveTextStartPx - indentRight);
45825
46211
  } else {
45826
46212
  initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
45827
46213
  }
@@ -45908,7 +46294,7 @@ async function measureParagraphBlock(block, maxWidth) {
45908
46294
  pendingTabAlignment = null;
45909
46295
  return startX;
45910
46296
  };
45911
- const alignSegmentAtTab = (segmentText, font, runContext) => {
46297
+ const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
45912
46298
  if (!pendingTabAlignment || !currentLine) return void 0;
45913
46299
  const { val } = pendingTabAlignment;
45914
46300
  let segmentWidth = 0;
@@ -45917,11 +46303,11 @@ async function measureParagraphBlock(block, maxWidth) {
45917
46303
  const idx = segmentText.indexOf(decimalSeparator);
45918
46304
  if (idx >= 0) {
45919
46305
  const beforeText = segmentText.slice(0, idx);
45920
- beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
46306
+ beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
45921
46307
  }
45922
- segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
46308
+ segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
45923
46309
  } else if (val === "end" || val === "center") {
45924
- segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
46310
+ segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
45925
46311
  }
45926
46312
  return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
45927
46313
  };
@@ -45973,8 +46359,8 @@ async function measureParagraphBlock(block, maxWidth) {
45973
46359
  const { font } = buildFontString(
45974
46360
  lastRun
45975
46361
  );
45976
- const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
45977
- const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun) : 0;
46362
+ const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun, sliceStart);
46363
+ const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun, sliceStart) : 0;
45978
46364
  const delta = Math.max(0, fullWidth - keptWidth);
45979
46365
  lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
45980
46366
  lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
@@ -46185,7 +46571,8 @@ async function measureParagraphBlock(block, maxWidth) {
46185
46571
  continue;
46186
46572
  }
46187
46573
  if (isFieldAnnotationRun(run)) {
46188
- const displayText = run.displayLabel || "";
46574
+ const rawDisplayText = run.displayLabel || "";
46575
+ const displayText = applyTextTransform(rawDisplayText, run);
46189
46576
  const annotationFontSize = typeof run.fontSize === "number" ? run.fontSize : typeof run.fontSize === "string" ? parseFloat(run.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
46190
46577
  const annotationFontFamily = run.fontFamily || "Arial, sans-serif";
46191
46578
  const fontWeight = run.bold ? "bold" : "normal";
@@ -46288,7 +46675,7 @@ async function measureParagraphBlock(block, maxWidth) {
46288
46675
  const spacesLength = segment.length;
46289
46676
  const spacesStartChar = charPosInRun;
46290
46677
  const spacesEndChar = charPosInRun + spacesLength;
46291
- const spacesWidth = measureRunWidth(segment, font, ctx2, run);
46678
+ const spacesWidth = measureRunWidth(segment, font, ctx2, run, spacesStartChar);
46292
46679
  if (!currentLine) {
46293
46680
  currentLine = {
46294
46681
  fromRun: runIndex,
@@ -46352,7 +46739,7 @@ async function measureParagraphBlock(block, maxWidth) {
46352
46739
  }
46353
46740
  let segmentStartX;
46354
46741
  if (currentLine && pendingTabAlignment) {
46355
- segmentStartX = alignSegmentAtTab(segment, font, run);
46742
+ segmentStartX = alignSegmentAtTab(segment, font, run, charPosInRun);
46356
46743
  if (segmentStartX == null) {
46357
46744
  segmentStartX = currentLine.width;
46358
46745
  }
@@ -46362,7 +46749,7 @@ async function measureParagraphBlock(block, maxWidth) {
46362
46749
  if (word2 === "") {
46363
46750
  const spaceStartChar = charPosInRun;
46364
46751
  const spaceEndChar = charPosInRun + 1;
46365
- const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run);
46752
+ const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run, spaceStartChar);
46366
46753
  if (!currentLine) {
46367
46754
  currentLine = {
46368
46755
  fromRun: runIndex,
@@ -46413,12 +46800,12 @@ async function measureParagraphBlock(block, maxWidth) {
46413
46800
  charPosInRun = spaceEndChar;
46414
46801
  continue;
46415
46802
  }
46416
- const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run);
46417
- const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
46418
- const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run) : 0;
46419
- const wordCommitWidth = wordOnlyWidth + spaceWidth;
46420
46803
  const wordStartChar = charPosInRun;
46804
+ const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run, wordStartChar);
46805
+ const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
46421
46806
  const wordEndNoSpace = charPosInRun + word2.length;
46807
+ const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run, wordEndNoSpace) : 0;
46808
+ const wordCommitWidth = wordOnlyWidth + spaceWidth;
46422
46809
  const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
46423
46810
  const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
46424
46811
  if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
@@ -46437,7 +46824,7 @@ async function measureParagraphBlock(block, maxWidth) {
46437
46824
  const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
46438
46825
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
46439
46826
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
46440
- const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run);
46827
+ const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run, wordStartChar);
46441
46828
  let chunkCharOffset = wordStartChar;
46442
46829
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
46443
46830
  const chunk = chunks[chunkIndex];
@@ -46561,7 +46948,7 @@ async function measureParagraphBlock(block, maxWidth) {
46561
46948
  if (candidateSpaces > 0) {
46562
46949
  const overflow = totalWidthWithWord - availableWidth;
46563
46950
  if (overflow > 0) {
46564
- const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run) || Math.max(1, boundarySpacing);
46951
+ const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run, wordEndNoSpace) || Math.max(1, boundarySpacing);
46565
46952
  const perSpaceCompression = overflow / candidateSpaces;
46566
46953
  const maxPerSpaceCompression = baseSpaceWidth * 0.25;
46567
46954
  if (perSpaceCompression <= maxPerSpaceCompression) {
@@ -46736,8 +47123,8 @@ async function measureParagraphBlock(block, maxWidth) {
46736
47123
  const { font: markerFont } = buildFontString(markerRun);
46737
47124
  const markerText = wordLayout.marker.markerText ?? "";
46738
47125
  const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
46739
- const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
46740
- const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
47126
+ const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
47127
+ const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP$1);
46741
47128
  markerInfo = {
46742
47129
  markerWidth: markerBoxWidth,
46743
47130
  markerTextWidth: glyphWidth,
@@ -47081,7 +47468,7 @@ async function measureListBlock(block, constraints) {
47081
47468
  markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
47082
47469
  indentLeft = resolveIndentLeft(item);
47083
47470
  const indentHanging = resolveIndentHanging(item);
47084
- markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
47471
+ markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
47085
47472
  }
47086
47473
  const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
47087
47474
  const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
@@ -47107,16 +47494,46 @@ const getPrimaryRun = (paragraph) => {
47107
47494
  fontSize: 16
47108
47495
  };
47109
47496
  };
47110
- const measureRunWidth = (text, font, ctx2, run) => {
47497
+ const isWordChar = (char) => {
47498
+ if (!char) return false;
47499
+ const code = char.charCodeAt(0);
47500
+ return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
47501
+ };
47502
+ const capitalizeText = (text, fullText, startOffset) => {
47503
+ if (!text) return text;
47504
+ const hasFullText = typeof startOffset === "number" && fullText != null;
47505
+ let result = "";
47506
+ for (let i = 0; i < text.length; i += 1) {
47507
+ const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
47508
+ const ch = text[i];
47509
+ result += isWordChar(ch) && !isWordChar(prevChar) ? ch.toUpperCase() : ch;
47510
+ }
47511
+ return result;
47512
+ };
47513
+ const applyTextTransform = (text, run, startOffset) => {
47514
+ const transform = run.textTransform;
47515
+ if (!text || !transform || transform === "none") return text;
47516
+ if (transform === "uppercase") return text.toUpperCase();
47517
+ if (transform === "lowercase") return text.toLowerCase();
47518
+ if (transform === "capitalize") {
47519
+ const fullText = "text" in run && typeof run.text === "string" ? run.text : text;
47520
+ return capitalizeText(text, fullText, startOffset);
47521
+ }
47522
+ return text;
47523
+ };
47524
+ const measureRunWidth = (text, font, ctx2, run, startOffset) => {
47111
47525
  const letterSpacing = run.kind === "text" || run.kind === void 0 ? run.letterSpacing || 0 : 0;
47112
- const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
47526
+ const displayText = applyTextTransform(text, run, startOffset);
47527
+ const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
47113
47528
  return roundValue(width);
47114
47529
  };
47115
- const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run) => {
47530
+ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run, startOffset) => {
47116
47531
  const chunks = [];
47532
+ const baseOffset = typeof startOffset === "number" ? startOffset : 0;
47117
47533
  if (maxWidth <= 0) {
47118
- for (const char of word2) {
47119
- const charWidth = measureRunWidth(char, font, ctx2, run);
47534
+ for (let i = 0; i < word2.length; i++) {
47535
+ const char = word2[i];
47536
+ const charWidth = measureRunWidth(char, font, ctx2, run, baseOffset + i);
47120
47537
  chunks.push({ text: char, width: charWidth });
47121
47538
  }
47122
47539
  return chunks;
@@ -47126,11 +47543,11 @@ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run) => {
47126
47543
  for (let i = 0; i < word2.length; i++) {
47127
47544
  const char = word2[i];
47128
47545
  const testChunk = currentChunk + char;
47129
- const testWidth = measureRunWidth(testChunk, font, ctx2, run);
47546
+ const testWidth = measureRunWidth(testChunk, font, ctx2, run, baseOffset);
47130
47547
  if (testWidth > maxWidth && currentChunk.length > 0) {
47131
47548
  chunks.push({ text: currentChunk, width: currentWidth });
47132
47549
  currentChunk = char;
47133
- currentWidth = measureRunWidth(char, font, ctx2, run);
47550
+ currentWidth = measureRunWidth(char, font, ctx2, run, baseOffset + i);
47134
47551
  } else {
47135
47552
  currentChunk = testChunk;
47136
47553
  currentWidth = testWidth;
@@ -47184,7 +47601,8 @@ const measureDropCap = (ctx2, descriptor, spacing) => {
47184
47601
  italic: run.italic
47185
47602
  });
47186
47603
  ctx2.font = font;
47187
- const metrics = ctx2.measureText(run.text);
47604
+ const displayText = applyTextTransform(run.text, run);
47605
+ const metrics = ctx2.measureText(displayText);
47188
47606
  const advanceWidth = metrics.width;
47189
47607
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
47190
47608
  const textWidth = Math.max(advanceWidth, paintedWidth);
@@ -47210,7 +47628,7 @@ const resolveIndentHanging = (item) => {
47210
47628
  if (indentHanging > 0) {
47211
47629
  return indentHanging;
47212
47630
  }
47213
- return DEFAULT_LIST_HANGING_PX;
47631
+ return DEFAULT_LIST_HANGING_PX$1;
47214
47632
  };
47215
47633
  const buildTabStopsPx = (indent, tabs, tabIntervalTwips) => {
47216
47634
  const paragraphIndentTwips = {
@@ -69660,19 +70078,20 @@ const getStarterExtensions = () => {
69660
70078
  ];
69661
70079
  };
69662
70080
  export {
69663
- Attribute as A,
69664
- index$1 as B,
69665
- index as C,
70081
+ Extension as A,
70082
+ Attribute as B,
70083
+ index$1 as C,
69666
70084
  DecorationSet as D,
69667
70085
  Editor as E,
69668
- AnnotatorHelpers as F,
69669
- SectionHelpers as G,
69670
- getAllowedImageDimensions as H,
69671
- CommentsPluginKey as I,
70086
+ index as F,
70087
+ AnnotatorHelpers as G,
70088
+ SectionHelpers as H,
70089
+ getAllowedImageDimensions as I,
70090
+ CommentsPluginKey as J,
69672
70091
  Mark as M,
69673
70092
  Node$1 as N,
69674
70093
  PresentationEditor as P,
69675
- SlashMenuPluginKey as S,
70094
+ SLASH_MENU_HANDLED_FLAG as S,
69676
70095
  TrackChangesBasePluginKey as T,
69677
70096
  _export_sfc as _,
69678
70097
  getQuickFormatList as a,
@@ -69687,18 +70106,18 @@ export {
69687
70106
  redoDepth as j,
69688
70107
  getEditorSurfaceElement as k,
69689
70108
  collectTrackedChangesForContext as l,
69690
- generateRulerDefinition as m,
69691
- clampHandlePosition as n,
69692
- calculateMarginFromHandle as o,
69693
- measureCache as p,
69694
- isHeadless as q,
70109
+ SlashMenuPluginKey as m,
70110
+ generateRulerDefinition as n,
70111
+ clampHandlePosition as o,
70112
+ calculateMarginFromHandle as p,
70113
+ measureCache as q,
69695
70114
  replaceSelectionWithImagePlaceholder as r,
69696
70115
  shouldBypassContextMenu as s,
69697
- getStarterExtensions as t,
70116
+ isHeadless as t,
69698
70117
  useHighContrastMode as u,
69699
- Placeholder as v,
69700
- getRichTextExtensions as w,
69701
- Decoration as x,
70118
+ getStarterExtensions as v,
70119
+ Placeholder as w,
70120
+ getRichTextExtensions as x,
69702
70121
  yUndoPluginKey as y,
69703
- Extension as z
70122
+ Decoration as z
69704
70123
  };