ooxml-ui 1.46.0 → 1.48.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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/chart/format-pane-axis.d.ts +0 -1
  3. package/dist/chart/format-pane-model.d.ts +0 -1
  4. package/dist/chart/format-pane-targets.d.ts +0 -1
  5. package/dist/chart/format-pane-types.d.ts +0 -1
  6. package/dist/chart/format-pane-view.d.ts +0 -1
  7. package/dist/{chunk-NH33G6LA.js → chunk-G5CALQUW.js} +43 -2
  8. package/dist/{chunk-HNSFEOSG.js → chunk-J3ROBM74.js} +1 -1
  9. package/dist/docx/backstage-options.d.ts +4 -0
  10. package/dist/docx/backstage-trust.d.ts +11 -0
  11. package/dist/docx/docx-webfonts.d.ts +23 -3
  12. package/dist/docx/element-api.d.ts +3 -1
  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.js +154 -13
  19. package/dist/fonts/font-download-policy.d.ts +23 -0
  20. package/dist/fonts/webfonts.d.ts +34 -13
  21. package/dist/fonts/webfonts.d.ts.map +1 -1
  22. package/dist/form/color-input/live-color-input.d.ts +0 -1
  23. package/dist/form/range-control.d.ts +0 -1
  24. package/dist/index.js +2 -2
  25. package/dist/pptx/{chunk-Y5I2GPXN.cjs → chunk-2C2C27ML.cjs} +99 -2
  26. package/dist/pptx/{chunk-Z6HDGNW6.mjs → chunk-C4GZLKDW.mjs} +97 -3
  27. package/dist/pptx/{chunk-F2LOZTP3.mjs → chunk-JUEKQZSB.mjs} +1 -1
  28. package/dist/pptx/{chunk-XPTB4LSI.cjs → chunk-N5WPJIMK.cjs} +42 -42
  29. package/dist/pptx/dom/index.cjs +370 -370
  30. package/dist/pptx/dom/index.mjs +4 -4
  31. package/dist/pptx/index.cjs +3074 -3062
  32. package/dist/pptx/index.mjs +1 -1
  33. package/dist/pptx/render/deck-webfont-readiness.d.ts +11 -0
  34. package/dist/pptx/render/deck-webfont-readiness.d.ts.map +1 -1
  35. package/dist/pptx/render/index.d.ts +2 -0
  36. package/dist/pptx/render/index.d.ts.map +1 -1
  37. package/dist/pptx/render/inline-text-paragraph-marker.d.ts +3 -0
  38. package/dist/pptx/render/inline-text-paragraph-marker.d.ts.map +1 -0
  39. package/dist/pptx/render/inline-trailing-space.d.ts +14 -0
  40. package/dist/pptx/render/inline-trailing-space.d.ts.map +1 -0
  41. package/dist/pptx/render/morph-predicates.d.ts +5 -1
  42. package/dist/pptx/render/morph-predicates.d.ts.map +1 -1
  43. package/dist/pptx/{smartart-insert-preview-O4B3T6TS.cjs → smartart-insert-preview-3BLHZGCE.cjs} +3 -3
  44. package/dist/pptx/{smartart-insert-preview-Q6V3WY7W.mjs → smartart-insert-preview-WRSYENYB.mjs} +2 -2
  45. package/dist/render-cache.d.ts +0 -1
  46. package/dist/teams.js +1 -1
  47. package/dist/theme-bridge.d.ts +0 -1
  48. package/dist/theme.d.ts +0 -1
  49. package/dist/visio/controller.d.ts +6 -0
  50. package/dist/visio/locales/trust-center.d.ts +7 -0
  51. package/dist/visio/viewer-behaviour.d.ts +5 -0
  52. package/dist/visio/viewer-element.d.ts +5 -3
  53. package/dist/visio/viewer-options-categories.d.ts +6 -0
  54. package/dist/visio/viewer-options-trust.d.ts +10 -0
  55. package/dist/visio/viewer-options.d.ts +6 -0
  56. package/dist/visio/viewer-webfonts.d.ts +15 -3
  57. package/dist/visio.js +184 -16
  58. package/dist/xlsx/backstage/options-trust.d.ts +9 -0
  59. package/dist/xlsx/backstage/parts.d.ts +4 -0
  60. package/dist/xlsx/element-api.d.ts +9 -7
  61. package/dist/xlsx/font-downloads.d.ts +8 -0
  62. package/dist/xlsx/webfonts.d.ts +21 -1
  63. package/dist/xlsx.js +130 -20
  64. package/package.json +2 -2
  65. /package/dist/{chunk-6G6KERIZ.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 unless the host sets their `googleFonts` property (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).
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
 
@@ -2,4 +2,3 @@ import type { ChartFormatSection } from './format-pane-types.js';
2
2
  import type { ChartFormatAxisView } from './format-pane-view.js';
3
3
  /** Axis Options, Tick Marks, Labels and Number sections for `axis`. */
4
4
  export declare function axisOptions(axis: ChartFormatAxisView): ChartFormatSection[];
5
- //# sourceMappingURL=format-pane-axis.d.ts.map
@@ -20,4 +20,3 @@ export declare function chartFormatSourceTabs(source: ChartFormatSource, target:
20
20
  * the mode's first tab. A `flat` source gets every chart section on one page.
21
21
  */
22
22
  export declare function buildChartFormatModel(source: ChartFormatSource, targetKey: string | undefined, tab?: ChartFormatTabId, mode?: ChartFormatPaneMode): ChartFormatPaneModel;
23
- //# sourceMappingURL=format-pane-model.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
@@ -115,4 +115,3 @@ export interface ChartFormatPaneModel {
115
115
  /** The value a field change carries. */
116
116
  export type ChartFormatFieldValue = string | number | boolean | '';
117
117
  export {};
118
- //# sourceMappingURL=format-pane-types.d.ts.map
@@ -228,4 +228,3 @@ export interface ChartFormatSource {
228
228
  /** Caption of the element picker (default "Chart Options"). */
229
229
  readonly picker?: ChartFormatText;
230
230
  }
231
- //# sourceMappingURL=format-pane-view.d.ts.map
@@ -1,7 +1,16 @@
1
1
  import { defineShareDialog, chartSpaceFormatSource, shareDialogLabels } from './chunk-UEFVC6V4.js';
2
- import { collectRunFamilies, collectWebfontFaces, selectGoogleWebfontFamilies, buildGoogleFontsHref, matchGoogleWebfontFragments } from 'ooxml-core/text';
2
+ import { GOOGLE_FONTS_CSS2_BASE, resolveGoogleFontsCss2Base, collectRunFamilies, collectWebfontFaces, selectGoogleWebfontFamilies, buildGoogleFontsHref, matchGoogleWebfontFragments } from 'ooxml-core/text';
3
+ import { readDeclaredFonts } from 'ooxml-core/opc';
3
4
  import { chartExStyleSpace } from 'ooxml-core/chart';
4
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
+ }
5
14
  var WEBFONT_TIMEOUT_MS = 150;
6
15
  var WEBFONT_PROGRESS_DELAY_MS = 400;
7
16
  var INSTALLED_FONT_TEST_STRING = "mmmmmmmmmmllww";
@@ -22,10 +31,13 @@ function isFontFamilyInstalledLocally(family) {
22
31
  return false;
23
32
  }
24
33
  }
34
+ var prefetchLinkId = (linkId) => `${linkId}-prefetch`;
25
35
  function syncGoogleWebfontStylesheet(doc, id, href) {
26
36
  const existing = doc.getElementById(id);
27
37
  if (!href) {
28
38
  existing?.remove();
39
+ const early = id.endsWith("-prefetch") ? null : doc.getElementById(prefetchLinkId(id));
40
+ if (early && !early.dataset["pending"]) early.remove();
29
41
  return null;
30
42
  }
31
43
  if (existing?.getAttribute("href") === href) return existing;
@@ -51,6 +63,34 @@ function webfontHref(candidates, base) {
51
63
  if (base === null) return null;
52
64
  return buildGoogleFontsHref(matchWebfontFragments(candidates), base);
53
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
+ }
54
94
  function stylesheetSettled(link) {
55
95
  if (link.sheet) return Promise.resolve();
56
96
  return new Promise((resolve) => {
@@ -76,6 +116,7 @@ async function prepareWebfonts(options) {
76
116
  progressDelayMs = WEBFONT_PROGRESS_DELAY_MS,
77
117
  isLocallyInstalled = isFontFamilyInstalledLocally
78
118
  } = options;
119
+ settlePrefetchedWebfonts(doc, linkId, base);
79
120
  if (base === null) return { href: null, families: [], unavailable: [], timedOut: false };
80
121
  const candidates = selectWebfontCandidates(
81
122
  collectRunFamilies(runs),
@@ -234,4 +275,4 @@ function chartExSpaceFormatSource(space, theme) {
234
275
  };
235
276
  }
236
277
 
237
- export { attachShareDialog, chartExSpaceFormatSource, connectedServicesLabels, prepareWebfonts, syncGoogleWebfontStylesheet };
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-6G6KERIZ.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;
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Word's webfont fallback: the `googleFonts` option of `<docx-editor>`. Off unless the host sets
3
- * it. When on, the families a document draws that the reader has neither installed nor embedded
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
4
5
  * (Word does not load a document's embedded fonts yet, so none count as embedded) are requested
5
6
  * from the Google Fonts CSS2 API, or the host's mirror, through one managed `<link>` per editor;
6
7
  * a family the catalogue does not serve under its own name ("Calibri") is requested as its
@@ -25,14 +26,22 @@ export type DocxWebfontWaitOptions = Pick<PrepareWebfontsOptions, 'timeoutMs' |
25
26
  * (the suite's tabs) never replace each other's stylesheet.
26
27
  */
27
28
  export declare class DocxWebfonts {
29
+ /** The host's `googleFonts` value; unset leaves the choice to the reader. */
28
30
  option: GoogleFontsOption | undefined;
29
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;
30
34
  /**
31
35
  * Point this editor's `<link>` at the faces `model` needs and wait (bounded) for them; with
32
36
  * the option off the `<link>` is removed and nothing is requested. Never rejects.
33
37
  */
34
38
  prepare(doc: Document | undefined, model: DocumentModel, wait?: DocxWebfontWaitOptions): Promise<WebfontReadiness>;
35
- /** Whether this editor's `<link>` is in `doc`. */
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`. */
36
45
  linked(doc: Document | undefined): boolean;
37
46
  }
38
47
  /** What {@link refreshDocxWebfonts} needs from the editor. */
@@ -53,3 +62,14 @@ export interface DocxWebfontHost {
53
62
  * takes its faces away without that event, so Print Layout is told to measure again here.
54
63
  */
55
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;
@@ -49,7 +49,9 @@ export declare abstract class DocxEditorApi extends HTMLElementBase {
49
49
  set fileProviders(value: readonly CloudFileProvider[] | null | undefined);
50
50
  /**
51
51
  * Webfonts for the document fonts the reader has neither installed nor embedded. Unset (the
52
- * default) or `false`: off, nothing is requested. `{ baseUrl }`: such a family that the Google
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
53
55
  * Fonts catalogue serves, or its metric-compatible clone (Calibri as Carlito), is requested from
54
56
  * that CSS2 endpoint (`https://fonts.googleapis.com/css2`, or a self-hosted mirror) with only
55
57
  * the family names, and `load` waits briefly (150 ms) for the faces before showing the document. An
@@ -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;
package/dist/docx.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineChartExOptions, statusLayout, watchStatusWidth, compactPageText } from './chunk-II43ALTT.js';
2
- import { syncGoogleWebfontStylesheet, prepareWebfonts, chartExSpaceFormatSource, attachShareDialog, connectedServicesLabels } from './chunk-NH33G6LA.js';
2
+ import { effectiveFontDownloads, syncGoogleWebfontStylesheet, prepareWebfonts, prefetchWebfonts, prefetchLinkId, FONT_DOWNLOADS_DEFAULT, chartExSpaceFormatSource, attachShareDialog, fontDownloadLock, connectedServicesLabels } from './chunk-G5CALQUW.js';
3
3
  import { syncRibbonAddIns, createHostBackstagePages, withHostMenuItems } from './chunk-ZTLP52FH.js';
4
4
  export { RIBBON_ADD_IN_EVENT } from './chunk-ZTLP52FH.js';
5
5
  import { defineSmartArt, smartArtColorsGalleryState, smartArtStylesGalleryState, SmartArtTextPaneController, pictureNeedsSvg, pictureSvg, defineSmartArtPicker } from './chunk-6FFZFH73.js';
@@ -66,8 +66,53 @@ var zhSplitCells = fromValues([
66
66
  "\u884C\u6570",
67
67
  "\u5C06\u5355\u5143\u683C\u62C6\u5206\u4E3A\u6B64\u6570\u91CF\u7684\u5217\u548C\u884C\u3002"
68
68
  ]);
69
+
70
+ // src/docx/locales/trust.ts
71
+ var enTrust = {
72
+ "Help keep your documents safe and secure.": "Help keep your documents safe and secure.",
73
+ "Security settings": "Security settings",
74
+ "These settings help keep the content you open safe. We recommend the defaults.": "These settings help keep the content you open safe. We recommend the defaults.",
75
+ "Download fonts that are not installed or embedded (Google Fonts)": "Download fonts that are not installed or embedded (Google Fonts)",
76
+ "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.": "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.",
77
+ "This setting is managed by your organization": "This setting is managed by your organization"
78
+ };
79
+ var frTrust = {
80
+ "Help keep your documents safe and secure.": "Assurez la s\xE9curit\xE9 et la protection de vos documents.",
81
+ "Security settings": "Param\xE8tres de s\xE9curit\xE9",
82
+ "These settings help keep the content you open safe. We recommend the defaults.": "Ces param\xE8tres contribuent \xE0 la s\xE9curit\xE9 du contenu que vous ouvrez. Nous recommandons les valeurs par d\xE9faut.",
83
+ "Download fonts that are not installed or embedded (Google Fonts)": "T\xE9l\xE9charger les polices non install\xE9es ni incorpor\xE9es (Google Fonts)",
84
+ "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.": "Lorsque cette option est activ\xE9e, votre navigateur contacte fonts.googleapis.com et fonts.gstatic.com (ou le serveur de polices de votre organisation) pour obtenir les polices manquantes. Lorsqu'elle est d\xE9sactiv\xE9e, le texte utilise des polices install\xE9es, incorpor\xE9es ou de substitution, et les sauts de ligne peuvent donc diff\xE9rer de Word.",
85
+ "This setting is managed by your organization": "Ce param\xE8tre est g\xE9r\xE9 par votre organisation"
86
+ };
87
+ var deTrust = {
88
+ "Help keep your documents safe and secure.": "Sorgen Sie f\xFCr die Sicherheit Ihrer Dokumente.",
89
+ "Security settings": "Sicherheitseinstellungen",
90
+ "These settings help keep the content you open safe. We recommend the defaults.": "Diese Einstellungen tragen dazu bei, ge\xF6ffnete Inhalte sicher zu halten. Wir empfehlen die Standardwerte.",
91
+ "Download fonts that are not installed or embedded (Google Fonts)": "Nicht installierte oder eingebettete Schriftarten herunterladen (Google Fonts)",
92
+ "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.": "Wenn aktiviert, ruft Ihr Browser fehlende Schriftarten von fonts.googleapis.com und fonts.gstatic.com (oder vom Schriftartserver Ihrer Organisation) ab. Wenn deaktiviert, verwendet Text installierte, eingebettete oder Ersatzschriftarten, sodass Zeilenumbr\xFCche von Word abweichen k\xF6nnen.",
93
+ "This setting is managed by your organization": "Diese Einstellung wird von Ihrer Organisation verwaltet"
94
+ };
95
+ var esTrust = {
96
+ "Help keep your documents safe and secure.": "Ayude a mantener sus documentos seguros y protegidos.",
97
+ "Security settings": "Configuraci\xF3n de seguridad",
98
+ "These settings help keep the content you open safe. We recommend the defaults.": "Esta configuraci\xF3n ayuda a mantener seguro el contenido que abre. Recomendamos los valores predeterminados.",
99
+ "Download fonts that are not installed or embedded (Google Fonts)": "Descargar fuentes que no est\xE1n instaladas ni incrustadas (Google Fonts)",
100
+ "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.": "Cuando est\xE1 activado, el navegador se conecta a fonts.googleapis.com y fonts.gstatic.com (o al servidor de fuentes de su organizaci\xF3n) para obtener las fuentes que faltan. Cuando est\xE1 desactivado, el texto usa fuentes instaladas, incrustadas o sustitutas, por lo que los saltos de l\xEDnea pueden diferir de Word.",
101
+ "This setting is managed by your organization": "Esta configuraci\xF3n la administra su organizaci\xF3n"
102
+ };
103
+ var zhTrust = {
104
+ "Help keep your documents safe and secure.": "\u5E2E\u52A9\u786E\u4FDD\u60A8\u7684\u6587\u6863\u5B89\u5168\u53EF\u9760\u3002",
105
+ "Security settings": "\u5B89\u5168\u8BBE\u7F6E",
106
+ "These settings help keep the content you open safe. We recommend the defaults.": "\u8FD9\u4E9B\u8BBE\u7F6E\u6709\u52A9\u4E8E\u786E\u4FDD\u60A8\u6253\u5F00\u7684\u5185\u5BB9\u5B89\u5168\u3002\u6211\u4EEC\u5EFA\u8BAE\u4F7F\u7528\u9ED8\u8BA4\u503C\u3002",
107
+ "Download fonts that are not installed or embedded (Google Fonts)": "\u4E0B\u8F7D\u672A\u5B89\u88C5\u6216\u672A\u5D4C\u5165\u7684\u5B57\u4F53\uFF08Google Fonts\uFF09",
108
+ "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.": "\u5F00\u542F\u65F6\uFF0C\u6D4F\u89C8\u5668\u4F1A\u8FDE\u63A5 fonts.googleapis.com \u548C fonts.gstatic.com\uFF08\u6216\u8D35\u7EC4\u7EC7\u8BBE\u7F6E\u7684\u5B57\u4F53\u670D\u52A1\u5668\uFF09\u4EE5\u83B7\u53D6\u7F3A\u5C11\u7684\u5B57\u4F53\u3002\u5173\u95ED\u65F6\uFF0C\u6587\u672C\u4F7F\u7528\u5DF2\u5B89\u88C5\u3001\u5DF2\u5D4C\u5165\u6216\u66FF\u4EE3\u5B57\u4F53\uFF0C\u56E0\u6B64\u6362\u884C\u53EF\u80FD\u4E0E Word \u4E0D\u540C\u3002",
109
+ "This setting is managed by your organization": "\u6B64\u8BBE\u7F6E\u7531\u4F60\u7684\u7EC4\u7EC7\u7BA1\u7406"
110
+ };
111
+
112
+ // src/docx/locales/options.ts
69
113
  var enOptions = {
70
114
  ...optionStrings.en,
115
+ ...enTrust,
71
116
  "Change how document content is displayed on the screen.": "Change how document content is displayed on the screen.",
72
117
  "Page display options": "Page display options",
73
118
  "Formatting marks": "Formatting marks",
@@ -75,6 +120,7 @@ var enOptions = {
75
120
  };
76
121
  var frOptions = {
77
122
  ...optionStrings.fr,
123
+ ...frTrust,
78
124
  "Change how document content is displayed on the screen.": "Modifiez l\u2019affichage du contenu du document \xE0 l\u2019\xE9cran.",
79
125
  "Page display options": "Options d\u2019affichage des pages",
80
126
  "Formatting marks": "Marques de mise en forme",
@@ -82,6 +128,7 @@ var frOptions = {
82
128
  };
83
129
  var deOptions = {
84
130
  ...optionStrings.de,
131
+ ...deTrust,
85
132
  "Change how document content is displayed on the screen.": "\xC4ndern Sie, wie der Dokumentinhalt auf dem Bildschirm angezeigt wird.",
86
133
  "Page display options": "Seitenanzeigeoptionen",
87
134
  "Formatting marks": "Formatierungszeichen",
@@ -89,6 +136,7 @@ var deOptions = {
89
136
  };
90
137
  var esOptions = {
91
138
  ...optionStrings.es,
139
+ ...esTrust,
92
140
  "Change how document content is displayed on the screen.": "Cambie la forma en que se muestra el contenido del documento en pantalla.",
93
141
  "Page display options": "Opciones de presentaci\xF3n de p\xE1gina",
94
142
  "Formatting marks": "Marcas de formato",
@@ -96,6 +144,7 @@ var esOptions = {
96
144
  };
97
145
  var zhOptions = {
98
146
  ...optionStrings["zh-CN"],
147
+ ...zhTrust,
99
148
  "Change how document content is displayed on the screen.": "\u66F4\u6539\u6587\u6863\u5185\u5BB9\u5728\u5C4F\u5E55\u4E0A\u7684\u663E\u793A\u65B9\u5F0F\u3002",
100
149
  "Page display options": "\u9875\u9762\u663E\u793A\u9009\u9879",
101
150
  "Formatting marks": "\u683C\u5F0F\u6807\u8BB0",
@@ -22144,6 +22193,28 @@ function applyViewOptions(core) {
22144
22193
  String(showThumbnails)
22145
22194
  );
22146
22195
  }
22196
+
22197
+ // src/docx/font-downloads.ts
22198
+ var FONT_DOWNLOADS_KEY = "ooxml.docx.allowFontDownloads";
22199
+ var memory;
22200
+ function readerAllowsFontDownloads() {
22201
+ try {
22202
+ const raw = globalThis.localStorage?.getItem(FONT_DOWNLOADS_KEY);
22203
+ if (raw === "true") return true;
22204
+ if (raw === "false") return false;
22205
+ } catch {
22206
+ }
22207
+ return memory ?? FONT_DOWNLOADS_DEFAULT;
22208
+ }
22209
+ function setReaderAllowsFontDownloads(allow) {
22210
+ memory = allow;
22211
+ try {
22212
+ globalThis.localStorage?.setItem(FONT_DOWNLOADS_KEY, String(allow));
22213
+ } catch {
22214
+ }
22215
+ }
22216
+
22217
+ // src/docx/docx-webfonts.ts
22147
22218
  var DOCX_WEBFONT_LINK_PREFIX = "docx-editor-webfonts";
22148
22219
  var OFF = { href: null, families: [], unavailable: [], timedOut: false };
22149
22220
  function docxGoogleFontsBase(option) {
@@ -22158,15 +22229,20 @@ function runsOf(model) {
22158
22229
  }
22159
22230
  var instances = 0;
22160
22231
  var DocxWebfonts = class {
22232
+ /** The host's `googleFonts` value; unset leaves the choice to the reader. */
22161
22233
  option;
22162
22234
  linkId = `${DOCX_WEBFONT_LINK_PREFIX}-${++instances}`;
22235
+ /** The CSS2 base the loader uses: the host's value, else the reader's Trust Center choice. */
22236
+ base() {
22237
+ return docxGoogleFontsBase(effectiveFontDownloads(this.option, readerAllowsFontDownloads()));
22238
+ }
22163
22239
  /**
22164
22240
  * Point this editor's `<link>` at the faces `model` needs and wait (bounded) for them; with
22165
22241
  * the option off the `<link>` is removed and nothing is requested. Never rejects.
22166
22242
  */
22167
22243
  async prepare(doc, model, wait = {}) {
22168
22244
  if (!doc?.head) return OFF;
22169
- const base = docxGoogleFontsBase(this.option);
22245
+ const base = this.base();
22170
22246
  if (base === null) {
22171
22247
  syncGoogleWebfontStylesheet(doc, this.linkId, null);
22172
22248
  return OFF;
@@ -22184,9 +22260,24 @@ var DocxWebfonts = class {
22184
22260
  return OFF;
22185
22261
  }
22186
22262
  }
22187
- /** Whether this editor's `<link>` is in `doc`. */
22263
+ /**
22264
+ * Start downloading the faces `bytes` declares before it is parsed (see `prefetchWebfonts`),
22265
+ * so they are usually ready when {@link prepare} waits. Never throws.
22266
+ */
22267
+ prefetch(doc, bytes) {
22268
+ if (!doc?.head) return;
22269
+ prefetchWebfonts({
22270
+ document: doc,
22271
+ linkId: this.linkId,
22272
+ bytes,
22273
+ base: this.base()
22274
+ });
22275
+ }
22276
+ /** Whether this editor's `<link>` (or its early `-prefetch` one) is in `doc`. */
22188
22277
  linked(doc) {
22189
- return Boolean(doc?.getElementById(this.linkId));
22278
+ return Boolean(
22279
+ doc?.getElementById(this.linkId) ?? doc?.getElementById(prefetchLinkId(this.linkId))
22280
+ );
22190
22281
  }
22191
22282
  };
22192
22283
  async function refreshDocxWebfonts(host) {
@@ -22195,6 +22286,18 @@ async function refreshDocxWebfonts(host) {
22195
22286
  await host.webfonts.prepare(doc, host.model);
22196
22287
  if (had && !host.webfonts.linked(doc)) host.shell.printLayout?.remeasure();
22197
22288
  }
22289
+ function fontDownloadOptions(webfonts) {
22290
+ const locked = fontDownloadLock(webfonts.option);
22291
+ return {
22292
+ allowFontDownloads: locked ?? readerAllowsFontDownloads(),
22293
+ fontDownloadsLocked: locked !== void 0
22294
+ };
22295
+ }
22296
+ function setFontDownloads(host, allow) {
22297
+ if (fontDownloadLock(host.webfonts.option) !== void 0) return;
22298
+ setReaderAllowsFontDownloads(allow);
22299
+ void refreshDocxWebfonts(host);
22300
+ }
22198
22301
 
22199
22302
  // src/docx/editor-core.ts
22200
22303
  var EditorCore = class {
@@ -26196,6 +26299,36 @@ function renderCustomizeRibbon(host, handlers, t) {
26196
26299
  host.replaceChildren(note, reset, ...sections);
26197
26300
  }
26198
26301
 
26302
+ // src/docx/backstage-trust.ts
26303
+ var FONT_DOWNLOADS_OPTION = "allowFontDownloads";
26304
+ var 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.";
26305
+ function trustCategory(context2, locked) {
26306
+ const { t } = context2;
26307
+ return {
26308
+ id: "trust",
26309
+ label: t("Trust Center"),
26310
+ description: t("Help keep your documents safe and secure."),
26311
+ sections: [
26312
+ {
26313
+ id: "trustSettings",
26314
+ title: t("Security settings"),
26315
+ description: t(
26316
+ "These settings help keep the content you open safe. We recommend the defaults."
26317
+ ),
26318
+ controls: [
26319
+ {
26320
+ kind: "toggle",
26321
+ key: FONT_DOWNLOADS_OPTION,
26322
+ label: t("Download fonts that are not installed or embedded (Google Fonts)"),
26323
+ info: t(FONT_DOWNLOADS_INFO),
26324
+ ...locked === void 0 ? {} : { disabled: t("This setting is managed by your organization") }
26325
+ }
26326
+ ]
26327
+ }
26328
+ ]
26329
+ };
26330
+ }
26331
+
26199
26332
  // src/docx/backstage-options.ts
26200
26333
  var LANGUAGES = [
26201
26334
  ["en", "English"],
@@ -26208,7 +26341,8 @@ var BOOLEAN_KEYS = [
26208
26341
  "spellCheck",
26209
26342
  "showRuler",
26210
26343
  "showMarks",
26211
- "showThumbnails"
26344
+ "showThumbnails",
26345
+ "allowFontDownloads"
26212
26346
  ];
26213
26347
  var KEYS = ["locale", "theme", "author", ...BOOLEAN_KEYS];
26214
26348
  function wordCategories(context2, current2) {
@@ -26298,7 +26432,10 @@ function wordCategories(context2, current2) {
26298
26432
  },
26299
26433
  unavailableCategory(context2, "qat"),
26300
26434
  unavailableCategory(context2, "addins"),
26301
- unavailableCategory(context2, "trust")
26435
+ current2.allowFontDownloads === void 0 ? unavailableCategory(context2, "trust") : trustCategory(
26436
+ context2,
26437
+ current2.fontDownloadsLocked ? current2.allowFontDownloads : void 0
26438
+ )
26302
26439
  ];
26303
26440
  }
26304
26441
  function dialogValues(current2) {
@@ -26332,10 +26469,9 @@ function createWordOptions(handlers, t) {
26332
26469
  element.defaults = {
26333
26470
  theme: "auto",
26334
26471
  ...Object.fromEntries(
26335
- BOOLEAN_KEYS.filter((key3) => current2[key3] !== void 0).map((key3) => [
26336
- key3,
26337
- key3 === "spellCheck"
26338
- ])
26472
+ BOOLEAN_KEYS.filter(
26473
+ (key3) => current2[key3] !== void 0 && !(key3 === "allowFontDownloads" && current2.fontDownloadsLocked)
26474
+ ).map((key3) => [key3, key3 === "spellCheck"])
26339
26475
  )
26340
26476
  };
26341
26477
  };
@@ -28792,10 +28928,12 @@ function createChrome(core, api) {
28792
28928
  spellCheck: core.view?.dom.spellcheck !== false,
28793
28929
  showRuler: Boolean(shell.canvas?.querySelector(".dve-ruler")),
28794
28930
  showMarks: shell.paper?.hasAttribute("data-show-marks") ?? false,
28795
- showThumbnails: core.viewOptions.showThumbnails
28931
+ showThumbnails: core.viewOptions.showThumbnails,
28932
+ ...fontDownloadOptions(core.webfonts)
28796
28933
  }),
28797
28934
  setOption: (key3, value) => {
28798
- if (key3 === "spellCheck") {
28935
+ if (key3 === "allowFontDownloads") setFontDownloads(core, value === "true");
28936
+ else if (key3 === "spellCheck") {
28799
28937
  if (core.view) core.view.dom.spellcheck = value === "true";
28800
28938
  core.refreshControls();
28801
28939
  } else if (key3 === "showThumbnails")
@@ -29319,7 +29457,9 @@ var DocxEditorApi = class extends HTMLElementBase {
29319
29457
  }
29320
29458
  /**
29321
29459
  * Webfonts for the document fonts the reader has neither installed nor embedded. Unset (the
29322
- * default) or `false`: off, nothing is requested. `{ baseUrl }`: such a family that the Google
29460
+ * default): the reader decides in File > Options > Trust Center (off until turned on; when on,
29461
+ * Google Fonts). `false`: off, nothing is requested. A set value locks that toggle, which then
29462
+ * shows it read-only. `{ baseUrl }`: such a family that the Google
29323
29463
  * Fonts catalogue serves, or its metric-compatible clone (Calibri as Carlito), is requested from
29324
29464
  * that CSS2 endpoint (`https://fonts.googleapis.com/css2`, or a self-hosted mirror) with only
29325
29465
  * the family names, and `load` waits briefly (150 ms) for the faces before showing the document. An
@@ -29651,6 +29791,7 @@ var DocxEditorElement = class extends DocxEditorApi {
29651
29791
  core.loading = true;
29652
29792
  core.refreshControls();
29653
29793
  try {
29794
+ core.webfonts.prefetch(this.ownerDocument, input);
29654
29795
  const session = await loadDocument(input);
29655
29796
  if (generation !== core.loadGeneration) return;
29656
29797
  await core.webfonts.prepare(this.ownerDocument, session.model);
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Who decides whether missing fonts are downloaded: the host's `googleFonts` value when it set
3
+ * one, otherwise the reader's Trust Center choice ("Download fonts that are not installed or
4
+ * embedded"). Shared by Word, Excel and Visio, whose Trust Center toggle is off until the reader
5
+ * turns it on (they made no network request before it existed); PowerPoint keeps its own policy
6
+ * (`pptx/render/options/font-download-policy.ts`), whose toggle starts on.
7
+ *
8
+ * @module fonts/font-download-policy
9
+ */
10
+ import { type GoogleFontsOption } from 'ooxml-core/text';
11
+ /** The Trust Center toggle's default for Word, Excel and Visio. */
12
+ export declare const FONT_DOWNLOADS_DEFAULT = false;
13
+ /**
14
+ * The option the product's webfont loader uses: the host's value when set, else Google Fonts when
15
+ * the reader allowed downloads and `false` when not.
16
+ */
17
+ export declare function effectiveFontDownloads(host: GoogleFontsOption | undefined, readerAllows: boolean): GoogleFontsOption;
18
+ /**
19
+ * How the host's value locks the Trust Center toggle: `undefined` when the host left it to the
20
+ * reader, otherwise the value the toggle shows read-only (on for a usable server, off for `false`
21
+ * or an invalid `baseUrl`, which fails closed).
22
+ */
23
+ export declare function fontDownloadLock(host: GoogleFontsOption | undefined): boolean | undefined;