@clevertask/scribe 0.0.9 → 0.0.11
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 +23 -0
- package/dist/browser-BJWkU9cc.js +2106 -0
- package/dist/clsx-OuTLNxxd.js +16 -0
- package/dist/components/Menu/BarMenu.d.ts +1 -0
- package/dist/components/Menu/BarMenu.js +38 -36
- package/dist/components/Menu/BubbleMenu.js +1 -1
- package/dist/components/Scribe/extension/emoji/EmojiList.d.ts +1 -0
- package/dist/components/Scribe/extension/emoji/EmojiList.js +35 -0
- package/dist/components/Scribe/extension/emoji/suggest.d.ts +16 -0
- package/dist/components/Scribe/extension/emoji/suggest.js +40 -0
- package/dist/components/Scribe/extension/extension-link.js +208 -200
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/index.js +30 -24
- package/dist/components/Scribe/extension/math-extension.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +7 -5
- package/dist/components/Scribe/extension/slashCommand/index.js +4 -153
- package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +14 -14
- package/dist/components/Scribe/index.d.ts +1 -0
- package/dist/components/Scribe/index.js +69 -75
- package/dist/index-BqFHWqw6.js +156 -0
- package/dist/{index-C3_lI_rP.js → index-C_aWB8qt.js} +449 -427
- package/dist/index-CasgquAq.js +39381 -0
- package/dist/{index-Gm-3o3nq.js → index-DeZ8laak.js} +1124 -1083
- package/dist/main.css +95 -5
- package/dist/{turndown.browser.es-BSoGafvq.js → turndown.browser.es-C1wFFc_i.js} +342 -334
- package/dist/utils/create-scribe-editor.js +2 -2
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +33 -31
- package/dist/browser-DEobZXxB.js +0 -2099
- package/dist/index-NRgJVTH-.js +0 -7576
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { b as F, P as T, D as U, c as j, e as z, a as G } from "./index-DeZ8laak.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
|
+
return null;
|
|
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
|
+
return null;
|
|
10
|
+
const n = o.input.slice(Math.max(0, o.index - 1), o.index), a = new RegExp(`^[${m == null ? void 0 : m.join("")}\0]?$`).test(n);
|
|
11
|
+
if (m !== null && !a)
|
|
12
|
+
return null;
|
|
13
|
+
const i = e + o.index;
|
|
14
|
+
let l = i + o[0].length;
|
|
15
|
+
return P && D.test(r.slice(l - 1, l + 1)) && (o[0] += " ", l += 1), i < d.pos && l >= d.pos ? {
|
|
16
|
+
range: {
|
|
17
|
+
from: i,
|
|
18
|
+
to: l
|
|
19
|
+
},
|
|
20
|
+
query: o[0].slice(g.length),
|
|
21
|
+
text: o[0]
|
|
22
|
+
} : null;
|
|
23
|
+
}
|
|
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
|
+
key: f,
|
|
29
|
+
view() {
|
|
30
|
+
return {
|
|
31
|
+
update: async (n, a) => {
|
|
32
|
+
var i, l, u, x, y, w, S;
|
|
33
|
+
const t = (i = this.key) === null || i === void 0 ? void 0 : i.getState(a), 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
|
+
return;
|
|
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
|
+
items: [],
|
|
43
|
+
command: (E) => p({
|
|
44
|
+
editor: s,
|
|
45
|
+
range: $.range,
|
|
46
|
+
props: E
|
|
47
|
+
}),
|
|
48
|
+
decorationNode: N,
|
|
49
|
+
// virtual node for popper.js or tippy.js
|
|
50
|
+
// this can be used for building popups without a DOM node
|
|
51
|
+
clientRect: N ? () => {
|
|
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
|
+
} : null
|
|
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
|
+
},
|
|
61
|
+
destroy: () => {
|
|
62
|
+
var n;
|
|
63
|
+
r && ((n = e == null ? void 0 : e.onExit) === null || n === void 0 || n.call(e, r));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
state: {
|
|
68
|
+
// Initialize the plugin's internal state.
|
|
69
|
+
init() {
|
|
70
|
+
return {
|
|
71
|
+
active: !1,
|
|
72
|
+
range: {
|
|
73
|
+
from: 0,
|
|
74
|
+
to: 0
|
|
75
|
+
},
|
|
76
|
+
query: null,
|
|
77
|
+
text: null,
|
|
78
|
+
composing: !1
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
// Apply changes to the plugin state from a view transaction.
|
|
82
|
+
apply(n, a, i, l) {
|
|
83
|
+
const { isEditable: u } = s, { composing: x } = s.view, { selection: y } = n, { empty: w, from: S } = y, t = { ...a };
|
|
84
|
+
if (t.composing = x, u && (w || s.view.composing)) {
|
|
85
|
+
(S < a.range.from || S > a.range.to) && !x && !a.composing && (t.active = !1);
|
|
86
|
+
const c = K({
|
|
87
|
+
char: g,
|
|
88
|
+
allowSpaces: v,
|
|
89
|
+
allowToIncludeChar: I,
|
|
90
|
+
allowedPrefixes: m,
|
|
91
|
+
startOfLine: R,
|
|
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,
|
|
98
|
+
isActive: a.active
|
|
99
|
+
}) ? (t.active = !0, t.decorationId = a.decorationId ? a.decorationId : q, t.range = c.range, t.query = c.query, t.text = c.text) : t.active = !1;
|
|
100
|
+
} else
|
|
101
|
+
t.active = !1;
|
|
102
|
+
return t.active || (t.decorationId = null, t.range = { from: 0, to: 0 }, t.query = null, t.text = null), t;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
props: {
|
|
106
|
+
// Call the keydown hook if suggestion is active.
|
|
107
|
+
handleKeyDown(n, a) {
|
|
108
|
+
var i;
|
|
109
|
+
const { active: l, range: u } = o.getState(n.state);
|
|
110
|
+
return l && ((i = e == null ? void 0 : e.onKeyDown) === null || i === void 0 ? void 0 : i.call(e, { view: n, event: a, range: u })) || !1;
|
|
111
|
+
},
|
|
112
|
+
// Setup decorator on the currently active suggestion.
|
|
113
|
+
decorations(n) {
|
|
114
|
+
const { active: a, range: i, decorationId: l } = o.getState(n);
|
|
115
|
+
return a ? U.create(n.doc, [
|
|
116
|
+
j.inline(i.from, i.to, {
|
|
117
|
+
nodeName: d,
|
|
118
|
+
class: P,
|
|
119
|
+
"data-decoration-id": l
|
|
120
|
+
})
|
|
121
|
+
]) : null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return o;
|
|
126
|
+
}
|
|
127
|
+
const V = new F("slashSuggestion"), X = G.create({
|
|
128
|
+
name: "slashCommand",
|
|
129
|
+
addOptions() {
|
|
130
|
+
var f;
|
|
131
|
+
return {
|
|
132
|
+
...(f = this.parent) == null ? void 0 : f.call(this),
|
|
133
|
+
slashSuggestion: {
|
|
134
|
+
char: "/",
|
|
135
|
+
startOfLine: !0,
|
|
136
|
+
command: ({ editor: s, range: g, props: v }) => {
|
|
137
|
+
v.command({ editor: s, range: g, props: v });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
addProseMirrorPlugins() {
|
|
143
|
+
return [
|
|
144
|
+
Q({
|
|
145
|
+
pluginKey: V,
|
|
146
|
+
...this.options.slashSuggestion,
|
|
147
|
+
editor: this.editor
|
|
148
|
+
})
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
export {
|
|
153
|
+
X as S,
|
|
154
|
+
Q as a,
|
|
155
|
+
V as s
|
|
156
|
+
};
|