@harbour-enterprises/superdoc 1.0.0-beta.97 → 1.0.0-beta.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/chunks/{PdfViewer-YvkZg201.cjs → PdfViewer-BtuTHUW7.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BHcBfUWj.es.js → PdfViewer-DF-v5Yrr.es.js} +1 -1
  3. package/dist/chunks/{index-Pvlqsxge-IH3eauKE.cjs → index-BB0msI45-CPU6Ak2R.cjs} +1 -1
  4. package/dist/chunks/{index-Pvlqsxge-vW641SZt.es.js → index-BB0msI45-DUPBw4Bh.es.js} +1 -1
  5. package/dist/chunks/{index-DZ_AI-HW.cjs → index-BBu9BBvp.cjs} +5 -14
  6. package/dist/chunks/{index-DeQfFbTb.es.js → index-CJy3FxL7.es.js} +5 -14
  7. package/dist/chunks/{super-editor.es-BinyZw4F.es.js → super-editor.es-BiaFIbw-.es.js} +242 -160
  8. package/dist/chunks/{super-editor.es-BP3PKkwh.cjs → super-editor.es-C04sFzVD.cjs} +242 -160
  9. package/dist/style.css +6 -6
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-BEVM5t3i.js → converter-B_cVJPnh.js} +1 -1
  12. package/dist/super-editor/chunks/{docx-zipper-vETk3IMG.js → docx-zipper-fPWx7kV0.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-B8k1bwD_.js → editor-DS9z42Je.js} +243 -161
  14. package/dist/super-editor/chunks/{index-Pvlqsxge.js → index-BB0msI45.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-j1GSUGWU.js → toolbar-aIFlIr6h.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/super-editor.es.js +6 -6
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +246 -173
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -12,8 +12,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _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-BEVM5t3i.js";
16
- import { D as DocxZipper } from "./docx-zipper-vETk3IMG.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-B_cVJPnh.js";
16
+ import { D as DocxZipper } from "./docx-zipper-fPWx7kV0.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.97";
13955
+ const summaryVersion = "1.0.0-beta.99";
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-Pvlqsxge.js"),
14747
+ import("./index-BB0msI45.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.97");
14952
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.99");
14953
14953
  if (!this.options.ydoc) return;
14954
14954
  const metaMap = this.options.ydoc.getMap("meta");
14955
14955
  let docVersion = metaMap.get("version");
@@ -17415,14 +17415,15 @@ function extractPageSizeAndOrientation(elements) {
17415
17415
  return { pageSizePx, orientation };
17416
17416
  }
17417
17417
  function extractFallbackMargins(elements, currentHeader, currentFooter) {
17418
- if (currentHeader !== void 0 && currentFooter !== void 0) {
17419
- return { headerPx: currentHeader, footerPx: currentFooter };
17420
- }
17421
17418
  const pgMar = elements.find((el) => el?.name === "w:pgMar");
17422
17419
  const a = pgMar?.attributes || {};
17423
17420
  return {
17424
17421
  headerPx: currentHeader ?? (a["w:header"] != null ? twipsToPixels$1(a["w:header"]) : void 0),
17425
- footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0)
17422
+ footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0),
17423
+ topPx: a["w:top"] != null ? twipsToPixels$1(a["w:top"]) : void 0,
17424
+ rightPx: a["w:right"] != null ? twipsToPixels$1(a["w:right"]) : void 0,
17425
+ bottomPx: a["w:bottom"] != null ? twipsToPixels$1(a["w:bottom"]) : void 0,
17426
+ leftPx: a["w:left"] != null ? twipsToPixels$1(a["w:left"]) : void 0
17426
17427
  };
17427
17428
  }
