@stll/folio-core 0.66.2 → 0.68.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 +138 -17
- package/dist/ai-edits/batch-claims.js +5 -3
- package/dist/ai-edits/clean-text.js +4 -1
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/read.js +6 -4
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +32 -17
- package/dist/ai-edits/table-cell-mutations.js +3 -2
- package/dist/ai-edits/table-row-column-mutations.js +20 -6
- 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 +29 -12
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +77 -19
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -2
- package/dist/controller/canonicalInput.js +47 -2
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +328 -75
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- 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 +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +10 -3
- package/dist/controller/hiddenEditorManager.js +94 -38
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +55 -18
- package/dist/controller/layoutSession.d.ts +1 -0
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.d.ts +3 -1
- package/dist/display-list/build/tablePrimitives.js +49 -14
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- 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 +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/chartPreview.d.ts +4 -1
- package/dist/docx/chartPreview.js +26 -15
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- 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/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 +17 -0
- package/dist/docx/hostCommentThreads.js +49 -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 +227 -96
- package/dist/docx/mainDocumentPart.d.ts +6 -0
- package/dist/docx/mainDocumentPart.js +65 -0
- 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/packageParts.d.ts +1 -1
- package/dist/docx/packageParts.js +10 -4
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- 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 +6 -0
- package/dist/docx/previewBudget.d.ts +6 -0
- package/dist/docx/previewBudget.js +7 -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 +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +42 -25
- 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 +3 -1
- 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/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/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/shapeAlternateContent.js +19 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- 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/unzip.js +2 -0
- package/dist/docx/verticalMergeProjection.js +1 -1
- 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/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/wholeStoryRevisionResolution.js +57 -12
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
- package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/tableConversion.js +25 -10
- package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/clickToPosition.js +5 -1
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- 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.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
- package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
- package/dist/layout-engine/tableLayout.js +34 -7
- package/dist/layout-engine/tableRowBreak.d.ts +46 -0
- package/dist/layout-engine/tableRowBreak.js +193 -36
- package/dist/layout-engine/types.d.ts +43 -3
- package/dist/layout-painter/previewSvg.d.ts +8 -0
- package/dist/layout-painter/previewSvg.js +47 -0
- package/dist/layout-painter/renderImage.js +2 -1
- package/dist/layout-painter/renderPage.d.ts +5 -4
- package/dist/layout-painter/renderPage.js +52 -20
- package/dist/layout-painter/renderParagraph.js +3 -2
- package/dist/layout-painter/renderTable.d.ts +5 -2
- package/dist/layout-painter/renderTable.js +39 -22
- 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/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
- package/dist/prosemirror/attrs/index.js +1 -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 +25 -0
- package/dist/prosemirror/commands/comments.js +122 -18
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
- package/dist/prosemirror/commands/pastePlainText.js +13 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
- 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/commentReferenceIntegrity.d.ts +8 -2
- package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +325 -55
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
- package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
- package/dist/prosemirror/index.d.ts +2 -2
- 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/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
- package/dist/prosemirror/plugins/suggestionMode.js +195 -30
- 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/rowGridOmissions.d.ts +11 -0
- package/dist/prosemirror/rowGridOmissions.js +21 -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/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 +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableGridMutation.d.ts +19 -2
- package/dist/prosemirror/tableGridMutation.js +118 -15
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
- package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
- package/dist/prosemirror/validation.js +2 -1
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- 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 -2
|
@@ -2,6 +2,7 @@ import { NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION } from "..
|
|
|
2
2
|
import { calculateFootnoteAreaRenderHeight } from "../../layout-painter/renderPage.js";
|
|
3
3
|
import { HIT_REGION_KINDS } from "../primitives.js";
|
|
4
4
|
import { DOC_CANVAS_TEXT } from "./colors.js";
|
|
5
|
+
import { createPageComposer } from "./regions.js";
|
|
5
6
|
import { paintFootnoteBlocks } from "./storyPrimitives.js";
|
|
6
7
|
import { UNSUPPORTED_CONSTRUCT } from "./unsupported.js";
|
|
7
8
|
// src/display-list/build/pageFurniture.ts
|
|
@@ -93,6 +94,7 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
93
94
|
}));
|
|
94
95
|
const missing = bodies.flatMap(({ noteId, content }) => content === void 0 ? [noteId] : []);
|
|
95
96
|
if (missing.length > 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.footnoteContent, context.pageIndex, `footnote bodies ${missing.join(", ")} were not supplied to the builder, so the band reserves their height and paints nothing`);
|
|
97
|
+
const noteWindowOf = (noteId) => page.footnoteWindows?.find((candidate) => candidate.noteId === noteId);
|
|
96
98
|
const items = bodies.map(({ noteId, content }) => ({
|
|
97
99
|
noteId,
|
|
98
100
|
displayNumber: String(content?.displayNumber ?? noteId),
|
|
@@ -104,7 +106,7 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
104
106
|
}));
|
|
105
107
|
const contentHeightPx = page.size.h - page.margins.top - page.margins.bottom;
|
|
106
108
|
const contentWidthPx = page.size.w - page.margins.left - page.margins.right;
|
|
107
|
-
const bandHeightPx = Math.max(reservedHeightPx, calculateFootnoteAreaRenderHeight(items));
|
|
109
|
+
const bandHeightPx = Math.max(reservedHeightPx, calculateFootnoteAreaRenderHeight(items, page.footnoteWindows));
|
|
108
110
|
const areaTopPx = page.margins.top + Math.max(-page.margins.top, contentHeightPx - bandHeightPx);
|
|
109
111
|
const primitives = [{
|
|
110
112
|
kind: "rect",
|
|
@@ -119,38 +121,58 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
119
121
|
composer.push(primitives);
|
|
120
122
|
for (const [index, { noteId, content }] of bodies.entries()) {
|
|
121
123
|
if (content === void 0) continue;
|
|
122
|
-
const offsetPx = calculateFootnoteAreaRenderHeight(items.slice(0, index));
|
|
124
|
+
const offsetPx = calculateFootnoteAreaRenderHeight(items.slice(0, index), page.footnoteWindows);
|
|
123
125
|
const story = {
|
|
124
126
|
kind: "footnote",
|
|
125
127
|
id: noteId
|
|
126
128
|
};
|
|
129
|
+
const noteWindow = noteWindowOf(noteId);
|
|
127
130
|
composer.region({
|
|
128
131
|
kind: HIT_REGION_KINDS.note,
|
|
129
132
|
rect: {
|
|
130
133
|
xPx: page.margins.left,
|
|
131
134
|
yPx: areaTopPx + offsetPx,
|
|
132
135
|
widthPx: contentWidthPx,
|
|
133
|
-
heightPx: content.height
|
|
136
|
+
heightPx: noteWindow ? noteWindow.to - noteWindow.from : content.height
|
|
134
137
|
},
|
|
135
138
|
model: { story }
|
|
136
139
|
}, () => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
const paintBlocks = (target) => {
|
|
141
|
+
paintFootnoteBlocks({
|
|
142
|
+
composer: target,
|
|
143
|
+
blocks: content.blocks,
|
|
144
|
+
measures: content.measures,
|
|
145
|
+
xPx: page.margins.left,
|
|
146
|
+
yPx: areaTopPx + offsetPx - (noteWindow?.from ?? 0),
|
|
147
|
+
widthPx: contentWidthPx,
|
|
148
|
+
context: {
|
|
149
|
+
...context,
|
|
150
|
+
story,
|
|
151
|
+
inlinePictureViewport: {
|
|
152
|
+
left: page.margins.left,
|
|
153
|
+
right: page.size.w - page.margins.right
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
label: `footnote ${content.displayNumber}`
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
if (!noteWindow) {
|
|
160
|
+
paintBlocks(composer);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const clipped = createPageComposer();
|
|
164
|
+
paintBlocks(clipped);
|
|
165
|
+
composer.push([{
|
|
166
|
+
kind: "clipGroup",
|
|
167
|
+
rect: {
|
|
168
|
+
xPx: page.margins.left,
|
|
169
|
+
yPx: areaTopPx + offsetPx,
|
|
170
|
+
widthPx: contentWidthPx,
|
|
171
|
+
heightPx: noteWindow.to - noteWindow.from
|
|
151
172
|
},
|
|
152
|
-
|
|
153
|
-
|
|
173
|
+
children: [...clipped.primitives()],
|
|
174
|
+
regions: [...clipped.regions()]
|
|
175
|
+
}]);
|
|
154
176
|
});
|
|
155
177
|
}
|
|
156
178
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TableBlock, TableFragment, TableMeasure, TextBoxBlock, TextBoxFragment, TextBoxMeasure } from "../../layout-engine/types.js";
|
|
2
|
+
import { VisibleBand } from "../../layout-engine/measure/tableVisibleBand.js";
|
|
2
3
|
import { BuildContext } from "./buildContext.js";
|
|
3
4
|
import { PageComposer } from "./regions.js";
|
|
4
5
|
type PaintTextBox = (options: {
|
|
@@ -16,9 +17,10 @@ export type TableBlockPaintOptions = {
|
|
|
16
17
|
readonly yPx: number;
|
|
17
18
|
readonly context: BuildContext;
|
|
18
19
|
readonly paintTextBox: PaintTextBox;
|
|
20
|
+
readonly visibleBand?: VisibleBand | undefined;
|
|
19
21
|
};
|
|
20
22
|
/** A whole, unpaginated table: what a nested table inside a cell or box is. */
|
|
21
|
-
export declare const paintTableBlock: ({ composer, block, measure, xPx, yPx, context, paintTextBox }: TableBlockPaintOptions) => void;
|
|
23
|
+
export declare const paintTableBlock: ({ composer, block, measure, xPx, yPx, context, paintTextBox, visibleBand }: TableBlockPaintOptions) => void;
|
|
22
24
|
export type TablePaintOptions = {
|
|
23
25
|
readonly composer: PageComposer;
|
|
24
26
|
readonly fragment: TableFragment;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createTableCellFlowState, placeTableCellBlock } from "../../layout-engine/measure/tableCellFlow.js";
|
|
2
2
|
import { buildTableCellGrid, buildTableCellPlacements, getSourceCellAt, getTableCellSpacingInsetsY } from "../../layout-engine/measure/tableCellGrid.js";
|
|
3
3
|
import { tableFragmentBottomBorders } from "../../layout-engine/measure/tableFragmentBorderGeometry.js";
|
|
4
|
+
import { isOutsideBand, tableHasFloatingCellContent, tableRowPaintBottom } from "../../layout-engine/measure/tableVisibleBand.js";
|
|
4
5
|
import { resolveTableCellPadding } from "../../layout-engine/types.js";
|
|
5
6
|
import { cellTextRotationDegrees } from "../../layout-painter/renderTable.js";
|
|
6
7
|
import { paintsCssBorder } from "../../utils/borderCss.js";
|
|
@@ -35,7 +36,7 @@ const strokeFor = (border, context, label) => {
|
|
|
35
36
|
if (unresolvedColor !== void 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `${label} colour ${unresolvedColor}`);
|
|
36
37
|
return stroke;
|
|
37
38
|
};
|
|
38
|
-
const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, sides }) => {
|
|
39
|
+
const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, visibleBand, contentBandPx, sides }) => {
|
|
39
40
|
const primitives = [];
|
|
40
41
|
if (cell.background) {
|
|
41
42
|
const fill = parseDisplayColor(cell.background);
|
|
@@ -110,8 +111,9 @@ const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, si
|
|
|
110
111
|
if (cellTextRotationDegrees(cell.textDirection) !== 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.verticalCellText, context.pageIndex, `w:textDirection ${cell.textDirection} paints horizontally`);
|
|
111
112
|
composer.push(primitives);
|
|
112
113
|
primitives.length = 0;
|
|
114
|
+
const contentComposer = contentBandPx ? createPageComposer() : composer;
|
|
113
115
|
paintCellBlocks({
|
|
114
|
-
composer,
|
|
116
|
+
composer: contentComposer,
|
|
115
117
|
blocks: cell.blocks,
|
|
116
118
|
measures: cellMeasure.blocks,
|
|
117
119
|
xPx: contentXPx,
|
|
@@ -119,8 +121,20 @@ const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, si
|
|
|
119
121
|
widthPx: contentWidthPx,
|
|
120
122
|
inlinePictureViewport: cellPictureViewport,
|
|
121
123
|
context,
|
|
122
|
-
paintTextBox
|
|
124
|
+
paintTextBox,
|
|
125
|
+
visibleBand
|
|
123
126
|
});
|
|
127
|
+
if (contentBandPx) composer.push([{
|
|
128
|
+
kind: "clipGroup",
|
|
129
|
+
rect: {
|
|
130
|
+
xPx: box.xPx,
|
|
131
|
+
yPx: contentBandPx.top,
|
|
132
|
+
widthPx: box.widthPx,
|
|
133
|
+
heightPx: Math.max(0, contentBandPx.bottom - contentBandPx.top)
|
|
134
|
+
},
|
|
135
|
+
children: [...contentComposer.primitives()],
|
|
136
|
+
regions: [...contentComposer.regions()]
|
|
137
|
+
}]);
|
|
124
138
|
const diagonals = [{
|
|
125
139
|
border: borders?.topLeftToBottomRight,
|
|
126
140
|
from: "topLeft"
|
|
@@ -146,7 +160,7 @@ const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, si
|
|
|
146
160
|
* A cell's inner blocks, stacked by the same flow state the measurer used, so
|
|
147
161
|
* paragraph spacing collapses in paint exactly where it collapsed in layout.
|
|
148
162
|
*/
|
|
149
|
-
const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inlinePictureViewport, context, paintTextBox }) => {
|
|
163
|
+
const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inlinePictureViewport, context, paintTextBox, visibleBand }) => {
|
|
150
164
|
const flowState = createTableCellFlowState();
|
|
151
165
|
for (let index = 0; index < blocks.length; index += 1) {
|
|
152
166
|
const block = blocks[index];
|
|
@@ -156,6 +170,7 @@ const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inline
|
|
|
156
170
|
continue;
|
|
157
171
|
}
|
|
158
172
|
const placement = placeTableCellBlock(flowState, block, measure);
|
|
173
|
+
if (block.kind === "table" && isOutsideBand(visibleBand, yPx + placement.top, yPx + placement.contentTop + placement.contentHeight)) continue;
|
|
159
174
|
if (block.kind === "paragraph" && measure.kind === "paragraph") {
|
|
160
175
|
const previous = blocks[index - 1];
|
|
161
176
|
const next = blocks[index + 1];
|
|
@@ -210,7 +225,8 @@ const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inline
|
|
|
210
225
|
...context,
|
|
211
226
|
inlinePictureViewport
|
|
212
227
|
},
|
|
213
|
-
paintTextBox
|
|
228
|
+
paintTextBox,
|
|
229
|
+
visibleBand
|
|
214
230
|
});
|
|
215
231
|
});
|
|
216
232
|
continue;
|
|
@@ -261,7 +277,7 @@ const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inline
|
|
|
261
277
|
}
|
|
262
278
|
};
|
|
263
279
|
const rowIsPainted = (row) => row !== void 0 && row.hidden !== true;
|
|
264
|
-
const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, headerRowCount, context, paintTextBox }) => {
|
|
280
|
+
const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, headerRowCount, context, paintTextBox, visibleBand, cellLineBand }) => {
|
|
265
281
|
const grid = buildTableCellGrid(block.rows, measure.columnWidths.length);
|
|
266
282
|
const placements = buildTableCellPlacements({
|
|
267
283
|
grid,
|
|
@@ -272,10 +288,14 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
272
288
|
const bordersSeparated = (block.cellSpacing ?? 0) > 0;
|
|
273
289
|
const rowTops = [0];
|
|
274
290
|
for (const rowMeasure of measure.rows) rowTops.push((rowTops.at(-1) ?? 0) + rowMeasure.height);
|
|
291
|
+
let firstShownRow;
|
|
275
292
|
const paintRow = (rowIndex, rowYPx) => {
|
|
276
293
|
const row = block.rows[rowIndex];
|
|
277
294
|
const rowMeasure = measure.rows[rowIndex];
|
|
278
295
|
if (!rowIsPainted(row) || !rowMeasure) return;
|
|
296
|
+
const rowTop = rowTops[rowIndex] ?? 0;
|
|
297
|
+
if (isOutsideBand(visibleBand, rowYPx, rowYPx + tableRowPaintBottom(row, rowIndex, rowTops) - rowTop)) return;
|
|
298
|
+
firstShownRow ??= rowIndex;
|
|
279
299
|
composer.region({
|
|
280
300
|
kind: HIT_REGION_KINDS.tableRow,
|
|
281
301
|
rect: {
|
|
@@ -290,10 +310,13 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
290
310
|
});
|
|
291
311
|
};
|
|
292
312
|
const paintRowCells = (row, rowMeasure, rowIndex, rowYPx) => {
|
|
313
|
+
const opensContinuation = visibleBand !== void 0 && rowIndex === firstShownRow && rowYPx >= visibleBand.top;
|
|
314
|
+
const cellBands = rowIndex === fromRow ? cellLineBand?.cells : void 0;
|
|
293
315
|
for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
|
|
294
316
|
const cell = row.cells[cellIndex];
|
|
295
317
|
const cellMeasure = rowMeasure.cells[cellIndex];
|
|
296
318
|
if (!cell || !cellMeasure) continue;
|
|
319
|
+
const cellBand = cellBands?.[cellIndex];
|
|
297
320
|
const placement = placements.get(cell);
|
|
298
321
|
if (!placement) continue;
|
|
299
322
|
const rowSpan = Math.max(1, Math.trunc(cell.rowSpan ?? 1));
|
|
@@ -328,8 +351,13 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
328
351
|
box,
|
|
329
352
|
context,
|
|
330
353
|
paintTextBox,
|
|
354
|
+
visibleBand,
|
|
355
|
+
...cellBand ? { contentBandPx: {
|
|
356
|
+
top: rowYPx + cellBand.top,
|
|
357
|
+
bottom: rowYPx + cellBand.bottom
|
|
358
|
+
} } : {},
|
|
331
359
|
sides: {
|
|
332
|
-
top: bordersSeparated || rowIndex === fromRow || !hasVisibleBorder(aboveCell?.borders?.bottom),
|
|
360
|
+
top: bordersSeparated || rowIndex === fromRow || opensContinuation || !hasVisibleBorder(aboveCell?.borders?.bottom),
|
|
333
361
|
bottom: true,
|
|
334
362
|
left: bordersSeparated || isFirstColumn || !hasVisibleBorder(leftCell?.borders?.right),
|
|
335
363
|
right: true
|
|
@@ -375,7 +403,7 @@ const paintFragmentBottomBorders = ({ composer, fragment, block, measure, contex
|
|
|
375
403
|
composer.push(primitives);
|
|
376
404
|
};
|
|
377
405
|
/** A whole, unpaginated table: what a nested table inside a cell or box is. */
|
|
378
|
-
const paintTableBlock = ({ composer, block, measure, xPx, yPx, context, paintTextBox }) => paintTableBody({
|
|
406
|
+
const paintTableBlock = ({ composer, block, measure, xPx, yPx, context, paintTextBox, visibleBand }) => paintTableBody({
|
|
379
407
|
composer,
|
|
380
408
|
block,
|
|
381
409
|
measure,
|
|
@@ -385,7 +413,8 @@ const paintTableBlock = ({ composer, block, measure, xPx, yPx, context, paintTex
|
|
|
385
413
|
toRow: block.rows.length,
|
|
386
414
|
headerRowCount: 0,
|
|
387
415
|
context,
|
|
388
|
-
paintTextBox
|
|
416
|
+
paintTextBox,
|
|
417
|
+
visibleBand
|
|
389
418
|
});
|
|
390
419
|
/**
|
|
391
420
|
* A table fragment's primitives. A fragment that cuts a row mid-content wraps
|
|
@@ -408,11 +437,12 @@ const paintTableFragment = ({ composer, fragment, block, measure, context, paint
|
|
|
408
437
|
toRow: 0,
|
|
409
438
|
headerRowCount,
|
|
410
439
|
context,
|
|
411
|
-
paintTextBox
|
|
440
|
+
paintTextBox,
|
|
441
|
+
visibleBand: void 0
|
|
412
442
|
});
|
|
413
443
|
};
|
|
414
444
|
const topClipPx = fragment.topClip ?? 0;
|
|
415
|
-
const paintBody = (into) => {
|
|
445
|
+
const paintBody = (into, visibleBand) => {
|
|
416
446
|
paintTableBody({
|
|
417
447
|
composer: into,
|
|
418
448
|
block,
|
|
@@ -423,7 +453,9 @@ const paintTableFragment = ({ composer, fragment, block, measure, context, paint
|
|
|
423
453
|
toRow: fragment.toRow,
|
|
424
454
|
headerRowCount: 0,
|
|
425
455
|
context,
|
|
426
|
-
paintTextBox
|
|
456
|
+
paintTextBox,
|
|
457
|
+
visibleBand,
|
|
458
|
+
...fragment.cellLineBand ? { cellLineBand: fragment.cellLineBand } : {}
|
|
427
459
|
});
|
|
428
460
|
};
|
|
429
461
|
if (fragment.topClip === void 0 && fragment.bottomClip === void 0) {
|
|
@@ -432,14 +464,17 @@ const paintTableFragment = ({ composer, fragment, block, measure, context, paint
|
|
|
432
464
|
return;
|
|
433
465
|
}
|
|
434
466
|
paintHeaders(composer);
|
|
435
|
-
const clipped = createPageComposer();
|
|
436
|
-
paintBody(clipped);
|
|
437
467
|
const clip = {
|
|
438
468
|
xPx: fragment.x,
|
|
439
469
|
yPx: fragment.y + headerHeightPx,
|
|
440
470
|
widthPx: fragment.width,
|
|
441
471
|
heightPx: Math.max(0, fragment.height - headerHeightPx)
|
|
442
472
|
};
|
|
473
|
+
const clipped = createPageComposer();
|
|
474
|
+
paintBody(clipped, tableHasFloatingCellContent(block) ? void 0 : {
|
|
475
|
+
top: clip.yPx,
|
|
476
|
+
bottom: clip.yPx + clip.heightPx
|
|
477
|
+
});
|
|
443
478
|
composer.push([{
|
|
444
479
|
kind: "clipGroup",
|
|
445
480
|
rect: clip,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { writeCommentAnchorIds } from "../../render-dom/commentAnchorAttributes.js";
|
|
2
2
|
import { bytesToDataUrl } from "../../utils/base64.js";
|
|
3
|
+
import { cssString } from "../../utils/cssString.js";
|
|
3
4
|
import { imageLuminanceFilter } from "../../utils/imageLuminance.js";
|
|
4
5
|
import { applyTextAdvanceGaps } from "../../utils/textAdvanceGapsDom.js";
|
|
5
6
|
import { anchorTargetAttrs } from "../../utils/urlSecurity.js";
|
|
@@ -78,7 +79,6 @@ const px = (value) => `${value}px`;
|
|
|
78
79
|
* the PDF backend's colour dump.
|
|
79
80
|
*/
|
|
80
81
|
const cssColor = ({ r, g, b, a }) => a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
81
|
-
const quoteFontFamily = (family) => `"${family.replaceAll("\"", "\\\"")}"`;
|
|
82
82
|
/**
|
|
83
83
|
* An embedded face wins over any installed face of the same name by being
|
|
84
84
|
* named first, under the id its `@font-face` rule was registered with.
|
|
@@ -91,8 +91,8 @@ const quoteFontFamily = (family) => `"${family.replaceAll("\"", "\\\"")}"`;
|
|
|
91
91
|
* any host missing the first one.
|
|
92
92
|
*/
|
|
93
93
|
const fontFamilyStack = ({ family, fallbacks, generic, embedded }) => {
|
|
94
|
-
const resolved = `${[family, ...fallbacks].map(
|
|
95
|
-
return embedded === void 0 ? resolved : `${
|
|
94
|
+
const resolved = `${[family, ...fallbacks].map(cssString).join(", ")}, ${generic}`;
|
|
95
|
+
return embedded === void 0 ? resolved : `${cssString(embedded.id)}, ${resolved}`;
|
|
96
96
|
};
|
|
97
97
|
const resolveFont = (ref, fonts) => {
|
|
98
98
|
const face = ref < 0 ? void 0 : fonts.at(ref);
|
|
@@ -110,7 +110,7 @@ const binarySrc = (bytes, mimeType, urls) => {
|
|
|
110
110
|
if (urls === "objectUrl" && isBlobPart(bytes) && typeof Blob === "function" && typeof URL !== "undefined" && typeof URL.createObjectURL === "function") return URL.createObjectURL(new Blob([bytes], { type: mimeType }));
|
|
111
111
|
return bytesToDataUrl(bytes, mimeType);
|
|
112
112
|
};
|
|
113
|
-
const fontFaceRule = (face, embedded, src) => `@font-face { font-family: ${
|
|
113
|
+
const fontFaceRule = (face, embedded, src) => `@font-face { font-family: ${cssString(embedded.id)}; src: url("${src}"); font-weight: ${face.weight}; font-style: ${face.italic ? "italic" : "normal"}; }`;
|
|
114
114
|
/**
|
|
115
115
|
* `@font-face` rules for the faces whose bytes travel with the list. Resolved
|
|
116
116
|
* once per render and shared by every page: an id maps to one blob, so the
|
|
@@ -314,6 +314,14 @@ export type ApplyFolioDocumentOperationsOptions = {
|
|
|
314
314
|
*/
|
|
315
315
|
restagesSuggestions?: boolean;
|
|
316
316
|
};
|
|
317
|
+
/**
|
|
318
|
+
* A suggested operation without a `suggestionId` is its own suggestion, named
|
|
319
|
+
* by its id. An id a still pending suggestion already carries would fold the
|
|
320
|
+
* two into one (accepted, rejected and exported together), so such an
|
|
321
|
+
* operation gets a distinct id, and an operation of the batch grouping with it
|
|
322
|
+
* by that id follows it.
|
|
323
|
+
*/
|
|
324
|
+
export declare const withDistinctSuggestionIds: (batch: FolioDocumentOperationBatch, pending: ReadonlySet<string>) => FolioDocumentOperationBatch;
|
|
317
325
|
export declare const applyFolioDocumentOperations: (input: ApplyFolioDocumentOperationsOptions) => FolioDocumentOperationResult;
|
|
318
326
|
/**
|
|
319
327
|
* Options of a caller that holds every story of the package: the numbering
|
|
@@ -1081,7 +1081,8 @@ const recoveryByReason = {
|
|
|
1081
1081
|
missingNumbering: "refreshDocument",
|
|
1082
1082
|
invalidResult: "refreshDocument",
|
|
1083
1083
|
pendingDeletion: "resolveTrackedChange",
|
|
1084
|
-
pendingParagraphMarkDeletion: "resolveTrackedChange"
|
|
1084
|
+
pendingParagraphMarkDeletion: "resolveTrackedChange",
|
|
1085
|
+
contentControlLock: "changeTarget"
|
|
1085
1086
|
};
|
|
1086
1087
|
const getFolioDocumentOperationIssues = (operations, skipped) => {
|
|
1087
1088
|
const indexById = /* @__PURE__ */ new Map();
|
|
@@ -1095,7 +1096,7 @@ const getFolioDocumentOperationIssues = (operations, skipped) => {
|
|
|
1095
1096
|
operationIndex,
|
|
1096
1097
|
path: `$.operations[${operationIndex}]`,
|
|
1097
1098
|
code: reason,
|
|
1098
|
-
retryable: reason !== "emptyOperation" && reason !== "noopOperation" && reason !== "pendingParagraphPropertyChange" && reason !== "pendingRunPropertyChange" && reason !== "pendingDeletion" && reason !== "pendingParagraphMarkDeletion" && reason !== "payloadDoesNotFit" && reason !== "protectedReference" && reason !== "invalidResult",
|
|
1099
|
+
retryable: reason !== "emptyOperation" && reason !== "noopOperation" && reason !== "pendingParagraphPropertyChange" && reason !== "pendingRunPropertyChange" && reason !== "pendingDeletion" && reason !== "pendingParagraphMarkDeletion" && reason !== "contentControlLock" && reason !== "payloadDoesNotFit" && reason !== "protectedReference" && reason !== "invalidResult",
|
|
1099
1100
|
recovery: recoveryByReason[reason],
|
|
1100
1101
|
...canonicalRefusal === void 0 ? {} : { canonicalRefusal },
|
|
1101
1102
|
...message !== void 0 && { message }
|
|
@@ -1517,4 +1518,4 @@ const applyFolioDocumentOperationsInPackage = ({ view, snapshot, batch, story =
|
|
|
1517
1518
|
undoHandle: result.applied.length > 0 && createUndoHandle !== void 0 ? createUndoHandle() : null
|
|
1518
1519
|
};
|
|
1519
1520
|
};
|
|
1520
|
-
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, applyFolioDocumentOperationsInPackage, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch };
|
|
1521
|
+
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, applyFolioDocumentOperationsInPackage, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, withDistinctSuggestionIds };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
+
import { PreviousListState } from "./listMarkerComputation.js";
|
|
3
4
|
import { ParseContext } from "./parseContext.js";
|
|
4
5
|
import { XmlElement } from "./xmlParser.js";
|
|
5
6
|
import { OwnedElsewhere } from "./containerChildren.js";
|
|
6
|
-
import { PreviousListState } from "./listMarkerComputation.js";
|
|
7
7
|
import { PreviewLedger } from "./previewBudget.js";
|
|
8
8
|
import { StyleMap } from "./styleParser.js";
|
|
9
9
|
type ParseBlockContentOptions = {
|
|
@@ -40,8 +40,12 @@ type BlockContentWalk = {
|
|
|
40
40
|
};
|
|
41
41
|
export declare const BLOCK_CONTENT_HANDLERS: {
|
|
42
42
|
readonly altChunk: "capture";
|
|
43
|
-
readonly commentRangeEnd:
|
|
44
|
-
|
|
43
|
+
readonly commentRangeEnd: (child: XmlElement, walk: {
|
|
44
|
+
modelled: document_d_exports.BlockContent[];
|
|
45
|
+
}) => void;
|
|
46
|
+
readonly commentRangeStart: (child: XmlElement, walk: {
|
|
47
|
+
modelled: document_d_exports.BlockContent[];
|
|
48
|
+
}) => void;
|
|
45
49
|
readonly customXmlDelRangeEnd: "capture";
|
|
46
50
|
readonly customXmlDelRangeStart: "capture";
|
|
47
51
|
readonly customXmlInsRangeEnd: "capture";
|
|
@@ -2,7 +2,7 @@ import { blockCustomXmlShell } from "./blockCustomXmlShell.js";
|
|
|
2
2
|
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
3
3
|
import { CAPTURE, dispatchChildrenWithContext, ownedElsewhere, withPreservedChildren } from "./containerChildren.js";
|
|
4
4
|
import { computeListMarker } from "./listMarkerComputation.js";
|
|
5
|
-
import { BLOCK_MOVE_RANGE_MARKER_HANDLERS } from "./markupRangeMarker.js";
|
|
5
|
+
import { BLOCK_COMMENT_RANGE_MARKER_HANDLERS, BLOCK_MOVE_RANGE_MARKER_HANDLERS } from "./markupRangeMarker.js";
|
|
6
6
|
import { parseParagraph } from "./paragraphParser.js";
|
|
7
7
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
8
8
|
import { standalonePreviewLedger } from "./previewBudget.js";
|
|
@@ -104,10 +104,9 @@ const BLOCK_CONTENT_HANDLERS = {
|
|
|
104
104
|
modelled.push(parseBookmarkEnd(child));
|
|
105
105
|
},
|
|
106
106
|
...BLOCK_MOVE_RANGE_MARKER_HANDLERS,
|
|
107
|
+
...BLOCK_COMMENT_RANGE_MARKER_HANDLERS,
|
|
107
108
|
...BLOCK_CHILD_OWNERS,
|
|
108
109
|
altChunk: CAPTURE,
|
|
109
|
-
commentRangeEnd: CAPTURE,
|
|
110
|
-
commentRangeStart: CAPTURE,
|
|
111
110
|
customXmlDelRangeEnd: CAPTURE,
|
|
112
111
|
customXmlDelRangeStart: CAPTURE,
|
|
113
112
|
customXmlInsRangeEnd: CAPTURE,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
/**
|
|
3
|
+
* Collapse each bookmark's markers in paragraphs to its first start and its
|
|
4
|
+
* last end. Answers how many markers were dropped.
|
|
5
|
+
*/
|
|
6
|
+
export declare const joinBookmarkRangesAcrossParagraphs: (blocks: readonly document_d_exports.BlockContent[]) => number;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { InlineContentRemovals } from "./inlineContentRemovals.js";
|
|
2
|
+
import { visitInlineContentSlots } from "./paragraphTraversal.js";
|
|
3
|
+
// src/docx/bookmarkRangeJoin.ts
|
|
4
|
+
const visitBookmarkMarkers = (blocks, visit) => {
|
|
5
|
+
for (const block of blocks) switch (block.type) {
|
|
6
|
+
case "paragraph":
|
|
7
|
+
visitInlineContentSlots(block, ({ content, index, item }) => {
|
|
8
|
+
if (item.type === "bookmarkStart") visit({
|
|
9
|
+
content,
|
|
10
|
+
index
|
|
11
|
+
}, "start", item.id);
|
|
12
|
+
else if (item.type === "bookmarkEnd") visit({
|
|
13
|
+
content,
|
|
14
|
+
index
|
|
15
|
+
}, "end", item.id);
|
|
16
|
+
});
|
|
17
|
+
break;
|
|
18
|
+
case "table":
|
|
19
|
+
for (const row of block.rows) for (const cell of row.cells) visitBookmarkMarkers(cell.content, visit);
|
|
20
|
+
break;
|
|
21
|
+
case "blockSdt":
|
|
22
|
+
case "blockCustomXml": visitBookmarkMarkers(block.content, visit);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Collapse each bookmark's markers in paragraphs to its first start and its
|
|
27
|
+
* last end. Answers how many markers were dropped.
|
|
28
|
+
*/
|
|
29
|
+
const joinBookmarkRangesAcrossParagraphs = (blocks) => {
|
|
30
|
+
const starts = /* @__PURE__ */ new Map();
|
|
31
|
+
const ends = /* @__PURE__ */ new Map();
|
|
32
|
+
visitBookmarkMarkers(blocks, (slot, type, id) => {
|
|
33
|
+
const byId = type === "start" ? starts : ends;
|
|
34
|
+
const slots = byId.get(id);
|
|
35
|
+
if (slots) slots.push(slot);
|
|
36
|
+
else byId.set(id, [slot]);
|
|
37
|
+
});
|
|
38
|
+
const removals = new InlineContentRemovals();
|
|
39
|
+
for (const slots of starts.values()) for (const slot of slots.slice(1)) removals.mark(slot);
|
|
40
|
+
for (const slots of ends.values()) for (const slot of slots.slice(0, -1)) removals.mark(slot);
|
|
41
|
+
return removals.apply();
|
|
42
|
+
};
|
|
43
|
+
export { joinBookmarkRangesAcrossParagraphs };
|
|
@@ -5,14 +5,18 @@ import { CanonicalResourceSaveRefusalError, canonicalResourceReplacementOf } fro
|
|
|
5
5
|
import { repackWithCanonicalStoryRemovals } from "./canonicalStoryRepack.js";
|
|
6
6
|
import { getDocumentSourceBaseline } from "./headerFooterVerbatim.js";
|
|
7
7
|
import { resolveSelectiveSaveFlags } from "./selectiveSaveFlags.js";
|
|
8
|
+
import { withoutUnusedSessionLists } from "./sessionListPruning.js";
|
|
8
9
|
import { Result, TaggedError } from "better-result";
|
|
10
|
+
import { withoutPendingSuggestions } from "@stll/docx-core/ops";
|
|
9
11
|
// src/docx/canonicalSave.ts
|
|
10
12
|
const CanonicalSaveDiagnosticErrorBase = TaggedError("CanonicalSaveDiagnosticError");
|
|
11
13
|
/** Forward a fidelity fallback through the adapters' existing error channel. */
|
|
12
14
|
var CanonicalSaveDiagnosticError = class extends CanonicalSaveDiagnosticErrorBase {};
|
|
13
15
|
/** Model and change signals come from one committed snapshot, never from PM. */
|
|
14
16
|
const serializeCanonicalSave = async ({ snapshot, options, featureFlags }) => {
|
|
15
|
-
const
|
|
17
|
+
const withoutSuggestions = withoutPendingSuggestions(snapshot.document);
|
|
18
|
+
if (withoutSuggestions.isErr()) throw withoutSuggestions.error;
|
|
19
|
+
const document = withoutUnusedSessionLists(withoutUnreferencedNotes(withoutSuggestions.value));
|
|
16
20
|
const replacementPart = snapshot.structure === "changed" ? canonicalResourceReplacementOf(document) : void 0;
|
|
17
21
|
if (replacementPart) {
|
|
18
22
|
const diagnostic = {
|
|
@@ -5,6 +5,10 @@ export declare class CanonicalDocxInputError extends CanonicalDocxInputErrorBase
|
|
|
5
5
|
message: string;
|
|
6
6
|
cause?: unknown;
|
|
7
7
|
}> {}
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Canonical seeding supports plaintext packages; refuse encryption before ZIP
|
|
10
|
+
* normalization. A package that repeats a paragraph or content control id is
|
|
11
|
+
* given unique ones, every paragraph and control kept.
|
|
12
|
+
*/
|
|
9
13
|
export declare const prepareCanonicalDocxInput: (input: DocxInput) => Promise<Err<ArrayBuffer, CanonicalDocxInputError> | Ok<Uint8Array<ArrayBufferLike>, CanonicalDocxInputError>>;
|
|
10
14
|
export {};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { toArrayBuffer } from "../utils/docxInput.js";
|
|
2
2
|
import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "./encryption/containerFormat.js";
|
|
3
3
|
import { ensureParaIds } from "./ensureParaIds.js";
|
|
4
|
+
import { ensureUniqueControlIds } from "./ensureUniqueControlIds.js";
|
|
4
5
|
import { Result, TaggedError } from "better-result";
|
|
5
6
|
// src/docx/canonicalSessionInput.ts
|
|
6
7
|
const CanonicalDocxInputErrorBase = TaggedError("CanonicalDocxInputError");
|
|
7
8
|
var CanonicalDocxInputError = class extends CanonicalDocxInputErrorBase {};
|
|
8
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Canonical seeding supports plaintext packages; refuse encryption before ZIP
|
|
11
|
+
* normalization. A package that repeats a paragraph or content control id is
|
|
12
|
+
* given unique ones, every paragraph and control kept.
|
|
13
|
+
*/
|
|
9
14
|
const prepareCanonicalDocxInput = async (input) => {
|
|
10
15
|
const bytes = await Result.tryPromise({
|
|
11
16
|
try: () => toArrayBuffer(input),
|
|
@@ -17,7 +22,7 @@ const prepareCanonicalDocxInput = async (input) => {
|
|
|
17
22
|
if (bytes.isErr()) return bytes;
|
|
18
23
|
if (detectDocxContainerType(bytes.value) === DOCX_CONTAINER_TYPES.CFB) return Result.err(new CanonicalDocxInputError({ message: "Password-protected documents are unavailable in the experimental canonical session." }));
|
|
19
24
|
return Result.tryPromise({
|
|
20
|
-
try: async () => (await ensureParaIds(bytes.value)).docx,
|
|
25
|
+
try: async () => (await ensureUniqueControlIds((await ensureParaIds(bytes.value)).docx)).docx,
|
|
21
26
|
catch: (cause) => new CanonicalDocxInputError({
|
|
22
27
|
message: cause instanceof Error ? cause.message : "Canonical document normalization failed.",
|
|
23
28
|
cause
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { XmlElement } from "./xmlParser.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Describe a chart: the marks of a supported cached chart, or an empty frame of
|
|
5
|
+
* the same size. AlternateContent fallbacks are resolved by the run parser.
|
|
6
|
+
*/
|
|
4
7
|
export declare const parseChartPreview: (drawing: XmlElement, rels?: document_d_exports.RelationshipMap, media?: Map<string, document_d_exports.MediaFile>) => document_d_exports.Image | null;
|
|
@@ -257,12 +257,33 @@ const chartPart = (drawing, rels, media) => {
|
|
|
257
257
|
path
|
|
258
258
|
} : null;
|
|
259
259
|
};
|
|
260
|
-
/**
|
|
260
|
+
/**
|
|
261
|
+
* Describe a chart: the marks of a supported cached chart, or an empty frame of
|
|
262
|
+
* the same size. AlternateContent fallbacks are resolved by the run parser.
|
|
263
|
+
*/
|
|
261
264
|
const parseChartPreview = (drawing, rels, media) => {
|
|
265
|
+
const size = extentOf(drawing);
|
|
266
|
+
if (!isChartDrawing(drawing) || size.width <= 0 || size.height <= 0) return null;
|
|
267
|
+
return {
|
|
268
|
+
type: "image",
|
|
269
|
+
preview: {
|
|
270
|
+
kind: "chart",
|
|
271
|
+
extent: size,
|
|
272
|
+
shapes: chartMarks(drawing, size, rels, media) ?? []
|
|
273
|
+
},
|
|
274
|
+
size,
|
|
275
|
+
wrap: { type: "inline" }
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
const isChartDrawing = (drawing) => {
|
|
279
|
+
const graphicData = firstDescendant(drawing, DRAWINGML, "graphicData");
|
|
280
|
+
return graphicData !== null && CHART.has(getAttribute(graphicData, null, "uri") ?? "") && firstDescendant(graphicData, CHART, "chart") !== null;
|
|
281
|
+
};
|
|
282
|
+
/** The marks a chart's cached data draws, or null when it cannot draw them. */
|
|
283
|
+
const chartMarks = (drawing, size, rels, media) => {
|
|
262
284
|
if (!rels || !media) return null;
|
|
263
285
|
const part = chartPart(drawing, rels, media);
|
|
264
|
-
|
|
265
|
-
if (!part || size.width <= 0 || size.height <= 0) return null;
|
|
286
|
+
if (!part) return null;
|
|
266
287
|
const plotArea = firstDescendant(part.root, CHART, "plotArea");
|
|
267
288
|
if (!plotArea) return null;
|
|
268
289
|
const supported = getChildElements(plotArea).find((item) => [
|
|
@@ -281,21 +302,11 @@ const parseChartPreview = (drawing, rels, media) => {
|
|
|
281
302
|
else shapes = pieShapes(supported, series, size.width, size.height, kind === "doughnutChart");
|
|
282
303
|
if (shapes.length === 0) return null;
|
|
283
304
|
if (shapes.reduce((total, shape) => total + (shape.type === "polygon" || shape.type === "polyline" ? shape.points.length : 0), 0) > 512) return null;
|
|
284
|
-
|
|
305
|
+
return shapes.every((shape) => shape.type === "polygon" || shape.type === "polyline" ? shape.points.every(({ x, y }) => Number.isFinite(x) && Number.isFinite(y)) : [
|
|
285
306
|
shape.x,
|
|
286
307
|
shape.y,
|
|
287
308
|
shape.width,
|
|
288
309
|
shape.height
|
|
289
|
-
].every(Number.isFinite))
|
|
290
|
-
return {
|
|
291
|
-
type: "image",
|
|
292
|
-
preview: {
|
|
293
|
-
kind: "chart",
|
|
294
|
-
extent: size,
|
|
295
|
-
shapes
|
|
296
|
-
},
|
|
297
|
-
size,
|
|
298
|
-
wrap: { type: "inline" }
|
|
299
|
-
};
|
|
310
|
+
].every(Number.isFinite)) ? shapes : null;
|
|
300
311
|
};
|
|
301
312
|
export { parseChartPreview };
|