@clevertask/scribe 0.1.11 → 0.1.13

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 (58) hide show
  1. package/README.md +1 -1
  2. package/dist/{BarMenu-5M9g9Y1j.js → BarMenu-O2IVhHXx.js} +1 -1
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.js +1 -1
  5. package/dist/components/Menu/BubbleMenu.js +2 -2
  6. package/dist/components/Menu/CalloutBubbleMenu.d.ts +7 -0
  7. package/dist/components/Menu/CalloutBubbleMenu.d.ts.map +1 -0
  8. package/dist/components/Menu/CalloutBubbleMenu.js +156 -0
  9. package/dist/components/Menu/LinkBubbleMenu.js +2 -2
  10. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  11. package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
  12. package/dist/components/Menu/TableBubbleMenu.js +99 -98
  13. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts +10 -0
  14. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts.map +1 -0
  15. package/dist/components/Menu/calloutBubbleMenuPlugin.js +22 -0
  16. package/dist/components/Menu/contextualMenuOwner.d.ts +4 -0
  17. package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -0
  18. package/dist/components/Menu/contextualMenuOwner.js +9 -0
  19. package/dist/components/Scribe/extension/callout.d.ts +32 -0
  20. package/dist/components/Scribe/extension/callout.d.ts.map +1 -0
  21. package/dist/components/Scribe/extension/callout.js +118 -0
  22. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  23. package/dist/components/Scribe/extension/extension-link.js +1 -1
  24. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  25. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  26. package/dist/components/Scribe/extension/index.d.ts +1 -1
  27. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  28. package/dist/components/Scribe/extension/index.js +1 -1
  29. package/dist/components/Scribe/extension/resizable-table.js +1 -1
  30. package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
  31. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  32. package/dist/components/Scribe/extension/slashCommand/items.js +48 -28
  33. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  34. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  35. package/dist/components/Scribe/index.d.ts.map +1 -1
  36. package/dist/components/Scribe/index.js +128 -126
  37. package/dist/{dist-Dw4STOPE.js → dist-BoYfa2nz.js} +1 -1
  38. package/dist/{dist-DFua_Xbu.js → dist-W9E-K577.js} +980 -618
  39. package/dist/{extension-Dy6hHSvD.js → extension-D5WIAWhc.js} +1984 -1946
  40. package/dist/{extension-link-CjfUZ90W.js → extension-link-D8Zi7OSa.js} +36 -36
  41. package/dist/{html-to-markdown-B6Uhn7ok.js → html-to-markdown-C920nQtn.js} +101 -60
  42. package/dist/icons/CalloutIcon.d.ts +9 -0
  43. package/dist/icons/CalloutIcon.d.ts.map +1 -0
  44. package/dist/icons/CalloutIcon.js +72 -0
  45. package/dist/main.css +119 -1
  46. package/dist/main.d.ts +1 -0
  47. package/dist/main.d.ts.map +1 -1
  48. package/dist/main.js +9 -8
  49. package/dist/{markdown-to-html-WmeDaJXP.js → markdown-to-html-CW0Nb9Ye.js} +32 -2
  50. package/dist/{menus-_EXlLMjz.js → menus-B1Zz0GjH.js} +17 -17
  51. package/dist/{resizable-table-Ddw3l6DJ.js → resizable-table-Bf-fb9iv.js} +36 -18
  52. package/dist/{slashCommand-CxX07Nbk.js → slashCommand-47omO4ob.js} +2 -2
  53. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  54. package/dist/utils/html-to-markdown.js +1 -1
  55. package/dist/utils/index.js +4 -4
  56. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  57. package/dist/utils/markdown-to-html.js +1 -1
  58. package/package.json +48 -25
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../BarMenu-5M9g9Y1j.js";
1
+ import { t as e } from "../../BarMenu-O2IVhHXx.js";
2
2
  export { e as default };
@@ -1,6 +1,6 @@
1
- import { a as e } from "../../dist-Dw4STOPE.js";
1
+ import { a as e } from "../../dist-BoYfa2nz.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import { t as n } from "../../menus-_EXlLMjz.js";
3
+ import { t as n } from "../../menus-B1Zz0GjH.js";
4
4
  import { Flex as r, IconButton as i } from "@radix-ui/themes";
5
5
  import { useCallback as a } from "react";
6
6
  import { jsx as o } from "react/jsx-runtime";
