@stll/folio-core 0.47.7 → 0.49.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.js +565 -121
- package/dist/ai-edits/minimal-replacement.d.ts +64 -0
- package/dist/ai-edits/minimal-replacement.js +282 -0
- package/dist/controller/fontReadiness.js +3 -3
- package/dist/controller/hyphenationReadiness.d.ts +19 -0
- package/dist/controller/hyphenationReadiness.js +47 -0
- package/dist/controller/layoutPipeline.d.ts +3 -0
- package/dist/controller/layoutPipeline.js +70 -18
- package/dist/display-list/build/buildDisplayList.js +39 -12
- package/dist/display-list/build/pageFurniture.d.ts +7 -1
- package/dist/display-list/build/pageFurniture.js +21 -8
- package/dist/display-list/build/paragraphPrimitives.js +68 -11
- package/dist/display-list/build/tablePrimitives.js +10 -6
- package/dist/display-list/build/textBoxPrimitives.js +1 -1
- package/dist/display-list/build/unsupported.d.ts +2 -2
- package/dist/display-list/build/unsupported.js +0 -0
- package/dist/display-list/dom/renderDisplayListToDom.js +0 -1
- package/dist/docx/attributeRemainder.js +10 -2
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +79 -64
- package/dist/docx/bulletMarkers.d.ts +18 -2
- package/dist/docx/bulletMarkers.js +27 -2
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +57 -45
- package/dist/docx/containerChildren.d.ts +21 -8
- package/dist/docx/containerChildren.js +39 -9
- package/dist/docx/documentParser.d.ts +5 -1
- package/dist/docx/documentParser.js +8 -5
- package/dist/docx/documentSectionFacts.d.ts +22 -0
- package/dist/docx/documentSectionFacts.js +43 -0
- package/dist/docx/drawingGroupChildren.d.ts +60 -0
- package/dist/docx/drawingGroupChildren.js +176 -0
- package/dist/docx/drawingUtils.js +3 -0
- package/dist/docx/fieldParser.d.ts +8 -1
- package/dist/docx/fieldParser.js +47 -3
- package/dist/docx/fontTableParser.js +34 -27
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +15 -12
- package/dist/docx/groupDrawingParser.d.ts +9 -2
- package/dist/docx/groupDrawingParser.js +125 -37
- package/dist/docx/headerFooterParser.d.ts +7 -2
- package/dist/docx/headerFooterParser.js +15 -5
- package/dist/docx/hyperlinkParser.d.ts +48 -36
- package/dist/docx/hyperlinkParser.js +97 -82
- package/dist/docx/numberingParser.js +108 -84
- package/dist/docx/packageParts.d.ts +45 -1
- package/dist/docx/packageParts.js +93 -2
- package/dist/docx/paraIdAttribute.d.ts +3 -2
- package/dist/docx/paragraphParser.d.ts +5 -1
- package/dist/docx/paragraphParser.js +468 -365
- package/dist/docx/paragraphProperties.js +123 -109
- package/dist/docx/paragraphPropertySource.d.ts +6 -1
- package/dist/docx/paragraphPropertySource.js +9 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +143 -10
- package/dist/docx/parser.d.ts +7 -1
- package/dist/docx/parser.js +33 -16
- package/dist/docx/previewBudget.d.ts +55 -33
- package/dist/docx/previewBudget.js +59 -65
- package/dist/docx/rezip.js +41 -58
- package/dist/docx/runParser.d.ts +4 -1
- package/dist/docx/runParser.js +182 -184
- package/dist/docx/sdtProperties.js +87 -84
- package/dist/docx/sectionParser.js +169 -160
- package/dist/docx/selectiveSaveFlags.d.ts +10 -3
- package/dist/docx/selectiveSaveFlags.js +1 -1
- package/dist/docx/selectiveXmlPatch.d.ts +56 -34
- package/dist/docx/selectiveXmlPatch.js +222 -115
- package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +12 -0
- package/dist/docx/serializer/groupTextBoxWriteBack.js +101 -0
- package/dist/docx/serializer/paragraphSerializer.js +47 -42
- package/dist/docx/serializer/runSerializer.d.ts +5 -1
- package/dist/docx/serializer/runSerializer.js +4 -3
- package/dist/docx/serializer/settingsSerializer.js +19 -1
- package/dist/docx/settingsParser.js +8 -0
- package/dist/docx/shapeAlternateContent.d.ts +25 -0
- package/dist/docx/shapeAlternateContent.js +52 -0
- package/dist/docx/streamingXmlParser.d.ts +6 -2
- package/dist/docx/streamingXmlParser.js +12 -7
- package/dist/docx/styleParser.js +34 -8
- package/dist/docx/tableParser.d.ts +21 -12
- package/dist/docx/tableParser.js +518 -441
- package/dist/docx/textBoxParser.d.ts +18 -5
- package/dist/docx/textBoxParser.js +12 -6
- package/dist/docx/verbatimCapture.d.ts +10 -8
- package/dist/docx/verbatimCapture.js +45 -2
- package/dist/docx/vmlImageParser.d.ts +15 -13
- package/dist/docx/vmlImageParser.js +75 -60
- package/dist/docx/vmlPreview.d.ts +3 -3
- package/dist/docx/vmlPreview.js +3 -4
- package/dist/docx/xmlNamespaceContext.d.ts +9 -0
- package/dist/docx/xmlNamespaceContext.js +54 -0
- package/dist/docx/xmlParser.d.ts +6 -3
- package/dist/docx/xmlParser.js +11 -41
- package/dist/docx/xmlResourceLimits.d.ts +2 -1
- package/dist/docx/xmlResourceLimits.js +4 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/headless-layout.d.ts +11 -2
- package/dist/headless-layout.js +153 -107
- package/dist/internal/headlessRevisionResolution.js +50 -13
- package/dist/internal/paragraphFormattingSerialization.js +3 -3
- package/dist/layout-bridge/convert/endnoteLayout.d.ts +65 -0
- package/dist/layout-bridge/convert/endnoteLayout.js +227 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +19 -3
- package/dist/layout-bridge/convert/footnoteLayout.js +40 -31
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -7
- package/dist/layout-bridge/convert/headerFooterLayout.js +5 -20
- package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +10 -0
- package/dist/layout-bridge/convert/paragraphMarkFormatting.js +59 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +29 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +284 -39
- package/dist/layout-bridge/engine/hitTest.js +5 -3
- package/dist/layout-bridge/engine/selectionRects.js +5 -3
- package/dist/layout-engine/anchorLayoutInCellCompatibility.d.ts +10 -0
- package/dist/layout-engine/anchorLayoutInCellCompatibility.js +22 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +102 -14
- package/dist/layout-engine/justificationCompatibility.d.ts +1 -1
- package/dist/layout-engine/justificationCompatibility.js +9 -5
- package/dist/layout-engine/keep-together.d.ts +15 -6
- package/dist/layout-engine/keep-together.js +43 -16
- package/dist/layout-engine/layoutInstrumentation.d.ts +8 -2
- package/dist/layout-engine/layoutInstrumentation.js +8 -1
- package/dist/layout-engine/measure/advanceComposition.js +50 -7
- package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +74 -0
- package/dist/layout-engine/measure/hyphenationDictionaries.js +138 -0
- package/dist/layout-engine/measure/hyphenationPreload.d.ts +11 -0
- package/dist/layout-engine/measure/hyphenationPreload.js +24 -0
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +12 -2
- package/dist/layout-engine/measure/lineBreakProvider.js +30 -30
- package/dist/layout-engine/measure/lineBreaks.d.ts +6 -1
- package/dist/layout-engine/measure/lineBreaks.js +10 -3
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +9 -6
- package/dist/layout-engine/measure/listMarkerWidth.js +20 -22
- package/dist/layout-engine/measure/measureBlocks.js +46 -10
- package/dist/layout-engine/measure/measureContainer.js +51 -8
- package/dist/layout-engine/measure/measureHelpers.d.ts +15 -3
- package/dist/layout-engine/measure/measureHelpers.js +34 -8
- package/dist/layout-engine/measure/measureParagraph.js +143 -101
- package/dist/layout-engine/measure/measureTypes.d.ts +5 -0
- package/dist/layout-engine/measure/smallCapsCasing.d.ts +56 -0
- package/dist/layout-engine/measure/smallCapsCasing.js +88 -0
- package/dist/layout-engine/measure/tabCalculator.d.ts +2 -0
- package/dist/layout-engine/measure/tabCalculator.js +2 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +51 -19
- package/dist/layout-engine/measure/tableCellGrid.d.ts +28 -3
- package/dist/layout-engine/measure/tableCellGrid.js +45 -5
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/noteAreaFlow.d.ts +19 -0
- package/dist/layout-engine/noteAreaFlow.js +83 -0
- package/dist/layout-engine/paginator.d.ts +12 -1
- package/dist/layout-engine/paginator.js +18 -2
- package/dist/layout-engine/paragraphSpacing.d.ts +4 -2
- package/dist/layout-engine/paragraphSpacing.js +2 -1
- package/dist/layout-engine/tableRowBreak.d.ts +8 -1
- package/dist/layout-engine/tableRowBreak.js +25 -2
- package/dist/layout-engine/types.d.ts +108 -3
- package/dist/layout-engine/types.js +96 -1
- package/dist/layout-painter/index.d.ts +3 -0
- package/dist/layout-painter/renderPage.js +32 -83
- package/dist/layout-painter/renderParagraph.d.ts +6 -1
- package/dist/layout-painter/renderParagraph.js +75 -26
- package/dist/layout-painter/renderTable.js +26 -13
- package/dist/layout-painter/renderTextBox.d.ts +12 -2
- package/dist/layout-painter/renderTextBox.js +26 -2
- package/dist/prosemirror/alternateContentAttrs.d.ts +9 -0
- package/dist/prosemirror/alternateContentAttrs.js +35 -0
- package/dist/prosemirror/attrs/index.d.ts +9 -9
- package/dist/prosemirror/attrs/index.js +133 -11
- package/dist/prosemirror/commands/comments.js +51 -41
- package/dist/prosemirror/contentControlRevisions.d.ts +43 -0
- package/dist/prosemirror/contentControlRevisions.js +84 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +54 -23
- package/dist/prosemirror/conversion/markInterner.d.ts +21 -0
- package/dist/prosemirror/conversion/markInterner.js +90 -0
- package/dist/prosemirror/conversion/toProseDoc.js +117 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +2 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +7 -7
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -7
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +6 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +39 -51
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +9 -2
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +4 -2
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/paragraphDirection.d.ts +29 -2
- package/dist/prosemirror/paragraphDirection.js +21 -2
- package/dist/prosemirror/plugins/suggestionMode.js +37 -8
- package/dist/prosemirror/rejoinRunCarriers.d.ts +27 -0
- package/dist/prosemirror/rejoinRunCarriers.js +66 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +10 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.js +90 -0
- package/dist/prosemirror/schema/nodes.d.ts +50 -6
- package/dist/prosemirror/textBoxHostParagraph.d.ts +13 -0
- package/dist/prosemirror/textBoxHostParagraph.js +21 -0
- package/dist/prosemirror/validation.js +91 -80
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +10 -1
- package/dist/utils/scriptSegments.d.ts +33 -4
- package/dist/utils/scriptSegments.js +39 -6
- package/dist/utils/textFormattingMerge.d.ts +17 -3
- package/dist/utils/textFormattingMerge.js +18 -12
- package/dist/utils/trailingText.d.ts +22 -0
- package/dist/utils/trailingText.js +32 -0
- package/package.json +2 -2
- package/dist/layout-engine/justifiedLineFit.d.ts +0 -7
- package/dist/layout-engine/justifiedLineFit.js +0 -6
|
@@ -15,21 +15,27 @@ const STYLE_TOGGLE_KEYS = [
|
|
|
15
15
|
"hidden"
|
|
16
16
|
];
|
|
17
17
|
/**
|
|
18
|
-
* Merge
|
|
18
|
+
* Merge one style's own run-formatting declarations onto its already-resolved
|
|
19
|
+
* `w:basedOn` ancestor.
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* ECMA-376 §17.7.3 resolves a toggle property (bold, italic, allCaps, ...) for a
|
|
22
|
+
* single style tier by walking the `basedOn` chain from the style itself towards
|
|
23
|
+
* its root: read the value the style declares; if it declares none, move to the
|
|
24
|
+
* parent and repeat. The first value found — whether an explicit "on" or an
|
|
25
|
+
* explicit "off" — is that tier's value, and it is *not* combined with whatever
|
|
26
|
+
* a weaker ancestor further up the chain happened to say. A style's own
|
|
27
|
+
* `<w:b w:val="0"/>` therefore turns bold off outright, even when its base style
|
|
28
|
+
* is bold; it does not defer to the base.
|
|
29
|
+
*
|
|
30
|
+
* That is exactly last-defined-wins, i.e. `mergeTextFormatting`'s existing
|
|
31
|
+
* behaviour for every other property. The toggle behaviour §17.7.3 is actually
|
|
32
|
+
* known for — combining a table style's, a paragraph style's and a character
|
|
33
|
+
* style's resolved values by Boolean XOR — combines the *outputs* of separate
|
|
34
|
+
* `basedOn` walks like this one; it is not part of resolving a single walk, so
|
|
35
|
+
* it has no place in this function.
|
|
22
36
|
*/
|
|
23
37
|
function mergeStyleTextFormatting(target, source) {
|
|
24
|
-
|
|
25
|
-
if (!result || !source) return result;
|
|
26
|
-
for (const key of STYLE_TOGGLE_KEYS) {
|
|
27
|
-
if (source[key] !== false) continue;
|
|
28
|
-
const inherited = target?.[key];
|
|
29
|
-
if (inherited === void 0) Reflect.deleteProperty(result, key);
|
|
30
|
-
else result[key] = inherited;
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
38
|
+
return mergeTextFormatting(target, source);
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* A merge answers "what does this text look like once the style, the paragraph
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/utils/trailingText.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Linear scans over the end of a text run. Layout calls these on every
|
|
4
|
+
* measure and paint pass, and run text can be arbitrarily long, so they
|
|
5
|
+
* must not backtrack the way an end-anchored regular expression does.
|
|
6
|
+
*/
|
|
7
|
+
/** Index where the trailing run of U+0020 spaces begins; `text.length` when there is none. */
|
|
8
|
+
declare function trailingSpaceStart(text: string): number;
|
|
9
|
+
type TrailingToken = {
|
|
10
|
+
/** Last run of non-whitespace characters. */
|
|
11
|
+
token: string;
|
|
12
|
+
/** Whitespace after the token, up to the end of the text. */
|
|
13
|
+
separator: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Split off the last whitespace-delimited token and the whitespace that
|
|
17
|
+
* follows it, or return undefined when the text has no non-whitespace
|
|
18
|
+
* character.
|
|
19
|
+
*/
|
|
20
|
+
declare function splitTrailingToken(text: string): TrailingToken | undefined;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { TrailingToken, splitTrailingToken, trailingSpaceStart };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/utils/trailingText.ts
|
|
2
|
+
/**
|
|
3
|
+
* Linear scans over the end of a text run. Layout calls these on every
|
|
4
|
+
* measure and paint pass, and run text can be arbitrarily long, so they
|
|
5
|
+
* must not backtrack the way an end-anchored regular expression does.
|
|
6
|
+
*/
|
|
7
|
+
const WHITESPACE = /\s/u;
|
|
8
|
+
const isWhitespaceUnit = (text, index) => WHITESPACE.test(text.charAt(index));
|
|
9
|
+
/** Index where the trailing run of U+0020 spaces begins; `text.length` when there is none. */
|
|
10
|
+
function trailingSpaceStart(text) {
|
|
11
|
+
let start = text.length;
|
|
12
|
+
while (start > 0 && text.charCodeAt(start - 1) === 32) start--;
|
|
13
|
+
return start;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Split off the last whitespace-delimited token and the whitespace that
|
|
17
|
+
* follows it, or return undefined when the text has no non-whitespace
|
|
18
|
+
* character.
|
|
19
|
+
*/
|
|
20
|
+
function splitTrailingToken(text) {
|
|
21
|
+
let tokenEnd = text.length;
|
|
22
|
+
while (tokenEnd > 0 && isWhitespaceUnit(text, tokenEnd - 1)) tokenEnd--;
|
|
23
|
+
if (tokenEnd === 0) return;
|
|
24
|
+
let tokenStart = tokenEnd;
|
|
25
|
+
while (tokenStart > 0 && !isWhitespaceUnit(text, tokenStart - 1)) tokenStart--;
|
|
26
|
+
return {
|
|
27
|
+
token: text.slice(tokenStart, tokenEnd),
|
|
28
|
+
separator: text.slice(tokenEnd)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { splitTrailingToken, trailingSpaceStart };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.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",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"perf": "bun scripts/profile-editor.ts"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
-
"@stll/docx-core": "^0.
|
|
131
|
+
"@stll/docx-core": "^0.27.0",
|
|
132
132
|
"@stll/docx-utils": "^0.1.0",
|
|
133
133
|
"@stll/template-conditions": ">=0.4.0 <1.0.0",
|
|
134
134
|
"better-result": "3.0.1",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ParagraphBlock } from "./types.js";
|
|
2
|
-
//#region src/layout-engine/justifiedLineFit.d.ts
|
|
3
|
-
declare const JUSTIFIED_FINAL_LINE_MAX_SHRINK_RATIO = 0.025;
|
|
4
|
-
declare const JUSTIFIED_FINAL_LINE_SPACE_CONTRACTION_RATIO = 0.32;
|
|
5
|
-
declare const supportsJustifiedFinalLineContraction: (block: ParagraphBlock) => boolean;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { JUSTIFIED_FINAL_LINE_MAX_SHRINK_RATIO, JUSTIFIED_FINAL_LINE_SPACE_CONTRACTION_RATIO, supportsJustifiedFinalLineContraction };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/layout-engine/justifiedLineFit.ts
|
|
2
|
-
const JUSTIFIED_FINAL_LINE_MAX_SHRINK_RATIO = .025;
|
|
3
|
-
const JUSTIFIED_FINAL_LINE_SPACE_CONTRACTION_RATIO = .32;
|
|
4
|
-
const supportsJustifiedFinalLineContraction = (block) => block.attrs?.alignment === "justify" && block.attrs.justificationCompatibility?.type !== "legacy" && (block.attrs.listMarker !== void 0 || (block.attrs.indent?.left ?? 0) > 0);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { JUSTIFIED_FINAL_LINE_MAX_SHRINK_RATIO, JUSTIFIED_FINAL_LINE_SPACE_CONTRACTION_RATIO, supportsJustifiedFinalLineContraction };
|