@clevertask/scribe 0.0.2 → 0.0.4
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/{SlashCommandList-D_Ndw6pj.js → SlashCommandList-DLPd43Tg.js} +538 -538
- package/dist/assets/index.css +1 -0
- package/dist/{browser-D3_ToIiA.js → browser-Ce149ePN.js} +497 -508
- package/dist/components/Menu/BubbleMenu.js +1 -1
- package/dist/components/Scribe/extension/extension-link.js +482 -432
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/index.d.ts +1 -1
- package/dist/components/Scribe/extension/index.js +2706 -568
- package/dist/components/Scribe/extension/math-extension.d.ts +2 -0
- package/dist/components/Scribe/extension/math-extension.js +11768 -0
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3 -3
- package/dist/components/Scribe/extension/slashCommand/index.js +76 -75
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
- package/dist/components/Scribe/index.d.ts +4 -3
- package/dist/components/Scribe/index.js +67 -66
- package/dist/{index-Cu10LNOZ.js → index-Bl1eZGET.js} +520 -516
- package/dist/{index-CzwFCNeI.js → index-pCZujIH1.js} +2074 -1965
- package/dist/main.css +10 -1
- package/dist/{turndown.browser.es-CeowJDZ0.js → turndown.browser.es-BSoGafvq.js} +249 -253
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +43 -38
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import { S as s } from "../../../../SlashCommandList-
|
|
2
|
+
import { S as s } from "../../../../SlashCommandList-DLPd43Tg.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import "../../../../turndown.browser.es-
|
|
5
|
-
import "../../../../browser-
|
|
4
|
+
import "../../../../turndown.browser.es-BSoGafvq.js";
|
|
5
|
+
import "../../../../browser-Ce149ePN.js";
|
|
6
6
|
import "../../../../utils/is-in-viewport.js";
|
|
7
7
|
export {
|
|
8
8
|
s as SlashCommandList
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
var
|
|
4
|
-
const { char:
|
|
5
|
-
if (!
|
|
1
|
+
import { a as F, P as T, D as U, b as j, e as z, E as G } from "../../../../index-pCZujIH1.js";
|
|
2
|
+
function H(f) {
|
|
3
|
+
var s;
|
|
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;
|
|
5
|
+
if (!r)
|
|
6
6
|
return null;
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
7
|
+
const e = d.pos - r.length, o = Array.from(r.matchAll(K)).pop();
|
|
8
|
+
if (!o || o.input === void 0 || o.index === void 0)
|
|
9
9
|
return null;
|
|
10
|
-
const
|
|
11
|
-
if (m !== null && !
|
|
10
|
+
const n = o.input.slice(Math.max(0, o.index - 1), o.index), i = new RegExp(`^[${m == null ? void 0 : m.join("")}\0]?$`).test(n);
|
|
11
|
+
if (m !== null && !i)
|
|
12
12
|
return null;
|
|
13
|
-
const
|
|
14
|
-
let
|
|
15
|
-
return
|
|
13
|
+
const a = e + o.index;
|
|
14
|
+
let l = a + o[0].length;
|
|
15
|
+
return P && D.test(r.slice(l - 1, l + 1)) && (o[0] += " ", l += 1), a < d.pos && l >= d.pos ? {
|
|
16
16
|
range: {
|
|
17
|
-
from:
|
|
18
|
-
to:
|
|
17
|
+
from: a,
|
|
18
|
+
to: l
|
|
19
19
|
},
|
|
20
|
-
query:
|
|
21
|
-
text:
|
|
20
|
+
query: o[0].slice(g.length),
|
|
21
|
+
text: o[0]
|
|
22
22
|
} : null;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
const e =
|
|
24
|
+
const J = new F("suggestion");
|
|
25
|
+
function Q({ pluginKey: f = J, editor: s, char: g = "@", allowSpaces: v = !1, allowToIncludeChar: I = !1, allowedPrefixes: m = [" "], startOfLine: R = !1, decorationTag: d = "span", decorationClass: P = "suggestion", command: p = () => null, items: D = () => [], render: h = () => ({}), allow: C = () => !0, findSuggestionMatch: K = H }) {
|
|
26
|
+
let r;
|
|
27
|
+
const e = h == null ? void 0 : h(), o = new T({
|
|
28
28
|
key: f,
|
|
29
29
|
view() {
|
|
30
30
|
return {
|
|
31
|
-
update: async (
|
|
32
|
-
var
|
|
33
|
-
const t = (
|
|
34
|
-
if (!
|
|
31
|
+
update: async (n, i) => {
|
|
32
|
+
var a, l, u, x, y, w, S;
|
|
33
|
+
const t = (a = this.key) === null || a === void 0 ? void 0 : a.getState(i), c = (l = this.key) === null || l === void 0 ? void 0 : l.getState(n.state), q = t.active && c.active && t.range.from !== c.range.from, O = !t.active && c.active, b = t.active && !c.active, B = !O && !b && t.query !== c.query, _ = O || q && B, M = B || q, k = b || q && B;
|
|
34
|
+
if (!_ && !M && !k)
|
|
35
35
|
return;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
editor:
|
|
39
|
-
range:
|
|
40
|
-
query:
|
|
41
|
-
text:
|
|
36
|
+
const $ = k && !_ ? t : c, N = n.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`);
|
|
37
|
+
r = {
|
|
38
|
+
editor: s,
|
|
39
|
+
range: $.range,
|
|
40
|
+
query: $.query,
|
|
41
|
+
text: $.text,
|
|
42
42
|
items: [],
|
|
43
|
-
command: (
|
|
44
|
-
editor:
|
|
45
|
-
range:
|
|
46
|
-
props:
|
|
43
|
+
command: (E) => p({
|
|
44
|
+
editor: s,
|
|
45
|
+
range: $.range,
|
|
46
|
+
props: E
|
|
47
47
|
}),
|
|
48
48
|
decorationNode: N,
|
|
49
49
|
// virtual node for popper.js or tippy.js
|
|
50
50
|
// this can be used for building popups without a DOM node
|
|
51
51
|
clientRect: N ? () => {
|
|
52
|
-
var
|
|
53
|
-
const { decorationId:
|
|
54
|
-
return (
|
|
52
|
+
var E;
|
|
53
|
+
const { decorationId: L } = (E = this.key) === null || E === void 0 ? void 0 : E.getState(s.state), A = n.dom.querySelector(`[data-decoration-id="${L}"]`);
|
|
54
|
+
return (A == null ? void 0 : A.getBoundingClientRect()) || null;
|
|
55
55
|
} : null
|
|
56
|
-
},
|
|
57
|
-
editor:
|
|
58
|
-
query:
|
|
59
|
-
})),
|
|
56
|
+
}, _ && ((u = e == null ? void 0 : e.onBeforeStart) === null || u === void 0 || u.call(e, r)), M && ((x = e == null ? void 0 : e.onBeforeUpdate) === null || x === void 0 || x.call(e, r)), (M || _) && (r.items = await D({
|
|
57
|
+
editor: s,
|
|
58
|
+
query: $.query
|
|
59
|
+
})), k && ((y = e == null ? void 0 : e.onExit) === null || y === void 0 || y.call(e, r)), M && ((w = e == null ? void 0 : e.onUpdate) === null || w === void 0 || w.call(e, r)), _ && ((S = e == null ? void 0 : e.onStart) === null || S === void 0 || S.call(e, r));
|
|
60
60
|
},
|
|
61
61
|
destroy: () => {
|
|
62
|
-
var
|
|
63
|
-
|
|
62
|
+
var n;
|
|
63
|
+
r && ((n = e == null ? void 0 : e.onExit) === null || n === void 0 || n.call(e, r));
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
},
|
|
@@ -79,23 +79,24 @@ function J({ pluginKey: f = H, editor: a, char: v = "@", allowSpaces: c = !1, al
|
|
|
79
79
|
};
|
|
80
80
|
},
|
|
81
81
|
// Apply changes to the plugin state from a view transaction.
|
|
82
|
-
apply(
|
|
83
|
-
const { isEditable:
|
|
84
|
-
if (t.composing = x,
|
|
85
|
-
(
|
|
86
|
-
const
|
|
87
|
-
char:
|
|
88
|
-
allowSpaces:
|
|
82
|
+
apply(n, i, a, l) {
|
|
83
|
+
const { isEditable: u } = s, { composing: x } = s.view, { selection: y } = n, { empty: w, from: S } = y, t = { ...i };
|
|
84
|
+
if (t.composing = x, u && (w || s.view.composing)) {
|
|
85
|
+
(S < i.range.from || S > i.range.to) && !x && !i.composing && (t.active = !1);
|
|
86
|
+
const c = K({
|
|
87
|
+
char: g,
|
|
88
|
+
allowSpaces: v,
|
|
89
|
+
allowToIncludeChar: I,
|
|
89
90
|
allowedPrefixes: m,
|
|
90
91
|
startOfLine: R,
|
|
91
|
-
$position:
|
|
92
|
-
}),
|
|
93
|
-
|
|
94
|
-
editor:
|
|
95
|
-
state:
|
|
96
|
-
range:
|
|
92
|
+
$position: y.$from
|
|
93
|
+
}), q = `id_${Math.floor(Math.random() * 4294967295)}`;
|
|
94
|
+
c && C({
|
|
95
|
+
editor: s,
|
|
96
|
+
state: l,
|
|
97
|
+
range: c.range,
|
|
97
98
|
isActive: i.active
|
|
98
|
-
}) ? (t.active = !0, t.decorationId = i.decorationId ? i.decorationId :
|
|
99
|
+
}) ? (t.active = !0, t.decorationId = i.decorationId ? i.decorationId : q, t.range = c.range, t.query = c.query, t.text = c.text) : t.active = !1;
|
|
99
100
|
} else
|
|
100
101
|
t.active = !1;
|
|
101
102
|
return t.active || (t.decorationId = null, t.range = { from: 0, to: 0 }, t.query = null, t.text = null), t;
|
|
@@ -103,27 +104,27 @@ function J({ pluginKey: f = H, editor: a, char: v = "@", allowSpaces: c = !1, al
|
|
|
103
104
|
},
|
|
104
105
|
props: {
|
|
105
106
|
// Call the keydown hook if suggestion is active.
|
|
106
|
-
handleKeyDown(
|
|
107
|
-
var
|
|
108
|
-
const { active:
|
|
109
|
-
return
|
|
107
|
+
handleKeyDown(n, i) {
|
|
108
|
+
var a;
|
|
109
|
+
const { active: l, range: u } = o.getState(n.state);
|
|
110
|
+
return l && ((a = e == null ? void 0 : e.onKeyDown) === null || a === void 0 ? void 0 : a.call(e, { view: n, event: i, range: u })) || !1;
|
|
110
111
|
},
|
|
111
112
|
// Setup decorator on the currently active suggestion.
|
|
112
|
-
decorations(
|
|
113
|
-
const { active: i, range:
|
|
114
|
-
return i ? U.create(
|
|
115
|
-
j.inline(
|
|
113
|
+
decorations(n) {
|
|
114
|
+
const { active: i, range: a, decorationId: l } = o.getState(n);
|
|
115
|
+
return i ? U.create(n.doc, [
|
|
116
|
+
j.inline(a.from, a.to, {
|
|
116
117
|
nodeName: d,
|
|
117
|
-
class:
|
|
118
|
-
"data-decoration-id":
|
|
118
|
+
class: P,
|
|
119
|
+
"data-decoration-id": l
|
|
119
120
|
})
|
|
120
121
|
]) : null;
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
});
|
|
124
|
-
return
|
|
125
|
+
return o;
|
|
125
126
|
}
|
|
126
|
-
const
|
|
127
|
+
const V = new F("slashSuggestion"), X = G.create({
|
|
127
128
|
name: "slashCommand",
|
|
128
129
|
addOptions() {
|
|
129
130
|
var f;
|
|
@@ -132,16 +133,16 @@ const Q = new O("slashSuggestion"), W = z.create({
|
|
|
132
133
|
slashSuggestion: {
|
|
133
134
|
char: "/",
|
|
134
135
|
startOfLine: !0,
|
|
135
|
-
command: ({ editor:
|
|
136
|
-
|
|
136
|
+
command: ({ editor: s, range: g, props: v }) => {
|
|
137
|
+
v.command({ editor: s, range: g, props: v });
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
};
|
|
140
141
|
},
|
|
141
142
|
addProseMirrorPlugins() {
|
|
142
143
|
return [
|
|
143
|
-
|
|
144
|
-
pluginKey:
|
|
144
|
+
Q({
|
|
145
|
+
pluginKey: V,
|
|
145
146
|
...this.options.slashSuggestion,
|
|
146
147
|
editor: this.editor
|
|
147
148
|
})
|
|
@@ -149,6 +150,6 @@ const Q = new O("slashSuggestion"), W = z.create({
|
|
|
149
150
|
}
|
|
150
151
|
});
|
|
151
152
|
export {
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
X as SlashCommand,
|
|
154
|
+
V as slashMenuPluginKey
|
|
154
155
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as l, t as c } from "../../../../index-
|
|
2
|
-
import { l as a, S as d } from "../../../../SlashCommandList-
|
|
1
|
+
import { R as l, t as c } from "../../../../index-Bl1eZGET.js";
|
|
2
|
+
import { l as a, S as d } from "../../../../SlashCommandList-DLPd43Tg.js";
|
|
3
3
|
const m = () => {
|
|
4
4
|
let n, t = [], r, i = !a.isEmpty(t);
|
|
5
5
|
return {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Content, Extension } from '@tiptap/react';
|
|
2
|
-
import { EditorProps } from '@tiptap/pm/view';
|
|
1
|
+
import { Content, Extension, JSONContent, UseEditorOptions } from '@tiptap/react';
|
|
3
2
|
import { KeyboardEventHandler } from 'react';
|
|
4
3
|
import { ClassValue } from 'clsx';
|
|
5
4
|
export type ScribeOnChangeContents = {
|
|
@@ -9,6 +8,8 @@ export type ScribeOnChangeContents = {
|
|
|
9
8
|
};
|
|
10
9
|
export interface ScribeRef {
|
|
11
10
|
resetContent: () => void;
|
|
11
|
+
getContent: (contentType: "html" | "json" | "markdown") => string | JSONContent | undefined;
|
|
12
|
+
setContent: (content: Content) => void;
|
|
12
13
|
}
|
|
13
14
|
export interface ScribeProps {
|
|
14
15
|
onContentChange?: (content: ScribeOnChangeContents) => void;
|
|
@@ -16,7 +17,7 @@ export interface ScribeProps {
|
|
|
16
17
|
editable?: boolean;
|
|
17
18
|
autoFocus?: boolean;
|
|
18
19
|
extensions?: Extension[];
|
|
19
|
-
editorProps?:
|
|
20
|
+
editorProps?: UseEditorOptions;
|
|
20
21
|
showBarMenu?: boolean;
|
|
21
22
|
placeholderText?: string;
|
|
22
23
|
editorContentStyle?: React.CSSProperties;
|
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { u as
|
|
3
|
-
import { initExtensions as
|
|
4
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as i, jsxs as S } from "react/jsx-runtime";
|
|
2
|
+
import { u as H, E as k } from "../../index-Bl1eZGET.js";
|
|
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
5
|
import A from "../Menu/BarMenu.js";
|
|
6
|
-
import { html2md as
|
|
7
|
-
import "../../browser-
|
|
8
|
-
function d(t) {
|
|
9
|
-
var
|
|
6
|
+
import { html2md as b } from "../../utils/html-to-markdown.js";
|
|
7
|
+
import "../../browser-Ce149ePN.js";
|
|
8
|
+
import '../../assets/index.css';function d(t) {
|
|
9
|
+
var o, s, e = "";
|
|
10
10
|
if (typeof t == "string" || typeof t == "number") e += t;
|
|
11
11
|
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
12
|
-
var
|
|
13
|
-
for (
|
|
14
|
-
} else for (
|
|
12
|
+
var r = t.length;
|
|
13
|
+
for (o = 0; o < r; o++) t[o] && (s = d(t[o])) && (e && (e += " "), e += s);
|
|
14
|
+
} else for (s in t) t[s] && (e && (e += " "), e += s);
|
|
15
15
|
return e;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
for (var t,
|
|
17
|
+
function p() {
|
|
18
|
+
for (var t, o, s = 0, e = "", r = arguments.length; s < r; s++) (t = arguments[s]) && (o = d(t)) && (e && (e += " "), e += o);
|
|
19
19
|
return e;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const R = L((t, o) => {
|
|
22
22
|
const {
|
|
23
|
-
autoFocus:
|
|
23
|
+
autoFocus: s = !1,
|
|
24
24
|
content: e,
|
|
25
|
-
editable:
|
|
26
|
-
editorProps:
|
|
27
|
-
extensions:
|
|
28
|
-
onContentChange:
|
|
29
|
-
showBarMenu:
|
|
30
|
-
editorContentStyle:
|
|
31
|
-
editorContentClassName:
|
|
32
|
-
mainContainerStyle:
|
|
33
|
-
mainContainerClassName:
|
|
34
|
-
onKeyDown:
|
|
35
|
-
} = t, n =
|
|
25
|
+
editable: r = !0,
|
|
26
|
+
editorProps: c,
|
|
27
|
+
extensions: h,
|
|
28
|
+
onContentChange: C,
|
|
29
|
+
showBarMenu: y = !0,
|
|
30
|
+
editorContentStyle: w,
|
|
31
|
+
editorContentClassName: x,
|
|
32
|
+
mainContainerStyle: v,
|
|
33
|
+
mainContainerClassName: E,
|
|
34
|
+
onKeyDown: N
|
|
35
|
+
} = t, n = H(
|
|
36
36
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
l
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
...c,
|
|
38
|
+
extensions: [...B(t), ...h ?? []],
|
|
39
|
+
onUpdate({ editor: a }) {
|
|
40
|
+
const m = a.getHTML(), l = a.getJSON();
|
|
41
|
+
C && C({
|
|
42
|
+
jsonContent: l,
|
|
43
|
+
htmlContent: m,
|
|
44
|
+
markdownContent: b(m)
|
|
44
45
|
});
|
|
45
46
|
},
|
|
46
47
|
editorProps: {
|
|
47
48
|
attributes: {
|
|
48
49
|
class: "scribe"
|
|
49
50
|
},
|
|
50
|
-
...
|
|
51
|
+
...c == null ? void 0 : c.editorProps
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
54
|
[]
|
|
54
|
-
),
|
|
55
|
+
), g = f(() => {
|
|
55
56
|
n == null || n.commands.setContent("");
|
|
57
|
+
}, []), j = f((a) => {
|
|
58
|
+
var l;
|
|
59
|
+
const m = {
|
|
60
|
+
html: () => n == null ? void 0 : n.getHTML(),
|
|
61
|
+
json: () => n == null ? void 0 : n.getJSON(),
|
|
62
|
+
markdown: () => b((n == null ? void 0 : n.getHTML()) || "")
|
|
63
|
+
};
|
|
64
|
+
return n != null && n.isEmpty ? "" : (l = m[a]) == null ? void 0 : l.call(m);
|
|
65
|
+
}, []), M = f((a) => {
|
|
66
|
+
n == null || n.commands.setContent(a);
|
|
56
67
|
}, []);
|
|
57
|
-
return
|
|
58
|
-
resetContent:
|
|
59
|
-
|
|
68
|
+
return T(o, () => ({
|
|
69
|
+
resetContent: g,
|
|
70
|
+
setContent: M,
|
|
71
|
+
getContent: j
|
|
72
|
+
}), [g]), u(() => {
|
|
60
73
|
n == null || n.commands.setContent(e || "");
|
|
61
|
-
}, [e]),
|
|
62
|
-
n == null || n.setEditable(!!
|
|
63
|
-
}, [
|
|
64
|
-
|
|
65
|
-
}, [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
className: m(
|
|
77
|
-
"prose max-w-none",
|
|
78
|
-
s && "w-full p-[16px]",
|
|
79
|
-
h
|
|
80
|
-
),
|
|
81
|
-
style: g,
|
|
82
|
-
children: /* @__PURE__ */ a(j, { editor: n, onKeyDown: x })
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
] })
|
|
86
|
-
}
|
|
87
|
-
);
|
|
74
|
+
}, [e]), u(() => {
|
|
75
|
+
n == null || n.setEditable(!!r);
|
|
76
|
+
}, [r]), u(() => {
|
|
77
|
+
s && (n == null || n.commands.focus("end"));
|
|
78
|
+
}, [s]), /* @__PURE__ */ i("div", { className: p("scribe-wrapper", E), style: v, id: "scribe-wrapper", children: /* @__PURE__ */ S("div", { className: p("bg-white", r && "rounded-lg border"), children: [
|
|
79
|
+
n && y && /* @__PURE__ */ i(A, { editor: n }),
|
|
80
|
+
/* @__PURE__ */ i(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: p("prose max-w-none", r && "w-full p-[16px]", x),
|
|
84
|
+
style: w,
|
|
85
|
+
children: /* @__PURE__ */ i(k, { editor: n, onKeyDown: N })
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
] }) });
|
|
88
89
|
});
|
|
89
90
|
export {
|
|
90
|
-
|
|
91
|
+
R as Scribe
|
|
91
92
|
};
|