@@ -0,0 +1,7 @@
1
+ import { Editor } from "@tiptap/react";
2
+ export interface CalloutBubbleMenuProps {
3
+ editor: Editor;
4
+ }
5
+ declare const CalloutBubbleMenu: ({ editor }: CalloutBubbleMenuProps) => import("react").JSX.Element | null;
6
+ export default CalloutBubbleMenu;
7
+ //# sourceMappingURL=CalloutBubbleMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalloutBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/CalloutBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAiBvD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAoDD,QAAA,MAAM,iBAAiB,eAAgB,sBAAsB,uCAyQ5D,CAAC;eAEa,iBAAiB"}
@@ -0,0 +1,156 @@
1
+ import { a as e } from "../../dist-BoYfa2nz.js";
2
+ import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
+ import { t as n } from "../../menus-B1Zz0GjH.js";
4
+ import { CalloutIcon as r, RemoveCalloutIcon as i } from "../../icons/CalloutIcon.js";
5
+ import { CALLOUT_VARIANTS as a, CALLOUT_VARIANT_LABELS as o, isCalloutVariant as s } from "../Scribe/extension/callout.js";
6
+ import { calloutBubbleMenuPluginKey as c, getSelectionCalloutContext as l } from "./calloutBubbleMenuPlugin.js";
7
+ import { getSelectionContextualMenuOwner as u } from "./contextualMenuOwner.js";
8
+ import { Button as d, Flex as f, Separator as p } from "@radix-ui/themes";
9
+ import { useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
10
+ import { jsx as y, jsxs as b } from "react/jsx-runtime";
11
+ //#region lib/components/Menu/CalloutBubbleMenu.tsx
12
+ var x = {
13
+ info: "blue",
14
+ tip: "green",
15
+ warning: "amber",
16
+ caution: "red"
17
+ }, S = a.map((e) => ({
18
+ color: x[e],
19
+ label: o[e],
20
+ variant: e
21
+ })), C = /auto|overlay|scroll/, w = (e) => s(e) ? e : "info", T = (e) => {
22
+ let t = e.ownerDocument.defaultView;
23
+ if (!t) return [];
24
+ let n = [], r = e.parentElement;
25
+ for (; r && r !== e.ownerDocument.body && r !== e.ownerDocument.documentElement;) {
26
+ let e = t.getComputedStyle(r);
27
+ C.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
28
+ }
29
+ return n;
30
+ }, E = ({ editor: a }) => {
31
+ let o = _(null), [s, x] = v(null), C = g(() => !!a.schema.nodes.callout && typeof a.commands.setCalloutVariant == "function" && typeof a.commands.unsetCallout == "function", [a]), E = e({
32
+ editor: a,
33
+ selector: ({ editor: e }) => {
34
+ let t = l(e.state);
35
+ return t ? w(t.node.attrs.variant) : null;
36
+ }
37
+ }), D = m(({ editor: e, element: t, state: n, view: r }) => {
38
+ let i = r.hasFocus() || t.contains(t.ownerDocument.activeElement);
39
+ return C && e.isEditable && i && u(n) === "callout";
40
+ }, [C]), O = m(() => {
41
+ if (a.isDestroyed) return null;
42
+ let e = l(a.state);
43
+ if (!e) return null;
44
+ let t = a.view.nodeDOM(e.position);
45
+ return t instanceof HTMLElement ? t.closest("[data-type=\"callout\"]") ?? t.querySelector("[data-type=\"callout\"]") ?? t : null;
46
+ }, [a]), k = m(() => t(a), [a]);
47
+ h(() => {
48
+ let e = a.view.dom.ownerDocument.defaultView;
49
+ if (!e) return;
50
+ let t = T(a.view.dom), n = null, r = () => {
51
+ n === null && (n = e.requestAnimationFrame(() => {
52
+ n = null, a.isDestroyed || a.view.dispatch(a.state.tr.setMeta(c, "updatePosition"));
53
+ }));
54
+ };
55
+ return e.addEventListener("scroll", r, { passive: !0 }), t.forEach((e) => {
56
+ e.addEventListener("scroll", r, { passive: !0 });
57
+ }), () => {
58
+ n !== null && e.cancelAnimationFrame(n), e.removeEventListener("scroll", r), t.forEach((e) => {
59
+ e.removeEventListener("scroll", r);
60
+ });
61
+ };
62
+ }, [a]), h(() => {
63
+ let e = a.view.dom.closest("[data-scribe-root]"), t = a.view.dom.ownerDocument.defaultView;
64
+ if (!e || !t) return;
65
+ let n = () => {
66
+ let t = e.getBoundingClientRect().width;
67
+ x(t > 0 ? Math.max(t - 16, 0) : null);
68
+ };
69
+ if (n(), !t.ResizeObserver) return;
70
+ let r = new t.ResizeObserver(n);
71
+ return r.observe(e), () => r.disconnect();
72
+ }, [a]), h(() => {
73
+ let e = a.view.dom, t = (e) => {
74
+ if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !a.isEditable || u(a.state) !== "callout") return;
75
+ let t = o.current?.querySelector("button:not(:disabled)");
76
+ t && (e.preventDefault(), t.focus());
77
+ };
78
+ return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
79
+ }, [a]);
80
+ let A = m((e) => {
81
+ if (e.key === "Escape") {
82
+ e.preventDefault(), a.chain().focus().run();
83
+ return;
84
+ }
85
+ if (![
86
+ "ArrowLeft",
87
+ "ArrowRight",
88
+ "ArrowUp",
89
+ "ArrowDown",
90
+ "Home",
91
+ "End"
92
+ ].includes(e.key)) return;
93
+ let t = Array.from(e.currentTarget.querySelectorAll("button:not(:disabled)"));
94
+ if (t.length === 0) return;
95
+ let n = e.currentTarget.ownerDocument.activeElement, r = t.findIndex((e) => e === n), i = r;
96
+ i = e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : e.key === "ArrowLeft" || e.key === "ArrowUp" ? r <= 0 ? t.length - 1 : r - 1 : r < 0 || r === t.length - 1 ? 0 : r + 1, e.preventDefault(), t[i]?.focus();
97
+ }, [a]), j = g(() => ({
98
+ strategy: "fixed",
99
+ placement: "top-start",
100
+ offset: 8,
101
+ flip: {},
102
+ shift: { padding: 8 }
103
+ }), []);
104
+ return C ? /* @__PURE__ */ y(n, {
105
+ editor: a,
106
+ pluginKey: c,
107
+ updateDelay: 0,
108
+ resizeDelay: 0,
109
+ appendTo: k,
110
+ shouldShow: D,
111
+ getReferencedVirtualElement: O,
112
+ options: j,
113
+ children: /* @__PURE__ */ b(f, {
114
+ ref: o,
115
+ className: "scribe-callout-bubble-menu",
116
+ role: "toolbar",
117
+ "aria-label": "Callout type",
118
+ "aria-keyshortcuts": "Alt+F10",
119
+ align: "center",
120
+ gap: "1",
121
+ wrap: "wrap",
122
+ onKeyDown: A,
123
+ style: s === null ? void 0 : { maxWidth: s },
124
+ children: [
125
+ S.map(({ color: e, label: t, variant: n }) => /* @__PURE__ */ b(d, {
126
+ type: "button",
127
+ className: "scribe-callout-type-button",
128
+ size: "1",
129
+ radius: "medium",
130
+ color: e,
131
+ variant: E === n ? "soft" : "ghost",
132
+ "aria-pressed": E === n,
133
+ onClick: () => a.chain().focus().setCalloutVariant(n).run(),
134
+ children: [/* @__PURE__ */ y(r, { variant: n }), t]
135
+ }, n)),
136
+ /* @__PURE__ */ y(p, {
137
+ className: "scribe-callout-menu-separator",
138
+ orientation: "vertical",
139
+ decorative: !0
140
+ }),
141
+ /* @__PURE__ */ b(d, {
142
+ type: "button",
143
+ className: "scribe-callout-type-button",
144
+ size: "1",
145
+ radius: "medium",
146
+ color: "gray",
147
+ variant: "ghost",
148
+ onClick: () => a.chain().focus().unsetCallout().run(),
149
+ children: [/* @__PURE__ */ y(i, {}), "Turn into text"]
150
+ })
151
+ ]
152
+ })
153
+ }) : null;
154
+ };
155
+ //#endregion
156
+ export { E as default };
@@ -1,8 +1,8 @@
1
- import { a as e } from "../../dist-Dw4STOPE.js";
1
+ import { a as e } from "../../dist-BoYfa2nz.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
3
  import n from "./LinkEditor.js";
