@stll/folio-core 0.6.1 → 0.7.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/controller/layoutPipeline.js +18 -10
- package/dist/docx/groupDrawingParser.d.ts +1 -1
- package/dist/docx/groupDrawingParser.js +49 -8
- package/dist/docx/runParser.js +11 -2
- package/dist/docx/server/boundedArchive.d.ts +24 -0
- package/dist/docx/server/boundedArchive.js +106 -0
- package/dist/docx/server/extractDocxText.d.ts +23 -0
- package/dist/docx/server/extractDocxText.js +154 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +64 -10
- package/dist/layout-engine/index.js +115 -16
- package/dist/layout-engine/keep-together.d.ts +7 -5
- package/dist/layout-engine/keep-together.js +20 -4
- package/dist/layout-engine/measure/cache.js +2 -0
- package/dist/layout-engine/measure/measureParagraph.js +30 -12
- package/dist/layout-engine/paginator.js +10 -2
- package/dist/layout-engine/types.d.ts +15 -3
- package/dist/layout-painter/renderParagraph.js +88 -5
- package/dist/prosemirror/conversion/toProseDoc.js +2 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +1 -0
- package/dist/prosemirror/schema/nodes.d.ts +2 -1
- package/dist/prosemirror/utils/tabCalculator.js +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/utils/formatToStyle.js +3 -3
- package/dist/utils/units.d.ts +6 -6
- package/dist/utils/units.js +8 -8
- package/package.json +1 -1
|
@@ -347,7 +347,8 @@ type TableAttrs = {
|
|
|
347
347
|
right?: number;
|
|
348
348
|
}; /** Table look flags for conditional formatting (w:tblLook) */
|
|
349
349
|
look?: document_d_exports.TableLook; /** Table-level borders (w:tblBorders) — full BorderSpec per side */
|
|
350
|
-
borders?: document_d_exports.TableBorders; /**
|
|
350
|
+
borders?: document_d_exports.TableBorders; /** Effective table indent after style resolution. PM-only; never serialized. */
|
|
351
|
+
_resolvedIndent?: NonNullable<document_d_exports.TableFormatting["indent"]>; /** Original table formatting from DOCX for lossless round-trip serialization */
|
|
351
352
|
_originalFormatting?: document_d_exports.TableFormatting; /** Tracked table property changes (w:tblPrChange) for round-trip + accept/reject */
|
|
352
353
|
tblPrChange?: document_d_exports.TablePropertyChange[];
|
|
353
354
|
};
|
|
@@ -105,7 +105,7 @@ function calculateTabWidth(currentXPx, context, following = {}) {
|
|
|
105
105
|
...nextStop.leader !== void 0 ? { leader: nextStop.leader } : {},
|
|
106
106
|
alignment: "bar"
|
|
107
107
|
};
|
|
108
|
-
if (width
|
|
108
|
+
if (width <= 0) {
|
|
109
109
|
const defaultTabPx = twipsToPixels(defaultTabInterval);
|
|
110
110
|
let fallbackWidth = defaultTabPx - currentXPx % defaultTabPx;
|
|
111
111
|
if (fallbackWidth <= 0) fallbackWidth = defaultTabPx;
|
package/dist/server.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBloc
|
|
|
7
7
|
import { CreateEmptyDocumentOptions, createEmptyDocument } from "./utils/createDocument.js";
|
|
8
8
|
import { createDocx } from "./docx/rezip.js";
|
|
9
9
|
import { CreateCommentReplyInput, replyToComment } from "./docx/replyToComment.js";
|
|
10
|
+
import { DocxArchiveError } from "./docx/server/boundedArchive.js";
|
|
11
|
+
import { DocxParagraphSource, ExtractedDocxParagraph, ExtractedDocxText, extractDocxText } from "./docx/server/extractDocxText.js";
|
|
10
12
|
import { GenerateRedlineDocxOptions, GenerateRedlineDocxResult, generateRedlineDocx } from "./redline.js";
|
|
11
13
|
import { FolioBlockDiff, FolioFormatProperty, FolioVersionDiff, FolioVersionDiffSegment, compareDocxVersions } from "./version-comparison.js";
|
|
12
|
-
export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, type DeriveBlockIdInput, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioFormatProperty, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioVersionDiff, type FolioVersionDiffSegment, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, deriveBlockId, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, replyToComment };
|
|
14
|
+
export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, type DeriveBlockIdInput, DocxArchiveError, type DocxParagraphSource, type ExtractedDocxParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioFormatProperty, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioVersionDiff, type FolioVersionDiffSegment, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, deriveBlockId, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, replyToComment };
|
package/dist/server.js
CHANGED
|
@@ -7,4 +7,6 @@ import { replyToComment } from "./docx/replyToComment.js";
|
|
|
7
7
|
import { FolioDocxReviewer, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
|
|
8
8
|
import { compareDocxVersions } from "./version-comparison.js";
|
|
9
9
|
import { generateRedlineDocx } from "./redline.js";
|
|
10
|
-
|
|
10
|
+
import { DocxArchiveError } from "./docx/server/boundedArchive.js";
|
|
11
|
+
import { extractDocxText } from "./docx/server/extractDocxText.js";
|
|
12
|
+
export { DocxArchiveError, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocxReviewer, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, deriveBlockId, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, replyToComment };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { eighthsToPixels, formatPx, halfPointsToPixels, halfPointsToPoints, twipsToPixels } from "./units.js";
|
|
1
|
+
import { AUTO_PARAGRAPH_SPACING_PX, eighthsToPixels, formatPx, halfPointsToPixels, halfPointsToPoints, twipsToPixels } from "./units.js";
|
|
2
2
|
import { resolveFontFamily, resolveThemeFont } from "./fontResolver.js";
|
|
3
3
|
import { resolveColor, resolveHighlightToCss, resolveShadingColor } from "./colorResolver.js";
|
|
4
4
|
//#region src/utils/formatToStyle.ts
|
|
@@ -89,9 +89,9 @@ function paragraphToStyle(formatting, theme) {
|
|
|
89
89
|
if (!formatting) return {};
|
|
90
90
|
const style = {};
|
|
91
91
|
if (formatting.alignment) style.textAlign = mapAlignment(formatting.alignment);
|
|
92
|
-
if (formatting.beforeAutospacing) style.marginTop = formatPx(
|
|
92
|
+
if (formatting.beforeAutospacing) style.marginTop = formatPx(AUTO_PARAGRAPH_SPACING_PX);
|
|
93
93
|
else if (formatting.spaceBefore !== void 0) style.marginTop = formatPx(twipsToPixels(formatting.spaceBefore));
|
|
94
|
-
if (formatting.afterAutospacing) style.marginBottom = formatPx(
|
|
94
|
+
if (formatting.afterAutospacing) style.marginBottom = formatPx(AUTO_PARAGRAPH_SPACING_PX);
|
|
95
95
|
else if (formatting.spaceAfter !== void 0) style.marginBottom = formatPx(twipsToPixels(formatting.spaceAfter));
|
|
96
96
|
if (formatting.lineSpacing !== void 0 && formatting.lineSpacing > 0) if (formatting.lineSpacingRule === "exact") {
|
|
97
97
|
const exactPx = twipsToPixels(formatting.lineSpacing);
|
package/dist/utils/units.d.ts
CHANGED
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
*/
|
|
14
14
|
/** Twips per inch (1 inch = 1440 twips) */
|
|
15
15
|
declare const TWIPS_PER_INCH = 1440;
|
|
16
|
+
/** Pixels per inch at standard DPI */
|
|
17
|
+
declare const PIXELS_PER_INCH = 96;
|
|
16
18
|
/**
|
|
17
19
|
* Word's auto paragraph spacing in px. HTML-origin paragraphs use
|
|
18
20
|
* `w:beforeAutospacing`/`w:afterAutospacing` instead of explicit before/after;
|
|
19
|
-
* Word ignores any explicit value on such paragraphs and renders
|
|
20
|
-
* value is empirical (Word's rendered auto gap), not derivable from a
|
|
21
|
-
* conversion. See eigenpal/docx-editor#823.
|
|
21
|
+
* Word ignores any explicit value on such paragraphs and renders a 14pt gap.
|
|
22
|
+
* The value is empirical (Word's rendered auto gap), not derivable from a
|
|
23
|
+
* twips conversion. See eigenpal/docx-editor#823.
|
|
22
24
|
*/
|
|
23
|
-
declare const AUTO_PARAGRAPH_SPACING_PX
|
|
24
|
-
/** Pixels per inch at standard DPI */
|
|
25
|
-
declare const PIXELS_PER_INCH = 96;
|
|
25
|
+
declare const AUTO_PARAGRAPH_SPACING_PX: number;
|
|
26
26
|
/**
|
|
27
27
|
* Convert twips to pixels (at 96 DPI)
|
|
28
28
|
*
|
package/dist/utils/units.js
CHANGED
|
@@ -15,14 +15,6 @@
|
|
|
15
15
|
const STANDARD_DPI = 96;
|
|
16
16
|
/** Twips per inch (1 inch = 1440 twips) */
|
|
17
17
|
const TWIPS_PER_INCH = 1440;
|
|
18
|
-
/**
|
|
19
|
-
* Word's auto paragraph spacing in px. HTML-origin paragraphs use
|
|
20
|
-
* `w:beforeAutospacing`/`w:afterAutospacing` instead of explicit before/after;
|
|
21
|
-
* Word ignores any explicit value on such paragraphs and renders ~14px. The
|
|
22
|
-
* value is empirical (Word's rendered auto gap), not derivable from a twips
|
|
23
|
-
* conversion. See eigenpal/docx-editor#823.
|
|
24
|
-
*/
|
|
25
|
-
const AUTO_PARAGRAPH_SPACING_PX = 14;
|
|
26
18
|
/** EMUs per inch (1 inch = 914400 EMUs) */
|
|
27
19
|
const EMUS_PER_INCH = 914400;
|
|
28
20
|
/** Points per inch (1 inch = 72 points) */
|
|
@@ -34,6 +26,14 @@ const EIGHTHS_PER_INCH = 576;
|
|
|
34
26
|
/** Pixels per inch at standard DPI */
|
|
35
27
|
const PIXELS_PER_INCH = STANDARD_DPI;
|
|
36
28
|
/**
|
|
29
|
+
* Word's auto paragraph spacing in px. HTML-origin paragraphs use
|
|
30
|
+
* `w:beforeAutospacing`/`w:afterAutospacing` instead of explicit before/after;
|
|
31
|
+
* Word ignores any explicit value on such paragraphs and renders a 14pt gap.
|
|
32
|
+
* The value is empirical (Word's rendered auto gap), not derivable from a
|
|
33
|
+
* twips conversion. See eigenpal/docx-editor#823.
|
|
34
|
+
*/
|
|
35
|
+
const AUTO_PARAGRAPH_SPACING_PX = pointsToPixels(14);
|
|
36
|
+
/**
|
|
37
37
|
* Convert twips to pixels (at 96 DPI)
|
|
38
38
|
*
|
|
39
39
|
* 1 inch = 1440 twips = 96 pixels
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|