@clevertask/scribe 0.1.0 → 0.1.1

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.
Files changed (37) hide show
  1. package/README.md +60 -16
  2. package/dist/{BarMenu-BDtEfu-R.js → BarMenu-DaKIz3zZ.js} +1 -1
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.js +2 -2
  5. package/dist/components/Menu/BubbleMenu.js +78 -74
  6. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  7. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  8. package/dist/components/Scribe/extension/extension-link.js +1 -1
  9. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  10. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  11. package/dist/components/Scribe/extension/index.d.ts +16 -2
  12. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  13. package/dist/components/Scribe/extension/index.js +2655 -2580
  14. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +1616 -1618
  15. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  16. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  17. package/dist/components/Scribe/extension/tableOfContents.d.ts +48 -0
  18. package/dist/components/Scribe/extension/tableOfContents.d.ts.map +1 -0
  19. package/dist/components/Scribe/extension/tableOfContents.js +180 -0
  20. package/dist/components/Scribe/index.d.ts +12 -0
  21. package/dist/components/Scribe/index.d.ts.map +1 -1
  22. package/dist/components/Scribe/index.js +108 -65
  23. package/dist/{extension-link-D3eyOFkn.js → extension-link-Ch_T7WWG.js} +1 -1
  24. package/dist/{index-hHvpW2H6.js → index-BiBV5TQx.js} +1287 -1250
  25. package/dist/{index-FY_iYS6i.js → index-CqzMmrnw.js} +1 -1
  26. package/dist/{index-PJNQPLn5.js → index-DxF-1P4n.js} +196 -203
  27. package/dist/index-V-gN11Y9.js +249 -0
  28. package/dist/main.js +1 -1
  29. package/dist/{markdown-to-html-BwS08CTi.js → markdown-to-html-pL7ckd-m.js} +14 -14
  30. package/dist/purify.es-exIQuqhb.js +595 -0
  31. package/dist/utils/create-scribe-editor.js +3 -3
  32. package/dist/utils/html-to-markdown.js +226 -306
  33. package/dist/utils/index.js +1 -1
  34. package/dist/utils/markdown-to-html.js +2 -2
  35. package/package.json +30 -30
  36. package/dist/index-DZylq4Bc.js +0 -232
  37. package/dist/purify.es-BPDBzHtc.js +0 -552
