superdoc 2.0.0-next.2 → 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.
- package/dist/chunks/{PdfViewer-C4xgIIbF.es.js → PdfViewer-4xn9rggA.es.js} +1 -1
- package/dist/chunks/{PdfViewer-CWO98Qls.cjs → PdfViewer-C6tuSJXA.cjs} +1 -1
- package/dist/chunks/{index-s9GUR_Gc.es.js → index-CSZ7bAL7.es.js} +3 -3
- package/dist/chunks/{index-BY-3Vl72.cjs → index-k0xTe_8v.cjs} +3 -3
- package/dist/chunks/{index-BqPa6D4q-Dulj8zfc.cjs → index-lLnrqNSJ-CMJxa5vJ.cjs} +1 -1
- package/dist/chunks/{index-BqPa6D4q-8U4x8RP6.es.js → index-lLnrqNSJ-DoACeFqL.es.js} +1 -1
- package/dist/chunks/{super-editor.es-CT28vUbx.es.js → super-editor.es-B1DZfUz0.es.js} +537 -130
- package/dist/chunks/{super-editor.es-BM-ulSRj.cjs → super-editor.es-BY4paJvP.cjs} +537 -130
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CDlAWcRu.js → converter-Bd6dIe0l.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-B2VXuf8h.js → docx-zipper-Dzdi5pfi.js} +1 -1
- package/dist/super-editor/chunks/{editor-B4Q_tNET.js → editor-C3sjGwAb.js} +538 -131
- package/dist/super-editor/chunks/{index-BqPa6D4q.js → index-lLnrqNSJ.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-BD-lDCLr.js → toolbar-Bn20lflQ.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +539 -132
- package/dist/superdoc.umd.js.map +1 -1
- 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-
|
|
16
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
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.
|
|
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-
|
|
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.
|
|
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$
|
|
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$
|
|
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$
|
|
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 =
|
|
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(
|
|
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(
|
|
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
|
|
28264
|
-
const
|
|
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 =
|
|
28421
|
+
const textUpToChar = displayText.slice(0, i);
|
|
28364
28422
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
28365
|
-
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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 * (
|
|
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 = {
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
30876
|
-
if (
|
|
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,
|
|
30922
|
-
{ left:
|
|
30923
|
-
|
|
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
|
-
|
|
30942
|
-
next.
|
|
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(
|
|
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
|
|
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(
|
|
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:
|
|
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 - (
|
|
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
|
|
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
|
|
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,
|
|
31516
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
31256
31517
|
entry.measure.width,
|
|
31257
|
-
{ left:
|
|
31518
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
31258
31519
|
activePageSize.w
|
|
31259
|
-
) :
|
|
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:
|
|
31472
|
-
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 -
|
|
31763
|
+
maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
|
|
31495
31764
|
} else if (relativeFrom === "margin") {
|
|
31496
|
-
maxWidth = activePageSize.w -
|
|
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
|
|
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
|
|
32870
|
-
|
|
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
|
|
33688
|
-
const
|
|
33689
|
-
const
|
|
33690
|
-
|
|
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
|
-
|
|
33694
|
-
|
|
33695
|
-
|
|
33696
|
-
|
|
33697
|
-
|
|
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
|
|
33703
|
-
measurementHeight
|
|
34033
|
+
measurementWidth,
|
|
34034
|
+
measurementHeight
|
|
33704
34035
|
};
|
|
33705
34036
|
}
|
|
33706
34037
|
const serializeHeaderFooterResults = (kind, batch) => {
|
|
@@ -39747,8 +40078,8 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
|
39747
40078
|
}
|
|
39748
40079
|
return void 0;
|
|
39749
40080
|
}
|
|
39750
|
-
const DEFAULT_LIST_HANGING_PX
|
|
39751
|
-
const LIST_MARKER_GAP
|
|
40081
|
+
const DEFAULT_LIST_HANGING_PX = 18;
|
|
40082
|
+
const LIST_MARKER_GAP = 8;
|
|
39752
40083
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
39753
40084
|
const DEFAULT_DECIMAL_PATTERN = "%1.";
|
|
39754
40085
|
const ASCII_UPPERCASE_A = 65;
|
|
@@ -40159,7 +40490,7 @@ function computeWordParagraphLayout(input) {
|
|
|
40159
40490
|
let markerBoxWidthPx;
|
|
40160
40491
|
let markerX;
|
|
40161
40492
|
if (hasFirstLineIndent) {
|
|
40162
|
-
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP
|
|
40493
|
+
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
|
|
40163
40494
|
markerX = indentLeftPx + (firstLinePx ?? 0);
|
|
40164
40495
|
layout.textStartPx = markerX + markerBoxWidthPx;
|
|
40165
40496
|
layout.hangingPx = 0;
|
|
@@ -40259,12 +40590,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
|
|
|
40259
40590
|
let markerBox = Math.max(hangingPxRaw || 0, 0);
|
|
40260
40591
|
if (markerBox <= 0) {
|
|
40261
40592
|
if (glyphWidthPx != null && glyphWidthPx > 0) {
|
|
40262
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
40593
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
40263
40594
|
} else {
|
|
40264
|
-
markerBox = DEFAULT_LIST_HANGING_PX
|
|
40595
|
+
markerBox = DEFAULT_LIST_HANGING_PX;
|
|
40265
40596
|
}
|
|
40266
|
-
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP
|
|
40267
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
40597
|
+
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
|
|
40598
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
40268
40599
|
}
|
|
40269
40600
|
return markerBox;
|
|
40270
40601
|
};
|
|
@@ -40284,7 +40615,7 @@ const buildMarkerLayout = ({
|
|
|
40284
40615
|
textStartX: textStartPx,
|
|
40285
40616
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
40286
40617
|
// Gutter is the small gap between marker and text, not the full marker box width
|
|
40287
|
-
gutterWidthPx: LIST_MARKER_GAP
|
|
40618
|
+
gutterWidthPx: LIST_MARKER_GAP,
|
|
40288
40619
|
justification: numbering.lvlJc ?? "left",
|
|
40289
40620
|
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
40290
40621
|
run: markerRun,
|
|
@@ -40976,6 +41307,31 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
40976
41307
|
return null;
|
|
40977
41308
|
}
|
|
40978
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
|
+
};
|
|
40979
41335
|
const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
|
|
40980
41336
|
const attrs = para.attrs ?? {};
|
|
40981
41337
|
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
@@ -41298,8 +41654,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
41298
41654
|
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
41299
41655
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
41300
41656
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
41301
|
-
const
|
|
41302
|
-
|
|
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) {
|
|
41303
41662
|
wordLayout = {
|
|
41304
41663
|
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
41305
41664
|
firstLineIndentMode: true,
|
|
@@ -41307,10 +41666,13 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
41307
41666
|
};
|
|
41308
41667
|
}
|
|
41309
41668
|
}
|
|
41310
|
-
if (wordLayout &&
|
|
41669
|
+
if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
41311
41670
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
41312
|
-
const
|
|
41313
|
-
|
|
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) {
|
|
41314
41676
|
wordLayout = {
|
|
41315
41677
|
...wordLayout,
|
|
41316
41678
|
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
@@ -41330,6 +41692,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
41330
41692
|
wordLayout.marker.suffix = listRendering.suffix;
|
|
41331
41693
|
}
|
|
41332
41694
|
}
|
|
41695
|
+
wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
|
|
41333
41696
|
paragraphAttrs.wordLayout = wordLayout;
|
|
41334
41697
|
}
|
|
41335
41698
|
if (enrichedNumberingProps.resolvedLevelIndent) {
|
|
@@ -45563,11 +45926,6 @@ function initHeaderFooterRegistry({
|
|
|
45563
45926
|
cleanups
|
|
45564
45927
|
};
|
|
45565
45928
|
}
|
|
45566
|
-
const LIST_MARKER_GAP = 8;
|
|
45567
|
-
const MIN_MARKER_GUTTER = 24;
|
|
45568
|
-
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
45569
|
-
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
45570
|
-
const DEFAULT_LIST_HANGING_PX = 18;
|
|
45571
45929
|
function calculateRotatedBounds(input) {
|
|
45572
45930
|
const width = Math.max(0, input.width);
|
|
45573
45931
|
const height = Math.max(0, input.height);
|
|
@@ -45831,8 +46189,25 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
45831
46189
|
const rawTextStartPx = wordLayout?.textStartPx;
|
|
45832
46190
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
45833
46191
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
|
|
45834
|
-
|
|
45835
|
-
|
|
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);
|
|
45836
46211
|
} else {
|
|
45837
46212
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
45838
46213
|
}
|
|
@@ -45919,7 +46294,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
45919
46294
|
pendingTabAlignment = null;
|
|
45920
46295
|
return startX;
|
|
45921
46296
|
};
|
|
45922
|
-
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
46297
|
+
const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
|
|
45923
46298
|
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
45924
46299
|
const { val } = pendingTabAlignment;
|
|
45925
46300
|
let segmentWidth = 0;
|
|
@@ -45928,11 +46303,11 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
45928
46303
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
45929
46304
|
if (idx >= 0) {
|
|
45930
46305
|
const beforeText = segmentText.slice(0, idx);
|
|
45931
|
-
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
46306
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
45932
46307
|
}
|
|
45933
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
46308
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
45934
46309
|
} else if (val === "end" || val === "center") {
|
|
45935
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
46310
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
45936
46311
|
}
|
|
45937
46312
|
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
45938
46313
|
};
|
|
@@ -45984,8 +46359,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
45984
46359
|
const { font } = buildFontString(
|
|
45985
46360
|
lastRun
|
|
45986
46361
|
);
|
|
45987
|
-
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
|
|
45988
|
-
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;
|
|
45989
46364
|
const delta = Math.max(0, fullWidth - keptWidth);
|
|
45990
46365
|
lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
|
|
45991
46366
|
lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
|
|
@@ -46196,7 +46571,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46196
46571
|
continue;
|
|
46197
46572
|
}
|
|
46198
46573
|
if (isFieldAnnotationRun(run)) {
|
|
46199
|
-
const
|
|
46574
|
+
const rawDisplayText = run.displayLabel || "";
|
|
46575
|
+
const displayText = applyTextTransform(rawDisplayText, run);
|
|
46200
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;
|
|
46201
46577
|
const annotationFontFamily = run.fontFamily || "Arial, sans-serif";
|
|
46202
46578
|
const fontWeight = run.bold ? "bold" : "normal";
|
|
@@ -46299,7 +46675,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46299
46675
|
const spacesLength = segment.length;
|
|
46300
46676
|
const spacesStartChar = charPosInRun;
|
|
46301
46677
|
const spacesEndChar = charPosInRun + spacesLength;
|
|
46302
|
-
const spacesWidth = measureRunWidth(segment, font, ctx2, run);
|
|
46678
|
+
const spacesWidth = measureRunWidth(segment, font, ctx2, run, spacesStartChar);
|
|
46303
46679
|
if (!currentLine) {
|
|
46304
46680
|
currentLine = {
|
|
46305
46681
|
fromRun: runIndex,
|
|
@@ -46363,7 +46739,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46363
46739
|
}
|
|
46364
46740
|
let segmentStartX;
|
|
46365
46741
|
if (currentLine && pendingTabAlignment) {
|
|
46366
|
-
segmentStartX = alignSegmentAtTab(segment, font, run);
|
|
46742
|
+
segmentStartX = alignSegmentAtTab(segment, font, run, charPosInRun);
|
|
46367
46743
|
if (segmentStartX == null) {
|
|
46368
46744
|
segmentStartX = currentLine.width;
|
|
46369
46745
|
}
|
|
@@ -46373,7 +46749,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46373
46749
|
if (word2 === "") {
|
|
46374
46750
|
const spaceStartChar = charPosInRun;
|
|
46375
46751
|
const spaceEndChar = charPosInRun + 1;
|
|
46376
|
-
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run);
|
|
46752
|
+
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run, spaceStartChar);
|
|
46377
46753
|
if (!currentLine) {
|
|
46378
46754
|
currentLine = {
|
|
46379
46755
|
fromRun: runIndex,
|
|
@@ -46424,12 +46800,12 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46424
46800
|
charPosInRun = spaceEndChar;
|
|
46425
46801
|
continue;
|
|
46426
46802
|
}
|
|
46427
|
-
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run);
|
|
46428
|
-
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
46429
|
-
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run) : 0;
|
|
46430
|
-
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
46431
46803
|
const wordStartChar = charPosInRun;
|
|
46804
|
+
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run, wordStartChar);
|
|
46805
|
+
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
46432
46806
|
const wordEndNoSpace = charPosInRun + word2.length;
|
|
46807
|
+
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run, wordEndNoSpace) : 0;
|
|
46808
|
+
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
46433
46809
|
const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
|
|
46434
46810
|
const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
|
|
46435
46811
|
if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
|
|
@@ -46448,7 +46824,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46448
46824
|
const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
46449
46825
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
46450
46826
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
46451
|
-
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run);
|
|
46827
|
+
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run, wordStartChar);
|
|
46452
46828
|
let chunkCharOffset = wordStartChar;
|
|
46453
46829
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
46454
46830
|
const chunk = chunks[chunkIndex];
|
|
@@ -46572,7 +46948,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46572
46948
|
if (candidateSpaces > 0) {
|
|
46573
46949
|
const overflow = totalWidthWithWord - availableWidth;
|
|
46574
46950
|
if (overflow > 0) {
|
|
46575
|
-
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run) || Math.max(1, boundarySpacing);
|
|
46951
|
+
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run, wordEndNoSpace) || Math.max(1, boundarySpacing);
|
|
46576
46952
|
const perSpaceCompression = overflow / candidateSpaces;
|
|
46577
46953
|
const maxPerSpaceCompression = baseSpaceWidth * 0.25;
|
|
46578
46954
|
if (perSpaceCompression <= maxPerSpaceCompression) {
|
|
@@ -46747,8 +47123,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
46747
47123
|
const { font: markerFont } = buildFontString(markerRun);
|
|
46748
47124
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
46749
47125
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
46750
|
-
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
46751
|
-
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);
|
|
46752
47128
|
markerInfo = {
|
|
46753
47129
|
markerWidth: markerBoxWidth,
|
|
46754
47130
|
markerTextWidth: glyphWidth,
|
|
@@ -47092,7 +47468,7 @@ async function measureListBlock(block, constraints) {
|
|
|
47092
47468
|
markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
47093
47469
|
indentLeft = resolveIndentLeft(item);
|
|
47094
47470
|
const indentHanging = resolveIndentHanging(item);
|
|
47095
|
-
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
|
|
47471
|
+
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
|
|
47096
47472
|
}
|
|
47097
47473
|
const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
|
|
47098
47474
|
const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
|
|
@@ -47118,16 +47494,46 @@ const getPrimaryRun = (paragraph) => {
|
|
|
47118
47494
|
fontSize: 16
|
|
47119
47495
|
};
|
|
47120
47496
|
};
|
|
47121
|
-
const
|
|
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) => {
|
|
47122
47525
|
const letterSpacing = run.kind === "text" || run.kind === void 0 ? run.letterSpacing || 0 : 0;
|
|
47123
|
-
const
|
|
47526
|
+
const displayText = applyTextTransform(text, run, startOffset);
|
|
47527
|
+
const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
|
|
47124
47528
|
return roundValue(width);
|
|
47125
47529
|
};
|
|
47126
|
-
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run) => {
|
|
47530
|
+
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run, startOffset) => {
|
|
47127
47531
|
const chunks = [];
|
|
47532
|
+
const baseOffset = typeof startOffset === "number" ? startOffset : 0;
|
|
47128
47533
|
if (maxWidth <= 0) {
|
|
47129
|
-
for (
|
|
47130
|
-
const
|
|
47534
|
+
for (let i = 0; i < word2.length; i++) {
|
|
47535
|
+
const char = word2[i];
|
|
47536
|
+
const charWidth = measureRunWidth(char, font, ctx2, run, baseOffset + i);
|
|
47131
47537
|
chunks.push({ text: char, width: charWidth });
|
|
47132
47538
|
}
|
|
47133
47539
|
return chunks;
|
|
@@ -47137,11 +47543,11 @@ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run) => {
|
|
|
47137
47543
|
for (let i = 0; i < word2.length; i++) {
|
|
47138
47544
|
const char = word2[i];
|
|
47139
47545
|
const testChunk = currentChunk + char;
|
|
47140
|
-
const testWidth = measureRunWidth(testChunk, font, ctx2, run);
|
|
47546
|
+
const testWidth = measureRunWidth(testChunk, font, ctx2, run, baseOffset);
|
|
47141
47547
|
if (testWidth > maxWidth && currentChunk.length > 0) {
|
|
47142
47548
|
chunks.push({ text: currentChunk, width: currentWidth });
|
|
47143
47549
|
currentChunk = char;
|
|
47144
|
-
currentWidth = measureRunWidth(char, font, ctx2, run);
|
|
47550
|
+
currentWidth = measureRunWidth(char, font, ctx2, run, baseOffset + i);
|
|
47145
47551
|
} else {
|
|
47146
47552
|
currentChunk = testChunk;
|
|
47147
47553
|
currentWidth = testWidth;
|
|
@@ -47195,7 +47601,8 @@ const measureDropCap = (ctx2, descriptor, spacing) => {
|
|
|
47195
47601
|
italic: run.italic
|
|
47196
47602
|
});
|
|
47197
47603
|
ctx2.font = font;
|
|
47198
|
-
const
|
|
47604
|
+
const displayText = applyTextTransform(run.text, run);
|
|
47605
|
+
const metrics = ctx2.measureText(displayText);
|
|
47199
47606
|
const advanceWidth = metrics.width;
|
|
47200
47607
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
47201
47608
|
const textWidth = Math.max(advanceWidth, paintedWidth);
|
|
@@ -47221,7 +47628,7 @@ const resolveIndentHanging = (item) => {
|
|
|
47221
47628
|
if (indentHanging > 0) {
|
|
47222
47629
|
return indentHanging;
|
|
47223
47630
|
}
|
|
47224
|
-
return DEFAULT_LIST_HANGING_PX;
|
|
47631
|
+
return DEFAULT_LIST_HANGING_PX$1;
|
|
47225
47632
|
};
|
|
47226
47633
|
const buildTabStopsPx = (indent, tabs, tabIntervalTwips) => {
|
|
47227
47634
|
const paragraphIndentTwips = {
|