@clevertask/scribe 0.1.8 → 0.1.9

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 +1 @@
1
- {"version":3,"file":"LinkBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/LinkBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EAAE,EAAE,EAAqD,MAAM,OAAO,CAAC;AAK9E,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAyG3C,CAAC;eAEa,cAAc"}
1
+ {"version":3,"file":"LinkBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/LinkBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EAAE,EAAE,EAAqD,MAAM,OAAO,CAAC;AAS9E,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA+J3C,CAAC;eAEa,cAAc"}
@@ -1,15 +1,15 @@
1
1
  import { a as e } from "../../dist-BgEySLwo.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
3
  import n from "./LinkEditor.js";
4
- import { hideLinkBubbleMenu as r, linkBubbleMenuPluginKey as i } from "./linkBubbleMenuPlugin.js";
5
- import { t as a } from "../../menus-D9OsP28c.js";
6
- import { Box as o } from "@radix-ui/themes";
7
- import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
8
- import { jsx as f } from "react/jsx-runtime";
4
+ import { hideLinkBubbleMenu as r, linkBubbleMenuPluginKey as i, showLinkBubbleMenu as a } from "./linkBubbleMenuPlugin.js";
5
+ import { t as o } from "../../menus-D9OsP28c.js";
6
+ import { Box as s } from "@radix-ui/themes";
7
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
8
+ import { jsx as p } from "react/jsx-runtime";
9
9
  //#region lib/components/Menu/LinkBubbleMenu.tsx
