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/dist/xlsx.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { statusLayout, watchStatusWidth, defineChartExOptions } from './chunk-II43ALTT.js';
2
2
  import { trackPointerGesture } from './chunk-GSXOZCAN.js';
3
- import { attachShareDialog, syncGoogleWebfontStylesheet, prepareWebfonts, chartExSpaceFormatSource, connectedServicesLabels } from './chunk-NH33G6LA.js';
4
- import './chunk-HNSFEOSG.js';
3
+ import { attachShareDialog, effectiveFontDownloads, fontDownloadLock, syncGoogleWebfontStylesheet, prefetchWebfonts, prepareWebfonts, chartExSpaceFormatSource, FONT_DOWNLOADS_DEFAULT, connectedServicesLabels } from './chunk-G5CALQUW.js';
4
+ import './chunk-J3ROBM74.js';
5
5
  import './chunk-DA57FPSN.js';
6
6
  import { createHostBackstagePages, syncRibbonAddIns, withHostMenuItems } from './chunk-ZTLP52FH.js';
7
7
  export { RIBBON_ADD_IN_EVENT } from './chunk-ZTLP52FH.js';
8
8
  import { needsPicturePixels, pictureSvg, pictureEffectFilter, SmartArtTextPaneController, defineSmartArt, defineSmartArtPicker, smartArtStylesGalleryState, smartArtColorsGalleryState, safeColor, svgTile } from './chunk-6FFZFH73.js';
9
- import { withExtension, saveExtension, downloadBytes, emit, emitEvent, blobFor, announceFileCommand, pickFile } from './chunk-6G6KERIZ.js';
10
- export { XLSX_EDITOR_EVENTS } from './chunk-6G6KERIZ.js';
9
+ import { withExtension, saveExtension, downloadBytes, emit, emitEvent, blobFor, announceFileCommand, pickFile } from './chunk-MUY444GW.js';
10
+ export { XLSX_EDITOR_EVENTS } from './chunk-MUY444GW.js';
11
11
  import './chunk-4ZSZPUE5.js';
12
12
  import './chunk-CDAXY5KC.js';
13
13
  import './chunk-NDUD5JJB.js';
@@ -895,6 +895,37 @@ function renderCustomizeRibbon(pane, host) {
895
895
  pane.replaceChildren(note, reset, ...sections);
896
896
  }
897
897
 
898
+ // src/xlsx/backstage/options-trust.ts
899
+ var FONT_DOWNLOADS_OPTION = "allowFontDownloads";
900
+ function trustCategory(context, locked) {
901
+ const { t } = context;
902
+ return {
903
+ id: "trust",
904
+ label: t("Trust Center"),
905
+ description: t("Help keep your documents safe and secure."),
906
+ sections: [
907
+ {
908
+ id: "trustSettings",
909
+ title: t("Security settings"),
910
+ description: t(
911
+ "These settings help keep the content you open safe. We recommend the defaults."
912
+ ),
913
+ controls: [
914
+ {
915
+ kind: "toggle",
916
+ key: FONT_DOWNLOADS_OPTION,
917
+ label: t("Download fonts that are not installed or embedded (Google Fonts)"),
918
+ info: t(
919
+ "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 Excel."
920
+ ),
921
+ ...locked ? { disabled: t("This setting is managed by your organization") } : {}
922
+ }
923
+ ]
924
+ }
925
+ ]
926
+ };
927
+ }
928
+
898
929
  // src/xlsx/backstage/options-dialog.ts
