@clevertask/scribe 0.0.8 → 0.0.9
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.
|
@@ -1,52 +1,55 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsx as l, jsxs as L } from "react/jsx-runtime";
|
|
2
|
+
import R from "../Menu/BarMenu.js";
|
|
3
3
|
import { html2md as b } from "../../utils/html-to-markdown.js";
|
|
4
4
|
import "../../browser-DEobZXxB.js";
|
|
5
|
-
import { E as
|
|
6
|
-
import { initExtensions as
|
|
7
|
-
import { E as
|
|
8
|
-
import { forwardRef as
|
|
9
|
-
import '../../assets/index.css';function h(
|
|
5
|
+
import { E as T } from "../../index-Gm-3o3nq.js";
|
|
6
|
+
import { initExtensions as A } from "./extension/index.js";
|
|
7
|
+
import { E as J } from "../../index-C3_lI_rP.js";
|
|
8
|
+
import { forwardRef as O, useRef as P, useCallback as u, useImperativeHandle as D, useEffect as f } from "react";
|
|
9
|
+
import '../../assets/index.css';function h(n) {
|
|
10
10
|
var r, s, e = "";
|
|
11
|
-
if (typeof
|
|
12
|
-
else if (typeof
|
|
13
|
-
var o =
|
|
14
|
-
for (r = 0; r < o; r++)
|
|
15
|
-
} else for (s in
|
|
11
|
+
if (typeof n == "string" || typeof n == "number") e += n;
|
|
12
|
+
else if (typeof n == "object") if (Array.isArray(n)) {
|
|
13
|
+
var o = n.length;
|
|
14
|
+
for (r = 0; r < o; r++) n[r] && (s = h(n[r])) && (e && (e += " "), e += s);
|
|
15
|
+
} else for (s in n) n[s] && (e && (e += " "), e += s);
|
|
16
16
|
return e;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
for (var
|
|
18
|
+
function y() {
|
|
19
|
+
for (var n, r, s = 0, e = "", o = arguments.length; s < o; s++) (n = arguments[s]) && (r = h(n)) && (e && (e += " "), e += r);
|
|
20
20
|
return e;
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const V = O((n, r) => {
|
|
23
23
|
const {
|
|
24
24
|
autoFocus: s = !1,
|
|
25
25
|
content: e,
|
|
26
26
|
editable: o = !0,
|
|
27
27
|
editorProps: c,
|
|
28
|
-
extensions:
|
|
29
|
-
onContentChange:
|
|
30
|
-
showBarMenu:
|
|
28
|
+
extensions: E,
|
|
29
|
+
onContentChange: p,
|
|
30
|
+
showBarMenu: w = !0,
|
|
31
31
|
editorContentStyle: x,
|
|
32
|
-
editorContentClassName:
|
|
33
|
-
mainContainerStyle:
|
|
34
|
-
mainContainerClassName:
|
|
35
|
-
onKeyDown:
|
|
36
|
-
externalEditor:
|
|
37
|
-
} =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
jsonContent: i,
|
|
46
|
-
htmlContent: m,
|
|
47
|
-
markdownContent: b(m)
|
|
32
|
+
editorContentClassName: v,
|
|
33
|
+
mainContainerStyle: N,
|
|
34
|
+
mainContainerClassName: j,
|
|
35
|
+
onKeyDown: M,
|
|
36
|
+
externalEditor: S
|
|
37
|
+
} = n, C = P(S || null), g = u(
|
|
38
|
+
({ editor: a }) => {
|
|
39
|
+
const m = a.getHTML(), i = a.getJSON(), B = !o;
|
|
40
|
+
p && p({
|
|
41
|
+
jsonContent: a.isEmpty ? "" : i,
|
|
42
|
+
htmlContent: a.isEmpty ? "" : m,
|
|
43
|
+
markdownContent: a.isEmpty ? "" : b(m),
|
|
44
|
+
source: B ? "programmatic" : "user"
|
|
48
45
|
});
|
|
49
46
|
},
|
|
47
|
+
[o, p]
|
|
48
|
+
);
|
|
49
|
+
C.current || (C.current = new T({
|
|
50
|
+
...c,
|
|
51
|
+
editable: o,
|
|
52
|
+
extensions: [...A(n), ...E ?? []],
|
|
50
53
|
editorProps: {
|
|
51
54
|
attributes: {
|
|
52
55
|
class: "scribe"
|
|
@@ -54,42 +57,44 @@ const G = A((t, r) => {
|
|
|
54
57
|
...c == null ? void 0 : c.editorProps
|
|
55
58
|
}
|
|
56
59
|
}));
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
}, []),
|
|
60
|
+
const t = C.current, d = u(() => {
|
|
61
|
+
t == null || t.commands.setContent("");
|
|
62
|
+
}, []), H = u((a) => {
|
|
60
63
|
var i;
|
|
61
64
|
const m = {
|
|
62
|
-
html: () =>
|
|
63
|
-
json: () =>
|
|
64
|
-
markdown: () => b((
|
|
65
|
+
html: () => t == null ? void 0 : t.getHTML(),
|
|
66
|
+
json: () => t == null ? void 0 : t.getJSON(),
|
|
67
|
+
markdown: () => b((t == null ? void 0 : t.getHTML()) || "")
|
|
65
68
|
};
|
|
66
|
-
return
|
|
67
|
-
}, []),
|
|
68
|
-
|
|
69
|
+
return t != null && t.isEmpty ? "" : (i = m[a]) == null ? void 0 : i.call(m);
|
|
70
|
+
}, []), k = u((a) => {
|
|
71
|
+
t == null || t.commands.setContent(a);
|
|
69
72
|
}, []);
|
|
70
|
-
return
|
|
73
|
+
return D(r, () => ({
|
|
71
74
|
resetContent: d,
|
|
72
|
-
setContent:
|
|
73
|
-
getContent:
|
|
74
|
-
editor:
|
|
75
|
-
}), [d]),
|
|
76
|
-
|
|
77
|
-
}, [e]),
|
|
78
|
-
|
|
79
|
-
}, [o]),
|
|
80
|
-
|
|
81
|
-
}, [
|
|
82
|
-
|
|
75
|
+
setContent: k,
|
|
76
|
+
getContent: H,
|
|
77
|
+
editor: t
|
|
78
|
+
}), [d]), f(() => {
|
|
79
|
+
t == null || t.commands.setContent(e || "");
|
|
80
|
+
}, [e]), f(() => {
|
|
81
|
+
t == null || t.setEditable(!!o);
|
|
82
|
+
}, [o]), f(() => (t.off("update"), t.on("update", g), () => {
|
|
83
|
+
t.off("update", g);
|
|
84
|
+
}), [g]), f(() => {
|
|
85
|
+
s && (t == null || t.commands.focus("end"));
|
|
86
|
+
}, [s]), /* @__PURE__ */ l("div", { className: y("scribe-wrapper", j), style: N, id: "scribe-wrapper", children: /* @__PURE__ */ L("div", { className: y("bg-white", o && "rounded-lg border"), children: [
|
|
87
|
+
t && w && /* @__PURE__ */ l(R, { editor: t }),
|
|
83
88
|
/* @__PURE__ */ l(
|
|
84
89
|
"div",
|
|
85
90
|
{
|
|
86
|
-
className:
|
|
91
|
+
className: y("prose max-w-none", o && "w-full p-[16px]", v),
|
|
87
92
|
style: x,
|
|
88
|
-
children: /* @__PURE__ */ l(
|
|
93
|
+
children: /* @__PURE__ */ l(J, { editor: t, onKeyDown: M })
|
|
89
94
|
}
|
|
90
95
|
)
|
|
91
96
|
] }) });
|
|
92
97
|
});
|
|
93
98
|
export {
|
|
94
|
-
|
|
99
|
+
V as Scribe
|
|
95
100
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A Tiptap-based rich text editor with a Notion-style block interface for viewing and creating content. Perfect for diverse needs like notes, documents, AI chat, Markdown parsing, and comments.",
|
|
4
4
|
"author": "CleverTask",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.9",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/main.js",
|
|
9
9
|
"types": "dist/main.d.ts",
|