@clevertask/scribe 0.0.7 → 0.0.8

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.
@@ -1,4 +1,4 @@
1
- import { N as fa, P as pa, a as va, m as ga } from "../../../index-o3ZWOEgq.js";
1
+ import { N as fa, P as pa, b as va, m as ga } from "../../../index-Gm-3o3nq.js";
2
2
  class u0 {
3
3
  // The + prefix indicates that these fields aren't writeable
4
4
  // Lexer holding the input string.
@@ -1,9 +1,13 @@
1
1
  import "react/jsx-runtime";
2
- import { S as s } from "../../../../SlashCommandList-DLPd43Tg.js";
2
+ import { g } from "../../../../index-NRgJVTH-.js";
3
3
  import "react";
4
4
  import "../../../../turndown.browser.es-BSoGafvq.js";
5
- import "../../../../browser-Ce149ePN.js";
5
+ import "../../../../browser-DEobZXxB.js";
6
6
  import "../../../../utils/is-in-viewport.js";
7
+ import "../extension-link.js";
8
+ import "./index.js";
9
+ import "../extension-selectedText.js";
10
+ import "../math-extension.js";
7
11
  export {
8
- s as SlashCommandList
12
+ g as SlashCommandList
9
13
  };
@@ -1,4 +1,4 @@
1
- import { a as F, P as T, D as U, b as j, e as z, E as G } from "../../../../index-o3ZWOEgq.js";
1
+ import { b as F, P as T, D as U, c as j, e as z, a as G } from "../../../../index-Gm-3o3nq.js";
2
2
  function H(f) {
3
3
  var s;
4
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;
@@ -1,5 +1,5 @@
1
- import { R as l, t as c } from "../../../../index-dyNx8_Ul.js";
2
- import { l as a, S as d } from "../../../../SlashCommandList-DLPd43Tg.js";
1
+ import { R as l, t as c } from "../../../../index-C3_lI_rP.js";
2
+ import { l as a, g as d } from "../../../../index-NRgJVTH-.js";
3
3
  const m = () => {
4
4
  let n, t = [], r, i = !a.isEmpty(t);
5
5
  return {
@@ -1,6 +1,6 @@
1
- import { Content, Extension, JSONContent, UseEditorOptions } from '@tiptap/react';
2
- import { KeyboardEventHandler } from 'react';
3
1
  import { ClassValue } from 'clsx';
2
+ import { Content, Editor, Extension, JSONContent, UseEditorOptions } from '@tiptap/react';
3
+ import { KeyboardEventHandler } from 'react';
4
4
  export type ScribeOnChangeContents = {
5
5
  jsonContent: Content;
6
6
  htmlContent: Content;
@@ -10,6 +10,7 @@ export interface ScribeRef {
10
10
  resetContent: () => void;
11
11
  getContent: (contentType: "html" | "json" | "markdown") => string | JSONContent | undefined;
12
12
  setContent: (content: Content) => void;
13
+ editor: Editor;
13
14
  }
14
15
  export interface ScribeProps {
15
16
  onContentChange?: (content: ScribeOnChangeContents) => void;
@@ -17,6 +18,7 @@ export interface ScribeProps {
17
18
  editable?: boolean;
18
19
  autoFocus?: boolean;
19
20
  extensions?: Extension[];
21
+ externalEditor?: Editor;
20
22
  editorProps?: UseEditorOptions;
21
23
  showBarMenu?: boolean;
22
24
  placeholderText?: string;
@@ -1,93 +1,95 @@
1
- import { jsx as i, jsxs as S } from "react/jsx-runtime";
2
- import { u as H, E as k } from "../../index-dyNx8_Ul.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
- import A from "../Menu/BarMenu.js";
1
+ import { jsx as l, jsxs as k } from "react/jsx-runtime";
2
+ import B from "../Menu/BarMenu.js";
6
3
  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 = "";
4
+ import "../../browser-DEobZXxB.js";
5
+ import { E as L } from "../../index-Gm-3o3nq.js";
6
+ import { initExtensions as R } from "./extension/index.js";
7
+ import { E as T } from "../../index-C3_lI_rP.js";
8
+ import { forwardRef as A, useRef as J, useCallback as u, useImperativeHandle as O, useEffect as p } from "react";
9
+ import '../../assets/index.css';function h(t) {
10
+ var r, s, e = "";
10
11
  if (typeof t == "string" || typeof t == "number") e += t;
11
12
  else if (typeof t == "object") if (Array.isArray(t)) {
12
- var r = t.length;
13
- for (o = 0; o < r; o++) t[o] && (s = d(t[o])) && (e && (e += " "), e += s);
13
+ var o = t.length;
14
+ for (r = 0; r < o; r++) t[r] && (s = h(t[r])) && (e && (e += " "), e += s);
14
15
  } else for (s in t) t[s] && (e && (e += " "), e += s);
15
16
  return e;
16
17
  }
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);
18
+ function C() {
19
+ for (var t, r, s = 0, e = "", o = arguments.length; s < o; s++) (t = arguments[s]) && (r = h(t)) && (e && (e += " "), e += r);
19
20
  return e;
20
21
  }
21
- const R = L((t, o) => {
22
+ const G = A((t, r) => {
22
23
  const {
23
24
  autoFocus: s = !1,
24
25
  content: e,
25
- editable: r = !0,
26
+ editable: o = !0,
26
27
  editorProps: c,
27
- extensions: h,
28
- onContentChange: C,
28
+ extensions: w,
29
+ onContentChange: g,
29
30
  showBarMenu: y = !0,
30
- editorContentStyle: w,
31
- editorContentClassName: x,
31
+ editorContentStyle: x,
32
+ editorContentClassName: E,
32
33
  mainContainerStyle: v,
33
- mainContainerClassName: E,
34
- onKeyDown: N
35
- } = t, n = H(
36
- {
37
- ...c,
38
- editable: r,
39
- extensions: [...B(t), ...h ?? []],
40
- onUpdate({ editor: a }) {
41
- const m = a.getHTML(), l = a.getJSON();
42
- C && C({
43
- jsonContent: l,
44
- htmlContent: m,
45
- markdownContent: b(m)
46
- });
47
- },
48
- editorProps: {
49
- attributes: {
50
- class: "scribe"
51
- },
52
- ...c == null ? void 0 : c.editorProps
53
- }
34
+ mainContainerClassName: N,
35
+ onKeyDown: j,
36
+ externalEditor: M
37
+ } = t, f = J(M || null);
38
+ f.current || (f.current = new L({
39
+ ...c,
40
+ editable: o,
41
+ extensions: [...R(t), ...w ?? []],
42
+ onUpdate({ editor: a }) {
43
+ const m = a.getHTML(), i = a.getJSON();
44
+ g && g({
45
+ jsonContent: i,
46
+ htmlContent: m,
47
+ markdownContent: b(m)
48
+ });
54
49
  },
55
- []
56
- ), g = f(() => {
50
+ editorProps: {
51
+ attributes: {
52
+ class: "scribe"
53
+ },
54
+ ...c == null ? void 0 : c.editorProps
55
+ }
56
+ }));
57
+ const n = f.current, d = u(() => {
57
58
  n == null || n.commands.setContent("");
58
- }, []), j = f((a) => {
59
- var l;
59
+ }, []), S = u((a) => {
60
+ var i;
60
61
  const m = {
61
62
  html: () => n == null ? void 0 : n.getHTML(),
62
63
  json: () => n == null ? void 0 : n.getJSON(),
63
64
  markdown: () => b((n == null ? void 0 : n.getHTML()) || "")
64
65
  };
65
- return n != null && n.isEmpty ? "" : (l = m[a]) == null ? void 0 : l.call(m);
66
- }, []), M = f((a) => {
66
+ return n != null && n.isEmpty ? "" : (i = m[a]) == null ? void 0 : i.call(m);
67
+ }, []), H = u((a) => {
67
68
  n == null || n.commands.setContent(a);
68
69
  }, []);
69
- return T(o, () => ({
70
- resetContent: g,
71
- setContent: M,
72
- getContent: j
73
- }), [g]), u(() => {
70
+ return O(r, () => ({
71
+ resetContent: d,
72
+ setContent: H,
73
+ getContent: S,
74
+ editor: n
75
+ }), [d]), p(() => {
74
76
  n == null || n.commands.setContent(e || "");
75
- }, [e]), u(() => {
76
- n == null || n.setEditable(!!r);
77
- }, [r]), u(() => {
77
+ }, [e]), p(() => {
78
+ n == null || n.setEditable(!!o);
79
+ }, [o]), p(() => {
78
80
  s && (n == null || n.commands.focus("end"));
79
- }, [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: [
80
- n && y && /* @__PURE__ */ i(A, { editor: n }),
81
- /* @__PURE__ */ i(
81
+ }, [s]), /* @__PURE__ */ l("div", { className: C("scribe-wrapper", N), style: v, id: "scribe-wrapper", children: /* @__PURE__ */ k("div", { className: C("bg-white", o && "rounded-lg border"), children: [
82
+ n && y && /* @__PURE__ */ l(B, { editor: n }),
83
+ /* @__PURE__ */ l(
82
84
  "div",
83
85
  {
84
- className: p("prose max-w-none", r && "w-full p-[16px]", x),
85
- style: w,
86
- children: /* @__PURE__ */ i(k, { editor: n, onKeyDown: N })
86
+ className: C("prose max-w-none", o && "w-full p-[16px]", E),
87
+ style: x,
88
+ children: /* @__PURE__ */ l(T, { editor: n, onKeyDown: j })
87
89
  }
88
90
  )
89
91
  ] }) });
90
92
  });
91
93
  export {
92
- R as Scribe
94
+ G as Scribe
93
95
  };