899
930
  var LANGUAGES = [
900
931
  ["en", "English"],
@@ -917,7 +948,7 @@ var RULE_LABELS = {
917
948
  };
918
949
  var ruleKey = (rule2) => "rule:" + rule2;
919
950
  var ITERATION_KEYS = ["iterate", "iterationCount", "iterationDelta"];
920
- function excelCategories(context) {
951
+ function excelCategories(context, host) {
921
952
  const { t } = context;
922
953
  return [
923
954
  {
@@ -1057,7 +1088,7 @@ function excelCategories(context) {
1057
1088
  },
1058
1089
  unavailableCategory(context, "qat"),
1059
1090
  unavailableCategory(context, "addins"),
1060
- unavailableCategory(context, "trust")
1091
+ trustCategory(context, host.options().fontDownloadsLocked === true)
1061
1092
  ];
1062
1093
  }
1063
1094
  function dialogValues(host) {
@@ -1070,6 +1101,7 @@ function dialogValues(host) {
1070
1101
  iterate: Boolean(current.iteration),
1071
1102
  iterationCount: current.iteration?.count ?? DEFAULT_ITERATIONS,
1072
1103
  iterationDelta: current.iteration?.delta ?? DEFAULT_MAX_CHANGE,
1104
+ [FONT_DOWNLOADS_OPTION]: current.allowFontDownloads ?? FONT_DOWNLOADS_DEFAULT,
1073
1105
  ...Object.fromEntries(
1074
1106
  ERROR_RULES.map((rule2) => [ruleKey(rule2), auditState(host.ctx).rules.includes(rule2)])
1075
1107
  )
@@ -1096,7 +1128,7 @@ function createExcelOptions(host) {
1096
1128
  const build = () => {
1097
1129
  element.setAttribute("heading", ctx.t("Options"));
1098
1130
  element.labels = optionsLabels(context);
1099
- element.categories = excelCategories(context);
1131
+ element.categories = excelCategories(context, host);
1100
1132
  element.values = dialogValues(host);
1101
1133
  element.defaults = {
1102
1134
  theme: "auto",
@@ -1104,6 +1136,8 @@ function createExcelOptions(host) {
1104
1136
  iterate: false,
1105
1137
  iterationCount: DEFAULT_ITERATIONS,
1106
1138
  iterationDelta: DEFAULT_MAX_CHANGE,
1139
+ // A host-locked toggle keeps the host's value.
1140
+ [FONT_DOWNLOADS_OPTION]: host.options().fontDownloadsLocked === true ? host.options().allowFontDownloads === true : FONT_DOWNLOADS_DEFAULT,
1107
1141
  ...Object.fromEntries(
1108
1142
  ERROR_RULES.map((rule2) => [ruleKey(rule2), rule2 !== "empty-cell-reference"])
1109
1143
  )
@@ -1120,6 +1154,8 @@ function createExcelOptions(host) {
1120
1154
  );
1121
1155
  if (changed.some((key) => ITERATION_KEYS.includes(key)))
1122
1156
  host.setOption("iteration", iterationOf(values));
1157
+ if (changed.includes(FONT_DOWNLOADS_OPTION) && host.options().fontDownloadsLocked !== true)
1158
+ host.setOption("allowFontDownloads", values[FONT_DOWNLOADS_OPTION] === true);
1123
1159
  build();
1124
1160
  });
1125
1161
  element.addEventListener("office-options-cancel", () => {
@@ -1775,6 +1811,7 @@ async function loadInto(core, bytes, fileName, chrome, cloud) {
1775
1811
  core.loading = true;
1776
1812
  core.requestRender();
1777
1813
  try {
1814
+ core.webfonts.prefetch(bytes);
1778
1815
  const { loadWorkbook, isOoxmlCryptoError } = await import('ooxml-core/xlsx/load');
1779
1816
  let password;
1780
1817
  let workbook;
@@ -21644,10 +21681,17 @@ function buildShell(core) {
21644
21681
  theme: core.theme,
21645
21682
  author: core.authorName,
21646
21683
  calculation: core.calculation,
21647
- iteration: core.iteration
21684
+ iteration: core.iteration,
21685
+ allowFontDownloads: core.webfonts.allowed(),
21686
+ fontDownloadsLocked: core.webfonts.lock() !== void 0
21648
21687
  }),
21649
21688
  setOption(key, raw) {
21650
21689
  if (key === "iteration") return core.setIterativeCalculation(raw);
21690
+ if (key === "allowFontDownloads") {
21691
+ if (core.webfonts.lock() === void 0) core.webfonts.setReaderAllows(raw === true);
21692
+ return;
21693
+ }
21694
+ if (key === "fontDownloadsLocked") return;
21651
21695
  const value = String(raw);
21652
21696
  if (key === "locale") element.locale = value;
21653
21697
  else if (key === "theme")
@@ -21966,6 +22010,28 @@ var CalcPreparation = class {
21966
22010
  else this.next();
21967
22011
  }
21968
22012
  };
22013
+
22014
+ // src/xlsx/font-downloads.ts
22015
+ var FONT_DOWNLOADS_KEY = "ooxml.xlsx.allowFontDownloads";
22016
+ var memory2;
22017
+ function readerAllowsFontDownloads() {
22018
+ try {
22019
+ const raw = globalThis.localStorage?.getItem(FONT_DOWNLOADS_KEY);
22020
+ if (raw === "true") return true;
22021
+ if (raw === "false") return false;
22022
+ } catch {
22023
+ }
22024
+ return memory2 ?? FONT_DOWNLOADS_DEFAULT;
22025
+ }
22026
+ function setReaderAllowsFontDownloads(allow) {
22027
+ memory2 = allow;
22028
+ try {
22029
+ globalThis.localStorage?.setItem(FONT_DOWNLOADS_KEY, String(allow));
22030
+ } catch {
22031
+ }
22032
+ }
22033
+
22034
+ // src/xlsx/webfonts.ts
21969
22035
  var XLSX_WEBFONT_LINK_ID = "xlsx-editor-webfonts";
21970
22036
  var OFF = { href: null, families: [], unavailable: [], timedOut: false };
21971
22037
  var instances = 0;
@@ -21984,9 +22050,52 @@ var XlsxWebfonts = class {
21984
22050
  instances += 1;
21985
22051
  this.linkId = instances === 1 ? XLSX_WEBFONT_LINK_ID : `${XLSX_WEBFONT_LINK_ID}-${instances}`;
21986
22052
  }
22053
+ /** The option the loader uses: the host's value when set, else the reader's choice. */
22054
+ effective() {
22055
+ return effectiveFontDownloads(this.option, readerAllowsFontDownloads());
22056
+ }
22057
+ /** The value the Trust Center toggle shows read-only, or `undefined` when the reader decides. */
22058
+ lock() {
22059
+ return fontDownloadLock(this.option);
22060
+ }
22061
+ /** Whether the Trust Center toggle is on: the host's locked value, else the reader's choice. */
22062
+ allowed() {
22063
+ return this.lock() ?? readerAllowsFontDownloads();
22064
+ }
22065
+ /** The reader's Trust Center choice: stored, and applied to the open workbook at once. */
22066
+ setReaderAllows(allow) {
22067
+ setReaderAllowsFontDownloads(allow);
22068
+ this.apply();
22069
+ }
21987
22070
  /** The CSS2 base the option requests, or `null` when the fallback is off (the default). */
21988
22071
  base() {
21989
- return resolveGoogleFontsCss2Base(this.option, null, "xlsx-editor");
22072
+ return resolveGoogleFontsCss2Base(this.effective(), null, "xlsx-editor");
22073
+ }
22074
+ /**
22075
+ * After the host value or the reader's choice changed: on, prepare the open workbook's faces
22076
+ * and measure again; off, remove the stylesheets and repaint with installed or substitute fonts.
22077
+ */
22078
+ apply() {
22079
+ if (this.base() !== null) {
22080
+ this.shown(this.#owner.workbook());
22081
+ return;
22082
+ }
22083
+ this.#off(this.#owner.host.ownerDocument);
22084
+ this.schedule();
22085
+ }
22086
+ /** Removes this editor's links and forgets the waits they served. */
22087
+ #off(doc) {
22088
+ syncGoogleWebfontStylesheet(doc, this.linkId, null);
22089
+ this.#prepared = /* @__PURE__ */ new WeakMap();
22090
+ }
22091
+ /**
22092
+ * Start downloading the faces the file declares before it is parsed (see `prefetchWebfonts`),
22093
+ * so they are usually ready when {@link prepare} waits. Never throws.
22094
+ */
22095
+ prefetch(bytes) {
22096
+ const doc = this.#owner.host.ownerDocument;
22097
+ if (!doc?.head) return;
22098
+ prefetchWebfonts({ document: doc, linkId: this.linkId, bytes, base: this.base() });
21990
22099
  }
21991
22100
  /**
21992
22101
  * Injects the stylesheet for the workbook's missing fonts and waits (bounded) for their faces.
@@ -21996,7 +22105,7 @@ var XlsxWebfonts = class {
21996
22105
  const doc = this.#owner.host.ownerDocument;
21997
22106
  const base = this.base();
21998
22107
  if (base === null) {
21999
- syncGoogleWebfontStylesheet(doc, this.linkId, null);
22108
+ this.#off(doc);
22000
22109
  return Promise.resolve(OFF);
22001
22110
  }
22002
22111
  const cached = this.#prepared.get(workbook);
@@ -22020,8 +22129,7 @@ var XlsxWebfonts = class {
22020
22129
  */
22021
22130
  shown(workbook) {
22022
22131
  if (!workbook) {
22023
- if (this.base() === null)
22024
- syncGoogleWebfontStylesheet(this.#owner.host.ownerDocument, this.linkId, null);
22132
+ if (this.base() === null) this.#off(this.#owner.host.ownerDocument);
22025
22133
  return;
22026
22134
  }
22027
22135
  const waited = this.#prepared.get(workbook);
@@ -22854,20 +22962,22 @@ var XlsxEditorApi = class extends HTMLElementBase {
22854
22962
  }
22855
22963
  /**
22856
22964
  * Webfont fallback for workbook fonts the reader has neither installed nor embedded. Unset (the
22857
- * default) or `false`: off, no request leaves the page and text uses installed or fallback
22858
- * fonts. `{ baseUrl }`: the fonts the workbook uses that the bundled Google Fonts catalogue
22859
- * serves (or their metric-compatible clone, such as Carlito for Calibri) are requested from that
22860
- * CSS2 endpoint (`https://fonts.googleapis.com/css2` for Google, or a self-hosted mirror) with
22861
- * one `<link>` in the document head, and the font files it names are then downloaded. Only
22862
- * public catalogue family names are sent, never cell text; an invalid `baseUrl` warns and stays
22863
- * off. Read when a workbook is shown; changing it applies to the open workbook.
22965
+ * default): the reader decides with File > Options > Trust Center > "Download fonts that are
22966
+ * not installed or embedded", which is off until they turn it on. Set, it is the host's
22967
+ * decision and that toggle is shown read-only: `false` is off (no request leaves the page;
22968
+ * text uses installed or substitute fonts), `{ baseUrl }` requests the fonts the workbook uses
22969
+ * that the bundled Google Fonts catalogue serves (or their metric-compatible clone, such as
22970
+ * Carlito for Calibri) from that CSS2 endpoint (`https://fonts.googleapis.com/css2` for Google,
22971
+ * or a self-hosted mirror) with one `<link>` in the document head, then the font files it
22972
+ * names. Only public catalogue family names are sent, never cell text; an invalid `baseUrl`
22973
+ * warns and stays off. Changing it applies to the open workbook.
22864
22974
  */
22865
22975
  get googleFonts() {
22866
22976
  return this.core.webfonts.option;
22867
22977
  }
22868
22978
  set googleFonts(value) {
22869
22979
  this.core.webfonts.option = value ?? void 0;
22870
- this.core.webfonts.shown(this.core.workbook);
22980
+ this.core.webfonts.apply();
22871
22981
  }
22872
22982
  get loading() {
22873
22983
  return this.core.loading;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-ui",
3
- "version": "1.46.0",
3
+ "version": "1.48.0",
4
4
  "description": "Shared, format-neutral web components and styles for the Office viewers (Word, PowerPoint, Excel)",
5
5
  "keywords": [
6
6
  "custom-elements",
@@ -176,7 +176,7 @@
176
176
  "dompurify": "^3.4.17",
177
177
  "emf-converter": "4.25.3",
178
178
  "lit": "^3.3.3",
179
- "ooxml-core": "^1.43.0",
179
+ "ooxml-core": "^1.48.0",
180
180
  "opentype.js": "^2.0.0",
181
181
  "prosemirror-collab": "^1.3.1",
182
182
  "prosemirror-commands": "^1.7.2",
File without changes