@vizel/react 1.0.0 → 1.1.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/README.md +38 -14
- package/dist/index.d.ts +246 -22
- package/dist/index.js +59 -51
- package/dist/index10.js +42 -40
- package/dist/index13.js +1 -1
- package/dist/index14.js +4 -4
- package/dist/index16.js +1 -1
- package/dist/index19.js +1 -1
- package/dist/index2.js +1 -1
- package/dist/index20.js +152 -8
- package/dist/index21.js +8 -10
- package/dist/index22.js +10 -78
- package/dist/index23.js +75 -112
- package/dist/index24.js +112 -32
- package/dist/index25.js +35 -5
- package/dist/index26.js +5 -68
- package/dist/index27.js +65 -88
- package/dist/index28.js +91 -4
- package/dist/index29.js +4 -36
- package/dist/index30.js +34 -51
- package/dist/index31.js +52 -11
- package/dist/index32.js +11 -24
- package/dist/index33.js +24 -29
- package/dist/index34.js +30 -4
- package/dist/index35.js +4 -33
- package/dist/index36.js +31 -48
- package/dist/index37.js +50 -37
- package/dist/index38.js +48 -7
- package/dist/index39.js +69 -50
- package/dist/index40.js +45 -11
- package/dist/index41.js +8 -15
- package/dist/index42.js +53 -3
- package/dist/index43.js +11 -20
- package/dist/index44.js +54 -2
- package/dist/index45.js +15 -9742
- package/dist/index46.js +3 -17016
- package/dist/index47.js +21 -2
- package/dist/index48.js +2 -8
- package/dist/index49.js +9742 -2
- package/dist/index50.js +17016 -2
- package/dist/index51.js +2 -222
- package/dist/index52.js +7 -224
- package/dist/index53.js +2 -2
- package/dist/index54.js +2 -2
- package/dist/index55.js +224 -0
- package/dist/index56.js +227 -0
- package/dist/index57.js +4 -0
- package/dist/index58.js +4 -0
- package/package.json +16 -26
package/dist/index39.js
CHANGED
|
@@ -1,55 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
t.current
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import { VIZEL_DEFAULT_COMMENT_OPTIONS as d, createVizelCommentHandlers as k } from "@vizel/core";
|
|
2
|
+
import { useRef as v, useState as E, useCallback as n, useMemo as S, useEffect as h } from "react";
|
|
3
|
+
function V(s, m = {}) {
|
|
4
|
+
const t = v(m);
|
|
5
|
+
t.current = m;
|
|
6
|
+
const c = m.enabled ?? d.enabled, C = m.storage ?? d.storage, l = m.key ?? d.key, [a, f] = E({
|
|
7
|
+
comments: [],
|
|
8
|
+
activeCommentId: null,
|
|
9
|
+
isLoading: !1,
|
|
10
|
+
error: null
|
|
11
|
+
}), u = v(s);
|
|
12
|
+
u.current = s;
|
|
13
|
+
const i = n((e) => {
|
|
14
|
+
f((r) => ({ ...r, ...e }));
|
|
15
|
+
}, []), o = S(
|
|
16
|
+
() => k(
|
|
17
|
+
() => u.current(),
|
|
18
|
+
{
|
|
19
|
+
enabled: c,
|
|
20
|
+
storage: C,
|
|
21
|
+
key: l,
|
|
22
|
+
onAdd: (e) => t.current.onAdd?.(e),
|
|
23
|
+
onRemove: (e) => t.current.onRemove?.(e),
|
|
24
|
+
onResolve: (e) => t.current.onResolve?.(e),
|
|
25
|
+
onReopen: (e) => t.current.onReopen?.(e),
|
|
26
|
+
onError: (e) => t.current.onError?.(e)
|
|
27
|
+
},
|
|
28
|
+
i
|
|
29
|
+
),
|
|
30
|
+
[c, C, l, i]
|
|
31
|
+
);
|
|
32
|
+
h(() => {
|
|
33
|
+
s() && c && o.loadComments();
|
|
34
|
+
}, [s, c, o]);
|
|
35
|
+
const R = n(
|
|
36
|
+
(e, r) => o.addComment(e, r),
|
|
37
|
+
[o]
|
|
38
|
+
), g = n(
|
|
39
|
+
(e) => o.removeComment(e),
|
|
40
|
+
[o]
|
|
41
|
+
), y = n(
|
|
42
|
+
(e) => o.resolveComment(e),
|
|
43
|
+
[o]
|
|
44
|
+
), I = n(
|
|
45
|
+
(e) => o.reopenComment(e),
|
|
46
|
+
[o]
|
|
47
|
+
), p = n(
|
|
48
|
+
(e, r, b) => o.replyToComment(e, r, b),
|
|
49
|
+
[o]
|
|
50
|
+
), A = n(
|
|
51
|
+
(e) => o.setActiveComment(e),
|
|
52
|
+
[o]
|
|
53
|
+
), L = n(() => o.loadComments(), [o]), T = n(
|
|
54
|
+
(e) => o.getCommentById(e),
|
|
55
|
+
[o]
|
|
56
|
+
);
|
|
46
57
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
comments: a.comments,
|
|
59
|
+
activeCommentId: a.activeCommentId,
|
|
60
|
+
isLoading: a.isLoading,
|
|
61
|
+
error: a.error,
|
|
62
|
+
addComment: R,
|
|
63
|
+
removeComment: g,
|
|
64
|
+
resolveComment: y,
|
|
65
|
+
reopenComment: I,
|
|
66
|
+
replyToComment: p,
|
|
67
|
+
setActiveComment: A,
|
|
68
|
+
loadComments: L,
|
|
69
|
+
getCommentById: T
|
|
51
70
|
};
|
|
52
71
|
}
|
|
53
72
|
export {
|
|
54
|
-
|
|
73
|
+
V as useVizelComment
|
|
55
74
|
};
|
package/dist/index40.js
CHANGED
|
@@ -1,14 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { createVizelEditorInstance as g, wrapAsVizelError as z, registerVizelUploadEventHandler as I } from "@vizel/core";
|
|
2
|
+
import { useState as O, useRef as c, useEffect as u } from "react";
|
|
3
|
+
import { createVizelSlashMenuRenderer as x } from "./index36.js";
|
|
4
|
+
function h(l = {}) {
|
|
5
|
+
const { features: o, extensions: f = [], ...p } = l, [r, E] = O(null), i = typeof o?.image == "object" ? o.image : {}, n = c(i);
|
|
6
|
+
n.current = i;
|
|
7
|
+
const m = c({
|
|
8
|
+
features: o,
|
|
9
|
+
additionalExtensions: f,
|
|
10
|
+
editorOptions: p
|
|
11
|
+
});
|
|
12
|
+
return u(() => {
|
|
13
|
+
const e = m.current;
|
|
14
|
+
let s = !0, a = null;
|
|
15
|
+
return (async () => {
|
|
16
|
+
try {
|
|
17
|
+
const t = await g({
|
|
18
|
+
...e.editorOptions,
|
|
19
|
+
...e.features !== void 0 && { features: e.features },
|
|
20
|
+
extensions: e.additionalExtensions,
|
|
21
|
+
createSlashMenuRenderer: x
|
|
22
|
+
});
|
|
23
|
+
if (!s) {
|
|
24
|
+
t.editor.destroy();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
a = t.editor, E(t.editor);
|
|
28
|
+
} catch (t) {
|
|
29
|
+
const d = z(t, {
|
|
30
|
+
context: "Editor initialization failed",
|
|
31
|
+
code: "EDITOR_INIT_FAILED"
|
|
32
|
+
});
|
|
33
|
+
throw e.editorOptions.onError?.(d), d;
|
|
34
|
+
}
|
|
35
|
+
})(), () => {
|
|
36
|
+
s = !1, a?.destroy();
|
|
37
|
+
};
|
|
38
|
+
}, []), u(() => {
|
|
39
|
+
if (r)
|
|
40
|
+
return I({
|
|
41
|
+
getEditor: () => r,
|
|
42
|
+
getImageOptions: () => n.current
|
|
43
|
+
});
|
|
44
|
+
}, [r]), r;
|
|
11
45
|
}
|
|
12
46
|
export {
|
|
13
|
-
|
|
47
|
+
h as useVizelEditor
|
|
14
48
|
};
|
package/dist/index41.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
|
|
9
|
-
return [e, s, r];
|
|
10
|
-
};
|
|
1
|
+
import { getVizelEditorState as r } from "@vizel/core";
|
|
2
|
+
import { useMemo as i } from "react";
|
|
3
|
+
import { useVizelState as u } from "./index43.js";
|
|
4
|
+
function p(t) {
|
|
5
|
+
const o = u(t), e = t() ?? null;
|
|
6
|
+
return i(() => r(e), [e, o]);
|
|
7
|
+
}
|
|
11
8
|
export {
|
|
12
|
-
|
|
13
|
-
t as h,
|
|
14
|
-
t as jsx,
|
|
15
|
-
t as jsxDEV,
|
|
16
|
-
t as jsxs
|
|
9
|
+
p as useVizelEditorState
|
|
17
10
|
};
|
package/dist/index42.js
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { createVizelMarkdownSyncHandlers as S, getVizelMarkdown as V } from "@vizel/core";
|
|
2
|
+
import { useState as l, useRef as d, useEffect as c, useCallback as k } from "react";
|
|
3
|
+
function R(r, m = {}) {
|
|
4
|
+
const { initialValue: s, ...w } = m, [M, a] = l(() => s ?? ""), [p, o] = l(!1), t = d(null);
|
|
5
|
+
t.current || (t.current = S(w));
|
|
6
|
+
const u = d(!1);
|
|
7
|
+
c(() => {
|
|
8
|
+
const e = r();
|
|
9
|
+
if (!(!e || u.current)) {
|
|
10
|
+
if (s !== void 0)
|
|
11
|
+
t.current?.setMarkdown(e, s), a(s);
|
|
12
|
+
else {
|
|
13
|
+
const n = V(e);
|
|
14
|
+
a(n);
|
|
15
|
+
}
|
|
16
|
+
u.current = !0;
|
|
17
|
+
}
|
|
18
|
+
}, [r, s]), c(() => {
|
|
19
|
+
const e = r();
|
|
20
|
+
if (!e) return;
|
|
21
|
+
const n = t.current;
|
|
22
|
+
if (!n) return;
|
|
23
|
+
const i = () => {
|
|
24
|
+
n.handleUpdate(e), o(n.isPending());
|
|
25
|
+
const f = () => {
|
|
26
|
+
n.isPending() ? requestAnimationFrame(f) : (a(n.getMarkdown()), o(!1));
|
|
27
|
+
};
|
|
28
|
+
requestAnimationFrame(f);
|
|
29
|
+
};
|
|
30
|
+
return e.on("update", i), () => {
|
|
31
|
+
e.off("update", i);
|
|
32
|
+
};
|
|
33
|
+
}, [r]), c(() => () => {
|
|
34
|
+
t.current?.destroy();
|
|
35
|
+
}, []);
|
|
36
|
+
const h = k(
|
|
37
|
+
(e) => {
|
|
38
|
+
const n = r();
|
|
39
|
+
n && (t.current?.setMarkdown(n, e), a(e), o(!1));
|
|
40
|
+
},
|
|
41
|
+
[r]
|
|
42
|
+
), P = k(() => {
|
|
43
|
+
const e = r();
|
|
44
|
+
e && (t.current?.flush(e), a(t.current?.getMarkdown() ?? ""), o(!1));
|
|
45
|
+
}, [r]);
|
|
46
|
+
return {
|
|
47
|
+
markdown: M,
|
|
48
|
+
setMarkdown: h,
|
|
49
|
+
isPending: p,
|
|
50
|
+
flush: P
|
|
51
|
+
};
|
|
52
|
+
}
|
|
3
53
|
export {
|
|
4
|
-
|
|
54
|
+
R as useVizelMarkdown
|
|
5
55
|
};
|
package/dist/index43.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
throw new Error("^_^");
|
|
12
|
-
try {
|
|
13
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r);
|
|
14
|
-
} catch (o) {
|
|
15
|
-
console.error(o);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return process.env.NODE_ENV === "production" ? (r(), e.exports = t()) : e.exports = i(), e.exports;
|
|
1
|
+
import { useReducer as u, useRef as c, useEffect as f } from "react";
|
|
2
|
+
function s(n) {
|
|
3
|
+
const [o, r] = u((t) => t + 1, 0), e = c(null);
|
|
4
|
+
return f(() => {
|
|
5
|
+
const t = n() ?? null;
|
|
6
|
+
if (e.current && e.current !== t && e.current.off("transaction", r), e.current = t, !!t)
|
|
7
|
+
return t.on("transaction", r), () => {
|
|
8
|
+
t.off("transaction", r);
|
|
9
|
+
};
|
|
10
|
+
}), o;
|
|
20
11
|
}
|
|
21
12
|
export {
|
|
22
|
-
|
|
13
|
+
s as useVizelState
|
|
23
14
|
};
|
package/dist/index44.js
CHANGED
|
@@ -1,4 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import { VIZEL_DEFAULT_VERSION_HISTORY_OPTIONS as c, createVizelVersionHistoryHandlers as k } from "@vizel/core";
|
|
2
|
+
import { useRef as S, useState as v, useCallback as o, useMemo as x, useEffect as E } from "react";
|
|
3
|
+
function O(n, r = {}) {
|
|
4
|
+
const t = S(r);
|
|
5
|
+
t.current = r;
|
|
6
|
+
const a = r.enabled ?? c.enabled, V = r.maxVersions ?? c.maxVersions, u = r.storage ?? c.storage, d = r.key ?? c.key, [i, R] = v({
|
|
7
|
+
snapshots: [],
|
|
8
|
+
isLoading: !1,
|
|
9
|
+
error: null
|
|
10
|
+
}), f = S(n);
|
|
11
|
+
f.current = n;
|
|
12
|
+
const m = o((e) => {
|
|
13
|
+
R((l) => ({ ...l, ...e }));
|
|
14
|
+
}, []), s = x(
|
|
15
|
+
() => k(
|
|
16
|
+
() => f.current(),
|
|
17
|
+
{
|
|
18
|
+
enabled: a,
|
|
19
|
+
maxVersions: V,
|
|
20
|
+
storage: u,
|
|
21
|
+
key: d,
|
|
22
|
+
onSave: (e) => t.current.onSave?.(e),
|
|
23
|
+
onError: (e) => t.current.onError?.(e),
|
|
24
|
+
onRestore: (e) => t.current.onRestore?.(e)
|
|
25
|
+
},
|
|
26
|
+
m
|
|
27
|
+
),
|
|
28
|
+
[a, V, u, d, m]
|
|
29
|
+
);
|
|
30
|
+
E(() => {
|
|
31
|
+
n() && a && s.loadVersions();
|
|
32
|
+
}, [n, a, s]);
|
|
33
|
+
const h = o(
|
|
34
|
+
(e, l) => s.saveVersion(e, l),
|
|
35
|
+
[s]
|
|
36
|
+
), g = o(
|
|
37
|
+
(e) => s.restoreVersion(e),
|
|
38
|
+
[s]
|
|
39
|
+
), y = o(() => s.loadVersions(), [s]), L = o(
|
|
40
|
+
(e) => s.deleteVersion(e),
|
|
41
|
+
[s]
|
|
42
|
+
), b = o(() => s.clearVersions(), [s]);
|
|
43
|
+
return {
|
|
44
|
+
snapshots: i.snapshots,
|
|
45
|
+
isLoading: i.isLoading,
|
|
46
|
+
error: i.error,
|
|
47
|
+
saveVersion: h,
|
|
48
|
+
restoreVersion: g,
|
|
49
|
+
loadVersions: y,
|
|
50
|
+
deleteVersion: L,
|
|
51
|
+
clearVersions: b
|
|
52
|
+
};
|
|
53
|
+
}
|
|
2
54
|
export {
|
|
3
|
-
|
|
55
|
+
O as useVizelVersionHistory
|
|
4
56
|
};
|