@@ -0,0 +1,249 @@
1
+ import { P as z, b as J, D as Q, e as V, g as X, a as Y } from "./index-BiBV5TQx.js";
2
+ function Z(u) {
3
+ var s;
4
+ const { char: g, allowSpaces: y, allowToIncludeChar: $, allowedPrefixes: E, startOfLine: k, $position: h } = u, P = y && !$, S = X(g), N = new RegExp(`\\s${S}$`), _ = k ? "^" : "", M = $ ? "" : S, C = P ? new RegExp(`${_}${S}.*?(?=\\s${M}|$)`, "gm") : new RegExp(`${_}(?:^)?${S}[^\\s${M}]*`, "gm"), R = ((s = h.nodeBefore) == null ? void 0 : s.isText) && h.nodeBefore.text;
5
+ if (!R)
6
+ return null;
7
+ const O = h.pos - R.length, c = Array.from(R.matchAll(C)).pop();
8
+ if (!c || c.input === void 0 || c.index === void 0)
9
+ return null;
10
+ const D = c.input.slice(Math.max(0, c.index - 1), c.index), f = new RegExp(`^[${E?.join("")}\0]?$`).test(D);
11
+ if (E !== null && !f)
12
+ return null;
13
+ const n = O + c.index;
14
+ let v = n + c[0].length;
15
+ return P && N.test(R.slice(v - 1, v + 1)) && (c[0] += " ", v += 1), n < h.pos && v >= h.pos ? {
16
+ range: {
17
+ from: n,
18
+ to: v
19
+ },
20
+ query: c[0].slice(g.length),
21
+ text: c[0]
22
+ } : null;
23
+ }
24
+ function ee(u) {
25
+ return u.docChanged ? u.steps.some((s) => {
26
+ const g = s.slice;
27
+ if (!g?.content)
28
+ return !1;
29
+ const y = g.content.textBetween(0, g.content.size, `
30
+ `);
31
+ return /\s/.test(y);
32
+ }) : !1;
33
+ }
34
+ var te = new z("suggestion");
35
+ function ne({
36
+ pluginKey: u = te,
37
+ editor: s,
38
+ char: g = "@",
39
+ allowSpaces: y = !1,
40
+ allowToIncludeChar: $ = !1,
41
+ allowedPrefixes: E = [" "],
42
+ startOfLine: k = !1,
43
+ decorationTag: h = "span",
44
+ decorationClass: P = "suggestion",
45
+ decorationContent: S = "",
46
+ decorationEmptyClass: N = "is-empty",
47
+ command: _ = () => null,
48
+ items: M = () => [],
49
+ render: C = () => ({}),
50
+ allow: R = () => !0,
51
+ findSuggestionMatch: O = Z,
52
+ shouldShow: c,
53
+ shouldResetDismissed: D
54
+ }) {
55
+ let f;
56
+ const n = C?.(), v = y && !$, T = () => {
57
+ const t = s.state.selection.$anchor.pos, o = s.view.coordsAtPos(t), { top: l, right: i, bottom: a, left: r } = o;
58
+ try {
59
+ return new DOMRect(r, l, i - r, a - l);
60
+ } catch {
61
+ return null;
62
+ }
63
+ }, j = (t, o) => o ? () => {
64
+ const l = u.getState(s.state), i = l?.decorationId, a = t.dom.querySelector(`[data-decoration-id="${i}"]`);
65
+ return a?.getBoundingClientRect() || null;
66
+ } : T, W = ({
67
+ match: t,
68
+ dismissedRange: o,
69
+ state: l,
70
+ transaction: i
71
+ }) => D?.({
72
+ editor: s,
73
+ state: l,
74
+ range: o,
75
+ match: t,
76
+ transaction: i,
77
+ allowSpaces: v
78
+ }) ? !1 : v ? t.range.from === o.from : t.range.from === o.from && !ee(i);
79
+ function G(t, o) {
80
+ var l;
81
+ try {
82
+ const a = u.getState(t.state), r = a?.decorationId ? t.dom.querySelector(`[data-decoration-id="${a.decorationId}"]`) : null, m = {
83
+ // @ts-ignore editor is available in closure
84
+ editor: s,
85
+ range: a?.range || { from: 0, to: 0 },
86
+ query: a?.query || null,
87
+ text: a?.text || null,
88
+ items: [],
89
+ command: (x) => _({ editor: s, range: a?.range || { from: 0, to: 0 }, props: x }),
90
+ decorationNode: r,
91
+ clientRect: j(t, r)
92
+ };
93
+ (l = n?.onExit) == null || l.call(n, m);
94
+ } catch {
95
+ }
96
+ const i = t.state.tr.setMeta(o, { exit: !0 });
97
+ t.dispatch(i);
98
+ }
99
+ const A = new J({
100
+ key: u,
101
+ view() {
102
+ return {
103
+ update: async (t, o) => {
104
+ var l, i, a, r, m, x, I;
105
+ const e = (l = this.key) == null ? void 0 : l.getState(o), p = (i = this.key) == null ? void 0 : i.getState(t.state), d = e.active && p.active && e.range.from !== p.range.from, B = !e.active && p.active, L = e.active && !p.active, K = !B && !L && e.query !== p.query, w = B || d && K, b = K || d, F = L || d && K;
106
+ if (!w && !b && !F)
107
+ return;
108
+ const q = F && !w ? e : p, U = t.dom.querySelector(`[data-decoration-id="${q.decorationId}"]`);
109
+ f = {
110
+ editor: s,
111
+ range: q.range,
112
+ query: q.query,
113
+ text: q.text,
114
+ items: [],
115
+ command: (H) => _({
116
+ editor: s,
117
+ range: q.range,
118
+ props: H
119
+ }),
120
+ decorationNode: U,
121
+ clientRect: j(t, U)
122
+ }, w && ((a = n?.onBeforeStart) == null || a.call(n, f)), b && ((r = n?.onBeforeUpdate) == null || r.call(n, f)), (b || w) && (f.items = await M({
123
+ editor: s,
124
+ query: q.query
125
+ })), F && ((m = n?.onExit) == null || m.call(n, f)), b && ((x = n?.onUpdate) == null || x.call(n, f)), w && ((I = n?.onStart) == null || I.call(n, f));
126
+ },
127
+ destroy: () => {
128
+ var t;
129
+ f && ((t = n?.onExit) == null || t.call(n, f));
130
+ }
131
+ };
132
+ },
133
+ state: {
134
+ // Initialize the plugin's internal state.
135
+ init() {
136
+ return {
137
+ active: !1,
138
+ range: {
139
+ from: 0,
140
+ to: 0
141
+ },
142
+ query: null,
143
+ text: null,
144
+ composing: !1,
145
+ dismissedRange: null
146
+ };
147
+ },
148
+ // Apply changes to the plugin state from a view transaction.
149
+ apply(t, o, l, i) {
150
+ const { isEditable: a } = s, { composing: r } = s.view, { selection: m } = t, { empty: x, from: I } = m, e = { ...o }, p = t.getMeta(u);
151
+ if (p && p.exit)
152
+ return e.active = !1, e.decorationId = null, e.range = { from: 0, to: 0 }, e.query = null, e.text = null, e.dismissedRange = o.active ? { ...o.range } : o.dismissedRange, e;
153
+ if (e.composing = r, t.docChanged && e.dismissedRange !== null && (e.dismissedRange = {
154
+ from: t.mapping.map(e.dismissedRange.from),
155
+ to: t.mapping.map(e.dismissedRange.to)
156
+ }), a && (x || s.view.composing)) {
157
+ (I < o.range.from || I > o.range.to) && !r && !o.composing && (e.active = !1);
158
+ const d = O({
159
+ char: g,
160
+ allowSpaces: y,
161
+ allowToIncludeChar: $,
162
+ allowedPrefixes: E,
163
+ startOfLine: k,
164
+ $position: m.$from
165
+ }), B = `id_${Math.floor(Math.random() * 4294967295)}`;
166
+ d && R({
167
+ editor: s,
168
+ state: i,
169
+ range: d.range,
170
+ isActive: o.active
171
+ }) && (!c || c({
172
+ editor: s,
173
+ range: d.range,
174
+ query: d.query,
175
+ text: d.text,
176
+ transaction: t
177
+ })) ? (e.dismissedRange !== null && !W({
178
+ match: d,
179
+ dismissedRange: e.dismissedRange,
180
+ state: i,
181
+ transaction: t
182
+ }) && (e.dismissedRange = null), e.dismissedRange === null ? (e.active = !0, e.decorationId = o.decorationId ? o.decorationId : B, e.range = d.range, e.query = d.query, e.text = d.text) : e.active = !1) : (d || (e.dismissedRange = null), e.active = !1);
183
+ } else
184
+ e.active = !1;
185
+ return e.active || (e.decorationId = null, e.range = { from: 0, to: 0 }, e.query = null, e.text = null), e;
186
+ }
187
+ },
188
+ props: {
189
+ // Call the keydown hook if suggestion is active.
190
+ handleKeyDown(t, o) {
191
+ var l, i;
192
+ const { active: a, range: r } = A.getState(t.state);
193
+ if (!a)
194
+ return !1;
195
+ if (o.key === "Escape" || o.key === "Esc") {
196
+ const x = A.getState(t.state);
197
+ return (l = n?.onKeyDown) == null || l.call(n, { view: t, event: o, range: x.range }), G(t, u), !0;
198
+ }
199
+ return ((i = n?.onKeyDown) == null ? void 0 : i.call(n, { view: t, event: o, range: r })) || !1;
200
+ },
201
+ // Setup decorator on the currently active suggestion.
202
+ decorations(t) {
203
+ const { active: o, range: l, decorationId: i, query: a } = A.getState(t);
204
+ if (!o)
205
+ return null;
206
+ const r = !a?.length, m = [P];
207
+ return r && m.push(N), Q.create(t.doc, [
208
+ V.inline(l.from, l.to, {
209
+ nodeName: h,
210
+ class: m.join(" "),
211
+ "data-decoration-id": i,
212
+ "data-decoration-content": S
213
+ })
214
+ ]);
215
+ }
216
+ }
217
+ });
218
+ return A;
219
+ }
220
+ var oe = ne;
221
+ const ae = new z("slashSuggestion"), le = Y.create({
222
+ name: "slashCommand",
223
+ addOptions() {
224
+ return {
225
+ ...this.parent?.(),
226
+ slashSuggestion: {
227
+ char: "/",
228
+ startOfLine: !0,
229
+ command: ({ editor: u, range: s, props: g }) => {
230
+ g.command({ editor: u, range: s, props: g });
231
+ }
232
+ }
233
+ };
234
+ },
235
+ addProseMirrorPlugins() {
236
+ return [
237
+ oe({
238
+ pluginKey: ae,
239
+ ...this.options.slashSuggestion,
240
+ editor: this.editor
241
+ })
242
+ ];
243
+ }
244
+ });
245
+ export {
246
+ ne as S,
247
+ le as a,
248
+ ae as s
249
+ };
package/dist/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Scribe as o } from "./components/Scribe/index.js";
2
2
  import { html2md as m } from "./utils/html-to-markdown.js";