17428
17429
  function extractHeaderFooterRefs(elements, refName) {
@@ -17483,7 +17484,10 @@ function extractSectionData(para) {
17483
17484
  const type = extractSectionType(sectPrElements);
17484
17485
  const { pageSizePx, orientation } = extractPageSizeAndOrientation(sectPrElements);
17485
17486
  const titlePg = sectPrElements.some((el) => el?.name === "w:titlePg");
17486
- ({ headerPx, footerPx } = extractFallbackMargins(sectPrElements, headerPx, footerPx));
17487
+ const fallbackMargins = extractFallbackMargins(sectPrElements, headerPx, footerPx);
17488
+ headerPx = fallbackMargins.headerPx;
17489
+ footerPx = fallbackMargins.footerPx;
17490
+ const { topPx, rightPx, bottomPx, leftPx } = fallbackMargins;
17487
17491
  const headerRefs = extractHeaderFooterRefs(sectPrElements, "w:headerReference");
17488
17492
  const footerRefs = extractHeaderFooterRefs(sectPrElements, "w:footerReference");
17489
17493
  const numbering = extractPageNumbering(sectPrElements);
@@ -17492,6 +17496,10 @@ function extractSectionData(para) {
17492
17496
  return {
17493
17497
  headerPx,
17494
17498
  footerPx,
17499
+ topPx,
17500
+ rightPx,
17501
+ bottomPx,
17502
+ leftPx,
17495
17503
  type,
17496
17504
  pageSizePx,
17497
17505
  orientation,
@@ -17603,7 +17611,14 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
17603
17611
  startParagraphIndex: currentStart,
17604
17612
  endParagraphIndex: item.index,
17605
17613
  sectPr,
17606
- margins: sectionData.headerPx != null || sectionData.footerPx != null ? { header: sectionData.headerPx ?? 0, footer: sectionData.footerPx ?? 0 } : null,
17614
+ margins: sectionData.headerPx != null || sectionData.footerPx != null ? {
17615
+ header: sectionData.headerPx ?? 0,
17616
+ footer: sectionData.footerPx ?? 0,
17617
+ top: sectionData.topPx,
17618
+ right: sectionData.rightPx,
17619
+ bottom: sectionData.bottomPx,
17620
+ left: sectionData.leftPx
17621
+ } : null,
17607
17622
  pageSize: sectionData.pageSizePx ?? null,
17608
17623
  orientation: sectionData.orientation ?? null,
17609
17624
  columns: sectionData.columnsPx ?? null,
@@ -17645,7 +17660,14 @@ function createFinalSectionFromBodySectPr(bodySectPr, currentStart, totalParagra
17645
17660
  startParagraphIndex: currentStart,
17646
17661
  endParagraphIndex: totalParagraphs - 1,
17647
17662
  sectPr: bodySectPr,
17648
- margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? { header: bodySectionData.headerPx ?? 0, footer: bodySectionData.footerPx ?? 0 } : null,
17663
+ margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? {
17664
+ header: bodySectionData.headerPx ?? 0,
17665
+ footer: bodySectionData.footerPx ?? 0,
17666
+ top: bodySectionData.topPx,
17667
+ right: bodySectionData.rightPx,
17668
+ bottom: bodySectionData.bottomPx,
17669
+ left: bodySectionData.leftPx
17670
+ } : null,
17649
17671
  pageSize: bodySectionData.pageSizePx ?? null,
17650
17672
  orientation: bodySectionData.orientation ?? null,
17651
17673
  columns: bodySectionData.columnsPx ?? null,
@@ -23924,41 +23946,6 @@ const parseTableCell = (args) => {
23924
23946
  }
23925
23947
  }
23926
23948
  }
23927
- try {
23928
- const blockSummaries = blocks.map((b) => {
23929
- if (b.kind === "paragraph") {
23930
- const runs = b.runs ?? [];
23931
- const attrs = b.attrs ?? {};
23932
- return {
23933
- kind: "paragraph",
23934
- runKinds: runs.map((r2) => r2.kind ?? "text"),
23935
- runCount: runs.length,
23936
- runPreview: runs.map((r2) => {
23937
- const kind = r2.kind ?? "text";
23938
- if (kind === "image") {
23939
- const img = r2;
23940
- return { kind, src: img.src, width: img.width, height: img.height };
23941
- }
23942
- return { kind };
23943
- }),
23944
- hasNumbering: Boolean(attrs.numberingProperties),
23945
- markerText: attrs.wordLayout?.marker?.markerText
23946
- };
23947
- }
23948
- return { kind: b.kind };
23949
- });
23950
- console.log(
23951
- "[tableNodeToBlock.parseTableCell] cell contents",
23952
- JSON.stringify({
23953
- cellIndex,
23954
- rowIndex,
23955
- cellIdPreview: `cell-${rowIndex}-${cellIndex}`,
23956
- childTypes: cellNode.content.map((c) => c?.type),
23957
- blocks: blockSummaries
23958
- })
23959
- );
23960
- } catch {
23961
- }
23962
23949
  if (blocks.length === 0) {
23963
23950
  return null;
23964
23951
  }
@@ -27823,20 +27810,6 @@ const renderTableCell = (deps) => {
27823
27810
  }
27824
27811
  const cellBlocks = cell?.blocks ?? (cell?.paragraph ? [cell.paragraph] : []);
27825
27812
  const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
27826
- try {
27827
- console.log(
27828
- "[DomPainter.renderTableCell] cell render input",
27829
- JSON.stringify({
27830
- cellId: cell?.id,
27831
- blockKinds: cellBlocks.map((b) => b.kind),
27832
- measureKinds: blockMeasures.map((m) => m.kind),
27833
- width: cellMeasure?.width,
27834
- height: cellMeasure?.height,
27835
- rowHeight
27836
- })
27837
- );
27838
- } catch {
27839
- }
27840
27813
  if (cellBlocks.length > 0 && blockMeasures.length > 0) {
27841
27814
  const content = doc2.createElement("div");
27842
27815
  content.style.position = "relative";
@@ -27869,15 +27842,6 @@ const renderTableCell = (deps) => {
27869
27842
  const blockMeasure = blockMeasures[i];
27870
27843
  const block = cellBlocks[i];
27871
27844
  if (blockMeasure.kind === "image" && block?.kind === "image") {
27872
- console.log(
27873
- "[DomPainter.renderTableCell] rendering image block in cell",
27874
- JSON.stringify({
27875
- cellId: cell?.id,
27876
- blockId: block.id,
27877
- width: blockMeasure.width,
27878
- height: blockMeasure.height
27879
- })
27880
- );
27881
27845
  const imageWrapper = doc2.createElement("div");
27882
27846
  imageWrapper.style.position = "relative";
27883
27847
  imageWrapper.style.width = `${blockMeasure.width}px`;
@@ -27900,16 +27864,6 @@ const renderTableCell = (deps) => {
27900
27864
  continue;
27901
27865
  }
27902
27866
  if (blockMeasure.kind === "drawing" && block?.kind === "drawing") {
27903
- console.log(
27904
- "[DomPainter.renderTableCell] rendering drawing block in cell",
27905
- JSON.stringify({
27906
- cellId: cell?.id,
27907
- blockId: block.id,
27908
- drawingKind: block.drawingKind,
27909
- width: blockMeasure.width,
27910
- height: blockMeasure.height
27911
- })
27912
- );
27913
27867
  const drawingWrapper = doc2.createElement("div");
27914
27868
  drawingWrapper.style.position = "relative";
27915
27869
  drawingWrapper.style.width = `${blockMeasure.width}px`;
@@ -27952,20 +27906,6 @@ const renderTableCell = (deps) => {
27952
27906
  continue;
27953
27907
  }
27954
27908
  if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
27955
- try {
27956
- const runKinds = (block.runs ?? []).map((r2) => r2.kind ?? "text");
27957
- const imageRuns = (block.runs ?? []).filter((r2) => r2.kind === "image").map((r2) => ({ src: r2.src }));
27958
- console.log(
27959
- "[DomPainter.renderTableCell] rendering paragraph block in cell",
27960
- JSON.stringify({
27961
- cellId: cell?.id,
27962
- blockId: block.id,
27963
- runKinds,
27964
- imageRuns
27965
- })
27966
- );
27967
- } catch {
27968
- }
27969
27909
  const paragraphMeasure = blockMeasure;
27970
27910
  const lines = paragraphMeasure.lines;
27971
27911
  const blockLineCount = lines?.length || 0;
@@ -28888,6 +28828,61 @@ function ensureRulerStyles(doc2) {
28888
28828
  doc2.head?.appendChild(styleEl);
28889
28829
  rulerStylesInjected = true;
28890
28830
  }
28831
+ const hashParagraphBorder$1 = (border) => {
28832
+ const parts = [];
28833
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
28834
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
28835
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
28836
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
28837
+ return parts.join(",");
28838
+ };
28839
+ const hashParagraphBorders$1 = (borders) => {
28840
+ const parts = [];
28841
+ if (borders.top) parts.push(`t:[${hashParagraphBorder$1(borders.top)}]`);
28842
+ if (borders.right) parts.push(`r:[${hashParagraphBorder$1(borders.right)}]`);
28843
+ if (borders.bottom) parts.push(`b:[${hashParagraphBorder$1(borders.bottom)}]`);
28844
+ if (borders.left) parts.push(`l:[${hashParagraphBorder$1(borders.left)}]`);
28845
+ return parts.join(";");
28846
+ };
28847
+ const hasStringProp = (run, prop) => {
28848
+ return prop in run && typeof run[prop] === "string";
28849
+ };
28850
+ const hasNumberProp = (run, prop) => {
28851
+ return prop in run && typeof run[prop] === "number";
28852
+ };
28853
+ const hasBooleanProp = (run, prop) => {
28854
+ return prop in run && typeof run[prop] === "boolean";
28855
+ };
28856
+ const getRunStringProp = (run, prop) => {
28857
+ if (hasStringProp(run, prop)) {
28858
+ return run[prop];
28859
+ }
28860
+ return "";
28861
+ };
28862
+ const getRunNumberProp = (run, prop) => {
28863
+ if (hasNumberProp(run, prop)) {
28864
+ return run[prop];
28865
+ }
28866
+ return 0;
28867
+ };
28868
+ const getRunBooleanProp = (run, prop) => {
28869
+ if (hasBooleanProp(run, prop)) {
28870
+ return run[prop];
28871
+ }
28872
+ return false;
28873
+ };
28874
+ const getRunUnderlineStyle = (run) => {
28875
+ if ("underline" in run && run.underline && typeof run.underline === "object") {
28876
+ return run.underline.style ?? "";
28877
+ }
28878
+ return "";
28879
+ };
28880
+ const getRunUnderlineColor = (run) => {
28881
+ if ("underline" in run && run.underline && typeof run.underline === "object") {
28882
+ return run.underline.color ?? "";
28883
+ }
28884
+ return "";
28885
+ };
28891
28886
  function isMinimalWordLayout(value) {
28892
28887
  if (typeof value !== "object" || value === null) {
28893
28888
  return false;
@@ -29780,7 +29775,9 @@ const _DomPainter = class _DomPainter {
29780
29775
  const isTocEntry = block.attrs?.isTocEntry;
29781
29776
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
29782
29777
  const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
29783
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
29778
+ const paraIndentForOverflow = block.attrs?.indent;
29779
+ const hasNegativeIndent = (paraIndentForOverflow?.left ?? 0) < 0 || (paraIndentForOverflow?.right ?? 0) < 0;
29780
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer || hasNegativeIndent ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
29784
29781
  applyStyles$2(fragmentEl, styles);
29785
29782
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
29786
29783
  if (isTocEntry) {
@@ -29809,6 +29806,8 @@ const _DomPainter = class _DomPainter {
29809
29806
  }
29810
29807
  if (fragmentEl.style.paddingLeft) fragmentEl.style.removeProperty("padding-left");
29811
29808
  if (fragmentEl.style.paddingRight) fragmentEl.style.removeProperty("padding-right");
29809
+ if (fragmentEl.style.marginLeft) fragmentEl.style.removeProperty("margin-left");
29810
+ if (fragmentEl.style.marginRight) fragmentEl.style.removeProperty("margin-right");
29812
29811
  if (fragmentEl.style.textIndent) fragmentEl.style.removeProperty("text-indent");
29813
29812
  const paraIndent = block.attrs?.indent;
29814
29813
  const paraIndentLeft = paraIndent?.left ?? 0;
@@ -29837,16 +29836,22 @@ const _DomPainter = class _DomPainter {
29837
29836
  if (!isListFirstLine) {
29838
29837
  if (hasExplicitSegmentPositioning) {
29839
29838
  if (isFirstLine && firstLineOffset !== 0) {
29840
- const adjustedPadding = paraIndentLeft + firstLineOffset;
29841
- lineEl.style.paddingLeft = `${adjustedPadding}px`;
29839
+ const effectiveLeftIndent = paraIndentLeft < 0 ? 0 : paraIndentLeft;
29840
+ const adjustedPadding = effectiveLeftIndent + firstLineOffset;
29841
+ if (adjustedPadding > 0) {
29842
+ lineEl.style.paddingLeft = `${adjustedPadding}px`;
29843
+ }
29842
29844
  }
29843
- } else if (paraIndentLeft) {
29845
+ } else if (paraIndentLeft && paraIndentLeft > 0) {
29844
29846
  lineEl.style.paddingLeft = `${paraIndentLeft}px`;
29847
+ } else if (!isFirstLine && paraIndent?.hanging && paraIndent.hanging > 0) {
29848
+ lineEl.style.paddingLeft = `${paraIndent.hanging}px`;
29845
29849
  }
29846
29850
  }
29847
- if (paraIndentRight) {
29851
+ if (paraIndentRight && paraIndentRight > 0) {
29848
29852
  lineEl.style.paddingRight = `${paraIndentRight}px`;
29849
29853
  }
29854
+ const hasNegativeLeftIndent = paraIndentLeft != null && paraIndentLeft < 0;
29850
29855
  if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
29851
29856
  if (!hasExplicitSegmentPositioning) {
29852
29857
  lineEl.style.textIndent = `${firstLineOffset}px`;
@@ -31957,7 +31962,7 @@ const deriveBlockVersion = (block) => {
31957
31962
  attrs.indent?.right ?? "",
31958
31963
  attrs.indent?.firstLine ?? "",
31959
31964
  attrs.indent?.hanging ?? "",
31960
- attrs.borders ? JSON.stringify(attrs.borders) : "",
31965
+ attrs.borders ? hashParagraphBorders$1(attrs.borders) : "",
31961
31966
  attrs.shading?.fill ?? "",
31962
31967
  attrs.shading?.color ?? "",
31963
31968
  attrs.direction ?? "",
@@ -32046,14 +32051,43 @@ const deriveBlockVersion = (block) => {
32046
32051
  for (const cellBlock of cellBlocks) {
32047
32052
  hash2 = hashString(hash2, cellBlock?.kind ?? "unknown");
32048
32053
  if (cellBlock?.kind === "paragraph") {
32049
- const runs = cellBlock.runs ?? [];
32054
+ const paragraphBlock = cellBlock;
32055
+ const runs = paragraphBlock.runs ?? [];
32050
32056
  hash2 = hashNumber(hash2, runs.length);
32057
+ const attrs = paragraphBlock.attrs;
32058
+ if (attrs) {
32059
+ hash2 = hashString(hash2, attrs.alignment ?? "");
32060
+ hash2 = hashNumber(hash2, attrs.spacing?.before ?? 0);
32061
+ hash2 = hashNumber(hash2, attrs.spacing?.after ?? 0);
32062
+ hash2 = hashNumber(hash2, attrs.spacing?.line ?? 0);
32063
+ hash2 = hashString(hash2, attrs.spacing?.lineRule ?? "");
32064
+ hash2 = hashNumber(hash2, attrs.indent?.left ?? 0);
32065
+ hash2 = hashNumber(hash2, attrs.indent?.right ?? 0);
32066
+ hash2 = hashNumber(hash2, attrs.indent?.firstLine ?? 0);
32067
+ hash2 = hashNumber(hash2, attrs.indent?.hanging ?? 0);
32068
+ hash2 = hashString(hash2, attrs.shading?.fill ?? "");
32069
+ hash2 = hashString(hash2, attrs.shading?.color ?? "");
32070
+ hash2 = hashString(hash2, attrs.direction ?? "");
32071
+ hash2 = hashString(hash2, attrs.rtl ? "1" : "");
32072
+ if (attrs.borders) {
32073
+ hash2 = hashString(hash2, hashParagraphBorders$1(attrs.borders));
32074
+ }
32075
+ }
32051
32076
  for (const run of runs) {
32052
32077
  if ("text" in run && typeof run.text === "string") {
32053
32078
  hash2 = hashString(hash2, run.text);
32054
32079
  }
32055
32080
  hash2 = hashNumber(hash2, run.pmStart ?? -1);
32056
32081
  hash2 = hashNumber(hash2, run.pmEnd ?? -1);
32082
+ hash2 = hashString(hash2, getRunStringProp(run, "color"));
32083
+ hash2 = hashString(hash2, getRunStringProp(run, "highlight"));
32084
+ hash2 = hashString(hash2, getRunBooleanProp(run, "bold") ? "1" : "");
32085
+ hash2 = hashString(hash2, getRunBooleanProp(run, "italic") ? "1" : "");
32086
+ hash2 = hashNumber(hash2, getRunNumberProp(run, "fontSize"));
32087
+ hash2 = hashString(hash2, getRunStringProp(run, "fontFamily"));
32088
+ hash2 = hashString(hash2, getRunUnderlineStyle(run));
32089
+ hash2 = hashString(hash2, getRunUnderlineColor(run));
32090
+ hash2 = hashString(hash2, getRunBooleanProp(run, "strike") ? "1" : "");
32057
32091
  }
32058
32092
  }
32059
32093
  }
@@ -32131,15 +32165,18 @@ const applyParagraphBlockStyles = (element, attrs) => {
32131
32165
  }
32132
32166
  const indent = attrs.indent;
32133
32167
  if (indent) {
32134
- if (indent.left) {
32168
+ if (indent.left && indent.left > 0) {
32135
32169
  element.style.paddingLeft = `${indent.left}px`;
32136
32170
  }
32137
- if (indent.right) {
32171
+ if (indent.right && indent.right > 0) {
32138
32172
  element.style.paddingRight = `${indent.right}px`;
32139
32173
  }
32140
- const textIndent = (indent.firstLine ?? 0) - (indent.hanging ?? 0);
32141
- if (textIndent) {
32142
- element.style.textIndent = `${textIndent}px`;
32174
+ const hasNegativeLeftIndent = indent.left != null && indent.left < 0;
32175
+ if (!hasNegativeLeftIndent) {
32176
+ const textIndent = (indent.firstLine ?? 0) - (indent.hanging ?? 0);
32177
+ if (textIndent) {
32178
+ element.style.textIndent = `${textIndent}px`;
32179
+ }
32143
32180
  }
32144
32181
  }
32145
32182
  applyParagraphBorderStyles(element, attrs.borders);
@@ -33501,20 +33538,6 @@ const asSafeNumber = (value) => {
33501
33538
  }
33502
33539
  return value;
33503
33540
  };
33504
- function calculateFirstLineIndent(block, measure) {
33505
- const wordLayout = block.attrs?.wordLayout;
33506
- if (!wordLayout?.firstLineIndentMode) {
33507
- return 0;
33508
- }
33509
- if (!wordLayout.marker || !measure.marker) {
33510
- return 0;
33511
- }
33512
- const markerWidthRaw = measure.marker.markerWidth ?? wordLayout.marker.markerBoxWidthPx ?? 0;
33513
- const markerWidth = Number.isFinite(markerWidthRaw) && markerWidthRaw >= 0 ? markerWidthRaw : 0;
33514
- const gutterWidthRaw = measure.marker.gutterWidth ?? 0;
33515
- const gutterWidth = Number.isFinite(gutterWidthRaw) && gutterWidthRaw >= 0 ? gutterWidthRaw : 0;
33516
- return markerWidth + gutterWidth;
33517
- }
33518
33541
  function layoutParagraphBlock(ctx2, anchors) {
33519
33542
  const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx2;
33520
33543
  const remeasureParagraph2 = ctx2.remeasureParagraph;
@@ -33636,10 +33659,25 @@ function layoutParagraphBlock(ctx2, anchors) {
33636
33659
  }
33637
33660
  let lines = normalizeLines(measure);
33638
33661
  const measurementWidth = lines[0]?.maxWidth;
33662
+ const paraIndent = block.attrs?.indent;
33663
+ const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
33664
+ const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
33665
+ const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
33666
+ const negativeRightIndent = indentRight < 0 ? indentRight : 0;
33667
+ const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
33639
33668
  let didRemeasureForColumnWidth = false;
33640
- if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > columnWidth) {
33641
- const firstLineIndent = calculateFirstLineIndent(block, measure);
33642
- const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
33669
+ if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
33670
+ let firstLineIndent = 0;
33671
+ const wordLayout = block.attrs?.wordLayout;
33672
+ if (wordLayout?.marker && measure.marker) {
33673
+ const markerJustification = wordLayout.marker.justification ?? "left";
33674
+ if (markerJustification === "left") {
33675
+ const markerWidth = measure.marker.markerWidth ?? 0;
33676
+ const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
33677
+ firstLineIndent = markerWidth + gutterWidth;
33678
+ }
33679
+ }
33680
+ const newMeasure = remeasureParagraph2(block, remeasureWidth, firstLineIndent);
33643
33681
  lines = normalizeLines(newMeasure);
33644
33682
  didRemeasureForColumnWidth = true;
33645
33683
  }
@@ -33718,9 +33756,19 @@ function layoutParagraphBlock(ctx2, anchors) {
33718
33756
  }
33719
33757
  tempY += lineHeight;
33720
33758
  }
33721
- if (narrowestWidth < columnWidth) {
33722
- const firstLineIndent = calculateFirstLineIndent(block, measure);
33723
- const newMeasure = remeasureParagraph2(block, narrowestWidth, firstLineIndent);
33759
+ const narrowestRemeasureWidth = Math.max(1, narrowestWidth - indentLeft - indentRight);
33760
+ if (narrowestRemeasureWidth < remeasureWidth) {
33761
+ let firstLineIndent = 0;
33762
+ const wordLayout = block.attrs?.wordLayout;
33763
+ if (wordLayout?.marker && measure.marker) {
33764
+ const markerJustification = wordLayout.marker.justification ?? "left";
33765
+ if (markerJustification === "left") {
33766
+ const markerWidth = measure.marker.markerWidth ?? 0;
33767
+ const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
33768
+ firstLineIndent = markerWidth + gutterWidth;
33769
+ }
33770
+ }
33771
+ const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
33724
33772
  lines = normalizeLines(newMeasure);
33725
33773
  didRemeasureForFloats = true;
33726
33774
  }
@@ -33774,14 +33822,16 @@ function layoutParagraphBlock(ctx2, anchors) {
33774
33822
  }
33775
33823
  const slice2 = sliceLines(lines, fromLine, state.contentBottom - state.cursorY);
33776
33824
  const fragmentHeight = slice2.height;
33825
+ const adjustedX = columnX(state.columnIndex) + offsetX + negativeLeftIndent;
33826
+ const adjustedWidth = effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
33777
33827
  const fragment = {
33778
33828
  kind: "para",
33779
33829
  blockId: block.id,
33780
33830
  fromLine,
33781
33831
  toLine: slice2.toLine,
33782
- x: columnX(state.columnIndex) + offsetX,
33832
+ x: adjustedX,
33783
33833
  y: state.cursorY,
33784
- width: effectiveColumnWidth,
33834
+ width: adjustedWidth,
33785
33835
  ...computeFragmentPmRange(block, lines, fromLine, slice2.toLine)
33786
33836
  };
33787
33837
  if (didRemeasureForColumnWidth) {
@@ -35735,10 +35785,6 @@ const resolveTrackedChangesEnabled = (attrs, defaultEnabled = true) => {
35735
35785
  }
35736
35786
  return attrs.trackedChangesEnabled !== false;
35737
35787
  };
35738
- const MAX_CACHE_SIZE$1 = 1e4;
35739
- const BYTES_PER_ENTRY_ESTIMATE = 5e3;
35740
- const NORMALIZED_WHITESPACE = /\s+/g;
35741
- const normalizeText = (text) => text.replace(NORMALIZED_WHITESPACE, " ");
35742
35788
  const hashParagraphBorder = (border) => {
35743
35789
  const parts = [];
35744
35790
  if (border.style !== void 0) parts.push(`s:${border.style}`);
@@ -35755,6 +35801,10 @@ const hashParagraphBorders = (borders) => {
35755
35801
  if (borders.left) parts.push(`l:[${hashParagraphBorder(borders.left)}]`);
35756
35802
  return parts.join(";");
35757
35803
  };
35804
+ const MAX_CACHE_SIZE$1 = 1e4;
35805
+ const BYTES_PER_ENTRY_ESTIMATE = 5e3;
35806
+ const NORMALIZED_WHITESPACE = /\s+/g;
35807
+ const normalizeText = (text) => text.replace(NORMALIZED_WHITESPACE, " ");
35758
35808
  const hashParagraphFrame = (frame) => {
35759
35809
  const parts = [];
35760
35810
  if (frame.wrap !== void 0) parts.push(`w:${frame.wrap}`);
@@ -35791,12 +35841,14 @@ const hashRuns = (block) => {
35791
35841
  const color = "color" in run ? run.color : void 0;
35792
35842
  const fontSize = "fontSize" in run ? run.fontSize : void 0;
35793
35843
  const fontFamily = "fontFamily" in run ? run.fontFamily : void 0;
35844
+ const highlight = "highlight" in run ? run.highlight : void 0;
35794
35845
  const marks = [
35795
35846
  bold ? "b" : "",
35796
35847
  italic ? "i" : "",
35797
35848
  color ?? "",
35798
35849
  fontSize !== void 0 ? `fs:${fontSize}` : "",
35799
- fontFamily ? `ff:${fontFamily}` : ""
35850
+ fontFamily ? `ff:${fontFamily}` : "",
35851
+ highlight ? `hl:${highlight}` : ""
35800
35852
  ].join("");
35801
35853
  let trackedKey = "";
35802
35854
  if (hasTrackedChange(run)) {
@@ -35807,6 +35859,38 @@ const hashRuns = (block) => {
35807
35859
  }
35808
35860
  cellHashes.push(`${text}:${marks}${trackedKey}`);
35809
35861
  }
35862
+ if (paragraphBlock.attrs) {
35863
+ const attrs = paragraphBlock.attrs;
35864
+ const parts = [];
35865
+ if (attrs.alignment) parts.push(`al:${attrs.alignment}`);
35866
+ if (attrs.spacing) {
35867
+ const s2 = attrs.spacing;
35868
+ if (s2.before !== void 0) parts.push(`sb:${s2.before}`);
35869
+ if (s2.after !== void 0) parts.push(`sa:${s2.after}`);
35870
+ if (s2.line !== void 0) parts.push(`sl:${s2.line}`);
35871
+ if (s2.lineRule) parts.push(`sr:${s2.lineRule}`);
35872
+ }
35873
+ if (attrs.indent) {
35874
+ const ind = attrs.indent;
35875
+ if (ind.left !== void 0) parts.push(`il:${ind.left}`);
35876
+ if (ind.right !== void 0) parts.push(`ir:${ind.right}`);
35877
+ if (ind.firstLine !== void 0) parts.push(`if:${ind.firstLine}`);
35878
+ if (ind.hanging !== void 0) parts.push(`ih:${ind.hanging}`);
35879
+ }
35880
+ if (attrs.borders) {
35881
+ parts.push(`br:${hashParagraphBorders(attrs.borders)}`);
35882
+ }
35883
+ if (attrs.shading) {
35884
+ const sh = attrs.shading;
35885
+ if (sh.fill) parts.push(`shf:${sh.fill}`);
35886
+ if (sh.color) parts.push(`shc:${sh.color}`);
35887
+ }
35888
+ if (attrs.direction) parts.push(`dir:${attrs.direction}`);
35889
+ if (attrs.rtl) parts.push("rtl");
35890
+ if (parts.length > 0) {
35891
+ cellHashes.push(`pa:${parts.join(":")}`);
35892
+ }
35893
+ }
35810
35894
  }
35811
35895
  }
35812
35896
  }
@@ -35830,12 +35914,14 @@ const hashRuns = (block) => {
35830
35914
  const color = "color" in run ? run.color : void 0;
35831
35915
  const fontSize = "fontSize" in run ? run.fontSize : void 0;
35832
35916
  const fontFamily = "fontFamily" in run ? run.fontFamily : void 0;
35917
+ const highlight = "highlight" in run ? run.highlight : void 0;
35833
35918
  const marks = [
35834
35919
  bold ? "b" : "",
35835
35920
  italic ? "i" : "",
35836
35921
  color ?? "",
35837
35922
  fontSize !== void 0 ? `fs:${fontSize}` : "",
35838
- fontFamily ? `ff:${fontFamily}` : ""
35923
+ fontFamily ? `ff:${fontFamily}` : "",
35924
+ highlight ? `hl:${highlight}` : ""
35839
35925
  ].join("");
35840
35926
  let trackedKey = "";
35841
35927
  if (hasTrackedChange(run)) {
@@ -36962,7 +37048,7 @@ const paragraphBlocksEqual = (a, b) => {
36962
37048
  for (let i = 0; i < a.runs.length; i += 1) {
36963
37049
  const runA = a.runs[i];
36964
37050
  const runB = b.runs[i];
36965
- if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
37051
+ if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || ("highlight" in runA ? runA.highlight : void 0) !== ("highlight" in runB ? runB.highlight : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
36966
37052
  return false;
36967
37053
  }
36968
37054
  }
@@ -37489,9 +37575,15 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
37489
37575
  }
37490
37576
  const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
37491
37577
  const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
37578
+ const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
37492
37579
  function resolveMeasurementConstraints(options) {
37493
37580
  const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
37494
- const margins = options.margins ?? DEFAULT_MARGINS$1;
37581
+ const margins = {
37582
+ top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
37583
+ right: normalizeMargin(options.margins?.right, DEFAULT_MARGINS$1.right),
37584
+ bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
37585
+ left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
37586
+ };
37495
37587
  const contentWidth = pageSize.w - (margins.left + margins.right);
37496
37588
  const contentHeight = pageSize.h - (margins.top + margins.bottom);
37497
37589
  const columns = options.columns;
@@ -39029,8 +39121,8 @@ async function measureParagraphBlock(block, maxWidth) {
39029
39121
  const lines = [];
39030
39122
  const indent = block.attrs?.indent;
39031
39123
  const spacing = block.attrs?.spacing;
39032
- const indentLeft = sanitizePositive(indent?.left);
39033
- const indentRight = sanitizePositive(indent?.right);
39124
+ const indentLeft = sanitizeIndent(indent?.left);
39125
+ const indentRight = sanitizeIndent(indent?.right);
39034
39126
  const firstLine = indent?.firstLine ?? 0;
39035
39127
  const hanging = indent?.hanging ?? 0;
39036
39128
  const isWordLayoutList = Boolean(wordLayout?.marker);
@@ -39039,10 +39131,10 @@ async function measureParagraphBlock(block, maxWidth) {
39039
39131
  const clampedFirstLineOffset = Math.max(0, rawFirstLineOffset);
39040
39132
  const firstLineOffset = isWordLayoutList ? 0 : clampedFirstLineOffset;
39041
39133
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
39134
+ const bodyContentWidth = contentWidth;
39042
39135
  let initialAvailableWidth;
39043
39136
  const textStartPx = wordLayout?.textStartPx;
39044
- const treatAsHanging = isWordLayoutList && indentLeft === 0 && hanging === 0 && typeof textStartPx === "number";
39045
- if (typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging) {
39137
+ if (typeof textStartPx === "number" && textStartPx > indentLeft) {
39046
39138
  initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
39047
39139
  } else {
39048
39140
  initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
@@ -39089,21 +39181,6 @@ async function measureParagraphBlock(block, maxWidth) {
39089
39181
  totalHeight: metrics.lineHeight
39090
39182
  };
39091
39183
  }
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
- }
39107
39184
  let currentLine = null;
39108
39185
  const getEffectiveWidth = (baseWidth) => {
39109
39186
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -39249,7 +39326,7 @@ async function measureParagraphBlock(block, maxWidth) {
39249
39326
  lines.push(emptyLine);
39250
39327
  }
39251
39328
  const hadPreviousLine = lines.length > 0;
39252
- const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(contentWidth) : getEffectiveWidth(initialAvailableWidth);
39329
+ const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(bodyContentWidth) : getEffectiveWidth(initialAvailableWidth);
39253
39330
  currentLine = {
39254
39331
  fromRun: runIndex,
39255
39332
  fromChar: 0,
@@ -39360,7 +39437,7 @@ async function measureParagraphBlock(block, maxWidth) {
39360
39437
  toChar: 1,
39361
39438
  width: imageWidth,
39362
39439
  maxFontSize: imageHeight,
39363
- maxWidth: getEffectiveWidth(contentWidth),
39440
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39364
39441
  spaceCount: 0,
39365
39442
  segments: [
39366
39443
  {
@@ -39449,7 +39526,7 @@ async function measureParagraphBlock(block, maxWidth) {
39449
39526
  toChar: 1,
39450
39527
  width: annotationWidth,
39451
39528
  maxFontSize: annotationHeight,
39452
- maxWidth: getEffectiveWidth(contentWidth),
39529
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39453
39530
  spaceCount: 0,
39454
39531
  segments: [
39455
39532
  {
@@ -39531,7 +39608,7 @@ async function measureParagraphBlock(block, maxWidth) {
39531
39608
  width: spacesWidth,
39532
39609
  maxFontSize: run.fontSize,
39533
39610
  maxFontInfo: getFontInfoFromRun(run),
39534
- maxWidth: getEffectiveWidth(contentWidth),
39611
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39535
39612
  segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }],
39536
39613
  spaceCount: spacesLength
39537
39614
  };
@@ -39594,7 +39671,7 @@ async function measureParagraphBlock(block, maxWidth) {
39594
39671
  width: singleSpaceWidth,
39595
39672
  maxFontSize: run.fontSize,
39596
39673
  maxFontInfo: getFontInfoFromRun(run),
39597
- maxWidth: getEffectiveWidth(contentWidth),
39674
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39598
39675
  segments: [{ runIndex, fromChar: spaceStartChar, toChar: spaceEndChar, width: singleSpaceWidth }],
39599
39676
  spaceCount: 1
39600
39677
  };
@@ -39787,7 +39864,7 @@ async function measureParagraphBlock(block, maxWidth) {
39787
39864
  width: wordOnlyWidth,
39788
39865
  maxFontSize: run.fontSize,
39789
39866
  maxFontInfo: getFontInfoFromRun(run),
39790
- maxWidth: getEffectiveWidth(contentWidth),
39867
+ maxWidth: getEffectiveWidth(bodyContentWidth),
39791
39868
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
39792
39869
  spaceCount: 0
39793
39870
  };
@@ -40352,6 +40429,7 @@ const resolveLineHeight = (spacing, baseLineHeight) => {
40352
40429
  return Math.max(baseLineHeight, raw);
40353
40430
  };
40354
40431
  const sanitizePositive = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
40432
+ const sanitizeIndent = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
40355
40433
  const sanitizeDecimalSeparator = (value) => {
40356
40434
  if (value === ",") return ",";
40357
40435
  return DEFAULT_DECIMAL_SEPARATOR;
@@ -45509,6 +45587,10 @@ resolveLayoutOptions_fn = function(blocks, sectionMetadata) {
45509
45587
  const pageSize = firstSection?.pageSize ?? defaults.pageSize;
45510
45588
  const margins = {
45511
45589
  ...defaults.margins,
45590
+ ...firstSection?.margins?.top != null ? { top: firstSection.margins.top } : {},
45591
+ ...firstSection?.margins?.right != null ? { right: firstSection.margins.right } : {},
45592
+ ...firstSection?.margins?.bottom != null ? { bottom: firstSection.margins.bottom } : {},
45593
+ ...firstSection?.margins?.left != null ? { left: firstSection.margins.left } : {},
45512
45594
  ...firstSection?.margins?.header != null ? { header: firstSection.margins.header } : {},
45513
45595
  ...firstSection?.margins?.footer != null ? { footer: firstSection.margins.footer } : {}
45514
45596
  };