@clevertask/scribe 0.1.3 → 0.1.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.
Files changed (32) hide show
  1. package/dist/{BarMenu-DaKIz3zZ.js → BarMenu-BNk2I0zi.js} +1 -1
  2. package/dist/assets/index.css +1 -1
  3. package/dist/components/Menu/BarMenu.js +2 -2
  4. package/dist/components/Menu/BubbleMenu.js +378 -1445
  5. package/dist/components/Menu/Mobile/ListOptionBar.d.ts +1 -1
  6. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  7. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  8. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  9. package/dist/components/Scribe/extension/extension-link.js +1 -1
  10. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  11. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  12. package/dist/components/Scribe/extension/index.js +5735 -3383
  13. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  14. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  15. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  16. package/dist/components/Scribe/index.js +5 -5
  17. package/dist/{extension-link-Ch_T7WWG.js → extension-link-P1rro4zO.js} +247 -218
  18. package/dist/floating-ui.dom-ZRy7FSVk.js +1246 -0
  19. package/dist/{index-DxF-1P4n.js → index-BMISMQrG.js} +168 -147
  20. package/dist/{index-CqzMmrnw.js → index-ByyiiYsp.js} +1 -1
  21. package/dist/{index-BiBV5TQx.js → index-CnKS-BY2.js} +2644 -2323
  22. package/dist/index-CnQHDObA.js +539 -0
  23. package/dist/main.js +1 -1
  24. package/dist/{markdown-to-html-pL7ckd-m.js → markdown-to-html-Bw9L43K6.js} +1 -1
  25. package/dist/purify.es-DC1iJOxX.js +864 -0
  26. package/dist/utils/create-scribe-editor.js +3 -3
  27. package/dist/utils/html-to-markdown.js +1 -1
  28. package/dist/utils/index.js +1 -1
  29. package/dist/utils/markdown-to-html.js +2 -2
  30. package/package.json +31 -31
  31. package/dist/index-V-gN11Y9.js +0 -249
  32. package/dist/purify.es-exIQuqhb.js +0 -595
