ooxml-ui 1.45.0 → 1.47.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.
Files changed (89) hide show
  1. package/README.md +1 -1
  2. package/dist/chart/format-pane-effects.d.ts +0 -1
  3. package/dist/chart/format-pane-fill-kinds.d.ts +0 -1
  4. package/dist/chart/format-pane-space.d.ts +0 -1
  5. package/dist/chart/format-pane-targets.d.ts +0 -1
  6. package/dist/chunk-G5CALQUW.js +278 -0
  7. package/dist/{chunk-LPI7LT4B.js → chunk-J3ROBM74.js} +1 -1
  8. package/dist/docx/backstage-options.d.ts +4 -0
  9. package/dist/docx/backstage-trust.d.ts +11 -0
  10. package/dist/docx/docx-webfonts.d.ts +75 -0
  11. package/dist/docx/editor-core.d.ts +3 -0
  12. package/dist/docx/element-api.d.ts +14 -0
  13. package/dist/docx/font-downloads.d.ts +8 -0
  14. package/dist/docx/locales/en.d.ts +6 -0
  15. package/dist/docx/locales/options.d.ts +6 -0
  16. package/dist/docx/locales/trust.d.ts +15 -0
  17. package/dist/docx/localization-strings.d.ts +6 -0
  18. package/dist/docx/print-layout-view.d.ts +2 -0
  19. package/dist/docx.js +229 -14
  20. package/dist/fonts/font-download-policy.d.ts +23 -0
  21. package/dist/fonts/webfonts.d.ts +118 -0
  22. package/dist/fonts/webfonts.d.ts.map +1 -0
  23. package/dist/form/color-swatches.d.ts +0 -1
  24. package/dist/index.js +2 -2
  25. package/dist/picture-artistic-filters.d.ts +0 -1
  26. package/dist/pptx/{chunk-CWBVJ4DC.cjs → chunk-6XIUBQPL.cjs} +403 -2398
  27. package/dist/pptx/{chunk-HGT3CA36.mjs → chunk-BV24XNBQ.mjs} +301 -2351
  28. package/dist/pptx/{chunk-MZCAYJ7H.cjs → chunk-JHI42PNB.cjs} +42 -42
  29. package/dist/pptx/{chunk-6JTQ7AG6.mjs → chunk-XMAQ23WE.mjs} +1 -1
  30. package/dist/pptx/dom/index.cjs +372 -371
  31. package/dist/pptx/dom/index.mjs +6 -5
  32. package/dist/pptx/dom/load-presentation.d.ts +8 -1
  33. package/dist/pptx/dom/load-presentation.d.ts.map +1 -1
  34. package/dist/pptx/index.cjs +3086 -3058
  35. package/dist/pptx/index.mjs +1 -1
  36. package/dist/pptx/render/deck-webfont-readiness.d.ts +24 -10
  37. package/dist/pptx/render/deck-webfont-readiness.d.ts.map +1 -1
  38. package/dist/pptx/render/font-weight-names.d.ts +2 -65
  39. package/dist/pptx/render/font-weight-names.d.ts.map +1 -1
  40. package/dist/pptx/render/google-fonts-catalogue.d.ts +2 -13
  41. package/dist/pptx/render/google-fonts-catalogue.d.ts.map +1 -1
  42. package/dist/pptx/render/google-fonts-lookup.d.ts +2 -6
  43. package/dist/pptx/render/google-fonts-lookup.d.ts.map +1 -1
  44. package/dist/pptx/render/google-webfonts-link.d.ts +2 -2
  45. package/dist/pptx/render/google-webfonts-link.d.ts.map +1 -1
  46. package/dist/pptx/render/google-webfonts-metric-clones.d.ts +2 -16
  47. package/dist/pptx/render/google-webfonts-metric-clones.d.ts.map +1 -1
  48. package/dist/pptx/render/google-webfonts.d.ts +11 -107
  49. package/dist/pptx/render/google-webfonts.d.ts.map +1 -1
  50. package/dist/pptx/render/index.d.ts +3 -0
  51. package/dist/pptx/render/index.d.ts.map +1 -1
  52. package/dist/pptx/render/inline-list-dom.d.ts.map +1 -1
  53. package/dist/pptx/render/inline-text-paragraph-marker.d.ts +3 -0
  54. package/dist/pptx/render/inline-text-paragraph-marker.d.ts.map +1 -0
  55. package/dist/pptx/render/inline-text-seed.d.ts +25 -0
  56. package/dist/pptx/render/inline-text-seed.d.ts.map +1 -0
  57. package/dist/pptx/render/inline-trailing-space.d.ts +14 -0
  58. package/dist/pptx/render/inline-trailing-space.d.ts.map +1 -0
  59. package/dist/pptx/render/status-bar-state.d.ts +10 -0
  60. package/dist/pptx/render/status-bar-state.d.ts.map +1 -1
  61. package/dist/pptx/{smartart-insert-preview-R7USUBIX.cjs → smartart-insert-preview-GE47FXVT.cjs} +3 -3
  62. package/dist/pptx/{smartart-insert-preview-ZKVFXFSI.mjs → smartart-insert-preview-WY6DHSAJ.mjs} +2 -2
  63. package/dist/pptx/web-components/status-bar.d.ts.map +1 -1
  64. package/dist/teams.js +1 -1
  65. package/dist/theme-bridge.d.ts +0 -1
  66. package/dist/visio/controller.d.ts +12 -0
  67. package/dist/visio/font-stack.d.ts +11 -0
  68. package/dist/visio/locales/trust-center.d.ts +7 -0
  69. package/dist/visio/viewer-behaviour.d.ts +5 -0
  70. package/dist/visio/viewer-element.d.ts +16 -0
  71. package/dist/visio/viewer-options-categories.d.ts +6 -0
  72. package/dist/visio/viewer-options-trust.d.ts +10 -0
  73. package/dist/visio/viewer-options.d.ts +6 -0
  74. package/dist/visio/viewer-webfonts.d.ts +42 -0
  75. package/dist/visio.js +323 -21
  76. package/dist/xlsx/backstage/options-trust.d.ts +9 -0
  77. package/dist/xlsx/backstage/parts.d.ts +4 -0
  78. package/dist/xlsx/editor-core.d.ts +3 -0
  79. package/dist/xlsx/element-api.d.ts +15 -0
  80. package/dist/xlsx/font-downloads.d.ts +8 -0
  81. package/dist/xlsx/grid/drawings.d.ts +2 -0
  82. package/dist/xlsx/grid/measure.d.ts +2 -0
  83. package/dist/xlsx/page-views/page-layout-css.d.ts +1 -1
  84. package/dist/xlsx/print-cell.d.ts +1 -1
  85. package/dist/xlsx/webfonts.d.ts +70 -0
  86. package/dist/xlsx.js +259 -18
  87. package/package.json +2 -2
  88. package/dist/chunk-MWDG776V.js +0 -90
  89. /package/dist/{chunk-2YRHRV4H.js → chunk-MUY444GW.js} +0 -0
