Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(docs): undefined error when call permission query (#3841)

Ran Luod642327d5585
diff --git a/packages/engine-render/src/components/docs/layout/shaping-engine/font-library.ts b/packages/engine-render/src/components/docs/layout/shaping-engine/font-library.ts
index a165e674a9..19b4fb4441 100644
--- a/packages/engine-render/src/components/docs/layout/shaping-engine/font-library.ts
+++ b/packages/engine-render/src/components/docs/layout/shaping-engine/font-library.ts
@@ -203,19 +203,24 @@ function compareFontInfoDistance(a: FontDistance, b: FontDistance) {
async function checkLocalFontsPermission() {
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
- return;
+ return false;
}
if (typeof window === 'undefined') {
- return;
+ return false;
}
if (window.navigator == null || window.navigator?.permissions == null) {
return false;
}
- const status = await window.navigator.permissions.query({ name: 'local-fonts' as PermissionName });
+ try {
+ const status = await window.navigator.permissions.query({ name: 'local-fonts' as PermissionName });
- return status.state === 'granted';
+ return status.state === 'granted';
+ // eslint-disable-next-line unused-imports/no-unused-vars
+ } catch (_err) {
+ return false;
+ }
}
class FontLibrary {