4
4
  import { hideLinkBubbleMenu as r, linkBubbleMenuPluginKey as i, showLinkBubbleMenu as a } from "./linkBubbleMenuPlugin.js";
5
- import { t as o } from "../../menus-_EXlLMjz.js";
5
+ import { t as o } from "../../menus-B1Zz0GjH.js";
6
6
  import { Box as s } from "@radix-ui/themes";
7
7
  import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
8
8
  import { jsx as p } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { a as e } from "../../../dist-Dw4STOPE.js";
1
+ import { a as e } from "../../../dist-BoYfa2nz.js";
2
2
  import { Button as t, Flex as n } from "@radix-ui/themes";
3
3
  import { useCallback as r } from "react";
4
4
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"TableBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/TableBubbleMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EACL,EAAE,EAQH,MAAM,OAAO,CAAC;AAIf,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAkKD,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAiV7C,CAAC;eAEa,eAAe"}
1
+ {"version":3,"file":"TableBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/TableBubbleMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EACL,EAAE,EAQH,MAAM,OAAO,CAAC;AAKf,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAkKD,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAiV7C,CAAC;eAEa,eAAe"}
@@ -1,12 +1,13 @@
1
- import { a as e } from "../../dist-Dw4STOPE.js";
1
+ import { a as e } from "../../dist-BoYfa2nz.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import { t as n } from "../../menus-_EXlLMjz.js";
3
+ import { t as n } from "../../menus-B1Zz0GjH.js";
4
4
  import { getSelectionTableContext as r, tableBubbleMenuPluginKey as i } from "./tableBubbleMenuPlugin.js";