3
- import { m as p } from "./markdown-to-html-BwS08CTi.js";
3
+ import { m as p } from "./markdown-to-html-pL7ckd-m.js";
4
4
  import { isInViewport as x } from "./utils/is-in-viewport.js";
5
5
  import { convertLegacyMathDelimiters as a } from "./utils/convert-legacy-math-delimiters.js";
6
6
  import { createScribeEditor as h } from "./utils/create-scribe-editor.js";
@@ -1,4 +1,4 @@
1
- import { p as xe } from "./purify.es-BPDBzHtc.js";
1
+ import { p as xe } from "./purify.es-exIQuqhb.js";
2
2
  function H() {
3
3
  return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
4
4
  }
@@ -325,7 +325,7 @@ ${c}` : c;
325
325
  let s = this.rules.inline.emStrongLDelim.exec(n);
326
326
  if (!(!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && r.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[3]) || !r || this.rules.inline.punctuation.exec(r))) {
327
327
  let t = [...s[0]].length - 1, i, l, o = t, a = 0, h = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
328
- for (h.lastIndex = 0, e = e.slice(-1 * n.length + t); (s = h.exec(e)) != null; ) {
328
+ for (h.lastIndex = 0, e = e.slice(-1 * n.length + t); (s = h.exec(e)) !== null; ) {
329
329
  if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue;
330
330
  if (l = [...i].length, s[3] || s[4]) {
331
331
  o += l;
@@ -361,7 +361,7 @@ ${c}` : c;
361
361
  let s = this.rules.inline.delLDelim.exec(n);
