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.
- package/dist/react/index.mjs +34 -34
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -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:
|
|
6
|
-
x2tPath:
|
|
5
|
+
assetsPath: R,
|
|
6
|
+
x2tPath: S = "/x2t-1",
|
|
7
7
|
file: y,
|
|
8
8
|
fileUrl: v,
|
|
9
|
-
newDocument:
|
|
10
|
-
language:
|
|
11
|
-
theme:
|
|
12
|
-
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:
|
|
18
|
-
className:
|
|
17
|
+
style: A,
|
|
18
|
+
className: P
|
|
19
19
|
}) {
|
|
20
|
-
const d = X(!1), 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:
|
|
28
|
-
y ? n.open(y) : v ? n.openUrl(v) :
|
|
29
|
-
const s = n.getDocument(),
|
|
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
|
|
32
|
-
l.on("connect",
|
|
33
|
-
const
|
|
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
|
|
40
|
-
|
|
39
|
+
const T = $(o.XMLHttpRequest), O = o.Worker;
|
|
40
|
+
T.use((m) => n.handleRequest(m)), Object.assign(o, {
|
|
41
41
|
io: B,
|
|
42
|
-
XMLHttpRequest:
|
|
42
|
+
XMLHttpRequest: T,
|
|
43
43
|
Worker: function(m, W) {
|
|
44
|
-
return new
|
|
44
|
+
return new O(new URL(m, a).href, W);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
},
|
|
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:
|
|
66
|
+
documentType: H,
|
|
67
67
|
editorConfig: {
|
|
68
|
-
lang:
|
|
68
|
+
lang: q,
|
|
69
69
|
coEditing: { mode: "fast", change: !1 },
|
|
70
|
-
user: { ...
|
|
70
|
+
user: { ...D },
|
|
71
71
|
customization: {
|
|
72
|
-
uiTheme:
|
|
72
|
+
uiTheme: x,
|
|
73
73
|
features: { spellcheck: { change: !1 } }
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
events: {
|
|
77
|
-
onAppReady: () =>
|
|
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
|
-
|
|
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 = () =>
|
|
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",
|
|
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
|
|
107
|
-
return /* @__PURE__ */ w("div", { style: { width: "100%", height: "100%", ...
|
|
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:
|
|
112
|
-
srcDoc:
|
|
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.
|
|
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",
|