@harbour-enterprises/superdoc 1.0.0-beta.87 → 1.0.0-beta.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/chunks/{PdfViewer-Cwmc4rak.cjs → PdfViewer-64l7m5Lq.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-DAayAt76.es.js → PdfViewer-Dj0ADYo6.es.js} +1 -1
  3. package/dist/chunks/{index-huIbWXSg.cjs → index-Cnq_7qcp.cjs} +3 -3
  4. package/dist/chunks/{index-BV2SxVfK.es.js → index-DXKu3E-3.es.js} +3 -3
  5. package/dist/chunks/{index-rv7o9043-DVlRSGhv.es.js → index-DcTrJ8db-9XJOggtC.es.js} +1 -1
  6. package/dist/chunks/{index-rv7o9043-DD5SvBoC.cjs → index-DcTrJ8db-kUMXGs8M.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-BuujpqOr.es.js → super-editor.es-D0fgEP38.es.js} +297 -68
  8. package/dist/chunks/{super-editor.es-C43B4f8Z.cjs → super-editor.es-D8F0msfn.cjs} +297 -68
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-G519mwN2.js → converter-DPyEmTPY.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-CHfjJ_h-.js → docx-zipper-BTkZSGvz.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-BQsR9BR1.js → editor-4iR-p-_J.js} +293 -64
  13. package/dist/super-editor/chunks/{index-rv7o9043.js → index-DcTrJ8db.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DNfQq2Cl.js → toolbar-Dx7gHXE2.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +299 -70
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -12,8 +12,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-G519mwN2.js";
16
- import { D as DocxZipper } from "./docx-zipper-CHfjJ_h-.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-DPyEmTPY.js";
16
+ import { D as DocxZipper } from "./docx-zipper-BTkZSGvz.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() {
@@ -13940,7 +13940,7 @@ const isHeadless = (editor) => {
13940
13940
  const shouldSkipNodeView = (editor) => {
13941
13941
  return isHeadless(editor);
13942
13942
  };
13943
- const summaryVersion = "1.0.0-beta.87";
13943
+ const summaryVersion = "1.0.0-beta.89";
13944
13944
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
13945
13945
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
13946
13946
  function mapAttributes(attrs) {
@@ -14732,7 +14732,7 @@ const _Editor = class _Editor extends EventEmitter {
14732
14732
  { default: remarkStringify },
14733
14733
  { default: remarkGfm }
14734
14734
  ] = await Promise.all([
14735
- import("./index-rv7o9043.js"),
14735
+ import("./index-DcTrJ8db.js"),
14736
14736
  import("./index-DRCvimau.js"),
14737
14737
  import("./index-C_x_N6Uh.js"),
14738
14738
  import("./index-D_sWOSiG.js"),
@@ -14937,7 +14937,7 @@ const _Editor = class _Editor extends EventEmitter {
14937
14937
  * Process collaboration migrations
14938
14938
  */
14939
14939
  processCollaborationMigrations() {
14940
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.87");
14940
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.89");
14941
14941
  if (!this.options.ydoc) return;
14942
14942
  const metaMap = this.options.ydoc.getMap("meta");
14943
14943
  let docVersion = metaMap.get("version");
@@ -27937,7 +27937,14 @@ const renderTableCell = (deps) => {
27937
27937
  let renderedHeight = 0;
27938
27938
  for (let lineIdx = localStartLine; lineIdx < localEndLine && lineIdx < lines.length; lineIdx++) {
27939
27939
  const line = lines[lineIdx];
27940
- const lineEl = renderLine(block, line, { ...context, section: "body" });
27940
+ const isLastLine = lineIdx === lines.length - 1;
27941
+ const lineEl = renderLine(
27942
+ block,
27943
+ line,
27944
+ { ...context, section: "body" },
27945
+ lineIdx,
27946
+ isLastLine
27947
+ );
27941
27948
  lineEl.style.paddingLeft = "";
27942
27949
  lineEl.style.paddingRight = "";
27943
27950
  lineEl.style.textIndent = "";
@@ -30569,8 +30576,11 @@ const _DomPainter = class _DomPainter {
30569
30576
  const applyFragmentFrameWithSection = (el, frag) => {
30570
30577
  this.applyFragmentFrame(el, frag, context.section);
30571
30578
  };
30572
- const renderLineForTableCell = (block, line, ctx2) => {
30573
- return this.renderLine(block, line, ctx2, void 0, void 0, true);
30579
+ const renderLineForTableCell = (block, line, ctx2, lineIndex, isLastLine) => {
30580
+ const lastRun = block.runs.length > 0 ? block.runs[block.runs.length - 1] : null;
30581
+ const paragraphEndsWithLineBreak = lastRun?.kind === "lineBreak";
30582
+ const shouldSkipJustify = isLastLine && !paragraphEndsWithLineBreak;
30583
+ return this.renderLine(block, line, ctx2, void 0, lineIndex, shouldSkipJustify);
30574
30584
  };
30575
30585
  const renderDrawingContentForTableCell = (block) => {
30576
30586
  if (block.drawingKind === "image") {
@@ -31179,9 +31189,10 @@ const _DomPainter = class _DomPainter {
31179
31189
  el.setAttribute("styleid", styleId);
31180
31190
  }
31181
31191
  const alignment = block.attrs?.alignment;
31182
- if (alignment === "center" || alignment === "right") {
31183
- el.style.textAlign = alignment;
31184
- } else if (alignment === "justify") {
31192
+ const effectiveAlignment = alignment;
31193
+ if (effectiveAlignment === "center" || effectiveAlignment === "right") {
31194
+ el.style.textAlign = effectiveAlignment;
31195
+ } else if (effectiveAlignment === "justify") {
31185
31196
  el.style.textAlign = "left";
31186
31197
  } else {
31187
31198
  el.style.textAlign = "left";
@@ -31243,16 +31254,16 @@ const _DomPainter = class _DomPainter {
31243
31254
  }
31244
31255
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
31245
31256
  const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
31246
- const shouldJustify = !skipJustify && alignment === "justify" && !hasExplicitPositioning;
31257
+ const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
31247
31258
  if (shouldJustify) {
31248
31259
  const spaceCount = textSlices.reduce(
31249
31260
  (sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
31250
31261
  0
31251
31262
  );
31252
- const slack = Math.max(0, availableWidth - line.width);
31253
- if (spaceCount > 0 && slack > 0) {
31254
- const extraPerSpace = slack / spaceCount;
31255
- el.style.wordSpacing = `${extraPerSpace}px`;
31263
+ const slack = availableWidth - line.width;
31264
+ if (spaceCount > 0 && slack !== 0) {
31265
+ const spacingPerSpace = slack / spaceCount;
31266
+ el.style.wordSpacing = `${spacingPerSpace}px`;
31256
31267
  }
31257
31268
  }
31258
31269
  if (hasExplicitPositioning && line.segments) {
@@ -32713,6 +32724,50 @@ function findCharIndexAtX(textNode, container, targetX) {
32713
32724
  }
32714
32725
  return index2;
32715
32726
  }
32727
+ function getWordLayoutConfig(block) {
32728
+ if (!block || block.kind !== "paragraph") {
32729
+ return void 0;
32730
+ }
32731
+ return block.attrs?.wordLayout;
32732
+ }
32733
+ function isListItem(markerWidth, block) {
32734
+ const hasMarkerWidth = markerWidth > 0;
32735
+ if (hasMarkerWidth) {
32736
+ return true;
32737
+ }
32738
+ if (!block || block.kind !== "paragraph") {
32739
+ return false;
32740
+ }
32741
+ const wordLayout = getWordLayoutConfig(block);
32742
+ const hasListAttrs = block.attrs?.listItem != null || wordLayout?.marker != null;
32743
+ if (hasListAttrs) {
32744
+ return true;
32745
+ }
32746
+ const hangingIndent = block.attrs?.indent?.hanging ?? 0;
32747
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
32748
+ const hasHangingIndentPattern = hangingIndent > 0 && paraIndentLeft > 0;
32749
+ return hasHangingIndentPattern;
32750
+ }
32751
+ function calculateTextStartIndent(params2) {
32752
+ const { isFirstLine, isListItem: isListItem2, markerWidth, paraIndentLeft, firstLineIndent, hangingIndent, wordLayout } = params2;
32753
+ const firstLineOffset = firstLineIndent - hangingIndent;
32754
+ const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
32755
+ let indentAdjust = paraIndentLeft;
32756
+ if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
32757
+ const textStartFallback = paraIndentLeft + Math.max(firstLineIndent, 0) + markerWidth;
32758
+ indentAdjust = typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : textStartFallback;
32759
+ } else if (isFirstLine && !isListItem2) {
32760
+ indentAdjust += firstLineOffset;
32761
+ }
32762
+ return indentAdjust;
32763
+ }
32764
+ function extractParagraphIndent(indent) {
32765
+ const left2 = typeof indent?.left === "number" && Number.isFinite(indent.left) ? indent.left : 0;
32766
+ const right2 = typeof indent?.right === "number" && Number.isFinite(indent.right) ? indent.right : 0;
32767
+ const firstLine = typeof indent?.firstLine === "number" && Number.isFinite(indent.firstLine) ? indent.firstLine : 0;
32768
+ const hanging = typeof indent?.hanging === "number" && Number.isFinite(indent.hanging) ? indent.hanging : 0;
32769
+ return { left: left2, right: right2, firstLine, hanging };
32770
+ }
32716
32771
  const defaultHeaderFooterIdentifier = () => ({
32717
32772
  headerIds: { default: null, first: null, even: null, odd: null },
32718
32773
  footerIds: { default: null, first: null, even: null, odd: null },
@@ -37724,8 +37779,8 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
37724
37779
  );
37725
37780
  }
37726
37781
  const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
37727
- const isListItem = markerWidth > 0;
37728
- const alignmentOverride = isListItem ? "left" : void 0;
37782
+ const isListItem3 = markerWidth > 0;
37783
+ const alignmentOverride = isListItem3 ? "left" : void 0;
37729
37784
  const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
37730
37785
  if (pos == null) {
37731
37786
  logClickStage("warn", "no-position", {
@@ -37769,8 +37824,8 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
37769
37824
  );
37770
37825
  }
37771
37826
  const cellMarkerWidth = cellMeasure.marker?.markerWidth ?? 0;
37772
- const isListItem = cellMarkerWidth > 0;
37773
- const alignmentOverride = isListItem ? "left" : void 0;
37827
+ const isListItem3 = cellMarkerWidth > 0;
37828
+ const alignmentOverride = isListItem3 ? "left" : void 0;
37774
37829
  const pos = mapPointToPm(cellBlock, line, localX, isRTL, availableWidth, alignmentOverride);
37775
37830
  if (pos != null) {
37776
37831
  logClickStage("log", "success", {
@@ -37928,17 +37983,22 @@ function selectionToRects(layout, blocks, measures, from2, to) {
37928
37983
  const charOffsetFrom = pmPosToCharOffset(block, line, sliceFrom);
37929
37984
  const charOffsetTo = pmPosToCharOffset(block, line, sliceTo);
37930
37985
  const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
37931
- const isListItem = markerWidth > 0;
37932
- const alignmentOverride = isListItem ? "left" : void 0;
37986
+ const isListItemFlag = isListItem(markerWidth, block);
37987
+ const alignmentOverride = isListItemFlag ? "left" : void 0;
37933
37988
  const startX = mapPmToX(block, line, charOffsetFrom, fragment.width, alignmentOverride);
37934
37989
  const endX = mapPmToX(block, line, charOffsetTo, fragment.width, alignmentOverride);
37935
- const paraIndentLeft = block.attrs?.indent?.left ?? 0;
37936
- const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
37990
+ const indent = extractParagraphIndent(block.attrs?.indent);
37991
+ const wordLayout = getWordLayoutConfig(block);
37937
37992
  const isFirstLine = index2 === fragment.fromLine;
37938
- let indentAdjust = paraIndentLeft;
37939
- if (isFirstLine && !isListItem) {
37940
- indentAdjust += firstLineOffset;
37941
- }
37993
+ const indentAdjust = calculateTextStartIndent({
37994
+ isFirstLine,
37995
+ isListItem: isListItemFlag,
37996
+ markerWidth,
37997
+ paraIndentLeft: indent.left,
37998
+ firstLineIndent: indent.firstLine,
37999
+ hangingIndent: indent.hanging,
38000
+ wordLayout
38001
+ });
37942
38002
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
37943
38003
  const rectWidth = Math.max(1, Math.abs(endX - startX));
37944
38004
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
@@ -38041,9 +38101,12 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38041
38101
  let blockTopCursor = padding.top + verticalOffset;
38042
38102
  renderedBlocks.forEach((info) => {
38043
38103
  const paragraphMarkerWidth = info.measure.marker?.markerWidth ?? 0;
38044
- const isListItem = paragraphMarkerWidth > 0;
38045
- const alignmentOverride = isListItem ? "left" : void 0;
38046
- const paraIndentLeft = info.block.kind === "paragraph" ? info.block.attrs?.indent?.left ?? 0 : 0;
38104
+ const cellIsListItem = isListItem(paragraphMarkerWidth, info.block);
38105
+ const alignmentOverride = cellIsListItem ? "left" : void 0;
38106
+ const cellIndent = extractParagraphIndent(
38107
+ info.block.kind === "paragraph" ? info.block.attrs?.indent : void 0
38108
+ );
38109
+ const cellWordLayout = getWordLayoutConfig(info.block);
38047
38110
  const intersectingLines = findLinesIntersectingRange(info.block, info.measure, from2, to);
38048
38111
  intersectingLines.forEach(({ line, index: index2 }) => {
38049
38112
  if (index2 < info.startLine || index2 >= info.endLine) {
@@ -38059,7 +38122,17 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38059
38122
  const availableWidth = Math.max(1, cellMeasure.width - padding.left - padding.right);
38060
38123
  const startX = mapPmToX(info.block, line, charOffsetFrom, availableWidth, alignmentOverride);
38061
38124
  const endX = mapPmToX(info.block, line, charOffsetTo, availableWidth, alignmentOverride);
38062
- const rectX = fragment.x + cellX + padding.left + paraIndentLeft + Math.min(startX, endX);
38125
+ const isFirstLine = index2 === info.startLine;
38126
+ const textIndentAdjust = calculateTextStartIndent({
38127
+ isFirstLine,
38128
+ isListItem: cellIsListItem,
38129
+ markerWidth: paragraphMarkerWidth,
38130
+ paraIndentLeft: cellIndent.left,
38131
+ firstLineIndent: cellIndent.firstLine,
38132
+ hangingIndent: cellIndent.hanging,
38133
+ wordLayout: cellWordLayout
38134
+ });
38135
+ const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
38063
38136
  const rectWidth = Math.max(1, Math.abs(endX - startX));
38064
38137
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
38065
38138
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
@@ -38431,9 +38504,7 @@ function getMeasuredTextWidth(text, font, letterSpacing, ctx2) {
38431
38504
  try {
38432
38505
  ctx2.font = font;
38433
38506
  const metrics = ctx2.measureText(text);
38434
- const advanceWidth = metrics.width;
38435
- const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
38436
- const baseWidth = Math.max(advanceWidth, paintedWidth);
38507
+ const baseWidth = metrics.width;
38437
38508
  const extra = letterSpacing ? Math.max(0, text.length - 1) * letterSpacing : 0;
38438
38509
  const width = baseWidth + extra;
38439
38510
  cache$1.set(key2, { width });
@@ -38642,7 +38713,8 @@ async function measureParagraphBlock(block, maxWidth) {
38642
38713
  const isWordLayoutList = Boolean(wordLayout?.marker);
38643
38714
  const suppressFirstLine = block.attrs?.suppressFirstLineIndent === true;
38644
38715
  const rawFirstLineOffset = suppressFirstLine ? 0 : firstLine - hanging;
38645
- const firstLineOffset = isWordLayoutList ? 0 : rawFirstLineOffset;
38716
+ const clampedFirstLineOffset = Math.max(0, rawFirstLineOffset);
38717
+ const firstLineOffset = isWordLayoutList ? 0 : clampedFirstLineOffset;
38646
38718
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
38647
38719
  let leftJustifiedMarkerSpace = 0;
38648
38720
  if (wordLayout?.marker) {
@@ -38795,7 +38867,8 @@ async function measureParagraphBlock(block, maxWidth) {
38795
38867
  if (run.kind === "break") {
38796
38868
  if (currentLine) {
38797
38869
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
38798
- const completedLine = { ...currentLine, ...metrics };
38870
+ const { spaceCount: _sc, ...lineBase } = currentLine;
38871
+ const completedLine = { ...lineBase, ...metrics };
38799
38872
  addBarTabsToLine(completedLine);
38800
38873
  lines.push(completedLine);
38801
38874
  currentLine = null;
@@ -38856,7 +38929,8 @@ async function measureParagraphBlock(block, maxWidth) {
38856
38929
  width: 0,
38857
38930
  maxFontSize: lastFontSize,
38858
38931
  maxWidth: nextLineMaxWidth,
38859
- segments: []
38932
+ segments: [],
38933
+ spaceCount: 0
38860
38934
  };
38861
38935
  tabStopCursor = 0;
38862
38936
  pendingTabAlignment = null;
@@ -38874,7 +38948,8 @@ async function measureParagraphBlock(block, maxWidth) {
38874
38948
  maxFontSize: 12,
38875
38949
  // Default font size for tabs
38876
38950
  maxWidth: getEffectiveWidth(initialAvailableWidth),
38877
- segments: []
38951
+ segments: [],
38952
+ spaceCount: 0
38878
38953
  };
38879
38954
  }
38880
38955
  const originX = currentLine.width;
@@ -38923,6 +38998,7 @@ async function measureParagraphBlock(block, maxWidth) {
38923
38998
  maxFontSize: imageHeight,
38924
38999
  // Use image height for line height calculation
38925
39000
  maxWidth: getEffectiveWidth(initialAvailableWidth),
39001
+ spaceCount: 0,
38926
39002
  segments: [
38927
39003
  {
38928
39004
  runIndex,
@@ -38938,8 +39014,9 @@ async function measureParagraphBlock(block, maxWidth) {
38938
39014
  const appliedTabAlign = lastAppliedTabAlign;
38939
39015
  if (currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
38940
39016
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39017
+ const { spaceCount: _sc, ...lineBase } = currentLine;
38941
39018
  const completedLine = {
38942
- ...currentLine,
39019
+ ...lineBase,
38943
39020
  ...metrics
38944
39021
  };
38945
39022
  addBarTabsToLine(completedLine);
@@ -38955,6 +39032,7 @@ async function measureParagraphBlock(block, maxWidth) {
38955
39032
  width: imageWidth,
38956
39033
  maxFontSize: imageHeight,
38957
39034
  maxWidth: getEffectiveWidth(contentWidth),
39035
+ spaceCount: 0,
38958
39036
  segments: [
38959
39037
  {
38960
39038
  runIndex,
@@ -39010,6 +39088,7 @@ async function measureParagraphBlock(block, maxWidth) {
39010
39088
  width: annotationWidth,
39011
39089
  maxFontSize: annotationHeight,
39012
39090
  maxWidth: getEffectiveWidth(initialAvailableWidth),
39091
+ spaceCount: 0,
39013
39092
  segments: [
39014
39093
  {
39015
39094
  runIndex,
@@ -39024,8 +39103,9 @@ async function measureParagraphBlock(block, maxWidth) {
39024
39103
  }
39025
39104
  if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
39026
39105
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39106
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39027
39107
  const completedLine = {
39028
- ...currentLine,
39108
+ ...lineBase,
39029
39109
  ...metrics
39030
39110
  };
39031
39111
  addBarTabsToLine(completedLine);
@@ -39041,6 +39121,7 @@ async function measureParagraphBlock(block, maxWidth) {
39041
39121
  width: annotationWidth,
39042
39122
  maxFontSize: annotationHeight,
39043
39123
  maxWidth: getEffectiveWidth(contentWidth),
39124
+ spaceCount: 0,
39044
39125
  segments: [
39045
39126
  {
39046
39127
  runIndex,
@@ -39096,14 +39177,16 @@ async function measureParagraphBlock(block, maxWidth) {
39096
39177
  maxFontSize: run.fontSize,
39097
39178
  maxFontInfo: getFontInfoFromRun(run),
39098
39179
  maxWidth: getEffectiveWidth(initialAvailableWidth),
39099
- segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }]
39180
+ segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }],
39181
+ spaceCount: spacesLength
39100
39182
  };
39101
39183
  } else {
39102
39184
  const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
39103
39185
  if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
39104
39186
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39187
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39105
39188
  const completedLine = {
39106
- ...currentLine,
39189
+ ...lineBase,
39107
39190
  ...metrics
39108
39191
  };
39109
39192
  addBarTabsToLine(completedLine);
@@ -39120,7 +39203,8 @@ async function measureParagraphBlock(block, maxWidth) {
39120
39203
  maxFontSize: run.fontSize,
39121
39204
  maxFontInfo: getFontInfoFromRun(run),
39122
39205
  maxWidth: getEffectiveWidth(contentWidth),
39123
- segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }]
39206
+ segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }],
39207
+ spaceCount: spacesLength
39124
39208
  };
39125
39209
  } else {
39126
39210
  currentLine.toRun = runIndex;
@@ -39129,6 +39213,7 @@ async function measureParagraphBlock(block, maxWidth) {
39129
39213
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
39130
39214
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
39131
39215
  appendSegment(currentLine.segments, runIndex, spacesStartChar, spacesEndChar, spacesWidth);
39216
+ currentLine.spaceCount += spacesLength;
39132
39217
  }
39133
39218
  }
39134
39219
  charPosInRun = spacesEndChar;
@@ -39145,7 +39230,56 @@ async function measureParagraphBlock(block, maxWidth) {
39145
39230
  for (let wordIndex = 0; wordIndex < words.length; wordIndex++) {
39146
39231
  const word = words[wordIndex];
39147
39232
  if (word === "") {
39148
- charPosInRun += 1;
39233
+ const spaceStartChar = charPosInRun;
39234
+ const spaceEndChar = charPosInRun + 1;
39235
+ const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run);
39236
+ if (!currentLine) {
39237
+ currentLine = {
39238
+ fromRun: runIndex,
39239
+ fromChar: spaceStartChar,
39240
+ toRun: runIndex,
39241
+ toChar: spaceEndChar,
39242
+ width: singleSpaceWidth,
39243
+ maxFontSize: run.fontSize,
39244
+ maxFontInfo: getFontInfoFromRun(run),
39245
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
39246
+ segments: [{ runIndex, fromChar: spaceStartChar, toChar: spaceEndChar, width: singleSpaceWidth }],
39247
+ spaceCount: 1
39248
+ };
39249
+ } else {
39250
+ const boundarySpacing2 = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
39251
+ if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
39252
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39253
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39254
+ const completedLine = { ...lineBase, ...metrics };
39255
+ addBarTabsToLine(completedLine);
39256
+ lines.push(completedLine);
39257
+ tabStopCursor = 0;
39258
+ pendingTabAlignment = null;
39259
+ lastAppliedTabAlign = null;
39260
+ currentLine = {
39261
+ fromRun: runIndex,
39262
+ fromChar: spaceStartChar,
39263
+ toRun: runIndex,
39264
+ toChar: spaceEndChar,
39265
+ width: singleSpaceWidth,
39266
+ maxFontSize: run.fontSize,
39267
+ maxFontInfo: getFontInfoFromRun(run),
39268
+ maxWidth: getEffectiveWidth(contentWidth),
39269
+ segments: [{ runIndex, fromChar: spaceStartChar, toChar: spaceEndChar, width: singleSpaceWidth }],
39270
+ spaceCount: 1
39271
+ };
39272
+ } else {
39273
+ currentLine.toRun = runIndex;
39274
+ currentLine.toChar = spaceEndChar;
39275
+ currentLine.width = roundValue(currentLine.width + boundarySpacing2 + singleSpaceWidth);
39276
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
39277
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
39278
+ appendSegment(currentLine.segments, runIndex, spaceStartChar, spaceEndChar, singleSpaceWidth);
39279
+ currentLine.spaceCount += 1;
39280
+ }
39281
+ }
39282
+ charPosInRun = spaceEndChar;
39149
39283
  continue;
39150
39284
  }
39151
39285
  const isLastWordInSegment = wordIndex === words.length - 1;
@@ -39166,13 +39300,15 @@ async function measureParagraphBlock(block, maxWidth) {
39166
39300
  maxFontSize: run.fontSize,
39167
39301
  maxFontInfo: getFontInfoFromRun(run),
39168
39302
  maxWidth: getEffectiveWidth(initialAvailableWidth),
39169
- segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
39303
+ segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
39304
+ spaceCount: 0
39170
39305
  };
39171
39306
  const ls = run.letterSpacing ?? 0;
39172
39307
  if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39173
39308
  currentLine.toChar = wordEndWithSpace;
39174
39309
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
39175
39310
  charPosInRun = wordEndWithSpace;
39311
+ currentLine.spaceCount += 1;
39176
39312
  } else {
39177
39313
  charPosInRun = wordEndWithSpace;
39178
39314
  }
@@ -39180,10 +39316,36 @@ async function measureParagraphBlock(block, maxWidth) {
39180
39316
  }
39181
39317
  const isTocEntry = block.attrs?.isTocEntry;
39182
39318
  const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
39183
- if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0 && !isTocEntry) {
39319
+ const justifyAlignment = block.attrs?.alignment === "justify";
39320
+ const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
39321
+ (isLastWord ? 0 : run.letterSpacing ?? 0);
39322
+ const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX;
39323
+ let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
39324
+ let compressedWidth = null;
39325
+ if (shouldBreak && justifyAlignment) {
39326
+ const isParagraphLastWord = isLastWord && runIndex === runsToProcess.length - 1;
39327
+ if (!isParagraphLastWord) {
39328
+ const existingSpaces = currentLine.spaceCount ?? 0;
39329
+ const candidateSpaces = existingSpaces + (isLastWord ? 0 : 1);
39330
+ if (candidateSpaces > 0) {
39331
+ const overflow = totalWidthWithWord - availableWidth;
39332
+ if (overflow > 0) {
39333
+ const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run) || Math.max(1, boundarySpacing);
39334
+ const perSpaceCompression = overflow / candidateSpaces;
39335
+ const maxPerSpaceCompression = baseSpaceWidth * 0.25;
39336
+ if (perSpaceCompression <= maxPerSpaceCompression) {
39337
+ shouldBreak = false;
39338
+ compressedWidth = availableWidth;
39339
+ }
39340
+ }
39341
+ }
39342
+ }
39343
+ }
39344
+ if (shouldBreak) {
39184
39345
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39346
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39185
39347
  const completedLine = {
39186
- ...currentLine,
39348
+ ...lineBase,
39187
39349
  ...metrics
39188
39350
  };
39189
39351
  addBarTabsToLine(completedLine);
@@ -39199,12 +39361,14 @@ async function measureParagraphBlock(block, maxWidth) {
39199
39361
  maxFontSize: run.fontSize,
39200
39362
  maxFontInfo: getFontInfoFromRun(run),
39201
39363
  maxWidth: getEffectiveWidth(contentWidth),
39202
- segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
39364
+ segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
39365
+ spaceCount: 0
39203
39366
  };
39204
39367
  if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39205
39368
  currentLine.toChar = wordEndWithSpace;
39206
39369
  currentLine.width = roundValue(currentLine.width + spaceWidth + (run.letterSpacing ?? 0));
39207
39370
  charPosInRun = wordEndWithSpace;
39371
+ currentLine.spaceCount += 1;
39208
39372
  } else {
39209
39373
  charPosInRun = wordEndWithSpace;
39210
39374
  }
@@ -39225,7 +39389,8 @@ async function measureParagraphBlock(block, maxWidth) {
39225
39389
  useExplicitXHere ? segmentStartX : void 0
39226
39390
  );
39227
39391
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39228
- const completedLine = { ...currentLine, ...metrics };
39392
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39393
+ const completedLine = { ...lineBase, ...metrics };
39229
39394
  addBarTabsToLine(completedLine);
39230
39395
  lines.push(completedLine);
39231
39396
  tabStopCursor = 0;
@@ -39238,12 +39403,14 @@ async function measureParagraphBlock(block, maxWidth) {
39238
39403
  currentLine.toChar = newToChar;
39239
39404
  const useExplicitX = wordIndex === 0 && segmentStartX !== void 0;
39240
39405
  const explicitX = useExplicitX ? segmentStartX : void 0;
39241
- currentLine.width = roundValue(
39242
- currentLine.width + boundarySpacing + wordCommitWidth + (isLastWord ? 0 : run.letterSpacing ?? 0)
39243
- );
39406
+ const targetWidth = compressedWidth != null ? compressedWidth : currentLine.width + boundarySpacing + wordCommitWidth + (isLastWord ? 0 : run.letterSpacing ?? 0);
39407
+ currentLine.width = roundValue(targetWidth);
39244
39408
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
39245
39409
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
39246
39410
  appendSegment(currentLine.segments, runIndex, wordStartChar, newToChar, wordCommitWidth, explicitX);
39411
+ if (!isLastWord) {
39412
+ currentLine.spaceCount += 1;
39413
+ }
39247
39414
  }
39248
39415
  charPosInRun = isLastWord ? wordEndNoSpace : wordEndWithSpace;
39249
39416
  }
@@ -39266,7 +39433,8 @@ async function measureParagraphBlock(block, maxWidth) {
39266
39433
  maxFontSize: run.fontSize,
39267
39434
  maxFontInfo: getFontInfoFromRun(run),
39268
39435
  maxWidth: getEffectiveWidth(initialAvailableWidth),
39269
- segments: []
39436
+ segments: [],
39437
+ spaceCount: 0
39270
39438
  };
39271
39439
  }
39272
39440
  const originX = currentLine.width;
@@ -39312,8 +39480,9 @@ async function measureParagraphBlock(block, maxWidth) {
39312
39480
  }
39313
39481
  if (currentLine) {
39314
39482
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39483
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39315
39484
  const finalLine = {
39316
- ...currentLine,
39485
+ ...lineBase,
39317
39486
  ...metrics
39318
39487
  };
39319
39488
  addBarTabsToLine(finalLine);
@@ -46449,18 +46618,78 @@ computeCaretLayoutRectGeometry_fn = function(pos, includeDomFallback = true) {
46449
46618
  if (range.pmStart == null || range.pmEnd == null) return null;
46450
46619
  const pmOffset = pmPosToCharOffset(block, line, pos);
46451
46620
  const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
46452
- const paraIndentLeft = block.attrs?.indent?.left ?? 0;
46453
- const paraIndentRight = block.attrs?.indent?.right ?? 0;
46454
- const availableWidth = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
46621
+ const indent = extractParagraphIndent(block.attrs?.indent);
46622
+ const availableWidth = Math.max(0, fragment.width - (indent.left + indent.right));
46455
46623
  const charX = measureCharacterX(block, line, pmOffset, availableWidth);
46456
- const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
46457
46624
  const isFirstLine = index2 === fragment.fromLine;
46458
- const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
46459
- let indentAdjust = 0;
46460
- if (!isListFirstLine) {
46461
- indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
46625
+ const isListItemFlag = isListItem(markerWidth, block);
46626
+ const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && isListItemFlag;
46627
+ const wordLayout = getWordLayoutConfig(block);
46628
+ const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
46629
+ if (isListFirstLine && isFirstLineIndentMode) {
46630
+ const textStartPx = calculateTextStartIndent({
46631
+ isFirstLine,
46632
+ isListItem: isListItemFlag,
46633
+ markerWidth,
46634
+ paraIndentLeft: indent.left,
46635
+ firstLineIndent: indent.firstLine,
46636
+ hangingIndent: indent.hanging,
46637
+ wordLayout
46638
+ });
46639
+ const localX2 = fragment.x + textStartPx + charX;
46640
+ const lineOffset2 = __privateMethod(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, fragment.fromLine, index2);
46641
+ const localY2 = fragment.y + lineOffset2;
46642
+ const result2 = {
46643
+ pageIndex: hit.pageIndex,
46644
+ x: localX2,
46645
+ y: localY2,
46646
+ height: line.lineHeight
46647
+ };
46648
+ const pageEl2 = __privateGet(this, _painterHost)?.querySelector(
46649
+ `.superdoc-page[data-page-index="${hit.pageIndex}"]`
46650
+ );
46651
+ const pageRect2 = pageEl2?.getBoundingClientRect();
46652
+ const zoom2 = __privateGet(this, _layoutOptions).zoom ?? 1;
46653
+ let domCaretX2 = null;
46654
+ let domCaretY2 = null;
46655
+ const spanEls2 = pageEl2?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
46656
+ for (const spanEl of spanEls2) {
46657
+ const pmStart = Number(spanEl.dataset.pmStart);
46658
+ const pmEnd = Number(spanEl.dataset.pmEnd);
46659
+ if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
46660
+ const textNode = spanEl.firstChild;
46661
+ const charIndex = Math.min(pos - pmStart, textNode.length);
46662
+ const rangeObj = document.createRange();
46663
+ rangeObj.setStart(textNode, charIndex);
46664
+ rangeObj.setEnd(textNode, charIndex);
46665
+ const rangeRect = rangeObj.getBoundingClientRect();
46666
+ if (pageRect2) {
46667
+ domCaretX2 = (rangeRect.left - pageRect2.left) / zoom2;
46668
+ domCaretY2 = (rangeRect.top - pageRect2.top) / zoom2;
46669
+ }
46670
+ break;
46671
+ }
46672
+ }
46673
+ if (includeDomFallback && domCaretX2 != null && domCaretY2 != null) {
46674
+ return {
46675
+ pageIndex: hit.pageIndex,
46676
+ x: domCaretX2,
46677
+ y: domCaretY2,
46678
+ height: line.lineHeight
46679
+ };
46680
+ }
46681
+ return result2;
46462
46682
  }
46463
- const localX = fragment.x + markerWidth + indentAdjust + charX;
46683
+ const indentAdjust = calculateTextStartIndent({
46684
+ isFirstLine,
46685
+ isListItem: isListItemFlag,
46686
+ markerWidth,
46687
+ paraIndentLeft: indent.left,
46688
+ firstLineIndent: indent.firstLine,
46689
+ hangingIndent: indent.hanging,
46690
+ wordLayout
46691
+ });
46692
+ const localX = fragment.x + indentAdjust + charX;
46464
46693
  const lineOffset = __privateMethod(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, fragment.fromLine, index2);
46465
46694
  const localY = fragment.y + lineOffset;
46466
46695
  const result = {