@clevertask/scribe 0.0.11 → 0.0.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.
Files changed (32) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/components/Menu/BubbleMenu.js +1 -1
  3. package/dist/components/Menu/Mobile/ListOptionBar.d.ts +6 -0
  4. package/dist/components/Menu/Mobile/ListOptionBar.js +40 -0
  5. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  6. package/dist/components/Scribe/extension/extension-link.js +240 -244
  7. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  8. package/dist/components/Scribe/extension/index.d.ts +1 -1
  9. package/dist/components/Scribe/extension/index.js +24 -25
  10. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +5 -5
  11. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  12. package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
  13. package/dist/components/Scribe/index.d.ts +1 -0
  14. package/dist/components/Scribe/index.js +83 -60
  15. package/dist/index-B0pieAxt.js +160 -0
  16. package/dist/{index-CasgquAq.js → index-CCS9HOYd.js} +16838 -5188
  17. package/dist/{index-DeZ8laak.js → index-DoNRu1rY.js} +1573 -1513
  18. package/dist/index-VneQGVTd.js +2385 -0
  19. package/dist/main.css +4 -4
  20. package/dist/marked.esm-BS_MmRZC.js +1566 -0
  21. package/dist/purify.es-BGaRrCfO.js +553 -0
  22. package/dist/turndown.browser.es-RmA_HBaI.js +649 -0
  23. package/dist/utils/create-scribe-editor.js +7 -6
  24. package/dist/utils/html-to-markdown.js +7 -6
  25. package/dist/utils/markdown-to-html.js +4 -3
  26. package/package.json +13 -12
  27. package/dist/browser-BJWkU9cc.js +0 -2106
  28. package/dist/components/Scribe/extension/math-extension.d.ts +0 -2
  29. package/dist/components/Scribe/extension/math-extension.js +0 -11770
  30. package/dist/index-BqFHWqw6.js +0 -156
  31. package/dist/index-C_aWB8qt.js +0 -2291
  32. package/dist/turndown.browser.es-C1wFFc_i.js +0 -1172
