@harbour-enterprises/superdoc 1.0.0-beta.95 → 1.0.0-beta.97
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-DC5ZtOHL.es.js → PdfViewer-BHcBfUWj.es.js} +1 -1
- package/dist/chunks/{PdfViewer--l9mxuw6.cjs → PdfViewer-YvkZg201.cjs} +1 -1
- package/dist/chunks/{index-DA6_gKCn.cjs → index-DZ_AI-HW.cjs} +3 -3
- package/dist/chunks/{index-D_AIVJix.es.js → index-DeQfFbTb.es.js} +3 -3
- package/dist/chunks/{index-DJD7xO_i-CVT8OSh8.cjs → index-Pvlqsxge-IH3eauKE.cjs} +1 -1
- package/dist/chunks/{index-DJD7xO_i-DlZGZmeW.es.js → index-Pvlqsxge-vW641SZt.es.js} +1 -1
- package/dist/chunks/{super-editor.es-DLfNMkAR.cjs → super-editor.es-BP3PKkwh.cjs} +244 -91
- package/dist/chunks/{super-editor.es-L0F8-awY.es.js → super-editor.es-BinyZw4F.es.js} +244 -91
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CAiO-oW4.js → converter-BEVM5t3i.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-DRP7HhmI.js → docx-zipper-vETk3IMG.js} +1 -1
- package/dist/super-editor/chunks/{editor-D5oQ83xJ.js → editor-B8k1bwD_.js} +245 -92
- package/dist/super-editor/chunks/{index-DJD7xO_i.js → index-Pvlqsxge.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-ax2sbcF_.js → toolbar-j1GSUGWU.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 +254 -101
- 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 _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-
|
|
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$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-BEVM5t3i.js";
|
|
16
|
+
import { D as DocxZipper } from "./docx-zipper-vETk3IMG.js";
|
|
17
17
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
@@ -13952,7 +13952,7 @@ const isHeadless = (editor) => {
|
|
|
13952
13952
|
const shouldSkipNodeView = (editor) => {
|
|
13953
13953
|
return isHeadless(editor);
|
|
13954
13954
|
};
|
|
13955
|
-
const summaryVersion = "1.0.0-beta.
|
|
13955
|
+
const summaryVersion = "1.0.0-beta.97";
|
|
13956
13956
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
13957
13957
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
13958
13958
|
function mapAttributes(attrs) {
|
|
@@ -14744,7 +14744,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14744
14744
|
{ default: remarkStringify },
|
|
14745
14745
|
{ default: remarkGfm }
|
|
14746
14746
|
] = await Promise.all([
|
|
14747
|
-
import("./index-
|
|
14747
|
+
import("./index-Pvlqsxge.js"),
|
|
14748
14748
|
import("./index-DRCvimau.js"),
|
|
14749
14749
|
import("./index-C_x_N6Uh.js"),
|
|
14750
14750
|
import("./index-D_sWOSiG.js"),
|
|
@@ -14949,7 +14949,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14949
14949
|
* Process collaboration migrations
|
|
14950
14950
|
*/
|
|
14951
14951
|
processCollaborationMigrations() {
|
|
14952
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
14952
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.97");
|
|
14953
14953
|
if (!this.options.ydoc) return;
|
|
14954
14954
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14955
14955
|
let docVersion = metaMap.get("version");
|
|
@@ -17361,12 +17361,12 @@ var SectionType = /* @__PURE__ */ ((SectionType2) => {
|
|
|
17361
17361
|
})(SectionType || {});
|
|
17362
17362
|
const DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage";
|
|
17363
17363
|
const DEFAULT_BODY_SECTION_TYPE = "continuous";
|
|
17364
|
-
const TWIPS_PER_INCH$
|
|
17365
|
-
const PX_PER_INCH$
|
|
17364
|
+
const TWIPS_PER_INCH$4 = 1440;
|
|
17365
|
+
const PX_PER_INCH$3 = 96;
|
|
17366
17366
|
const DEFAULT_COLUMN_GAP_INCHES = 0.5;
|
|
17367
17367
|
function twipsToPixels$1(twips) {
|
|
17368
17368
|
const n = Number(twips);
|
|
17369
|
-
return Number.isFinite(n) ? n / TWIPS_PER_INCH$
|
|
17369
|
+
return Number.isFinite(n) ? n / TWIPS_PER_INCH$4 * PX_PER_INCH$3 : void 0;
|
|
17370
17370
|
}
|
|
17371
17371
|
function parseColumnCount(rawValue) {
|
|
17372
17372
|
if (rawValue == null) return 1;
|
|
@@ -17376,7 +17376,7 @@ function parseColumnCount(rawValue) {
|
|
|
17376
17376
|
function parseColumnGap(gapTwips) {
|
|
17377
17377
|
if (gapTwips == null) return DEFAULT_COLUMN_GAP_INCHES;
|
|
17378
17378
|
const gap = Number(gapTwips);
|
|
17379
|
-
return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$
|
|
17379
|
+
return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$4 : DEFAULT_COLUMN_GAP_INCHES;
|
|
17380
17380
|
}
|
|
17381
17381
|
function extractNormalizedMargins(attrs) {
|
|
17382
17382
|
const sectionMargins = attrs.sectionMargins;
|
|
@@ -17460,7 +17460,7 @@ function extractColumns(elements) {
|
|
|
17460
17460
|
const gapInches = parseColumnGap(cols.attributes["w:space"]);
|
|
17461
17461
|
return {
|
|
17462
17462
|
count,
|
|
17463
|
-
gap: gapInches * PX_PER_INCH$
|
|
17463
|
+
gap: gapInches * PX_PER_INCH$3
|
|
17464
17464
|
};
|
|
17465
17465
|
}
|
|
17466
17466
|
function extractVerticalAlign(elements) {
|
|
@@ -17696,8 +17696,8 @@ function analyzeSectionRanges(doc2, bodySectPr) {
|
|
|
17696
17696
|
}
|
|
17697
17697
|
return ranges;
|
|
17698
17698
|
}
|
|
17699
|
-
const TWIPS_PER_INCH$
|
|
17700
|
-
const PX_PER_INCH$
|
|
17699
|
+
const TWIPS_PER_INCH$3 = 1440;
|
|
17700
|
+
const PX_PER_INCH$2 = 96;
|
|
17701
17701
|
const PX_PER_PT = 96 / 72;
|
|
17702
17702
|
SectionType.NEXT_PAGE;
|
|
17703
17703
|
SectionType.CONTINUOUS;
|
|
@@ -17836,7 +17836,7 @@ const applyTrackedChangesModeToRuns = (runs, config, hyperlinkConfig, applyMarks
|
|
|
17836
17836
|
}
|
|
17837
17837
|
return filtered;
|
|
17838
17838
|
};
|
|
17839
|
-
const twipsToPx$
|
|
17839
|
+
const twipsToPx$2 = (value) => value / TWIPS_PER_INCH$3 * PX_PER_INCH$2;
|
|
17840
17840
|
const ptToPx = (pt) => {
|
|
17841
17841
|
if (pt == null || !Number.isFinite(pt)) return void 0;
|
|
17842
17842
|
return pt * PX_PER_PT;
|
|
@@ -19346,8 +19346,8 @@ const normalizeParagraphSpacing = (value) => {
|
|
|
19346
19346
|
const beforeAutospacing = toBooleanFlag(source.beforeAutospacing ?? source.beforeAutoSpacing);
|
|
19347
19347
|
const afterAutospacing = toBooleanFlag(source.afterAutospacing ?? source.afterAutoSpacing);
|
|
19348
19348
|
const contextualSpacing = toBooleanFlag(source.contextualSpacing);
|
|
19349
|
-
const before = beforeRaw != null ? twipsToPx$
|
|
19350
|
-
const after = afterRaw != null ? twipsToPx$
|
|
19349
|
+
const before = beforeRaw != null ? twipsToPx$2(beforeRaw) : pickNumber(source.lineSpaceBefore);
|
|
19350
|
+
const after = afterRaw != null ? twipsToPx$2(afterRaw) : pickNumber(source.lineSpaceAfter);
|
|
19351
19351
|
const line = normalizeLineValue(lineRaw, lineRule);
|
|
19352
19352
|
if (before != null) spacing.before = before;
|
|
19353
19353
|
if (after != null) spacing.after = after;
|
|
@@ -19377,9 +19377,9 @@ const normalizeLineValue = (value, lineRule) => {
|
|
|
19377
19377
|
if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
|
|
19378
19378
|
return value;
|
|
19379
19379
|
}
|
|
19380
|
-
return twipsToPx$
|
|
19380
|
+
return twipsToPx$2(value);
|
|
19381
19381
|
}
|
|
19382
|
-
return twipsToPx$
|
|
19382
|
+
return twipsToPx$2(value);
|
|
19383
19383
|
};
|
|
19384
19384
|
const normalizeLineRule = (value) => {
|
|
19385
19385
|
if (value === "auto" || value === "exact" || value === "atLeast") {
|
|
@@ -19416,7 +19416,7 @@ const normalizeParagraphIndent = (value) => {
|
|
|
19416
19416
|
if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
|
|
19417
19417
|
return num;
|
|
19418
19418
|
}
|
|
19419
|
-
return twipsToPx$
|
|
19419
|
+
return twipsToPx$2(Number(num));
|
|
19420
19420
|
};
|
|
19421
19421
|
const left2 = convert(pickNumber(source.left));
|
|
19422
19422
|
const right2 = convert(pickNumber(source.right));
|
|
@@ -19996,9 +19996,9 @@ const buildFontCss = (run) => {
|
|
|
19996
19996
|
const family = run.fontFamily ?? "Times New Roman";
|
|
19997
19997
|
return `${style}${weight}${size} ${family}`;
|
|
19998
19998
|
};
|
|
19999
|
-
const TWIPS_PER_INCH$
|
|
19999
|
+
const TWIPS_PER_INCH$2 = 1440;
|
|
20000
20000
|
const PIXELS_PER_INCH = 96;
|
|
20001
|
-
const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$
|
|
20001
|
+
const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$2 / PIXELS_PER_INCH);
|
|
20002
20002
|
const PIXELS_PER_TWIP = 1 / TWIPS_PER_PIXEL;
|
|
20003
20003
|
const toFiniteNumber = (value) => {
|
|
20004
20004
|
if (value == null) return null;
|
|
@@ -21022,7 +21022,7 @@ const extractMarkerRun = (lvl) => {
|
|
|
21022
21022
|
}
|
|
21023
21023
|
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
21024
21024
|
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
21025
|
-
run.letterSpacing = twipsToPx$
|
|
21025
|
+
run.letterSpacing = twipsToPx$2(spacingTwips);
|
|
21026
21026
|
}
|
|
21027
21027
|
return Object.keys(run).length ? run : void 0;
|
|
21028
21028
|
};
|
|
@@ -21097,6 +21097,13 @@ const isTruthy = (value) => {
|
|
|
21097
21097
|
}
|
|
21098
21098
|
return false;
|
|
21099
21099
|
};
|
|
21100
|
+
const safeGetProperty = (obj, key2) => {
|
|
21101
|
+
if (!obj || typeof obj !== "object") {
|
|
21102
|
+
return void 0;
|
|
21103
|
+
}
|
|
21104
|
+
const record = obj;
|
|
21105
|
+
return record[key2];
|
|
21106
|
+
};
|
|
21100
21107
|
const isExplicitFalse = (value) => {
|
|
21101
21108
|
if (value === false || value === 0) return true;
|
|
21102
21109
|
if (typeof value === "string") {
|
|
@@ -21239,10 +21246,19 @@ const buildNumberingPath = (numId, ilvl, counterValue, listCounterContext) => {
|
|
|
21239
21246
|
const convertIndentTwipsToPx = (indent) => {
|
|
21240
21247
|
if (!indent) return void 0;
|
|
21241
21248
|
const result = {};
|
|
21242
|
-
|
|
21243
|
-
|
|
21244
|
-
|
|
21245
|
-
|
|
21249
|
+
const toNum = (v) => {
|
|
21250
|
+
if (typeof v === "string" && v.trim() !== "" && isFinite(Number(v))) return Number(v);
|
|
21251
|
+
if (isFiniteNumber(v)) return Number(v);
|
|
21252
|
+
return void 0;
|
|
21253
|
+
};
|
|
21254
|
+
const left2 = toNum(indent.left);
|
|
21255
|
+
const right2 = toNum(indent.right);
|
|
21256
|
+
const firstLine = toNum(indent.firstLine);
|
|
21257
|
+
const hanging = toNum(indent.hanging);
|
|
21258
|
+
if (left2 != null) result.left = twipsToPx$2(left2);
|
|
21259
|
+
if (right2 != null) result.right = twipsToPx$2(right2);
|
|
21260
|
+
if (firstLine != null) result.firstLine = twipsToPx$2(firstLine);
|
|
21261
|
+
if (hanging != null) result.hanging = twipsToPx$2(hanging);
|
|
21246
21262
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
21247
21263
|
};
|
|
21248
21264
|
const toAdapterNumberingProps = (value) => {
|
|
@@ -21267,7 +21283,7 @@ const toResolvedTabStops = (tabs) => {
|
|
|
21267
21283
|
if (!stop || typeof stop.pos !== "number") continue;
|
|
21268
21284
|
const alignment = normalizeResolvedTabAlignment(stop.val);
|
|
21269
21285
|
if (!alignment) continue;
|
|
21270
|
-
const position = twipsToPx$
|
|
21286
|
+
const position = twipsToPx$2(stop.pos);
|
|
21271
21287
|
if (!Number.isFinite(position)) continue;
|
|
21272
21288
|
const resolvedStop = {
|
|
21273
21289
|
position,
|
|
@@ -21589,8 +21605,9 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
21589
21605
|
paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
|
|
21590
21606
|
}
|
|
21591
21607
|
}
|
|
21592
|
-
|
|
21593
|
-
|
|
21608
|
+
const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing");
|
|
21609
|
+
if (contextualSpacingValue != null) {
|
|
21610
|
+
paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
|
|
21594
21611
|
}
|
|
21595
21612
|
const hasExplicitIndent = Boolean(normalizedIndent);
|
|
21596
21613
|
const hasNumberingIndent = Boolean(computed2.numbering?.indent?.left || computed2.numbering?.indent?.hanging);
|
|
@@ -21642,7 +21659,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
21642
21659
|
paragraphAttrs.tabs = normalizedTabs;
|
|
21643
21660
|
}
|
|
21644
21661
|
}
|
|
21645
|
-
const
|
|
21662
|
+
const asString2 = (value) => {
|
|
21646
21663
|
return typeof value === "string" ? value : void 0;
|
|
21647
21664
|
};
|
|
21648
21665
|
const normalizeFramePr = (value) => {
|
|
@@ -21665,7 +21682,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
21665
21682
|
};
|
|
21666
21683
|
const framePr = normalizeFramePr(attrs.framePr) ?? normalizeFramePr(attrs.paragraphProperties?.framePr) ?? extractFramePrFromElements(attrs.paragraphProperties);
|
|
21667
21684
|
if (framePr) {
|
|
21668
|
-
const rawXAlign =
|
|
21685
|
+
const rawXAlign = asString2(framePr["w:xAlign"] ?? framePr.xAlign);
|
|
21669
21686
|
const xAlign = typeof rawXAlign === "string" ? rawXAlign.toLowerCase() : void 0;
|
|
21670
21687
|
if (xAlign === "left" || xAlign === "right" || xAlign === "center") {
|
|
21671
21688
|
paragraphAttrs.floatAlignment = xAlign;
|
|
@@ -21675,7 +21692,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
21675
21692
|
paragraphAttrs.dropCap = dropCap;
|
|
21676
21693
|
const dropCapMode = typeof dropCap === "string" ? dropCap.toLowerCase() : "drop";
|
|
21677
21694
|
const linesValue = pickNumber(framePr["w:lines"] ?? framePr.lines);
|
|
21678
|
-
const wrapValue =
|
|
21695
|
+
const wrapValue = asString2(framePr["w:wrap"] ?? framePr.wrap);
|
|
21679
21696
|
const dropCapRunInfo = extractDropCapRunFromParagraph(para);
|
|
21680
21697
|
if (dropCapRunInfo) {
|
|
21681
21698
|
const descriptor = {
|
|
@@ -21693,23 +21710,23 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
21693
21710
|
}
|
|
21694
21711
|
}
|
|
21695
21712
|
const frame = {};
|
|
21696
|
-
const wrap =
|
|
21713
|
+
const wrap = asString2(framePr["w:wrap"] ?? framePr.wrap);
|
|
21697
21714
|
if (wrap) frame.wrap = wrap;
|
|
21698
21715
|
if (xAlign) {
|
|
21699
21716
|
frame.xAlign = xAlign;
|
|
21700
21717
|
}
|
|
21701
|
-
const rawYAlign =
|
|
21718
|
+
const rawYAlign = asString2(framePr["w:yAlign"] ?? framePr.yAlign);
|
|
21702
21719
|
if (rawYAlign) {
|
|
21703
21720
|
frame.yAlign = rawYAlign;
|
|
21704
21721
|
}
|
|
21705
|
-
const hAnchor =
|
|
21722
|
+
const hAnchor = asString2(framePr["w:hAnchor"] ?? framePr.hAnchor);
|
|
21706
21723
|
if (hAnchor) frame.hAnchor = hAnchor;
|
|
21707
|
-
const vAnchor =
|
|
21724
|
+
const vAnchor = asString2(framePr["w:vAnchor"] ?? framePr.vAnchor);
|
|
21708
21725
|
if (vAnchor) frame.vAnchor = vAnchor;
|
|
21709
21726
|
const xTwips = pickNumber(framePr["w:x"] ?? framePr.x);
|
|
21710
|
-
if (xTwips != null) frame.x = twipsToPx$
|
|
21727
|
+
if (xTwips != null) frame.x = twipsToPx$2(xTwips);
|
|
21711
21728
|
const yTwips = pickNumber(framePr["w:y"] ?? framePr.y);
|
|
21712
|
-
if (yTwips != null) frame.y = twipsToPx$
|
|
21729
|
+
if (yTwips != null) frame.y = twipsToPx$2(yTwips);
|
|
21713
21730
|
if (Object.keys(frame).length > 0) {
|
|
21714
21731
|
paragraphAttrs.frame = frame;
|
|
21715
21732
|
}
|
|
@@ -21797,7 +21814,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
21797
21814
|
}
|
|
21798
21815
|
}
|
|
21799
21816
|
}
|
|
21800
|
-
|
|
21817
|
+
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
21818
|
+
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
21819
|
+
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
21820
|
+
const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
|
|
21821
|
+
if (firstLinePx > 0) {
|
|
21822
|
+
wordLayout = {
|
|
21823
|
+
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
21824
|
+
firstLineIndentMode: true,
|
|
21825
|
+
textStartPx: firstLinePx
|
|
21826
|
+
};
|
|
21827
|
+
}
|
|
21828
|
+
}
|
|
21829
|
+
if (wordLayout && (!wordLayout.textStartPx || !Number.isFinite(wordLayout.textStartPx)) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
21830
|
+
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
21831
|
+
const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
|
|
21832
|
+
if (firstLinePx > 0) {
|
|
21833
|
+
wordLayout = {
|
|
21834
|
+
...wordLayout,
|
|
21835
|
+
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
21836
|
+
textStartPx: firstLinePx
|
|
21837
|
+
};
|
|
21838
|
+
}
|
|
21839
|
+
}
|
|
21801
21840
|
if (wordLayout) {
|
|
21802
21841
|
if (wordLayout.marker) {
|
|
21803
21842
|
if (listRendering?.markerText) {
|
|
@@ -23708,7 +23747,7 @@ const measurementToPx = (value) => {
|
|
|
23708
23747
|
const entry = value;
|
|
23709
23748
|
if (typeof entry.value !== "number") return void 0;
|
|
23710
23749
|
if (!entry.type || entry.type === "px" || entry.type === "pixel") return entry.value;
|
|
23711
|
-
if (entry.type === "dxa") return twipsToPx$
|
|
23750
|
+
if (entry.type === "dxa") return twipsToPx$2(entry.value);
|
|
23712
23751
|
return void 0;
|
|
23713
23752
|
};
|
|
23714
23753
|
const normalizeTableWidth = (value) => {
|
|
@@ -23720,7 +23759,7 @@ const normalizeTableWidth = (value) => {
|
|
|
23720
23759
|
return { width: raw, type: measurement.type ?? "px" };
|
|
23721
23760
|
}
|
|
23722
23761
|
if (measurement.type === "dxa") {
|
|
23723
|
-
return { width: twipsToPx$
|
|
23762
|
+
return { width: twipsToPx$2(raw), type: "px" };
|
|
23724
23763
|
}
|
|
23725
23764
|
return { width: raw, type: measurement.type };
|
|
23726
23765
|
};
|
|
@@ -23748,13 +23787,13 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
|
|
|
23748
23787
|
const line = parseIntSafe$1(attrs["w:line"]);
|
|
23749
23788
|
const rawLineRule = attrs["w:lineRule"];
|
|
23750
23789
|
const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
|
|
23751
|
-
if (before != null) spacing.before = twipsToPx$
|
|
23752
|
-
if (after != null) spacing.after = twipsToPx$
|
|
23790
|
+
if (before != null) spacing.before = twipsToPx$2(before);
|
|
23791
|
+
if (after != null) spacing.after = twipsToPx$2(after);
|
|
23753
23792
|
if (line != null) {
|
|
23754
23793
|
if (lineRule === "auto") {
|
|
23755
23794
|
spacing.line = line / 240;
|
|
23756
23795
|
} else {
|
|
23757
|
-
spacing.line = twipsToPx$
|
|
23796
|
+
spacing.line = twipsToPx$2(line);
|
|
23758
23797
|
}
|
|
23759
23798
|
}
|
|
23760
23799
|
if (lineRule) spacing.lineRule = lineRule;
|
|
@@ -23780,7 +23819,7 @@ const normalizeRowHeight = (rowProps) => {
|
|
|
23780
23819
|
if (rawValue == null) return void 0;
|
|
23781
23820
|
const rawRule = heightObj.rule ?? heightObj.hRule;
|
|
23782
23821
|
const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
|
|
23783
|
-
const valuePx = twipsToPx$
|
|
23822
|
+
const valuePx = twipsToPx$2(rawValue);
|
|
23784
23823
|
return {
|
|
23785
23824
|
value: valuePx,
|
|
23786
23825
|
rule
|
|
@@ -24030,10 +24069,10 @@ function extractFloatingTableAnchorWrap(node) {
|
|
|
24030
24069
|
anchor.alignV = floatingProps.tblpYSpec;
|
|
24031
24070
|
}
|
|
24032
24071
|
if (floatingProps.tblpX !== void 0) {
|
|
24033
|
-
anchor.offsetH = twipsToPx$
|
|
24072
|
+
anchor.offsetH = twipsToPx$2(floatingProps.tblpX);
|
|
24034
24073
|
}
|
|
24035
24074
|
if (floatingProps.tblpY !== void 0) {
|
|
24036
|
-
anchor.offsetV = twipsToPx$
|
|
24075
|
+
anchor.offsetV = twipsToPx$2(floatingProps.tblpY);
|
|
24037
24076
|
}
|
|
24038
24077
|
const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
|
|
24039
24078
|
const wrap = {
|
|
@@ -24044,16 +24083,16 @@ function extractFloatingTableAnchorWrap(node) {
|
|
|
24044
24083
|
};
|
|
24045
24084
|
if (hasDistances) {
|
|
24046
24085
|
if (floatingProps.topFromText !== void 0) {
|
|
24047
|
-
wrap.distTop = twipsToPx$
|
|
24086
|
+
wrap.distTop = twipsToPx$2(floatingProps.topFromText);
|
|
24048
24087
|
}
|
|
24049
24088
|
if (floatingProps.bottomFromText !== void 0) {
|
|
24050
|
-
wrap.distBottom = twipsToPx$
|
|
24089
|
+
wrap.distBottom = twipsToPx$2(floatingProps.bottomFromText);
|
|
24051
24090
|
}
|
|
24052
24091
|
if (floatingProps.leftFromText !== void 0) {
|
|
24053
|
-
wrap.distLeft = twipsToPx$
|
|
24092
|
+
wrap.distLeft = twipsToPx$2(floatingProps.leftFromText);
|
|
24054
24093
|
}
|
|
24055
24094
|
if (floatingProps.rightFromText !== void 0) {
|
|
24056
|
-
wrap.distRight = twipsToPx$
|
|
24095
|
+
wrap.distRight = twipsToPx$2(floatingProps.rightFromText);
|
|
24057
24096
|
}
|
|
24058
24097
|
}
|
|
24059
24098
|
return { anchor, wrap };
|
|
@@ -31226,7 +31265,7 @@ const _DomPainter = class _DomPainter {
|
|
|
31226
31265
|
}
|
|
31227
31266
|
const runsForLine = sliceRunsForLine(block, line);
|
|
31228
31267
|
const trackedConfig = this.resolveTrackedChangesConfig(block);
|
|
31229
|
-
|
|
31268
|
+
runsForLine.length > 0 ? runsForLine.filter((r2) => (r2.kind === "text" || r2.kind === void 0) && "text" in r2 && r2.text != null).map((r2) => r2.text) : gatherTextSlicesForLine(block, line);
|
|
31230
31269
|
if (runsForLine.length === 0) {
|
|
31231
31270
|
const span = this.doc.createElement("span");
|
|
31232
31271
|
span.innerHTML = " ";
|
|
@@ -31273,19 +31312,7 @@ const _DomPainter = class _DomPainter {
|
|
|
31273
31312
|
});
|
|
31274
31313
|
}
|
|
31275
31314
|
const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
31276
|
-
|
|
31277
|
-
const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
|
|
31278
|
-
if (shouldJustify) {
|
|
31279
|
-
const spaceCount = textSlices.reduce(
|
|
31280
|
-
(sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
|
|
31281
|
-
0
|
|
31282
|
-
);
|
|
31283
|
-
const slack = availableWidth - line.width;
|
|
31284
|
-
if (spaceCount > 0 && slack !== 0) {
|
|
31285
|
-
const spacingPerSpace = slack / spaceCount;
|
|
31286
|
-
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
31287
|
-
}
|
|
31288
|
-
}
|
|
31315
|
+
availableWidthOverride ?? line.maxWidth ?? line.width;
|
|
31289
31316
|
if (hasExplicitPositioning && line.segments) {
|
|
31290
31317
|
const paraIndent = block.attrs?.indent;
|
|
31291
31318
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -33448,6 +33475,32 @@ const extractBlockPmRange = (block) => {
|
|
|
33448
33475
|
pmEnd: end2 ?? (start2 != null ? start2 + 1 : void 0)
|
|
33449
33476
|
};
|
|
33450
33477
|
};
|
|
33478
|
+
const getParagraphAttrs = (block) => {
|
|
33479
|
+
if (!block.attrs || typeof block.attrs !== "object") {
|
|
33480
|
+
return void 0;
|
|
33481
|
+
}
|
|
33482
|
+
return block.attrs;
|
|
33483
|
+
};
|
|
33484
|
+
const asString = (value) => {
|
|
33485
|
+
return typeof value === "string" ? value : void 0;
|
|
33486
|
+
};
|
|
33487
|
+
const asBoolean = (value) => {
|
|
33488
|
+
if (value === true || value === 1) return true;
|
|
33489
|
+
if (typeof value === "string") {
|
|
33490
|
+
const normalized = value.toLowerCase();
|
|
33491
|
+
return normalized === "true" || normalized === "1" || normalized === "on";
|
|
33492
|
+
}
|
|
33493
|
+
return false;
|
|
33494
|
+
};
|
|
33495
|
+
const asSafeNumber = (value) => {
|
|
33496
|
+
if (typeof value !== "number") {
|
|
33497
|
+
return 0;
|
|
33498
|
+
}
|
|
33499
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
33500
|
+
return 0;
|
|
33501
|
+
}
|
|
33502
|
+
return value;
|
|
33503
|
+
};
|
|
33451
33504
|
function calculateFirstLineIndent(block, measure) {
|
|
33452
33505
|
const wordLayout = block.attrs?.wordLayout;
|
|
33453
33506
|
if (!wordLayout?.firstLineIndentMode) {
|
|
@@ -33465,7 +33518,8 @@ function calculateFirstLineIndent(block, measure) {
|
|
|
33465
33518
|
function layoutParagraphBlock(ctx2, anchors) {
|
|
33466
33519
|
const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx2;
|
|
33467
33520
|
const remeasureParagraph2 = ctx2.remeasureParagraph;
|
|
33468
|
-
const
|
|
33521
|
+
const blockAttrs = getParagraphAttrs(block);
|
|
33522
|
+
const frame = blockAttrs?.frame;
|
|
33469
33523
|
if (anchors?.anchoredDrawings?.length) {
|
|
33470
33524
|
for (const entry of anchors.anchoredDrawings) {
|
|
33471
33525
|
if (anchors.placedAnchoredIds.has(entry.block.id)) continue;
|
|
@@ -33590,9 +33644,10 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
33590
33644
|
didRemeasureForColumnWidth = true;
|
|
33591
33645
|
}
|
|
33592
33646
|
let fromLine = 0;
|
|
33593
|
-
const
|
|
33594
|
-
const
|
|
33595
|
-
const
|
|
33647
|
+
const attrs = getParagraphAttrs(block);
|
|
33648
|
+
const spacing = attrs?.spacing ?? {};
|
|
33649
|
+
const styleId = asString(attrs?.styleId);
|
|
33650
|
+
const contextualSpacing = asBoolean(attrs?.contextualSpacing);
|
|
33596
33651
|
let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
|
|
33597
33652
|
const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
|
|
33598
33653
|
let appliedSpacingBefore = spacingBefore === 0;
|
|
@@ -33673,14 +33728,13 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
33673
33728
|
while (fromLine < lines.length) {
|
|
33674
33729
|
let state = ensurePage();
|
|
33675
33730
|
if (state.trailingSpacing == null) state.trailingSpacing = 0;
|
|
33676
|
-
if (contextualSpacing) {
|
|
33677
|
-
const prevStyle = state.lastParagraphStyleId;
|
|
33678
|
-
if (styleId && prevStyle && prevStyle === styleId) {
|
|
33679
|
-
spacingBefore = 0;
|
|
33680
|
-
}
|
|
33681
|
-
}
|
|
33682
33731
|
if (contextualSpacing && state.lastParagraphStyleId && styleId && state.lastParagraphStyleId === styleId) {
|
|
33683
33732
|
spacingBefore = 0;
|
|
33733
|
+
const prevTrailing = asSafeNumber(state.trailingSpacing);
|
|
33734
|
+
if (prevTrailing > 0) {
|
|
33735
|
+
state.cursorY -= prevTrailing;
|
|
33736
|
+
state.trailingSpacing = 0;
|
|
33737
|
+
}
|
|
33684
33738
|
}
|
|
33685
33739
|
if (!appliedSpacingBefore && spacingBefore > 0) {
|
|
33686
33740
|
while (!appliedSpacingBefore) {
|
|
@@ -36580,7 +36634,13 @@ function getCtx() {
|
|
|
36580
36634
|
return ctx;
|
|
36581
36635
|
}
|
|
36582
36636
|
function isTextRun(run) {
|
|
36583
|
-
|
|
36637
|
+
if (run.kind === "tab" || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation") {
|
|
36638
|
+
return false;
|
|
36639
|
+
}
|
|
36640
|
+
if ("src" in run) {
|
|
36641
|
+
return false;
|
|
36642
|
+
}
|
|
36643
|
+
return true;
|
|
36584
36644
|
}
|
|
36585
36645
|
function fontString(run) {
|
|
36586
36646
|
const textRun = isTextRun(run) ? run : null;
|
|
@@ -36593,6 +36653,42 @@ function fontString(run) {
|
|
|
36593
36653
|
function runText(run) {
|
|
36594
36654
|
return "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
|
|
36595
36655
|
}
|
|
36656
|
+
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
36657
|
+
const TWIPS_PER_INCH$1 = 1440;
|
|
36658
|
+
const PX_PER_INCH$1 = 96;
|
|
36659
|
+
const TWIPS_PER_PX$1 = TWIPS_PER_INCH$1 / PX_PER_INCH$1;
|
|
36660
|
+
const TAB_EPSILON$1 = 0.1;
|
|
36661
|
+
const WIDTH_FUDGE_PX = 0.5;
|
|
36662
|
+
const twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$1;
|
|
36663
|
+
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
36664
|
+
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
36665
|
+
const paragraphIndentTwips = {
|
|
36666
|
+
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
36667
|
+
right: pxToTwips$1(Math.max(0, indent?.right ?? 0)),
|
|
36668
|
+
firstLine: pxToTwips$1(Math.max(0, indent?.firstLine ?? 0)),
|
|
36669
|
+
hanging: pxToTwips$1(Math.max(0, indent?.hanging ?? 0))
|
|
36670
|
+
};
|
|
36671
|
+
const stops = computeTabStops$1({
|
|
36672
|
+
explicitStops: tabs ?? [],
|
|
36673
|
+
defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
|
|
36674
|
+
paragraphIndent: paragraphIndentTwips
|
|
36675
|
+
});
|
|
36676
|
+
return stops.map((stop) => ({
|
|
36677
|
+
pos: twipsToPx$1(stop.pos),
|
|
36678
|
+
val: stop.val,
|
|
36679
|
+
leader: stop.leader
|
|
36680
|
+
}));
|
|
36681
|
+
};
|
|
36682
|
+
const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
36683
|
+
let index2 = startIndex;
|
|
36684
|
+
while (index2 < tabStops.length && tabStops[index2].pos <= currentX + TAB_EPSILON$1) {
|
|
36685
|
+
index2 += 1;
|
|
36686
|
+
}
|
|
36687
|
+
if (index2 < tabStops.length) {
|
|
36688
|
+
return { target: tabStops[index2].pos, nextIndex: index2 + 1 };
|
|
36689
|
+
}
|
|
36690
|
+
return { target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1), nextIndex: index2 };
|
|
36691
|
+
};
|
|
36596
36692
|
function measureRunSliceWidth(run, fromChar, toChar) {
|
|
36597
36693
|
const context = getCtx();
|
|
36598
36694
|
const text = runText(run).slice(fromChar, toChar);
|
|
@@ -36616,13 +36712,38 @@ function lineHeightForRuns(runs, fromRun, toRun) {
|
|
|
36616
36712
|
return maxSize2 * 1.2;
|
|
36617
36713
|
}
|
|
36618
36714
|
function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
36715
|
+
if (!Number.isFinite(maxWidth) || maxWidth <= 0) {
|
|
36716
|
+
throw new Error(`remeasureParagraph: maxWidth must be a positive number, got ${maxWidth}`);
|
|
36717
|
+
}
|
|
36718
|
+
if (!Number.isFinite(firstLineIndent)) {
|
|
36719
|
+
throw new Error(`remeasureParagraph: firstLineIndent must be a finite number, got ${firstLineIndent}`);
|
|
36720
|
+
}
|
|
36721
|
+
if (!block) {
|
|
36722
|
+
throw new Error("remeasureParagraph: block must be defined");
|
|
36723
|
+
}
|
|
36724
|
+
if (!Array.isArray(block.runs)) {
|
|
36725
|
+
throw new Error(`remeasureParagraph: block.runs must be an array, got ${typeof block.runs}`);
|
|
36726
|
+
}
|
|
36619
36727
|
const runs = block.runs ?? [];
|
|
36620
36728
|
const lines = [];
|
|
36729
|
+
const attrs = block.attrs;
|
|
36730
|
+
const indent = attrs?.indent;
|
|
36731
|
+
const wordLayout = attrs?.wordLayout;
|
|
36732
|
+
const indentLeft = Math.max(0, indent?.left ?? 0);
|
|
36733
|
+
const indentRight = Math.max(0, indent?.right ?? 0);
|
|
36734
|
+
const indentFirstLine = Math.max(0, indent?.firstLine ?? 0);
|
|
36735
|
+
const indentHanging = Math.max(0, indent?.hanging ?? 0);
|
|
36736
|
+
const rawFirstLineOffset = Math.max(0, firstLineIndent || indentFirstLine - indentHanging);
|
|
36737
|
+
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
36738
|
+
const textStartPx = wordLayout?.textStartPx;
|
|
36739
|
+
const treatAsHanging = textStartPx && indentLeft === 0 && indentHanging === 0;
|
|
36740
|
+
const firstLineWidth = typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - textStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
36741
|
+
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
36621
36742
|
let currentRun = 0;
|
|
36622
36743
|
let currentChar = 0;
|
|
36623
36744
|
while (currentRun < runs.length) {
|
|
36624
36745
|
const isFirstLine = lines.length === 0;
|
|
36625
|
-
const effectiveMaxWidth = isFirstLine ?
|
|
36746
|
+
const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
|
|
36626
36747
|
const startRun = currentRun;
|
|
36627
36748
|
const startChar = currentChar;
|
|
36628
36749
|
let width = 0;
|
|
@@ -36630,13 +36751,26 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
36630
36751
|
let lastBreakChar = -1;
|
|
36631
36752
|
let endRun = currentRun;
|
|
36632
36753
|
let endChar = currentChar;
|
|
36754
|
+
let tabStopCursor = 0;
|
|
36755
|
+
let didBreakInThisLine = false;
|
|
36633
36756
|
for (let r2 = currentRun; r2 < runs.length; r2 += 1) {
|
|
36634
36757
|
const run = runs[r2];
|
|
36758
|
+
if (run.kind === "tab") {
|
|
36759
|
+
const { target, nextIndex } = getNextTabStopPx$1(width, tabStops, tabStopCursor);
|
|
36760
|
+
const tabAdvance = Math.max(0, target - width);
|
|
36761
|
+
width += tabAdvance;
|
|
36762
|
+
tabStopCursor = nextIndex;
|
|
36763
|
+
endRun = r2;
|
|
36764
|
+
endChar = 1;
|
|
36765
|
+
lastBreakRun = r2;
|
|
36766
|
+
lastBreakChar = 1;
|
|
36767
|
+
continue;
|
|
36768
|
+
}
|
|
36635
36769
|
const text = runText(run);
|
|
36636
36770
|
const start2 = r2 === currentRun ? currentChar : 0;
|
|
36637
36771
|
for (let c = start2; c < text.length; c += 1) {
|
|
36638
36772
|
const w = measureRunSliceWidth(run, c, c + 1);
|
|
36639
|
-
if (width + w > effectiveMaxWidth && width > 0) {
|
|
36773
|
+
if (width + w > effectiveMaxWidth - WIDTH_FUDGE_PX && width > 0) {
|
|
36640
36774
|
if (lastBreakRun >= 0) {
|
|
36641
36775
|
endRun = lastBreakRun;
|
|
36642
36776
|
endChar = lastBreakChar;
|
|
@@ -36644,6 +36778,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
36644
36778
|
endRun = r2;
|
|
36645
36779
|
endChar = c;
|
|
36646
36780
|
}
|
|
36781
|
+
didBreakInThisLine = true;
|
|
36647
36782
|
break;
|
|
36648
36783
|
}
|
|
36649
36784
|
width += w;
|
|
@@ -36655,9 +36790,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
36655
36790
|
lastBreakChar = c + 1;
|
|
36656
36791
|
}
|
|
36657
36792
|
}
|
|
36658
|
-
if (
|
|
36659
|
-
break;
|
|
36660
|
-
}
|
|
36793
|
+
if (didBreakInThisLine) break;
|
|
36661
36794
|
}
|
|
36662
36795
|
if (startRun === endRun && startChar === endChar) {
|
|
36663
36796
|
endRun = startRun;
|
|
@@ -36671,11 +36804,15 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
36671
36804
|
width,
|
|
36672
36805
|
ascent: 0,
|
|
36673
36806
|
descent: 0,
|
|
36674
|
-
lineHeight: lineHeightForRuns(runs, startRun, endRun)
|
|
36807
|
+
lineHeight: lineHeightForRuns(runs, startRun, endRun),
|
|
36808
|
+
maxWidth: effectiveMaxWidth
|
|
36675
36809
|
};
|
|
36676
36810
|
lines.push(line);
|
|
36677
36811
|
currentRun = endRun;
|
|
36678
36812
|
currentChar = endChar;
|
|
36813
|
+
if (currentRun >= runs.length) {
|
|
36814
|
+
break;
|
|
36815
|
+
}
|
|
36679
36816
|
if (currentChar >= runText(runs[currentRun]).length) {
|
|
36680
36817
|
currentRun += 1;
|
|
36681
36818
|
currentChar = 0;
|
|
@@ -38888,7 +39025,7 @@ async function measureBlock(block, constraints) {
|
|
|
38888
39025
|
async function measureParagraphBlock(block, maxWidth) {
|
|
38889
39026
|
const ctx2 = getCanvasContext();
|
|
38890
39027
|
const wordLayout = block.attrs?.wordLayout;
|
|
38891
|
-
const
|
|
39028
|
+
const WIDTH_FUDGE_PX2 = 0.5;
|
|
38892
39029
|
const lines = [];
|
|
38893
39030
|
const indent = block.attrs?.indent;
|
|
38894
39031
|
const spacing = block.attrs?.spacing;
|
|
@@ -38904,7 +39041,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
38904
39041
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
38905
39042
|
let initialAvailableWidth;
|
|
38906
39043
|
const textStartPx = wordLayout?.textStartPx;
|
|
38907
|
-
|
|
39044
|
+
const treatAsHanging = isWordLayoutList && indentLeft === 0 && hanging === 0 && typeof textStartPx === "number";
|
|
39045
|
+
if (typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging) {
|
|
38908
39046
|
initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
|
|
38909
39047
|
} else {
|
|
38910
39048
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
@@ -38951,6 +39089,21 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
38951
39089
|
totalHeight: metrics.lineHeight
|
|
38952
39090
|
};
|
|
38953
39091
|
}
|
|
39092
|
+
const isListLike = Boolean(block.attrs?.numId || wordLayout?.marker);
|
|
39093
|
+
if (isListLike) {
|
|
39094
|
+
console.log(
|
|
39095
|
+
"[measureParagraph][list]",
|
|
39096
|
+
JSON.stringify({
|
|
39097
|
+
blockId: block.id,
|
|
39098
|
+
maxWidth,
|
|
39099
|
+
indentLeft,
|
|
39100
|
+
indentRight,
|
|
39101
|
+
textStartPx: textStartPx ?? null,
|
|
39102
|
+
firstLineOffset: firstLineOffset ?? null,
|
|
39103
|
+
initialAvailableWidth
|
|
39104
|
+
})
|
|
39105
|
+
);
|
|
39106
|
+
}
|
|
38954
39107
|
let currentLine = null;
|
|
38955
39108
|
const getEffectiveWidth = (baseWidth) => {
|
|
38956
39109
|
if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
|
|
@@ -39358,7 +39511,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39358
39511
|
};
|
|
39359
39512
|
} else {
|
|
39360
39513
|
const boundarySpacing = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
|
|
39361
|
-
if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth -
|
|
39514
|
+
if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
|
|
39362
39515
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
39363
39516
|
const { spaceCount: _sc, ...lineBase } = currentLine;
|
|
39364
39517
|
const completedLine = {
|
|
@@ -39424,7 +39577,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39424
39577
|
};
|
|
39425
39578
|
} else {
|
|
39426
39579
|
const boundarySpacing2 = currentLine.width > 0 ? run.letterSpacing ?? 0 : 0;
|
|
39427
|
-
if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth -
|
|
39580
|
+
if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
|
|
39428
39581
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
39429
39582
|
const { spaceCount: _sc, ...lineBase } = currentLine;
|
|
39430
39583
|
const completedLine = { ...lineBase, ...metrics };
|
|
@@ -39482,7 +39635,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39482
39635
|
const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
39483
39636
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
39484
39637
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
39485
|
-
const chunks = breakWordIntoChunks(word, chunkWidth -
|
|
39638
|
+
const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run);
|
|
39486
39639
|
let chunkCharOffset = wordStartChar;
|
|
39487
39640
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
39488
39641
|
const chunk = chunks[chunkIndex];
|
|
@@ -39504,7 +39657,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39504
39657
|
});
|
|
39505
39658
|
if (isLastChunk) {
|
|
39506
39659
|
const ls = run.letterSpacing ?? 0;
|
|
39507
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
39660
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
39508
39661
|
currentLine.toChar = wordEndWithSpace;
|
|
39509
39662
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
39510
39663
|
charPosInRun = wordEndWithSpace;
|
|
@@ -39536,7 +39689,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39536
39689
|
spaceCount: 0
|
|
39537
39690
|
};
|
|
39538
39691
|
const ls = run.letterSpacing ?? 0;
|
|
39539
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
39692
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
39540
39693
|
currentLine.toChar = wordEndWithSpace;
|
|
39541
39694
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
39542
39695
|
charPosInRun = wordEndWithSpace;
|
|
@@ -39578,7 +39731,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39578
39731
|
spaceCount: 0
|
|
39579
39732
|
};
|
|
39580
39733
|
const ls = run.letterSpacing ?? 0;
|
|
39581
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
39734
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
39582
39735
|
currentLine.toChar = wordEndWithSpace;
|
|
39583
39736
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
39584
39737
|
charPosInRun = wordEndWithSpace;
|
|
@@ -39593,7 +39746,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39593
39746
|
const justifyAlignment = block.attrs?.alignment === "justify";
|
|
39594
39747
|
const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
|
|
39595
39748
|
(isLastWord ? 0 : run.letterSpacing ?? 0);
|
|
39596
|
-
const availableWidth = currentLine.maxWidth -
|
|
39749
|
+
const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
|
|
39597
39750
|
let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
|
|
39598
39751
|
let compressedWidth = null;
|
|
39599
39752
|
if (shouldBreak && justifyAlignment) {
|
|
@@ -39638,7 +39791,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39638
39791
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
|
|
39639
39792
|
spaceCount: 0
|
|
39640
39793
|
};
|
|
39641
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
39794
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
39642
39795
|
currentLine.toChar = wordEndWithSpace;
|
|
39643
39796
|
currentLine.width = roundValue(currentLine.width + spaceWidth + (run.letterSpacing ?? 0));
|
|
39644
39797
|
charPosInRun = wordEndWithSpace;
|
|
@@ -39648,7 +39801,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
39648
39801
|
}
|
|
39649
39802
|
} else {
|
|
39650
39803
|
currentLine.toRun = runIndex;
|
|
39651
|
-
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth -
|
|
39804
|
+
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
39652
39805
|
currentLine.toChar = wordEndNoSpace;
|
|
39653
39806
|
currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
|
|
39654
39807
|
currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
|