@stll/folio-core 0.59.0 → 0.60.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 +10 -1
- package/dist/compat/eigenpal.d.ts +2 -2
- package/dist/compat/eigenpal.js +2 -2
- package/dist/controller/canonicalSession.js +3 -2
- package/dist/controller/canonicalStructure.js +10 -7
- package/dist/controller/fontReadiness.js +1 -1
- package/dist/controller/layoutPipeline.js +7 -1
- package/dist/controller/layoutSession.d.ts +2 -0
- package/dist/display-list/build/fontTable.js +7 -5
- package/dist/display-list/build/furniture.d.ts +1 -0
- package/dist/display-list/build/furniture.js +1 -0
- package/dist/display-list/build/watermarkPrimitives.d.ts +2 -1
- package/dist/display-list/build/watermarkPrimitives.js +9 -3
- package/dist/display-list/editor/pageRenderer.js +1 -0
- package/dist/docx/bookmarkIdNormalization.d.ts +10 -0
- package/dist/docx/bookmarkIdNormalization.js +100 -0
- package/dist/docx/bookmarkParser.js +4 -2
- package/dist/docx/importedIdCollisions.d.ts +136 -0
- package/dist/docx/importedIdCollisions.js +215 -0
- package/dist/docx/numberingParser.js +2 -2
- package/dist/docx/paragraphPropertySource.js +1 -2
- package/dist/docx/parseContext.d.ts +2 -1
- package/dist/docx/parseContext.js +1 -0
- package/dist/docx/parseWarningMessage.js +1 -0
- package/dist/docx/parser.js +5 -1
- package/dist/docx/relsParser.js +1 -1
- package/dist/docx/rezip.js +2 -1
- package/dist/docx/selectedXmlIdentityScan.d.ts +10 -0
- package/dist/docx/selectedXmlIdentityScan.js +36 -0
- package/dist/docx/selectiveSave.js +5 -4
- package/dist/docx/selectiveXmlPatch.js +44 -52
- package/dist/docx/serializer/commentSerializer.d.ts +3 -1
- package/dist/docx/serializer/commentSerializer.js +11 -2
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +1 -3
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -11
- package/dist/fonts/embeddedFontFingerprint.d.ts +5 -0
- package/dist/fonts/embeddedFontFingerprint.js +18 -0
- package/dist/fonts/embeddedFonts.d.ts +1 -1
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/headless-layout.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +2 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -1
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/paragraphConversion.js +8 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +25 -1
- package/dist/layout-engine/measure/cache.js +39 -7
- package/dist/layout-engine/measure/lineTypography.js +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +1 -0
- package/dist/layout-engine/measure/measureContainer.js +3 -4
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -9
- package/dist/layout-engine/measure/measureHelpers.js +21 -18
- package/dist/layout-engine/measure/measureParagraph.js +2 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -0
- package/dist/layout-engine/types.d.ts +4 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +11 -3
- package/dist/layout-painter/renderParagraph.js +13 -3
- package/dist/layout-painter/renderWatermark.d.ts +1 -0
- package/dist/layout-painter/renderWatermark.js +7 -3
- package/dist/managers/editorShortcuts.d.ts +2 -1
- package/dist/managers/editorShortcuts.js +2 -1
- package/dist/prosemirror/canonicalSelectionRange.d.ts +4 -1
- package/dist/prosemirror/canonicalSelectionRange.js +9 -3
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +39 -3
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +4 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +6 -5
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +11 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +1 -1
- package/dist/prosemirror/pluginKeyOwner.d.ts +13 -0
- package/dist/prosemirror/pluginKeyOwner.js +35 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiCitationDecorations.js +16 -3
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +18 -3
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +11 -11
- package/dist/prosemirror/plugins/anonymizationDecorations.js +23 -13
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +8 -2
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +27 -5
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +8 -2
- package/dist/prosemirror/plugins/contentControlWidgets.js +4 -3
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +6 -5
- package/dist/prosemirror/plugins/createDocScanPlugin.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +5 -3
- package/dist/prosemirror/plugins/documentStyleState.d.ts +8 -2
- package/dist/prosemirror/plugins/documentStyleState.js +2 -2
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +8 -2
- package/dist/prosemirror/plugins/selectionTracker.js +4 -3
- package/dist/prosemirror/plugins/suggestionMode.d.ts +8 -2
- package/dist/prosemirror/plugins/suggestionMode.js +4 -3
- package/dist/prosemirror/plugins/templateDirectives.d.ts +8 -2
- package/dist/prosemirror/plugins/templateDirectives.js +19 -4
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +8 -2
- package/dist/prosemirror/plugins/templatePreviewValues.js +27 -5
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +8 -2
- package/dist/prosemirror/plugins/templateSlashMenu.js +23 -5
- package/dist/prosemirror/plugins/transactionInvariants.js +23 -3
- package/dist/utils/fontLoader.d.ts +2 -2
- package/dist/utils/fontLoader.js +2 -7
- package/dist/utils/fontResolver.d.ts +7 -3
- package/dist/utils/fontResolver.js +6 -8
- package/package.json +24 -8
|
@@ -1,8 +1,32 @@
|
|
|
1
|
+
import { createPluginKeyOwner } from "../pluginKeyOwner.js";
|
|
1
2
|
import { scanDirectives } from "./templateDirectives.js";
|
|
2
|
-
import { Plugin
|
|
3
|
+
import { Plugin } from "prosemirror-state";
|
|
3
4
|
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
4
5
|
import { isFieldPath } from "@stll/template-conditions";
|
|
5
6
|
//#region src/prosemirror/plugins/templatePreviewValues.ts
|
|
7
|
+
/**
|
|
8
|
+
* Template Preview Values Plugin
|
|
9
|
+
*
|
|
10
|
+
* Live fill preview for template documents: given a map of field path →
|
|
11
|
+
* typed value, every matching `{{path}}` marker is visually replaced by
|
|
12
|
+
* the value — the marker text is hidden by an inline decoration and the
|
|
13
|
+
* value is injected as a widget in its place. The document itself is
|
|
14
|
+
* never modified; clearing the preview restores the markers.
|
|
15
|
+
*
|
|
16
|
+
* The same preview hides conditional blocks the host reports as not
|
|
17
|
+
* applying: `conditions` maps an `{% if expr %}` expression to whether
|
|
18
|
+
* its block applies, and a `false` block is hidden from its opener
|
|
19
|
+
* through its `{% endif %}`. folio evaluates no expression.
|
|
20
|
+
*
|
|
21
|
+
* Two render modes: `highlighted` paints the substituted values with the
|
|
22
|
+
* preview accent so it is unmistakably a preview, and keeps every
|
|
23
|
+
* directive tag visible; `plain` renders the values as ordinary text and
|
|
24
|
+
* drops the tag paragraphs of a block the host has ruled on, so it
|
|
25
|
+
* approximates the generated document rather than the template.
|
|
26
|
+
*
|
|
27
|
+
* Updates are pushed via {@link setTemplatePreviewValues}; the host wires
|
|
28
|
+
* this to its fill inputs.
|
|
29
|
+
*/
|
|
6
30
|
/** Concatenated plain text of a preview value. */
|
|
7
31
|
const templatePreviewValueText = (value) => typeof value === "string" ? value : value.runs.map((run) => run.text).join("");
|
|
8
32
|
/** Stable identity of a preview value (text + formatting), for decoration
|
|
@@ -26,9 +50,7 @@ const templatePreviewHidesWholeBlock = (range, block) => range.from <= block.pmS
|
|
|
26
50
|
const ORIGINAL_CLASS = "folio-template-preview-original";
|
|
27
51
|
/** Hides a conditional block the host reported as not applying. */
|
|
28
52
|
const HIDDEN_CLASS = "folio-template-preview-hidden";
|
|
29
|
-
const
|
|
30
|
-
const keyHolder = globalThis;
|
|
31
|
-
const templatePreviewValuesKey = keyHolder[KEY_HOLDER_SYMBOL] ?? (keyHolder[KEY_HOLDER_SYMBOL] = new PluginKey("templatePreviewValues"));
|
|
53
|
+
const templatePreviewValuesKey = createPluginKeyOwner("templatePreviewValues");
|
|
32
54
|
/** A rich span as DOM: text wrapped in `<em>` / `<strong>` per its flags. */
|
|
33
55
|
function buildSpanNode(span) {
|
|
34
56
|
let node = document.createTextNode(span.text);
|
|
@@ -267,7 +289,7 @@ function buildDecorationSet(doc, { entries, hidden }, mode) {
|
|
|
267
289
|
}
|
|
268
290
|
function createTemplatePreviewValuesPlugin() {
|
|
269
291
|
return new Plugin({
|
|
270
|
-
key: templatePreviewValuesKey,
|
|
292
|
+
key: templatePreviewValuesKey.createKey(),
|
|
271
293
|
state: {
|
|
272
294
|
init() {
|
|
273
295
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorState, Plugin,
|
|
1
|
+
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
2
2
|
//#region src/prosemirror/plugins/templateSlashMenu.d.ts
|
|
3
3
|
type TemplateSlashMenuState = {
|
|
4
4
|
active: false;
|
|
@@ -34,7 +34,13 @@ type TemplateSlashMenuPluginOptions = {
|
|
|
34
34
|
*/
|
|
35
35
|
onKeyAction?: (action: TemplateSlashMenuKeyAction) => boolean;
|
|
36
36
|
};
|
|
37
|
-
declare const templateSlashMenuKey:
|
|
37
|
+
declare const templateSlashMenuKey: Readonly<{
|
|
38
|
+
key: string;
|
|
39
|
+
createKey: () => import("prosemirror-state").PluginKey<TemplateSlashMenuState>;
|
|
40
|
+
owns: (plugin: Plugin<TemplateSlashMenuState>) => boolean;
|
|
41
|
+
get: (state: EditorState) => Plugin<TemplateSlashMenuState> | undefined;
|
|
42
|
+
getState: (state: EditorState) => TemplateSlashMenuState | undefined;
|
|
43
|
+
}>;
|
|
38
44
|
declare const templateSlashMenuPlugin: (options?: TemplateSlashMenuPluginOptions) => Plugin<TemplateSlashMenuState>;
|
|
39
45
|
declare const getTemplateSlashMenu: (state: EditorState) => TemplateSlashMenuState;
|
|
40
46
|
/** Clear the trigger. Set on the host's marker-insert transaction so the
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
import { createPluginKeyOwner } from "../pluginKeyOwner.js";
|
|
1
2
|
import { getTemplateDirectives } from "./templateDirectives.js";
|
|
2
|
-
import { Plugin
|
|
3
|
+
import { Plugin } from "prosemirror-state";
|
|
3
4
|
//#region src/prosemirror/plugins/templateSlashMenu.ts
|
|
5
|
+
/**
|
|
6
|
+
* Template slash-menu trigger plugin.
|
|
7
|
+
*
|
|
8
|
+
* Watches the template editor for a `/` typed at a marker boundary (start of a
|
|
9
|
+
* text block or right after whitespace) and tracks the query the author types
|
|
10
|
+
* after it. The plugin owns only the *trigger* state — `{active, from, query}` —
|
|
11
|
+
* and the keyboard contract while active; the floating menu UI and the actual
|
|
12
|
+
* marker insertion live in the host (template-studio), which subscribes via
|
|
13
|
+
* {@link TemplateSlashMenuPluginOptions.onChange} and resolves keys via
|
|
14
|
+
* {@link TemplateSlashMenuPluginOptions.onKeyAction}.
|
|
15
|
+
*
|
|
16
|
+
* The trigger guard is deliberately strict so the menu never misfires inside
|
|
17
|
+
* ordinary legal prose: dates (`30/06`), `and/or`, and URLs all have a non-space
|
|
18
|
+
* char before the `/`, so only a leading or post-whitespace `/` opens the menu.
|
|
19
|
+
*
|
|
20
|
+
* Insertion is host-driven: a doc-changing transaction the host dispatches to
|
|
21
|
+
* insert the marker carries a `clear` meta so the plugin tears down without the
|
|
22
|
+
* generic doc-change reset racing the host's selection move.
|
|
23
|
+
*/
|
|
4
24
|
const IDLE = {
|
|
5
25
|
active: false,
|
|
6
26
|
from: null,
|
|
@@ -8,9 +28,7 @@ const IDLE = {
|
|
|
8
28
|
query: ""
|
|
9
29
|
};
|
|
10
30
|
const QUERY_CHAR = /[\p{L}\p{N}_.-]/u;
|
|
11
|
-
const
|
|
12
|
-
const keyHolder = globalThis;
|
|
13
|
-
const templateSlashMenuKey = keyHolder[KEY_HOLDER_SYMBOL] ?? (keyHolder[KEY_HOLDER_SYMBOL] = new PluginKey("templateSlashMenu"));
|
|
31
|
+
const templateSlashMenuKey = createPluginKeyOwner("templateSlashMenu");
|
|
14
32
|
/** Whether the char immediately before `pos` is a marker boundary (start of the
|
|
15
33
|
* text block or whitespace). This is the misfire guard: a `/` mid-token (dates,
|
|
16
34
|
* URLs, and/or) has a word char before it and never opens the menu. */
|
|
@@ -78,7 +96,7 @@ const tryOpenTrigger = (view) => {
|
|
|
78
96
|
};
|
|
79
97
|
const templateSlashMenuPlugin = (options = {}) => {
|
|
80
98
|
return new Plugin({
|
|
81
|
-
key: templateSlashMenuKey,
|
|
99
|
+
key: templateSlashMenuKey.createKey(),
|
|
82
100
|
state: {
|
|
83
101
|
init: () => IDLE,
|
|
84
102
|
apply: (tr, value, _oldState, newState) => {
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { expectParagraphAttrs } from "../attrs/index.js";
|
|
2
2
|
import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary } from "../numberingAttr.js";
|
|
3
|
+
import { createPluginKeyOwner } from "../pluginKeyOwner.js";
|
|
3
4
|
import { validateProseMirrorDocument } from "../validation.js";
|
|
4
5
|
import { getDocumentNumbering, hasDocumentNumbering } from "./documentNumbering.js";
|
|
5
|
-
import { Plugin
|
|
6
|
+
import { Plugin } from "prosemirror-state";
|
|
6
7
|
//#region src/prosemirror/plugins/transactionInvariants.ts
|
|
8
|
+
/**
|
|
9
|
+
* Transaction invariants: a development and test aid that checks the editor
|
|
10
|
+
* document after every transaction, so a command that leaves a document the
|
|
11
|
+
* save path will refuse fails where it happens rather than at save.
|
|
12
|
+
*
|
|
13
|
+
* Off by default. {@link ExtensionManager} installs it when
|
|
14
|
+
* `globalThis.__folioTransactionInvariants` is `{ enabled: true }` at the time
|
|
15
|
+
* the runtime is initialized; the core test preload sets that flag, which turns
|
|
16
|
+
* every editor test built on the extension manager into a validity check. A
|
|
17
|
+
* host may set it in a development build. Production code never reads it
|
|
18
|
+
* otherwise.
|
|
19
|
+
*
|
|
20
|
+
* The checks are the ones the document-model validator makes that the editor
|
|
21
|
+
* state can answer on its own:
|
|
22
|
+
* - the ProseMirror document is structurally valid (node and mark attributes,
|
|
23
|
+
* bookmark pairing), incrementally cached per node;
|
|
24
|
+
* - every paragraph numbering reference names an instance the document's
|
|
25
|
+
* numbering defines.
|
|
26
|
+
*/
|
|
7
27
|
/** Whether new extension-manager runtimes install the invariant plugin. */
|
|
8
28
|
const areTransactionInvariantsEnabled = () => globalThis.__folioTransactionInvariants?.enabled === true;
|
|
9
29
|
const MAX_REPORTED_STEPS_LENGTH = 4e3;
|
|
@@ -69,14 +89,14 @@ const introducedIssues = (before, after, transactions) => {
|
|
|
69
89
|
return false;
|
|
70
90
|
});
|
|
71
91
|
};
|
|
72
|
-
const transactionInvariantsKey =
|
|
92
|
+
const transactionInvariantsKey = createPluginKeyOwner("transactionInvariants");
|
|
73
93
|
/**
|
|
74
94
|
* Throw a {@link TransactionInvariantError} naming the offending steps when a
|
|
75
95
|
* document-changing transaction leaves the state with an issue it did not
|
|
76
96
|
* have before.
|
|
77
97
|
*/
|
|
78
98
|
const createTransactionInvariantPlugin = () => new Plugin({
|
|
79
|
-
key: transactionInvariantsKey,
|
|
99
|
+
key: transactionInvariantsKey.createKey(),
|
|
80
100
|
appendTransaction(transactions, oldState, newState) {
|
|
81
101
|
if (!transactions.some((transaction) => transaction.docChanged)) return null;
|
|
82
102
|
const issues = checkEditorStateInvariants(newState);
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* Mapping from common Office/system fonts to bundled Croscore equivalents.
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
12
|
+
* The resolver supplies the visual fallback stack; this map is used for
|
|
13
|
+
* font availability checks and preloading.
|
|
14
14
|
*/
|
|
15
15
|
declare const FONT_MAPPING: Record<string, string>;
|
|
16
16
|
/**
|
package/dist/utils/fontLoader.js
CHANGED
|
@@ -13,8 +13,8 @@ const loadCallbacks = /* @__PURE__ */ new Set();
|
|
|
13
13
|
let isLoadingAny = false;
|
|
14
14
|
/**
|
|
15
15
|
* Mapping from common Office/system fonts to bundled Croscore equivalents.
|
|
16
|
-
* The
|
|
17
|
-
*
|
|
16
|
+
* The resolver supplies the visual fallback stack; this map is used for
|
|
17
|
+
* font availability checks and preloading.
|
|
18
18
|
*/
|
|
19
19
|
const FONT_MAPPING = {
|
|
20
20
|
Aptos: "Lato",
|
|
@@ -42,11 +42,6 @@ const BUNDLED_FONTS = /* @__PURE__ */ new Set([
|
|
|
42
42
|
"Cousine",
|
|
43
43
|
"Lato",
|
|
44
44
|
"Source Sans 3",
|
|
45
|
-
"Calibri",
|
|
46
|
-
"Cambria",
|
|
47
|
-
"Arial",
|
|
48
|
-
"Times New Roman",
|
|
49
|
-
"Courier New",
|
|
50
45
|
"Noto Sans Arabic"
|
|
51
46
|
]);
|
|
52
47
|
/**
|
|
@@ -46,8 +46,12 @@ declare function isCjkFont(family: string): boolean;
|
|
|
46
46
|
declare const CJK_FALLBACK_FONT_FAMILY = "MS Mincho";
|
|
47
47
|
declare const setGoogleFontsEnabled: (enabled: boolean) => void;
|
|
48
48
|
declare const getGoogleFontsEnabled: () => boolean;
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
type FontResolutionOptions = {
|
|
50
|
+
alternateFontName?: string | undefined;
|
|
51
|
+
embeddedFontFamilyMap?: ReadonlyMap<string, string> | undefined;
|
|
52
|
+
};
|
|
53
|
+
/** Resolve against the calling editor's immutable embedded-font lookup. */
|
|
54
|
+
declare function resolveFontFamily(docxFontName: string, options?: FontResolutionOptions): ResolvedFont;
|
|
51
55
|
/**
|
|
52
56
|
* Split a CSS `font-family` list built by `quoteFontName` back into family
|
|
53
57
|
* names: the inverse of the quoting and escaping applied there. Quoted entries
|
|
@@ -93,4 +97,4 @@ declare function getGoogleFontEquivalent(docxFontName: string): string | null;
|
|
|
93
97
|
*/
|
|
94
98
|
declare function hasGoogleFontEquivalent(docxFontName: string): boolean;
|
|
95
99
|
//#endregion
|
|
96
|
-
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, ResolvedFont, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsEnabled, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, parseFontFamilyList, resolveFontFamily, resolveThemeFont,
|
|
100
|
+
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, ResolvedFont, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsEnabled, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, parseFontFamilyList, resolveFontFamily, resolveThemeFont, setGoogleFontsEnabled };
|
|
@@ -1043,11 +1043,9 @@ const setGoogleFontsEnabled = (enabled) => {
|
|
|
1043
1043
|
googleFontsEnabled = enabled;
|
|
1044
1044
|
};
|
|
1045
1045
|
const getGoogleFontsEnabled = () => googleFontsEnabled;
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
embeddedFontFamilyMap =
|
|
1049
|
-
};
|
|
1050
|
-
function resolveFontFamily(docxFontName, alternateFontName) {
|
|
1046
|
+
/** Resolve against the calling editor's immutable embedded-font lookup. */
|
|
1047
|
+
function resolveFontFamily(docxFontName, options = {}) {
|
|
1048
|
+
const { alternateFontName, embeddedFontFamilyMap } = options;
|
|
1051
1049
|
const normalizedName = docxFontName.trim().toLowerCase();
|
|
1052
1050
|
const scopedFamily = embeddedFontFamilyMap?.get(docxFontName) ?? null;
|
|
1053
1051
|
const aliasTarget = CJK_FONT_ALIASES[normalizedName];
|
|
@@ -1062,7 +1060,7 @@ function resolveFontFamily(docxFontName, alternateFontName) {
|
|
|
1062
1060
|
hasGoogleEquivalent: googleFontsEnabled,
|
|
1063
1061
|
singleLineRatio: mapping.singleLineRatio
|
|
1064
1062
|
};
|
|
1065
|
-
const alternate = resolveFontFamily(alternateFontName);
|
|
1063
|
+
const alternate = resolveFontFamily(alternateFontName, { embeddedFontFamilyMap });
|
|
1066
1064
|
const category = mapping.category;
|
|
1067
1065
|
const concreteStack = dedupeFontFamilies([
|
|
1068
1066
|
scopedFamily ?? docxFontName,
|
|
@@ -1080,7 +1078,7 @@ function resolveFontFamily(docxFontName, alternateFontName) {
|
|
|
1080
1078
|
}
|
|
1081
1079
|
const alternateName = alternateFontName?.trim();
|
|
1082
1080
|
if (alternateName && alternateName.toLowerCase() !== normalizedName) {
|
|
1083
|
-
const alternate = resolveFontFamily(alternateName);
|
|
1081
|
+
const alternate = resolveFontFamily(alternateName, { embeddedFontFamilyMap });
|
|
1084
1082
|
const category = detectFontCategory(docxFontName);
|
|
1085
1083
|
const concreteStack = dedupeFontFamilies([scopedFamily ?? docxFontName, ...parseFontFamilyList(alternate.cssFallback)]).filter((family) => !isCssGenericFontFamily(family));
|
|
1086
1084
|
return {
|
|
@@ -1258,4 +1256,4 @@ function hasGoogleFontEquivalent(docxFontName) {
|
|
|
1258
1256
|
return (CJK_FONT_ALIASES[normalizedName] ?? normalizedName) in FONT_MAPPINGS;
|
|
1259
1257
|
}
|
|
1260
1258
|
//#endregion
|
|
1261
|
-
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsEnabled, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, parseFontFamilyList, resolveFontFamily, resolveThemeFont,
|
|
1259
|
+
export { CJK_FALLBACK_FONT_FAMILY, DEFAULT_SINGLE_LINE_RATIO, buildFontFamilyString, getGoogleFontEquivalent, getGoogleFontsEnabled, getGoogleFontsToLoad, hasGoogleFontEquivalent, isCjkFont, parseFontFamilyList, 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.60.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",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"perf": "bun scripts/profile-editor.ts"
|
|
147
147
|
},
|
|
148
148
|
"dependencies": {
|
|
149
|
-
"@stll/docx-core": "^0.
|
|
149
|
+
"@stll/docx-core": "^0.37.0",
|
|
150
150
|
"@stll/docx-utils": "^0.1.0",
|
|
151
151
|
"@stll/template-conditions": "^0.6.2",
|
|
152
152
|
"better-result": "3.0.1",
|
|
@@ -155,6 +155,13 @@
|
|
|
155
155
|
"fast-xml-parser": "^5.10.1",
|
|
156
156
|
"hyphen": "1.14.1",
|
|
157
157
|
"jszip": "3.10.2",
|
|
158
|
+
"utif2": "^4.1.0",
|
|
159
|
+
"valibot": "1.5.0"
|
|
160
|
+
},
|
|
161
|
+
"devDependencies": {
|
|
162
|
+
"@fontsource/noto-sans-devanagari": "^5.3.0",
|
|
163
|
+
"@fontsource/noto-sans-hebrew": "^5.3.0",
|
|
164
|
+
"@types/hyphen": "1.14.0",
|
|
158
165
|
"prosemirror-commands": "^1.7.1",
|
|
159
166
|
"prosemirror-dropcursor": "^1.8.2",
|
|
160
167
|
"prosemirror-gapcursor": "^1.4.1",
|
|
@@ -166,16 +173,25 @@
|
|
|
166
173
|
"prosemirror-tables": "^1.8.5",
|
|
167
174
|
"prosemirror-transform": "^1.12.0",
|
|
168
175
|
"prosemirror-view": "^1.42.6",
|
|
169
|
-
"utif2": "^4.1.0",
|
|
170
|
-
"valibot": "1.5.0",
|
|
171
176
|
"y-prosemirror": "^1.3.7",
|
|
172
177
|
"y-protocols": "^1.0.6",
|
|
173
178
|
"yjs": "^13.6.31"
|
|
174
179
|
},
|
|
175
|
-
"
|
|
176
|
-
"
|
|
177
|
-
"
|
|
178
|
-
"
|
|
180
|
+
"peerDependencies": {
|
|
181
|
+
"prosemirror-commands": "^1.7.1",
|
|
182
|
+
"prosemirror-dropcursor": "^1.8.2",
|
|
183
|
+
"prosemirror-gapcursor": "^1.4.1",
|
|
184
|
+
"prosemirror-history": "^1.5.0",
|
|
185
|
+
"prosemirror-inputrules": "^1.5.0",
|
|
186
|
+
"prosemirror-keymap": "^1.2.3",
|
|
187
|
+
"prosemirror-model": "^1.25.9",
|
|
188
|
+
"prosemirror-state": "^1.4.4",
|
|
189
|
+
"prosemirror-tables": "^1.8.5",
|
|
190
|
+
"prosemirror-transform": "^1.12.0",
|
|
191
|
+
"prosemirror-view": "^1.42.6",
|
|
192
|
+
"y-prosemirror": "^1.3.7",
|
|
193
|
+
"y-protocols": "^1.0.6",
|
|
194
|
+
"yjs": "^13.6.31"
|
|
179
195
|
},
|
|
180
196
|
"main": "./dist/index.js",
|
|
181
197
|
"types": "./dist/index.d.ts"
|