@milkdown/plugin-slash 6.5.0 → 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 +170 -161
- 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 -45
- 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 -80
- package/src/style.ts +21 -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
|
-
import { createPlugin as b, AtomList as
|
|
2
|
-
import { ThemeSize as
|
|
1
|
+
import { createPlugin as b, AtomList as $ } from "@milkdown/utils";
|
|
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
3
|
import { missingIcon as A, missingRootElement as D } from "@milkdown/exception";
|
|
4
|
-
import { Plugin as
|
|
5
|
-
import { findParentNode as
|
|
6
|
-
import { DecorationSet as
|
|
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 q = (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,216 +33,224 @@ const q = (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
|
+
min-height: 48px;
|
|
48
49
|
max-height: 320px;
|
|
49
50
|
overflow-y: auto;
|
|
50
|
-
border-radius: ${e.get(
|
|
51
|
+
border-radius: ${e.get(C, "radius")};
|
|
51
52
|
position: absolute;
|
|
52
|
-
background: ${
|
|
53
|
+
background: ${n("surface")};
|
|
53
54
|
|
|
54
|
-
${e.get(
|
|
55
|
+
${e.get(E, void 0)}
|
|
56
|
+
${e.get(T, void 0)}
|
|
55
57
|
${e.get(N, void 0)}
|
|
56
|
-
${e.get(S, void 0)}
|
|
57
58
|
|
|
58
59
|
&.hide {
|
|
59
60
|
display: none;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
${
|
|
63
|
+
${O(e, t)}
|
|
63
64
|
`;
|
|
64
|
-
},
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
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) => {
|
|
71
72
|
var l;
|
|
72
|
-
const s = (l =
|
|
73
|
+
const s = (l = o == null ? void 0 : o.textClassName) != null ? l : "text", r = document.createElement("div");
|
|
73
74
|
r.setAttribute("role", "option"), r.classList.add("slash-dropdown-item");
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
76
|
-
throw A(
|
|
77
|
-
const
|
|
78
|
-
return
|
|
79
|
-
},
|
|
80
|
-
const { selection:
|
|
75
|
+
const i = e.get(S, n);
|
|
76
|
+
if (!i)
|
|
77
|
+
throw A(n);
|
|
78
|
+
const a = document.createElement("span");
|
|
79
|
+
return a.textContent = t, a.className = s, r.appendChild(i.dom), r.appendChild(a), r;
|
|
80
|
+
}, B = (e, t) => {
|
|
81
|
+
const { selection: n } = e, { $from: o } = n, s = e.tr.deleteRange(o.start(), o.pos);
|
|
81
82
|
return t == null || t(s), !1;
|
|
82
|
-
}, F = (e) => (t,
|
|
83
|
-
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 = [
|
|
84
85
|
{
|
|
85
86
|
id: "h1",
|
|
86
|
-
dom:
|
|
87
|
-
command: () => e.get(
|
|
87
|
+
dom: f(e.get(u), "Large Heading", "h1"),
|
|
88
|
+
command: () => e.get(p).call("TurnIntoHeading", 1),
|
|
88
89
|
keyword: ["h1", "large heading"],
|
|
89
90
|
typeName: "heading"
|
|
90
91
|
},
|
|
91
92
|
{
|
|
92
93
|
id: "h2",
|
|
93
|
-
dom:
|
|
94
|
-
command: () => e.get(
|
|
94
|
+
dom: f(e.get(u), "Medium Heading", "h2"),
|
|
95
|
+
command: () => e.get(p).call("TurnIntoHeading", 2),
|
|
95
96
|
keyword: ["h2", "medium heading"],
|
|
96
97
|
typeName: "heading"
|
|
97
98
|
},
|
|
98
99
|
{
|
|
99
100
|
id: "h3",
|
|
100
|
-
dom:
|
|
101
|
-
command: () => e.get(
|
|
101
|
+
dom: f(e.get(u), "Small Heading", "h3"),
|
|
102
|
+
command: () => e.get(p).call("TurnIntoHeading", 3),
|
|
102
103
|
keyword: ["h3", "small heading"],
|
|
103
104
|
typeName: "heading"
|
|
104
105
|
},
|
|
105
106
|
{
|
|
106
107
|
id: "bulletList",
|
|
107
|
-
dom:
|
|
108
|
-
command: () => e.get(
|
|
108
|
+
dom: f(e.get(u), "Bullet List", "bulletList"),
|
|
109
|
+
command: () => e.get(p).call("WrapInBulletList"),
|
|
109
110
|
keyword: ["bullet list", "ul"],
|
|
110
111
|
typeName: "bullet_list"
|
|
111
112
|
},
|
|
112
113
|
{
|
|
113
114
|
id: "orderedList",
|
|
114
|
-
dom:
|
|
115
|
-
command: () => e.get(
|
|
115
|
+
dom: f(e.get(u), "Ordered List", "orderedList"),
|
|
116
|
+
command: () => e.get(p).call("WrapInOrderedList"),
|
|
116
117
|
keyword: ["ordered list", "ol"],
|
|
117
118
|
typeName: "ordered_list"
|
|
118
119
|
},
|
|
119
120
|
{
|
|
120
121
|
id: "taskList",
|
|
121
|
-
dom:
|
|
122
|
-
command: () => e.get(
|
|
122
|
+
dom: f(e.get(u), "Task List", "taskList"),
|
|
123
|
+
command: () => e.get(p).call("TurnIntoTaskList"),
|
|
123
124
|
keyword: ["task list", "task"],
|
|
124
125
|
typeName: "task_list_item"
|
|
125
126
|
},
|
|
126
127
|
{
|
|
127
128
|
id: "image",
|
|
128
|
-
dom:
|
|
129
|
-
command: () => e.get(
|
|
129
|
+
dom: f(e.get(u), "Image", "image"),
|
|
130
|
+
command: () => e.get(p).call("InsertImage"),
|
|
130
131
|
keyword: ["image"],
|
|
131
132
|
typeName: "image"
|
|
132
133
|
},
|
|
133
134
|
{
|
|
134
135
|
id: "blockquote",
|
|
135
|
-
dom:
|
|
136
|
-
command: () => e.get(
|
|
136
|
+
dom: f(e.get(u), "Quote", "quote"),
|
|
137
|
+
command: () => e.get(p).call("WrapInBlockquote"),
|
|
137
138
|
keyword: ["quote", "blockquote"],
|
|
138
139
|
typeName: "blockquote"
|
|
139
140
|
},
|
|
140
141
|
{
|
|
141
142
|
id: "table",
|
|
142
|
-
dom:
|
|
143
|
-
command: () => e.get(
|
|
143
|
+
dom: f(e.get(u), "Table", "table"),
|
|
144
|
+
command: () => e.get(p).call("InsertTable"),
|
|
144
145
|
keyword: ["table"],
|
|
145
146
|
typeName: "table"
|
|
146
147
|
},
|
|
147
148
|
{
|
|
148
149
|
id: "code",
|
|
149
|
-
dom:
|
|
150
|
-
command: () => e.get(
|
|
150
|
+
dom: f(e.get(u), "Code Fence", "code"),
|
|
151
|
+
command: () => e.get(p).call("TurnIntoCodeFence"),
|
|
151
152
|
keyword: ["code"],
|
|
152
153
|
typeName: "fence"
|
|
153
154
|
},
|
|
154
155
|
{
|
|
155
156
|
id: "divider",
|
|
156
|
-
dom:
|
|
157
|
-
command: () => e.get(
|
|
157
|
+
dom: f(e.get(u), "Divide Line", "divider"),
|
|
158
|
+
command: () => e.get(p).call("InsertHr"),
|
|
158
159
|
keyword: ["divider", "hr"],
|
|
159
160
|
typeName: "hr"
|
|
160
161
|
}
|
|
161
162
|
], s = t.slice(1).toLocaleLowerCase();
|
|
162
|
-
return
|
|
163
|
-
}, j = (e) => ({ content: t, isTopLevel:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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");
|
|
170
176
|
return t`
|
|
171
177
|
position: relative;
|
|
172
178
|
&::before {
|
|
173
179
|
position: absolute;
|
|
174
180
|
cursor: text;
|
|
175
|
-
font-family: ${
|
|
181
|
+
font-family: ${o};
|
|
176
182
|
font-size: 14px;
|
|
177
|
-
color: ${
|
|
183
|
+
color: ${n("neutral", 0.6)};
|
|
178
184
|
content: attr(data-text);
|
|
179
185
|
height: 100%;
|
|
180
186
|
display: flex;
|
|
181
187
|
align-items: center;
|
|
182
188
|
}
|
|
183
189
|
`;
|
|
184
|
-
},
|
|
190
|
+
}, V = (e, { css: t }) => t`
|
|
185
191
|
&::before {
|
|
186
192
|
left: 8px;
|
|
187
193
|
}
|
|
188
194
|
`, R = (e, t) => ({
|
|
189
|
-
handleKeyDown: (
|
|
190
|
-
decorations: (
|
|
191
|
-
const
|
|
192
|
-
|
|
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(
|
|
198
|
+
(d) => d.key === "MILKDOWN_UPLOAD$"
|
|
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")
|
|
193
201
|
return e.clear(), null;
|
|
194
|
-
const { placeholder:
|
|
195
|
-
parentNode:
|
|
196
|
-
isTopLevel:
|
|
197
|
-
content:
|
|
198
|
-
state:
|
|
202
|
+
const { placeholder: i, actions: a } = e.update({
|
|
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
|
|
199
207
|
});
|
|
200
|
-
if (!
|
|
208
|
+
if (!i)
|
|
201
209
|
return null;
|
|
202
|
-
const l = (
|
|
203
|
-
const
|
|
204
|
-
return
|
|
205
|
-
|
|
206
|
-
class:
|
|
207
|
-
"data-text":
|
|
210
|
+
const l = (d, h) => {
|
|
211
|
+
const g = o.pos;
|
|
212
|
+
return q.create(n.doc, [
|
|
213
|
+
K.node(g, g + o.node.nodeSize, {
|
|
214
|
+
class: h.filter((v) => v).join(" "),
|
|
215
|
+
"data-text": d
|
|
208
216
|
})
|
|
209
217
|
]);
|
|
210
|
-
},
|
|
211
|
-
return
|
|
218
|
+
}, m = t.getStyle((d) => z(t.themeManager, d)), c = t.getStyle((d) => V(t.themeManager, d));
|
|
219
|
+
return a.length ? l(i, [m, c, "empty-node", "is-slash"]) : l(i, [m, "empty-node"]);
|
|
212
220
|
}
|
|
213
|
-
}),
|
|
221
|
+
}), Q = (e) => ({
|
|
214
222
|
id: e.id,
|
|
215
223
|
$: e.dom,
|
|
216
224
|
command: F(e.command)
|
|
217
|
-
}),
|
|
225
|
+
}), G = () => ({
|
|
218
226
|
placeholder: null,
|
|
219
227
|
actions: []
|
|
220
|
-
}),
|
|
221
|
-
const t =
|
|
228
|
+
}), J = (e) => {
|
|
229
|
+
const t = G();
|
|
222
230
|
return {
|
|
223
231
|
get: () => t,
|
|
224
232
|
clear: () => {
|
|
225
233
|
t.placeholder = null, t.actions = [];
|
|
226
234
|
},
|
|
227
|
-
update: (
|
|
235
|
+
update: (n) => {
|
|
228
236
|
var s, r;
|
|
229
|
-
const
|
|
230
|
-
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;
|
|
231
239
|
},
|
|
232
240
|
isEmpty: () => t.actions.length === 0
|
|
233
241
|
};
|
|
234
|
-
},
|
|
235
|
-
const { actions:
|
|
236
|
-
if (!
|
|
242
|
+
}, X = (e, t, n) => {
|
|
243
|
+
const { actions: o } = e.get();
|
|
244
|
+
if (!o.length)
|
|
237
245
|
return t.classList.add("hide"), !1;
|
|
238
246
|
for (t.childNodes.forEach((r) => {
|
|
239
|
-
r.removeEventListener("mouseenter",
|
|
247
|
+
r.removeEventListener("mouseenter", n.mouseEnter), r.removeEventListener("mouseleave", n.mouseLeave);
|
|
240
248
|
}); t.firstChild; )
|
|
241
249
|
t.firstChild.remove();
|
|
242
|
-
|
|
243
|
-
r.classList.remove("active"), r.addEventListener("mouseenter",
|
|
244
|
-
}), t.classList.remove("hide");
|
|
245
|
-
const s =
|
|
250
|
+
o.forEach(({ $: r }) => {
|
|
251
|
+
r.classList.remove("active"), r.addEventListener("mouseenter", n.mouseEnter), r.addEventListener("mouseleave", n.mouseLeave), t.appendChild(r);
|
|
252
|
+
}), t.style.maxHeight = "", t.classList.remove("hide");
|
|
253
|
+
const s = o[0];
|
|
246
254
|
return s && (s.$.classList.add("active"), requestAnimationFrame(() => {
|
|
247
255
|
w(s.$, {
|
|
248
256
|
scrollMode: "if-needed",
|
|
@@ -250,7 +258,7 @@ const q = (e, { css: t }) => {
|
|
|
250
258
|
inline: "nearest"
|
|
251
259
|
});
|
|
252
260
|
})), !0;
|
|
253
|
-
},
|
|
261
|
+
}, Y = () => {
|
|
254
262
|
let e = !1;
|
|
255
263
|
return {
|
|
256
264
|
isLock: () => e,
|
|
@@ -261,120 +269,121 @@ const q = (e, { css: t }) => {
|
|
|
261
269
|
e = !1;
|
|
262
270
|
}
|
|
263
271
|
};
|
|
264
|
-
},
|
|
272
|
+
}, Z = (e) => () => {
|
|
265
273
|
e.unlock();
|
|
266
|
-
},
|
|
274
|
+
}, ee = (e, t) => (n) => {
|
|
267
275
|
if (t.isLock())
|
|
268
276
|
return;
|
|
269
|
-
const { actions:
|
|
277
|
+
const { actions: o } = e.get(), s = o.findIndex((a) => a.$.classList.contains("active")), r = o[s];
|
|
270
278
|
r && s >= 0 && r.$.classList.remove("active");
|
|
271
|
-
const { target:
|
|
272
|
-
|
|
273
|
-
},
|
|
279
|
+
const { target: i } = n;
|
|
280
|
+
i instanceof HTMLElement && i.classList.add("active");
|
|
281
|
+
}, te = () => (e) => {
|
|
274
282
|
const { target: t } = e;
|
|
275
283
|
t instanceof HTMLElement && t.classList.remove("active");
|
|
276
|
-
},
|
|
277
|
-
const { target: s } =
|
|
284
|
+
}, oe = (e, t, n) => (o) => {
|
|
285
|
+
const { target: s } = o;
|
|
278
286
|
if (!(s instanceof HTMLElement) || !t)
|
|
279
287
|
return;
|
|
280
288
|
const r = () => {
|
|
281
|
-
|
|
282
|
-
}, { actions:
|
|
283
|
-
if (!
|
|
289
|
+
o.stopPropagation(), o.preventDefault();
|
|
290
|
+
}, { actions: i } = e.get(), a = Object.values(i).find(({ $: l }) => l.contains(s));
|
|
291
|
+
if (!a) {
|
|
284
292
|
if (e.isEmpty())
|
|
285
293
|
return;
|
|
286
|
-
e.clear(),
|
|
294
|
+
e.clear(), n.classList.add("hide"), r();
|
|
287
295
|
return;
|
|
288
296
|
}
|
|
289
|
-
r(),
|
|
290
|
-
},
|
|
297
|
+
r(), a.command(t.state, t.dispatch, t);
|
|
298
|
+
}, ne = (e, t, n, o) => (s) => {
|
|
291
299
|
if (!(s instanceof KeyboardEvent))
|
|
292
300
|
return;
|
|
293
|
-
|
|
301
|
+
o.isLock() || o.lock();
|
|
294
302
|
const { key: r } = s;
|
|
295
303
|
if (e.isEmpty() || !["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(r))
|
|
296
304
|
return;
|
|
297
|
-
const { actions:
|
|
298
|
-
let
|
|
299
|
-
|
|
300
|
-
const l = (
|
|
301
|
-
const
|
|
302
|
-
!
|
|
305
|
+
const { actions: i } = e.get();
|
|
306
|
+
let a = i.findIndex(({ $: c }) => c.classList.contains("active"));
|
|
307
|
+
a < 0 && (a = 0);
|
|
308
|
+
const l = (c) => {
|
|
309
|
+
const d = i[a], h = i[c];
|
|
310
|
+
!d || !h || (d.$.classList.remove("active"), h.$.classList.add("active"), w(h.$, {
|
|
303
311
|
scrollMode: "if-needed",
|
|
304
312
|
block: "nearest",
|
|
305
313
|
inline: "nearest"
|
|
306
314
|
}));
|
|
307
315
|
};
|
|
308
316
|
if (r === "ArrowDown") {
|
|
309
|
-
const
|
|
310
|
-
l(
|
|
317
|
+
const c = a === i.length - 1 ? 0 : a + 1;
|
|
318
|
+
l(c);
|
|
311
319
|
return;
|
|
312
320
|
}
|
|
313
321
|
if (r === "ArrowUp") {
|
|
314
|
-
const
|
|
315
|
-
l(
|
|
322
|
+
const c = a === 0 ? i.length - 1 : a - 1;
|
|
323
|
+
l(c);
|
|
316
324
|
return;
|
|
317
325
|
}
|
|
318
326
|
if (r === "Escape") {
|
|
319
327
|
if (e.isEmpty())
|
|
320
328
|
return;
|
|
321
|
-
e.clear(),
|
|
329
|
+
e.clear(), n.classList.add("hide");
|
|
322
330
|
return;
|
|
323
331
|
}
|
|
324
|
-
const
|
|
325
|
-
!
|
|
326
|
-
},
|
|
327
|
-
|
|
332
|
+
const m = i[a];
|
|
333
|
+
!m || (m.command(t.state, t.dispatch, t), m.$.classList.remove("active"));
|
|
334
|
+
}, re = (e, t) => {
|
|
335
|
+
H(e, t, (n, o, s) => {
|
|
328
336
|
const r = t.parentElement;
|
|
329
337
|
if (!r)
|
|
330
338
|
throw D();
|
|
331
|
-
let
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
339
|
+
let i = n.left - s.left;
|
|
340
|
+
i < 0 && (i = 0);
|
|
341
|
+
let a, l;
|
|
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;
|
|
345
|
+
return t.style.maxHeight = l !== void 0 && l > 0 ? `${l}px` : "", [d, i];
|
|
337
346
|
});
|
|
338
|
-
},
|
|
347
|
+
}, se = (e, t, n, o, s) => {
|
|
339
348
|
const r = t.dom.parentNode;
|
|
340
349
|
if (!r)
|
|
341
350
|
return {};
|
|
342
|
-
const
|
|
343
|
-
r.appendChild(
|
|
344
|
-
const l =
|
|
345
|
-
return r.addEventListener("mousemove", l), r.addEventListener("mousedown",
|
|
346
|
-
update: (
|
|
347
|
-
!
|
|
348
|
-
mouseEnter:
|
|
349
|
-
mouseLeave:
|
|
350
|
-
}) || s(
|
|
351
|
+
const i = W(n, o), a = Y();
|
|
352
|
+
r.appendChild(i);
|
|
353
|
+
const l = Z(a), m = oe(e, t, i), c = ne(e, t, i, a), d = ee(e, a), h = te();
|
|
354
|
+
return r.addEventListener("mousemove", l), r.addEventListener("mousedown", m), r.addEventListener("keydown", c), {
|
|
355
|
+
update: (g) => {
|
|
356
|
+
!X(e, i, {
|
|
357
|
+
mouseEnter: d,
|
|
358
|
+
mouseLeave: h
|
|
359
|
+
}) || s(g, i);
|
|
351
360
|
},
|
|
352
361
|
destroy: () => {
|
|
353
|
-
r.removeEventListener("mousemove", l), r.removeEventListener("mousedown",
|
|
362
|
+
r.removeEventListener("mousemove", l), r.removeEventListener("mousedown", m), r.removeEventListener("keydown", c), i.remove();
|
|
354
363
|
}
|
|
355
364
|
};
|
|
356
|
-
},
|
|
357
|
-
const s =
|
|
358
|
-
return new
|
|
359
|
-
key: new
|
|
365
|
+
}, ie = "MILKDOWN_SLASH", ae = (e, t, n, o) => {
|
|
366
|
+
const s = J(t);
|
|
367
|
+
return new _({
|
|
368
|
+
key: new M(ie),
|
|
360
369
|
props: R(s, e),
|
|
361
|
-
view: (r) =>
|
|
370
|
+
view: (r) => se(s, r, e, n, o)
|
|
362
371
|
});
|
|
363
|
-
},
|
|
372
|
+
}, le = b((e, t) => {
|
|
364
373
|
var s, r;
|
|
365
|
-
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;
|
|
366
375
|
return {
|
|
367
|
-
prosePlugins: (
|
|
368
|
-
const l =
|
|
369
|
-
return [ae(e, l, "slash-dropdown",
|
|
376
|
+
prosePlugins: (i, a) => {
|
|
377
|
+
const l = n(a);
|
|
378
|
+
return [ae(e, l, "slash-dropdown", o)];
|
|
370
379
|
}
|
|
371
380
|
};
|
|
372
|
-
}), ge =
|
|
381
|
+
}), ge = $.create([le()]);
|
|
373
382
|
export {
|
|
374
|
-
|
|
383
|
+
f as createDropdownItem,
|
|
375
384
|
L as defaultActions,
|
|
376
385
|
j as defaultConfig,
|
|
377
386
|
ge as slash,
|
|
378
|
-
|
|
387
|
+
le as slashPlugin
|
|
379
388
|
};
|
|
380
389
|
//# sourceMappingURL=index.es.js.map
|