@milkdown/plugin-slash 6.5.2 → 6.5.3
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/lib/config.d.ts +11 -11
- package/lib/config.d.ts.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +111 -106
- package/lib/index.es.js.map +1 -1
- package/lib/item.d.ts +3 -3
- package/lib/item.d.ts.map +1 -1
- package/lib/prose-plugin/dropdown.d.ts +3 -3
- package/lib/prose-plugin/dropdown.d.ts.map +1 -1
- package/lib/prose-plugin/index.d.ts +2 -2
- package/lib/prose-plugin/index.d.ts.map +1 -1
- package/lib/prose-plugin/input.d.ts +3 -3
- package/lib/prose-plugin/input.d.ts.map +1 -1
- package/lib/prose-plugin/props.d.ts +5 -4
- package/lib/prose-plugin/props.d.ts.map +1 -1
- package/lib/prose-plugin/status.d.ts +5 -5
- package/lib/prose-plugin/status.d.ts.map +1 -1
- package/lib/prose-plugin/view.d.ts +4 -4
- package/lib/prose-plugin/view.d.ts.map +1 -1
- package/lib/style.d.ts +1 -1
- package/lib/style.d.ts.map +1 -1
- package/lib/utility.d.ts +3 -3
- package/lib/utility.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/config.ts +126 -121
- package/src/index.ts +25 -24
- package/src/item.ts +14 -14
- package/src/prose-plugin/dropdown.ts +45 -46
- package/src/prose-plugin/index.ts +19 -18
- package/src/prose-plugin/input.ts +122 -108
- package/src/prose-plugin/props.ts +79 -81
- package/src/prose-plugin/status.ts +29 -28
- package/src/prose-plugin/view.ts +104 -102
- package/src/style.ts +20 -18
- package/src/utility.ts +63 -64
package/lib/config.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Ctx } from '@milkdown/core';
|
|
2
|
-
import { Node } from '@milkdown/prose/model';
|
|
3
|
-
import { EditorState } from '@milkdown/prose/state';
|
|
4
|
-
import { WrappedAction } from './item';
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
import type { Ctx } from '@milkdown/core';
|
|
2
|
+
import type { Node } from '@milkdown/prose/model';
|
|
3
|
+
import type { EditorState } from '@milkdown/prose/state';
|
|
4
|
+
import type { WrappedAction } from './item';
|
|
5
|
+
type Nullable<T> = T | null | undefined;
|
|
6
|
+
export interface StatusConfig {
|
|
7
7
|
placeholder?: Nullable<string>;
|
|
8
8
|
actions?: Nullable<WrappedAction[]>;
|
|
9
|
-
}
|
|
10
|
-
export
|
|
9
|
+
}
|
|
10
|
+
export interface StatusConfigBuilderParams {
|
|
11
11
|
content: string;
|
|
12
12
|
isTopLevel: boolean;
|
|
13
13
|
parentNode: Node;
|
|
14
14
|
state: EditorState;
|
|
15
|
-
}
|
|
16
|
-
export
|
|
17
|
-
export
|
|
15
|
+
}
|
|
16
|
+
export type StatusConfigBuilder = (params: StatusConfigBuilderParams) => Nullable<StatusConfig>;
|
|
17
|
+
export type Config = (ctx: Ctx) => StatusConfigBuilder;
|
|
18
18
|
export declare const defaultActions: (ctx: Ctx, input?: string) => WrappedAction[];
|
|
19
19
|
export declare const defaultConfig: Config;
|
|
20
20
|
export {};
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAG3C,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;AAEvC,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC9B,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,IAAI,CAAA;IAChB,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,QAAQ,CAAC,YAAY,CAAC,CAAA;AAE/F,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,mBAAmB,CAAA;AAEtD,eAAO,MAAM,cAAc,QAAS,GAAG,qBAAgB,aAAa,EAuFnE,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,MAyB3B,CAAA"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AtomList } from '@milkdown/utils';
|
|
2
2
|
import type { Config } from './config';
|
|
3
|
-
import { CalcPosition } from './prose-plugin/view';
|
|
3
|
+
import type { CalcPosition } from './prose-plugin/view';
|
|
4
4
|
export type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';
|
|
5
5
|
export { defaultActions, defaultConfig } from './config';
|
|
6
6
|
export type { Action, WrappedAction } from './item';
|
|
7
7
|
export { createDropdownItem } from './utility';
|
|
8
|
-
export
|
|
8
|
+
export interface Options {
|
|
9
9
|
config: Config;
|
|
10
10
|
calcPosition: CalcPosition;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
export declare const slashPlugin: import("@milkdown/utils").WithExtend<string, Options, import("@milkdown/utils").TypeMapping<string, string>, import("@milkdown/utils").PluginRest<string, string>>;
|
|
13
13
|
export declare const slash: AtomList<import("@milkdown/utils").Metadata<import("@milkdown/utils").GetPlugin<string, Options>> & import("@milkdown/core").MilkdownPlugin>;
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAA;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGvD,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AACpG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE9C,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED,eAAO,MAAM,WAAW,oKAatB,CAAA;AAEF,eAAO,MAAM,KAAK,8IAAmC,CAAA"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createPlugin as b, AtomList as $ } from "@milkdown/utils";
|
|
2
|
-
import { ThemeSize as
|
|
3
|
-
import { missingIcon as
|
|
4
|
-
import { Plugin as
|
|
5
|
-
import { findParentNode as
|
|
6
|
-
import { DecorationSet as
|
|
2
|
+
import { ThemeSize as C, ThemeBorder as E, ThemeShadow as T, ThemeScrollbar as N, ThemeFont as k, ThemeColor as y, ThemeIcon as S, schemaCtx as I, themeManagerCtx as u, commandsCtx as p, editorViewCtx as x } from "@milkdown/core";
|
|
3
|
+
import { missingIcon as A, missingRootElement as D } from "@milkdown/exception";
|
|
4
|
+
import { Plugin as _, PluginKey as M } from "@milkdown/prose/state";
|
|
5
|
+
import { findParentNode as P, calculateNodePosition as H } from "@milkdown/prose";
|
|
6
|
+
import { DecorationSet as q, Decoration as K } from "@milkdown/prose/view";
|
|
7
7
|
import w from "smooth-scroll-into-view-if-needed";
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const O = (e, { css: t }) => {
|
|
9
|
+
const n = (o, s = 1) => e.get(y, [o, s]);
|
|
10
10
|
return t`
|
|
11
11
|
.slash-dropdown-item {
|
|
12
12
|
display: flex;
|
|
@@ -24,7 +24,7 @@ const K = (e, { css: t }) => {
|
|
|
24
24
|
|
|
25
25
|
&,
|
|
26
26
|
.icon {
|
|
27
|
-
color: ${
|
|
27
|
+
color: ${n("neutral", 0.87)};
|
|
28
28
|
transition: all 0.2s ease-in-out;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -33,26 +33,26 @@ const K = (e, { css: t }) => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&.active {
|
|
36
|
-
background: ${
|
|
36
|
+
background: ${n("secondary", 0.12)};
|
|
37
37
|
&,
|
|
38
38
|
.icon {
|
|
39
|
-
color: ${
|
|
39
|
+
color: ${n("primary")};
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
`;
|
|
44
|
-
},
|
|
45
|
-
const
|
|
44
|
+
}, U = (e, t) => {
|
|
45
|
+
const n = (o, s = 1) => e.get(y, [o, s]);
|
|
46
46
|
return t.css`
|
|
47
47
|
width: 320px;
|
|
48
48
|
min-height: 48px;
|
|
49
49
|
max-height: 320px;
|
|
50
50
|
overflow-y: auto;
|
|
51
|
-
border-radius: ${e.get(
|
|
51
|
+
border-radius: ${e.get(C, "radius")};
|
|
52
52
|
position: absolute;
|
|
53
|
-
background: ${
|
|
53
|
+
background: ${n("surface")};
|
|
54
54
|
|
|
55
|
-
${e.get(
|
|
55
|
+
${e.get(E, void 0)}
|
|
56
56
|
${e.get(T, void 0)}
|
|
57
57
|
${e.get(N, void 0)}
|
|
58
58
|
|
|
@@ -60,28 +60,28 @@ const K = (e, { css: t }) => {
|
|
|
60
60
|
display: none;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
${
|
|
63
|
+
${O(e, t)}
|
|
64
64
|
`;
|
|
65
|
-
},
|
|
66
|
-
const
|
|
67
|
-
return
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
}),
|
|
71
|
-
}, f = (e, t,
|
|
65
|
+
}, W = (e, t) => {
|
|
66
|
+
const n = document.createElement("div");
|
|
67
|
+
return n.setAttribute("role", "listbox"), n.setAttribute("tabindex", "-1"), e.themeManager.onFlush(() => {
|
|
68
|
+
const o = e.getStyle((s) => U(e.themeManager, s));
|
|
69
|
+
o && n.classList.add(o);
|
|
70
|
+
}), n.classList.add(e.getClassName({}, t), "hide"), n;
|
|
71
|
+
}, f = (e, t, n, o) => {
|
|
72
72
|
var l;
|
|
73
|
-
const s = (l =
|
|
73
|
+
const s = (l = o == null ? void 0 : o.textClassName) != null ? l : "text", r = document.createElement("div");
|
|
74
74
|
r.setAttribute("role", "option"), r.classList.add("slash-dropdown-item");
|
|
75
|
-
const i = e.get(S,
|
|
75
|
+
const i = e.get(S, n);
|
|
76
76
|
if (!i)
|
|
77
|
-
throw
|
|
77
|
+
throw A(n);
|
|
78
78
|
const a = document.createElement("span");
|
|
79
79
|
return a.textContent = t, a.className = s, r.appendChild(i.dom), r.appendChild(a), r;
|
|
80
|
-
},
|
|
81
|
-
const { selection:
|
|
80
|
+
}, B = (e, t) => {
|
|
81
|
+
const { selection: n } = e, { $from: o } = n, s = e.tr.deleteRange(o.start(), o.pos);
|
|
82
82
|
return t == null || t(s), !1;
|
|
83
|
-
},
|
|
84
|
-
const { nodes:
|
|
83
|
+
}, F = (e) => (t, n, o) => (o && (B(t, n), e()), !0), L = (e, t = "/") => {
|
|
84
|
+
const { nodes: n } = e.get(I), o = [
|
|
85
85
|
{
|
|
86
86
|
id: "h1",
|
|
87
87
|
dom: f(e.get(u), "Large Heading", "h1"),
|
|
@@ -160,92 +160,97 @@ const K = (e, { css: t }) => {
|
|
|
160
160
|
typeName: "hr"
|
|
161
161
|
}
|
|
162
162
|
], s = t.slice(1).toLocaleLowerCase();
|
|
163
|
-
return
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
return o.filter((r) => !!n[r.typeName] && r.keyword.some((i) => i.includes(s))).map(({ keyword: r, typeName: i, ...a }) => a);
|
|
164
|
+
}, j = (e) => ({ content: t, isTopLevel: n }) => {
|
|
165
|
+
if (!n)
|
|
166
|
+
return null;
|
|
167
|
+
const o = e.get(x);
|
|
168
|
+
return o != null && o.editable ? t ? t.startsWith("/") ? t === "/" ? {
|
|
169
|
+
placeholder: "Type to filter...",
|
|
170
|
+
actions: L(e)
|
|
171
|
+
} : {
|
|
172
|
+
actions: L(e, t)
|
|
173
|
+
} : null : { placeholder: "Type / to use the slash commands..." } : null;
|
|
174
|
+
}, z = (e, { css: t }) => {
|
|
175
|
+
const n = (s, r = 1) => e.get(y, [s, r]), o = e.get(k, "typography");
|
|
171
176
|
return t`
|
|
172
177
|
position: relative;
|
|
173
178
|
&::before {
|
|
174
179
|
position: absolute;
|
|
175
180
|
cursor: text;
|
|
176
|
-
font-family: ${
|
|
181
|
+
font-family: ${o};
|
|
177
182
|
font-size: 14px;
|
|
178
|
-
color: ${
|
|
183
|
+
color: ${n("neutral", 0.6)};
|
|
179
184
|
content: attr(data-text);
|
|
180
185
|
height: 100%;
|
|
181
186
|
display: flex;
|
|
182
187
|
align-items: center;
|
|
183
188
|
}
|
|
184
189
|
`;
|
|
185
|
-
},
|
|
190
|
+
}, V = (e, { css: t }) => t`
|
|
186
191
|
&::before {
|
|
187
192
|
left: 8px;
|
|
188
193
|
}
|
|
189
194
|
`, R = (e, t) => ({
|
|
190
|
-
handleKeyDown: (
|
|
191
|
-
decorations: (
|
|
192
|
-
const
|
|
195
|
+
handleKeyDown: (n, o) => !(e.isEmpty() || !(o instanceof KeyboardEvent) || !["ArrowUp", "ArrowDown", "Enter"].includes(o.key)),
|
|
196
|
+
decorations: (n) => {
|
|
197
|
+
const o = P(({ type: d }) => d.name === "paragraph")(n.selection), s = n.plugins.find(
|
|
193
198
|
(d) => d.key === "MILKDOWN_UPLOAD$"
|
|
194
|
-
), r = s == null ? void 0 : s.getState(
|
|
195
|
-
if (r != null && r.find(
|
|
199
|
+
), r = s == null ? void 0 : s.getState(n);
|
|
200
|
+
if (r != null && r.find(n.selection.from, n.selection.to).length > 0 || !o || o.node.childCount > 1 || n.selection.$from.parentOffset !== o.node.textContent.length || o.node.firstChild && o.node.firstChild.type.name !== "text")
|
|
196
201
|
return e.clear(), null;
|
|
197
202
|
const { placeholder: i, actions: a } = e.update({
|
|
198
|
-
parentNode:
|
|
199
|
-
isTopLevel:
|
|
200
|
-
content:
|
|
201
|
-
state:
|
|
203
|
+
parentNode: n.selection.$from.node(n.selection.$from.depth - 1),
|
|
204
|
+
isTopLevel: n.selection.$from.depth === 1,
|
|
205
|
+
content: o.node.textContent,
|
|
206
|
+
state: n
|
|
202
207
|
});
|
|
203
208
|
if (!i)
|
|
204
209
|
return null;
|
|
205
210
|
const l = (d, h) => {
|
|
206
|
-
const g =
|
|
207
|
-
return
|
|
208
|
-
|
|
211
|
+
const g = o.pos;
|
|
212
|
+
return q.create(n.doc, [
|
|
213
|
+
K.node(g, g + o.node.nodeSize, {
|
|
209
214
|
class: h.filter((v) => v).join(" "),
|
|
210
215
|
"data-text": d
|
|
211
216
|
})
|
|
212
217
|
]);
|
|
213
|
-
}, m = t.getStyle((d) =>
|
|
218
|
+
}, m = t.getStyle((d) => z(t.themeManager, d)), c = t.getStyle((d) => V(t.themeManager, d));
|
|
214
219
|
return a.length ? l(i, [m, c, "empty-node", "is-slash"]) : l(i, [m, "empty-node"]);
|
|
215
220
|
}
|
|
216
|
-
}),
|
|
221
|
+
}), Q = (e) => ({
|
|
217
222
|
id: e.id,
|
|
218
223
|
$: e.dom,
|
|
219
|
-
command:
|
|
220
|
-
}),
|
|
224
|
+
command: F(e.command)
|
|
225
|
+
}), G = () => ({
|
|
221
226
|
placeholder: null,
|
|
222
227
|
actions: []
|
|
223
|
-
}),
|
|
224
|
-
const t =
|
|
228
|
+
}), J = (e) => {
|
|
229
|
+
const t = G();
|
|
225
230
|
return {
|
|
226
231
|
get: () => t,
|
|
227
232
|
clear: () => {
|
|
228
233
|
t.placeholder = null, t.actions = [];
|
|
229
234
|
},
|
|
230
|
-
update: (
|
|
235
|
+
update: (n) => {
|
|
231
236
|
var s, r;
|
|
232
|
-
const
|
|
233
|
-
return t.placeholder = (s =
|
|
237
|
+
const o = e(n);
|
|
238
|
+
return t.placeholder = (s = o == null ? void 0 : o.placeholder) != null ? s : null, t.actions = ((r = o == null ? void 0 : o.actions) != null ? r : []).map(Q), t;
|
|
234
239
|
},
|
|
235
240
|
isEmpty: () => t.actions.length === 0
|
|
236
241
|
};
|
|
237
|
-
},
|
|
238
|
-
const { actions:
|
|
239
|
-
if (!
|
|
242
|
+
}, X = (e, t, n) => {
|
|
243
|
+
const { actions: o } = e.get();
|
|
244
|
+
if (!o.length)
|
|
240
245
|
return t.classList.add("hide"), !1;
|
|
241
246
|
for (t.childNodes.forEach((r) => {
|
|
242
|
-
r.removeEventListener("mouseenter",
|
|
247
|
+
r.removeEventListener("mouseenter", n.mouseEnter), r.removeEventListener("mouseleave", n.mouseLeave);
|
|
243
248
|
}); t.firstChild; )
|
|
244
249
|
t.firstChild.remove();
|
|
245
|
-
|
|
246
|
-
r.classList.remove("active"), r.addEventListener("mouseenter",
|
|
250
|
+
o.forEach(({ $: r }) => {
|
|
251
|
+
r.classList.remove("active"), r.addEventListener("mouseenter", n.mouseEnter), r.addEventListener("mouseleave", n.mouseLeave), t.appendChild(r);
|
|
247
252
|
}), t.style.maxHeight = "", t.classList.remove("hide");
|
|
248
|
-
const s =
|
|
253
|
+
const s = o[0];
|
|
249
254
|
return s && (s.$.classList.add("active"), requestAnimationFrame(() => {
|
|
250
255
|
w(s.$, {
|
|
251
256
|
scrollMode: "if-needed",
|
|
@@ -253,7 +258,7 @@ const K = (e, { css: t }) => {
|
|
|
253
258
|
inline: "nearest"
|
|
254
259
|
});
|
|
255
260
|
})), !0;
|
|
256
|
-
},
|
|
261
|
+
}, Y = () => {
|
|
257
262
|
let e = !1;
|
|
258
263
|
return {
|
|
259
264
|
isLock: () => e,
|
|
@@ -264,36 +269,36 @@ const K = (e, { css: t }) => {
|
|
|
264
269
|
e = !1;
|
|
265
270
|
}
|
|
266
271
|
};
|
|
267
|
-
},
|
|
272
|
+
}, Z = (e) => () => {
|
|
268
273
|
e.unlock();
|
|
269
|
-
},
|
|
274
|
+
}, ee = (e, t) => (n) => {
|
|
270
275
|
if (t.isLock())
|
|
271
276
|
return;
|
|
272
|
-
const { actions:
|
|
277
|
+
const { actions: o } = e.get(), s = o.findIndex((a) => a.$.classList.contains("active")), r = o[s];
|
|
273
278
|
r && s >= 0 && r.$.classList.remove("active");
|
|
274
|
-
const { target: i } =
|
|
279
|
+
const { target: i } = n;
|
|
275
280
|
i instanceof HTMLElement && i.classList.add("active");
|
|
276
|
-
},
|
|
281
|
+
}, te = () => (e) => {
|
|
277
282
|
const { target: t } = e;
|
|
278
283
|
t instanceof HTMLElement && t.classList.remove("active");
|
|
279
|
-
},
|
|
280
|
-
const { target: s } =
|
|
284
|
+
}, oe = (e, t, n) => (o) => {
|
|
285
|
+
const { target: s } = o;
|
|
281
286
|
if (!(s instanceof HTMLElement) || !t)
|
|
282
287
|
return;
|
|
283
288
|
const r = () => {
|
|
284
|
-
|
|
289
|
+
o.stopPropagation(), o.preventDefault();
|
|
285
290
|
}, { actions: i } = e.get(), a = Object.values(i).find(({ $: l }) => l.contains(s));
|
|
286
291
|
if (!a) {
|
|
287
292
|
if (e.isEmpty())
|
|
288
293
|
return;
|
|
289
|
-
e.clear(),
|
|
294
|
+
e.clear(), n.classList.add("hide"), r();
|
|
290
295
|
return;
|
|
291
296
|
}
|
|
292
297
|
r(), a.command(t.state, t.dispatch, t);
|
|
293
|
-
},
|
|
298
|
+
}, ne = (e, t, n, o) => (s) => {
|
|
294
299
|
if (!(s instanceof KeyboardEvent))
|
|
295
300
|
return;
|
|
296
|
-
|
|
301
|
+
o.isLock() || o.lock();
|
|
297
302
|
const { key: r } = s;
|
|
298
303
|
if (e.isEmpty() || !["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(r))
|
|
299
304
|
return;
|
|
@@ -321,34 +326,34 @@ const K = (e, { css: t }) => {
|
|
|
321
326
|
if (r === "Escape") {
|
|
322
327
|
if (e.isEmpty())
|
|
323
328
|
return;
|
|
324
|
-
e.clear(),
|
|
329
|
+
e.clear(), n.classList.add("hide");
|
|
325
330
|
return;
|
|
326
331
|
}
|
|
327
332
|
const m = i[a];
|
|
328
333
|
!m || (m.command(t.state, t.dispatch, t), m.$.classList.remove("active"));
|
|
329
|
-
},
|
|
330
|
-
|
|
334
|
+
}, re = (e, t) => {
|
|
335
|
+
H(e, t, (n, o, s) => {
|
|
331
336
|
const r = t.parentElement;
|
|
332
337
|
if (!r)
|
|
333
|
-
throw
|
|
334
|
-
let i =
|
|
338
|
+
throw D();
|
|
339
|
+
let i = n.left - s.left;
|
|
335
340
|
i < 0 && (i = 0);
|
|
336
341
|
let a, l;
|
|
337
|
-
const m =
|
|
338
|
-
c >=
|
|
339
|
-
const d = a === "top" ?
|
|
342
|
+
const m = n.top - s.top, c = s.height + s.top - n.bottom;
|
|
343
|
+
c >= o.height + 28 ? a = "bottom" : m >= o.height + 28 ? a = "top" : c >= m ? (a = "bottom", l = c - 28) : (a = "top", l = m - 28), (m < 0 || c < 0) && (l = s.height - n.height - 28, l > o.height && (l = void 0));
|
|
344
|
+
const d = a === "top" ? n.top - s.top - (l != null ? l : o.height) - 14 + r.scrollTop : n.bottom - s.top + 14 + r.scrollTop;
|
|
340
345
|
return t.style.maxHeight = l !== void 0 && l > 0 ? `${l}px` : "", [d, i];
|
|
341
346
|
});
|
|
342
|
-
},
|
|
347
|
+
}, se = (e, t, n, o, s) => {
|
|
343
348
|
const r = t.dom.parentNode;
|
|
344
349
|
if (!r)
|
|
345
350
|
return {};
|
|
346
|
-
const i =
|
|
351
|
+
const i = W(n, o), a = Y();
|
|
347
352
|
r.appendChild(i);
|
|
348
|
-
const l =
|
|
353
|
+
const l = Z(a), m = oe(e, t, i), c = ne(e, t, i, a), d = ee(e, a), h = te();
|
|
349
354
|
return r.addEventListener("mousemove", l), r.addEventListener("mousedown", m), r.addEventListener("keydown", c), {
|
|
350
355
|
update: (g) => {
|
|
351
|
-
!
|
|
356
|
+
!X(e, i, {
|
|
352
357
|
mouseEnter: d,
|
|
353
358
|
mouseLeave: h
|
|
354
359
|
}) || s(g, i);
|
|
@@ -357,28 +362,28 @@ const K = (e, { css: t }) => {
|
|
|
357
362
|
r.removeEventListener("mousemove", l), r.removeEventListener("mousedown", m), r.removeEventListener("keydown", c), i.remove();
|
|
358
363
|
}
|
|
359
364
|
};
|
|
360
|
-
},
|
|
361
|
-
const s =
|
|
362
|
-
return new
|
|
363
|
-
key: new
|
|
365
|
+
}, ie = "MILKDOWN_SLASH", ae = (e, t, n, o) => {
|
|
366
|
+
const s = J(t);
|
|
367
|
+
return new _({
|
|
368
|
+
key: new M(ie),
|
|
364
369
|
props: R(s, e),
|
|
365
|
-
view: (r) =>
|
|
370
|
+
view: (r) => se(s, r, e, n, o)
|
|
366
371
|
});
|
|
367
|
-
},
|
|
372
|
+
}, le = b((e, t) => {
|
|
368
373
|
var s, r;
|
|
369
|
-
const
|
|
374
|
+
const n = (s = t == null ? void 0 : t.config) != null ? s : j, o = (r = t == null ? void 0 : t.calcPosition) != null ? r : re;
|
|
370
375
|
return {
|
|
371
376
|
prosePlugins: (i, a) => {
|
|
372
|
-
const l =
|
|
373
|
-
return [
|
|
377
|
+
const l = n(a);
|
|
378
|
+
return [ae(e, l, "slash-dropdown", o)];
|
|
374
379
|
}
|
|
375
380
|
};
|
|
376
|
-
}),
|
|
381
|
+
}), ge = $.create([le()]);
|
|
377
382
|
export {
|
|
378
383
|
f as createDropdownItem,
|
|
379
384
|
L as defaultActions,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
385
|
+
j as defaultConfig,
|
|
386
|
+
ge as slash,
|
|
387
|
+
le as slashPlugin
|
|
383
388
|
};
|
|
384
389
|
//# sourceMappingURL=index.es.js.map
|