10
- var p = ({ editor: p }) => {
11
- let [m, h] = d(""), g = u(null), _ = u(null), v = e({
12
- editor: p,
10
+ var m = ({ editor: m }) => {
11
+ let [h, g] = f(""), _ = d(null), v = d(null), y = e({
12
+ editor: m,
13
13
  selector: ({ editor: e }) => {
14
14
  let { from: t, to: n } = e.state.selection;
15
15
  return {
@@ -19,43 +19,57 @@ var p = ({ editor: p }) => {
19
19
  };
20
20
  }
21
21
  });
22
- c(() => {
23
- h(v.href);
22
+ l(() => {
23
+ g(y.href);
24
24
  }, [
25
- v.from,
26
- v.href,
27
- v.to
28
- ]), c(() => () => {
29
- _.current !== null && window.cancelAnimationFrame(_.current);
30
- }, []);
31
- let y = s(() => {
32
- if (p.isDestroyed) return;
33
- let e = p.state.selection.to;
34
- r(p), p.chain().setTextSelection(e).focus().run();
35
- }, [p]), b = s(() => {
36
- _.current !== null && window.cancelAnimationFrame(_.current), _.current = window.requestAnimationFrame(() => {
37
- g.current?.focus(), g.current?.select(), _.current = null;
25
+ y.from,
26
+ y.href,
27
+ y.to
28
+ ]), l(() => () => {
29
+ v.current !== null && window.cancelAnimationFrame(v.current);
30
+ }, []), l(() => {
31
+ if (m.isDestroyed) return;
32
+ let e = m.view.dom, t = null, n = !1, r = (r) => {
33
+ if (r.button !== 0 || !m.isEditable) return;
34
+ let i = r.target?.closest?.("a");
35
+ !i || !e.contains(i) || (t !== null && window.clearTimeout(t), t = window.setTimeout(() => {
36
+ if (t = null, n || m.isDestroyed || !m.isEditable || !r.defaultPrevented) return;
37
+ let { from: e, to: i } = m.state.selection;
38
+ e === i || !m.isActive("link") || a(m);
39
+ }));
40
+ };
41
+ return e.addEventListener("mouseup", r), () => {
42
+ n = !0, t !== null && window.clearTimeout(t), e.removeEventListener("mouseup", r);
43
+ };
44
+ }, [m]);
45
+ let b = c(() => {
46
+ if (m.isDestroyed) return;
47
+ let e = m.state.selection.to;
48
+ r(m), m.chain().setTextSelection(e).focus().run();
49
+ }, [m]), x = c(() => {
50
+ v.current !== null && window.cancelAnimationFrame(v.current), v.current = window.requestAnimationFrame(() => {
51
+ _.current?.focus(), _.current?.select(), v.current = null;
38
52
  });
39
- }, []), x = s(({ editor: e, element: t, from: n, to: r, view: i }) => {
40
- let a = t.contains(t.ownerDocument.activeElement);
41
- return e.isEditable && n !== r && e.isActive("link") && (i.hasFocus() || a);
42
- }, []), S = s(() => t(p), [p]), C = l(() => ({
53
+ }, []), S = c(({ editor: e, element: t, from: n, to: r }) => {
54
+ let i = t.contains(t.ownerDocument.activeElement);
55
+ return e.isEditable && n !== r && e.isActive("link") && i;
56
+ }, []), C = c(() => t(m), [m]), w = u(() => ({
43
57
  strategy: "fixed",
44
58
  placement: "bottom",
45
59
  offset: 8,
46
60
  flip: {},
47
61
  shift: { padding: 8 },
48
62
  inline: !0,
49
- onShow: b
50
- }), [b]);
51
- return /* @__PURE__ */ f(a, {
52
- editor: p,
63
+ onShow: x
64
+ }), [x]);
65
+ return /* @__PURE__ */ p(o, {
66
+ editor: m,
53
67
  pluginKey: i,
54
68
  updateDelay: 0,
55
- appendTo: S,
56
- shouldShow: x,
57
- options: C,
58
- children: /* @__PURE__ */ f(o, {
69
+ appendTo: C,
70
+ shouldShow: S,
71
+ options: w,
72
+ children: /* @__PURE__ */ p(s, {
59
73
  className: "scribe-link-popover",
60
74
  role: "dialog",
61
75
  "aria-label": "Edit link",
@@ -63,16 +77,16 @@ var p = ({ editor: p }) => {
63
77
  maxWidth: "calc(100vw - 32px)",
64
78
  width: 320
65
79
  },
66
- children: /* @__PURE__ */ f(n, {
67
- editor: p,
68
- existingHref: v.href,
69
- inputRef: g,
70
- onClose: y,
71
- onValueChange: h,
72
- value: m
80
+ children: /* @__PURE__ */ p(n, {
81
+ editor: m,
82
+ existingHref: y.href,
83
+ inputRef: _,
84
+ onClose: b,
85
+ onValueChange: g,
86
+ value: h
73
87
  })
74
88
  })
75
89
  });
76
90
  };
77
91
  //#endregion
78
- export { p as default };
92
+ export { m as default };
@@ -1,5 +1,6 @@
1
1
  import { PluginKey } from "@tiptap/pm/state";
2
2
  import { Editor } from "@tiptap/react";
3
3
  export declare const linkBubbleMenuPluginKey: PluginKey<any>;
4
+ export declare const showLinkBubbleMenu: (editor: Editor) => void;
4
5
  export declare const hideLinkBubbleMenu: (editor: Editor) => void;
5
6
  //# sourceMappingURL=linkBubbleMenuPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkBubbleMenuPlugin.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/linkBubbleMenuPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,eAAO,MAAM,uBAAuB,gBAAwC,CAAC;AAE7E,eAAO,MAAM,kBAAkB,WAAY,MAAM,SAMhD,CAAC"}
1
+ {"version":3,"file":"linkBubbleMenuPlugin.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/linkBubbleMenuPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,eAAO,MAAM,uBAAuB,gBAAwC,CAAC;AAE7E,eAAO,MAAM,kBAAkB,WAAY,MAAM,SAahD,CAAC;AAEF,eAAO,MAAM,kBAAkB,WAAY,MAAM,SAMhD,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import { a as e } from "../../dist-FrapLVQu.js";
2
2
  //#region lib/components/Menu/linkBubbleMenuPlugin.ts
3
3
  var t = new e("scribeLinkBubbleMenu"), n = (e) => {
4
+ e.isDestroyed || (e.view.dispatch(e.state.tr.setMeta(t, "show")), !e.isDestroyed && e.view.dispatch(e.state.tr.setMeta(t, "updatePosition")));
5
+ }, r = (e) => {
4
6
  e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(t, "hide"));
5
7
  };
6
8
  //#endregion
7
- export { n as hideLinkBubbleMenu, t as linkBubbleMenuPluginKey };
9
+ export { r as hideLinkBubbleMenu, t as linkBubbleMenuPluginKey, n as showLinkBubbleMenu };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clevertask/scribe",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "private": false,
5
5
  "description": "A Radix-based Tiptap rich text editor with a Notion-style block interface for viewing and creating content. Perfect for diverse needs like notes, documents, AI chat, Markdown parsing, and comments.",
6
6
  "keywords": [