@@ -0,0 +1,539 @@
1
+ import { P as U, b as N, D as K, e as j, g as z, a as H } from "./index-CnKS-BY2.js";
2
+ import { o as Q, f as V, a as W, c as G } from "./floating-ui.dom-ZRy7FSVk.js";
3
+ function J(t) {
4
+ var s;
5
+ const {
6
+ char: o,
7
+ allowSpaces: n,
8
+ allowToIncludeChar: r,
9
+ allowedPrefixes: u,
10
+ startOfLine: a,
11
+ $position: c
12
+ } = t, d = n && !r, g = z(o), m = new RegExp(`\\s${g}$`), l = a ? "^" : "", f = r ? "" : g, S = d ? new RegExp(`${l}${g}.*?(?=\\s${f}|$)`, "gm") : new RegExp(`${l}(?:^)?${g}[^\\s${f}]*`, "gm"), p = ((s = c.nodeBefore) == null ? void 0 : s.isText) && c.nodeBefore.text;
13
+ if (!p)
14
+ return null;
15
+ const y = c.pos - p.length, i = Array.from(p.matchAll(S)).pop();
16
+ if (!i || i.input === void 0 || i.index === void 0)
17
+ return null;
18
+ const x = i.input.slice(Math.max(0, i.index - 1), i.index), _ = new RegExp(`^[${u?.join("")}\0]?$`).test(x);
19
+ if (u !== null && !_)
20
+ return null;
21
+ const b = y + i.index;
22
+ let e = b + i[0].length;
23
+ return d && m.test(p.slice(e - 1, e + 1)) && (i[0] += " ", e += 1), b < c.pos && e >= c.pos ? {
24
+ range: {
25
+ from: b,
26
+ to: e
27
+ },
28
+ query: i[0].slice(o.length),
29
+ text: i[0]
30
+ } : null;
31
+ }
32
+ function X(t) {
33
+ return t.docChanged ? t.steps.some((s) => {
34
+ const o = s.slice;
35
+ if (!o?.content)
36
+ return !1;
37
+ const n = o.content.textBetween(0, o.content.size, `
38
+ `);
39
+ return /\s/.test(n);
40
+ }) : !1;
41
+ }
42
+ function Y(t) {
43
+ return () => {
44
+ const s = t.state.selection.$anchor.pos, o = t.view.coordsAtPos(s), { top: n, right: r, bottom: u, left: a } = o;
45
+ try {
46
+ return new DOMRect(a, n, r - a, u - n);
47
+ } catch {
48
+ return null;
49
+ }
50
+ };
51
+ }
52
+ function Z(t, s, o, n) {
53
+ return o ? () => {
54
+ const r = n.getState(t.state), u = r?.decorationId, a = s.dom.querySelector(`[data-decoration-id="${u}"]`);
55
+ return a?.getBoundingClientRect() || null;
56
+ } : Y(t);
57
+ }
58
+ function tt({
59
+ match: t,
60
+ dismissedRange: s,
61
+ state: o,
62
+ transaction: n,
63
+ editor: r,
64
+ shouldResetDismissed: u,
65
+ effectiveAllowSpaces: a
66
+ }) {
67
+ return u?.({
68
+ editor: r,
69
+ state: o,
70
+ range: s,
71
+ match: t,
72
+ transaction: n,
73
+ allowSpaces: a
74
+ }) ? !1 : a ? t.range.from === s.from : t.range.from === s.from && !X(n);
75
+ }
76
+ function et({
77
+ view: t,
78
+ pluginKeyRef: s
79
+ }) {
80
+ const o = t.state.tr.setMeta(s, { exit: !0 });
81
+ t.dispatch(o);
82
+ }
83
+ function nt({
84
+ pluginKey: t,
85
+ decorationTag: s,
86
+ decorationClass: o,
87
+ decorationContent: n,
88
+ decorationEmptyClass: r,
89
+ renderer: u,
90
+ dispatchExit: a
91
+ }) {
92
+ return {
93
+ /**
94
+ * Call the keydown hook if suggestion is active.
95
+ */
96
+ handleKeyDown(c, d) {
97
+ var g, m;
98
+ const l = t.getState(c.state);
99
+ return l.active ? d.key === "Escape" || d.key === "Esc" ? ((g = u?.onKeyDown) == null || g.call(u, { view: c, event: d, range: l.range }), a(c), !0) : ((m = u?.onKeyDown) == null ? void 0 : m.call(u, { view: c, event: d, range: l.range })) || !1 : !1;
100
+ },
101
+ /**
102
+ * Setup decorator on the currently active suggestion.
103
+ */
104
+ decorations(c) {
105
+ const d = t.getState(c), { active: g, range: m, decorationId: l, query: f } = d;
106
+ if (!g)
107
+ return null;
108
+ const S = !f?.length, p = [o];
109
+ return S && p.push(r), K.create(c.doc, [
110
+ j.inline(m.from, m.to, {
111
+ nodeName: s,
112
+ class: p.join(" "),
113
+ "data-decoration-id": l || void 0,
114
+ "data-decoration-content": n
115
+ })
116
+ ]);
117
+ }
118
+ };
119
+ }
120
+ function ot({
121
+ editor: t,
122
+ char: s,
123
+ effectiveAllowSpaces: o,
124
+ allowToIncludeChar: n,
125
+ allowedPrefixes: r,
126
+ startOfLine: u,
127
+ findSuggestionMatch: a,
128
+ allow: c,
129
+ shouldShow: d,
130
+ shouldKeepDismissed: g,
131
+ pluginKey: m
132
+ }) {
133
+ return {
134
+ /**
135
+ * Initialize the plugin's internal state.
136
+ */
137
+ init() {
138
+ return {
139
+ active: !1,
140
+ range: { from: 0, to: 0 },
141
+ query: null,
142
+ text: null,
143
+ composing: !1,
144
+ dismissedRange: null
145
+ };
146
+ },
147
+ /**
148
+ * Apply changes to the plugin state from a view transaction.
149
+ */
150
+ apply(l, f, S, p) {
151
+ const { isEditable: y } = t, { composing: i } = t.view, { selection: x } = l, { empty: _, from: b } = x, e = { ...f }, R = l.getMeta(m);
152
+ if (R && R.exit)
153
+ return e.active = !1, e.decorationId = null, e.range = { from: 0, to: 0 }, e.query = null, e.text = null, e.dismissedRange = f.active ? { ...f.range } : f.dismissedRange, e;
154
+ if (e.composing = i, l.docChanged && e.dismissedRange !== null && (e.dismissedRange = {
155
+ from: l.mapping.map(e.dismissedRange.from),
156
+ to: l.mapping.map(e.dismissedRange.to)
157
+ }), y && (_ || t.view.composing)) {
158
+ (b < f.range.from || b > f.range.to) && !i && !f.composing && (e.active = !1);
159
+ const v = a({
160
+ char: s,
161
+ allowSpaces: o,
162
+ allowToIncludeChar: n,
163
+ allowedPrefixes: r,
164
+ startOfLine: u,
165
+ $position: x.$from
166
+ }), C = `id_${Math.floor(Math.random() * 4294967295)}`;
167
+ v && c({
168
+ editor: t,
169
+ state: p,
170
+ range: v.range,
171
+ isActive: f.active
172
+ }) && (!d || d({
173
+ editor: t,
174
+ range: v.range,
175
+ query: v.query,
176
+ text: v.text,
177
+ transaction: l
178
+ })) ? (e.dismissedRange !== null && !g({
179
+ match: v,
180
+ dismissedRange: e.dismissedRange,
181
+ state: p,
182
+ transaction: l
183
+ }) && (e.dismissedRange = null), e.dismissedRange === null ? (e.active = !0, e.decorationId = f.decorationId || C, e.range = v.range, e.query = v.query, e.text = v.text) : e.active = !1) : (v || (e.dismissedRange = null), e.active = !1);
184
+ } else
185
+ e.active = !1;
186
+ return e.active || (e.decorationId = null, e.range = { from: 0, to: 0 }, e.query = null, e.text = null), e;
187
+ }
188
+ };
189
+ }
190
+ function st({
191
+ editor: t,
192
+ items: s
193
+ }) {
194
+ let o = null, n = null, r = null;
195
+ const u = () => {
196
+ n !== null && (clearTimeout(n), n = null), r?.(), r = null;
197
+ }, a = (g) => new Promise((m) => {
198
+ r = m, n = setTimeout(() => {
199
+ n = null;
200
+ const l = r;
201
+ r = null, l?.();
202
+ }, g);
203
+ }), c = () => {
204
+ o?.abort(), u(), o = null;
205
+ };
206
+ return {
207
+ abort: c,
208
+ fetch: async (g, m) => {
209
+ c(), o = new AbortController();
210
+ const l = o;
211
+ if (m > 0 && await a(m), o !== l || l.signal.aborted)
212
+ return { status: "aborted" };
213
+ try {
214
+ const f = await s({
215
+ editor: t,
216
+ query: g,
217
+ signal: l.signal
218
+ });
219
+ return o !== l || l.signal.aborted ? { status: "aborted" } : { status: "resolved", items: f };
220
+ } catch {
221
+ return o !== l || l.signal.aborted ? { status: "aborted" } : { status: "error" };
222
+ }
223
+ }
224
+ };
225
+ }
226
+ function at({
227
+ placement: t,
228
+ offset: s,
229
+ flip: o,
230
+ floatingUi: n
231
+ }) {
232
+ var r, u, a, c;
233
+ const d = [
234
+ Q({
235
+ mainAxis: (r = s.mainAxis) != null ? r : 4,
236
+ crossAxis: (u = s.crossAxis) != null ? u : 0
237
+ })
238
+ ];
239
+ return o && d.push(V()), (a = n?.middleware) != null && a.length && d.push(...n.middleware), {
240
+ placement: t,
241
+ strategy: (c = n?.strategy) != null ? c : "absolute",
242
+ middleware: d
243
+ };
244
+ }
245
+ function it(t) {
246
+ if (t instanceof HTMLElement)
247
+ return t;
248
+ if (typeof t == "string")
249
+ try {
250
+ const s = document.querySelector(t);
251
+ if (s)
252
+ return s;
253
+ } catch {
254
+ return document.body;
255
+ }
256
+ return document.body;
257
+ }
258
+ function lt({
259
+ getReferenceRect: t,
260
+ contextElement: s,
261
+ config: o,
262
+ container: n,
263
+ dismissOnOutsideClick: r,
264
+ dismiss: u
265
+ }) {
266
+ return (a, c = {}) => {
267
+ const d = {
268
+ getBoundingClientRect: () => {
269
+ var p;
270
+ return (p = t()) != null ? p : new DOMRect();
271
+ },
272
+ contextElement: s
273
+ };
274
+ let g = !1;
275
+ const m = !a.isConnected;
276
+ m && it(n).appendChild(a), c.onPosition || (a.style.visibility = "hidden", a.style.width = "max-content");
277
+ const f = W(d, a, () => {
278
+ G(d, a, {
279
+ placement: o.placement,
280
+ strategy: o.strategy,
281
+ middleware: o.middleware
282
+ }).then(({ x: p, y, placement: i, strategy: x }) => {
283
+ if (c.onPosition) {
284
+ c.onPosition({ x: p, y, placement: i, strategy: x });
285
+ return;
286
+ }
287
+ Object.assign(a.style, {
288
+ position: x,
289
+ left: `${p}px`,
290
+ top: `${y}px`
291
+ }), g || (g = !0, a.style.visibility = "");
292
+ });
293
+ }, c.autoUpdate);
294
+ let S;
295
+ return r && (S = (p) => {
296
+ const y = p.target;
297
+ !(y instanceof Node) || a.contains(y) || s.contains(y) || u();
298
+ }, document.addEventListener("pointerdown", S, !0)), () => {
299
+ f(), S && document.removeEventListener("pointerdown", S, !0), m && a.remove();
300
+ };
301
+ };
302
+ }
303
+ function rt({
304
+ editor: t,
305
+ pluginKey: s,
306
+ items: o,
307
+ renderer: n,
308
+ minQueryLength: r,
309
+ debounce: u,
310
+ initialItems: a,
311
+ placement: c,
312
+ offset: d,
313
+ container: g,
314
+ flip: m,
315
+ floatingUi: l,
316
+ dismissOnOutsideClick: f,
317
+ command: S,
318
+ clientRectFor: p,
319
+ dispatchExit: y
320
+ }) {
321
+ let i;
322
+ const x = st({
323
+ editor: t,
324
+ items: o
325
+ }), _ = at({
326
+ placement: c,
327
+ offset: d,
328
+ flip: m,
329
+ floatingUi: l
330
+ });
331
+ function b(e, R) {
332
+ var v, C, $;
333
+ switch (e) {
334
+ case "started":
335
+ (v = n?.onStart) == null || v.call(n, R);
336
+ break;
337
+ case "updated":
338
+ (C = n?.onUpdate) == null || C.call(n, R);
339
+ break;
340
+ case "stopped":
341
+ ($ = n?.onExit) == null || $.call(n, R);
342
+ break;
343
+ }
344
+ }
345
+ return {
346
+ update: async (e, R) => {
347
+ var v, C, $, P;
348
+ const q = s.getState(R), w = s.getState(e.state);
349
+ if (!q || !w)
350
+ return;
351
+ let h = null;
352
+ const F = q.query !== w.query, B = q.text !== w.text, D = q.range.from !== w.range.from || q.range.to !== w.range.to, A = F || B || D;
353
+ if (!q.active && w.active)
354
+ h = "started";
355
+ else if (q.active && !w.active)
356
+ h = "stopped";
357
+ else if (w.active && A)
358
+ h = "updated";
359
+ else
360
+ return;
361
+ const E = h === "stopped" ? q : w, k = e.dom.querySelector(`[data-decoration-id="${E.decorationId}"]`), I = p(e, k), L = r === 0 || (E.query ? E.query.length >= r : !1), O = (h === "started" || h === "updated") && L;
362
+ if (i = {
363
+ editor: t,
364
+ range: E.range,
365
+ query: E.query || "",
366
+ text: E.text || "",
367
+ items: a ?? [],
368
+ command: (M) => S({
369
+ editor: t,
370
+ range: E.range,
371
+ props: M
372
+ }),
373
+ decorationNode: k,
374
+ clientRect: I,
375
+ loading: O,
376
+ placement: c,
377
+ offset: { mainAxis: (v = d.mainAxis) != null ? v : 4, crossAxis: (C = d.crossAxis) != null ? C : 0 },
378
+ container: g,
379
+ flip: m,
380
+ floatingUi: _,
381
+ mount: lt({
382
+ getReferenceRect: I,
383
+ contextElement: e.dom,
384
+ config: _,
385
+ container: g,
386
+ dismissOnOutsideClick: f,
387
+ dismiss: () => y(t.view)
388
+ })
389
+ }, h === "started" && (($ = n?.onBeforeStart) == null || $.call(n, i)), h === "updated" && ((P = n?.onBeforeUpdate) == null || P.call(n, i)), h === "started" && b(h, i), h === "started" || h === "updated")
390
+ if (!O)
391
+ x.abort(), i = { ...i, items: a ?? [], loading: !1 };
392
+ else {
393
+ i = { ...i, items: a ?? [], loading: !0 }, h = "updated", b(h, i);
394
+ const M = await x.fetch(E.query || "", u);
395
+ if (M.status === "aborted")
396
+ return;
397
+ const T = s.getState(e.state);
398
+ if (!T?.active) {
399
+ x.abort();
400
+ return;
401
+ }
402
+ i = M.status === "resolved" ? {
403
+ ...i,
404
+ items: M.items,
405
+ loading: !1
406
+ } : {
407
+ ...i,
408
+ loading: !1
409
+ };
410
+ }
411
+ if (h === "stopped") {
412
+ x.abort(), b(h, i), i = void 0;
413
+ return;
414
+ }
415
+ h === "updated" && b(h, i);
416
+ },
417
+ destroy: () => {
418
+ var e;
419
+ x.abort(), i && ((e = n?.onExit) == null || e.call(n, i));
420
+ }
421
+ };
422
+ }
423
+ var ct = new U("suggestion");
424
+ function ut({
425
+ pluginKey: t = ct,
426
+ editor: s,
427
+ char: o = "@",
428
+ allowSpaces: n = !1,
429
+ allowToIncludeChar: r = !1,
430
+ allowedPrefixes: u = [" "],
431
+ startOfLine: a = !1,
432
+ decorationTag: c = "span",
433
+ decorationClass: d = "suggestion",
434
+ decorationContent: g = "",
435
+ decorationEmptyClass: m = "is-empty",
436
+ command: l = () => null,
437
+ items: f = () => [],
438
+ minQueryLength: S = 0,
439
+ debounce: p = 0,
440
+ initialItems: y,
441
+ placement: i = "bottom-start",
442
+ offset: x = {},
443
+ container: _,
444
+ flip: b = !0,
445
+ floatingUi: e,
446
+ dismissOnOutsideClick: R = !0,
447
+ render: v = () => ({}),
448
+ allow: C = () => !0,
449
+ findSuggestionMatch: $ = J,
450
+ shouldShow: P,
451
+ shouldResetDismissed: q
452
+ }) {
453
+ const w = v?.(), h = n && !r, F = (A, E) => Z(s, A, E, t);
454
+ function B(A) {
455
+ return tt({
456
+ ...A,
457
+ editor: s,
458
+ shouldResetDismissed: q,
459
+ effectiveAllowSpaces: h
460
+ });
461
+ }
462
+ const D = (A) => et({
463
+ view: A,
464
+ pluginKeyRef: t
465
+ });
466
+ return new N({
467
+ key: t,
468
+ view: () => rt({
469
+ editor: s,
470
+ pluginKey: t,
471
+ items: f,
472
+ renderer: w,
473
+ minQueryLength: S,
474
+ debounce: p,
475
+ initialItems: y,
476
+ placement: i,
477
+ offset: x,
478
+ container: _,
479
+ flip: b,
480
+ floatingUi: e,
481
+ dismissOnOutsideClick: R,
482
+ command: l,
483
+ clientRectFor: F,
484
+ dispatchExit: D
485
+ }),
486
+ state: ot({
487
+ editor: s,
488
+ char: o,
489
+ effectiveAllowSpaces: h,
490
+ allowToIncludeChar: r,
491
+ allowedPrefixes: u,
492
+ startOfLine: a,
493
+ findSuggestionMatch: $,
494
+ allow: C,
495
+ shouldShow: P,
496
+ shouldKeepDismissed: B,
497
+ pluginKey: t
498
+ }),
499
+ props: nt({
500
+ pluginKey: t,
501
+ decorationTag: c,
502
+ decorationClass: d,
503
+ decorationContent: g,
504
+ decorationEmptyClass: m,
505
+ renderer: w,
506
+ dispatchExit: D
507
+ })
508
+ });
509
+ }
510
+ var dt = ut;
511
+ const ft = new U("slashSuggestion"), pt = H.create({
512
+ name: "slashCommand",
513
+ addOptions() {
514
+ return {
515
+ ...this.parent?.(),
516
+ slashSuggestion: {
517
+ char: "/",
518
+ startOfLine: !0,
519
+ command: ({ editor: t, range: s, props: o }) => {
520
+ o.command({ editor: t, range: s, props: o });
521
+ }
522
+ }
523
+ };
524
+ },
525
+ addProseMirrorPlugins() {
526
+ return [
527
+ dt({
528
+ pluginKey: ft,
529
+ ...this.options.slashSuggestion,
530
+ editor: this.editor
531
+ })
532
+ ];
533
+ }
534
+ });
535
+ export {
536
+ ut as S,
537
+ pt as a,
538
+ ft as s
539
+ };
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 i } from "./markdown-to-html-pL7ckd-m.js";
3
+ import { m as i } from "./markdown-to-html-Bw9L43K6.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 d } from "./utils/create-scribe-editor.js";
@@ -1,4 +1,4 @@
1
- import { p as xe } from "./purify.es-exIQuqhb.js";
1
+ import { p as xe } from "./purify.es-DC1iJOxX.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
  }