@stll/folio-core 0.67.0 → 0.69.0
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/ai-edits/apply.d.ts +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +106 -36
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/newListNumbering.d.ts +14 -1
- package/dist/ai-edits/newListNumbering.js +24 -1
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/pending-suggestions.js +2 -2
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +31 -14
- package/dist/controller/canonicalComposition.js +35 -6
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +32 -7
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +23 -0
- package/dist/controller/canonicalLockGuard.js +133 -0
- package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
- package/dist/controller/canonicalProjectionBlocks.js +75 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +676 -46
- package/dist/controller/canonicalSeedContent.d.ts +12 -0
- package/dist/controller/canonicalSeedContent.js +131 -0
- package/dist/controller/canonicalSession.d.ts +133 -21
- package/dist/controller/canonicalSession.js +738 -205
- package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
- package/dist/controller/canonicalSourceNormalization.js +148 -0
- package/dist/controller/canonicalStoryEditor.d.ts +4 -3
- package/dist/controller/canonicalStoryEditor.js +20 -15
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +4 -0
- package/dist/controller/headerFooterEditorManager.d.ts +7 -2
- package/dist/controller/headerFooterEditorManager.js +11 -6
- package/dist/controller/hiddenEditorApi.d.ts +17 -2
- package/dist/controller/hiddenEditorApi.js +4 -0
- package/dist/controller/hiddenEditorManager.d.ts +11 -3
- package/dist/controller/hiddenEditorManager.js +157 -48
- package/dist/controller/layoutPipeline.js +50 -16
- package/dist/controller/layoutSession.d.ts +3 -0
- package/dist/controller/layoutSession.js +3 -1
- package/dist/controller/noteEditorManager.d.ts +7 -2
- package/dist/controller/noteEditorManager.js +11 -6
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +13 -11
- package/dist/document-operations.d.ts +9 -1
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +11 -2
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +40 -5
- package/dist/docx/commentAnchorIndex.js +94 -12
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/contentTypeRegistry.js +1 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +27 -0
- package/dist/docx/hostCommentThreads.js +72 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +226 -96
- package/dist/docx/listNumberingInstances.d.ts +1 -1
- package/dist/docx/listNumberingInstances.js +2 -2
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/numberingIds.d.ts +6 -0
- package/dist/docx/numberingIds.js +6 -1
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
- package/dist/docx/numberingReferenceNormalization.js +12 -2
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +29 -0
- package/dist/docx/paragraphPropertySource.js +106 -16
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +8 -0
- package/dist/docx/removeHeaderFooterParts.js +1 -1
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +171 -33
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +5 -2
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/partNamespaces.d.ts +1 -1
- package/dist/docx/serializer/partNamespaces.js +1 -1
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +19 -2
- package/dist/docx/structuralXmlPatch.js +44 -11
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/docx/xmlParser.d.ts +1 -1
- package/dist/docx/xmlParser.js +2 -3
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +3 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
- package/dist/i18n/messages/catalogs.gen.js +51 -0
- package/dist/i18n/messages/cs.gen.js +3 -0
- package/dist/i18n/messages/de.gen.js +3 -0
- package/dist/i18n/messages/en.gen.js +3 -0
- package/dist/i18n/messages/es.gen.js +3 -0
- package/dist/i18n/messages/et.gen.js +3 -0
- package/dist/i18n/messages/fr.gen.js +3 -0
- package/dist/i18n/messages/he.gen.js +3 -0
- package/dist/i18n/messages/hi.gen.js +3 -0
- package/dist/i18n/messages/hu.gen.js +3 -0
- package/dist/i18n/messages/lt.gen.js +3 -0
- package/dist/i18n/messages/lv.gen.js +3 -0
- package/dist/i18n/messages/messages.gen.d.ts +3 -0
- package/dist/i18n/messages/pl.gen.js +3 -0
- package/dist/i18n/messages/pt-BR.gen.js +3 -0
- package/dist/i18n/messages/sk.gen.js +3 -0
- package/dist/i18n/messages/tr.gen.js +3 -0
- package/dist/i18n/messages/zh-CN.gen.js +3 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
- package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/subtreeHolds.d.ts +12 -0
- package/dist/internal/subtreeHolds.js +25 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
- package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
- package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
- package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
- package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
- package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
- package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
- package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
- package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
- package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
- package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
- package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
- package/dist/layout-bridge/dom/textStreamDom.js +3 -2
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-bridge/headerFooterLayout.js +12 -11
- package/dist/layout-bridge/tableInsertHover.js +2 -1
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.d.ts +2 -0
- package/dist/layout-engine/measure/cache.js +16 -6
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +42 -1
- package/dist/layout-painter/imageLayout.js +2 -1
- package/dist/layout-painter/pageShellStyles.d.ts +10 -0
- package/dist/layout-painter/pageShellStyles.js +32 -0
- package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
- package/dist/layout-painter/reconcileRenderedContent.js +117 -0
- package/dist/layout-painter/renderFragment.js +4 -6
- package/dist/layout-painter/renderImage.js +2 -2
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +54 -46
- package/dist/layout-painter/renderParagraph.js +3 -3
- package/dist/layout-painter/renderTable.js +16 -16
- package/dist/layout-painter/renderTextBox.js +2 -2
- package/dist/layout-painter/sdtBoundary.js +3 -2
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/paged-layout/blockGeometry.js +3 -2
- package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
- package/dist/paged-layout/editorScrollRoot.js +10 -1
- package/dist/paged-layout/rangeProjection.js +5 -4
- package/dist/paged-layout/scrollToPmPosition.js +3 -3
- package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
- package/dist/paged-layout/selectionViewportRect.js +8 -2
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +2 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +30 -2
- package/dist/prosemirror/commands/comments.js +189 -18
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentRecords.d.ts +137 -0
- package/dist/prosemirror/commentRecords.js +400 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +85 -34
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +140 -4
- package/dist/prosemirror/conversion/toProseDoc.js +432 -76
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +23 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/nativeSelection.d.ts +33 -0
- package/dist/prosemirror/nativeSelection.js +74 -0
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/numberedRefFields.d.ts +2 -0
- package/dist/prosemirror/numberedRefFields.js +16 -5
- package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
- package/dist/prosemirror/paragraphMarkJoin.js +155 -16
- package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +37 -15
- package/dist/prosemirror/plugins/suggestionMode.js +33 -10
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +13 -1
- package/dist/prosemirror/storyListNumbering.js +7 -2
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableResize.d.ts +10 -9
- package/dist/prosemirror/tableResize.js +60 -49
- package/dist/prosemirror/textInput.d.ts +30 -1
- package/dist/prosemirror/textInput.js +144 -17
- package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
- package/dist/prosemirror/validation.d.ts +19 -0
- package/dist/prosemirror/validation.js +79 -5
- package/dist/redline.js +23 -9
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
- package/dist/render-dom/RenderedDomContext.js +7 -6
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +38 -16
- package/dist/types/canonicalCapabilities.js +21 -18
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/findMatchView.js +4 -3
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/dist/utils/mergeDocumentContent.js +2 -2
- package/dist/utils/paintedPositions.d.ts +60 -0
- package/dist/utils/paintedPositions.js +101 -0
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -3
|
@@ -10,6 +10,7 @@ import { resolveTableCellPadding } from "../../layout-engine/types.js";
|
|
|
10
10
|
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
11
11
|
import { resolveParagraphLineGeometryForBlock, resolvePhysicalParagraphInlineLayout } from "../../utils/paragraphInlineLayout.js";
|
|
12
12
|
import { inlineImageBoundingBox } from "../../utils/rotationBoundingBox.js";
|
|
13
|
+
import { indexBlocksById } from "./blockIndex.js";
|
|
13
14
|
import { getPageTop } from "./hitTest.js";
|
|
14
15
|
import { computeLinePmRange } from "./linePmRange.js";
|
|
15
16
|
// src/layout-bridge/engine/selectionRects.ts
|
|
@@ -49,9 +50,6 @@ function mathRunToFontStyle(run) {
|
|
|
49
50
|
/**
|
|
50
51
|
* Find a block by its ID.
|
|
51
52
|
*/
|
|
52
|
-
function findBlockById(blocks, blockId) {
|
|
53
|
-
return blocks.findIndex((block) => block.id === blockId);
|
|
54
|
-
}
|
|
55
53
|
function getCellContentOffsetY(cell, cellMeasure, rowHeight) {
|
|
56
54
|
const { top: padTop } = resolveTableCellPadding(cell);
|
|
57
55
|
const spareHeight = Math.max(0, rowHeight - cellMeasure.height);
|
|
@@ -211,12 +209,13 @@ function selectionToRects(layout, blocks, measures, from, to) {
|
|
|
211
209
|
const selTo = Math.max(from, to);
|
|
212
210
|
const rects = [];
|
|
213
211
|
const tableCellPlacements = /* @__PURE__ */ new WeakMap();
|
|
212
|
+
const blockIndices = indexBlocksById(blocks);
|
|
214
213
|
for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex++) {
|
|
215
214
|
const page = layout.pages[pageIndex];
|
|
216
215
|
const pageTopY = getPageTop(layout, pageIndex);
|
|
217
216
|
for (const fragment of page.fragments) {
|
|
218
217
|
if (fragment.kind === "paragraph") {
|
|
219
|
-
const blockIndex =
|
|
218
|
+
const blockIndex = blockIndices.get(fragment.blockId) ?? -1;
|
|
220
219
|
if (blockIndex === -1) continue;
|
|
221
220
|
const block = blocks[blockIndex];
|
|
222
221
|
const measure = measures[blockIndex];
|
|
@@ -261,7 +260,7 @@ function selectionToRects(layout, blocks, measures, from, to) {
|
|
|
261
260
|
}
|
|
262
261
|
}
|
|
263
262
|
if (fragment.kind === "table") {
|
|
264
|
-
const blockIndex =
|
|
263
|
+
const blockIndex = blockIndices.get(fragment.blockId) ?? -1;
|
|
265
264
|
if (blockIndex === -1) continue;
|
|
266
265
|
const block = blocks[blockIndex];
|
|
267
266
|
const measure = measures[blockIndex];
|
|
@@ -385,12 +384,13 @@ function selectionToRects(layout, blocks, measures, from, to) {
|
|
|
385
384
|
* @returns Caret position, or null if not found.
|
|
386
385
|
*/
|
|
387
386
|
function getCaretPosition(layout, blocks, measures, pmPosition) {
|
|
387
|
+
const blockIndices = indexBlocksById(blocks);
|
|
388
388
|
for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex++) {
|
|
389
389
|
const page = layout.pages[pageIndex];
|
|
390
390
|
const pageTopY = getPageTop(layout, pageIndex);
|
|
391
391
|
for (const fragment of page.fragments) {
|
|
392
392
|
if (fragment.kind === "paragraph") {
|
|
393
|
-
const blockIndex =
|
|
393
|
+
const blockIndex = blockIndices.get(fragment.blockId) ?? -1;
|
|
394
394
|
if (blockIndex === -1) continue;
|
|
395
395
|
const block = blocks[blockIndex];
|
|
396
396
|
const measure = measures[blockIndex];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PAINTED_RANGE_SELECTOR, paintedStartSelector, readPaintedEnd, readPaintedStart } from "../utils/paintedPositions.js";
|
|
1
2
|
import { getCollapsedLineEdgeCaretGeometry } from "./dom/clickToPositionDom.js";
|
|
2
3
|
import { createTextStreamRange, descendantTextNodes, totalTextLength } from "./dom/textStreamDom.js";
|
|
3
4
|
// src/layout-bridge/headerFooterLayout.ts
|
|
@@ -35,8 +36,8 @@ function getHfDomSnapshot(section, doc) {
|
|
|
35
36
|
}
|
|
36
37
|
const cached = hfDomCache[section];
|
|
37
38
|
if (cached && cached.host === host && cached.host.isConnected) return cached;
|
|
38
|
-
const spans = Array.from(host.querySelectorAll(
|
|
39
|
-
const ranged = Array.from(host.querySelectorAll(
|
|
39
|
+
const spans = Array.from(host.querySelectorAll(`span${PAINTED_RANGE_SELECTOR}`));
|
|
40
|
+
const ranged = Array.from(host.querySelectorAll(PAINTED_RANGE_SELECTOR));
|
|
40
41
|
const snapshot = {
|
|
41
42
|
host,
|
|
42
43
|
spans,
|
|
@@ -66,8 +67,8 @@ function computeHfCaretRectFromView(view, section, doc = globalThis.document) {
|
|
|
66
67
|
if (!snapshot) return null;
|
|
67
68
|
const { host, spans } = snapshot;
|
|
68
69
|
for (const span of spans) {
|
|
69
|
-
const start =
|
|
70
|
-
const end =
|
|
70
|
+
const start = readPaintedStart(span) ?? NaN;
|
|
71
|
+
const end = readPaintedEnd(span) ?? NaN;
|
|
71
72
|
if (!Number.isFinite(start) || !Number.isFinite(end)) continue;
|
|
72
73
|
if (pmPos >= start && pmPos <= end) {
|
|
73
74
|
const collapsedGeometry = getCollapsedLineEdgeCaretGeometry(span, pmPos);
|
|
@@ -95,7 +96,7 @@ function computeHfCaretRectFromView(view, section, doc = globalThis.document) {
|
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
|
-
const anchor = host.querySelector(
|
|
99
|
+
const anchor = host.querySelector(paintedStartSelector(pmPos));
|
|
99
100
|
if (anchor) {
|
|
100
101
|
const rect = anchor.getBoundingClientRect();
|
|
101
102
|
return {
|
|
@@ -108,8 +109,8 @@ function computeHfCaretRectFromView(view, section, doc = globalThis.document) {
|
|
|
108
109
|
let bestEl = null;
|
|
109
110
|
let bestSpan = Infinity;
|
|
110
111
|
for (const el of ranged) {
|
|
111
|
-
const start =
|
|
112
|
-
const end =
|
|
112
|
+
const start = readPaintedStart(el) ?? NaN;
|
|
113
|
+
const end = readPaintedEnd(el) ?? NaN;
|
|
113
114
|
if (!Number.isFinite(start) || !Number.isFinite(end)) continue;
|
|
114
115
|
if (pmPos < start || pmPos > end) continue;
|
|
115
116
|
const span = end - start;
|
|
@@ -120,7 +121,7 @@ function computeHfCaretRectFromView(view, section, doc = globalThis.document) {
|
|
|
120
121
|
}
|
|
121
122
|
if (bestEl) {
|
|
122
123
|
const rect = bestEl.getBoundingClientRect();
|
|
123
|
-
const atEnd = pmPos >=
|
|
124
|
+
const atEnd = pmPos >= (readPaintedEnd(bestEl) ?? NaN);
|
|
124
125
|
return {
|
|
125
126
|
top: rect.top,
|
|
126
127
|
left: atEnd ? rect.right : rect.left + 1,
|
|
@@ -130,7 +131,7 @@ function computeHfCaretRectFromView(view, section, doc = globalThis.document) {
|
|
|
130
131
|
let trailingEl = null;
|
|
131
132
|
let trailingStart = -Infinity;
|
|
132
133
|
for (const el of ranged) {
|
|
133
|
-
const start =
|
|
134
|
+
const start = readPaintedStart(el) ?? NaN;
|
|
134
135
|
if (!Number.isFinite(start)) continue;
|
|
135
136
|
if (start > pmPos) continue;
|
|
136
137
|
if (start > trailingStart) {
|
|
@@ -175,8 +176,8 @@ function computeHfSelectionRectsFromView(view, section, doc = globalThis.documen
|
|
|
175
176
|
if (!snapshot) return out;
|
|
176
177
|
const { spans } = snapshot;
|
|
177
178
|
for (const spanEl of spans) {
|
|
178
|
-
const pmStart =
|
|
179
|
-
const pmEnd =
|
|
179
|
+
const pmStart = readPaintedStart(spanEl) ?? NaN;
|
|
180
|
+
const pmEnd = readPaintedEnd(spanEl) ?? NaN;
|
|
180
181
|
if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd)) continue;
|
|
181
182
|
if (pmEnd <= from || pmStart >= to) continue;
|
|
182
183
|
if (spanEl.classList.contains("layout-run-tab")) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readPaintedStart } from "../utils/paintedPositions.js";
|
|
1
2
|
// src/layout-bridge/tableInsertHover.ts
|
|
2
3
|
/**
|
|
3
4
|
* Table-insert "+" hover hit-test.
|
|
@@ -65,7 +66,7 @@ function detectTableInsertHover(input) {
|
|
|
65
66
|
if (!nearLeftEdge && !nearTopEdge) return null;
|
|
66
67
|
const rows = tableEl.querySelectorAll(`:scope > ${rowSelector}`);
|
|
67
68
|
if (rows.length === 0) return null;
|
|
68
|
-
const getCellPmPos = (el) => el ?
|
|
69
|
+
const getCellPmPos = (el) => el ? readPaintedStart(el) || 0 : 0;
|
|
69
70
|
if (nearLeftEdge) for (const row of Array.from(rows)) {
|
|
70
71
|
const rowRect = row.getBoundingClientRect();
|
|
71
72
|
if (mouseY >= rowRect.top && mouseY <= rowRect.bottom) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FootnoteContent, FootnoteWindow, Page } from "./types.js";
|
|
2
|
+
/** What each note's reference reserves on a page of this content height. */
|
|
3
|
+
export declare const footnoteReservationHeights: (heights: ReadonlyMap<number, number>, contentHeight: number) => Map<number, number>;
|
|
4
|
+
/** Every height a window of the note may end at, ascending, the note's end last. */
|
|
5
|
+
export declare const footnoteBreakOffsets: (content: Pick<FootnoteContent, "measures" | "height">) => number[];
|
|
6
|
+
type NoteContent = Pick<FootnoteContent, "measures" | "height">;
|
|
7
|
+
type PlanOptions = {
|
|
8
|
+
pages: readonly Page[];
|
|
9
|
+
contentById: ReadonlyMap<number, NoteContent>;
|
|
10
|
+
/** Pages already added past the last body page for a note's rest. */
|
|
11
|
+
trailingPages?: number;
|
|
12
|
+
};
|
|
13
|
+
export type FootnoteContinuationPlan = {
|
|
14
|
+
/** A page number's notes and their height, for each page the plan changes. */
|
|
15
|
+
pages: Map<number, {
|
|
16
|
+
ids: number[];
|
|
17
|
+
windows: FootnoteWindow[];
|
|
18
|
+
height: number;
|
|
19
|
+
}>;
|
|
20
|
+
/** The height a carried note reserves on a page before the body is placed. */
|
|
21
|
+
reservedHeights: Map<number, number>;
|
|
22
|
+
/** Pages the rest of a note still needs beyond the ones laid out. */
|
|
23
|
+
extraPages: number;
|
|
24
|
+
/** How many pages past the last body page the layout should add. */
|
|
25
|
+
trailingPages: number;
|
|
26
|
+
};
|
|
27
|
+
/** Where each note's windows fall, given how the body laid out. */
|
|
28
|
+
export declare const planFootnoteContinuation: ({ pages, contentById, trailingPages }: PlanOptions) => FootnoteContinuationPlan;
|
|
29
|
+
/** Whether a layout was made with what this plan asks for. */
|
|
30
|
+
export declare const footnoteContinuationSettled: (used: {
|
|
31
|
+
reservedHeights: ReadonlyMap<number, number> | undefined;
|
|
32
|
+
trailingPages: number;
|
|
33
|
+
}, plan: FootnoteContinuationPlan) => boolean;
|
|
34
|
+
/** The pages with a plan's note windows. */
|
|
35
|
+
export declare const applyFootnoteContinuation: (pages: readonly Page[], plan: FootnoteContinuationPlan) => Page[];
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { measuredLineAdvance } from "./lineFlow.js";
|
|
2
|
+
import "./types.js";
|
|
3
|
+
// src/layout-engine/footnoteContinuation.ts
|
|
4
|
+
/**
|
|
5
|
+
* A footnote taller than the room its page leaves continues on the next page.
|
|
6
|
+
*
|
|
7
|
+
* The note's reference line keeps its page and the note fills what is left of
|
|
8
|
+
* it. What remains opens the next page's note area, ahead of that page's own
|
|
9
|
+
* notes, and the body there moves up to make room. A note never breaks through
|
|
10
|
+
* a line: each page shows a window of the note between two line bottoms.
|
|
11
|
+
*/
|
|
12
|
+
/** The most of a page a note may claim, keeping body beside its reference. */
|
|
13
|
+
const NOTE_SHARE_OF_PAGE = .75;
|
|
14
|
+
const EPSILON = .01;
|
|
15
|
+
const contentHeightOf = (page) => page.size.h - page.margins.top - page.margins.bottom;
|
|
16
|
+
const noteShareOf = (contentHeight) => Math.max(0, contentHeight) * NOTE_SHARE_OF_PAGE;
|
|
17
|
+
/** What each note's reference reserves on a page of this content height. */
|
|
18
|
+
const footnoteReservationHeights = (heights, contentHeight) => {
|
|
19
|
+
const share = noteShareOf(contentHeight);
|
|
20
|
+
const reserved = /* @__PURE__ */ new Map();
|
|
21
|
+
for (const [id, height] of heights) reserved.set(id, Math.min(height, share));
|
|
22
|
+
return reserved;
|
|
23
|
+
};
|
|
24
|
+
const blockHeight = (measure) => {
|
|
25
|
+
if (measure.kind === "paragraph" || measure.kind === "table") return measure.totalHeight;
|
|
26
|
+
return measure.kind === "image" || measure.kind === "textBox" ? measure.height : 0;
|
|
27
|
+
};
|
|
28
|
+
/** Where a block can be cut inside itself: below a line or below a row. */
|
|
29
|
+
const inBlockBreakOffsets = (measure, top) => {
|
|
30
|
+
const offsets = [];
|
|
31
|
+
let bottom = top;
|
|
32
|
+
if (measure.kind === "paragraph") for (const line of measure.lines.slice(0, -1)) {
|
|
33
|
+
bottom += measuredLineAdvance(line);
|
|
34
|
+
offsets.push(bottom);
|
|
35
|
+
}
|
|
36
|
+
else if (measure.kind === "table") for (const row of measure.rows.slice(0, -1)) {
|
|
37
|
+
bottom += row.height;
|
|
38
|
+
offsets.push(bottom);
|
|
39
|
+
}
|
|
40
|
+
return offsets;
|
|
41
|
+
};
|
|
42
|
+
/** Every height a window of the note may end at, ascending, the note's end last. */
|
|
43
|
+
const footnoteBreakOffsets = (content) => {
|
|
44
|
+
const offsets = [];
|
|
45
|
+
let top = 0;
|
|
46
|
+
for (const measure of content.measures) {
|
|
47
|
+
offsets.push(...inBlockBreakOffsets(measure, top));
|
|
48
|
+
top += blockHeight(measure);
|
|
49
|
+
offsets.push(top);
|
|
50
|
+
}
|
|
51
|
+
offsets.push(content.height);
|
|
52
|
+
return [...new Set(offsets)].toSorted((a, b) => a - b);
|
|
53
|
+
};
|
|
54
|
+
const bodyBottomOf = (page) => {
|
|
55
|
+
let bottom = 0;
|
|
56
|
+
for (const fragment of page.fragments) bottom = Math.max(bottom, fragment.y + ("height" in fragment ? fragment.height : 0));
|
|
57
|
+
return Math.max(0, bottom - page.margins.top);
|
|
58
|
+
};
|
|
59
|
+
/** What of these notes fits a page's room, and what goes on to the next page. */
|
|
60
|
+
const placeEntries = ({ entries, room, fullRoom, contentById }) => {
|
|
61
|
+
const ids = [];
|
|
62
|
+
const windows = [];
|
|
63
|
+
const rest = [];
|
|
64
|
+
let left = room;
|
|
65
|
+
let cut = false;
|
|
66
|
+
let height = 12;
|
|
67
|
+
for (const { noteId, from } of entries) {
|
|
68
|
+
const content = contentById.get(noteId);
|
|
69
|
+
if (!content) continue;
|
|
70
|
+
if (cut) {
|
|
71
|
+
rest.push({
|
|
72
|
+
noteId,
|
|
73
|
+
from
|
|
74
|
+
});
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const remaining = content.height - from;
|
|
78
|
+
if (remaining + 0 <= left + EPSILON) {
|
|
79
|
+
ids.push(noteId);
|
|
80
|
+
if (from > 0) windows.push({
|
|
81
|
+
noteId,
|
|
82
|
+
from,
|
|
83
|
+
to: content.height
|
|
84
|
+
});
|
|
85
|
+
left -= remaining + 0;
|
|
86
|
+
height += remaining + 0;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const start = from + EPSILON;
|
|
90
|
+
const offsets = footnoteBreakOffsets(content).filter((offset) => offset > start);
|
|
91
|
+
let fitting;
|
|
92
|
+
for (const offset of offsets) if (offset - from <= left + EPSILON) fitting = offset;
|
|
93
|
+
const next = offsets.at(0);
|
|
94
|
+
const oversized = ids.length === 0 && next !== void 0 && next - from > fullRoom + EPSILON;
|
|
95
|
+
const to = fitting ?? (oversized ? next : void 0);
|
|
96
|
+
cut = true;
|
|
97
|
+
if (to === void 0) {
|
|
98
|
+
rest.push({
|
|
99
|
+
noteId,
|
|
100
|
+
from
|
|
101
|
+
});
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
ids.push(noteId);
|
|
105
|
+
windows.push({
|
|
106
|
+
noteId,
|
|
107
|
+
from,
|
|
108
|
+
to
|
|
109
|
+
});
|
|
110
|
+
height += to - from + 0;
|
|
111
|
+
if (to < content.height - EPSILON) rest.push({
|
|
112
|
+
noteId,
|
|
113
|
+
from: to
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
ids,
|
|
118
|
+
windows,
|
|
119
|
+
rest,
|
|
120
|
+
height: ids.length === 0 ? 0 : height
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/** Where each note's windows fall, given how the body laid out. */
|
|
124
|
+
const planFootnoteContinuation = ({ pages, contentById, trailingPages = 0 }) => {
|
|
125
|
+
const plan = {
|
|
126
|
+
pages: /* @__PURE__ */ new Map(),
|
|
127
|
+
reservedHeights: /* @__PURE__ */ new Map(),
|
|
128
|
+
extraPages: 0,
|
|
129
|
+
trailingPages
|
|
130
|
+
};
|
|
131
|
+
const last = pages.at(-1);
|
|
132
|
+
if (!last) return plan;
|
|
133
|
+
const reserveFor = (entries, fromPage) => {
|
|
134
|
+
let needed = 12;
|
|
135
|
+
for (const { noteId, from } of entries) {
|
|
136
|
+
const height = contentById.get(noteId)?.height ?? from;
|
|
137
|
+
needed += height - from + 0;
|
|
138
|
+
}
|
|
139
|
+
for (let next = fromPage; needed > EPSILON; next += 1) {
|
|
140
|
+
const share = noteShareOf(contentHeightOf(pages[next - 1] ?? last));
|
|
141
|
+
if (share <= EPSILON) {
|
|
142
|
+
if (next > pages.length) break;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
plan.reservedHeights.set(next, Math.min(needed, share));
|
|
146
|
+
needed -= share;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
let carried = [];
|
|
150
|
+
for (const page of pages) {
|
|
151
|
+
const own = (page.footnoteIds ?? []).map((noteId) => ({
|
|
152
|
+
noteId,
|
|
153
|
+
from: 0
|
|
154
|
+
}));
|
|
155
|
+
const fullRoom = contentHeightOf(page) - 12;
|
|
156
|
+
const placed = placeEntries({
|
|
157
|
+
entries: [...carried, ...own],
|
|
158
|
+
room: fullRoom - bodyBottomOf(page),
|
|
159
|
+
fullRoom,
|
|
160
|
+
contentById
|
|
161
|
+
});
|
|
162
|
+
if (carried.length > 0 || placed.rest.length > 0) plan.pages.set(page.number, {
|
|
163
|
+
ids: placed.ids,
|
|
164
|
+
windows: placed.windows,
|
|
165
|
+
height: placed.height
|
|
166
|
+
});
|
|
167
|
+
carried = placed.rest;
|
|
168
|
+
if (carried.length > 0) reserveFor(carried, page.number + 1);
|
|
169
|
+
}
|
|
170
|
+
const fullRoom = contentHeightOf(last) - 12;
|
|
171
|
+
while (carried.length > 0) {
|
|
172
|
+
plan.extraPages += 1;
|
|
173
|
+
carried = placeEntries({
|
|
174
|
+
entries: carried,
|
|
175
|
+
room: fullRoom,
|
|
176
|
+
fullRoom,
|
|
177
|
+
contentById
|
|
178
|
+
}).rest;
|
|
179
|
+
}
|
|
180
|
+
let surplus = 0;
|
|
181
|
+
if (plan.extraPages === 0) {
|
|
182
|
+
const noteOn = (page) => plan.pages.get(page.number)?.ids.length ?? page.footnoteIds?.length ?? 0;
|
|
183
|
+
for (const page of pages.slice(pages.length - trailingPages).toReversed()) {
|
|
184
|
+
if (page.fragments.length > 0 || noteOn(page) > 0) break;
|
|
185
|
+
surplus += 1;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
plan.trailingPages = trailingPages + plan.extraPages - surplus;
|
|
189
|
+
return plan;
|
|
190
|
+
};
|
|
191
|
+
/** Whether a layout was made with what this plan asks for. */
|
|
192
|
+
const footnoteContinuationSettled = (used, plan) => {
|
|
193
|
+
if (used.trailingPages !== plan.trailingPages) return false;
|
|
194
|
+
if ((used.reservedHeights?.size ?? 0) !== plan.reservedHeights.size) return false;
|
|
195
|
+
for (const [page, height] of plan.reservedHeights) if (Math.abs((used.reservedHeights?.get(page) ?? -1) - height) > EPSILON) return false;
|
|
196
|
+
return true;
|
|
197
|
+
};
|
|
198
|
+
/** The pages with a plan's note windows. */
|
|
199
|
+
const applyFootnoteContinuation = (pages, plan) => pages.map((page) => {
|
|
200
|
+
const placed = plan.pages.get(page.number);
|
|
201
|
+
if (!placed) return page;
|
|
202
|
+
const next = {
|
|
203
|
+
...page,
|
|
204
|
+
footnoteIds: placed.ids,
|
|
205
|
+
footnoteReservedHeight: placed.height
|
|
206
|
+
};
|
|
207
|
+
if (placed.windows.length > 0) next.footnoteWindows = placed.windows;
|
|
208
|
+
return next;
|
|
209
|
+
});
|
|
210
|
+
export { applyFootnoteContinuation, footnoteBreakOffsets, footnoteContinuationSettled, footnoteReservationHeights, planFootnoteContinuation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockId, BorderStyle, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, SectionPageNumbering, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxGradientFill, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, stripFlowBlockPmAnchors, tableColumnsArePinned } from "./types.js";
|
|
1
|
+
import { BlockId, BorderStyle, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, FootnoteWindow, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, SectionPageNumbering, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxGradientFill, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, stripFlowBlockPmAnchors, tableColumnsArePinned } from "./types.js";
|
|
2
2
|
import { PageState, Paginator, PaginatorOptions, createPaginator } from "./paginator.js";
|
|
3
3
|
import { KeepNextChain, calculateChainHeight, computeKeepNextChains, getMidChainIndices, hasKeepLines, hasPageBreakBefore } from "./keep-together.js";
|
|
4
4
|
import { resolveSectionHeaderFooterRefs } from "./headerFooterRefs.js";
|
|
@@ -25,4 +25,4 @@ export declare function applyContextualSpacing(blocks: FlowBlock[]): void;
|
|
|
25
25
|
* reservations as page floors so every column participates in the same footnote geometry.
|
|
26
26
|
*/
|
|
27
27
|
export declare function layoutDocument(blocks: FlowBlock[], measures: Measure[], options: LayoutOptions): Layout;
|
|
28
|
-
export { BlockId, BorderStyle, type BreakDecision, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, type KeepNextChain, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, type PageState, type Paginator, type PaginatorOptions, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, type SectionLayoutConfig, SectionPageNumbering, type SectionState, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxGradientFill, TextBoxMeasure, TextRun, applyPendingToActive, assertExhaustiveFlowBlock, calculateChainHeight, collectSectionConfigs, computeKeepNextChains, createInitialSectionState, createPaginator, findPageIndexContainingPmPos, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getEffectiveColumns, getEffectiveMargins, getEffectivePageSize, getHeaderRowsHeight, getMidChainIndices, getTableRowLeadingWidth, hasKeepLines, hasPageBreakBefore, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveSectionHeaderFooterRefs, resolveTableCellPadding, resolveTableWidthPx, scheduleSectionBreak, stripFlowBlockPmAnchors, tableColumnsArePinned };
|
|
28
|
+
export { BlockId, BorderStyle, type BreakDecision, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, FootnoteWindow, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, type KeepNextChain, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, type PageState, type Paginator, type PaginatorOptions, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, type SectionLayoutConfig, SectionPageNumbering, type SectionState, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxGradientFill, TextBoxMeasure, TextRun, applyPendingToActive, assertExhaustiveFlowBlock, calculateChainHeight, collectSectionConfigs, computeKeepNextChains, createInitialSectionState, createPaginator, findPageIndexContainingPmPos, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getEffectiveColumns, getEffectiveMargins, getEffectivePageSize, getHeaderRowsHeight, getMidChainIndices, getTableRowLeadingWidth, hasKeepLines, hasPageBreakBefore, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveSectionHeaderFooterRefs, resolveTableCellPadding, resolveTableWidthPx, scheduleSectionBreak, stripFlowBlockPmAnchors, tableColumnsArePinned };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { reflowFootnoteColumns } from "./footnoteColumnReflow.js";
|
|
2
|
+
import { footnoteReservationHeights } from "./footnoteContinuation.js";
|
|
2
3
|
import { resolveSectionHeaderFooterRefs } from "./headerFooterRefs.js";
|
|
3
4
|
import { layoutImage } from "./imageLayout.js";
|
|
4
5
|
import { calculateChainHeight, computeKeepNextChains, getMidChainIndices, hasKeepLines, hasPageBreakBefore } from "./keep-together.js";
|
|
@@ -125,6 +126,8 @@ function layoutDocumentPass(blocks, measures, options) {
|
|
|
125
126
|
let activeSectionMarginTop = initialConfig.margins.top;
|
|
126
127
|
let activeSectionPageHeight = initialConfig.pageSize.h;
|
|
127
128
|
let activeSectionMarginBottom = initialConfig.margins.bottom;
|
|
129
|
+
const noteHeightsForActiveSection = () => options.footnoteHeightById && options.footnoteContinuation ? footnoteReservationHeights(options.footnoteHeightById, activeSectionPageHeight - activeSectionMarginTop - activeSectionMarginBottom) : options.footnoteHeightById;
|
|
130
|
+
let footnoteHeightById = noteHeightsForActiveSection();
|
|
128
131
|
let renderedBreakState = INITIAL_RENDERED_BREAK_STATE;
|
|
129
132
|
const noteAreaContinuation = createNoteAreaContinuation(options.noteAreas, paginator);
|
|
130
133
|
for (let i = 0; i < blocks.length; i++) {
|
|
@@ -166,13 +169,13 @@ function layoutDocumentPass(blocks, measures, options) {
|
|
|
166
169
|
measure,
|
|
167
170
|
paginator,
|
|
168
171
|
contentWidth: paginator.columnWidth,
|
|
169
|
-
footnoteHeightById
|
|
172
|
+
footnoteHeightById,
|
|
170
173
|
suppressSpaceBefore: breakDecision.suppressSpaceBefore || suppressDocumentStartAutomaticSpaceBefore
|
|
171
174
|
});
|
|
172
175
|
break;
|
|
173
176
|
case "table":
|
|
174
177
|
if (block.floating) layoutFloatingTable(block, measure, paginator, paginator.getContentWidth());
|
|
175
|
-
else layoutTable(block, measure, paginator,
|
|
178
|
+
else layoutTable(block, measure, paginator, footnoteHeightById);
|
|
176
179
|
break;
|
|
177
180
|
case "image":
|
|
178
181
|
layoutImage(block, measure, paginator);
|
|
@@ -216,6 +219,7 @@ function layoutDocumentPass(blocks, measures, options) {
|
|
|
216
219
|
activeSectionMarginTop = nextSectionConfig.margins.top;
|
|
217
220
|
activeSectionPageHeight = nextSectionConfig.pageSize.h;
|
|
218
221
|
activeSectionMarginBottom = nextSectionConfig.margins.bottom;
|
|
222
|
+
footnoteHeightById = noteHeightsForActiveSection();
|
|
219
223
|
sectionIdx++;
|
|
220
224
|
break;
|
|
221
225
|
}
|
|
@@ -230,6 +234,7 @@ function layoutDocumentPass(blocks, measures, options) {
|
|
|
230
234
|
}
|
|
231
235
|
paginator.setPageTopContinuation(void 0);
|
|
232
236
|
if (paginator.states.length === 0) paginator.getCurrentState();
|
|
237
|
+
for (let added = 0; added < (options.footnoteContinuation?.trailingPages ?? 0); added += 1) paginator.forcePageBreak();
|
|
233
238
|
return {
|
|
234
239
|
pageSize,
|
|
235
240
|
pages: paginator.pages,
|
|
@@ -57,6 +57,8 @@ export declare function setFontCacheSize(size: number): void;
|
|
|
57
57
|
export declare function getFontCacheSize(): number;
|
|
58
58
|
/** Serialize the complete, semantically normalized paragraph measurement contract into a cache key. */
|
|
59
59
|
export declare function hashParagraphBlock(block: ParagraphBlock): string;
|
|
60
|
+
/** `hashParagraphBlock` computed in full. */
|
|
61
|
+
export declare function serializeParagraphBlock(block: ParagraphBlock): string;
|
|
60
62
|
/**
|
|
61
63
|
* Get cached paragraph measurement or return undefined
|
|
62
64
|
*/
|
|
@@ -2,6 +2,7 @@ import { documentFontFactsCacheIdentity } from "../../fonts/documentFontFacts.js
|
|
|
2
2
|
import { embeddedFontFingerprint } from "../../fonts/embeddedFontFingerprint.js";
|
|
3
3
|
import { getLineBreakProviderGeneration } from "./lineBreakProvider.js";
|
|
4
4
|
import { clearFontResolvedCache } from "./measureHelpers.js";
|
|
5
|
+
import { memoizedParagraphKey } from "./paragraphKeyMemo.js";
|
|
5
6
|
import { panic } from "better-result";
|
|
6
7
|
// src/layout-engine/measure/cache.ts
|
|
7
8
|
/**
|
|
@@ -192,6 +193,8 @@ const imageMeasureCacheInput = (run) => ({
|
|
|
192
193
|
exactLineHeight: run.exactLineHeight,
|
|
193
194
|
positioned: run.position !== void 0
|
|
194
195
|
});
|
|
196
|
+
/** A cache input naming no position: one that names a position does not compile. */
|
|
197
|
+
const positionFree = (input) => input;
|
|
195
198
|
const runMeasureCacheInput = (run, fontContextRef, documentFontContextRef) => {
|
|
196
199
|
switch (run.kind) {
|
|
197
200
|
case "text":
|
|
@@ -199,15 +202,18 @@ const runMeasureCacheInput = (run, fontContextRef, documentFontContextRef) => {
|
|
|
199
202
|
case "renderedPageBreak":
|
|
200
203
|
case "field":
|
|
201
204
|
case "math": {
|
|
202
|
-
const { embeddedFontFamilyMap, documentFontFacts, ...formatting } = run;
|
|
203
|
-
return {
|
|
205
|
+
const { embeddedFontFamilyMap, documentFontFacts, pmStart: _pmStart, pmEnd: _pmEnd, ...formatting } = run;
|
|
206
|
+
return positionFree({
|
|
204
207
|
...formatting,
|
|
205
208
|
embeddedFontFamilies: fontContextRef(embeddedFontFamilyMap),
|
|
206
209
|
documentFontFacts: documentFontContextRef(documentFontFacts)
|
|
207
|
-
};
|
|
210
|
+
});
|
|
208
211
|
}
|
|
209
|
-
case "lineBreak":
|
|
210
|
-
|
|
212
|
+
case "lineBreak": {
|
|
213
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...lineBreak } = run;
|
|
214
|
+
return positionFree(lineBreak);
|
|
215
|
+
}
|
|
216
|
+
case "image": return positionFree(imageMeasureCacheInput(run));
|
|
211
217
|
default: return run;
|
|
212
218
|
}
|
|
213
219
|
};
|
|
@@ -227,6 +233,10 @@ const paragraphAttrsMeasureCacheInput = (attrs, fontContextRef, documentFontCont
|
|
|
227
233
|
};
|
|
228
234
|
/** Serialize the complete, semantically normalized paragraph measurement contract into a cache key. */
|
|
229
235
|
function hashParagraphBlock(block) {
|
|
236
|
+
return memoizedParagraphKey(block, getLineBreakProviderGeneration(), serializeParagraphBlock);
|
|
237
|
+
}
|
|
238
|
+
/** `hashParagraphBlock` computed in full. */
|
|
239
|
+
function serializeParagraphBlock(block) {
|
|
230
240
|
const fontContexts = [];
|
|
231
241
|
const contextRefs = /* @__PURE__ */ new Map();
|
|
232
242
|
const documentFontContexts = [];
|
|
@@ -372,4 +382,4 @@ function labelMeasureCachesFontSet(fontSet) {
|
|
|
372
382
|
function getTotalCacheSize() {
|
|
373
383
|
return getTextCacheSize() + getFontCacheSize() + getParagraphCacheSize();
|
|
374
384
|
}
|
|
375
|
-
export { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTextWidthCacheGeneration, getTotalCacheSize, hashParagraphBlock, labelMeasureCachesFontSet, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize, syncMeasureCachesToFontSet };
|
|
385
|
+
export { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTextWidthCacheGeneration, getTotalCacheSize, hashParagraphBlock, labelMeasureCachesFontSet, serializeParagraphBlock, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize, syncMeasureCachesToFontSet };
|
|
@@ -589,7 +589,7 @@ function measureParagraph(block, maxWidth, options) {
|
|
|
589
589
|
while (chunkStart < measuredWord.length) {
|
|
590
590
|
const spaceLeft = currentLine.availableWidth - currentLine.width - chunkLeadingLetterSpacing + WIDTH_TOLERANCE;
|
|
591
591
|
const remaining = measuredWord.slice(chunkStart);
|
|
592
|
-
|
|
592
|
+
const bestEnd = findMaxFittingLength(remaining, style, spaceLeft, currentLine.width === 0, breakPolicy);
|
|
593
593
|
if (bestEnd === 0) {
|
|
594
594
|
startNewLine(runIndex, charIndex + chunkStart);
|
|
595
595
|
chunkLeadingLetterSpacing = 0;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParagraphBlock } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Record that `block` is `origin`, the block kept for its paragraph, moved:
|
|
4
|
+
* the two show the same, positions aside.
|
|
5
|
+
*/
|
|
6
|
+
export declare const noteParagraphOrigin: (block: ParagraphBlock, origin: ParagraphBlock) => void;
|
|
7
|
+
/** `block`'s key: a recorded one while its values hold, else `compute`'s. */
|
|
8
|
+
export declare const memoizedParagraphKey: (block: ParagraphBlock, generation: number, compute: (block: ParagraphBlock) => string) => string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { documentFontFactsCacheIdentity } from "../../fonts/documentFontFacts.js";
|
|
2
|
+
// src/layout-engine/measure/paragraphKeyMemo.ts
|
|
3
|
+
/**
|
|
4
|
+
* The measurement key of a paragraph that an edit only moved, without
|
|
5
|
+
* serializing it again.
|
|
6
|
+
*
|
|
7
|
+
* Every layout pass converts the document into fresh blocks, and a paragraph
|
|
8
|
+
* after an edit comes out as a copy of the block kept for it with shifted
|
|
9
|
+
* positions. Its key is the key of what it was moved from whenever every
|
|
10
|
+
* value the key reads is the one it read then: the key never reads
|
|
11
|
+
* positions, and the values a moved block shares are never written after
|
|
12
|
+
* conversion. A block whose values differ, or whose origin is unknown, is
|
|
13
|
+
* serialized in full.
|
|
14
|
+
*/
|
|
15
|
+
/** The run fields the key leaves out: they say where a run stands. */
|
|
16
|
+
const POSITION_FIELDS = /* @__PURE__ */ new Set(["pmStart", "pmEnd"]);
|
|
17
|
+
const NO_FIELDS = /* @__PURE__ */ new Set();
|
|
18
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype;
|
|
19
|
+
const fieldsOf = (record, skip) => Object.entries(record).filter(([name]) => !skip.has(name)).map(([name, value]) => [name, isPlainObject(value) ? { fields: Object.entries(value) } : { value }]);
|
|
20
|
+
const countFields = (record, skip) => {
|
|
21
|
+
let count = 0;
|
|
22
|
+
for (const name of Object.keys(record)) if (!skip.has(name)) count += 1;
|
|
23
|
+
return count;
|
|
24
|
+
};
|
|
25
|
+
/** Whether `record` holds the values `fields` recorded, nested ones included. */
|
|
26
|
+
const holds = (record, fields, skip) => {
|
|
27
|
+
if (countFields(record, skip) !== fields.length) return false;
|
|
28
|
+
for (const [name, recorded] of fields) {
|
|
29
|
+
const value = record[name];
|
|
30
|
+
if (!("fields" in recorded)) {
|
|
31
|
+
if (value !== recorded.value) return false;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (!isPlainObject(value)) return false;
|
|
35
|
+
if (Object.keys(value).length !== recorded.fields.length) return false;
|
|
36
|
+
for (const [nestedName, nestedValue] of recorded.fields) if (value[nestedName] !== nestedValue) return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
const factIdentitiesOf = (block) => {
|
|
41
|
+
const identities = [factIdentity(block.attrs?.documentFontFacts)];
|
|
42
|
+
for (const run of block.runs) if ("documentFontFacts" in run) identities.push(factIdentity(run.documentFontFacts));
|
|
43
|
+
return identities;
|
|
44
|
+
};
|
|
45
|
+
const factIdentity = (facts) => documentFontFactsCacheIdentity(facts);
|
|
46
|
+
const record = (block, key, generation) => ({
|
|
47
|
+
key,
|
|
48
|
+
generation,
|
|
49
|
+
attrs: block.attrs === void 0 ? void 0 : fieldsOf(block.attrs, NO_FIELDS),
|
|
50
|
+
runs: block.runs.map((run) => fieldsOf(run, POSITION_FIELDS)),
|
|
51
|
+
factIdentities: factIdentitiesOf(block)
|
|
52
|
+
});
|
|
53
|
+
const stillHolds = (recorded, block, generation) => {
|
|
54
|
+
if (recorded.generation !== generation) return false;
|
|
55
|
+
if (recorded.runs.length !== block.runs.length) return false;
|
|
56
|
+
if (recorded.attrs === void 0 !== (block.attrs === void 0)) return false;
|
|
57
|
+
if (recorded.attrs !== void 0 && !holds(block.attrs, recorded.attrs, NO_FIELDS)) return false;
|
|
58
|
+
for (const [index, run] of block.runs.entries()) {
|
|
59
|
+
const fields = recorded.runs[index];
|
|
60
|
+
if (!fields || !holds(run, fields, POSITION_FIELDS)) return false;
|
|
61
|
+
}
|
|
62
|
+
const identities = factIdentitiesOf(block);
|
|
63
|
+
return identities.length === recorded.factIdentities.length && identities.every((identity, index) => identity === recorded.factIdentities[index]);
|
|
64
|
+
};
|
|
65
|
+
/** The block each block was moved from, as the block cache keeps it. */
|
|
66
|
+
const origins = /* @__PURE__ */ new WeakMap();
|
|
67
|
+
/** The key last given to a block or to blocks moved from an origin. */
|
|
68
|
+
const keys = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
/**
|
|
70
|
+
* Record that `block` is `origin`, the block kept for its paragraph, moved:
|
|
71
|
+
* the two show the same, positions aside.
|
|
72
|
+
*/
|
|
73
|
+
const noteParagraphOrigin = (block, origin) => {
|
|
74
|
+
origins.set(block, origin);
|
|
75
|
+
};
|
|
76
|
+
/** `block`'s key: a recorded one while its values hold, else `compute`'s. */
|
|
77
|
+
const memoizedParagraphKey = (block, generation, compute) => {
|
|
78
|
+
const own = keys.get(block);
|
|
79
|
+
if (own && stillHolds(own, block, generation)) return own.key;
|
|
80
|
+
const origin = origins.get(block);
|
|
81
|
+
const moved = origin === void 0 ? void 0 : keys.get(origin);
|
|
82
|
+
if (moved && stillHolds(moved, block, generation)) {
|
|
83
|
+
keys.set(block, moved);
|
|
84
|
+
return moved.key;
|
|
85
|
+
}
|
|
86
|
+
const key = compute(block);
|
|
87
|
+
const recorded = record(block, key, generation);
|
|
88
|
+
keys.set(block, recorded);
|
|
89
|
+
if (origin !== void 0) keys.set(origin, recorded);
|
|
90
|
+
return key;
|
|
91
|
+
};
|
|
92
|
+
export { memoizedParagraphKey, noteParagraphOrigin };
|