@superdoc-dev/fonts 0.2.0 → 0.3.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/LICENSE +661 -0
- package/README.md +19 -82
- package/assets/LICENSES.md +21 -1
- package/assets/OFL.txt +11 -3
- package/dist/cdn-entry.d.ts +1 -1
- package/dist/cdn-entry.js +7 -7
- package/dist/curation.d.ts +1 -0
- package/dist/curation.js +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/superdoc-fonts.min.js +1 -1
- package/dist/superdoc-fonts.min.js.map +1 -1
- package/package.json +16 -6
- package/src/cdn-entry.test.ts +3 -3
- package/src/cdn-entry.ts +7 -7
- package/src/curation.ts +5 -4
- package/src/index.test.ts +1 -1
- package/src/index.ts +6 -6
package/src/curation.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface SuperDocFontsOptions {
|
|
|
53
53
|
export interface SuperDocFontsConfig {
|
|
54
54
|
resolveAssetUrl: BundledFontAssetResolver;
|
|
55
55
|
bundled?: { include?: string[]; exclude?: string[] };
|
|
56
|
+
[key: string]: unknown;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -69,7 +70,7 @@ export function resolveCuration(options: SuperDocFontsOptions = {}): {
|
|
|
69
70
|
// clearly) rather than picking one arbitrarily.
|
|
70
71
|
if (include && exclude) {
|
|
71
72
|
throw new Error(
|
|
72
|
-
'[@superdoc
|
|
73
|
+
'[@superdoc/fonts] createSuperDocFonts: pass `include` OR `exclude`, not both. ' +
|
|
73
74
|
'`include` is an allow-list (only those families resolve and appear in the toolbar); ' +
|
|
74
75
|
'`exclude` keeps everything but the named families.',
|
|
75
76
|
);
|
|
@@ -88,12 +89,12 @@ export function resolveCuration(options: SuperDocFontsOptions = {}): {
|
|
|
88
89
|
function normalizeNameList(value: readonly string[] | undefined, field: 'include' | 'exclude'): string[] | undefined {
|
|
89
90
|
if (value == null) return undefined;
|
|
90
91
|
if (!Array.isArray(value)) {
|
|
91
|
-
throw new Error(`[@superdoc
|
|
92
|
+
throw new Error(`[@superdoc/fonts] createSuperDocFonts: \`${field}\` must be an array of Word font names.`);
|
|
92
93
|
}
|
|
93
94
|
const names = value.map((name) => (typeof name === 'string' ? name.trim() : '')).filter(Boolean);
|
|
94
95
|
if (names.length !== value.length) {
|
|
95
96
|
throw new Error(
|
|
96
|
-
`[@superdoc
|
|
97
|
+
`[@superdoc/fonts] createSuperDocFonts: \`${field}\` must contain only non-empty font name strings ` +
|
|
97
98
|
`(e.g. ["Calibri", "Cambria"]).`,
|
|
98
99
|
);
|
|
99
100
|
}
|
|
@@ -151,7 +152,7 @@ function assertKnownFamilies(names: readonly string[], field: 'include' | 'exclu
|
|
|
151
152
|
return suggestion ? `"${name}" (did you mean "${suggestion}"?)` : `"${name}"`;
|
|
152
153
|
});
|
|
153
154
|
throw new Error(
|
|
154
|
-
`[@superdoc
|
|
155
|
+
`[@superdoc/fonts] createSuperDocFonts: \`${field}\` names a font SuperDoc does not bundle: ${hints.join(', ')}. ` +
|
|
155
156
|
`Curate by Word family name. Bundled families: ${BUNDLED_FAMILY_NAMES.join(', ')}.`,
|
|
156
157
|
);
|
|
157
158
|
}
|
package/src/index.test.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@superdoc
|
|
2
|
+
* `@superdoc/fonts` - the reviewed metric-compatible font substitutes SuperDoc renders for
|
|
3
3
|
* proprietary Word fonts (Carlito for Calibri, Liberation Serif for Times New Roman, etc.).
|
|
4
4
|
*
|
|
5
5
|
* Optional: install it to make the bundled fallbacks load automatically in any bundler app, with
|
|
@@ -45,10 +45,10 @@ export type { BundledFontFamilyName } from './bundled-families.js';
|
|
|
45
45
|
* Pass as SuperDoc's `fonts.resolveAssetUrl` so the reviewed fallback pack loads from THIS
|
|
46
46
|
* package's emitted assets, with no manual copy step and no `assetBaseUrl`:
|
|
47
47
|
*
|
|
48
|
-
* import { resolveBundledFontAssetUrl } from '@superdoc
|
|
48
|
+
* import { resolveBundledFontAssetUrl } from '@superdoc/fonts';
|
|
49
49
|
* new SuperDoc({ selector: '#editor', document, fonts: { resolveAssetUrl: resolveBundledFontAssetUrl } });
|
|
50
50
|
*
|
|
51
|
-
* Throws on an unknown file, which signals a version mismatch between `@superdoc
|
|
51
|
+
* Throws on an unknown file, which signals a version mismatch between `@superdoc/fonts` and
|
|
52
52
|
* the `superdoc` core manifest rather than silently degrading to the logical font name.
|
|
53
53
|
*
|
|
54
54
|
* @beta
|
|
@@ -57,9 +57,9 @@ export function resolveBundledFontAssetUrl(context: BundledFontAssetContext): st
|
|
|
57
57
|
const url = BUNDLED_FONT_ASSET_URLS[context.file];
|
|
58
58
|
if (!url) {
|
|
59
59
|
throw new Error(
|
|
60
|
-
`[@superdoc
|
|
60
|
+
`[@superdoc/fonts] no bundled asset for "${context.file}". This pack ships ` +
|
|
61
61
|
`${Object.keys(BUNDLED_FONT_ASSET_URLS).length} faces; the file is unknown, so ` +
|
|
62
|
-
`@superdoc
|
|
62
|
+
`@superdoc/fonts and superdoc are likely version-mismatched. Align their versions.`,
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
return url;
|
|
@@ -78,7 +78,7 @@ export const superdocFonts: SuperDocFontsConfig = {
|
|
|
78
78
|
/**
|
|
79
79
|
* Build a curated `fonts` config: the bundled pack, narrowed to the families you choose.
|
|
80
80
|
*
|
|
81
|
-
* import { createSuperDocFonts } from '@superdoc
|
|
81
|
+
* import { createSuperDocFonts } from '@superdoc/fonts';
|
|
82
82
|
* new SuperDoc({
|
|
83
83
|
* selector: '#editor',
|
|
84
84
|
* document,
|