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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(engine-render): disable queryLocalFonts in Electron to prevent memory overflow (#5629)
白熱dd32c665e46d
diff --git a/packages/core/src/shared/tools.ts b/packages/core/src/shared/tools.tsindex 9316e77fd6..54a255bb31 100644--- a/packages/core/src/shared/tools.ts+++ b/packages/core/src/shared/tools.ts@@ -368,10 +368,6 @@ export class Tools {return false;}- static isBoolean(value?: any): value is boolean {- return this.getValueType(value) === '[object Boolean]';- }-static isPlainObject(value: any): value is object {if (!this.isDefine(value)) {return false;@@ -379,10 +375,6 @@ export class Tools {return Object.getPrototypeOf(value) === Object.getPrototypeOf({});}- static isFunction(value?: any): value is boolean {- return this.getValueType(value) === '[object Function]';- }-static isDate(value?: Date): value is Date {return this.getValueType(value) === '[object Date]';}@@ -419,32 +411,10 @@ export class Tools {return true;}- static isMobile(): boolean {- let clientWidth = 0;- let clientHeight = 0;- if (document.body.clientWidth) {- clientWidth = document.body.clientWidth;- }- if (document.body.clientHeight) {- clientHeight = document.body.clientHeight;- }- return this.isAndroid() || this.isIPhone() || this.isTablet() || (clientWidth < 350 && clientHeight < 500);- }-static isTablet(): boolean {return /ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase());}- static isWeChat(): boolean {- const userAgent = navigator.userAgent.toLowerCase();- return String(userAgent.match(/MicroMessenger/i)) === 'micromessenger' ? !0 : !1;- }-- static isAndroid(): boolean {- const userAgent = navigator.userAgent;- return userAgent.indexOf('Android') > -1 || userAgent.indexOf('Linux') > -1;- }-static isIPhone(): boolean {return /iPhone/i.test(navigator.userAgent);}@@ -461,40 +431,6 @@ export class Tools {return [...topLevelDomainSet].join('|');}- static itCount(count: number): Function {- return (callback: Function) => {- for (let i = 0; i < count; i++) {- callback && callback();- }- };- }-- static hasLength(target: IArguments | any[] | string, length?: number): boolean {- if (Tools.isDefine(target)) {- if (Tools.isDefine(length)) {- return target.length === length;- }- return target.length > 0;- }- return false;- }-- static capitalize(str: string) {- return str.charAt(0).toUpperCase() + str.slice(1);- }-- // Used by camelCase as callback to replace()- static fCamelCase(_all: any, letter: string) {- return letter.toUpperCase();- }-- // Convert dashed to camelCase; used by the css and data modules- // Support: IE <=9 - 11, Edge 12 - 15- // Microsoft forgot to hump their vendor prefix (#9572)- static camelCase(str: string) {- return str.replace(rmsPrefix, 'ms-').replace(rDashAlpha, this.fCamelCase);- }-/*** remove all null from object* @param obj@@ -554,17 +490,12 @@ export class Tools {}/**- ** Column subscript letter to number*- * @privateRemarks- * zh: 列下标 字母转数字- ** @param a - Column subscript letter,e.g.,"A1"* @returns Column subscript number,e.g.,0**/-static ABCatNum(a: string): number {if (a == null || a.length === 0) {return Number.NaN;@@ -585,9 +516,7 @@ export class Tools {}/**- * en: Column subscript number to letter- *- * zh: 列下标 数字转字母+ * Column subscript number to letter** @param n Column subscript number,e.g.,0* @returns Column subscript letter,e.g.,"A1"@@ -610,16 +539,6 @@ export class Tools {return s.toUpperCase();}- static randSort<T>(arr: T[]) {- for (let i = 0, len = arr.length; i < len; i++) {- const rand = Number.parseInt((Math.random() * len).toString());- const temp = arr[rand];- arr[rand] = arr[i];- arr[i] = temp;- }- return arr;- }-/*** extend two objects* @param originJson@@ -644,26 +563,6 @@ export class Tools {return resultJsonObject as unknown as T;}- static commonExtend1<T>(originJson: IKeyValue, extendJson: IKeyValue): T {- for (const attr in originJson) {- if (extendJson[attr] == null) {- extendJson[attr] = originJson[attr];- }- }- return extendJson as unknown as T;- }-- static arrayToObject(array: IKeyValue[][]) {- const obj: IKeyValue = {};- array.forEach((row, i) => {- obj[i] = {};- row.forEach((column, j) => {- obj[i][j] = column;- });- });- return obj;- }-static hasIntersectionBetweenTwoRanges(range1Start: number,range1End: number,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.tsindex 6f198f9a17..f010598b9e 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@@ -233,22 +233,23 @@ class FontLibrary {}private async _loadFontsToBook() {- if (this.isReady) {- return;- }+ if (this.isReady) return;const permissionStatus = await checkLocalFontsPermission();-- if (!permissionStatus) {+ if (!permissionStatus || !('queryLocalFonts' in window)) {return;}- if (!('queryLocalFonts' in window)) {+ // If running in Electron, we should not use the Local Font Access API+ if (typeof navigator === 'object' && navigator.userAgent.includes('Electron')) {return;}try {- const availableFonts = await (window as any).queryLocalFonts();+ // @ts-expect-error queryLocalFonts is an experimental API and may not be available in all environments.+ const availableFonts = await window.queryLocalFonts({+ postscriptNames: [],+ });for (const font of availableFonts) {const { family, style } = font;