@clevertask/scribe 0.1.11 → 0.1.12
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/components/Menu/CalloutBubbleMenu.d.ts +7 -0
- package/dist/components/Menu/CalloutBubbleMenu.d.ts.map +1 -0
- package/dist/components/Menu/CalloutBubbleMenu.js +156 -0
- package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +97 -96
- package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts +10 -0
- package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts.map +1 -0
- package/dist/components/Menu/calloutBubbleMenuPlugin.js +22 -0
- package/dist/components/Menu/contextualMenuOwner.d.ts +4 -0
- package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -0
- package/dist/components/Menu/contextualMenuOwner.js +9 -0
- package/dist/components/Scribe/extension/callout.d.ts +32 -0
- package/dist/components/Scribe/extension/callout.d.ts.map +1 -0
- package/dist/components/Scribe/extension/callout.js +118 -0
- package/dist/components/Scribe/extension/extension-markdown-paste.js +1 -1
- package/dist/components/Scribe/extension/index.d.ts +1 -1
- package/dist/components/Scribe/extension/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
- package/dist/components/Scribe/extension/slashCommand/items.js +48 -28
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +126 -124
- package/dist/{extension-Dy6hHSvD.js → extension-_8uh0Ik9.js} +1234 -1232
- package/dist/{html-to-markdown-B6Uhn7ok.js → html-to-markdown-C920nQtn.js} +101 -60
- package/dist/icons/CalloutIcon.d.ts +9 -0
- package/dist/icons/CalloutIcon.d.ts.map +1 -0
- package/dist/icons/CalloutIcon.js +72 -0
- package/dist/main.css +119 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +9 -8
- package/dist/{markdown-to-html-WmeDaJXP.js → markdown-to-html-CW0Nb9Ye.js} +32 -2
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/markdown-to-html.d.ts.map +1 -1
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +42 -19
|
@@ -1,143 +1,144 @@
|
|
|
1
1
|
import { n as e, t } from "../../BarMenu-5M9g9Y1j.js";
|
|
2
2
|
import { i as n, t as r } from "../../dist-Dw4STOPE.js";
|
|
3
|
-
import i from "../Menu/
|
|
4
|
-
import a from "../Menu/
|
|
5
|
-
import
|
|
6
|
-
import { t as s } from "../../
|
|
7
|
-
import {
|
|
3
|
+
import i from "../Menu/CalloutBubbleMenu.js";
|
|
4
|
+
import a from "../Menu/LinkBubbleMenu.js";
|
|
5
|
+
import o from "../Menu/TableBubbleMenu.js";
|
|
6
|
+
import { t as s } from "../../html-to-markdown-C920nQtn.js";
|
|
7
|
+
import { t as c } from "../../extension-_8uh0Ik9.js";
|
|
8
|
+
import { SuggestionItemType as l } from "./extension/slashCommand/items.js";
|
|
8
9
|
import "./extension/tableOfContents.js";
|
|
9
10
|
import "../../utils/index.js";
|
|
10
|
-
import { ListOptionBar as
|
|
11
|
-
import { forwardRef as
|
|
12
|
-
import { jsx as
|
|
11
|
+
import { ListOptionBar as u } from "../Menu/Mobile/ListOptionBar.js";
|
|
12
|
+
import { forwardRef as d, useCallback as f, useEffect as p, useImperativeHandle as m, useRef as h, useState as g } from "react";
|
|
13
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
13
14
|
import '../../assets/index.css';//#region lib/components/Scribe/index.tsx
|
|
14
|
-
var
|
|
15
|
+
var y = "Rich text editor", b = [
|
|
15
16
|
"role",
|
|
16
17
|
"aria-label",
|
|
17
18
|
"aria-multiline",
|
|
18
19
|
"aria-readonly"
|
|
19
|
-
],
|
|
20
|
+
], x = (t, n, r) => {
|
|
20
21
|
let i = t.role ?? "textbox";
|
|
21
22
|
return {
|
|
22
23
|
...t,
|
|
23
24
|
role: i,
|
|
24
25
|
class: e("scribe", t.class),
|
|
25
|
-
"aria-label": n ?? t["aria-label"] ??
|
|
26
|
+
"aria-label": n ?? t["aria-label"] ?? y,
|
|
26
27
|
...i === "textbox" ? {
|
|
27
28
|
"aria-multiline": "true",
|
|
28
29
|
"aria-readonly": String(!r)
|
|
29
30
|
} : {}
|
|
30
31
|
};
|
|
31
|
-
},
|
|
32
|
-
let t =
|
|
33
|
-
return
|
|
32
|
+
}, S = (e) => {
|
|
33
|
+
let t = h([]), n = h(e);
|
|
34
|
+
return p(() => {
|
|
34
35
|
n.current = e;
|
|
35
36
|
}, [e]), {
|
|
36
|
-
handleTableOfContentsChange:
|
|
37
|
+
handleTableOfContentsChange: f((e, r) => {
|
|
37
38
|
t.current = e, n.current?.(e, r);
|
|
38
39
|
}, []),
|
|
39
40
|
tableOfContentsItemsRef: t
|
|
40
41
|
};
|
|
41
|
-
},
|
|
42
|
-
let { ariaLabel:
|
|
43
|
-
ariaLabel:
|
|
44
|
-
editable:
|
|
45
|
-
}),
|
|
46
|
-
|
|
47
|
-
ariaLabel:
|
|
48
|
-
editable:
|
|
42
|
+
}, C = d((n, c) => {
|
|
43
|
+
let { ariaLabel: l, autoFocus: d = !1, content: g, editable: y = !0, editor: S, editorProps: C, externalEditor: w, initialContentWasApplied: T, onContentChange: E, showBarMenu: D = !0, editorContentStyle: O, editorContentClassName: k, mainContainerStyle: A, mainContainerClassName: j, onKeyDown: M, mobile: N, tableOfContentsItemsRef: P } = n, F = h({
|
|
44
|
+
ariaLabel: l,
|
|
45
|
+
editable: y
|
|
46
|
+
}), I = h(null);
|
|
47
|
+
F.current = {
|
|
48
|
+
ariaLabel: l,
|
|
49
|
+
editable: y
|
|
49
50
|
};
|
|
50
|
-
let
|
|
51
|
+
let L = h(T && g !== void 0), R = f(({ editor: e, transaction: t }) => {
|
|
51
52
|
if (t.getMeta("scribeTableOfContents")) return;
|
|
52
|
-
let n = e.getHTML(), r = e.getJSON(), i = !
|
|
53
|
-
|
|
53
|
+
let n = e.getHTML(), r = e.getJSON(), i = !y;
|
|
54
|
+
E && E({
|
|
54
55
|
jsonContent: e.isEmpty ? "" : r,
|
|
55
56
|
htmlContent: e.isEmpty ? "" : n,
|
|
56
|
-
markdownContent: e.isEmpty ? "" :
|
|
57
|
+
markdownContent: e.isEmpty ? "" : s(n),
|
|
57
58
|
source: i ? "programmatic" : "user"
|
|
58
59
|
});
|
|
59
|
-
}, [
|
|
60
|
-
|
|
61
|
-
}, [
|
|
62
|
-
html: () =>
|
|
63
|
-
json: () =>
|
|
64
|
-
markdown: () =>
|
|
65
|
-
}[e]?.(), [
|
|
66
|
-
|
|
67
|
-
}, [
|
|
68
|
-
let t = typeof e == "string" ? e : e.id, n =
|
|
69
|
-
if (!n ||
|
|
70
|
-
let r =
|
|
71
|
-
if (
|
|
72
|
-
let e = Math.max(0, Math.min(n.pos + n.node.nodeSize - 1,
|
|
73
|
-
|
|
60
|
+
}, [y, E]), z = f(() => {
|
|
61
|
+
S.commands.setContent("");
|
|
62
|
+
}, [S]), B = f((e) => S.isEmpty ? "" : {
|
|
63
|
+
html: () => S.getHTML(),
|
|
64
|
+
json: () => S.getJSON(),
|
|
65
|
+
markdown: () => s(S.getHTML())
|
|
66
|
+
}[e]?.(), [S]), V = f((e) => {
|
|
67
|
+
S.commands.setContent(e);
|
|
68
|
+
}, [S]), H = f((e) => {
|
|
69
|
+
let t = typeof e == "string" ? e : e.id, n = P.current.find((e) => e.id === t) ?? (typeof e == "string" ? void 0 : e);
|
|
70
|
+
if (!n || S.isDestroyed) return;
|
|
71
|
+
let r = S.view.nodeDOM(n.pos), i = r instanceof HTMLElement ? r : n.dom;
|
|
72
|
+
if (S.isEditable) {
|
|
73
|
+
let e = Math.max(0, Math.min(n.pos + n.node.nodeSize - 1, S.state.doc.content.size));
|
|
74
|
+
S.commands.focus(e, { scrollIntoView: !1 });
|
|
74
75
|
}
|
|
75
76
|
i.scrollIntoView({
|
|
76
77
|
behavior: "smooth",
|
|
77
78
|
block: "start"
|
|
78
79
|
});
|
|
79
|
-
}, [
|
|
80
|
-
return
|
|
81
|
-
resetContent:
|
|
82
|
-
setContent:
|
|
83
|
-
getContent:
|
|
84
|
-
scrollToTableOfContentsItem:
|
|
85
|
-
editor:
|
|
80
|
+
}, [S, P]);
|
|
81
|
+
return m(c, () => ({
|
|
82
|
+
resetContent: z,
|
|
83
|
+
setContent: V,
|
|
84
|
+
getContent: B,
|
|
85
|
+
scrollToTableOfContentsItem: H,
|
|
86
|
+
editor: S
|
|
86
87
|
}), [
|
|
87
|
-
|
|
88
|
+
S,
|
|
89
|
+
B,
|
|
88
90
|
z,
|
|
89
|
-
|
|
90
|
-
V
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
I.current = !1;
|
|
91
|
+
H,
|
|
92
|
+
V
|
|
93
|
+
]), p(() => {
|
|
94
|
+
if (g !== void 0) {
|
|
95
|
+
if (L.current) {
|
|
96
|
+
L.current = !1;
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
S.commands.setContent(g, { emitUpdate: !1 });
|
|
99
100
|
}
|
|
100
|
-
}, [
|
|
101
|
-
if (!
|
|
102
|
-
|
|
101
|
+
}, [g, S]), p(() => {
|
|
102
|
+
if (!w) {
|
|
103
|
+
I.current = null;
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
105
|
-
let e =
|
|
106
|
+
let e = S.view.dom, t = Object.fromEntries(b.map((t) => [t, e.getAttribute(t)])), n = S.options.editable, r = S.options.editorProps ?? {}, i = r.attributes, a = /* @__PURE__ */ new Set(), o = (e, t) => {
|
|
106
107
|
let n = typeof i == "function" ? i.call(t, e) : i;
|
|
107
108
|
return Object.keys(n ?? {}).forEach((e) => a.add(e)), n ?? {};
|
|
108
109
|
}, s = (e, n) => {
|
|
109
110
|
let r = o(e, n), i = {};
|
|
110
|
-
return
|
|
111
|
+
return b.forEach((e) => {
|
|
111
112
|
let n = t[e];
|
|
112
113
|
!a.has(e) && n !== null && (i[e] = n);
|
|
113
114
|
}), {
|
|
114
115
|
...i,
|
|
115
116
|
...r
|
|
116
117
|
};
|
|
117
|
-
}, c = s(
|
|
118
|
-
|
|
119
|
-
editor:
|
|
118
|
+
}, c = s(S.state, r);
|
|
119
|
+
I.current = {
|
|
120
|
+
editor: S,
|
|
120
121
|
attributes: c
|
|
121
122
|
};
|
|
122
123
|
let l = function(e) {
|
|
123
124
|
let t = s(e, this);
|
|
124
|
-
|
|
125
|
-
let n =
|
|
126
|
-
return
|
|
125
|
+
I.current?.editor === S && (I.current.attributes = t);
|
|
126
|
+
let n = F.current;
|
|
127
|
+
return x(t, n.ariaLabel, n.editable);
|
|
127
128
|
};
|
|
128
|
-
return
|
|
129
|
+
return S.setOptions({ editorProps: {
|
|
129
130
|
...r,
|
|
130
131
|
attributes: l
|
|
131
132
|
} }), () => {
|
|
132
|
-
if (!
|
|
133
|
-
let s =
|
|
133
|
+
if (!S.isDestroyed) {
|
|
134
|
+
let s = S.options.editorProps ?? {}, c = s.attributes === l;
|
|
134
135
|
if (c) {
|
|
135
136
|
let e = { ...s };
|
|
136
|
-
i === void 0 ? delete e.attributes : e.attributes = i,
|
|
137
|
+
i === void 0 ? delete e.attributes : e.attributes = i, S.setOptions({ editorProps: e });
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
-
let u = c ? o(
|
|
140
|
-
u &&
|
|
139
|
+
S.setEditable(!!n, !1);
|
|
140
|
+
let u = c ? o(S.state, r) : null;
|
|
141
|
+
u && b.forEach((n) => {
|
|
141
142
|
let r = n in u ? u[n] : a.has(n) ? null : t[n];
|
|
142
143
|
if (r == null) {
|
|
143
144
|
e.removeAttribute(n);
|
|
@@ -146,12 +147,12 @@ var v = "Rich text editor", y = [
|
|
|
146
147
|
e.setAttribute(n, r);
|
|
147
148
|
});
|
|
148
149
|
}
|
|
149
|
-
|
|
150
|
+
I.current?.editor === S && (I.current = null);
|
|
150
151
|
};
|
|
151
|
-
}, [
|
|
152
|
-
|
|
153
|
-
let e =
|
|
154
|
-
|
|
152
|
+
}, [S, w]), p(() => {
|
|
153
|
+
S.setEditable(!!y);
|
|
154
|
+
let e = S.view.dom, t = x((w ? I.current?.attributes : typeof C?.editorProps?.attributes == "function" ? C.editorProps.attributes.call(C.editorProps, S.state) : C?.editorProps?.attributes) ?? {}, l, y);
|
|
155
|
+
b.forEach((n) => {
|
|
155
156
|
let r = t[n];
|
|
156
157
|
if (r === void 0) {
|
|
157
158
|
e.removeAttribute(n);
|
|
@@ -160,46 +161,47 @@ var v = "Rich text editor", y = [
|
|
|
160
161
|
e.setAttribute(n, r);
|
|
161
162
|
});
|
|
162
163
|
}, [
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
x,
|
|
164
|
+
l,
|
|
165
|
+
y,
|
|
166
166
|
S,
|
|
167
|
-
C
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
C,
|
|
168
|
+
w
|
|
169
|
+
]), p(() => (S.off("update"), S.on("update", R), () => {
|
|
170
|
+
S.off("update", R);
|
|
171
|
+
}), [S, R]), p(() => {
|
|
172
|
+
d && S.commands.focus("end");
|
|
173
|
+
}, [d, S]), /* @__PURE__ */ v("div", {
|
|
174
|
+
className: e("scribe-wrapper", "scribe-root", j),
|
|
174
175
|
"data-scribe-root": !0,
|
|
175
|
-
style:
|
|
176
|
-
children: [/* @__PURE__ */
|
|
177
|
-
className: e("scribe-frame",
|
|
176
|
+
style: A,
|
|
177
|
+
children: [/* @__PURE__ */ v("div", {
|
|
178
|
+
className: e("scribe-frame", y && "scribe-frame--editable"),
|
|
178
179
|
children: [
|
|
179
|
-
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
className: e("scribe-content",
|
|
182
|
-
style:
|
|
180
|
+
S && D ? /* @__PURE__ */ _(t, { editor: S }) : null,
|
|
181
|
+
/* @__PURE__ */ v("div", {
|
|
182
|
+
className: e("scribe-content", y && "scribe-content--editable", k),
|
|
183
|
+
style: O,
|
|
183
184
|
children: [
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
editor:
|
|
186
|
-
onKeyDown:
|
|
185
|
+
/* @__PURE__ */ _(r, {
|
|
186
|
+
editor: S,
|
|
187
|
+
onKeyDown: M
|
|
187
188
|
}),
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
y ? /* @__PURE__ */ _(a, { editor: S }) : null,
|
|
190
|
+
y && S.schema.nodes.callout ? /* @__PURE__ */ _(i, { editor: S }) : null,
|
|
191
|
+
y && S.schema.nodes.table ? /* @__PURE__ */ _(o, { editor: S }) : null
|
|
190
192
|
]
|
|
191
193
|
}),
|
|
192
|
-
|
|
194
|
+
N ? /* @__PURE__ */ _(u, { editor: S }) : null
|
|
193
195
|
]
|
|
194
|
-
}), /* @__PURE__ */
|
|
196
|
+
}), /* @__PURE__ */ _("div", {
|
|
195
197
|
className: "scribe-popup-root",
|
|
196
198
|
"data-scribe-popup-root": !0
|
|
197
199
|
})]
|
|
198
200
|
});
|
|
199
201
|
});
|
|
200
|
-
|
|
201
|
-
var
|
|
202
|
-
let { ariaLabel: r, content: i, editable: a = !0, editorProps: o, extensions:
|
|
202
|
+
C.displayName = "ScribeEditor";
|
|
203
|
+
var w = d((e, t) => {
|
|
204
|
+
let { ariaLabel: r, content: i, editable: a = !0, editorProps: o, extensions: s, onTableOfContentsChange: l } = e, { handleTableOfContentsChange: u, tableOfContentsItemsRef: d } = S(l), f = o?.editorProps?.attributes, p = h({
|
|
203
205
|
ariaLabel: r,
|
|
204
206
|
editable: a
|
|
205
207
|
});
|
|
@@ -207,24 +209,24 @@ var C = u((e, t) => {
|
|
|
207
209
|
ariaLabel: r,
|
|
208
210
|
editable: a
|
|
209
211
|
};
|
|
210
|
-
let
|
|
212
|
+
let m = typeof f == "function" ? function(e) {
|
|
211
213
|
let t = p.current;
|
|
212
|
-
return
|
|
213
|
-
} :
|
|
214
|
+
return x(f.call(this, e), t.ariaLabel, t.editable);
|
|
215
|
+
} : x(f ?? {}, r, a), [v] = g(() => ({
|
|
214
216
|
...o,
|
|
215
217
|
content: i ?? o?.content,
|
|
216
218
|
editable: a,
|
|
217
|
-
extensions: [...
|
|
219
|
+
extensions: [...c({
|
|
218
220
|
...e,
|
|
219
221
|
onTableOfContentsChange: u
|
|
220
|
-
}), ...
|
|
222
|
+
}), ...s ?? []],
|
|
221
223
|
editorProps: {
|
|
222
224
|
...o?.editorProps,
|
|
223
|
-
attributes:
|
|
225
|
+
attributes: m
|
|
224
226
|
},
|
|
225
227
|
shouldRerenderOnTransaction: o?.shouldRerenderOnTransaction ?? !1
|
|
226
228
|
})), y = n(v);
|
|
227
|
-
return y ? /* @__PURE__ */
|
|
229
|
+
return y ? /* @__PURE__ */ _(C, {
|
|
228
230
|
...e,
|
|
229
231
|
ref: t,
|
|
230
232
|
editor: y,
|
|
@@ -232,10 +234,10 @@ var C = u((e, t) => {
|
|
|
232
234
|
tableOfContentsItemsRef: d
|
|
233
235
|
}) : null;
|
|
234
236
|
});
|
|
235
|
-
|
|
236
|
-
var
|
|
237
|
-
let { externalEditor: n, onTableOfContentsChange: r } = e, { tableOfContentsItemsRef: i } =
|
|
238
|
-
return n ? /* @__PURE__ */
|
|
237
|
+
w.displayName = "OwnedScribe";
|
|
238
|
+
var T = d((e, t) => {
|
|
239
|
+
let { externalEditor: n, onTableOfContentsChange: r } = e, { tableOfContentsItemsRef: i } = S(r);
|
|
240
|
+
return n ? /* @__PURE__ */ _(C, {
|
|
239
241
|
...e,
|
|
240
242
|
ref: t,
|
|
241
243
|
editor: n,
|
|
@@ -243,14 +245,14 @@ var w = u((e, t) => {
|
|
|
243
245
|
tableOfContentsItemsRef: i
|
|
244
246
|
}) : null;
|
|
245
247
|
});
|
|
246
|
-
|
|
247
|
-
var
|
|
248
|
+
T.displayName = "ExternalScribe";
|
|
249
|
+
var E = d((e, t) => e.externalEditor ? /* @__PURE__ */ _(T, {
|
|
248
250
|
...e,
|
|
249
251
|
ref: t
|
|
250
|
-
}) : /* @__PURE__ */
|
|
252
|
+
}) : /* @__PURE__ */ _(w, {
|
|
251
253
|
...e,
|
|
252
254
|
ref: t
|
|
253
255
|
}));
|
|
254
|
-
|
|
256
|
+
E.displayName = "Scribe";
|
|
255
257
|
//#endregion
|
|
256
|
-
export {
|
|
258
|
+
export { E as Scribe, l as SuggestionItemType };
|