From 3d24b0967e327cd661b4e2b538014bbf260926e7 Mon Sep 17 00:00:00 2001 From: icaparros-at-wiris Date: Thu, 11 Jan 2024 16:50:48 +0100 Subject: [PATCH] feat(viewer): add customheaders --- packages/viewer/src/app.ts | 2 +- packages/viewer/src/properties.ts | 45 +++++++++++++++++++------------ packages/viewer/src/services.ts | 13 ++++++--- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/packages/viewer/src/app.ts b/packages/viewer/src/app.ts index 922de3320..74bc9b903 100644 --- a/packages/viewer/src/app.ts +++ b/packages/viewer/src/app.ts @@ -23,7 +23,7 @@ main(window); */ async function main(w: Window): Promise { - const properties: Properties = await Properties.generate(); + const properties: Properties = await Properties.getInstance(); // Expose the globals to the browser if (!w.viewer) { diff --git a/packages/viewer/src/properties.ts b/packages/viewer/src/properties.ts index acc10c54d..691b608d2 100644 --- a/packages/viewer/src/properties.ts +++ b/packages/viewer/src/properties.ts @@ -1,4 +1,5 @@ import { configurationJson, StatusError } from './services'; +import Util from '@wiris/mathtype-html-integration-devkit/src/util'; // Helper types for Config below type Viewer = 'none' | 'image' | 'mathml' | 'latex'; @@ -13,6 +14,7 @@ export type Config = { backendConfig?: { wirispluginperformance?: Wirispluginperformance, wiriseditormathmlattribute?: string, + wiriscustomheaders?: object, }, dpi?: number, element?: string, @@ -29,7 +31,8 @@ const defaultValues: Config = { editorServicesExtension: '', backendConfig: { wirispluginperformance: 'true', - wiriseditormathmlattribute: 'data-mathml' + wiriseditormathmlattribute: 'data-mathml', + wiriscustomheaders: {}, }, dpi: 96, element: 'body', @@ -43,6 +46,8 @@ const defaultValues: Config = { */ export class Properties { + private static instance: Properties | null = null; + render: () => Promise = async () => {}; // Get URL properties (retrocompatibility). @@ -54,13 +59,18 @@ export class Properties { */ private new() {} + static getInstance(): Properties { + if (!Properties.instance) { + Properties.instance = new Properties(); + Properties.instance.initialize(); + } + return Properties.instance; + } + /** * Creates and sets up a new instance of class Properties */ - static async generate(): Promise { - - const instance = new Properties(); - + private async initialize(): Promise { // Get URL parameters from