@stll/folio-core 0.3.0 → 0.4.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/README.md +2 -2
- package/dist/ai-edits/headless.d.ts +2 -1
- package/dist/ai-edits/headless.js +9 -7
- package/dist/compat/eigenpal.d.ts +29 -0
- package/dist/compat/eigenpal.js +24 -0
- package/dist/controller/layoutPipeline.d.ts +1 -1
- package/dist/controller/layoutPipeline.js +22 -0
- package/dist/controller/layoutSession.d.ts +1 -1
- package/dist/docx/encryption/agileDecryption.d.ts +6 -0
- package/dist/docx/encryption/agileDecryption.js +208 -0
- package/dist/docx/encryption/compoundFile.d.ts +20 -0
- package/dist/docx/encryption/compoundFile.js +249 -0
- package/dist/docx/encryption/containerFormat.d.ts +15 -0
- package/dist/docx/encryption/containerFormat.js +40 -0
- package/dist/docx/encryption/cryptoBytes.d.ts +11 -0
- package/dist/docx/encryption/cryptoBytes.js +55 -0
- package/dist/docx/encryption/encryptionInfo.d.ts +32 -0
- package/dist/docx/encryption/encryptionInfo.js +128 -0
- package/dist/docx/encryption/errors.d.ts +18 -0
- package/dist/docx/encryption/errors.js +13 -0
- package/dist/docx/encryption/index.d.ts +4 -0
- package/dist/docx/encryption/index.js +4 -0
- package/dist/docx/encryption/openEncryptedDocx.d.ts +28 -0
- package/dist/docx/encryption/openEncryptedDocx.js +65 -0
- package/dist/docx/index.d.ts +3 -1
- package/dist/docx/index.js +3 -1
- package/dist/docx/parser.d.ts +4 -5
- package/dist/docx/parser.js +8 -2
- package/dist/docx/unzip.d.ts +7 -5
- package/dist/docx/unzip.js +8 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.js +2 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -1
- package/dist/layout-bridge/convert/headerFooterLayout.js +16 -6
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +2 -0
- package/dist/layout-engine/index.js +27 -1
- package/dist/layout-engine/measure/measureBlocks.js +15 -1
- package/dist/layout-engine/measure/measureParagraph.js +37 -6
- package/dist/layout-engine/types.d.ts +3 -0
- package/dist/layout-painter/renderPage.js +2 -1
- package/dist/layout-painter/renderParagraph.js +30 -5
- package/dist/layout-painter/renderTable.js +17 -0
- package/dist/managers/DocumentLoaderManager.d.ts +3 -1
- package/dist/managers/DocumentLoaderManager.js +3 -2
- package/dist/paged-layout/headerFooterMargins.d.ts +3 -1
- package/dist/paged-layout/headerFooterMargins.js +5 -3
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +7 -2
- package/dist/prosemirror/conversion/toProseDoc.js +14 -7
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +2 -0
- package/dist/prosemirror/schema/nodes.d.ts +4 -2
- package/dist/server.d.ts +2 -2
- package/dist/utils/fontResolver.d.ts +3 -1
- package/dist/utils/fontResolver.js +28 -4
- package/package.json +9 -1
|
@@ -199,6 +199,7 @@ const tableRowSpec = {
|
|
|
199
199
|
height: { default: null },
|
|
200
200
|
heightRule: { default: null },
|
|
201
201
|
isHeader: { default: false },
|
|
202
|
+
hidden: { default: false },
|
|
202
203
|
_originalFormatting: { default: null }
|
|
203
204
|
},
|
|
204
205
|
parseDOM: [{ tag: "tr" }],
|
|
@@ -206,6 +207,7 @@ const tableRowSpec = {
|
|
|
206
207
|
const attrs = expectTableRowAttrs(node);
|
|
207
208
|
const domAttrs = {};
|
|
208
209
|
if (typeof attrs.height === "number") domAttrs["style"] = `height: ${Math.round(attrs.height / 20 * 1.333)}px`;
|
|
210
|
+
if (attrs.hidden) domAttrs["style"] = `${domAttrs["style"] ? `${domAttrs["style"]}; ` : ""}display: none`;
|
|
209
211
|
return [
|
|
210
212
|
"tr",
|
|
211
213
|
domAttrs,
|
|
@@ -82,7 +82,8 @@ type ParagraphAttrs = {
|
|
|
82
82
|
pageBreakBefore?: boolean; /** Word's cached rendered-page-break marker; preserved for round-trip only. */
|
|
83
83
|
renderedPageBreakBefore?: boolean;
|
|
84
84
|
keepNext?: boolean;
|
|
85
|
-
keepLines?: boolean;
|
|
85
|
+
keepLines?: boolean;
|
|
86
|
+
widowControl?: boolean; /** Contextual spacing — suppress space between same-style paragraphs */
|
|
86
87
|
contextualSpacing?: boolean;
|
|
87
88
|
defaultTextFormatting?: document_d_exports.TextFormatting;
|
|
88
89
|
sectionBreakType?: "nextPage" | "continuous" | "oddPage" | "evenPage";
|
|
@@ -353,7 +354,8 @@ type TableAttrs = {
|
|
|
353
354
|
type TableRowAttrs = {
|
|
354
355
|
/** Row height (in twips) */height?: number; /** Height rule ('auto', 'exact', 'atLeast') */
|
|
355
356
|
heightRule?: NonNullable<document_d_exports.TableRowFormatting["heightRule"]>; /** Is header row */
|
|
356
|
-
isHeader?: boolean; /**
|
|
357
|
+
isHeader?: boolean; /** Whether the row is hidden (`w:hidden`) */
|
|
358
|
+
hidden?: boolean; /** Original row formatting from DOCX for lossless round-trip serialization */
|
|
357
359
|
_originalFormatting?: document_d_exports.TableRowFormatting;
|
|
358
360
|
};
|
|
359
361
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreview
|
|
|
2
2
|
import { FolioReviewChange, FolioReviewChangeKind } from "./ai-edits/read.js";
|
|
3
3
|
import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FolioApplyOperationsOptions, FolioDocxReviewer, FolioDocxReviewerOptions, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
|
|
4
4
|
import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
5
|
-
import { CreateCommentReplyInput, replyToComment } from "./docx/replyToComment.js";
|
|
6
|
-
import { createDocx } from "./docx/rezip.js";
|
|
7
5
|
import { CreateEmptyDocumentOptions, createEmptyDocument } from "./utils/createDocument.js";
|
|
6
|
+
import { createDocx } from "./docx/rezip.js";
|
|
7
|
+
import { CreateCommentReplyInput, replyToComment } from "./docx/replyToComment.js";
|
|
8
8
|
export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, type DeriveBlockIdInput, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditSnapshot, type FolioApplyOperationsOptions, type FolioBlockId, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, applyFolioAIEditsToBuffer, createDocx, createEmptyDocument, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId, replyToComment };
|
|
@@ -38,6 +38,8 @@ declare function isCjkFont(family: string): boolean;
|
|
|
38
38
|
* used for width measurement or painting.
|
|
39
39
|
*/
|
|
40
40
|
declare const CJK_FALLBACK_FONT_FAMILY = "MS Mincho";
|
|
41
|
+
declare const setGoogleFontsEnabled: (enabled: boolean) => void;
|
|
42
|
+
declare const getGoogleFontsEnabled: () => boolean;
|
|
41
43
|
declare function resolveFontFamily(docxFontName: string): ResolvedFont;
|
|
42
44
|
/**
|
|
43
45
|
* Resolve a theme font reference to actual font names
|
|
@@ -77,4 +79,4 @@ declare function getGoogleFontEquivalent(docxFontName: string): string | null;
|
|
|
77
79
|
*/
|
|
78
80
|
declare function hasGoogleFontEquivalent(docxFontName: string): boolean;
|
|
79
81
|
//#endregion
|
|
80
|
-
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, ResolvedFont, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, resolveFontFamily, resolveThemeFont };
|
|
82
|
+
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, ResolvedFont, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsEnabled, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, resolveFontFamily, resolveThemeFont, setGoogleFontsEnabled };
|
|
@@ -128,6 +128,23 @@ const FONT_MAPPINGS = {
|
|
|
128
128
|
unitsPerEm: 2048
|
|
129
129
|
})
|
|
130
130
|
},
|
|
131
|
+
"cg times": {
|
|
132
|
+
googleFont: "Tinos",
|
|
133
|
+
category: "serif",
|
|
134
|
+
fallbackStack: [
|
|
135
|
+
"Times New Roman",
|
|
136
|
+
"Tinos",
|
|
137
|
+
"Times",
|
|
138
|
+
"serif"
|
|
139
|
+
],
|
|
140
|
+
singleLineRatio: singleLineRatioOf({
|
|
141
|
+
source: "hhea",
|
|
142
|
+
hheaAscent: 1825,
|
|
143
|
+
hheaDescent: -443,
|
|
144
|
+
hheaLineGap: 87,
|
|
145
|
+
unitsPerEm: 2048
|
|
146
|
+
})
|
|
147
|
+
},
|
|
131
148
|
"courier new": {
|
|
132
149
|
googleFont: "Cousine",
|
|
133
150
|
category: "monospace",
|
|
@@ -723,6 +740,11 @@ const CJK_FALLBACK_FONT_FAMILY = "MS Mincho";
|
|
|
723
740
|
const ARABIC_FALLBACK = "\"Noto Sans Arabic\"";
|
|
724
741
|
const TRAILING_GENERIC = /,\s*(?<generic>sans-serif|serif|monospace|cursive)\s*$/u;
|
|
725
742
|
const withArabicFallback = (stack) => TRAILING_GENERIC.test(stack) ? stack.replace(TRAILING_GENERIC, `, ${ARABIC_FALLBACK}, $<generic>`) : `${stack}, ${ARABIC_FALLBACK}`;
|
|
743
|
+
let googleFontsEnabled = true;
|
|
744
|
+
const setGoogleFontsEnabled = (enabled) => {
|
|
745
|
+
googleFontsEnabled = enabled;
|
|
746
|
+
};
|
|
747
|
+
const getGoogleFontsEnabled = () => googleFontsEnabled;
|
|
726
748
|
function resolveFontFamily(docxFontName) {
|
|
727
749
|
const normalizedName = docxFontName.trim().toLowerCase();
|
|
728
750
|
const aliasTarget = CJK_FONT_ALIASES[normalizedName];
|
|
@@ -730,10 +752,10 @@ function resolveFontFamily(docxFontName) {
|
|
|
730
752
|
if (mapping) {
|
|
731
753
|
const fallbackStack = aliasTarget && !mapping.fallbackStack.some((f) => f.toLowerCase() === normalizedName) ? [docxFontName, ...mapping.fallbackStack] : mapping.fallbackStack;
|
|
732
754
|
return {
|
|
733
|
-
googleFont: mapping.googleFont,
|
|
755
|
+
googleFont: googleFontsEnabled ? mapping.googleFont : null,
|
|
734
756
|
cssFallback: withArabicFallback(fallbackStack.map(quoteFontName).join(", ")),
|
|
735
757
|
originalFont: docxFontName,
|
|
736
|
-
hasGoogleEquivalent:
|
|
758
|
+
hasGoogleEquivalent: googleFontsEnabled,
|
|
737
759
|
singleLineRatio: mapping.singleLineRatio
|
|
738
760
|
};
|
|
739
761
|
}
|
|
@@ -830,7 +852,9 @@ function getGoogleFontEquivalent(docxFontName) {
|
|
|
830
852
|
* @returns true if there's a Google Fonts equivalent
|
|
831
853
|
*/
|
|
832
854
|
function hasGoogleFontEquivalent(docxFontName) {
|
|
833
|
-
|
|
855
|
+
if (!googleFontsEnabled) return false;
|
|
856
|
+
const normalizedName = docxFontName.trim().toLowerCase();
|
|
857
|
+
return (CJK_FONT_ALIASES[normalizedName] ?? normalizedName) in FONT_MAPPINGS;
|
|
834
858
|
}
|
|
835
859
|
//#endregion
|
|
836
|
-
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, resolveFontFamily, resolveThemeFont };
|
|
860
|
+
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsEnabled, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, resolveFontFamily, resolveThemeFont, setGoogleFontsEnabled };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -45,6 +45,14 @@
|
|
|
45
45
|
"types": "./dist/content-controls/index.d.ts",
|
|
46
46
|
"import": "./dist/content-controls/index.js"
|
|
47
47
|
},
|
|
48
|
+
"./compat/eigenpal": {
|
|
49
|
+
"types": "./dist/compat/eigenpal.d.ts",
|
|
50
|
+
"import": "./dist/compat/eigenpal.js"
|
|
51
|
+
},
|
|
52
|
+
"./watermark": {
|
|
53
|
+
"types": "./dist/watermark/index.d.ts",
|
|
54
|
+
"import": "./dist/watermark/index.js"
|
|
55
|
+
},
|
|
48
56
|
"./layout-engine": {
|
|
49
57
|
"types": "./dist/layout-engine/index.d.ts",
|
|
50
58
|
"import": "./dist/layout-engine/index.js"
|