@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isQuoteStyle, resolveHeadingLevel } from "../docx/builtInStyles.js";
|
|
2
2
|
import { countParagraphList } from "./countParagraphList.js";
|
|
3
|
-
import { inlineBreaksToHtml } from "./escape.js";
|
|
3
|
+
import { escapeLeadingBlockMarker, inlineBreaksToHtml, protectBreakBlanks } from "./escape.js";
|
|
4
4
|
import { renderParagraphInline } from "./renderRuns.js";
|
|
5
5
|
// src/markdown/renderParagraph.ts
|
|
6
6
|
/**
|
|
@@ -33,12 +33,14 @@ function renderParagraph(ctx, pkg, para) {
|
|
|
33
33
|
*/
|
|
34
34
|
function renderParagraphBlock(ctx, pkg, para) {
|
|
35
35
|
const { visibleList, label } = countParagraphList(ctx, pkg, para);
|
|
36
|
-
const
|
|
36
|
+
const written = renderParagraphInline(ctx, pkg, para.content, para.paraId);
|
|
37
|
+
const blank = written.trim().length === 0;
|
|
38
|
+
const inline = protectBreakBlanks(written);
|
|
37
39
|
const styleId = para.formatting?.styleId;
|
|
38
40
|
const headingLevel = markdownHeadingLevel(ctx, para);
|
|
39
41
|
if (headingLevel !== void 0) {
|
|
40
42
|
ctx.listIndentWidths = [];
|
|
41
|
-
if (!inline ||
|
|
43
|
+
if (!inline || blank && label === void 0) return {
|
|
42
44
|
type: "paragraph",
|
|
43
45
|
markdown: ""
|
|
44
46
|
};
|
|
@@ -49,7 +51,12 @@ function renderParagraphBlock(ctx, pkg, para) {
|
|
|
49
51
|
type: "paragraph"
|
|
50
52
|
};
|
|
51
53
|
}
|
|
52
|
-
if (visibleList && label !== void 0) return renderListItem(ctx,
|
|
54
|
+
if (visibleList && label !== void 0) return renderListItem(ctx, {
|
|
55
|
+
list: visibleList,
|
|
56
|
+
label,
|
|
57
|
+
inline,
|
|
58
|
+
blank
|
|
59
|
+
});
|
|
53
60
|
ctx.listIndentWidths = [];
|
|
54
61
|
if (isQuoteStyle(styleId, ctx.builtInStyles)) return {
|
|
55
62
|
markdown: inline.split("\n").map((line) => `> ${line}`).join("\n"),
|
|
@@ -68,15 +75,6 @@ function markdownHeadingLevel(ctx, para) {
|
|
|
68
75
|
}, ctx.builtInStyles);
|
|
69
76
|
}
|
|
70
77
|
/**
|
|
71
|
-
* A plain paragraph whose visible text begins with markdown block syntax (e.g.
|
|
72
|
-
* `# Not a heading`, `- value`, `1. value`, `> quote`) would be reclassified as
|
|
73
|
-
* a heading/list/blockquote on re-parse, even though Word carries no matching
|
|
74
|
-
* style/list metadata. Escape the leading marker so literal text round-trips.
|
|
75
|
-
*/
|
|
76
|
-
function escapeLeadingBlockMarker(text) {
|
|
77
|
-
return text.replace(/^(?<ws>[ \t]*)(?<marker>[#>=])/gmu, "$<ws>\\$<marker>").replace(/^(?<ws>[ \t]*)(?<marker>[-+*])(?=[ \t]|$)/gmu, "$<ws>\\$<marker>").replace(/^(?<ws>[ \t]*)-(?=[- \t]*$)/gmu, "$<ws>\\-").replace(/^(?<ws>[ \t]*)(?<num>\d{1,9})(?<marker>[.)])(?<after>[ \t])/gmu, "$<ws>$<num>\\$<marker>$<after>");
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
78
|
* Only emitted Markdown ancestors contribute columns. OOXML levels may skip
|
|
81
79
|
* ancestors or resume after prose; inventing those columns creates code blocks.
|
|
82
80
|
*/
|
|
@@ -85,19 +83,7 @@ function listIndentWidth(ctx, level) {
|
|
|
85
83
|
for (let ancestor = 0; ancestor < level; ancestor++) width += ctx.listIndentWidths[ancestor] ?? 0;
|
|
86
84
|
return width;
|
|
87
85
|
}
|
|
88
|
-
|
|
89
|
-
* A list item line with the label the page shows (`1.`, `a)`, `i.`), counted
|
|
90
|
-
* in document order across the whole render, list items inside tables and
|
|
91
|
-
* block SDTs included. A bullet is Markdown's `-`.
|
|
92
|
-
*
|
|
93
|
-
* The indent before the marker is not a fixed two spaces: CommonMark keeps a
|
|
94
|
-
* child nested under its parent only when it starts at or past the column
|
|
95
|
-
* where the parent item's content begins, which is the width of the parent's
|
|
96
|
-
* marker plus its one trailing space (`1. ` is 3 columns, `10. ` is 4, `- ` is
|
|
97
|
-
* 2). `ctx.listIndentWidths` is updated with this item's own marker width so
|
|
98
|
-
* a following, deeper item can indent correctly under it.
|
|
99
|
-
*/
|
|
100
|
-
function renderListItem(ctx, list, label, inline) {
|
|
86
|
+
function renderListItem(ctx, { list, label, inline, blank }) {
|
|
101
87
|
if (!(list.isBullet || /^\d{1,9}[.)]$/u.test(label))) {
|
|
102
88
|
ctx.listIndentWidths = [];
|
|
103
89
|
return {
|
|
@@ -112,7 +98,7 @@ function renderListItem(ctx, list, label, inline) {
|
|
|
112
98
|
return {
|
|
113
99
|
type: "listItem",
|
|
114
100
|
markdown: `${indent}${marker}${escapeLeadingBlockMarker(inline)}`.trimEnd(),
|
|
115
|
-
separation:
|
|
101
|
+
separation: blank ? "loose" : "tight"
|
|
116
102
|
};
|
|
117
103
|
}
|
|
118
104
|
export { renderParagraph, renderParagraphBlock };
|
|
@@ -3,7 +3,7 @@ import { getHyperlinkRuns } from "../docx/hyperlinkParser.js";
|
|
|
3
3
|
import { OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC, isOpaqueNestedRowMarkup, opaqueRevisionCarrierName } from "../docx/opaqueCarrier.js";
|
|
4
4
|
import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "../docx/relsParser.js";
|
|
5
5
|
import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
|
|
6
|
-
import { escapeTableCell } from "./escape.js";
|
|
6
|
+
import { escapeTableCell, inlineBreaksToHtml } from "./escape.js";
|
|
7
7
|
import { registerImage } from "./images.js";
|
|
8
8
|
import { numberNoteReference, pushWarning } from "./internals.js";
|
|
9
9
|
import { renderParagraph } from "./renderParagraph.js";
|
|
@@ -90,6 +90,8 @@ function renderGfmCell(ctx, pkg, cell) {
|
|
|
90
90
|
break;
|
|
91
91
|
case "bookmarkStart":
|
|
92
92
|
case "bookmarkEnd":
|
|
93
|
+
case "commentRangeStart":
|
|
94
|
+
case "commentRangeEnd":
|
|
93
95
|
case "moveFromRangeStart":
|
|
94
96
|
case "moveFromRangeEnd":
|
|
95
97
|
case "moveToRangeStart":
|
|
@@ -167,12 +169,14 @@ function renderHtmlCell(ctx, pkg, cell) {
|
|
|
167
169
|
renderBlocks(item.content);
|
|
168
170
|
break;
|
|
169
171
|
case "preservedBlock":
|
|
170
|
-
if (isAltChunkMarkup(item.xml)) parts.push(item.readerText === void 0 ? ALT_CHUNK_READER_DIAGNOSTIC : `${ALT_CHUNK_READER_DIAGNOSTIC} ${item.readerText}`);
|
|
172
|
+
if (isAltChunkMarkup(item.xml)) parts.push(item.readerText === void 0 ? ALT_CHUNK_READER_DIAGNOSTIC : `${ALT_CHUNK_READER_DIAGNOSTIC} ${inlineBreaksToHtml(escapeHtml(item.readerText))}`);
|
|
171
173
|
else if (opaqueRevisionCarrierName(item.xml) !== void 0) parts.push(OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC);
|
|
172
174
|
else if (isOpaqueNestedRowMarkup(item.xml)) parts.push("[Unsupported nested w:tr content]");
|
|
173
175
|
break;
|
|
174
176
|
case "bookmarkStart":
|
|
175
177
|
case "bookmarkEnd":
|
|
178
|
+
case "commentRangeStart":
|
|
179
|
+
case "commentRangeEnd":
|
|
176
180
|
case "moveFromRangeStart":
|
|
177
181
|
case "moveFromRangeEnd":
|
|
178
182
|
case "moveToRangeStart":
|
|
@@ -55,6 +55,7 @@ function inlineText(content) {
|
|
|
55
55
|
break;
|
|
56
56
|
case "hyperlink":
|
|
57
57
|
for (const child of item.children) if (child.type === "run") out += runText(child);
|
|
58
|
+
else if (child.type === "complexField") out += inlineText(child.fieldResult);
|
|
58
59
|
break;
|
|
59
60
|
case "complexField":
|
|
60
61
|
out += inlineText(item.fieldResult);
|
package/dist/pdf/images.d.ts
CHANGED
|
@@ -22,5 +22,21 @@ export type PdfImageSamples = {
|
|
|
22
22
|
readonly decode?: readonly number[];
|
|
23
23
|
readonly alpha?: PdfImageAlpha;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Largest PNG raster decoded for one image. A PNG's IDAT can compress an
|
|
27
|
+
* empty raster about a thousandfold, so the encoded size says little about
|
|
28
|
+
* the decode: 64 MP of RGBA is 256 MB per raster copy before the alpha split
|
|
29
|
+
* and the re-deflate. Matches the per-image TIFF ceiling at import.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MAX_PDF_PNG_PIXELS = 64000000;
|
|
32
|
+
/**
|
|
33
|
+
* Pixels decoded across every PNG in one PDF. The per-image ceiling bounds a
|
|
34
|
+
* single decode; without a running total many large images still add up.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MAX_PDF_DOCUMENT_PNG_PIXELS = 256000000;
|
|
37
|
+
/**
|
|
38
|
+
* Decode one image for painting. `maxPngPixels` is what remains of the
|
|
39
|
+
* document's PNG pixel budget; JPEG passes through undecoded and spends none.
|
|
40
|
+
*/
|
|
41
|
+
export declare const decodeImage: (source: DisplayImageSource, maxPngPixels?: number) => Result<PdfImageSamples, PdfImageError>;
|
|
26
42
|
export {};
|
package/dist/pdf/images.js
CHANGED
|
@@ -48,6 +48,18 @@ const FULLY_OPAQUE = 255;
|
|
|
48
48
|
const EIGHT_BIT = 8;
|
|
49
49
|
/** IHDR interlace method 1: the only one PNG defines besides "none". */
|
|
50
50
|
const ADAM7_INTERLACE = 1;
|
|
51
|
+
/**
|
|
52
|
+
* Largest PNG raster decoded for one image. A PNG's IDAT can compress an
|
|
53
|
+
* empty raster about a thousandfold, so the encoded size says little about
|
|
54
|
+
* the decode: 64 MP of RGBA is 256 MB per raster copy before the alpha split
|
|
55
|
+
* and the re-deflate. Matches the per-image TIFF ceiling at import.
|
|
56
|
+
*/
|
|
57
|
+
const MAX_PDF_PNG_PIXELS = 64e6;
|
|
58
|
+
/**
|
|
59
|
+
* Pixels decoded across every PNG in one PDF. The per-image ceiling bounds a
|
|
60
|
+
* single decode; without a running total many large images still add up.
|
|
61
|
+
*/
|
|
62
|
+
const MAX_PDF_DOCUMENT_PNG_PIXELS = 256e6;
|
|
51
63
|
const toHex = (bytes) => {
|
|
52
64
|
let out = "";
|
|
53
65
|
for (const byte of bytes) out += byte.toString(16).padStart(2, "0").toUpperCase();
|
|
@@ -281,7 +293,7 @@ const expandIndices = ({ rows, bytesPerRow, width, height, bitDepth }) => {
|
|
|
281
293
|
}
|
|
282
294
|
return out;
|
|
283
295
|
};
|
|
284
|
-
const decodePng = (bytes) => {
|
|
296
|
+
const decodePng = (bytes, maxPixels) => {
|
|
285
297
|
const chunks = readPngChunks(bytes);
|
|
286
298
|
if (chunks.isErr()) return Result.err(chunks.error);
|
|
287
299
|
const { header, palette, transparency, pixels } = chunks.value;
|
|
@@ -292,6 +304,8 @@ const decodePng = (bytes) => {
|
|
|
292
304
|
const colorType = header[9] ?? 0;
|
|
293
305
|
const interlace = header[12] ?? 0;
|
|
294
306
|
if (width === 0 || height === 0) return Result.err(new PdfImageError({ message: "PNG has a zero dimension" }));
|
|
307
|
+
const pixelLimit = Math.min(maxPixels, MAX_PDF_PNG_PIXELS);
|
|
308
|
+
if (width * height > pixelLimit) return Result.err(new PdfImageError({ message: `PNG is ${String(width)}x${String(height)} pixels, above the ${String(pixelLimit)} pixels allowed` }));
|
|
295
309
|
if (interlace !== 0 && interlace !== ADAM7_INTERLACE) return Result.err(new PdfImageError({ message: `unknown PNG interlace method ${String(interlace)}` }));
|
|
296
310
|
const channels = CHANNELS_PER_COLOR_TYPE[colorType];
|
|
297
311
|
if (channels === void 0) return Result.err(new PdfImageError({ message: `unknown PNG colour type ${String(colorType)}` }));
|
|
@@ -566,9 +580,13 @@ const decodeJpeg = (bytes) => {
|
|
|
566
580
|
}
|
|
567
581
|
return Result.err(new PdfImageError({ message: "JPEG has no frame header" }));
|
|
568
582
|
};
|
|
569
|
-
|
|
583
|
+
/**
|
|
584
|
+
* Decode one image for painting. `maxPngPixels` is what remains of the
|
|
585
|
+
* document's PNG pixel budget; JPEG passes through undecoded and spends none.
|
|
586
|
+
*/
|
|
587
|
+
const decodeImage = (source, maxPngPixels = MAX_PDF_PNG_PIXELS) => {
|
|
570
588
|
switch (source.format) {
|
|
571
|
-
case "png": return decodePng(source.bytes);
|
|
589
|
+
case "png": return decodePng(source.bytes, maxPngPixels);
|
|
572
590
|
case "jpeg": return decodeJpeg(source.bytes);
|
|
573
591
|
case "svg": return Result.err(new PdfImageError({ message: "SVG images are not supported in PDF" }));
|
|
574
592
|
default: {
|
|
@@ -577,4 +595,4 @@ const decodeImage = (source) => {
|
|
|
577
595
|
}
|
|
578
596
|
}
|
|
579
597
|
};
|
|
580
|
-
export { PdfImageError, decodeImage };
|
|
598
|
+
export { MAX_PDF_DOCUMENT_PNG_PIXELS, MAX_PDF_PNG_PIXELS, PdfImageError, decodeImage };
|
package/dist/pdf/writePdf.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getShaper } from "../shaping/shaper.js";
|
|
|
2
2
|
import { encodeUtf8 } from "../utils/textEncoding.js";
|
|
3
3
|
import { collectResources, renderContentStream } from "./contentStream.js";
|
|
4
4
|
import { prepareFonts } from "./fonts.js";
|
|
5
|
-
import { decodeImage } from "./images.js";
|
|
5
|
+
import { MAX_PDF_DOCUMENT_PNG_PIXELS, decodeImage } from "./images.js";
|
|
6
6
|
import { createPdfDocument, pdfArray, pdfAsciiString, pdfDict, pdfFlateStream, pdfName, pdfNull, pdfNumber, pdfNumberArray, pdfStream, pdfTextString } from "./objects.js";
|
|
7
7
|
import { displayPointToPdf, pxToPt } from "./pageSpace.js";
|
|
8
8
|
import { collectUsage, paintPage } from "./paint.js";
|
|
@@ -265,14 +265,16 @@ const writePdf = async (list, options) => {
|
|
|
265
265
|
});
|
|
266
266
|
if (options.strictGlyphCoverage === true && unencodable.length > 0) return Result.err(new WritePdfError({ message: describeUnencodable(unencodable) }));
|
|
267
267
|
const imageRefs = /* @__PURE__ */ new Map();
|
|
268
|
+
let remainingPngPixels = MAX_PDF_DOCUMENT_PNG_PIXELS;
|
|
268
269
|
for (const imageIndex of [...usage.value.imageIndices].sort((left, right) => left - right)) {
|
|
269
270
|
const source = list.images[imageIndex];
|
|
270
271
|
if (source === void 0) return Result.err(new WritePdfError({ message: `image ${String(imageIndex)} is outside the image table` }));
|
|
271
|
-
const decoded = decodeImage(source);
|
|
272
|
+
const decoded = decodeImage(source, remainingPngPixels);
|
|
272
273
|
if (decoded.isErr()) return Result.err(new WritePdfError({
|
|
273
274
|
message: `image ${String(imageIndex)} could not be decoded: ${decoded.error.message}`,
|
|
274
275
|
cause: decoded.error
|
|
275
276
|
}));
|
|
277
|
+
if (source.format === "png") remainingPngPixels -= decoded.value.widthPx * decoded.value.heightPx;
|
|
276
278
|
imageRefs.set(imageIndex, buildImageObject(document, decoded.value));
|
|
277
279
|
}
|
|
278
280
|
const outlineRoots = buildOutlineTree(list.outline, document);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Transaction } from "prosemirror-state";
|
|
3
|
+
import { Transform } from "prosemirror-transform";
|
|
3
4
|
/** The id a text box anchor names, or `undefined` for anything else. */
|
|
4
5
|
export declare const textBoxAnchorIdOf: (node: Node) => string | undefined;
|
|
5
6
|
/** The anchor ids of the text boxes drawn in `node`. */
|
|
@@ -31,4 +32,4 @@ export declare const textBoxAnchorIdsBetween: (doc: Node, from: number, to: numb
|
|
|
31
32
|
* boxes drawn in it, which stand between the two, past that paragraph, where
|
|
32
33
|
* they follow the joined one. Returns whether any moved.
|
|
33
34
|
*/
|
|
34
|
-
export declare const moveTextBoxesPastNextParagraph: (tr:
|
|
35
|
+
export declare const moveTextBoxesPastNextParagraph: (tr: Transform, position: number) => boolean;
|
|
@@ -978,6 +978,7 @@ const readCommentMarkAttrs = (mark) => {
|
|
|
978
978
|
const issues = [];
|
|
979
979
|
expectMarkType(mark, "comment", issues);
|
|
980
980
|
requiredNumber(attrs, "commentId", "comment.attrs.commentId", issues);
|
|
981
|
+
optionalBoolean(attrs, "point", "comment.attrs.point", issues);
|
|
981
982
|
return attrsResult(attrs, issues);
|
|
982
983
|
};
|
|
983
984
|
const expectCommentMarkAttrs = (mark) => expectCachedMarkAttrs(mark, commentAttrsCache, readCommentMarkAttrs, "comment attrs");
|
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { TableCellFormatting, TableFormatting, TableRowFormatting } from "../types/formatting.js";
|
|
2
3
|
import { Node } from "prosemirror-model";
|
|
3
4
|
import { Command, EditorState } from "prosemirror-state";
|
|
4
|
-
import { FormattingPatch, ParagraphPropsPatch, RunPropsPatch } from "@stll/docx-core/ops";
|
|
5
|
+
import { FormattingPatch, ParagraphPropsPatch, RunPropsPatch, TableBlockIntentOperation, TableIntentOperation, TableRowIntentOperation } from "@stll/docx-core/ops";
|
|
6
|
+
/** One table, row or cell, addressed by a position inside its first paragraph. */
|
|
7
|
+
export type CanonicalTableFormatTarget = {
|
|
8
|
+
scope: "table";
|
|
9
|
+
at: number;
|
|
10
|
+
patch: FormattingPatch<TableFormatting>;
|
|
11
|
+
} | {
|
|
12
|
+
scope: "row";
|
|
13
|
+
at: number;
|
|
14
|
+
patch: FormattingPatch<TableRowFormatting>;
|
|
15
|
+
} | {
|
|
16
|
+
scope: "cell";
|
|
17
|
+
at: number;
|
|
18
|
+
patch: FormattingPatch<TableCellFormatting>;
|
|
19
|
+
};
|
|
20
|
+
type WithoutTableTarget<Operation> = Operation extends unknown ? Omit<Operation, "story" | "blockId"> : never;
|
|
21
|
+
/**
|
|
22
|
+
* A change to a table's columns, cells or grid. The session addresses the
|
|
23
|
+
* table through a paragraph of its own; the engine derives fresh ids.
|
|
24
|
+
*/
|
|
25
|
+
export type CanonicalTableEdit = WithoutTableTarget<Exclude<TableIntentOperation, {
|
|
26
|
+
type: "setCellProps" | "setRowProps" | "setTableProps";
|
|
27
|
+
}>>;
|
|
5
28
|
/** Command meaning before canonical positions are resolved by the session. */
|
|
6
29
|
export type CanonicalCommandIntent = {
|
|
30
|
+
type: "formatTable";
|
|
31
|
+
targets: readonly CanonicalTableFormatTarget[];
|
|
32
|
+
} | {
|
|
33
|
+
type: "editTable";
|
|
34
|
+
at: number;
|
|
35
|
+
edit: CanonicalTableEdit;
|
|
36
|
+
} | {
|
|
37
|
+
type: "editTableBlock";
|
|
38
|
+
at: number;
|
|
39
|
+
edit: WithoutTableTarget<TableBlockIntentOperation>;
|
|
40
|
+
} | {
|
|
41
|
+
type: "editTableRow";
|
|
42
|
+
at: number;
|
|
43
|
+
edit: WithoutTableTarget<TableRowIntentOperation>;
|
|
44
|
+
} | {
|
|
7
45
|
type: "generateTOC";
|
|
8
46
|
at: number;
|
|
9
47
|
title: string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CanonicalCommandIntent } from "./canonicalCommands.js";
|
|
2
|
+
import { Command, EditorState } from "prosemirror-state";
|
|
3
|
+
/**
|
|
4
|
+
* What an attribute-only table command does, as table formatting patches.
|
|
5
|
+
*
|
|
6
|
+
* The command runs against the state without dispatching to the view. Every
|
|
7
|
+
* table, row and cell whose attributes it changed lowers to a patch of the
|
|
8
|
+
* formatting the save would write for it, so the session applies exactly what
|
|
9
|
+
* the editor would have saved. A command that changes anything else (content,
|
|
10
|
+
* a node's type, a span) has no attribute lowering and stays refused.
|
|
11
|
+
*/
|
|
12
|
+
export declare const lowerTableAttributeCommand: (command: Command, state: EditorState) => readonly CanonicalCommandIntent[] | undefined;
|
|
13
|
+
/** Register a command whose whole effect is table, row and cell attributes. */
|
|
14
|
+
export declare const withCanonicalTableAttributeCommand: (command: Command) => Command;
|
|
15
|
+
export declare const withCanonicalColumnInsertion: (command: Command, side: "left" | "right") => Command;
|
|
16
|
+
export declare const withCanonicalColumnDeletion: (command: Command) => Command;
|
|
17
|
+
export declare const withCanonicalCellMerge: (command: Command) => Command;
|
|
18
|
+
export declare const withCanonicalCellSplit: (command: Command) => Command;
|
|
19
|
+
export declare const withCanonicalRowInsertion: (command: Command, side: "above" | "below") => Command;
|
|
20
|
+
export declare const withCanonicalRowDeletion: (command: Command) => Command;
|
|
21
|
+
export declare const withCanonicalTableDeletion: (command: Command) => Command;
|
|
22
|
+
/**
|
|
23
|
+
* Register the insert table command, lowered to a table and an empty
|
|
24
|
+
* paragraph after the paragraph that holds the caret, as the command places
|
|
25
|
+
* them. The table is the one the command built, without the revision marks
|
|
26
|
+
* it put on its rows; in suggesting mode the engine records its own.
|
|
27
|
+
*/
|
|
28
|
+
export declare const withCanonicalTableInsertion: (command: Command) => Command;
|