362
362
  if (s && (!s[1] || !r || this.rules.inline.punctuation.exec(r))) {
363
363
  let t = [...s[0]].length - 1, i, l, o = t, a = this.rules.inline.delRDelim;
364
- for (a.lastIndex = 0, e = e.slice(-1 * n.length + t); (s = a.exec(e)) != null; ) {
364
+ for (a.lastIndex = 0, e = e.slice(-1 * n.length + t); (s = a.exec(e)) !== null; ) {
365
365
  if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (l = [...i].length, l !== t)) continue;
366
366
  if (s[3] || s[4]) {
367
367
  o += l;
@@ -535,11 +535,11 @@ ${c}` : c;
535
535
  let s = e, t = null;
536
536
  if (this.tokens.links) {
537
537
  let a = Object.keys(this.tokens.links);
538
- if (a.length > 0) for (; (t = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; ) a.includes(t[0].slice(t[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, t.index) + "[" + "a".repeat(t[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
538
+ if (a.length > 0) for (; (t = this.tokenizer.rules.inline.reflinkSearch.exec(s)) !== null; ) a.includes(t[0].slice(t[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, t.index) + "[" + "a".repeat(t[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
539
539
  }
540
- for (; (t = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; ) s = s.slice(0, t.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
540
+ for (; (t = this.tokenizer.rules.inline.anyPunctuation.exec(s)) !== null; ) s = s.slice(0, t.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
541
541
  let i;
542
- for (; (t = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; ) i = t[2] ? t[2].length : 0, s = s.slice(0, t.index + i) + "[" + "a".repeat(t[0].length - i - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
542
+ for (; (t = this.tokenizer.rules.inline.blockSkip.exec(s)) !== null; ) i = t[2] ? t[2].length : 0, s = s.slice(0, t.index + i) + "[" + "a".repeat(t[0].length - i - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
543
543
  s = this.options.hooks?.emStrongMask?.call({ lexer: this }, s) ?? s;
544
544
  let l = !1, o = "";
545
545
  for (; e; ) {
@@ -930,11 +930,11 @@ ${n}</tr>
930
930
  emStrongMask(n) {
931
931
  return n;
932
932
  }
933
- provideLexer() {
934
- return this.block ? b.lex : b.lexInline;
933
+ provideLexer(n = this.block) {
934
+ return n ? b.lex : b.lexInline;
935
935
  }
936
- provideParser() {
937
- return this.block ? w.parse : w.parseInline;
936
+ provideParser(n = this.block) {
937
+ return n ? w.parse : w.parseInline;
938
938
  }
939
939
  }, st = class {
940
940
  defaults = H();
@@ -1069,16 +1069,16 @@ ${n}</tr>
1069
1069
  if (typeof e > "u" || e === null) return i(new Error("marked(): input parameter is undefined or null"));
1070
1070
  if (typeof e != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
1071
1071
  if (t.hooks && (t.hooks.options = t, t.hooks.block = n), t.async) return (async () => {
1072
- let l = t.hooks ? await t.hooks.preprocess(e) : e, o = await (t.hooks ? await t.hooks.provideLexer() : n ? b.lex : b.lexInline)(l, t), a = t.hooks ? await t.hooks.processAllTokens(o) : o;
1072
+ let l = t.hooks ? await t.hooks.preprocess(e) : e, o = await (t.hooks ? await t.hooks.provideLexer(n) : n ? b.lex : b.lexInline)(l, t), a = t.hooks ? await t.hooks.processAllTokens(o) : o;
1073
1073
  t.walkTokens && await Promise.all(this.walkTokens(a, t.walkTokens));
1074
- let h = await (t.hooks ? await t.hooks.provideParser() : n ? w.parse : w.parseInline)(a, t);
1074
+ let h = await (t.hooks ? await t.hooks.provideParser(n) : n ? w.parse : w.parseInline)(a, t);
1075
1075
  return t.hooks ? await t.hooks.postprocess(h) : h;
1076
1076
  })().catch(i);
1077
1077
  try {
1078
1078
  t.hooks && (e = t.hooks.preprocess(e));
1079
- let l = (t.hooks ? t.hooks.provideLexer() : n ? b.lex : b.lexInline)(e, t);
1079
+ let l = (t.hooks ? t.hooks.provideLexer(n) : n ? b.lex : b.lexInline)(e, t);
1080
1080
  t.hooks && (l = t.hooks.processAllTokens(l)), t.walkTokens && this.walkTokens(l, t.walkTokens);
1081
- let o = (t.hooks ? t.hooks.provideParser() : n ? w.parse : w.parseInline)(l, t);
1081
+ let o = (t.hooks ? t.hooks.provideParser(n) : n ? w.parse : w.parseInline)(l, t);
1082
1082
  return t.hooks && (o = t.hooks.postprocess(o)), o;
1083
1083
  } catch (l) {
1084
1084
  return i(l);