@wiris/mathtype-viewer 1.2.0 → 1.2.1

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.
package/dist/app.d.ts CHANGED
@@ -1,2 +1,10 @@
1
- export {};
1
+ import { Properties } from './properties';
2
+ declare global {
3
+ interface Window {
4
+ viewer: {
5
+ properties: Properties;
6
+ isLoaded: boolean;
7
+ };
8
+ }
9
+ }
2
10
  //# sourceMappingURL=app.d.ts.map
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE;YACN,UAAU,EAAE,UAAU,CAAC;YACvB,QAAQ,EAAE,OAAO,CAAA;SAClB,CAAC;KACH;CACF"}
@@ -18,6 +18,7 @@ export declare class Properties {
18
18
  config: Config;
19
19
  private new;
20
20
  static generate(): Promise<Properties>;
21
+ private checkServices;
21
22
  get editorServicesRoot(): string;
22
23
  set editorServicesRoot(editorServicesRoot: string);
23
24
  get editorServicesExtension(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":"AAGA,aAAK,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AACpD,aAAK,sBAAsB,GAAG,MAAM,GAAG,OAAO,CAAC;AAK/C,oBAAY,MAAM,GAAG;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE;QACd,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;QAChD,0BAA0B,CAAC,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I,IAAI,MAAM,CAGjB;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,EAGpB;IAQD,IAAI,OAAO,IAAI,MAAM,CAGpB;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,EAG1B;IAQD,IAAI,sBAAsB,IAAI,sBAAsB,CAGnD;IAED,IAAI,sBAAsB,CAAC,sBAAsB,EAAE,sBAAsB,EAGxE;IAQD,IAAI,0BAA0B,IAAI,MAAM,CAGvC;IAED,IAAI,0BAA0B,CAAC,0BAA0B,EAAE,MAAM,EAGhE;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiris/mathtype-viewer",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "author": "Integrations",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@wiris/mathtype-html-integration-devkit": "1.14.0"
18
+ "@wiris/mathtype-html-integration-devkit": "1.14.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "babel-loader": "^9.1.2",
package/src/app.ts CHANGED
@@ -3,6 +3,15 @@ import { renderLatex } from './latex';
3
3
  import { renderMathML } from './mathml';
4
4
  import { bypassEncapsulation } from './retro';
5
5
 
6
+ declare global {
7
+ interface Window {
8
+ viewer: {
9
+ properties: Properties,
10
+ isLoaded: boolean
11
+ };
12
+ }
13
+ }
14
+
6
15
  // This should be the only code executed outside of a function
7
16
  // and the only code containing browser globals (e.g. window)
8
17
  // TODO try to set up the linter to check these two constraints
@@ -17,9 +26,12 @@ async function main(w: Window): Promise<void> {
17
26
  const properties: Properties = await Properties.generate();
18
27
 
19
28
  // Expose the globals to the browser
20
- (w as any).viewer = {
21
- properties,
22
- };
29
+ if (!w.viewer) {
30
+ w.viewer = {
31
+ properties,
32
+ isLoaded: false,
33
+ };
34
+ }
23
35
 
24
36
  const document = w.document;
25
37
 
@@ -40,6 +52,11 @@ async function main(w: Window): Promise<void> {
40
52
  // Initial function to call once document is loaded
41
53
  // Renders formulas and sets observer
42
54
  const start = async () => {
55
+ // Check if the viewer is alredy loaded
56
+ if (w.viewer.isLoaded) return;
57
+
58
+ w.viewer.isLoaded = true;
59
+
43
60
  // First render
44
61
  properties.render();
45
62
 
package/src/properties.ts CHANGED
@@ -66,7 +66,6 @@ export class Properties {
66
66
  const script: HTMLScriptElement = document.querySelector(`script[src*="${pluginName}"]`);
67
67
 
68
68
  if (!!script) {
69
-
70
69
  const pluginNamePosition: number = script.src.lastIndexOf(pluginName);
71
70
  const params: string = script.src.substring(pluginNamePosition + pluginName.length);
72
71
  const urlParams = new URLSearchParams(params);
@@ -86,9 +85,10 @@ export class Properties {
86
85
  if (urlParams.get('zoom') !== null && urlParams.get('zoom') !== undefined) {
87
86
  instance.config.zoom = +urlParams.get('zoom');
88
87
  }
89
-
90
88
  }
91
89
 
90
+ instance.checkServices();
91
+
92
92
  // Get backend parameters calling the configurationjson service
93
93
  try {
94
94
  instance.config.backendConfig = await configurationJson(
@@ -108,6 +108,24 @@ export class Properties {
108
108
  return instance;
109
109
  }
110
110
 
111
+ /**
112
+ * Check if is inside Integrations Services
113
+ * @deprecated This will be removed once the viewer uncouple from the integration services.
114
+ */
115
+ private checkServices(): void {
116
+ const path = ((document.currentScript as HTMLScriptElement).src);
117
+
118
+ if (path.includes('pluginwiris_engine')) {
119
+ // If the path includes pluginwiris_engine use Java Integrations Services
120
+ this.config.editorServicesRoot = path;
121
+ this.config.editorServicesExtension = '';
122
+ } else if (path.includes('integration/WIRISplugins')) {
123
+ // If the path includes 'integration/WIRISplugins' use PHP Integrations Services
124
+ this.config.editorServicesRoot = path;
125
+ this.config.editorServicesExtension = '.php';
126
+ }
127
+ }
128
+
111
129
  get editorServicesRoot(): string {
112
130
  return this.config.editorServicesRoot ||
113
131
  defaultValues.editorServicesRoot;