@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.
- package/README.md +1 -1
- package/dist/{BarMenu-5M9g9Y1j.js → BarMenu-O2IVhHXx.js} +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/components/Menu/BarMenu.js +1 -1
- package/dist/components/Menu/BubbleMenu.js +2 -2
- package/dist/components/Menu/CalloutBubbleMenu.d.ts +7 -0
- package/dist/components/Menu/CalloutBubbleMenu.d.ts.map +1 -0
- package/dist/components/Menu/CalloutBubbleMenu.js +156 -0
- package/dist/components/Menu/LinkBubbleMenu.js +2 -2
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +99 -98
- package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts +10 -0
- package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts.map +1 -0
- package/dist/components/Menu/calloutBubbleMenuPlugin.js +22 -0
- package/dist/components/Menu/contextualMenuOwner.d.ts +4 -0
- package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -0
- package/dist/components/Menu/contextualMenuOwner.js +9 -0
- package/dist/components/Scribe/extension/callout.d.ts +32 -0
- package/dist/components/Scribe/extension/callout.d.ts.map +1 -0
- package/dist/components/Scribe/extension/callout.js +118 -0
- package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
- package/dist/components/Scribe/extension/extension-link.js +1 -1
- package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/index.d.ts +1 -1
- package/dist/components/Scribe/extension/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/resizable-table.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
- package/dist/components/Scribe/extension/slashCommand/items.js +48 -28
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
- package/dist/components/Scribe/extension/tableOfContents.js +1 -1
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +128 -126
- package/dist/{dist-Dw4STOPE.js → dist-BoYfa2nz.js} +1 -1
- package/dist/{dist-DFua_Xbu.js → dist-W9E-K577.js} +980 -618
- package/dist/{extension-Dy6hHSvD.js → extension-D5WIAWhc.js} +1984 -1946
- package/dist/{extension-link-CjfUZ90W.js → extension-link-D8Zi7OSa.js} +36 -36
- package/dist/{html-to-markdown-B6Uhn7ok.js → html-to-markdown-C920nQtn.js} +101 -60
- package/dist/icons/CalloutIcon.d.ts +9 -0
- package/dist/icons/CalloutIcon.d.ts.map +1 -0
- package/dist/icons/CalloutIcon.js +72 -0
- package/dist/main.css +119 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +9 -8
- package/dist/{markdown-to-html-WmeDaJXP.js → markdown-to-html-CW0Nb9Ye.js} +32 -2
- package/dist/{menus-_EXlLMjz.js → menus-B1Zz0GjH.js} +17 -17
- package/dist/{resizable-table-Ddw3l6DJ.js → resizable-table-Bf-fb9iv.js} +36 -18
- package/dist/{slashCommand-CxX07Nbk.js → slashCommand-47omO4ob.js} +2 -2
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/markdown-to-html.d.ts.map +1 -1
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +48 -25
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../BarMenu-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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 +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;
|
|
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-
|
|
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-
|
|
3
|
+
import { t as n } from "../../menus-B1Zz0GjH.js";
|
|
4
4
|
import { getSelectionTableContext as r, tableBubbleMenuPluginKey as i } from "./tableBubbleMenuPlugin.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
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
|
-
],
|
|
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
|
-
},
|
|
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
|
-
|
|
35
|
+
v.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
|
|
35
36
|
}
|
|
36
37
|
return n;
|
|
37
|
-
},
|
|
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
|
-
},
|
|
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__ */
|
|
60
|
+
return /* @__PURE__ */ h("svg", {
|
|
60
61
|
...t,
|
|
61
|
-
children: [/* @__PURE__ */
|
|
62
|
+
children: [/* @__PURE__ */ m("path", {
|
|
62
63
|
d: "M3.5 6.5h13v7h-13zM3.5 10h13M10 6.5v7",
|
|
63
64
|
...n
|
|
64
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
73
|
+
return /* @__PURE__ */ h("svg", {
|
|
73
74
|
...t,
|
|
74
|
-
children: [/* @__PURE__ */
|
|
75
|
+
children: [/* @__PURE__ */ m("path", {
|
|
75
76
|
d: "M6.5 3.5h7v13h-7zM10 3.5v13M6.5 10h7",
|
|
76
77
|
...n
|
|
77
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
84
|
+
return e === "delete-row" ? /* @__PURE__ */ h("svg", {
|
|
84
85
|
...t,
|
|
85
|
-
children: [/* @__PURE__ */
|
|
86
|
+
children: [/* @__PURE__ */ m("path", {
|
|
86
87
|
d: "M3.5 4h13v12h-13zM3.5 8h13M3.5 12h13M10 4v12",
|
|
87
88
|
...n
|
|
88
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
94
|
+
}) : e === "delete-column" ? /* @__PURE__ */ h("svg", {
|
|
94
95
|
...t,
|
|
95
|
-
children: [/* @__PURE__ */
|
|
96
|
+
children: [/* @__PURE__ */ m("path", {
|
|
96
97
|
d: "M4 3.5h12v13h-12zM8 3.5v13M12 3.5v13M4 10h12",
|
|
97
98
|
...n
|
|
98
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
104
|
+
}) : e === "toggle-header-row" ? /* @__PURE__ */ h("svg", {
|
|
104
105
|
...t,
|
|
105
|
-
children: [/* @__PURE__ */
|
|
106
|
+
children: [/* @__PURE__ */ m("path", {
|
|
106
107
|
d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
|
|
107
108
|
...n
|
|
108
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
114
|
+
}) : /* @__PURE__ */ h("svg", {
|
|
114
115
|
...t,
|
|
115
|
-
children: [/* @__PURE__ */
|
|
116
|
+
children: [/* @__PURE__ */ m("path", {
|
|
116
117
|
d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
|
|
117
118
|
...n
|
|
118
|
-
}), /* @__PURE__ */
|
|
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
|
-
},
|
|
125
|
-
let
|
|
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 (!
|
|
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 ?
|
|
140
|
+
hasHeaderRow: t ? b(t.node) : !1
|
|
140
141
|
};
|
|
141
142
|
}
|
|
142
|
-
}),
|
|
143
|
-
let
|
|
144
|
-
return
|
|
145
|
-
}, [
|
|
146
|
-
if (
|
|
147
|
-
let e = r(
|
|
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 =
|
|
150
|
+
let t = v.view.nodeDOM(e.position);
|
|
150
151
|
return t instanceof HTMLElement ? t.closest(".tableWrapper") ?? t.querySelector(".tableWrapper") ?? t : null;
|
|
151
|
-
}, [
|
|
152
|
-
|
|
153
|
-
let e =
|
|
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
|
|
156
|
+
let t = y(v.view.dom), n = null, r = () => {
|
|
156
157
|
n === null && (n = e.requestAnimationFrame(() => {
|
|
157
|
-
n = null,
|
|
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
|
-
}, [
|
|
168
|
-
let e =
|
|
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
|
-
|
|
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
|
-
}, [
|
|
178
|
-
let e =
|
|
179
|
-
if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !
|
|
180
|
-
let t =
|
|
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
|
|
185
|
+
}, [v]);
|
|
186
|
+
let A = l((e) => {
|
|
186
187
|
if (e.key === "Escape") {
|
|
187
|
-
e.preventDefault(),
|
|
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
|
-
}, [
|
|
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
|
-
}), []),
|
|
207
|
+
}), []), M = d(() => [
|
|
207
208
|
[
|
|
208
209
|
{
|
|
209
210
|
label: "Add row above",
|
|
210
|
-
command: () =>
|
|
211
|
-
disabled: !
|
|
212
|
-
icon: /* @__PURE__ */
|
|
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: () =>
|
|
217
|
-
disabled: !
|
|
218
|
-
icon: /* @__PURE__ */
|
|
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: () =>
|
|
223
|
-
disabled: !
|
|
224
|
-
icon: /* @__PURE__ */
|
|
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: () =>
|
|
231
|
-
disabled: !
|
|
232
|
-
icon: /* @__PURE__ */
|
|
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: () =>
|
|
237
|
-
disabled: !
|
|
238
|
-
icon: /* @__PURE__ */
|
|
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: () =>
|
|
243
|
-
disabled: !
|
|
244
|
-
icon: /* @__PURE__ */
|
|
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: () =>
|
|
250
|
-
disabled: !
|
|
251
|
-
icon: /* @__PURE__ */
|
|
252
|
-
ariaPressed:
|
|
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: () =>
|
|
257
|
-
disabled: !
|
|
258
|
-
icon: /* @__PURE__ */
|
|
257
|
+
command: () => v.chain().focus().deleteTable().run(),
|
|
258
|
+
disabled: !E.canDeleteTable,
|
|
259
|
+
icon: /* @__PURE__ */ m(x, { name: "delete-table" })
|
|
259
260
|
}]
|
|
260
|
-
], [
|
|
261
|
-
return /* @__PURE__ */
|
|
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:
|
|
267
|
-
shouldShow:
|
|
268
|
-
getReferencedVirtualElement:
|
|
269
|
-
options:
|
|
270
|
-
children: /* @__PURE__ */
|
|
271
|
-
ref:
|
|
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:
|
|
279
|
-
style:
|
|
280
|
-
children:
|
|
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__ */
|
|
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__ */
|
|
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 {
|
|
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 @@
|
|
|
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 };
|