@clevertask/scribe 0.0.7 → 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.
- package/dist/{browser-Ce149ePN.js → browser-DEobZXxB.js} +48 -48
- package/dist/components/Menu/BubbleMenu.js +1 -1
- package/dist/components/Scribe/extension/extension-link.js +1 -1
- package/dist/components/Scribe/extension/extension-selectedText.js +4 -4
- package/dist/components/Scribe/extension/index.js +28 -3853
- package/dist/components/Scribe/extension/math-extension.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +7 -3
- package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
- package/dist/components/Scribe/index.d.ts +5 -2
- package/dist/components/Scribe/index.js +79 -72
- package/dist/index-C3_lI_rP.js +2269 -0
- package/dist/{index-o3ZWOEgq.js → index-Gm-3o3nq.js} +25 -25
- package/dist/index-NRgJVTH-.js +7576 -0
- package/dist/main.js +8 -6
- package/dist/utils/create-scribe-editor.d.ts +11 -0
- package/dist/utils/create-scribe-editor.js +26 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +6 -4
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +1 -1
- package/dist/SlashCommandList-DLPd43Tg.js +0 -3733
- package/dist/index-dyNx8_Ul.js +0 -2509
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as fa, P as pa,
|
|
1
|
+
import { N as fa, P as pa, b as va, m as ga } from "../../../index-Gm-3o3nq.js";
|
|
2
2
|
class u0 {
|
|
3
3
|
// The + prefix indicates that these fields aren't writeable
|
|
4
4
|
// Lexer holding the input string.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { g } from "../../../../index-NRgJVTH-.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../../../../turndown.browser.es-BSoGafvq.js";
|
|
5
|
-
import "../../../../browser-
|
|
5
|
+
import "../../../../browser-DEobZXxB.js";
|
|
6
6
|
import "../../../../utils/is-in-viewport.js";
|
|
7
|
+
import "../extension-link.js";
|
|
8
|
+
import "./index.js";
|
|
9
|
+
import "../extension-selectedText.js";
|
|
10
|
+
import "../math-extension.js";
|
|
7
11
|
export {
|
|
8
|
-
|
|
12
|
+
g as SlashCommandList
|
|
9
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as F, P as T, D as U, c as j, e as z, a as G } from "../../../../index-Gm-3o3nq.js";
|
|
2
2
|
function H(f) {
|
|
3
3
|
var s;
|
|
4
4
|
const { char: g, allowSpaces: v, allowToIncludeChar: I, allowedPrefixes: m, startOfLine: R, $position: d } = f, P = v && !I, p = z(g), D = new RegExp(`\\s${p}$`), h = R ? "^" : "", C = I ? "" : p, K = P ? new RegExp(`${h}${p}.*?(?=\\s${C}|$)`, "gm") : new RegExp(`${h}(?:^)?${p}[^\\s${C}]*`, "gm"), r = ((s = d.nodeBefore) === null || s === void 0 ? void 0 : s.isText) && d.nodeBefore.text;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as l, t as c } from "../../../../index-
|
|
2
|
-
import { l as a,
|
|
1
|
+
import { R as l, t as c } from "../../../../index-C3_lI_rP.js";
|
|
2
|
+
import { l as a, g as d } from "../../../../index-NRgJVTH-.js";
|
|
3
3
|
const m = () => {
|
|
4
4
|
let n, t = [], r, i = !a.isEmpty(t);
|
|
5
5
|
return {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { Content, Extension, JSONContent, UseEditorOptions } from '@tiptap/react';
|
|
2
|
-
import { KeyboardEventHandler } from 'react';
|
|
3
1
|
import { ClassValue } from 'clsx';
|
|
2
|
+
import { Content, Editor, Extension, JSONContent, UseEditorOptions } from '@tiptap/react';
|
|
3
|
+
import { KeyboardEventHandler } from 'react';
|
|
4
4
|
export type ScribeOnChangeContents = {
|
|
5
5
|
jsonContent: Content;
|
|
6
6
|
htmlContent: Content;
|
|
7
7
|
markdownContent: string;
|
|
8
|
+
source: "user" | "programmatic";
|
|
8
9
|
};
|
|
9
10
|
export interface ScribeRef {
|
|
10
11
|
resetContent: () => void;
|
|
11
12
|
getContent: (contentType: "html" | "json" | "markdown") => string | JSONContent | undefined;
|
|
12
13
|
setContent: (content: Content) => void;
|
|
14
|
+
editor: Editor;
|
|
13
15
|
}
|
|
14
16
|
export interface ScribeProps {
|
|
15
17
|
onContentChange?: (content: ScribeOnChangeContents) => void;
|
|
@@ -17,6 +19,7 @@ export interface ScribeProps {
|
|
|
17
19
|
editable?: boolean;
|
|
18
20
|
autoFocus?: boolean;
|
|
19
21
|
extensions?: Extension[];
|
|
22
|
+
externalEditor?: Editor;
|
|
20
23
|
editorProps?: UseEditorOptions;
|
|
21
24
|
showBarMenu?: boolean;
|
|
22
25
|
placeholderText?: string;
|
|
@@ -1,93 +1,100 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { initExtensions as B } from "./extension/index.js";
|
|
4
|
-
import { forwardRef as L, useCallback as f, useImperativeHandle as T, useEffect as u } from "react";
|
|
5
|
-
import A from "../Menu/BarMenu.js";
|
|
1
|
+
import { jsx as l, jsxs as L } from "react/jsx-runtime";
|
|
2
|
+
import R from "../Menu/BarMenu.js";
|
|
6
3
|
import { html2md as b } from "../../utils/html-to-markdown.js";
|
|
7
|
-
import "../../browser-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import "../../browser-DEobZXxB.js";
|
|
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
|
+
var r, s, e = "";
|
|
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);
|
|
15
16
|
return e;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
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);
|
|
19
20
|
return e;
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
+
const V = O((n, r) => {
|
|
22
23
|
const {
|
|
23
24
|
autoFocus: s = !1,
|
|
24
25
|
content: e,
|
|
25
|
-
editable:
|
|
26
|
+
editable: o = !0,
|
|
26
27
|
editorProps: c,
|
|
27
|
-
extensions:
|
|
28
|
-
onContentChange:
|
|
29
|
-
showBarMenu:
|
|
30
|
-
editorContentStyle:
|
|
31
|
-
editorContentClassName:
|
|
32
|
-
mainContainerStyle:
|
|
33
|
-
mainContainerClassName:
|
|
34
|
-
onKeyDown:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
markdownContent: b(m)
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
editorProps: {
|
|
49
|
-
attributes: {
|
|
50
|
-
class: "scribe"
|
|
51
|
-
},
|
|
52
|
-
...c == null ? void 0 : c.editorProps
|
|
53
|
-
}
|
|
28
|
+
extensions: E,
|
|
29
|
+
onContentChange: p,
|
|
30
|
+
showBarMenu: w = !0,
|
|
31
|
+
editorContentStyle: x,
|
|
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"
|
|
45
|
+
});
|
|
54
46
|
},
|
|
55
|
-
[]
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
[o, p]
|
|
48
|
+
);
|
|
49
|
+
C.current || (C.current = new T({
|
|
50
|
+
...c,
|
|
51
|
+
editable: o,
|
|
52
|
+
extensions: [...A(n), ...E ?? []],
|
|
53
|
+
editorProps: {
|
|
54
|
+
attributes: {
|
|
55
|
+
class: "scribe"
|
|
56
|
+
},
|
|
57
|
+
...c == null ? void 0 : c.editorProps
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
const t = C.current, d = u(() => {
|
|
61
|
+
t == null || t.commands.setContent("");
|
|
62
|
+
}, []), H = u((a) => {
|
|
63
|
+
var i;
|
|
60
64
|
const m = {
|
|
61
|
-
html: () =>
|
|
62
|
-
json: () =>
|
|
63
|
-
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()) || "")
|
|
64
68
|
};
|
|
65
|
-
return
|
|
66
|
-
}, []),
|
|
67
|
-
|
|
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);
|
|
68
72
|
}, []);
|
|
69
|
-
return
|
|
70
|
-
resetContent:
|
|
71
|
-
setContent:
|
|
72
|
-
getContent:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
return D(r, () => ({
|
|
74
|
+
resetContent: d,
|
|
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 }),
|
|
88
|
+
/* @__PURE__ */ l(
|
|
82
89
|
"div",
|
|
83
90
|
{
|
|
84
|
-
className:
|
|
85
|
-
style:
|
|
86
|
-
children: /* @__PURE__ */
|
|
91
|
+
className: y("prose max-w-none", o && "w-full p-[16px]", v),
|
|
92
|
+
style: x,
|
|
93
|
+
children: /* @__PURE__ */ l(J, { editor: t, onKeyDown: M })
|
|
87
94
|
}
|
|
88
95
|
)
|
|
89
96
|
] }) });
|
|
90
97
|
});
|
|
91
98
|
export {
|
|
92
|
-
|
|
99
|
+
V as Scribe
|
|
93
100
|
};
|