dishui 0.0.97 → 0.0.101
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/dist/.release-verified.json +2 -2
- package/dist/ai.js +17 -15
- package/dist/components/Card/Ticket.d.ts +52 -0
- package/dist/components/Card/Ticket2.js +218 -0
- package/dist/components/Card/Ticket2.js.map +1 -0
- package/dist/components/Card/index.d.ts +12 -0
- package/dist/components/Card/index.js +142 -139
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/ai/AgentRunCard/index.d.ts +38 -0
- package/dist/components/ai/AgentRunCard/index.js +100 -0
- package/dist/components/ai/AgentRunCard/index.js.map +1 -0
- package/dist/components/ai/IssueCard/index.d.ts +39 -0
- package/dist/components/ai/IssueCard/index.js +78 -0
- package/dist/components/ai/IssueCard/index.js.map +1 -0
- package/dist/components/ai/index.d.ts +4 -0
- package/dist/components/pro/Flow/constants.js +3 -3
- package/dist/components/pro/Flow/constants.js.map +1 -1
- package/dist/components/pro/Flow/nodes/shapes.js +3 -3
- package/dist/components/pro/Flow/nodes/shapes.js.map +1 -1
- package/dist/components/pro/Flow/utils/themeColor.d.ts +2 -2
- package/dist/components/pro/Flow/utils/themeColor.js +2 -2
- package/dist/components/pro/Flow/utils/themeColor.js.map +1 -1
- package/dist/components/pro/Kanban/Kanban.d.ts +3 -0
- package/dist/components/pro/Kanban/Kanban.js +339 -0
- package/dist/components/pro/Kanban/Kanban.js.map +1 -0
- package/dist/components/pro/Kanban/Swimlanes.d.ts +3 -0
- package/dist/components/pro/Kanban/Swimlanes.js +60 -0
- package/dist/components/pro/Kanban/Swimlanes.js.map +1 -0
- package/dist/components/pro/Kanban/index.d.ts +5 -0
- package/dist/components/pro/Kanban/types.d.ts +103 -0
- package/dist/components/pro/Kanban/useKanbanDrag.d.ts +17 -0
- package/dist/components/pro/Kanban/useKanbanDrag.js +69 -0
- package/dist/components/pro/Kanban/useKanbanDrag.js.map +1 -0
- package/dist/components/pro/Kanban/utils.d.ts +13 -0
- package/dist/components/pro/Kanban/utils.js +48 -0
- package/dist/components/pro/Kanban/utils.js.map +1 -0
- package/dist/components/pro/RichTextEditor/AIRewrite.js +158 -127
- package/dist/components/pro/RichTextEditor/AIRewrite.js.map +1 -1
- package/dist/components/pro/RichTextEditor/BlockHandle.d.ts +2 -0
- package/dist/components/pro/RichTextEditor/BlockHandle.js +156 -115
- package/dist/components/pro/RichTextEditor/BlockHandle.js.map +1 -1
- package/dist/components/pro/RichTextEditor/RichTextEditor.js +136 -159
- package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js +44 -41
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/FloatingDialogMenu.js +59 -53
- package/dist/components/pro/RichTextEditor/Toolbar/FloatingDialogMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/MarkdownTemplates.js +48 -44
- package/dist/components/pro/RichTextEditor/Toolbar/MarkdownTemplates.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/TableOpsMenu.js +67 -63
- package/dist/components/pro/RichTextEditor/Toolbar/TableOpsMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.d.ts +1 -0
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js +182 -129
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/ToolbarButton.d.ts +1 -0
- package/dist/components/pro/RichTextEditor/Toolbar/ToolbarButton.js +3 -3
- package/dist/components/pro/RichTextEditor/Toolbar/ToolbarButton.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/useAnchoredDropdown.d.ts +3 -0
- package/dist/components/pro/RichTextEditor/Toolbar/useAnchoredDropdown.js +31 -0
- package/dist/components/pro/RichTextEditor/Toolbar/useAnchoredDropdown.js.map +1 -0
- package/dist/components/pro/RichTextEditor/index.d.ts +1 -1
- package/dist/components/pro/RichTextEditor/types.d.ts +78 -11
- package/dist/components/pro/RichTextEditor/types.js +11 -0
- package/dist/components/pro/RichTextEditor/types.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/index-nostyled.d.ts +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +128 -122
- package/dist/kanban.js +5 -0
- package/dist/utils/i18n.js +20 -0
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js +1 -1
- package/dist/utils/menu.js.map +1 -1
- package/package.json +5 -1
|
@@ -2,21 +2,21 @@ import { useCallback as e, useEffect as t, useLayoutEffect as n, useRef as r, us
|
|
|
2
2
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
3
3
|
import { NodeSelection as c, Selection as l } from "@tiptap/pm/state";
|
|
4
4
|
//#region src/components/pro/RichTextEditor/BlockHandle.tsx
|
|
5
|
-
var u = ({ editor: u }) => {
|
|
6
|
-
let [
|
|
5
|
+
var u = ({ editor: u, persistent: d = !1 }) => {
|
|
6
|
+
let [f, p] = i(!1), [m, h] = i(0), [g, _] = i(!1), [v, y] = i("add"), [b, x] = i({
|
|
7
7
|
left: 4,
|
|
8
8
|
top: 0
|
|
9
|
-
}),
|
|
10
|
-
|
|
11
|
-
}, []),
|
|
12
|
-
|
|
13
|
-
!
|
|
9
|
+
}), S = r(null), C = r(null), w = r(!1), [T, E] = i(-1), [D, O] = i(!1), [k, A] = i(null), j = r(null), M = r(null), N = r(null), P = r(!1), F = e(() => {
|
|
10
|
+
N.current &&= (clearTimeout(N.current), null);
|
|
11
|
+
}, []), I = e(() => {
|
|
12
|
+
F(), N.current = setTimeout(() => {
|
|
13
|
+
!P.current && !g && !D && !M.current?.contains(document.activeElement) && !j.current?.contains(document.activeElement) && p(!1);
|
|
14
14
|
}, 200);
|
|
15
15
|
}, [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
]),
|
|
16
|
+
F,
|
|
17
|
+
g,
|
|
18
|
+
D
|
|
19
|
+
]), L = e(() => {
|
|
20
20
|
if (u.isDestroyed) return [];
|
|
21
21
|
let e = u.view.dom.closest(".rte-editor-wrapper");
|
|
22
22
|
if (!e) return [];
|
|
@@ -33,76 +33,102 @@ var u = ({ editor: u }) => {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
}), r;
|
|
36
|
-
}, [u]),
|
|
36
|
+
}, [u]), R = e((e) => {
|
|
37
37
|
let t = u.view.dom.closest(".rte-editor-wrapper");
|
|
38
38
|
if (!t) return -1;
|
|
39
39
|
let n = e - t.getBoundingClientRect().top - t.clientTop + t.scrollTop;
|
|
40
|
-
return
|
|
41
|
-
}, [u,
|
|
40
|
+
return L().findIndex((e) => n >= e.domTop && n <= e.domBottom);
|
|
41
|
+
}, [u, L]), z = e((e) => {
|
|
42
|
+
let t = L(), n = R(e);
|
|
43
|
+
if (n < 0 || n >= t.length) return !1;
|
|
44
|
+
let r = t[n], i = u.state.doc.nodeAt(r.pos);
|
|
45
|
+
return i ? (S.current = {
|
|
46
|
+
pos: r.pos,
|
|
47
|
+
node: i
|
|
48
|
+
}, E(n), h(r.domTop), p(!0), !0) : !1;
|
|
49
|
+
}, [
|
|
50
|
+
u,
|
|
51
|
+
R,
|
|
52
|
+
L
|
|
53
|
+
]), B = e((e) => {
|
|
42
54
|
let t = u.view.dom.closest(".rte-editor-wrapper");
|
|
43
55
|
if (!t) return null;
|
|
44
|
-
let n = e - t.getBoundingClientRect().top - t.clientTop + t.scrollTop, r =
|
|
56
|
+
let n = e - t.getBoundingClientRect().top - t.clientTop + t.scrollTop, r = L();
|
|
45
57
|
if (r.length === 0) return null;
|
|
46
|
-
let i =
|
|
58
|
+
let i = S.current, a = i ? r.findIndex((e) => e.pos === i.pos) : -1, o = r.findIndex((e) => n >= e.domTop && n <= e.domBottom);
|
|
59
|
+
if (a > o && o >= 0) return {
|
|
60
|
+
slotIndex: o,
|
|
61
|
+
indicatorTop: r[o].domTop
|
|
62
|
+
};
|
|
63
|
+
let s = 0, c = Infinity, l = r[0].domTop;
|
|
47
64
|
for (let e = 0; e <= r.length; e++) {
|
|
48
|
-
let t = e < r.length ? r[e].domTop : r[r.length - 1].domBottom,
|
|
49
|
-
|
|
65
|
+
let t = e < r.length ? r[e].domTop : r[r.length - 1].domBottom, i = Math.abs(n - t);
|
|
66
|
+
i < c && (c = i, s = e, l = t);
|
|
50
67
|
}
|
|
51
68
|
return {
|
|
52
|
-
slotIndex:
|
|
53
|
-
indicatorTop:
|
|
69
|
+
slotIndex: s,
|
|
70
|
+
indicatorTop: l
|
|
54
71
|
};
|
|
55
|
-
}, [u,
|
|
72
|
+
}, [u, L]);
|
|
56
73
|
t(() => {
|
|
57
74
|
let e = u.view.dom.closest(".rte-editor-wrapper");
|
|
58
75
|
if (!e) return;
|
|
59
76
|
let t = (t) => {
|
|
60
|
-
if (
|
|
61
|
-
let n =
|
|
77
|
+
if (D || C.current || g || P.current || !u.isEditable || u.view.composing || M.current?.contains(t.target) || j.current?.contains(t.target)) return;
|
|
78
|
+
let n = R(t.clientY);
|
|
62
79
|
if (n < 0) {
|
|
63
|
-
|
|
80
|
+
I();
|
|
64
81
|
return;
|
|
65
82
|
}
|
|
66
|
-
let r =
|
|
67
|
-
if (n >= r.length) return;
|
|
83
|
+
let r = L();
|
|
84
|
+
if (n >= r.length || !z(t.clientY)) return;
|
|
68
85
|
let i = Math.max(0, -e.getBoundingClientRect().top);
|
|
69
|
-
|
|
70
|
-
let a = u.state.doc.nodeAt(r[n].pos);
|
|
71
|
-
x.current = a ? {
|
|
72
|
-
pos: r[n].pos,
|
|
73
|
-
node: a
|
|
74
|
-
} : null, P(), f(!0);
|
|
86
|
+
h(Math.max(r[n].domTop, e.scrollTop + i + 4)), F();
|
|
75
87
|
}, n = () => {
|
|
76
|
-
|
|
88
|
+
D || I();
|
|
89
|
+
}, r = (e) => {
|
|
90
|
+
if (!u.isEditable || u.view.composing) return;
|
|
91
|
+
let t = e.touches[0];
|
|
92
|
+
t && z(t.clientY);
|
|
77
93
|
};
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
e.addEventListener("mousemove", t), e.addEventListener("mouseleave", n), e.addEventListener("touchstart", r);
|
|
95
|
+
let i = d ? requestAnimationFrame(() => {
|
|
96
|
+
let e = L(), t = e[0] ? u.state.doc.nodeAt(e[0].pos) : null;
|
|
97
|
+
e[0] && t && (S.current = {
|
|
98
|
+
pos: e[0].pos,
|
|
99
|
+
node: t
|
|
100
|
+
}, E(0), h(e[0].domTop), p(!0));
|
|
101
|
+
}) : null;
|
|
102
|
+
return () => {
|
|
103
|
+
e.removeEventListener("mousemove", t), e.removeEventListener("mouseleave", n), e.removeEventListener("touchstart", r), i !== null && cancelAnimationFrame(i), F();
|
|
80
104
|
};
|
|
81
105
|
}, [
|
|
82
106
|
u,
|
|
83
|
-
P,
|
|
84
107
|
F,
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
I,
|
|
109
|
+
D,
|
|
110
|
+
g,
|
|
111
|
+
R,
|
|
87
112
|
L,
|
|
88
|
-
|
|
113
|
+
z,
|
|
114
|
+
d
|
|
89
115
|
]), t(() => {
|
|
90
|
-
if (!
|
|
116
|
+
if (!g) return;
|
|
91
117
|
let e = (e) => {
|
|
92
|
-
|
|
118
|
+
j.current && !j.current.contains(e.target) && !M.current?.contains(e.target) && (P.current = !1, _(!1));
|
|
93
119
|
};
|
|
94
120
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
95
|
-
}, [
|
|
96
|
-
let
|
|
97
|
-
let e =
|
|
121
|
+
}, [g]);
|
|
122
|
+
let V = e(() => {
|
|
123
|
+
let e = S.current;
|
|
98
124
|
return u.isDestroyed || !u.isEditable || u.view.composing || !e || u.state.doc.nodeAt(e.pos) !== e.node ? null : e;
|
|
99
|
-
}, [u]),
|
|
100
|
-
let t =
|
|
125
|
+
}, [u]), H = e((e) => {
|
|
126
|
+
let t = V();
|
|
101
127
|
if (!t) return;
|
|
102
128
|
let n = t.pos + t.node.nodeSize;
|
|
103
|
-
u.chain().focus().insertContentAt(n, e).command(({ tr: e }) => (e.setSelection(l.near(e.doc.resolve(n + 1))), !0)).run(),
|
|
104
|
-
}, [u,
|
|
105
|
-
let t =
|
|
129
|
+
u.chain().focus().insertContentAt(n, e).command(({ tr: e }) => (e.setSelection(l.near(e.doc.resolve(n + 1))), !0)).run(), _(!1);
|
|
130
|
+
}, [u, V]), U = e((e) => {
|
|
131
|
+
let t = V(), n = L();
|
|
106
132
|
if (!t || e < 0 || e > n.length) return;
|
|
107
133
|
let r = n.findIndex((e) => e.pos === t.pos);
|
|
108
134
|
if (r < 0 || e === r || e === r + 1) return;
|
|
@@ -110,67 +136,72 @@ var u = ({ editor: u }) => {
|
|
|
110
136
|
a.insert(o, t.node), a.setSelection(c.isSelectable(t.node) ? c.create(a.doc, o) : l.near(a.doc.resolve(o))), u.view.dispatch(a.scrollIntoView()), u.view.focus();
|
|
111
137
|
}, [
|
|
112
138
|
u,
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
V,
|
|
140
|
+
L
|
|
115
141
|
]);
|
|
116
142
|
t(() => {
|
|
117
143
|
let e = () => {
|
|
118
|
-
|
|
144
|
+
C.current?.(), S.current = null, P.current = !1, p(d), _(!1), F();
|
|
119
145
|
}, t = ({ transaction: t }) => {
|
|
120
146
|
(t.docChanged || !u.isEditable) && e();
|
|
121
147
|
}, n = (t) => {
|
|
122
|
-
(!(t.target instanceof Node) || !
|
|
148
|
+
(!(t.target instanceof Node) || !j.current?.contains(t.target)) && e();
|
|
123
149
|
};
|
|
124
150
|
u.on("transaction", t);
|
|
125
151
|
let r = u.view.dom;
|
|
126
152
|
return r.addEventListener("compositionstart", e), window.addEventListener("scroll", n, !0), window.addEventListener("resize", e), window.addEventListener("blur", e), () => {
|
|
127
|
-
u.off("transaction", t), r.removeEventListener("compositionstart", e), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", e), window.removeEventListener("blur", e),
|
|
153
|
+
u.off("transaction", t), r.removeEventListener("compositionstart", e), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", e), window.removeEventListener("blur", e), C.current?.(), F();
|
|
128
154
|
};
|
|
129
|
-
}, [
|
|
130
|
-
|
|
131
|
-
|
|
155
|
+
}, [
|
|
156
|
+
u,
|
|
157
|
+
F,
|
|
158
|
+
d
|
|
159
|
+
]), n(() => {
|
|
160
|
+
if (!g) return;
|
|
161
|
+
let e = j.current, t = M.current, n = u.view.dom.closest(".rte-editor-wrapper");
|
|
132
162
|
if (!e || !t || !n) return;
|
|
133
163
|
let r = n.getBoundingClientRect(), i = t.getBoundingClientRect(), a = Math.max(8, r.left + n.clientLeft), o = Math.min(window.innerWidth - 8, r.right), s = Math.max(8, r.top + n.clientTop), c = Math.min(window.innerHeight - 8, r.bottom) - i.bottom - 4, l = i.top - s - 4, d = c < e.scrollHeight && l > c;
|
|
134
|
-
e.style.maxHeight = `${Math.max(0, Math.min(320, d ? l : c))}px`, e.style.minWidth = "0", e.style.width = `${Math.max(0, Math.min(220, o - a))}px`,
|
|
164
|
+
e.style.maxHeight = `${Math.max(0, Math.min(320, d ? l : c))}px`, e.style.minWidth = "0", e.style.width = `${Math.max(0, Math.min(220, o - a))}px`, x({
|
|
135
165
|
left: Math.max(a, Math.min(i.left, o - e.offsetWidth)) - r.left - n.clientLeft + n.scrollLeft,
|
|
136
166
|
top: (d ? i.top - e.offsetHeight - 4 : i.bottom + 4) - r.top - n.clientTop + n.scrollTop
|
|
137
167
|
});
|
|
138
|
-
let f =
|
|
168
|
+
let f = v === "actions" ? "button:not(:disabled)" : "button";
|
|
139
169
|
e.querySelector(f)?.focus({ preventScroll: !0 });
|
|
140
170
|
}, [
|
|
141
171
|
u,
|
|
142
|
-
|
|
143
|
-
|
|
172
|
+
g,
|
|
173
|
+
v
|
|
144
174
|
]);
|
|
145
|
-
let
|
|
146
|
-
if (e.preventDefault(), e.stopPropagation(), e.button !== 0 || !z()) return;
|
|
147
|
-
|
|
175
|
+
let W = e((e) => {
|
|
176
|
+
if (e.preventDefault(), e.stopPropagation(), e.button !== 0 || !z(e.clientY) || !V()) return;
|
|
177
|
+
C.current?.(), w.current = !1;
|
|
148
178
|
let t = e.clientX, n = e.clientY, r = !1, i = (e) => {
|
|
149
179
|
if (!r && Math.hypot(e.clientX - t, e.clientY - n) < 5) return;
|
|
150
|
-
r = !0,
|
|
151
|
-
let i =
|
|
152
|
-
i &&
|
|
180
|
+
r = !0, w.current = !0, _(!1), O(!0);
|
|
181
|
+
let i = B(e.clientY);
|
|
182
|
+
i && A({ top: i.indicatorTop });
|
|
153
183
|
}, a = () => {
|
|
154
|
-
document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", s), document.removeEventListener("keydown", o, !0),
|
|
184
|
+
document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", s), document.removeEventListener("keydown", o, !0), C.current = null, O(!1), A(null);
|
|
155
185
|
}, o = (e) => {
|
|
156
|
-
e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation(),
|
|
186
|
+
e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation(), w.current = !0, a());
|
|
157
187
|
}, s = (e) => {
|
|
158
188
|
if (a(), !r) return;
|
|
159
189
|
let t = u.view.dom.closest(".rte-editor-wrapper")?.getBoundingClientRect();
|
|
160
190
|
if (!t || e.clientX < t.left || e.clientX > t.right || e.clientY < t.top || e.clientY > t.bottom) return;
|
|
161
|
-
let n =
|
|
162
|
-
n &&
|
|
191
|
+
let n = B(e.clientY);
|
|
192
|
+
n && U(n.slotIndex);
|
|
163
193
|
};
|
|
164
|
-
|
|
194
|
+
C.current = a, document.addEventListener("mousemove", i), document.addEventListener("mouseup", s), document.addEventListener("keydown", o, !0);
|
|
165
195
|
}, [
|
|
166
196
|
u,
|
|
167
|
-
z,
|
|
168
197
|
V,
|
|
169
|
-
|
|
170
|
-
|
|
198
|
+
U,
|
|
199
|
+
B,
|
|
200
|
+
z
|
|
201
|
+
]), G = { type: "paragraph" }, K = [
|
|
171
202
|
{
|
|
172
203
|
label: "Text",
|
|
173
|
-
content:
|
|
204
|
+
content: G
|
|
174
205
|
},
|
|
175
206
|
...[
|
|
176
207
|
1,
|
|
@@ -189,7 +220,7 @@ var u = ({ editor: u }) => {
|
|
|
189
220
|
type: "bulletList",
|
|
190
221
|
content: [{
|
|
191
222
|
type: "listItem",
|
|
192
|
-
content: [
|
|
223
|
+
content: [G]
|
|
193
224
|
}]
|
|
194
225
|
}
|
|
195
226
|
},
|
|
@@ -199,7 +230,7 @@ var u = ({ editor: u }) => {
|
|
|
199
230
|
type: "orderedList",
|
|
200
231
|
content: [{
|
|
201
232
|
type: "listItem",
|
|
202
|
-
content: [
|
|
233
|
+
content: [G]
|
|
203
234
|
}]
|
|
204
235
|
}
|
|
205
236
|
},
|
|
@@ -210,7 +241,7 @@ var u = ({ editor: u }) => {
|
|
|
210
241
|
content: [{
|
|
211
242
|
type: "taskItem",
|
|
212
243
|
attrs: { checked: !1 },
|
|
213
|
-
content: [
|
|
244
|
+
content: [G]
|
|
214
245
|
}]
|
|
215
246
|
}
|
|
216
247
|
},
|
|
@@ -218,7 +249,7 @@ var u = ({ editor: u }) => {
|
|
|
218
249
|
label: "Blockquote",
|
|
219
250
|
content: {
|
|
220
251
|
type: "blockquote",
|
|
221
|
-
content: [
|
|
252
|
+
content: [G]
|
|
222
253
|
}
|
|
223
254
|
},
|
|
224
255
|
{
|
|
@@ -237,48 +268,48 @@ var u = ({ editor: u }) => {
|
|
|
237
268
|
type: "tableRow",
|
|
238
269
|
content: Array.from({ length: 3 }, () => ({
|
|
239
270
|
type: t === 0 ? "tableHeader" : "tableCell",
|
|
240
|
-
content: [
|
|
271
|
+
content: [G]
|
|
241
272
|
}))
|
|
242
273
|
}))
|
|
243
274
|
}
|
|
244
275
|
}
|
|
245
|
-
],
|
|
276
|
+
], q = v === "add" ? K.filter((e) => u.schema.nodes[e.content.type]) : [
|
|
246
277
|
{ label: "Duplicate" },
|
|
247
278
|
{ label: "Delete" },
|
|
248
279
|
{
|
|
249
280
|
label: "Move up",
|
|
250
|
-
disabled:
|
|
281
|
+
disabled: T <= 0
|
|
251
282
|
},
|
|
252
283
|
{
|
|
253
284
|
label: "Move down",
|
|
254
|
-
disabled:
|
|
285
|
+
disabled: T >= u.state.doc.childCount - 1
|
|
255
286
|
}
|
|
256
|
-
],
|
|
287
|
+
], J = (e) => {
|
|
257
288
|
if (e.disabled) return;
|
|
258
|
-
let t =
|
|
289
|
+
let t = V();
|
|
259
290
|
if (t) {
|
|
260
|
-
if (e.content)
|
|
291
|
+
if (e.content) H(e.content);
|
|
261
292
|
else if (e.label === "Duplicate") {
|
|
262
293
|
let e = t.pos + t.node.nodeSize, n = u.state.tr.insert(e, t.node);
|
|
263
294
|
n.setSelection(l.near(n.doc.resolve(e + 1))), u.view.dispatch(n.scrollIntoView()), u.view.focus();
|
|
264
295
|
} else e.label === "Delete" ? u.chain().focus().deleteRange({
|
|
265
296
|
from: t.pos,
|
|
266
297
|
to: t.pos + t.node.nodeSize
|
|
267
|
-
}).run() : e.label === "Move up" ?
|
|
298
|
+
}).run() : e.label === "Move up" ? U(T - 1) : e.label === "Move down" && U(T + 2);
|
|
268
299
|
}
|
|
269
300
|
};
|
|
270
|
-
return !
|
|
301
|
+
return !f && !g && !D ? null : /* @__PURE__ */ s(a, { children: [
|
|
271
302
|
/* @__PURE__ */ s("div", {
|
|
272
|
-
ref:
|
|
273
|
-
className: "rte-block-handle"
|
|
274
|
-
style: { top:
|
|
275
|
-
onFocus:
|
|
276
|
-
onBlur:
|
|
303
|
+
ref: M,
|
|
304
|
+
className: `rte-block-handle ${d ? "rte-block-handle--persistent" : ""}`,
|
|
305
|
+
style: { top: m },
|
|
306
|
+
onFocus: F,
|
|
307
|
+
onBlur: I,
|
|
277
308
|
onMouseEnter: () => {
|
|
278
|
-
|
|
309
|
+
P.current = !0, F();
|
|
279
310
|
},
|
|
280
311
|
onMouseLeave: () => {
|
|
281
|
-
|
|
312
|
+
P.current = !1, D || I();
|
|
282
313
|
},
|
|
283
314
|
onMouseDown: (e) => {
|
|
284
315
|
e.stopPropagation(), e.preventDefault();
|
|
@@ -289,12 +320,19 @@ var u = ({ editor: u }) => {
|
|
|
289
320
|
onMouseDown: (e) => {
|
|
290
321
|
e.stopPropagation(), e.preventDefault();
|
|
291
322
|
},
|
|
323
|
+
onTouchStart: (e) => {
|
|
324
|
+
e.stopPropagation(), w.current = !0, V() && (y("add"), _(!g || v !== "add"));
|
|
325
|
+
},
|
|
292
326
|
onClick: (e) => {
|
|
293
|
-
e.stopPropagation(),
|
|
327
|
+
if (e.stopPropagation(), w.current) {
|
|
328
|
+
w.current = !1;
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
V() && (y("add"), _(!g || v !== "add"));
|
|
294
332
|
},
|
|
295
333
|
"aria-label": "Add block",
|
|
296
334
|
"aria-haspopup": "menu",
|
|
297
|
-
"aria-expanded":
|
|
335
|
+
"aria-expanded": g && v === "add",
|
|
298
336
|
title: "Add block",
|
|
299
337
|
children: /* @__PURE__ */ s("svg", {
|
|
300
338
|
width: "14",
|
|
@@ -317,18 +355,21 @@ var u = ({ editor: u }) => {
|
|
|
317
355
|
})
|
|
318
356
|
}), /* @__PURE__ */ o("button", {
|
|
319
357
|
type: "button",
|
|
320
|
-
className: `rte-block-handle__btn rte-block-handle__btn--drag ${
|
|
358
|
+
className: `rte-block-handle__btn rte-block-handle__btn--drag ${D ? "rte-block-handle__btn--dragging" : ""}`,
|
|
321
359
|
title: "Drag to reorder or click for block actions",
|
|
322
360
|
"aria-label": "Block actions",
|
|
323
361
|
"aria-haspopup": "menu",
|
|
324
|
-
"aria-expanded":
|
|
325
|
-
onMouseDown:
|
|
362
|
+
"aria-expanded": g && v === "actions",
|
|
363
|
+
onMouseDown: W,
|
|
364
|
+
onTouchStart: (e) => {
|
|
365
|
+
e.stopPropagation(), w.current = !0, y("actions"), _(!g || v !== "actions");
|
|
366
|
+
},
|
|
326
367
|
onClick: (e) => {
|
|
327
|
-
if (e.stopPropagation(),
|
|
328
|
-
|
|
368
|
+
if (e.stopPropagation(), w.current) {
|
|
369
|
+
w.current = !1;
|
|
329
370
|
return;
|
|
330
371
|
}
|
|
331
|
-
|
|
372
|
+
V() && (y("actions"), _(!g || v !== "actions"));
|
|
332
373
|
},
|
|
333
374
|
children: /* @__PURE__ */ s("svg", {
|
|
334
375
|
width: "14",
|
|
@@ -372,20 +413,20 @@ var u = ({ editor: u }) => {
|
|
|
372
413
|
})
|
|
373
414
|
})]
|
|
374
415
|
}),
|
|
375
|
-
|
|
376
|
-
ref:
|
|
416
|
+
g && /* @__PURE__ */ o("div", {
|
|
417
|
+
ref: j,
|
|
377
418
|
className: "rte-block-handle__menu",
|
|
378
419
|
role: "menu",
|
|
379
|
-
"aria-label":
|
|
420
|
+
"aria-label": v === "add" ? "Add block" : "Block actions",
|
|
380
421
|
style: {
|
|
381
|
-
...
|
|
422
|
+
...b,
|
|
382
423
|
overflowY: "auto"
|
|
383
424
|
},
|
|
384
425
|
onMouseEnter: () => {
|
|
385
|
-
|
|
426
|
+
P.current = !0, F();
|
|
386
427
|
},
|
|
387
428
|
onMouseLeave: () => {
|
|
388
|
-
|
|
429
|
+
P.current = !1;
|
|
389
430
|
},
|
|
390
431
|
onMouseDown: (e) => {
|
|
391
432
|
e.stopPropagation(), e.preventDefault();
|
|
@@ -393,7 +434,7 @@ var u = ({ editor: u }) => {
|
|
|
393
434
|
onKeyDown: (e) => {
|
|
394
435
|
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
395
436
|
if (e.key === "Escape" || e.key === "Tab") {
|
|
396
|
-
e.key === "Escape" && e.preventDefault(), e.stopPropagation(),
|
|
437
|
+
e.key === "Escape" && e.preventDefault(), e.stopPropagation(), P.current = !1, _(!1), M.current?.querySelector(v === "add" ? ".rte-block-handle__btn--add" : ".rte-block-handle__btn--drag")?.focus({ preventScroll: !0 });
|
|
397
438
|
return;
|
|
398
439
|
}
|
|
399
440
|
if (![
|
|
@@ -408,7 +449,7 @@ var u = ({ editor: u }) => {
|
|
|
408
449
|
let i = t[r];
|
|
409
450
|
i && i.offsetTop < e.currentTarget.scrollTop ? e.currentTarget.scrollTop = i.offsetTop : i && i.offsetTop + i.offsetHeight > e.currentTarget.scrollTop + e.currentTarget.clientHeight && (e.currentTarget.scrollTop = i.offsetTop + i.offsetHeight - e.currentTarget.clientHeight);
|
|
410
451
|
},
|
|
411
|
-
children:
|
|
452
|
+
children: q.map((e) => /* @__PURE__ */ o("button", {
|
|
412
453
|
type: "button",
|
|
413
454
|
role: "menuitem",
|
|
414
455
|
disabled: e.disabled,
|
|
@@ -419,14 +460,14 @@ var u = ({ editor: u }) => {
|
|
|
419
460
|
className: "rte-block-handle__menu-item",
|
|
420
461
|
onMouseDown: (e) => e.stopPropagation(),
|
|
421
462
|
onClick: (t) => {
|
|
422
|
-
t.stopPropagation(),
|
|
463
|
+
t.stopPropagation(), J(e), _(!1), P.current = !1;
|
|
423
464
|
},
|
|
424
465
|
children: e.label
|
|
425
466
|
}, e.label))
|
|
426
467
|
}),
|
|
427
|
-
|
|
468
|
+
D && k && /* @__PURE__ */ o("div", {
|
|
428
469
|
className: "rte-block-handle__drop-indicator",
|
|
429
|
-
style: { top:
|
|
470
|
+
style: { top: k.top }
|
|
430
471
|
})
|
|
431
472
|
] });
|
|
432
473
|
};
|