5
- import { Flex as a, IconButton as o, Separator as s } from "@radix-ui/themes";
6
- import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
7
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
5
+ import { getSelectionContextualMenuOwner as a } from "./contextualMenuOwner.js";
6
+ import { Flex as o, IconButton as s, Separator as c } from "@radix-ui/themes";
7
+ import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
8
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
9
  //#region lib/components/Menu/TableBubbleMenu.tsx
9
- var h = [
10
+ var g = [
10
11
  "addColumnAfter",
11
12
  "addColumnBefore",
12
13
  "addRowAfter",
@@ -15,7 +16,7 @@ var h = [
15
16
  "deleteRow",
16
17
  "deleteTable",
17
18
  "toggleHeaderRow"
18
- ], g = {
19
+ ], _ = {
19
20
  canAddColumnAfter: !1,
20
21
  canAddColumnBefore: !1,
21
22
  canAddRowAfter: !1,
@@ -25,23 +26,23 @@ var h = [
25
26
  canDeleteTable: !1,
26
27
  canToggleHeaderRow: !1,
27
28
  hasHeaderRow: !1
28
- }, _ = /auto|overlay|scroll/, v = (e) => {
29
+ }, v = /auto|overlay|scroll/, y = (e) => {
29
30
  let t = e.ownerDocument.defaultView;
30
31
  if (!t) return [];
31
32
  let n = [], r = e.parentElement;
32
33
  for (; r && r !== e.ownerDocument.body && r !== e.ownerDocument.documentElement;) {
33
34
  let e = t.getComputedStyle(r);
34
- _.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
35
+ v.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
35
36
  }
36
37
  return n;
37
- }, y = (e) => {
38
+ }, b = (e) => {
38
39
  let t = e.firstChild;
39
40
  if (!t || t.childCount === 0) return !1;
40
41
  let n = !0;
41
42
  return t.forEach((e) => {
42
43
  e.type.name !== "tableHeader" && (n = !1);
43
44
  }), n;
44
- }, b = ({ name: e }) => {
45
+ }, x = ({ name: e }) => {
45
46
  let t = {
46
47
  "aria-hidden": !0,
47
48
  fill: "none",
@@ -56,12 +57,12 @@ var h = [
56
57
  };
57
58
  if (e === "add-row-above" || e === "add-row-below") {
58
59
  let r = e === "add-row-above" ? 3.5 : 16.5;
59
- return /* @__PURE__ */ m("svg", {
60
+ return /* @__PURE__ */ h("svg", {
60
61
  ...t,
61
- children: [/* @__PURE__ */ p("path", {
62
+ children: [/* @__PURE__ */ m("path", {
62
63
  d: "M3.5 6.5h13v7h-13zM3.5 10h13M10 6.5v7",
63
64
  ...n
64
- }), /* @__PURE__ */ p("path", {
65
+ }), /* @__PURE__ */ m("path", {
65
66
  d: `M7.75 ${r}h4.5M10 ${r - 2.25}v4.5`,
66
67
  ...n
67
68
  })]
@@ -69,63 +70,63 @@ var h = [
69
70
  }
70
71
  if (e === "add-column-before" || e === "add-column-after") {
71
72
  let r = e === "add-column-before" ? 3.5 : 16.5;
72
- return /* @__PURE__ */ m("svg", {
73
+ return /* @__PURE__ */ h("svg", {
73
74
  ...t,
74
- children: [/* @__PURE__ */ p("path", {
75
+ children: [/* @__PURE__ */ m("path", {
75
76
  d: "M6.5 3.5h7v13h-7zM10 3.5v13M6.5 10h7",
76
77
  ...n
77
- }), /* @__PURE__ */ p("path", {
78
+ }), /* @__PURE__ */ m("path", {
78
79
  d: `M${r - 2.25} 10h4.5M${r} 7.75v4.5`,
79
80
  ...n
80
81
  })]
81
82
  });
82
83
  }
83
- return e === "delete-row" ? /* @__PURE__ */ m("svg", {
84
+ return e === "delete-row" ? /* @__PURE__ */ h("svg", {
84
85
  ...t,
85
- children: [/* @__PURE__ */ p("path", {
86
+ children: [/* @__PURE__ */ m("path", {
86
87
  d: "M3.5 4h13v12h-13zM3.5 8h13M3.5 12h13M10 4v12",
87
88
  ...n
88
- }), /* @__PURE__ */ p("path", {
89
+ }), /* @__PURE__ */ m("path", {
89
90
  d: "M6.75 10h6.5",
90
91
  stroke: "currentColor",
91
92
  strokeWidth: "2.2"
92
93
  })]
93
- }) : e === "delete-column" ? /* @__PURE__ */ m("svg", {
94
+ }) : e === "delete-column" ? /* @__PURE__ */ h("svg", {
94
95
  ...t,
95
- children: [/* @__PURE__ */ p("path", {
96
+ children: [/* @__PURE__ */ m("path", {
96
97
  d: "M4 3.5h12v13h-12zM8 3.5v13M12 3.5v13M4 10h12",
97
98
  ...n
98
- }), /* @__PURE__ */ p("path", {
99
+ }), /* @__PURE__ */ m("path", {
99
100
  d: "M10 6.75v6.5",
100
101
  stroke: "currentColor",
101
102
  strokeWidth: "2.2"
102
103
  })]
103
- }) : e === "toggle-header-row" ? /* @__PURE__ */ m("svg", {
104
+ }) : e === "toggle-header-row" ? /* @__PURE__ */ h("svg", {
104
105
  ...t,
105
- children: [/* @__PURE__ */ p("path", {
106
+ children: [/* @__PURE__ */ m("path", {
106
107
  d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
107
108
  ...n
108
- }), /* @__PURE__ */ p("path", {
109
+ }), /* @__PURE__ */ m("path", {
109
110
  d: "M4.2 4.7h11.6v2.6H4.2z",
110
111
  fill: "currentColor",
111
112
  opacity: "0.45"
112
113
  })]
113
- }) : /* @__PURE__ */ m("svg", {
114
+ }) : /* @__PURE__ */ h("svg", {
114
115
  ...t,
115
- children: [/* @__PURE__ */ p("path", {
116
+ children: [/* @__PURE__ */ m("path", {
116
117
  d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
117
118
  ...n
118
- }), /* @__PURE__ */ p("path", {
119
+ }), /* @__PURE__ */ m("path", {
119
120
  d: "m6.75 7 6.5 6.5m0-6.5-6.5 6.5",
120
121
  stroke: "currentColor",
121
122
  strokeWidth: "1.8"
122
123
  })]
123
124
  });
124
- }, x = ({ editor: _ }) => {
125
- let x = d(null), [S, C] = f(null), w = u(() => h.every((e) => typeof _.commands[e] == "function"), [_]), T = e({
126
- editor: _,
125
+ }, S = ({ editor: v }) => {
126
+ let S = f(null), [C, w] = p(null), T = d(() => g.every((e) => typeof v.commands[e] == "function"), [v]), E = e({
127
+ editor: v,
127
128
  selector: ({ editor: e }) => {
128
- if (!w) return g;
129
+ if (!T) return _;
129
130
  let t = r(e.state), n = e.can();
130
131
  return {
131
132
  canAddColumnAfter: n.addColumnAfter(),
@@ -136,25 +137,25 @@ var h = [
136
137
  canDeleteRow: n.deleteRow(),
137
138
  canDeleteTable: n.deleteTable(),
138
139
  canToggleHeaderRow: n.toggleHeaderRow(),
139
- hasHeaderRow: t ? y(t.node) : !1
140
+ hasHeaderRow: t ? b(t.node) : !1
140
141
  };
141
142
  }
142
- }), E = c(({ editor: e, element: t, state: n, view: i }) => {
143
- let a = i.hasFocus() || t.contains(t.ownerDocument.activeElement);
144
- return w && e.isEditable && a && r(n) !== null;
145
- }, [w]), D = c(() => {
146
- if (_.isDestroyed) return null;
147
- let e = r(_.state);
143
+ }), D = l(({ editor: e, element: t, state: n, view: r }) => {
144
+ let i = r.hasFocus() || t.contains(t.ownerDocument.activeElement);
145
+ return T && e.isEditable && i && a(n) === "table";
146
+ }, [T]), O = l(() => {
147
+ if (v.isDestroyed) return null;
148
+ let e = r(v.state);
148
149
  if (!e) return null;
149
- let t = _.view.nodeDOM(e.position);
150
+ let t = v.view.nodeDOM(e.position);
150
151
  return t instanceof HTMLElement ? t.closest(".tableWrapper") ?? t.querySelector(".tableWrapper") ?? t : null;
151
- }, [_]), O = c(() => t(_), [_]);
152
- l(() => {
153
- let e = _.view.dom.ownerDocument.defaultView;
152
+ }, [v]), k = l(() => t(v), [v]);
153
+ u(() => {
154
+ let e = v.view.dom.ownerDocument.defaultView;
154
155
  if (!e) return;
155
- let t = v(_.view.dom), n = null, r = () => {
156
+ let t = y(v.view.dom), n = null, r = () => {
156
157
  n === null && (n = e.requestAnimationFrame(() => {
157
- n = null, _.isDestroyed || _.view.dispatch(_.state.tr.setMeta(i, "updatePosition"));
158
+ n = null, v.isDestroyed || v.view.dispatch(v.state.tr.setMeta(i, "updatePosition"));
158
159
  }));
159
160
  };
160
161
  return t.forEach((e) => {
@@ -164,27 +165,27 @@ var h = [
164
165
  e.removeEventListener("scroll", r);
165
166
  });
166
167
  };
167
- }, [_]), l(() => {
168
- let e = _.view.dom.closest("[data-scribe-root]"), t = _.view.dom.ownerDocument.defaultView;
168
+ }, [v]), u(() => {
169
+ let e = v.view.dom.closest("[data-scribe-root]"), t = v.view.dom.ownerDocument.defaultView;
169
170
  if (!e || !t) return;
170
171
  let n = () => {
171
172
  let t = e.getBoundingClientRect().width;
172
- C(t > 0 ? Math.max(t - 16, 0) : null);
173
+ w(t > 0 ? Math.max(t - 16, 0) : null);
173
174
  };
174
175
  if (n(), !t.ResizeObserver) return;
175
176
  let r = new t.ResizeObserver(n);
176
177
  return r.observe(e), () => r.disconnect();
177
- }, [_]), l(() => {
178
- let e = _.view.dom, t = (e) => {
179
- if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !_.isEditable || !r(_.state)) return;
180
- let t = x.current?.querySelector("button:not(:disabled)");
178
+ }, [v]), u(() => {
179
+ let e = v.view.dom, t = (e) => {
180
+ if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !v.isEditable || a(v.state) !== "table") return;
181
+ let t = S.current?.querySelector("button:not(:disabled)");
181
182
  t && (e.preventDefault(), t.focus());
182
183
  };
183
184
  return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
184
- }, [_]);
185
- let k = c((e) => {
185
+ }, [v]);
186
+ let A = l((e) => {
186
187
  if (e.key === "Escape") {
187
- e.preventDefault(), _.chain().focus().run();
188
+ e.preventDefault(), v.chain().focus().run();
188
189
  return;
189
190
  }
190
191
  if (![
@@ -197,94 +198,94 @@ var h = [
197
198
  if (t.length === 0) return;
198
199
  let n = e.currentTarget.ownerDocument.activeElement, r = t.findIndex((e) => e === n), i = r;
199
200
  i = e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : e.key === "ArrowLeft" ? r <= 0 ? t.length - 1 : r - 1 : r < 0 || r === t.length - 1 ? 0 : r + 1, e.preventDefault(), t[i]?.focus();
200
- }, [_]), A = u(() => ({
201
+ }, [v]), j = d(() => ({
201
202
  strategy: "fixed",
202
203
  placement: "top-start",
203
204
  offset: 8,
204
205
  flip: {},
205
206
  shift: { padding: 8 }
206
- }), []), j = u(() => [
207
+ }), []), M = d(() => [
207
208
  [
208
209
  {
209
210
  label: "Add row above",
210
- command: () => _.chain().focus().addRowBefore().run(),
211
- disabled: !T.canAddRowBefore,
212
- icon: /* @__PURE__ */ p(b, { name: "add-row-above" })
211
+ command: () => v.chain().focus().addRowBefore().run(),
212
+ disabled: !E.canAddRowBefore,
213
+ icon: /* @__PURE__ */ m(x, { name: "add-row-above" })
213
214
  },
214
215
  {
215
216
  label: "Add row below",
216
- command: () => _.chain().focus().addRowAfter().run(),
217
- disabled: !T.canAddRowAfter,
218
- icon: /* @__PURE__ */ p(b, { name: "add-row-below" })
217
+ command: () => v.chain().focus().addRowAfter().run(),
218
+ disabled: !E.canAddRowAfter,
219
+ icon: /* @__PURE__ */ m(x, { name: "add-row-below" })
219
220
  },
220
221
  {
221
222
  label: "Delete row",
222
- command: () => _.chain().focus().deleteRow().run(),
223
- disabled: !T.canDeleteRow,
224
- icon: /* @__PURE__ */ p(b, { name: "delete-row" })
223
+ command: () => v.chain().focus().deleteRow().run(),
224
+ disabled: !E.canDeleteRow,
225
+ icon: /* @__PURE__ */ m(x, { name: "delete-row" })
225
226
  }
226
227
  ],
227
228
  [
228
229
  {
229
230
  label: "Add column before",
230
- command: () => _.chain().focus().addColumnBefore().run(),
231
- disabled: !T.canAddColumnBefore,
232
- icon: /* @__PURE__ */ p(b, { name: "add-column-before" })
231
+ command: () => v.chain().focus().addColumnBefore().run(),
232
+ disabled: !E.canAddColumnBefore,
233
+ icon: /* @__PURE__ */ m(x, { name: "add-column-before" })
233
234
  },
234
235
  {
235
236
  label: "Add column after",
236
- command: () => _.chain().focus().addColumnAfter().run(),
237
- disabled: !T.canAddColumnAfter,
238
- icon: /* @__PURE__ */ p(b, { name: "add-column-after" })
237
+ command: () => v.chain().focus().addColumnAfter().run(),
238
+ disabled: !E.canAddColumnAfter,
239
+ icon: /* @__PURE__ */ m(x, { name: "add-column-after" })
239
240
  },
240
241
  {
241
242
  label: "Delete column",
242
- command: () => _.chain().focus().deleteColumn().run(),
243
- disabled: !T.canDeleteColumn,
244
- icon: /* @__PURE__ */ p(b, { name: "delete-column" })
243
+ command: () => v.chain().focus().deleteColumn().run(),
244
+ disabled: !E.canDeleteColumn,
245
+ icon: /* @__PURE__ */ m(x, { name: "delete-column" })
245
246
  }
246
247
  ],
247
248
  [{
248
249
  label: "Toggle header row",
249
- command: () => _.chain().focus().toggleHeaderRow().run(),
250
- disabled: !T.canToggleHeaderRow,
251
- icon: /* @__PURE__ */ p(b, { name: "toggle-header-row" }),
252
- ariaPressed: T.hasHeaderRow
250
+ command: () => v.chain().focus().toggleHeaderRow().run(),
251
+ disabled: !E.canToggleHeaderRow,
252
+ icon: /* @__PURE__ */ m(x, { name: "toggle-header-row" }),
253
+ ariaPressed: E.hasHeaderRow
253
254
  }],
254
255
  [{
255
256
  label: "Delete table",
256
- command: () => _.chain().focus().deleteTable().run(),
257
- disabled: !T.canDeleteTable,
258
- icon: /* @__PURE__ */ p(b, { name: "delete-table" })
257
+ command: () => v.chain().focus().deleteTable().run(),
258
+ disabled: !E.canDeleteTable,
259
+ icon: /* @__PURE__ */ m(x, { name: "delete-table" })
259
260
  }]
260
- ], [_, T]);
261
- return /* @__PURE__ */ p(n, {
262
- editor: _,
261
+ ], [v, E]);
262
+ return /* @__PURE__ */ m(n, {
263
+ editor: v,
263
264
  pluginKey: i,
264
265
  updateDelay: 0,
265
266
  resizeDelay: 0,
266
- appendTo: O,
267
- shouldShow: E,
268
- getReferencedVirtualElement: D,
269
- options: A,
270
- children: /* @__PURE__ */ p(a, {
271
- ref: x,
267
+ appendTo: k,
268
+ shouldShow: D,
269
+ getReferencedVirtualElement: O,
270
+ options: j,
271
+ children: /* @__PURE__ */ m(o, {
272
+ ref: S,
272
273
  className: "scribe-table-bubble-menu",
273
274
  role: "toolbar",
274
275
  "aria-label": "Table controls",
275
276
  "aria-keyshortcuts": "Alt+F10",
276
277
  align: "center",
277
278
  gap: "2",
278
- onKeyDown: k,
279
- style: S === null ? void 0 : { maxWidth: S },
280
- children: j.map((e, t) => /* @__PURE__ */ m(a, {
279
+ onKeyDown: A,
280
+ style: C === null ? void 0 : { maxWidth: C },
281
+ children: M.map((e, t) => /* @__PURE__ */ h(o, {
281
282
  align: "center",
282
283
  gap: "1",
283
- children: [t > 0 ? /* @__PURE__ */ p(s, {
284
+ children: [t > 0 ? /* @__PURE__ */ m(c, {
284
285
  orientation: "vertical",
285
286
  decorative: !0,
286
287
  style: { height: 20 }
287
- }) : null, e.map((e) => /* @__PURE__ */ p(o, {
288
+ }) : null, e.map((e) => /* @__PURE__ */ m(s, {
288
289
  type: "button",
289
290
  size: "1",
290
291
  radius: "medium",
@@ -302,4 +303,4 @@ var h = [
302
303
  });
303
304
  };
304
305
  //#endregion
305
- export { x as default };
306
+ export { S as default };
@@ -0,0 +1,10 @@
1
+ import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
2
+ import type { EditorState } from "@tiptap/pm/state";
3
+ import { PluginKey } from "@tiptap/pm/state";
4
+ export interface CalloutContext {
5
+ node: ProseMirrorNode;
6
+ position: number;
7
+ }
8
+ export declare const calloutBubbleMenuPluginKey: PluginKey<any>;
9
+ export declare const getSelectionCalloutContext: (state: EditorState) => CalloutContext | null;
10
+ //# sourceMappingURL=calloutBubbleMenuPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calloutBubbleMenuPlugin.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/calloutBubbleMenuPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAe,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAiB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,0BAA0B,gBAA2C,CAAC;AAiBnF,eAAO,MAAM,0BAA0B,UAAW,WAAW,KAAG,cAAc,GAAG,IAkBhF,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { NodeSelection as e, PluginKey as t } from "@tiptap/pm/state";
2
+ //#region lib/components/Menu/calloutBubbleMenuPlugin.ts
3
+ var n = new t("scribeCalloutBubbleMenu"), r = (e) => {
4
+ for (let t = e.depth; t > 0; --t) {
5
+ let n = e.node(t);
6
+ if (n.type.name === "callout") return {
7
+ node: n,
8
+ position: e.before(t)
9
+ };
10
+ }
11
+ return null;
12
+ }, i = (t) => {
13
+ let { selection: n } = t;
14
+ if (n instanceof e && n.node.type.name === "callout") return {
15
+ node: n.node,
16
+ position: n.from
17
+ };
18
+ let i = r(n.$from), a = r(n.$to);
19
+ return !i || !a || i.position !== a.position ? null : i;
20
+ };
21
+ //#endregion
22
+ export { n as calloutBubbleMenuPluginKey, i as getSelectionCalloutContext };
@@ -0,0 +1,4 @@
1
+ import type { EditorState } from "@tiptap/pm/state";
2
+ export type ContextualMenuOwner = "callout" | "table";
3
+ export declare const getSelectionContextualMenuOwner: (state: EditorState) => ContextualMenuOwner | null;
4
+ //# sourceMappingURL=contextualMenuOwner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextualMenuOwner.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/contextualMenuOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtD,eAAO,MAAM,+BAA+B,UAAW,WAAW,KAAG,mBAAmB,GAAG,IAa1F,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { getSelectionCalloutContext as e } from "./calloutBubbleMenuPlugin.js";
2
+ import { getSelectionTableContext as t } from "./tableBubbleMenuPlugin.js";
3
+ //#region lib/components/Menu/contextualMenuOwner.ts
4
+ var n = (n) => {
5
+ let r = e(n), i = t(n);
6
+ return r ? i ? r.position > i.position ? "callout" : "table" : "callout" : i ? "table" : null;
7
+ };
8
+ //#endregion
9
+ export { n as getSelectionContextualMenuOwner };