wasm-onlyoffice-sdk 0.1.4 → 0.1.5

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.
@@ -2,51 +2,51 @@ import { jsx as w } from "react/jsx-runtime";
2
2
  import { useRef as X, useEffect as j, useLayoutEffect as F } from "react";
3
3
  import { EditorServer as M, getDocumentType as N, MockSocket as l, createXHRProxy as $, io as B } from "../index.mjs";
4
4
  function J({
5
- assetsPath: S,
6
- x2tPath: q = "/x2t-1",
5
+ assetsPath: R,
6
+ x2tPath: S = "/x2t-1",
7
7
  file: y,
8
8
  fileUrl: v,
9
- newDocument: D,
10
- language: x = "en",
11
- theme: A = "theme-light",
12
- user: b = { id: "uid", name: "User" },
9
+ newDocument: g,
10
+ language: q = "en",
11
+ theme: x = "theme-light",
12
+ user: D = { id: "uid", name: "User" },
13
13
  onReady: p,
14
14
  onDocumentStateChange: u,
15
15
  onSave: z,
16
16
  onError: t,
17
- style: P,
18
- className: R
17
+ style: A,
18
+ className: P
19
19
  }) {
20
- const d = X(!1), r = S.replace(/\/$/, ""), f = /^https?:\/\//.test(r);
20
+ const d = X(!1), r = R.replace(/\/$/, ""), f = /^https?:\/\//.test(r);
21
21
  j(() => {
22
22
  const c = (a) => {
23
23
  d.current && (a.preventDefault(), a.returnValue = "");
24
24
  };
25
25
  return window.addEventListener("beforeunload", c), () => window.removeEventListener("beforeunload", c);
26
26
  }, []), F(() => {
27
- const c = r + "/web-apps/apps/api/documents/api.js", a = f ? r + "/web-apps/apps/api/documents/" : location.origin, n = new M({ x2tPath: q, user: b });
28
- y ? n.open(y) : v ? n.openUrl(v) : D ? n.openNew(D) : n.openNew("docx");
29
- const s = n.getDocument(), I = N(s.fileType);
27
+ const c = r + "/web-apps/apps/api/documents/api.js", a = f ? r + "/web-apps/apps/api/documents/" : location.origin, n = new M({ x2tPath: S, user: D });
28
+ y ? n.open(y) : v ? n.openUrl(v) : g ? n.openNew(g) : n.openNew("docx");
29
+ const s = n.getDocument(), H = N(s.fileType);
30
30
  let i = null;
31
- const g = ({ socket: e }) => n.handleConnect({ socket: e }), k = ({ socket: e }) => n.handleDisconnect({ socket: e });
32
- l.on("connect", g), l.on("disconnect", k);
33
- const O = () => {
31
+ const b = ({ socket: e }) => n.handleConnect({ socket: e }), k = ({ socket: e }) => n.handleDisconnect({ socket: e });
32
+ l.on("connect", b), l.on("disconnect", k);
33
+ const I = () => {
34
34
  const e = document.querySelector('iframe[name="frameEditor"]'), o = e == null ? void 0 : e.contentWindow, h = e == null ? void 0 : e.contentDocument;
35
35
  if (!h || !o) {
36
36
  t == null || t(new Error("Iframe not loaded"));
37
37
  return;
38
38
  }
39
- const E = $(o.XMLHttpRequest), U = o.Worker;
40
- E.use((m) => n.handleRequest(m)), Object.assign(o, {
39
+ const T = $(o.XMLHttpRequest), O = o.Worker;
40
+ T.use((m) => n.handleRequest(m)), Object.assign(o, {
41
41
  io: B,
42
- XMLHttpRequest: E,
42
+ XMLHttpRequest: T,
43
43
  Worker: function(m, W) {
44
- return new U(new URL(m, a).href, W);
44
+ return new O(new URL(m, a).href, W);
45
45
  }
46
46
  });
47
- const L = h.createElement("script");
48
- L.src = c, h.body.appendChild(L), p == null || p();
49
- }, T = () => {
47
+ const E = h.createElement("script");
48
+ E.src = new URL(c, location.origin).href, h.body.appendChild(E), p == null || p();
49
+ }, L = () => {
50
50
  i = new window.DocsAPI.DocEditor("placeholder", {
51
51
  isLocalFile: !0,
52
52
  document: {
@@ -63,18 +63,18 @@ function J({
63
63
  print: !1
64
64
  }
65
65
  },
66
- documentType: I,
66
+ documentType: H,
67
67
  editorConfig: {
68
- lang: x,
68
+ lang: q,
69
69
  coEditing: { mode: "fast", change: !1 },
70
- user: { ...b },
70
+ user: { ...D },
71
71
  customization: {
72
- uiTheme: A,
72
+ uiTheme: x,
73
73
  features: { spellcheck: { change: !1 } }
74
74
  }
75
75
  },
76
76
  events: {
77
- onAppReady: () => O(),
77
+ onAppReady: () => I(),
78
78
  onDocumentStateChange: (e) => {
79
79
  e.data && (d.current = !0), u == null || u(e.data);
80
80
  },
@@ -93,23 +93,23 @@ function J({
93
93
  return (() => {
94
94
  var o;
95
95
  if ((o = window.DocsAPI) != null && o.DocEditor) {
96
- T();
96
+ L();
97
97
  return;
98
98
  }
99
99
  let e = document.querySelector(`script[src="${c}"]`);
100
- e || (e = document.createElement("script"), e.src = c, document.head.appendChild(e)), e.onload = () => T(), e.onerror = () => t == null ? void 0 : t(new Error("Failed to load DocsAPI script"));
100
+ e || (e = document.createElement("script"), e.src = c, document.head.appendChild(e)), e.onload = () => L(), e.onerror = () => t == null ? void 0 : t(new Error("Failed to load DocsAPI script"));
101
101
  })(), () => {
102
102
  var e;
103
- l.off("connect", g), l.off("disconnect", k), (e = i == null ? void 0 : i.destroyEditor) == null || e.call(i), n.destroy();
103
+ l.off("connect", b), l.off("disconnect", k), (e = i == null ? void 0 : i.destroyEditor) == null || e.call(i), n.destroy();
104
104
  };
105
105
  }, []);
106
- const C = f ? void 0 : r + "/web-apps/apps/api/documents/preload.html", H = f ? `<!DOCTYPE html><html><head><base href="${r}/web-apps/apps/api/documents/"></head><body></body></html>` : void 0;
107
- return /* @__PURE__ */ w("div", { style: { width: "100%", height: "100%", ...P }, className: R, children: /* @__PURE__ */ w("div", { id: "placeholder", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ w(
106
+ const U = f ? void 0 : r + "/web-apps/apps/api/documents/preload.html", C = f ? `<!DOCTYPE html><html><head><base href="${r}/web-apps/apps/api/documents/"></head><body></body></html>` : void 0;
107
+ return /* @__PURE__ */ w("div", { style: { width: "100%", height: "100%", ...A }, className: P, children: /* @__PURE__ */ w("div", { id: "placeholder", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ w(
108
108
  "iframe",
109
109
  {
110
110
  style: { width: 0, height: 0, display: "none" },
111
- src: C,
112
- srcDoc: H
111
+ src: U,
112
+ srcDoc: C
113
113
  }
114
114
  ) }) });
115
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasm-onlyoffice-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Offline OnlyOffice document editor SDK for React and Vue, powered by WebAssembly",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "homepage": "https://github.com/oonxt/wasm-onlyoffice-sdk#readme",