@@ -1,4 +1,4 @@
1
- import { a as o } from "../../../index-DeZ8laak.js";
1
+ import { a as o } from "../../../index-DoNRu1rY.js";
2
2
  const s = o.create({
3
3
  name: "SelectedText",
4
4
  addCommands: () => ({
@@ -1,2 +1,2 @@
1
1
  import { ScribeProps } from '..';
2
- export declare const initExtensions: (props: ScribeProps) => (import('@tiptap/core').Mark<import('@tiptap/extension-link').LinkOptions, any> | import('@tiptap/core').Extension<any, any> | import('@tiptap/core').Node<any, any> | import('@tiptap/core').Mark<import('@tiptap/extension-highlight').HighlightOptions, any>)[];
2
+ export declare const initExtensions: (props: ScribeProps) => (import('@tiptap/core').Mark<import('@tiptap/extension-link').LinkOptions, any> | import('@tiptap/core').Extension<any, any> | import('@tiptap/core').Node<import('@tiptap/extension-table-row').TableRowOptions, any> | import('@tiptap/core').Mark<import('@tiptap/extension-highlight').HighlightOptions, any>)[];
@@ -1,33 +1,32 @@
1
1
  import r from "./extension-link.js";
2
- import { S as o, T as i, a, b as n, c as l, d as m, e as u, P as c, F as g, H as d, I as f, E as p, f as h, g as b } from "../../../index-CasgquAq.js";
3
- import { S as T } from "../../../index-BqFHWqw6.js";
4
- import y from "./extension-selectedText.js";
2
+ import { T as i, a as o, b as a, H as n, M as l, c as m, S as u, d as c, e as g, f as d, P as f, F as h, I as p, E as b, g as T } from "../../../index-CCS9HOYd.js";
3
+ import { S as y } from "../../../index-B0pieAxt.js";
4
+ import C from "./extension-selectedText.js";
5
5
  import E from "./slashCommand/renderItems.js";
6
- import { getSuggestionItems as C } from "./slashCommand/items.js";
7
- import { LatexExtension as H } from "./math-extension.js";
6
+ import { getSuggestionItems as H } from "./slashCommand/items.js";
8
7
  import S from "./emoji/suggest.js";
9
- const M = (e) => [
10
- o.configure({
8
+ const A = (e) => [
9
+ u.configure({
11
10
  dropcursor: {
12
11
  width: 4,
13
12
  color: "#ebf6fe"
14
13
  }
15
14
  }),
16
- i.configure({
15
+ c.configure({
17
16
  HTMLAttributes: {
18
17
  class: "scribe-task-list"
19
18
  }
20
19
  }),
21
- a.configure({
20
+ g.configure({
22
21
  nested: !0
23
22
  }),
24
- n.configure({
23
+ d.configure({
25
24
  resizable: !0
26
25
  }),
27
- l,
28
- m,
29
- u,
30
- c.configure({
26
+ i,
27
+ o,
28
+ a,
29
+ f.configure({
31
30
  showOnlyWhenEditable: !0,
32
31
  includeChildren: !0,
33
32
  showOnlyCurrent: !1,
@@ -35,31 +34,31 @@ const M = (e) => [
35
34
  emptyNodeClass: "is-node-empty",
36
35
  placeholder: ({ editor: t, node: s }) => t.isDestroyed ? "" : s.type.name === "heading" ? `Heading ${s.attrs.level}` : e.placeholderText || 'Type "/" for commands...'
37
36
  }),
38
- g.configure({ mode: "deepest", className: "has-focus" }),
39
- T.configure({
37
+ h.configure({ mode: "deepest", className: "has-focus" }),
38
+ y.configure({
40
39
  slashSuggestion: {
41
- items: C,
40
+ items: H,
42
41
  render: E(e)
43
42
  }
44
43
  }),
45
- d,
46
- y,
44
+ n,
45
+ C,
47
46
  r,
48
- f.configure({
47
+ p.configure({
49
48
  inline: !0,
50
49
  HTMLAttributes: {
51
50
  class: "scribe-image-node"
52
51
  },
53
52
  allowBase64: !0
54
53
  }),
55
- p.configure({
56
- emojis: b,
54
+ b.configure({
55
+ emojis: T,
57
56
  enableEmoticons: !0,
58
57
  suggestion: S(e)
59
58
  }),
60
- H,
61
- h
59
+ l,
60
+ m
62
61
  ];
63
62
  export {
64
- M as initExtensions
63
+ A as initExtensions
65
64
  };
@@ -1,13 +1,13 @@
1
1
  import "react/jsx-runtime";
2
- import { h as n } from "../../../../index-CasgquAq.js";
2
+ import { h as n } from "../../../../index-CCS9HOYd.js";
3
3
  import "react";
4
- import "../../../../turndown.browser.es-C1wFFc_i.js";
5
- import "../../../../browser-BJWkU9cc.js";
4
+ import "../../../../purify.es-BGaRrCfO.js";
5
+ import "../../../../turndown.browser.es-RmA_HBaI.js";
6
+ import "../../../../marked.esm-BS_MmRZC.js";
6
7
  import "../../../../utils/is-in-viewport.js";
7
8
  import "../extension-link.js";
8
- import "../../../../index-BqFHWqw6.js";
9
+ import "../../../../index-B0pieAxt.js";
9
10
  import "../extension-selectedText.js";
10
- import "../math-extension.js";
11
11
  import "../emoji/EmojiList.js";
12
12
  import "../../../../clsx-OuTLNxxd.js";
13
13
  export {
@@ -1,5 +1,5 @@
1
- import "../../../../index-DeZ8laak.js";
2
- import { S as o, s as e } from "../../../../index-BqFHWqw6.js";
1
+ import "../../../../index-DoNRu1rY.js";
2
+ import { S as o, s as e } from "../../../../index-B0pieAxt.js";
3
3
  export {
4
4
  o as SlashCommand,
5
5
  e as slashMenuPluginKey
@@ -1,5 +1,5 @@
1
- import { R as c, t as d } from "../../../../index-C_aWB8qt.js";
2
- import { l as s, h as u } from "../../../../index-CasgquAq.js";
1
+ import { R as c, t as d } from "../../../../index-VneQGVTd.js";
2
+ import { l as s, h as u } from "../../../../index-CCS9HOYd.js";
3
3
  const y = (a) => () => {
4
4
  let r, t = [], n, i = !s.isEmpty(t);
5
5
  return {
@@ -29,5 +29,6 @@ export interface ScribeProps {
29
29
  mainContainerClassName?: ClassValue;
30
30
  onKeyDown?: KeyboardEventHandler;
31
31
  darkMode?: boolean;
32
+ mobile?: boolean;
32
33
  }
33
34
  export declare const Scribe: import('react').ForwardRefExoticComponent<ScribeProps & import('react').RefAttributes<ScribeRef>>;
@@ -1,20 +1,22 @@
1
- import { jsx as a, jsxs as L } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as O } from "react/jsx-runtime";
2
2
  import R from "../Menu/BarMenu.js";
3
- import { c as p } from "../../clsx-OuTLNxxd.js";
3
+ import { c as f } from "../../clsx-OuTLNxxd.js";
4
4
  import { html2md as g } from "../../utils/html-to-markdown.js";
5
- import "../../browser-BJWkU9cc.js";
6
- import { E as T } from "../../index-DeZ8laak.js";
5
+ import "../../marked.esm-BS_MmRZC.js";
6
+ import "../../purify.es-BGaRrCfO.js";
7
+ import { E as T } from "../../index-DoNRu1rY.js";
7
8
  import { initExtensions as z } from "./extension/index.js";
8
- import { E as J } from "../../index-C_aWB8qt.js";
9
- import { forwardRef as O, useRef as P, useCallback as m, useImperativeHandle as D, useEffect as c } from "react";
10
- import '../../assets/index.css';const W = O((C, x) => {
9
+ import { E as J } from "../../index-VneQGVTd.js";
10
+ import { forwardRef as P, useRef as D, useCallback as a, useImperativeHandle as F, useEffect as c } from "react";
11
+ import { ListOptionBar as I } from "../Menu/Mobile/ListOptionBar.js";
12
+ import '../../assets/index.css';const _ = P((C, x) => {
11
13
  const {
12
14
  autoFocus: d = !1,
13
15
  content: E,
14
16
  editable: e = !0,
15
- editorProps: s,
17
+ editorProps: r,
16
18
  extensions: h,
17
- onContentChange: l,
19
+ onContentChange: i,
18
20
  showBarMenu: w = !0,
19
21
  editorContentStyle: y,
20
22
  editorContentClassName: M,
@@ -22,73 +24,94 @@ import '../../assets/index.css';const W = O((C, x) => {
22
24
  mainContainerClassName: j,
23
25
  onKeyDown: k,
24
26
  externalEditor: v,
25
- darkMode: i
26
- } = C, u = P(v || null), f = m(
27
- ({ editor: t }) => {
28
- const o = t.getHTML(), r = t.getJSON(), B = !e;
29
- l && l({
30
- jsonContent: t.isEmpty ? "" : r,
31
- htmlContent: t.isEmpty ? "" : o,
32
- markdownContent: t.isEmpty ? "" : g(o),
33
- source: B ? "programmatic" : "user"
27
+ darkMode: l,
28
+ mobile: S
29
+ } = C, p = D(v || null), u = a(
30
+ ({ editor: n }) => {
31
+ const o = n.getHTML(), m = n.getJSON(), L = !e;
32
+ i && i({
33
+ jsonContent: n.isEmpty ? "" : m,
34
+ htmlContent: n.isEmpty ? "" : o,
35
+ markdownContent: n.isEmpty ? "" : g(o),
36
+ source: L ? "programmatic" : "user"
34
37
  });
35
38
  },
36
- [e, l]
39
+ [e, i]
37
40
  );
38
- u.current || (u.current = new T({
39
- ...s,
41
+ p.current || (p.current = new T({
42
+ ...r,
40
43
  editable: e,
41
44
  extensions: [...z(C), ...h ?? []],
42
45
  editorProps: {
43
46
  attributes: {
44
47
  class: "scribe"
45
48
  },
46
- ...s == null ? void 0 : s.editorProps
49
+ ...r == null ? void 0 : r.editorProps
47
50
  }
48
51
  }));
49
- const n = u.current, b = m(() => {
50
- n == null || n.commands.setContent("");
51
- }, []), S = m((t) => {
52
- var r;
53
- const o = {
54
- html: () => n == null ? void 0 : n.getHTML(),
55
- json: () => n == null ? void 0 : n.getJSON(),
56
- markdown: () => g((n == null ? void 0 : n.getHTML()) || "")
57
- };
58
- return n != null && n.isEmpty ? "" : (r = o[t]) == null ? void 0 : r.call(o);
59
- }, []), H = m((t) => {
60
- n == null || n.commands.setContent(t);
52
+ const t = p.current, b = a(() => {
53
+ t == null || t.commands.setContent("");
54
+ }, []), B = a(
55
+ (n) => {
56
+ var m;
57
+ const o = {
58
+ html: () => t == null ? void 0 : t.getHTML(),
59
+ json: () => t == null ? void 0 : t.getJSON(),
60
+ markdown: () => g((t == null ? void 0 : t.getHTML()) || "")
61
+ };
62
+ return t != null && t.isEmpty ? "" : (m = o[n]) == null ? void 0 : m.call(o);
63
+ },
64
+ []
65
+ ), H = a((n) => {
66
+ t == null || t.commands.setContent(n);
61
67
  }, []);
62
- return D(x, () => ({
68
+ return F(x, () => ({
63
69
  resetContent: b,
64
70
  setContent: H,
65
- getContent: S,
66
- editor: n
71
+ getContent: B,
72
+ editor: t
67
73
  }), [b]), c(() => {
68
- n == null || n.commands.setContent(E || "");
74
+ t == null || t.commands.setContent(E || "");
69
75
  }, [E]), c(() => {
70
- n == null || n.setEditable(!!e);
71
- }, [e]), c(() => (n.off("update"), n.on("update", f), () => {
72
- n.off("update", f);
73
- }), [f]), c(() => {
74
- d && (n == null || n.commands.focus("end"));
75
- }, [d]), /* @__PURE__ */ a("div", { className: p("scribe-wrapper", j), style: N, children: /* @__PURE__ */ L("div", { className: p(e && "rounded-lg border", i ? "border-zinc-700" : "border-zinc-200"), children: [
76
- n && w && /* @__PURE__ */ a(R, { editor: n, darkMode: !!i }),
77
- /* @__PURE__ */ a(
78
- "div",
79
- {
80
- className: p(
81
- "prose max-w-none",
82
- e && "w-full p-[16px]",
83
- i && "prose-invert",
84
- M
85
- ),
86
- style: y,
87
- children: /* @__PURE__ */ a(J, { editor: n, onKeyDown: k })
88
- }
89
- )
90
- ] }) });
76
+ t == null || t.setEditable(!!e);
77
+ }, [e]), c(() => (t.off("update"), t.on("update", u), () => {
78
+ t.off("update", u);
79
+ }), [u]), c(() => {
80
+ d && (t == null || t.commands.focus("end"));
81
+ }, [d]), /* @__PURE__ */ s(
82
+ "div",
83
+ {
84
+ className: f("scribe-wrapper", j),
85
+ style: N,
86
+ children: /* @__PURE__ */ O(
87
+ "div",
88
+ {
89
+ className: f(
90
+ e && "rounded-lg border",
91
+ l ? "border-zinc-700" : "border-zinc-200"
92
+ ),
93
+ children: [
94
+ t && w && /* @__PURE__ */ s(R, { editor: t, darkMode: !!l }),
95
+ /* @__PURE__ */ s(
96
+ "div",
97
+ {
98
+ className: f(
99
+ "prose max-w-none",
100
+ e && "w-full p-[16px]",
101
+ l && "prose-invert",
102
+ M
103
+ ),
104
+ style: y,
105
+ children: /* @__PURE__ */ s(J, { editor: t, onKeyDown: k })
106
+ }
107
+ ),
108
+ S && /* @__PURE__ */ s(I, { editor: t })
109
+ ]
110
+ }
111
+ )
112
+ }
113
+ );
91
114
  });
92
115
  export {
93
- W as Scribe
116
+ _ as Scribe
94
117
  };
@@ -0,0 +1,160 @@
1
+ import { P as L, b as U, D as z, c as G, e as H, a as J } from "./index-DoNRu1rY.js";
2
+ function Q(g) {
3
+ var i;
4
+ const { char: v, allowSpaces: m, allowToIncludeChar: P, allowedPrefixes: p, startOfLine: K, $position: f } = g, C = m && !P, h = H(v), B = new RegExp(`\\s${h}$`), M = K ? "^" : "", R = P ? "" : h, $ = C ? new RegExp(`${M}${h}.*?(?=\\s${R}|$)`, "gm") : new RegExp(`${M}(?:^)?${h}[^\\s${R}]*`, "gm"), x = ((i = f.nodeBefore) === null || i === void 0 ? void 0 : i.isText) && f.nodeBefore.text;
5
+ if (!x)
6
+ return null;
7
+ const k = f.pos - x.length, n = Array.from(x.matchAll($)).pop();
8
+ if (!n || n.input === void 0 || n.index === void 0)
9
+ return null;
10
+ const e = n.input.slice(Math.max(0, n.index - 1), n.index), w = new RegExp(`^[${p == null ? void 0 : p.join("")}\0]?$`).test(e);
11
+ if (p !== null && !w)
12
+ return null;
13
+ const o = k + n.index;
14
+ let a = o + n[0].length;
15
+ return C && B.test(x.slice(a - 1, a + 1)) && (n[0] += " ", a += 1), o < f.pos && a >= f.pos ? {
16
+ range: {
17
+ from: o,
18
+ to: a
19
+ },
20
+ query: n[0].slice(v.length),
21
+ text: n[0]
22
+ } : null;
23
+ }
24
+ const V = new L("suggestion");
25
+ function W({ pluginKey: g = V, editor: i, char: v = "@", allowSpaces: m = !1, allowToIncludeChar: P = !1, allowedPrefixes: p = [" "], startOfLine: K = !1, decorationTag: f = "span", decorationClass: C = "suggestion", decorationContent: h = "", decorationEmptyClass: B = "is-empty", command: M = () => null, items: R = () => [], render: $ = () => ({}), allow: x = () => !0, findSuggestionMatch: k = Q }) {
26
+ let n;
27
+ const e = $ == null ? void 0 : $(), w = new U({
28
+ key: g,
29
+ view() {
30
+ return {
31
+ update: async (o, a) => {
32
+ var l, c, r, u, d, q, y;
33
+ const t = (l = this.key) === null || l === void 0 ? void 0 : l.getState(a), s = (c = this.key) === null || c === void 0 ? void 0 : c.getState(o.state), _ = t.active && s.active && t.range.from !== s.range.from, b = !t.active && s.active, j = t.active && !s.active, A = !b && !j && t.query !== s.query, E = b || _ && A, D = A || _, N = j || _ && A;
34
+ if (!E && !D && !N)
35
+ return;
36
+ const S = N && !E ? t : s, F = o.dom.querySelector(`[data-decoration-id="${S.decorationId}"]`);
37
+ n = {
38
+ editor: i,
39
+ range: S.range,
40
+ query: S.query,
41
+ text: S.text,
42
+ items: [],
43
+ command: (I) => M({
44
+ editor: i,
45
+ range: S.range,
46
+ props: I
47
+ }),
48
+ decorationNode: F,
49
+ // virtual node for popper.js or tippy.js
50
+ // this can be used for building popups without a DOM node
51
+ clientRect: F ? () => {
52
+ var I;
53
+ const { decorationId: T } = (I = this.key) === null || I === void 0 ? void 0 : I.getState(i.state), O = o.dom.querySelector(`[data-decoration-id="${T}"]`);
54
+ return (O == null ? void 0 : O.getBoundingClientRect()) || null;
55
+ } : null
56
+ }, E && ((r = e == null ? void 0 : e.onBeforeStart) === null || r === void 0 || r.call(e, n)), D && ((u = e == null ? void 0 : e.onBeforeUpdate) === null || u === void 0 || u.call(e, n)), (D || E) && (n.items = await R({
57
+ editor: i,
58
+ query: S.query
59
+ })), N && ((d = e == null ? void 0 : e.onExit) === null || d === void 0 || d.call(e, n)), D && ((q = e == null ? void 0 : e.onUpdate) === null || q === void 0 || q.call(e, n)), E && ((y = e == null ? void 0 : e.onStart) === null || y === void 0 || y.call(e, n));
60
+ },
61
+ destroy: () => {
62
+ var o;
63
+ n && ((o = e == null ? void 0 : e.onExit) === null || o === void 0 || o.call(e, n));
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(o, a, l, c) {
83
+ const { isEditable: r } = i, { composing: u } = i.view, { selection: d } = o, { empty: q, from: y } = d, t = { ...a };
84
+ if (t.composing = u, r && (q || i.view.composing)) {
85
+ (y < a.range.from || y > a.range.to) && !u && !a.composing && (t.active = !1);
86
+ const s = k({
87
+ char: v,
88
+ allowSpaces: m,
89
+ allowToIncludeChar: P,
90
+ allowedPrefixes: p,
91
+ startOfLine: K,
92
+ $position: d.$from
93
+ }), _ = `id_${Math.floor(Math.random() * 4294967295)}`;
94
+ s && x({
95
+ editor: i,
96
+ state: c,
97
+ range: s.range,
98
+ isActive: a.active
99
+ }) ? (t.active = !0, t.decorationId = a.decorationId ? a.decorationId : _, t.range = s.range, t.query = s.query, t.text = s.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(o, a) {
108
+ var l;
109
+ const { active: c, range: r } = w.getState(o.state);
110
+ return c && ((l = e == null ? void 0 : e.onKeyDown) === null || l === void 0 ? void 0 : l.call(e, { view: o, event: a, range: r })) || !1;
111
+ },
112
+ // Setup decorator on the currently active suggestion.
113
+ decorations(o) {
114
+ const { active: a, range: l, decorationId: c, query: r } = w.getState(o);
115
+ if (!a)
116
+ return null;
117
+ const u = !(r != null && r.length), d = [C];
118
+ return u && d.push(B), z.create(o.doc, [
119
+ G.inline(l.from, l.to, {
120
+ nodeName: f,
121
+ class: d.join(" "),
122
+ "data-decoration-id": c,
123
+ "data-decoration-content": h
124
+ })
125
+ ]);
126
+ }
127
+ }
128
+ });
129
+ return w;
130
+ }
131
+ const X = new L("slashSuggestion"), Z = J.create({
132
+ name: "slashCommand",
133
+ addOptions() {
134
+ var g;
135
+ return {
136
+ ...(g = this.parent) == null ? void 0 : g.call(this),
137
+ slashSuggestion: {
138
+ char: "/",
139
+ startOfLine: !0,
140
+ command: ({ editor: i, range: v, props: m }) => {
141
+ m.command({ editor: i, range: v, props: m });
142
+ }
143
+ }
144
+ };
145
+ },
146
+ addProseMirrorPlugins() {
147
+ return [
148
+ W({
149
+ pluginKey: X,
150
+ ...this.options.slashSuggestion,
151
+ editor: this.editor
152
+ })
153
+ ];
154
+ }
155
+ });
156
+ export {
157
+ Z as S,
158
+ W as a,
159
+ X as s
160
+ };