package/README.md CHANGED
@@ -483,7 +483,7 @@ content and native media controls without editing overlays.
483
483
 
484
484
  ## Privacy and network use
485
485
 
486
- The elements render and edit locally. The PowerPoint elements (`ooxml-ui/pptx`) download fonts that are neither installed nor embedded from Google Fonts by default, fetch linked pictures and media while "Allow external content" is on, and use public signaling and STUN servers for serverless Share; each has an option to turn it off (`googleFonts`, `allowExternalContent`, `signaling`), described in [font loading](https://github.com/ChristopherVR/ooxml/blob/main/docs/font-loading.md). The Word, Excel and Visio elements make no network request, and Teams talks only to the servers you configure (plus Google's public STUN server for calls unless `iceServers` is set). Nothing collects analytics or telemetry. See [PRIVACY.md](https://github.com/ChristopherVR/ooxml/blob/main/PRIVACY.md).
486
+ The elements render and edit locally. The PowerPoint elements (`ooxml-ui/pptx`) download fonts that are neither installed nor embedded from Google Fonts by default, fetch linked pictures and media while "Allow external content" is on, and use public signaling and STUN servers for serverless Share; each has an option to turn it off (`googleFonts`, `allowExternalContent`, `signaling`), described in [font loading](https://github.com/ChristopherVR/ooxml/blob/main/docs/font-loading.md). The Word, Excel and Visio elements make no network request unless the host sets their `googleFonts` property or the reader turns on File > Options > Trust Center > "Download fonts that are not installed or embedded" (off by default; the same font requests as PowerPoint), and Teams talks only to the servers you configure (plus Google's public STUN server for calls unless `iceServers` is set). Nothing collects analytics or telemetry. See [PRIVACY.md](https://github.com/ChristopherVR/ooxml/blob/main/PRIVACY.md).
487
487
 
488
488
  ## License
489
489
 
@@ -22,4 +22,3 @@ export declare function glowSection(prefix: string, glow: Effects['glow']): Char
22
22
  /** The Effects tab's sections. */
23
23
  export declare function effectsSections(view: ChartFormatElementView): ChartFormatSection[];
24
24
  export {};
25
- //# sourceMappingURL=format-pane-effects.d.ts.map
@@ -13,4 +13,3 @@ export declare function gradientFields(prefix: string, gradient: ChartGradientFi
13
13
  export declare function patternFields(pattern: NonNullable<ChartFormatFillView['pattern']>, presets: readonly ChartFormatChoice[]): ChartFormatField[];
14
14
  /** Picture source, transparency and tiling of a picture fill. */
15
15
  export declare function pictureFields(picture: ChartFormatFillView['picture']): ChartFormatField[];
16
- //# sourceMappingURL=format-pane-fill-kinds.d.ts.map
@@ -19,4 +19,3 @@ export interface ChartSpaceFormatSourceOptions {
19
19
  }
20
20
  /** The Format pane source of `space`. */
21
21
  export declare function chartSpaceFormatSource(space: ChartSpace, options?: ChartSpaceFormatSourceOptions): ChartFormatSource;
22
- //# sourceMappingURL=format-pane-space.d.ts.map
@@ -22,4 +22,3 @@ export declare function chartFormatPaneTitle(target: ChartFormatTarget): ChartFo
22
22
  export declare function chartFormatTargetOptions(targets: readonly ChartFormatTarget[], describe: ChartFormatDescribe): ChartFormatTargetOption[];
23
23
  /** The chart area entry, what a stale or missing key falls back to. */
24
24
  export declare const CHART_AREA_TARGET: ChartFormatTargetOption;
25
- //# sourceMappingURL=format-pane-targets.d.ts.map
@@ -0,0 +1,278 @@
1
+ import { defineShareDialog, chartSpaceFormatSource, shareDialogLabels } from './chunk-UEFVC6V4.js';
2
+ import { GOOGLE_FONTS_CSS2_BASE, resolveGoogleFontsCss2Base, collectRunFamilies, collectWebfontFaces, selectGoogleWebfontFamilies, buildGoogleFontsHref, matchGoogleWebfontFragments } from 'ooxml-core/text';
3
+ import { readDeclaredFonts } from 'ooxml-core/opc';
4
+ import { chartExStyleSpace } from 'ooxml-core/chart';
5
+
6
+ var FONT_DOWNLOADS_DEFAULT = false;
7
+ function effectiveFontDownloads(host, readerAllows) {
8
+ if (host !== void 0) return host;
9
+ return readerAllows ? { baseUrl: GOOGLE_FONTS_CSS2_BASE } : false;
10
+ }
11
+ function fontDownloadLock(host) {
12
+ return host === void 0 ? void 0 : resolveGoogleFontsCss2Base(host, null, "ooxml") !== null;
13
+ }
14
+ var WEBFONT_TIMEOUT_MS = 150;
15
+ var WEBFONT_PROGRESS_DELAY_MS = 400;
16
+ var INSTALLED_FONT_TEST_STRING = "mmmmmmmmmmllww";
17
+ function isFontFamilyInstalledLocally(family) {
18
+ if (typeof document === "undefined") return false;
19
+ try {
20
+ const context = document.createElement("canvas").getContext("2d");
21
+ if (!context) return false;
22
+ const quoted = `"${family.replace(/[\\"]/gu, "\\$&")}"`;
23
+ for (const fallback of ["monospace", "serif", "sans-serif"]) {
24
+ context.font = `72px ${fallback}`;
25
+ const base = context.measureText(INSTALLED_FONT_TEST_STRING).width;
26
+ context.font = `72px ${quoted}, ${fallback}`;
27
+ if (context.measureText(INSTALLED_FONT_TEST_STRING).width !== base) return true;
28
+ }
29
+ return false;
30
+ } catch {
31
+ return false;
32
+ }
33
+ }
34
+ var prefetchLinkId = (linkId) => `${linkId}-prefetch`;
35
+ function syncGoogleWebfontStylesheet(doc, id, href) {
36
+ const existing = doc.getElementById(id);
37
+ if (!href) {
38
+ existing?.remove();
39
+ const early = id.endsWith("-prefetch") ? null : doc.getElementById(prefetchLinkId(id));
40
+ if (early && !early.dataset["pending"]) early.remove();
41
+ return null;
42
+ }
43
+ if (existing?.getAttribute("href") === href) return existing;
44
+ const link = existing ?? doc.createElement("link");
45
+ link.id = id;
46
+ link.rel = "stylesheet";
47
+ link.href = href;
48
+ if (!existing) doc.head.appendChild(link);
49
+ return link;
50
+ }
51
+ var resolvedFamilies = /* @__PURE__ */ new Set();
52
+ function selectWebfontCandidates(families, embedded = [], isLocallyInstalled = isFontFamilyInstalledLocally) {
53
+ return selectGoogleWebfontFamilies(
54
+ families,
55
+ embedded,
56
+ (family) => !resolvedFamilies.has(family) && isLocallyInstalled(family)
57
+ );
58
+ }
59
+ function matchWebfontFragments(candidates) {
60
+ return matchGoogleWebfontFragments(candidates, (family) => resolvedFamilies.add(family));
61
+ }
62
+ function webfontHref(candidates, base) {
63
+ if (base === null) return null;
64
+ return buildGoogleFontsHref(matchWebfontFragments(candidates), base);
65
+ }
66
+ function prefetchWebfonts(options) {
67
+ const { document: doc, linkId, bytes, base } = options;
68
+ const id = prefetchLinkId(linkId);
69
+ try {
70
+ if (base === null) {
71
+ doc.getElementById(id)?.remove();
72
+ return null;
73
+ }
74
+ const declared = readDeclaredFonts(bytes);
75
+ const candidates = selectWebfontCandidates(
76
+ declared.families,
77
+ declared.embedded,
78
+ options.isLocallyInstalled ?? isFontFamilyInstalledLocally
79
+ );
80
+ const href = webfontHref(candidates, base);
81
+ const link = syncGoogleWebfontStylesheet(doc, id, href);
82
+ if (link) link.dataset["pending"] = "1";
83
+ return href;
84
+ } catch {
85
+ return null;
86
+ }
87
+ }
88
+ function settlePrefetchedWebfonts(doc, linkId, base) {
89
+ const early = doc.getElementById(prefetchLinkId(linkId));
90
+ if (!early) return;
91
+ if (base === null) early.remove();
92
+ else delete early.dataset["pending"];
93
+ }
94
+ function stylesheetSettled(link) {
95
+ if (link.sheet) return Promise.resolve();
96
+ return new Promise((resolve) => {
97
+ link.addEventListener("load", () => resolve(), { once: true });
98
+ link.addEventListener("error", () => resolve(), { once: true });
99
+ });
100
+ }
101
+ async function loadFace(fonts, face) {
102
+ try {
103
+ await fonts.load(face.font, face.chars.size > 0 ? [...face.chars].join("") : "x");
104
+ } catch {
105
+ }
106
+ }
107
+ async function prepareWebfonts(options) {
108
+ const {
109
+ document: doc,
110
+ linkId,
111
+ runs,
112
+ embedded,
113
+ base,
114
+ onProgress,
115
+ timeoutMs = WEBFONT_TIMEOUT_MS,
116
+ progressDelayMs = WEBFONT_PROGRESS_DELAY_MS,
117
+ isLocallyInstalled = isFontFamilyInstalledLocally
118
+ } = options;
119
+ settlePrefetchedWebfonts(doc, linkId, base);
120
+ if (base === null) return { href: null, families: [], unavailable: [], timedOut: false };
121
+ const candidates = selectWebfontCandidates(
122
+ collectRunFamilies(runs),
123
+ embedded,
124
+ isLocallyInstalled
125
+ );
126
+ const { faces, unavailable } = collectWebfontFaces(runs, candidates);
127
+ const href = webfontHref(candidates, base);
128
+ const families = [...faces.keys()];
129
+ const link = syncGoogleWebfontStylesheet(doc, linkId, href);
130
+ const fontSet = doc.fonts;
131
+ if (!link || families.length === 0 || !fontSet || typeof fontSet.load !== "function") {
132
+ return { href, families, unavailable, timedOut: false };
133
+ }
134
+ return waitForFaces(link, fontSet, faces, families, {
135
+ href,
136
+ unavailable,
137
+ timeoutMs,
138
+ progressDelayMs,
139
+ ...onProgress ? { onProgress } : {}
140
+ });
141
+ }
142
+ async function waitForFaces(link, fontSet, faces, families, context) {
143
+ const { href, unavailable, timeoutMs, progressDelayMs, onProgress, followMs, onProgressEnd } = context;
144
+ let loaded = 0;
145
+ let reporting = false;
146
+ let over = false;
147
+ const timers = [];
148
+ const report = () => {
149
+ if (reporting && !over) onProgress?.({ loaded, total: families.length, families });
150
+ };
151
+ const end = () => {
152
+ if (over) return;
153
+ over = true;
154
+ for (const timer of timers) clearTimeout(timer);
155
+ if (reporting) {
156
+ reporting = false;
157
+ onProgressEnd?.();
158
+ }
159
+ };
160
+ const download = (async () => {
161
+ await stylesheetSettled(link);
162
+ await Promise.all(
163
+ [...faces.values()].map(async (familyFaces) => {
164
+ await Promise.all(familyFaces.map((face) => loadFace(fontSet, face)));
165
+ loaded += 1;
166
+ report();
167
+ })
168
+ );
169
+ })();
170
+ timers.push(
171
+ setTimeout(() => {
172
+ reporting = true;
173
+ report();
174
+ }, progressDelayMs)
175
+ );
176
+ if (followMs !== void 0) {
177
+ timers.push(setTimeout(end, followMs));
178
+ void download.then(end);
179
+ }
180
+ let waitTimer;
181
+ const timedOut = await Promise.race([
182
+ download.then(() => false),
183
+ new Promise((resolve) => {
184
+ waitTimer = setTimeout(() => resolve(true), timeoutMs);
185
+ })
186
+ ]);
187
+ clearTimeout(waitTimer);
188
+ if (followMs === void 0 || !timedOut) end();
189
+ return { href, families, unavailable, timedOut };
190
+ }
191
+
192
+ // src/dialog/share-controller.ts
193
+ var message = (cause) => cause instanceof Error ? cause.message : String(cause);
194
+ function attachShareDialog(setup) {
195
+ const doc = setup.container.ownerDocument ?? setup.container;
196
+ defineShareDialog(doc.defaultView?.customElements);
197
+ const element = doc.createElement("office-ui-share-dialog");
198
+ element.roomPrefix = setup.roomPrefix;
199
+ const relocalize = () => {
200
+ const locale = setup.locale?.();
201
+ const labels = shareDialogLabels(locale);
202
+ element.labels = labels;
203
+ element.note = setup.note?.(locale) ?? "";
204
+ };
205
+ const refresh = () => {
206
+ element.state = setup.host.state();
207
+ };
208
+ element.addEventListener("office-share-start", (event) => {
209
+ const { options } = event.detail;
210
+ element.error = "";
211
+ try {
212
+ Promise.resolve(setup.host.start(options)).then(refresh).catch((cause) => {
213
+ element.error = message(cause);
214
+ refresh();
215
+ });
216
+ } catch (cause) {
217
+ element.error = message(cause);
218
+ }
219
+ refresh();
220
+ });
221
+ element.addEventListener("office-share-stop", () => {
222
+ element.error = "";
223
+ try {
224
+ setup.host.stop();
225
+ } catch (cause) {
226
+ element.error = message(cause);
227
+ }
228
+ refresh();
229
+ });
230
+ setup.container.append(element);
231
+ relocalize();
232
+ refresh();
233
+ return {
234
+ element,
235
+ open(invitation = "") {
236
+ relocalize();
237
+ refresh();
238
+ element.defaults = setup.defaults?.() ?? {};
239
+ element.invitation = invitation;
240
+ element.error = "";
241
+ element.open = true;
242
+ },
243
+ refresh,
244
+ relocalize,
245
+ destroy() {
246
+ element.remove();
247
+ }
248
+ };
249
+ }
250
+
251
+ // src/files/connected-services-labels.ts
252
+ function connectedServicesLabels(t) {
253
+ return {
254
+ heading: t("Connected services"),
255
+ description: t("Link your storage to open and save files from every app."),
256
+ notConnected: t("Not connected"),
257
+ connect: t("Connect"),
258
+ disconnect: t("Disconnect"),
259
+ managed: t("Managed by your organization"),
260
+ failed: t("Could not update {provider}. Try again.")
261
+ };
262
+ }
263
+ function chartExSpaceFormatSource(space, theme) {
264
+ const source = chartSpaceFormatSource(chartExStyleSpace(space), {
265
+ ...theme ? { theme } : {},
266
+ advanced: true
267
+ });
268
+ const { axisOptions: _axes, seriesOptions: _series, ...common } = source;
269
+ return {
270
+ ...common,
271
+ element(target) {
272
+ const view = source.element(target);
273
+ return { ...view, support: { ...view.support, secondaryAxis: false } };
274
+ }
275
+ };
276
+ }
277
+
278
+ export { FONT_DOWNLOADS_DEFAULT, attachShareDialog, chartExSpaceFormatSource, connectedServicesLabels, effectiveFontDownloads, fontDownloadLock, prefetchLinkId, prefetchWebfonts, prepareWebfonts, syncGoogleWebfontStylesheet };
@@ -1,5 +1,5 @@
1
1
  import { defineSmartArt, defineSmartArtPicker, defineSmartArtTextPane } from './chunk-6FFZFH73.js';
2
- import { TEAMS_TAGS, registerTeams } from './chunk-2YRHRV4H.js';
2
+ import { TEAMS_TAGS, registerTeams } from './chunk-MUY444GW.js';
3
3
  import { installOfficeUiTheme } from './chunk-N6AKS4ED.js';
4
4
  import { registerControls } from './chunk-UEFVC6V4.js';
5
5
  import { definePresence } from './chunk-Q6WZEGAM.js';
@@ -7,6 +7,10 @@ export interface BackstageOptions {
7
7
  showRuler?: boolean;
8
8
  showMarks?: boolean;
9
9
  showThumbnails?: boolean;
10
+ /** Trust Center: download missing fonts (the host's value when it set one). */
11
+ allowFontDownloads?: boolean;
12
+ /** The host's `googleFonts` decides the toggle, which is then read-only. */
13
+ fontDownloadsLocked?: boolean;
10
14
  }
11
15
  export type BackstageOptionKey = keyof BackstageOptions;
12
16
  export interface WordOptions {
@@ -0,0 +1,11 @@
1
+ import type { OfficeOptionCategory, OptionsContext } from '../controls.js';
2
+ /** The option key of the Trust Center's font download toggle. */
3
+ export declare const FONT_DOWNLOADS_OPTION = "allowFontDownloads";
4
+ /** The toggle's info text (PowerPoint's, naming Word). */
5
+ export declare const FONT_DOWNLOADS_INFO = "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Word.";
6
+ /**
7
+ * File > Options > Trust Center, worded as PowerPoint's: one toggle for downloading the fonts a
8
+ * document uses that are neither installed nor embedded. `locked` is the host's `googleFonts`
9
+ * decision (`fontDownloadLock`): the toggle then shows that value read-only, with the reason.
10
+ */
11
+ export declare function trustCategory(context: OptionsContext, locked: boolean | undefined): OfficeOptionCategory;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Word's webfont fallback: the `googleFonts` option of `<docx-editor>` when the host sets it,
3
+ * otherwise the reader's Trust Center choice (`font-downloads.ts`, off until turned on), joined by
4
+ * the shared `effectiveFontDownloads` rule. When on, the families a document draws that the reader has neither installed nor embedded
5
+ * (Word does not load a document's embedded fonts yet, so none count as embedded) are requested
6
+ * from the Google Fonts CSS2 API, or the host's mirror, through one managed `<link>` per editor;
7
+ * a family the catalogue does not serve under its own name ("Calibri") is requested as its
8
+ * metric-compatible clone ("Carlito"), which Word's font stacks (`cssFontStack`) already list
9
+ * after the document font in both measurement and paint.
10
+ *
11
+ * Which runs and families is `collectDocxWebfontRuns` (core); the browser side is
12
+ * `fonts/webfonts`. This module only joins them to the element's option.
13
+ *
14
+ * @module docx/docx-webfonts
15
+ */
16
+ import type { DocumentModel } from 'ooxml-core/docx';
17
+ import { type GoogleFontsOption } from 'ooxml-core/text';
18
+ import { type PrepareWebfontsOptions, type WebfontReadiness } from '../fonts/webfonts.js';
19
+ /** Prefix of each editor's managed `<link>` id (`docx-editor-webfonts-1`, ...). */
20
+ export declare const DOCX_WEBFONT_LINK_PREFIX = "docx-editor-webfonts";
21
+ /** The CSS2 base `option` requests, or `null` (off). Unset is off in Word. */
22
+ export declare function docxGoogleFontsBase(option: GoogleFontsOption | undefined): string | null;
23
+ export type DocxWebfontWaitOptions = Pick<PrepareWebfontsOptions, 'timeoutMs' | 'progressDelayMs' | 'onProgress' | 'isLocallyInstalled'>;
24
+ /**
25
+ * One editor's webfont state: the host's option and its own `<link>`, so two editors on a page
26
+ * (the suite's tabs) never replace each other's stylesheet.
27
+ */
28
+ export declare class DocxWebfonts {
29
+ /** The host's `googleFonts` value; unset leaves the choice to the reader. */
30
+ option: GoogleFontsOption | undefined;
31
+ readonly linkId: string;
32
+ /** The CSS2 base the loader uses: the host's value, else the reader's Trust Center choice. */
33
+ base(): string | null;
34
+ /**
35
+ * Point this editor's `<link>` at the faces `model` needs and wait (bounded) for them; with
36
+ * the option off the `<link>` is removed and nothing is requested. Never rejects.
37
+ */
38
+ prepare(doc: Document | undefined, model: DocumentModel, wait?: DocxWebfontWaitOptions): Promise<WebfontReadiness>;
39
+ /**
40
+ * Start downloading the faces `bytes` declares before it is parsed (see `prefetchWebfonts`),
41
+ * so they are usually ready when {@link prepare} waits. Never throws.
42
+ */
43
+ prefetch(doc: Document | undefined, bytes: Uint8Array | ArrayBuffer): void;
44
+ /** Whether this editor's `<link>` (or its early `-prefetch` one) is in `doc`. */
45
+ linked(doc: Document | undefined): boolean;
46
+ }
47
+ /** What {@link refreshDocxWebfonts} needs from the editor. */
48
+ export interface DocxWebfontHost {
49
+ readonly element: HTMLElement;
50
+ readonly webfonts: DocxWebfonts;
51
+ readonly model: DocumentModel;
52
+ readonly shell: {
53
+ printLayout?: {
54
+ remeasure(): void;
55
+ };
56
+ };
57
+ }
58
+ /**
59
+ * Bring the webfonts up to date for the document already on screen (a document set without
60
+ * `load`, or the option changed). Faces that arrive fire `document.fonts` `loadingdone`, on which
61
+ * Print Layout measures again and the run decorations refresh; a stylesheet that was removed
62
+ * takes its faces away without that event, so Print Layout is told to measure again here.
63
+ */
64
+ export declare function refreshDocxWebfonts(host: DocxWebfontHost): Promise<void>;
65
+ /** The Trust Center toggle as File > Options shows it: the host's value, locked, or the reader's. */
66
+ export declare function fontDownloadOptions(webfonts: DocxWebfonts): {
67
+ allowFontDownloads: boolean;
68
+ fontDownloadsLocked: boolean;
69
+ };
70
+ /**
71
+ * Records the reader's choice and applies it to the open document at once: on requests its
72
+ * fonts, off removes the stylesheets and measures again. A host's value wins, so nothing changes
73
+ * then.
74
+ */
75
+ export declare function setFontDownloads(host: DocxWebfontHost, allow: boolean): void;
@@ -28,6 +28,7 @@ import type { PageNavigator } from './page-navigator.js';
28
28
  import type { HeadingNavigator } from './heading-navigator.js';
29
29
  import type { DocxChartFormatPane } from './chart-format-pane.js';
30
30
  import { ViewOptions } from './view-options.js';
31
+ import { DocxWebfonts } from './docx-webfonts.js';
31
32
  export type LoadedDocument = Awaited<ReturnType<typeof loadDocument>>;
32
33
  /** DOM pieces created by the shell once the element connects. */
33
34
  export interface ShellParts {
@@ -123,6 +124,8 @@ export declare class EditorCore {
123
124
  readonly parts: PartsController;
124
125
  readonly pages: PageController;
125
126
  readonly viewOptions: ViewOptions;
127
+ /** The `googleFonts` option and this editor's webfont `<link>`. */
128
+ readonly webfonts: DocxWebfonts;
126
129
  readonly dirtyState: DirtyState;
127
130
  readonly pageTracker: PageTracker;
128
131
  private wordText;
@@ -9,6 +9,7 @@ import type { WordCustomization } from './customization.js';
9
9
  import { type WordToolbarProps } from './building-blocks.js';
10
10
  import { type WordNavigationProps, type WordStatusProps } from './building-blocks-status.js';
11
11
  import type { SurfaceHostActions } from './building-blocks-actions.js';
12
+ import type { GoogleFontsOption } from 'ooxml-core/text';
12
13
  declare const HTMLElementBase: typeof HTMLElement;
13
14
  /**
14
15
  * Save, collaboration, dirty-tracking and UI-customisation surface of `<docx-editor>`.
@@ -46,6 +47,19 @@ export declare abstract class DocxEditorApi extends HTMLElementBase {
46
47
  */
47
48
  get fileProviders(): readonly CloudFileProvider[];
48
49
  set fileProviders(value: readonly CloudFileProvider[] | null | undefined);
50
+ /**
51
+ * Webfonts for the document fonts the reader has neither installed nor embedded. Unset (the
52
+ * default): the reader decides in File > Options > Trust Center (off until turned on; when on,
53
+ * Google Fonts). `false`: off, nothing is requested. A set value locks that toggle, which then
54
+ * shows it read-only. `{ baseUrl }`: such a family that the Google
55
+ * Fonts catalogue serves, or its metric-compatible clone (Calibri as Carlito), is requested from
56
+ * that CSS2 endpoint (`https://fonts.googleapis.com/css2`, or a self-hosted mirror) with only
57
+ * the family names, and `load` waits briefly (150 ms) for the faces before showing the document. An
58
+ * invalid `baseUrl` warns and stays off. Read when a document loads; changing it re-requests
59
+ * for the document on screen.
60
+ */
61
+ get googleFonts(): GoogleFontsOption | undefined;
62
+ set googleFonts(value: GoogleFontsOption | undefined);
49
63
  get loading(): boolean;
50
64
  /** Selection and formatting updates, including changes which do not dirty the document. */
51
65
  subscribeEditorState(listener: () => void): () => void;
@@ -0,0 +1,8 @@
1
+ /** The localStorage key of the choice (`"true"` or `"false"`). */
2
+ export declare const FONT_DOWNLOADS_KEY = "ooxml.docx.allowFontDownloads";
3
+ /** The reader's choice: the stored value, else the session's, else the default (off). */
4
+ export declare function readerAllowsFontDownloads(): boolean;
5
+ /** Records the reader's choice. */
6
+ export declare function setReaderAllowsFontDownloads(allow: boolean): void;
7
+ /** Forgets the choice (tests, and a reset). */
8
+ export declare function clearReaderFontDownloads(): void;
@@ -93,6 +93,12 @@ export declare const en: {
93
93
  readonly 'Split cells': 'Split cells';
94
94
  readonly 'Number of rows': 'Number of rows';
95
95
  readonly 'Split the cell into this many columns and rows.': 'Split the cell into this many columns and rows.';
96
+ readonly 'Help keep your documents safe and secure.': string;
97
+ readonly 'Security settings': string;
98
+ readonly 'These settings help keep the content you open safe. We recommend the defaults.': string;
99
+ readonly 'Download fonts that are not installed or embedded (Google Fonts)': string;
100
+ readonly 'When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Word.': string;
101
+ readonly 'This setting is managed by your organization': string;
96
102
  readonly 'Change how document content is displayed on the screen.': string;
97
103
  readonly 'Page display options': string;
98
104
  readonly 'Formatting marks': string;
@@ -1,5 +1,11 @@
1
1
  /** File > Options: the shared Office option strings plus the Display and Proofing panes of Word. */
2
2
  export declare const enOptions: {
3
+ 'Help keep your documents safe and secure.': string;
4
+ 'Security settings': string;
5
+ 'These settings help keep the content you open safe. We recommend the defaults.': string;
6
+ 'Download fonts that are not installed or embedded (Google Fonts)': string;
7
+ 'When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Word.': string;
8
+ 'This setting is managed by your organization': string;
3
9
  'Change how document content is displayed on the screen.': string;
4
10
  'Page display options': string;
5
11
  'Formatting marks': string;
@@ -0,0 +1,15 @@
1
+ /** File > Options > Trust Center: PowerPoint's wording, with Word named in the info text. */
2
+ export declare const enTrust: {
3
+ 'Help keep your documents safe and secure.': string;
4
+ 'Security settings': string;
5
+ 'These settings help keep the content you open safe. We recommend the defaults.': string;
6
+ 'Download fonts that are not installed or embedded (Google Fonts)': string;
7
+ 'When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Word.': string;
8
+ 'This setting is managed by your organization': string;
9
+ };
10
+ type Trust = Record<keyof typeof enTrust, string>;
11
+ export declare const frTrust: Trust;
12
+ export declare const deTrust: Trust;
13
+ export declare const esTrust: Trust;
14
+ export declare const zhTrust: Trust;
15
+ export {};
@@ -90,6 +90,12 @@ export declare const strings: {
90
90
  readonly 'Split cells': 'Split cells';
91
91
  readonly 'Number of rows': 'Number of rows';
92
92
  readonly 'Split the cell into this many columns and rows.': 'Split the cell into this many columns and rows.';
93
+ readonly 'Help keep your documents safe and secure.': string;
94
+ readonly 'Security settings': string;
95
+ readonly 'These settings help keep the content you open safe. We recommend the defaults.': string;
96
+ readonly 'Download fonts that are not installed or embedded (Google Fonts)': string;
97
+ readonly 'When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Word.': string;
98
+ readonly 'This setting is managed by your organization': string;
93
99
  readonly 'Change how document content is displayed on the screen.': string;
94
100
  readonly 'Page display options': string;
95
101
  readonly 'Formatting marks': string;
@@ -14,6 +14,8 @@ export interface PrintLayoutController {
14
14
  scheduleRelayout(model: DocumentModel): void;
15
15
  /** Lays out now, dropping a pending debounced layout (a document swap must not show stale pages). */
16
16
  relayoutNow(model: DocumentModel): void;
17
+ /** Measures again from scratch, as when a web font arrives (also after its stylesheet left). */
18
+ remeasure(): void;
17
19
  /** Recomputes which page is most visible; call on the scroll container's `scroll` event. */
18
20
  refreshCurrentPage(): void;
19
21
  pageStatus(): {