@milkdown/plugin-slash 6.1.5 → 6.3.1
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/index.d.ts +1 -15
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +238 -408
- package/lib/index.es.js.map +1 -1
- package/lib/item.d.ts +1 -1
- package/lib/item.d.ts.map +1 -1
- package/lib/prose-plugin/index.d.ts +1 -1
- package/lib/prose-plugin/index.d.ts.map +1 -1
- package/lib/prose-plugin/props.d.ts +1 -1
- package/lib/prose-plugin/view.d.ts.map +1 -1
- package/lib/utility.d.ts +2 -2
- package/lib/utility.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/item.ts +1 -1
- package/src/prose-plugin/props.ts +4 -4
- package/src/prose-plugin/view.ts +2 -1
- package/src/style.ts +7 -7
- package/src/utility.ts +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -7,20 +7,6 @@ export { createDropdownItem } from './utility';
|
|
|
7
7
|
export declare type Options = {
|
|
8
8
|
config: Config;
|
|
9
9
|
};
|
|
10
|
-
export declare const slashPlugin: import("@milkdown/utils").WithExtend<string, Options,
|
|
11
|
-
[x: string]: import("@milkdown/prose/model").NodeType<any>;
|
|
12
|
-
} & {
|
|
13
|
-
[x: string]: import("@milkdown/prose/model").MarkType<any>;
|
|
14
|
-
}, {
|
|
15
|
-
schema?: ((ctx: import("@milkdown/core").Ctx) => {
|
|
16
|
-
node?: Record<string, import("@milkdown/core").NodeSchema> | undefined;
|
|
17
|
-
mark?: Record<string, import("@milkdown/core").MarkSchema> | undefined;
|
|
18
|
-
}) | undefined;
|
|
19
|
-
view?: ((ctx: import("@milkdown/core").Ctx) => Partial<{
|
|
20
|
-
[x: string]: import("@milkdown/prose").NodeViewFactory;
|
|
21
|
-
} & {
|
|
22
|
-
[x: string]: import("@milkdown/prose").MarkViewFactory;
|
|
23
|
-
}>) | undefined;
|
|
24
|
-
}>;
|
|
10
|
+
export declare const slashPlugin: import("@milkdown/utils").WithExtend<string, Options, import("@milkdown/utils").TypeMapping<string, string>, import("@milkdown/utils").PluginRest<string, string>>;
|
|
25
11
|
export declare const slash: AtomList<import("@milkdown/utils").Metadata<import("@milkdown/utils").GetPlugin<string, Options>> & import("@milkdown/core").MilkdownPlugin>;
|
|
26
12
|
//# 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,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,oBAAY,OAAO,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,oBAAY,OAAO,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW,oKAYtB,CAAC;AAEH,eAAO,MAAM,KAAK,8IAAmC,CAAC"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
-
target[prop] = source[prop];
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
import { createPlugin, AtomList } from "@milkdown/utils";
|
|
17
|
-
import { ThemeSize, ThemeBorder, ThemeShadow, ThemeScrollbar, ThemeFont, ThemeColor, ThemeIcon, schemaCtx, themeManagerCtx, commandsCtx } from "@milkdown/core";
|
|
18
|
-
import { Plugin, PluginKey } from "@milkdown/prose/state";
|
|
19
|
-
import { findParentNode, calculateNodePosition } from "@milkdown/prose";
|
|
20
|
-
import { DecorationSet, Decoration } from "@milkdown/prose/view";
|
|
21
|
-
import scrollIntoView from "smooth-scroll-into-view-if-needed";
|
|
22
|
-
const itemStyle = (themeManager, { css }) => {
|
|
23
|
-
const palette = (color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);
|
|
24
|
-
return css`
|
|
1
|
+
import { createPlugin as b, AtomList as E } from "@milkdown/utils";
|
|
2
|
+
import { ThemeSize as $, ThemeBorder as C, ThemeShadow as N, ThemeScrollbar as S, ThemeFont as L, ThemeColor as y, ThemeIcon as T, schemaCtx as I, themeManagerCtx as m, commandsCtx as u } from "@milkdown/core";
|
|
3
|
+
import { missingIcon as A, missingRootElement as D } from "@milkdown/exception";
|
|
4
|
+
import { Plugin as x, PluginKey as _ } from "@milkdown/prose/state";
|
|
5
|
+
import { findParentNode as M, calculateNodePosition as H } from "@milkdown/prose";
|
|
6
|
+
import { DecorationSet as P, Decoration as O } from "@milkdown/prose/view";
|
|
7
|
+
import k from "smooth-scroll-into-view-if-needed";
|
|
8
|
+
const q = (e, { css: t }) => {
|
|
9
|
+
const n = (o, r = 1) => e.get(y, [o, r]);
|
|
10
|
+
return t`
|
|
25
11
|
.slash-dropdown-item {
|
|
26
12
|
display: flex;
|
|
27
|
-
gap:
|
|
28
|
-
height:
|
|
29
|
-
padding: 0
|
|
13
|
+
gap: 32px;
|
|
14
|
+
height: 48px;
|
|
15
|
+
padding: 0 16px;
|
|
30
16
|
align-items: center;
|
|
31
17
|
justify-content: flex-start;
|
|
32
18
|
cursor: pointer;
|
|
33
|
-
line-height:
|
|
34
|
-
font-family: ${
|
|
35
|
-
font-size:
|
|
19
|
+
line-height: 48px;
|
|
20
|
+
font-family: ${e.get(L, "typography")};
|
|
21
|
+
font-size: 14px;
|
|
36
22
|
|
|
37
23
|
transition: all 0.2s ease-in-out;
|
|
38
24
|
|
|
39
25
|
&,
|
|
40
26
|
.icon {
|
|
41
|
-
color: ${
|
|
27
|
+
color: ${n("neutral", 0.87)};
|
|
42
28
|
transition: all 0.2s ease-in-out;
|
|
43
29
|
}
|
|
44
30
|
|
|
@@ -47,504 +33,348 @@ const itemStyle = (themeManager, { css }) => {
|
|
|
47
33
|
}
|
|
48
34
|
|
|
49
35
|
&.active {
|
|
50
|
-
background: ${
|
|
36
|
+
background: ${n("secondary", 0.12)};
|
|
51
37
|
&,
|
|
52
38
|
.icon {
|
|
53
|
-
color: ${
|
|
39
|
+
color: ${n("primary")};
|
|
54
40
|
}
|
|
55
41
|
}
|
|
56
42
|
}
|
|
57
43
|
`;
|
|
58
|
-
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
max-height: 20.5em;
|
|
44
|
+
}, K = (e, t) => {
|
|
45
|
+
const n = (o, r = 1) => e.get(y, [o, r]);
|
|
46
|
+
return t.css`
|
|
47
|
+
width: 320px;
|
|
48
|
+
max-height: 320px;
|
|
64
49
|
overflow-y: auto;
|
|
65
|
-
border-radius: ${
|
|
50
|
+
border-radius: ${e.get($, "radius")};
|
|
66
51
|
position: absolute;
|
|
67
|
-
background: ${
|
|
52
|
+
background: ${n("surface")};
|
|
68
53
|
|
|
69
|
-
${
|
|
70
|
-
${
|
|
71
|
-
${
|
|
54
|
+
${e.get(C, void 0)}
|
|
55
|
+
${e.get(N, void 0)}
|
|
56
|
+
${e.get(S, void 0)}
|
|
72
57
|
|
|
73
58
|
&.hide {
|
|
74
59
|
display: none;
|
|
75
60
|
}
|
|
76
61
|
|
|
77
|
-
${
|
|
62
|
+
${q(e, t)}
|
|
78
63
|
`;
|
|
79
|
-
}
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const iconSpan = themeManager.get(ThemeIcon, icon);
|
|
100
|
-
if (!iconSpan) {
|
|
101
|
-
throw new Error("icon not found");
|
|
102
|
-
}
|
|
103
|
-
const textSpan = document.createElement("span");
|
|
104
|
-
textSpan.textContent = text;
|
|
105
|
-
textSpan.className = textClassName;
|
|
106
|
-
div.appendChild(iconSpan.dom);
|
|
107
|
-
div.appendChild(textSpan);
|
|
108
|
-
return div;
|
|
109
|
-
};
|
|
110
|
-
const cleanUp = (state, dispatch) => {
|
|
111
|
-
const { selection } = state;
|
|
112
|
-
const { $from } = selection;
|
|
113
|
-
const tr = state.tr.deleteRange($from.start(), $from.pos);
|
|
114
|
-
dispatch == null ? void 0 : dispatch(tr);
|
|
115
|
-
return false;
|
|
116
|
-
};
|
|
117
|
-
const cleanUpAndCreateNode = (createCommand) => (state, dispatch, view) => {
|
|
118
|
-
if (view) {
|
|
119
|
-
cleanUp(state, dispatch);
|
|
120
|
-
createCommand();
|
|
121
|
-
}
|
|
122
|
-
return true;
|
|
123
|
-
};
|
|
124
|
-
const defaultActions = (ctx, input = "/") => {
|
|
125
|
-
const { nodes } = ctx.get(schemaCtx);
|
|
126
|
-
const actions = [
|
|
64
|
+
}, U = (e, t) => {
|
|
65
|
+
const n = document.createElement("div");
|
|
66
|
+
return n.setAttribute("role", "listbox"), n.setAttribute("tabindex", "-1"), e.themeManager.onFlush(() => {
|
|
67
|
+
const o = e.getStyle((r) => K(e.themeManager, r));
|
|
68
|
+
o && n.classList.add(o);
|
|
69
|
+
}), n.classList.add(e.getClassName({}, t), "hide"), n;
|
|
70
|
+
}, p = (e, t, n, o) => {
|
|
71
|
+
var l;
|
|
72
|
+
const r = (l = o == null ? void 0 : o.textClassName) != null ? l : "text", s = document.createElement("div");
|
|
73
|
+
s.setAttribute("role", "option"), s.classList.add("slash-dropdown-item");
|
|
74
|
+
const a = e.get(T, n);
|
|
75
|
+
if (!a)
|
|
76
|
+
throw A(n);
|
|
77
|
+
const i = document.createElement("span");
|
|
78
|
+
return i.textContent = t, i.className = r, s.appendChild(a.dom), s.appendChild(i), s;
|
|
79
|
+
}, W = (e, t) => {
|
|
80
|
+
const { selection: n } = e, { $from: o } = n, r = e.tr.deleteRange(o.start(), o.pos);
|
|
81
|
+
return t == null || t(r), !1;
|
|
82
|
+
}, F = (e) => (t, n, o) => (o && (W(t, n), e()), !0), v = (e, t = "/") => {
|
|
83
|
+
const { nodes: n } = e.get(I), o = [
|
|
127
84
|
{
|
|
128
85
|
id: "h1",
|
|
129
|
-
dom:
|
|
130
|
-
command: () =>
|
|
86
|
+
dom: p(e.get(m), "Large Heading", "h1"),
|
|
87
|
+
command: () => e.get(u).call("TurnIntoHeading", 1),
|
|
131
88
|
keyword: ["h1", "large heading"],
|
|
132
89
|
typeName: "heading"
|
|
133
90
|
},
|
|
134
91
|
{
|
|
135
92
|
id: "h2",
|
|
136
|
-
dom:
|
|
137
|
-
command: () =>
|
|
93
|
+
dom: p(e.get(m), "Medium Heading", "h2"),
|
|
94
|
+
command: () => e.get(u).call("TurnIntoHeading", 2),
|
|
138
95
|
keyword: ["h2", "medium heading"],
|
|
139
96
|
typeName: "heading"
|
|
140
97
|
},
|
|
141
98
|
{
|
|
142
99
|
id: "h3",
|
|
143
|
-
dom:
|
|
144
|
-
command: () =>
|
|
100
|
+
dom: p(e.get(m), "Small Heading", "h3"),
|
|
101
|
+
command: () => e.get(u).call("TurnIntoHeading", 3),
|
|
145
102
|
keyword: ["h3", "small heading"],
|
|
146
103
|
typeName: "heading"
|
|
147
104
|
},
|
|
148
105
|
{
|
|
149
106
|
id: "bulletList",
|
|
150
|
-
dom:
|
|
151
|
-
command: () =>
|
|
107
|
+
dom: p(e.get(m), "Bullet List", "bulletList"),
|
|
108
|
+
command: () => e.get(u).call("WrapInBulletList"),
|
|
152
109
|
keyword: ["bullet list", "ul"],
|
|
153
110
|
typeName: "bullet_list"
|
|
154
111
|
},
|
|
155
112
|
{
|
|
156
113
|
id: "orderedList",
|
|
157
|
-
dom:
|
|
158
|
-
command: () =>
|
|
114
|
+
dom: p(e.get(m), "Ordered List", "orderedList"),
|
|
115
|
+
command: () => e.get(u).call("WrapInOrderedList"),
|
|
159
116
|
keyword: ["ordered list", "ol"],
|
|
160
117
|
typeName: "ordered_list"
|
|
161
118
|
},
|
|
162
119
|
{
|
|
163
120
|
id: "taskList",
|
|
164
|
-
dom:
|
|
165
|
-
command: () =>
|
|
121
|
+
dom: p(e.get(m), "Task List", "taskList"),
|
|
122
|
+
command: () => e.get(u).call("TurnIntoTaskList"),
|
|
166
123
|
keyword: ["task list", "task"],
|
|
167
124
|
typeName: "task_list_item"
|
|
168
125
|
},
|
|
169
126
|
{
|
|
170
127
|
id: "image",
|
|
171
|
-
dom:
|
|
172
|
-
command: () =>
|
|
128
|
+
dom: p(e.get(m), "Image", "image"),
|
|
129
|
+
command: () => e.get(u).call("InsertImage"),
|
|
173
130
|
keyword: ["image"],
|
|
174
131
|
typeName: "image"
|
|
175
132
|
},
|
|
176
133
|
{
|
|
177
134
|
id: "blockquote",
|
|
178
|
-
dom:
|
|
179
|
-
command: () =>
|
|
135
|
+
dom: p(e.get(m), "Quote", "quote"),
|
|
136
|
+
command: () => e.get(u).call("WrapInBlockquote"),
|
|
180
137
|
keyword: ["quote", "blockquote"],
|
|
181
138
|
typeName: "blockquote"
|
|
182
139
|
},
|
|
183
140
|
{
|
|
184
141
|
id: "table",
|
|
185
|
-
dom:
|
|
186
|
-
command: () =>
|
|
142
|
+
dom: p(e.get(m), "Table", "table"),
|
|
143
|
+
command: () => e.get(u).call("InsertTable"),
|
|
187
144
|
keyword: ["table"],
|
|
188
145
|
typeName: "table"
|
|
189
146
|
},
|
|
190
147
|
{
|
|
191
148
|
id: "code",
|
|
192
|
-
dom:
|
|
193
|
-
command: () =>
|
|
149
|
+
dom: p(e.get(m), "Code Fence", "code"),
|
|
150
|
+
command: () => e.get(u).call("TurnIntoCodeFence"),
|
|
194
151
|
keyword: ["code"],
|
|
195
152
|
typeName: "fence"
|
|
196
153
|
},
|
|
197
154
|
{
|
|
198
155
|
id: "divider",
|
|
199
|
-
dom:
|
|
200
|
-
command: () =>
|
|
156
|
+
dom: p(e.get(m), "Divide Line", "divider"),
|
|
157
|
+
command: () => e.get(u).call("InsertHr"),
|
|
201
158
|
keyword: ["divider", "hr"],
|
|
202
159
|
typeName: "hr"
|
|
203
160
|
}
|
|
204
|
-
];
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return null;
|
|
215
|
-
if (!content) {
|
|
216
|
-
return { placeholder: "Type / to use the slash commands..." };
|
|
217
|
-
}
|
|
218
|
-
if (content.startsWith("/")) {
|
|
219
|
-
return content === "/" ? {
|
|
220
|
-
placeholder: "Type to filter...",
|
|
221
|
-
actions: defaultActions(ctx)
|
|
222
|
-
} : {
|
|
223
|
-
actions: defaultActions(ctx, content)
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
return null;
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
const createEmptyStyle = (themeManager, { css }) => {
|
|
230
|
-
const palette = (color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);
|
|
231
|
-
const typography = themeManager.get(ThemeFont, "typography");
|
|
232
|
-
return css`
|
|
161
|
+
], r = t.slice(1).toLocaleLowerCase();
|
|
162
|
+
return o.filter((s) => !!n[s.typeName] && s.keyword.some((a) => a.includes(r))).map(({ keyword: s, typeName: a, ...i }) => i);
|
|
163
|
+
}, j = (e) => ({ content: t, isTopLevel: n }) => n ? t ? t.startsWith("/") ? t === "/" ? {
|
|
164
|
+
placeholder: "Type to filter...",
|
|
165
|
+
actions: v(e)
|
|
166
|
+
} : {
|
|
167
|
+
actions: v(e, t)
|
|
168
|
+
} : null : { placeholder: "Type / to use the slash commands..." } : null, z = (e, { css: t }) => {
|
|
169
|
+
const n = (r, s = 1) => e.get(y, [r, s]), o = e.get(L, "typography");
|
|
170
|
+
return t`
|
|
233
171
|
position: relative;
|
|
234
172
|
&::before {
|
|
235
173
|
position: absolute;
|
|
236
174
|
cursor: text;
|
|
237
|
-
font-family: ${
|
|
238
|
-
font-size:
|
|
239
|
-
color: ${
|
|
175
|
+
font-family: ${o};
|
|
176
|
+
font-size: 14px;
|
|
177
|
+
color: ${n("neutral", 0.6)};
|
|
240
178
|
content: attr(data-text);
|
|
241
179
|
height: 100%;
|
|
242
180
|
display: flex;
|
|
243
181
|
align-items: center;
|
|
244
182
|
}
|
|
245
183
|
`;
|
|
246
|
-
}
|
|
247
|
-
const createSlashStyle = (_, { css }) => css`
|
|
184
|
+
}, B = (e, { css: t }) => t`
|
|
248
185
|
&::before {
|
|
249
|
-
left:
|
|
186
|
+
left: 8px;
|
|
250
187
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
const createDecoration = (text, className) => {
|
|
288
|
-
const pos = paragraph.pos;
|
|
289
|
-
return DecorationSet.create(state.doc, [
|
|
290
|
-
Decoration.node(pos, pos + paragraph.node.nodeSize, {
|
|
291
|
-
class: className.filter((x) => x).join(" "),
|
|
292
|
-
"data-text": text
|
|
293
|
-
})
|
|
294
|
-
]);
|
|
295
|
-
};
|
|
296
|
-
const emptyStyle = utils.getStyle((emotion) => createEmptyStyle(utils.themeManager, emotion));
|
|
297
|
-
const slashStyle = utils.getStyle((emotion) => createSlashStyle(utils.themeManager, emotion));
|
|
298
|
-
if (actions.length) {
|
|
299
|
-
return createDecoration(placeholder, [emptyStyle, slashStyle, "empty-node", "is-slash"]);
|
|
300
|
-
}
|
|
301
|
-
return createDecoration(placeholder, [emptyStyle, "empty-node"]);
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
};
|
|
305
|
-
const transformAction = (action) => ({
|
|
306
|
-
id: action.id,
|
|
307
|
-
$: action.dom,
|
|
308
|
-
command: cleanUpAndCreateNode(action.command)
|
|
309
|
-
});
|
|
310
|
-
const createStatusCtx = () => {
|
|
311
|
-
return {
|
|
312
|
-
placeholder: null,
|
|
313
|
-
actions: []
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
const createStatus = (builder) => {
|
|
317
|
-
const statusCtx = createStatusCtx();
|
|
188
|
+
`, R = (e, t) => ({
|
|
189
|
+
handleKeyDown: (n, o) => !(e.isEmpty() || !(o instanceof KeyboardEvent) || !["ArrowUp", "ArrowDown", "Enter"].includes(o.key)),
|
|
190
|
+
decorations: (n) => {
|
|
191
|
+
const o = M(({ type: c }) => c.name === "paragraph")(n.selection), r = n.plugins.find((c) => c.key === "MILKDOWN_UPLOAD$"), s = r == null ? void 0 : r.getState(n);
|
|
192
|
+
if (s != null && s.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
|
+
return e.clear(), null;
|
|
194
|
+
const { placeholder: a, actions: i } = e.update({
|
|
195
|
+
parentNode: n.selection.$from.node(n.selection.$from.depth - 1),
|
|
196
|
+
isTopLevel: n.selection.$from.depth === 1,
|
|
197
|
+
content: o.node.textContent,
|
|
198
|
+
state: n
|
|
199
|
+
});
|
|
200
|
+
if (!a)
|
|
201
|
+
return null;
|
|
202
|
+
const l = (c, g) => {
|
|
203
|
+
const h = o.pos;
|
|
204
|
+
return P.create(n.doc, [
|
|
205
|
+
O.node(h, h + o.node.nodeSize, {
|
|
206
|
+
class: g.filter((w) => w).join(" "),
|
|
207
|
+
"data-text": c
|
|
208
|
+
})
|
|
209
|
+
]);
|
|
210
|
+
}, f = t.getStyle((c) => z(t.themeManager, c)), d = t.getStyle((c) => B(t.themeManager, c));
|
|
211
|
+
return i.length ? l(a, [f, d, "empty-node", "is-slash"]) : l(a, [f, "empty-node"]);
|
|
212
|
+
}
|
|
213
|
+
}), V = (e) => ({
|
|
214
|
+
id: e.id,
|
|
215
|
+
$: e.dom,
|
|
216
|
+
command: F(e.command)
|
|
217
|
+
}), Q = () => ({
|
|
218
|
+
placeholder: null,
|
|
219
|
+
actions: []
|
|
220
|
+
}), G = (e) => {
|
|
221
|
+
const t = Q();
|
|
318
222
|
return {
|
|
319
|
-
get: () =>
|
|
223
|
+
get: () => t,
|
|
320
224
|
clear: () => {
|
|
321
|
-
|
|
322
|
-
statusCtx.actions = [];
|
|
225
|
+
t.placeholder = null, t.actions = [];
|
|
323
226
|
},
|
|
324
|
-
update: (
|
|
325
|
-
var
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
statusCtx.actions = ((_b = config == null ? void 0 : config.actions) != null ? _b : []).map(transformAction);
|
|
329
|
-
return statusCtx;
|
|
227
|
+
update: (n) => {
|
|
228
|
+
var r, s;
|
|
229
|
+
const o = e(n);
|
|
230
|
+
return t.placeholder = (r = o == null ? void 0 : o.placeholder) != null ? r : null, t.actions = ((s = o == null ? void 0 : o.actions) != null ? s : []).map(V), t;
|
|
330
231
|
},
|
|
331
|
-
isEmpty: () =>
|
|
232
|
+
isEmpty: () => t.actions.length === 0
|
|
332
233
|
};
|
|
333
|
-
}
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
$.addEventListener("mouseleave", listeners.mouseLeave);
|
|
351
|
-
dropdownElement.appendChild($);
|
|
352
|
-
});
|
|
353
|
-
dropdownElement.classList.remove("hide");
|
|
354
|
-
const first$ = actions[0];
|
|
355
|
-
if (first$) {
|
|
356
|
-
first$.$.classList.add("active");
|
|
357
|
-
requestAnimationFrame(() => {
|
|
358
|
-
scrollIntoView(first$.$, {
|
|
359
|
-
scrollMode: "if-needed",
|
|
360
|
-
block: "nearest",
|
|
361
|
-
inline: "nearest"
|
|
362
|
-
});
|
|
234
|
+
}, J = (e, t, n) => {
|
|
235
|
+
const { actions: o } = e.get();
|
|
236
|
+
if (!o.length)
|
|
237
|
+
return t.classList.add("hide"), !1;
|
|
238
|
+
for (t.childNodes.forEach((s) => {
|
|
239
|
+
s.removeEventListener("mouseenter", n.mouseEnter), s.removeEventListener("mouseleave", n.mouseLeave);
|
|
240
|
+
}); t.firstChild; )
|
|
241
|
+
t.firstChild.remove();
|
|
242
|
+
o.forEach(({ $: s }) => {
|
|
243
|
+
s.classList.remove("active"), s.addEventListener("mouseenter", n.mouseEnter), s.addEventListener("mouseleave", n.mouseLeave), t.appendChild(s);
|
|
244
|
+
}), t.classList.remove("hide");
|
|
245
|
+
const r = o[0];
|
|
246
|
+
return r && (r.$.classList.add("active"), requestAnimationFrame(() => {
|
|
247
|
+
k(r.$, {
|
|
248
|
+
scrollMode: "if-needed",
|
|
249
|
+
block: "nearest",
|
|
250
|
+
inline: "nearest"
|
|
363
251
|
});
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const createMouseManager = () => {
|
|
368
|
-
let mouseLock = false;
|
|
252
|
+
})), !0;
|
|
253
|
+
}, X = () => {
|
|
254
|
+
let e = !1;
|
|
369
255
|
return {
|
|
370
|
-
isLock: () =>
|
|
256
|
+
isLock: () => e,
|
|
371
257
|
lock: () => {
|
|
372
|
-
|
|
258
|
+
e = !0;
|
|
373
259
|
},
|
|
374
260
|
unlock: () => {
|
|
375
|
-
|
|
261
|
+
e = !1;
|
|
376
262
|
}
|
|
377
263
|
};
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const handleMouseEnter = (status, mouseManager) => (e) => {
|
|
383
|
-
if (mouseManager.isLock())
|
|
384
|
-
return;
|
|
385
|
-
const { actions } = status.get();
|
|
386
|
-
const active = actions.findIndex((x) => x.$.classList.contains("active"));
|
|
387
|
-
const active$ = actions[active];
|
|
388
|
-
if (active$ && active >= 0) {
|
|
389
|
-
active$.$.classList.remove("active");
|
|
390
|
-
}
|
|
391
|
-
const { target } = e;
|
|
392
|
-
if (!(target instanceof HTMLElement))
|
|
393
|
-
return;
|
|
394
|
-
target.classList.add("active");
|
|
395
|
-
};
|
|
396
|
-
const handleMouseLeave = () => (e) => {
|
|
397
|
-
const { target } = e;
|
|
398
|
-
if (!(target instanceof HTMLElement))
|
|
264
|
+
}, Y = (e) => () => {
|
|
265
|
+
e.unlock();
|
|
266
|
+
}, Z = (e, t) => (n) => {
|
|
267
|
+
if (t.isLock())
|
|
399
268
|
return;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
269
|
+
const { actions: o } = e.get(), r = o.findIndex((i) => i.$.classList.contains("active")), s = o[r];
|
|
270
|
+
s && r >= 0 && s.$.classList.remove("active");
|
|
271
|
+
const { target: a } = n;
|
|
272
|
+
a instanceof HTMLElement && a.classList.add("active");
|
|
273
|
+
}, ee = () => (e) => {
|
|
274
|
+
const { target: t } = e;
|
|
275
|
+
t instanceof HTMLElement && t.classList.remove("active");
|
|
276
|
+
}, te = (e, t, n) => (o) => {
|
|
277
|
+
const { target: r } = o;
|
|
278
|
+
if (!(r instanceof HTMLElement) || !t)
|
|
405
279
|
return;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
e.
|
|
411
|
-
};
|
|
412
|
-
const { actions } = status.get();
|
|
413
|
-
const el = Object.values(actions).find(({ $ }) => $.contains(target));
|
|
414
|
-
if (!el) {
|
|
415
|
-
if (status.isEmpty())
|
|
280
|
+
const s = () => {
|
|
281
|
+
o.stopPropagation(), o.preventDefault();
|
|
282
|
+
}, { actions: a } = e.get(), i = Object.values(a).find(({ $: l }) => l.contains(r));
|
|
283
|
+
if (!i) {
|
|
284
|
+
if (e.isEmpty())
|
|
416
285
|
return;
|
|
417
|
-
|
|
418
|
-
dropdownElement.classList.add("hide");
|
|
419
|
-
stop();
|
|
286
|
+
e.clear(), n.classList.add("hide"), s();
|
|
420
287
|
return;
|
|
421
288
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const handleKeydown = (status, view, dropdownElement, mouseManager) => (e) => {
|
|
426
|
-
if (!(e instanceof KeyboardEvent))
|
|
427
|
-
return;
|
|
428
|
-
if (!mouseManager.isLock())
|
|
429
|
-
mouseManager.lock();
|
|
430
|
-
const { key: key2 } = e;
|
|
431
|
-
if (status.isEmpty())
|
|
289
|
+
s(), i.command(t.state, t.dispatch, t);
|
|
290
|
+
}, oe = (e, t, n, o) => (r) => {
|
|
291
|
+
if (!(r instanceof KeyboardEvent))
|
|
432
292
|
return;
|
|
433
|
-
|
|
293
|
+
o.isLock() || o.lock();
|
|
294
|
+
const { key: s } = r;
|
|
295
|
+
if (e.isEmpty() || !["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(s))
|
|
434
296
|
return;
|
|
435
|
-
const { actions } =
|
|
436
|
-
let
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
const next$ = actions[next];
|
|
442
|
-
if (!active$2 || !next$)
|
|
443
|
-
return;
|
|
444
|
-
active$2.$.classList.remove("active");
|
|
445
|
-
next$.$.classList.add("active");
|
|
446
|
-
scrollIntoView(next$.$, {
|
|
297
|
+
const { actions: a } = e.get();
|
|
298
|
+
let i = a.findIndex(({ $: d }) => d.classList.contains("active"));
|
|
299
|
+
i < 0 && (i = 0);
|
|
300
|
+
const l = (d) => {
|
|
301
|
+
const c = a[i], g = a[d];
|
|
302
|
+
!c || !g || (c.$.classList.remove("active"), g.$.classList.add("active"), k(g.$, {
|
|
447
303
|
scrollMode: "if-needed",
|
|
448
304
|
block: "nearest",
|
|
449
305
|
inline: "nearest"
|
|
450
|
-
});
|
|
306
|
+
}));
|
|
451
307
|
};
|
|
452
|
-
if (
|
|
453
|
-
const
|
|
454
|
-
|
|
308
|
+
if (s === "ArrowDown") {
|
|
309
|
+
const d = i === a.length - 1 ? 0 : i + 1;
|
|
310
|
+
l(d);
|
|
455
311
|
return;
|
|
456
312
|
}
|
|
457
|
-
if (
|
|
458
|
-
const
|
|
459
|
-
|
|
313
|
+
if (s === "ArrowUp") {
|
|
314
|
+
const d = i === 0 ? a.length - 1 : i - 1;
|
|
315
|
+
l(d);
|
|
460
316
|
return;
|
|
461
317
|
}
|
|
462
|
-
if (
|
|
463
|
-
if (
|
|
318
|
+
if (s === "Escape") {
|
|
319
|
+
if (e.isEmpty())
|
|
464
320
|
return;
|
|
465
|
-
|
|
466
|
-
dropdownElement.classList.add("hide");
|
|
321
|
+
e.clear(), n.classList.add("hide");
|
|
467
322
|
return;
|
|
468
323
|
}
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
324
|
+
const f = a[i];
|
|
325
|
+
!f || (f.command(t.state, t.dispatch, t), f.$.classList.remove("active"));
|
|
326
|
+
}, ne = (e, t) => {
|
|
327
|
+
H(e, t, (n, o, r) => {
|
|
328
|
+
const s = t.parentElement;
|
|
329
|
+
if (!s)
|
|
330
|
+
throw D();
|
|
331
|
+
let a = n.left - r.left, i = n.bottom - r.top + 14 + s.scrollTop;
|
|
332
|
+
if (a < 0 && (a = 0), r.height + r.top - n.bottom < o.height) {
|
|
333
|
+
const l = n.top - r.top - o.height - 14 + s.scrollTop;
|
|
334
|
+
l > 0 && (i = l);
|
|
480
335
|
}
|
|
481
|
-
|
|
482
|
-
let top = selected.bottom - parent.top + 14 + $editor.scrollTop;
|
|
483
|
-
if (left < 0) {
|
|
484
|
-
left = 0;
|
|
485
|
-
}
|
|
486
|
-
if (parent.height + parent.top - selected.bottom < target.height) {
|
|
487
|
-
const topOffset = selected.top - parent.top - target.height - 14 + $editor.scrollTop;
|
|
488
|
-
if (topOffset > 0) {
|
|
489
|
-
top = topOffset;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
return [top, left];
|
|
336
|
+
return [i, a];
|
|
493
337
|
});
|
|
494
|
-
}
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
if (!wrapper)
|
|
338
|
+
}, re = (e, t, n, o) => {
|
|
339
|
+
const r = t.dom.parentNode;
|
|
340
|
+
if (!r)
|
|
498
341
|
return {};
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
wrapper.addEventListener("mousedown", _mouseDown);
|
|
509
|
-
wrapper.addEventListener("keydown", _keydown);
|
|
510
|
-
return {
|
|
511
|
-
update: (view2) => {
|
|
512
|
-
const show = renderDropdown(status, dropdownElement, {
|
|
513
|
-
mouseEnter: _mouseEnter,
|
|
514
|
-
mouseLeave: _mouseLeave
|
|
515
|
-
});
|
|
516
|
-
if (!show)
|
|
517
|
-
return;
|
|
518
|
-
calculatePosition(view2, dropdownElement);
|
|
342
|
+
const s = U(n, o), a = X();
|
|
343
|
+
r.appendChild(s);
|
|
344
|
+
const i = Y(a), l = te(e, t, s), f = oe(e, t, s, a), d = Z(e, a), c = ee();
|
|
345
|
+
return r.addEventListener("mousemove", i), r.addEventListener("mousedown", l), r.addEventListener("keydown", f), {
|
|
346
|
+
update: (g) => {
|
|
347
|
+
!J(e, s, {
|
|
348
|
+
mouseEnter: d,
|
|
349
|
+
mouseLeave: c
|
|
350
|
+
}) || ne(g, s);
|
|
519
351
|
},
|
|
520
352
|
destroy: () => {
|
|
521
|
-
|
|
522
|
-
wrapper.removeEventListener("mousedown", _mouseDown);
|
|
523
|
-
wrapper.removeEventListener("keydown", _keydown);
|
|
524
|
-
dropdownElement.remove();
|
|
353
|
+
r.removeEventListener("mousemove", i), r.removeEventListener("mousedown", l), r.removeEventListener("keydown", f), s.remove();
|
|
525
354
|
}
|
|
526
355
|
};
|
|
527
|
-
}
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
props: createProps(status, utils),
|
|
534
|
-
view: (view) => createView(status, view, utils, className)
|
|
356
|
+
}, se = "MILKDOWN_SLASH", ae = (e, t, n) => {
|
|
357
|
+
const o = G(t);
|
|
358
|
+
return new x({
|
|
359
|
+
key: new _(se),
|
|
360
|
+
props: R(o, e),
|
|
361
|
+
view: (r) => re(o, r, e, n)
|
|
535
362
|
});
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
const slashConfig = (_a = options == null ? void 0 : options.config) != null ? _a : defaultConfig;
|
|
363
|
+
}, ie = b((e, t) => {
|
|
364
|
+
var o;
|
|
365
|
+
const n = (o = t == null ? void 0 : t.config) != null ? o : j;
|
|
540
366
|
return {
|
|
541
|
-
prosePlugins: (
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
return [plugin];
|
|
367
|
+
prosePlugins: (r, s) => {
|
|
368
|
+
const a = n(s);
|
|
369
|
+
return [ae(e, a, "slash-dropdown")];
|
|
545
370
|
}
|
|
546
371
|
};
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
|
|
372
|
+
}), ge = E.create([ie()]);
|
|
373
|
+
export {
|
|
374
|
+
p as createDropdownItem,
|
|
375
|
+
v as defaultActions,
|
|
376
|
+
j as defaultConfig,
|
|
377
|
+
ge as slash,
|
|
378
|
+
ie as slashPlugin
|
|
379
|
+
};
|
|
550
380
|
//# sourceMappingURL=index.es.js.map
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/style.ts","../src/utility.ts","../src/config.ts","../src/prose-plugin/props.ts","../src/item.ts","../src/prose-plugin/status.ts","../src/prose-plugin/dropdown.ts","../src/prose-plugin/input.ts","../src/prose-plugin/view.ts","../src/prose-plugin/index.ts","../src/index.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nimport {\n Color,\n Emotion,\n ThemeBorder,\n ThemeColor,\n ThemeFont,\n ThemeManager,\n ThemeScrollbar,\n ThemeShadow,\n ThemeSize,\n} from '@milkdown/core';\n\nconst itemStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n return css`\n .slash-dropdown-item {\n display: flex;\n gap: 2em;\n height: 3.4286em;\n padding: 0 1em;\n align-items: center;\n justify-content: flex-start;\n cursor: pointer;\n line-height: 3.4286em;\n font-family: ${themeManager.get(ThemeFont, 'typography')};\n font-size: 0.875em;\n\n transition: all 0.2s ease-in-out;\n\n &,\n .icon {\n color: ${palette('neutral', 0.87)};\n transition: all 0.2s ease-in-out;\n }\n\n &.hide {\n display: none;\n }\n\n &.active {\n background: ${palette('secondary', 0.12)};\n &,\n .icon {\n color: ${palette('primary')};\n }\n }\n }\n `;\n};\n\nexport const injectStyle = (themeManager: ThemeManager, emotion: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n\n return emotion.css`\n width: 20.5em;\n max-height: 20.5em;\n overflow-y: auto;\n border-radius: ${themeManager.get(ThemeSize, 'radius')};\n position: absolute;\n background: ${palette('surface')};\n\n ${themeManager.get(ThemeBorder, undefined)}\n ${themeManager.get(ThemeShadow, undefined)}\n ${themeManager.get(ThemeScrollbar, undefined)}\n\n &.hide {\n display: none;\n }\n\n ${itemStyle(themeManager, emotion)}\n `;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { ThemeIcon, ThemeManager } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport type { Command } from '@milkdown/prose/commands';\nimport type { Node } from '@milkdown/prose/model';\nimport type { Utils } from '@milkdown/utils';\n\nimport { injectStyle } from './style';\n\nexport const createDropdown = (utils: Utils, className: string) => {\n const div = document.createElement('div');\n div.setAttribute('role', 'listbox');\n div.setAttribute('tabindex', '-1');\n utils.themeManager.onFlush(() => {\n const style = utils.getStyle((emotion) => injectStyle(utils.themeManager, emotion));\n\n if (style) {\n div.classList.add(style);\n }\n });\n\n div.classList.add(utils.getClassName({}, className), 'hide');\n\n return div;\n};\n\ntype ItemOptions = {\n textClassName: string;\n};\nexport const createDropdownItem = (\n themeManager: ThemeManager,\n text: string,\n icon: Icon,\n options?: Partial<ItemOptions>,\n) => {\n const textClassName = options?.textClassName ?? 'text';\n\n const div = document.createElement('div');\n div.setAttribute('role', 'option');\n div.classList.add('slash-dropdown-item');\n\n // const iconSpan = themeManager.slots.icon(icon);\n const iconSpan = themeManager.get(ThemeIcon, icon);\n\n if (!iconSpan) {\n throw new Error('icon not found');\n }\n\n const textSpan = document.createElement('span');\n textSpan.textContent = text;\n textSpan.className = textClassName;\n\n div.appendChild(iconSpan.dom);\n div.appendChild(textSpan);\n\n return div;\n};\n\nexport const getDepth = (node: Node) => {\n let cur = node;\n let depth = 0;\n while (cur.childCount) {\n cur = cur.child(0);\n depth += 1;\n }\n\n return depth;\n};\n\nconst cleanUp: Command = (state, dispatch) => {\n const { selection } = state;\n const { $from } = selection;\n const tr = state.tr.deleteRange($from.start(), $from.pos);\n dispatch?.(tr);\n return false;\n};\n\nexport const cleanUpAndCreateNode =\n (createCommand: () => void): Command =>\n (state, dispatch, view) => {\n if (view) {\n cleanUp(state, dispatch, view);\n createCommand();\n }\n return true;\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { commandsCtx, Ctx, schemaCtx, themeManagerCtx } from '@milkdown/core';\nimport { Node } from '@milkdown/prose/model';\nimport { EditorState } from '@milkdown/prose/state';\n\nimport { WrappedAction } from './item';\nimport { createDropdownItem } from './utility';\n\ntype Nullable<T> = T | null | undefined;\n\nexport type StatusConfig = {\n placeholder?: Nullable<string>;\n actions?: Nullable<WrappedAction[]>;\n};\n\nexport type StatusConfigBuilderParams = {\n content: string;\n isTopLevel: boolean;\n parentNode: Node;\n state: EditorState;\n};\n\nexport type StatusConfigBuilder = (params: StatusConfigBuilderParams) => Nullable<StatusConfig>;\n\nexport type Config = (ctx: Ctx) => StatusConfigBuilder;\n\nexport const defaultActions = (ctx: Ctx, input = '/'): WrappedAction[] => {\n const { nodes } = ctx.get(schemaCtx);\n const actions: Array<WrappedAction & { keyword: string[]; typeName: string }> = [\n {\n id: 'h1',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Large Heading', 'h1'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 1),\n keyword: ['h1', 'large heading'],\n typeName: 'heading',\n },\n {\n id: 'h2',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Medium Heading', 'h2'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 2),\n keyword: ['h2', 'medium heading'],\n typeName: 'heading',\n },\n {\n id: 'h3',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Small Heading', 'h3'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 3),\n keyword: ['h3', 'small heading'],\n typeName: 'heading',\n },\n {\n id: 'bulletList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Bullet List', 'bulletList'),\n command: () => ctx.get(commandsCtx).call('WrapInBulletList'),\n keyword: ['bullet list', 'ul'],\n typeName: 'bullet_list',\n },\n {\n id: 'orderedList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Ordered List', 'orderedList'),\n command: () => ctx.get(commandsCtx).call('WrapInOrderedList'),\n keyword: ['ordered list', 'ol'],\n typeName: 'ordered_list',\n },\n {\n id: 'taskList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Task List', 'taskList'),\n command: () => ctx.get(commandsCtx).call('TurnIntoTaskList'),\n keyword: ['task list', 'task'],\n typeName: 'task_list_item',\n },\n {\n id: 'image',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Image', 'image'),\n command: () => ctx.get(commandsCtx).call('InsertImage'),\n keyword: ['image'],\n typeName: 'image',\n },\n {\n id: 'blockquote',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Quote', 'quote'),\n command: () => ctx.get(commandsCtx).call('WrapInBlockquote'),\n keyword: ['quote', 'blockquote'],\n typeName: 'blockquote',\n },\n {\n id: 'table',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Table', 'table'),\n command: () => ctx.get(commandsCtx).call('InsertTable'),\n keyword: ['table'],\n typeName: 'table',\n },\n {\n id: 'code',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Code Fence', 'code'),\n command: () => ctx.get(commandsCtx).call('TurnIntoCodeFence'),\n keyword: ['code'],\n typeName: 'fence',\n },\n {\n id: 'divider',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Divide Line', 'divider'),\n command: () => ctx.get(commandsCtx).call('InsertHr'),\n keyword: ['divider', 'hr'],\n typeName: 'hr',\n },\n ];\n\n const userInput = input.slice(1).toLocaleLowerCase();\n\n return actions\n .filter((action) => !!nodes[action.typeName] && action.keyword.some((keyword) => keyword.includes(userInput)))\n .map(({ keyword, typeName, ...action }) => action);\n};\n\nexport const defaultConfig: Config = (ctx) => {\n return ({ content, isTopLevel }) => {\n if (!isTopLevel) return null;\n\n if (!content) {\n return { placeholder: 'Type / to use the slash commands...' };\n }\n\n if (content.startsWith('/')) {\n return content === '/'\n ? {\n placeholder: 'Type to filter...',\n actions: defaultActions(ctx),\n }\n : {\n actions: defaultActions(ctx, content),\n };\n }\n\n return null;\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Color, Emotion, ThemeColor, ThemeFont, ThemeManager } from '@milkdown/core';\nimport { findParentNode } from '@milkdown/prose';\nimport { EditorState } from '@milkdown/prose/state';\nimport { Decoration, DecorationSet, EditorView } from '@milkdown/prose/view';\nimport { Utils } from '@milkdown/utils';\n\nimport type { Status } from './status';\n\nexport type Props = ReturnType<typeof createProps>;\n\nconst createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n const typography = themeManager.get(ThemeFont, 'typography');\n\n return css`\n position: relative;\n &::before {\n position: absolute;\n cursor: text;\n font-family: ${typography};\n font-size: 0.875em;\n color: ${palette('neutral', 0.6)};\n content: attr(data-text);\n height: 100%;\n display: flex;\n align-items: center;\n }\n `;\n};\n\nconst createSlashStyle = (_: ThemeManager, { css }: Emotion) => css`\n &::before {\n left: 0.5em;\n }\n`;\n\nexport const createProps = (status: Status, utils: Utils) => {\n return {\n handleKeyDown: (_: EditorView, event: Event) => {\n if (status.isEmpty()) {\n return false;\n }\n if (!(event instanceof KeyboardEvent)) {\n return false;\n }\n\n if (!['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {\n return false;\n }\n\n return true;\n },\n decorations: (state: EditorState) => {\n const paragraph = findParentNode(({ type }) => type.name === 'paragraph')(state.selection);\n const uploadPlugin = state.plugins.find(\n (x) => (x as unknown as { key: string }).key === 'MILKDOWN_UPLOAD$',\n );\n const decorations: DecorationSet = uploadPlugin?.getState(state);\n if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {\n status.clear();\n return;\n }\n\n if (\n !paragraph ||\n paragraph.node.childCount > 1 ||\n state.selection.$from.parentOffset !== paragraph.node.textContent.length ||\n (paragraph.node.firstChild && paragraph.node.firstChild.type.name !== 'text')\n ) {\n status.clear();\n return;\n }\n\n const { placeholder, actions } = status.update({\n parentNode: state.selection.$from.node(state.selection.$from.depth - 1),\n isTopLevel: state.selection.$from.depth === 1,\n content: paragraph.node.textContent,\n state,\n });\n\n if (!placeholder) {\n return null;\n }\n\n const createDecoration = (text: string, className: (string | undefined)[]) => {\n const pos = paragraph.pos;\n return DecorationSet.create(state.doc, [\n Decoration.node(pos, pos + paragraph.node.nodeSize, {\n class: className.filter((x) => x).join(' '),\n 'data-text': text,\n }),\n ]);\n };\n\n const emptyStyle = utils.getStyle((emotion) => createEmptyStyle(utils.themeManager, emotion));\n const slashStyle = utils.getStyle((emotion) => createSlashStyle(utils.themeManager, emotion));\n\n if (actions.length) {\n return createDecoration(placeholder, [emptyStyle, slashStyle, 'empty-node', 'is-slash']);\n }\n\n return createDecoration(placeholder, [emptyStyle, 'empty-node']);\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport type { Command } from '@milkdown/prose/commands';\n\nimport { cleanUpAndCreateNode } from './utility';\n\nexport type Action = {\n id: string;\n $: HTMLElement;\n command: Command;\n};\n\nexport type WrappedAction = Pick<Action, 'id'> & {\n command: () => void;\n dom: HTMLElement;\n};\n\nexport const transformAction = (action: WrappedAction): Action => ({\n id: action.id,\n $: action.dom,\n command: cleanUpAndCreateNode(action.command),\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { StatusConfigBuilder, StatusConfigBuilderParams } from '..';\nimport { Action, transformAction } from '../item';\n\nexport type StatusCtx = {\n placeholder: string | null;\n actions: Action[];\n};\n\nconst createStatusCtx = (): StatusCtx => {\n return {\n placeholder: null,\n actions: [],\n };\n};\n\nexport type Status = ReturnType<typeof createStatus>;\n\nexport const createStatus = (builder: StatusConfigBuilder) => {\n const statusCtx = createStatusCtx();\n\n return {\n get: () => statusCtx,\n clear: () => {\n statusCtx.placeholder = null;\n statusCtx.actions = [];\n },\n update: (builderParams: StatusConfigBuilderParams) => {\n const config = builder(builderParams);\n statusCtx.placeholder = config?.placeholder ?? null;\n statusCtx.actions = (config?.actions ?? []).map(transformAction);\n return statusCtx;\n },\n isEmpty: () => statusCtx.actions.length === 0,\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\ntype Listeners = {\n mouseEnter: EventListener;\n mouseLeave: EventListener;\n};\n\nexport const renderDropdown = (status: Status, dropdownElement: HTMLElement, listeners: Listeners): boolean => {\n const { actions } = status.get();\n\n if (!actions.length) {\n dropdownElement.classList.add('hide');\n return false;\n }\n\n dropdownElement.childNodes.forEach((child) => {\n child.removeEventListener('mouseenter', listeners.mouseEnter);\n child.removeEventListener('mouseleave', listeners.mouseLeave);\n });\n\n while (dropdownElement.firstChild) {\n dropdownElement.firstChild.remove();\n }\n\n actions.forEach(({ $ }) => {\n $.classList.remove('active');\n $.addEventListener('mouseenter', listeners.mouseEnter);\n $.addEventListener('mouseleave', listeners.mouseLeave);\n dropdownElement.appendChild($);\n });\n\n dropdownElement.classList.remove('hide');\n\n const first$ = actions[0];\n if (first$) {\n first$.$.classList.add('active');\n requestAnimationFrame(() => {\n scrollIntoView(first$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n });\n }\n\n return true;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\n\nimport { EditorView } from '@milkdown/prose/view';\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\nexport const createMouseManager = () => {\n let mouseLock = false;\n\n return {\n isLock: () => mouseLock,\n lock: () => {\n mouseLock = true;\n },\n unlock: () => {\n mouseLock = false;\n },\n };\n};\nexport type MouseManager = ReturnType<typeof createMouseManager>;\n\nexport const handleMouseMove = (mouseManager: MouseManager) => () => {\n mouseManager.unlock();\n};\n\nexport const handleMouseEnter = (status: Status, mouseManager: MouseManager) => (e: MouseEvent) => {\n if (mouseManager.isLock()) return;\n const { actions } = status.get();\n const active = actions.findIndex((x) => x.$.classList.contains('active'));\n const active$ = actions[active];\n if (active$ && active >= 0) {\n active$.$.classList.remove('active');\n }\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.add('active');\n};\n\nexport const handleMouseLeave = () => (e: MouseEvent) => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.remove('active');\n};\n\nexport const handleClick =\n (status: Status, view: EditorView, dropdownElement: HTMLElement) =>\n (e: Event): void => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n if (!view) return;\n\n const stop = () => {\n e.stopPropagation();\n e.preventDefault();\n };\n\n const { actions } = status.get();\n\n const el = Object.values(actions).find(({ $ }) => $.contains(target));\n if (!el) {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n stop();\n\n return;\n }\n\n stop();\n el.command(view.state, view.dispatch, view);\n };\n\nexport const handleKeydown =\n (status: Status, view: EditorView, dropdownElement: HTMLElement, mouseManager: MouseManager) => (e: Event) => {\n if (!(e instanceof KeyboardEvent)) return;\n if (!mouseManager.isLock()) mouseManager.lock();\n\n const { key } = e;\n if (status.isEmpty()) return;\n if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(key)) return;\n\n const { actions } = status.get();\n\n let active = actions.findIndex(({ $ }) => $.classList.contains('active'));\n if (active < 0) active = 0;\n\n const moveActive = (next: number) => {\n const active$ = actions[active];\n const next$ = actions[next];\n if (!active$ || !next$) return;\n active$.$.classList.remove('active');\n next$.$.classList.add('active');\n scrollIntoView(next$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n };\n\n if (key === 'ArrowDown') {\n const next = active === actions.length - 1 ? 0 : active + 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'ArrowUp') {\n const next = active === 0 ? actions.length - 1 : active - 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'Escape') {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n return;\n }\n\n const active$ = actions[active];\n if (!active$) return;\n active$.command(view.state, view.dispatch, view);\n active$.$.classList.remove('active');\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { calculateNodePosition } from '@milkdown/prose';\nimport { EditorView } from '@milkdown/prose/view';\nimport { Utils } from '@milkdown/utils';\n\nimport { createDropdown } from '../utility';\nimport { renderDropdown } from './dropdown';\nimport {\n createMouseManager,\n handleClick,\n handleKeydown,\n handleMouseEnter,\n handleMouseLeave,\n handleMouseMove,\n} from './input';\nimport { Status } from './status';\n\nconst calculatePosition = (view: EditorView, dropdownElement: HTMLElement) => {\n calculateNodePosition(view, dropdownElement, (selected, target, parent) => {\n const $editor = dropdownElement.parentElement;\n if (!$editor) {\n throw new Error();\n }\n\n let left = selected.left - parent.left;\n let top = selected.bottom - parent.top + 14 + $editor.scrollTop;\n\n if (left < 0) {\n left = 0;\n }\n\n if (parent.height + parent.top - selected.bottom < target.height) {\n const topOffset = selected.top - parent.top - target.height - 14 + $editor.scrollTop;\n if (topOffset > 0) {\n top = topOffset;\n }\n }\n return [top, left];\n });\n};\n\nexport const createView = (status: Status, view: EditorView, utils: Utils, className: string) => {\n const wrapper = view.dom.parentNode;\n if (!wrapper) return {};\n\n const dropdownElement = createDropdown(utils, className);\n const mouseManager = createMouseManager();\n wrapper.appendChild(dropdownElement);\n\n const _mouseMove = handleMouseMove(mouseManager);\n const _mouseDown = handleClick(status, view, dropdownElement);\n const _keydown = handleKeydown(status, view, dropdownElement, mouseManager);\n const _mouseEnter = handleMouseEnter(status, mouseManager);\n const _mouseLeave = handleMouseLeave();\n\n wrapper.addEventListener('mousemove', _mouseMove);\n wrapper.addEventListener('mousedown', _mouseDown);\n wrapper.addEventListener('keydown', _keydown);\n\n return {\n update: (view: EditorView) => {\n const show = renderDropdown(status, dropdownElement, {\n mouseEnter: _mouseEnter as EventListener,\n mouseLeave: _mouseLeave as EventListener,\n });\n\n if (!show) return;\n\n calculatePosition(view, dropdownElement);\n },\n\n destroy: () => {\n wrapper.removeEventListener('mousemove', _mouseMove);\n wrapper.removeEventListener('mousedown', _mouseDown);\n wrapper.removeEventListener('keydown', _keydown);\n dropdownElement.remove();\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Plugin, PluginKey } from '@milkdown/prose/state';\nimport { Utils } from '@milkdown/utils';\n\nimport type { StatusConfigBuilder } from '..';\nimport { createProps } from './props';\nimport { createStatus } from './status';\nimport { createView } from './view';\n\nexport const key = 'MILKDOWN_SLASH';\n\nexport const createSlashPlugin = (utils: Utils, builder: StatusConfigBuilder, className: string) => {\n const status = createStatus(builder);\n\n return new Plugin({\n key: new PluginKey(key),\n props: createProps(status, utils),\n view: (view) => createView(status, view, utils, className),\n });\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { AtomList, createPlugin } from '@milkdown/utils';\n\nimport type { Config } from './config';\nimport { defaultConfig } from './config';\nimport { createSlashPlugin } from './prose-plugin';\n\nexport type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';\nexport { defaultActions, defaultConfig } from './config';\nexport type { Action, WrappedAction } from './item';\nexport { createDropdownItem } from './utility';\n\nexport type Options = {\n config: Config;\n};\n\nexport const slashPlugin = createPlugin<string, Options>((utils, options) => {\n const slashConfig = options?.config ?? defaultConfig;\n\n return {\n prosePlugins: (_, ctx) => {\n const config = slashConfig(ctx);\n\n const plugin = createSlashPlugin(utils, config, 'slash-dropdown');\n\n return [plugin];\n },\n };\n});\n\nexport const slash = AtomList.create([slashPlugin()]);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,YAAY,CAAC,cAA4B,EAAE,UAAmB;AAC1D,QAAA,UAAU,CAAC,OAAc,UAAU,MAAM,aAAa,IAAI,YAAY,CAAC,OAAO,OAAO,CAAC;AACrF,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUgB,aAAa,IAAI,WAAW,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAO1C,QAAQ,WAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BASlB,QAAQ,aAAa,IAAI;AAAA;AAAA;AAAA,6BAG1B,QAAQ,SAAS;AAAA;AAAA;AAAA;AAAA;AAK9C;AAEa,MAAA,cAAc,CAAC,cAA4B,YAAqB;AACnE,QAAA,UAAU,CAAC,OAAc,UAAU,MAAM,aAAa,IAAI,YAAY,CAAC,OAAO,OAAO,CAAC;AAE5F,SAAO,QAAQ;AAAA;AAAA;AAAA;AAAA,yBAIM,aAAa,IAAI,WAAW,QAAQ;AAAA;AAAA,sBAEvC,QAAQ,SAAS;AAAA;AAAA,UAE7B,aAAa,IAAI,aAAa,MAAS;AAAA,UACvC,aAAa,IAAI,aAAa,MAAS;AAAA,UACvC,aAAa,IAAI,gBAAgB,MAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAM1C,UAAU,cAAc,OAAO;AAAA;AAEzC;AC/Da,MAAA,iBAAiB,CAAC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Y,GAAG;AAE9B,YAAM,SAAS,kBAAkB,OAAO,QAAQ,gBAAgB;AAEhE,aAAO,CAAC,MAAM;AAAA,IAClB;AAAA,EAAA;AAER,CAAC;AAEM,MAAM,QAAQ,SAAS,OAAO,CAAC,YAAA,CAAa,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/style.ts","../src/utility.ts","../src/config.ts","../src/prose-plugin/props.ts","../src/item.ts","../src/prose-plugin/status.ts","../src/prose-plugin/dropdown.ts","../src/prose-plugin/input.ts","../src/prose-plugin/view.ts","../src/prose-plugin/index.ts","../src/index.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nimport {\n Color,\n Emotion,\n ThemeBorder,\n ThemeColor,\n ThemeFont,\n ThemeManager,\n ThemeScrollbar,\n ThemeShadow,\n ThemeSize,\n} from '@milkdown/core';\n\nconst itemStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n return css`\n .slash-dropdown-item {\n display: flex;\n gap: 32px;\n height: 48px;\n padding: 0 16px;\n align-items: center;\n justify-content: flex-start;\n cursor: pointer;\n line-height: 48px;\n font-family: ${themeManager.get(ThemeFont, 'typography')};\n font-size: 14px;\n\n transition: all 0.2s ease-in-out;\n\n &,\n .icon {\n color: ${palette('neutral', 0.87)};\n transition: all 0.2s ease-in-out;\n }\n\n &.hide {\n display: none;\n }\n\n &.active {\n background: ${palette('secondary', 0.12)};\n &,\n .icon {\n color: ${palette('primary')};\n }\n }\n }\n `;\n};\n\nexport const injectStyle = (themeManager: ThemeManager, emotion: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n\n return emotion.css`\n width: 320px;\n max-height: 320px;\n overflow-y: auto;\n border-radius: ${themeManager.get(ThemeSize, 'radius')};\n position: absolute;\n background: ${palette('surface')};\n\n ${themeManager.get(ThemeBorder, undefined)}\n ${themeManager.get(ThemeShadow, undefined)}\n ${themeManager.get(ThemeScrollbar, undefined)}\n\n &.hide {\n display: none;\n }\n\n ${itemStyle(themeManager, emotion)}\n `;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { ThemeIcon, ThemeManager } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport { missingIcon } from '@milkdown/exception';\nimport type { Node } from '@milkdown/prose/model';\nimport type { Command } from '@milkdown/prose/state';\nimport type { Utils } from '@milkdown/utils';\n\nimport { injectStyle } from './style';\n\nexport const createDropdown = (utils: Utils, className: string) => {\n const div = document.createElement('div');\n div.setAttribute('role', 'listbox');\n div.setAttribute('tabindex', '-1');\n utils.themeManager.onFlush(() => {\n const style = utils.getStyle((emotion) => injectStyle(utils.themeManager, emotion));\n\n if (style) {\n div.classList.add(style);\n }\n });\n\n div.classList.add(utils.getClassName({}, className), 'hide');\n\n return div;\n};\n\ntype ItemOptions = {\n textClassName: string;\n};\nexport const createDropdownItem = (\n themeManager: ThemeManager,\n text: string,\n icon: Icon,\n options?: Partial<ItemOptions>,\n) => {\n const textClassName = options?.textClassName ?? 'text';\n\n const div = document.createElement('div');\n div.setAttribute('role', 'option');\n div.classList.add('slash-dropdown-item');\n\n const iconSpan = themeManager.get(ThemeIcon, icon);\n\n if (!iconSpan) {\n throw missingIcon(icon);\n }\n\n const textSpan = document.createElement('span');\n textSpan.textContent = text;\n textSpan.className = textClassName;\n\n div.appendChild(iconSpan.dom);\n div.appendChild(textSpan);\n\n return div;\n};\n\nexport const getDepth = (node: Node) => {\n let cur = node;\n let depth = 0;\n while (cur.childCount) {\n cur = cur.child(0);\n depth += 1;\n }\n\n return depth;\n};\n\nconst cleanUp: Command = (state, dispatch) => {\n const { selection } = state;\n const { $from } = selection;\n const tr = state.tr.deleteRange($from.start(), $from.pos);\n dispatch?.(tr);\n return false;\n};\n\nexport const cleanUpAndCreateNode =\n (createCommand: () => void): Command =>\n (state, dispatch, view) => {\n if (view) {\n cleanUp(state, dispatch, view);\n createCommand();\n }\n return true;\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { commandsCtx, Ctx, schemaCtx, themeManagerCtx } from '@milkdown/core';\nimport { Node } from '@milkdown/prose/model';\nimport { EditorState } from '@milkdown/prose/state';\n\nimport { WrappedAction } from './item';\nimport { createDropdownItem } from './utility';\n\ntype Nullable<T> = T | null | undefined;\n\nexport type StatusConfig = {\n placeholder?: Nullable<string>;\n actions?: Nullable<WrappedAction[]>;\n};\n\nexport type StatusConfigBuilderParams = {\n content: string;\n isTopLevel: boolean;\n parentNode: Node;\n state: EditorState;\n};\n\nexport type StatusConfigBuilder = (params: StatusConfigBuilderParams) => Nullable<StatusConfig>;\n\nexport type Config = (ctx: Ctx) => StatusConfigBuilder;\n\nexport const defaultActions = (ctx: Ctx, input = '/'): WrappedAction[] => {\n const { nodes } = ctx.get(schemaCtx);\n const actions: Array<WrappedAction & { keyword: string[]; typeName: string }> = [\n {\n id: 'h1',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Large Heading', 'h1'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 1),\n keyword: ['h1', 'large heading'],\n typeName: 'heading',\n },\n {\n id: 'h2',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Medium Heading', 'h2'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 2),\n keyword: ['h2', 'medium heading'],\n typeName: 'heading',\n },\n {\n id: 'h3',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Small Heading', 'h3'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 3),\n keyword: ['h3', 'small heading'],\n typeName: 'heading',\n },\n {\n id: 'bulletList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Bullet List', 'bulletList'),\n command: () => ctx.get(commandsCtx).call('WrapInBulletList'),\n keyword: ['bullet list', 'ul'],\n typeName: 'bullet_list',\n },\n {\n id: 'orderedList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Ordered List', 'orderedList'),\n command: () => ctx.get(commandsCtx).call('WrapInOrderedList'),\n keyword: ['ordered list', 'ol'],\n typeName: 'ordered_list',\n },\n {\n id: 'taskList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Task List', 'taskList'),\n command: () => ctx.get(commandsCtx).call('TurnIntoTaskList'),\n keyword: ['task list', 'task'],\n typeName: 'task_list_item',\n },\n {\n id: 'image',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Image', 'image'),\n command: () => ctx.get(commandsCtx).call('InsertImage'),\n keyword: ['image'],\n typeName: 'image',\n },\n {\n id: 'blockquote',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Quote', 'quote'),\n command: () => ctx.get(commandsCtx).call('WrapInBlockquote'),\n keyword: ['quote', 'blockquote'],\n typeName: 'blockquote',\n },\n {\n id: 'table',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Table', 'table'),\n command: () => ctx.get(commandsCtx).call('InsertTable'),\n keyword: ['table'],\n typeName: 'table',\n },\n {\n id: 'code',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Code Fence', 'code'),\n command: () => ctx.get(commandsCtx).call('TurnIntoCodeFence'),\n keyword: ['code'],\n typeName: 'fence',\n },\n {\n id: 'divider',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Divide Line', 'divider'),\n command: () => ctx.get(commandsCtx).call('InsertHr'),\n keyword: ['divider', 'hr'],\n typeName: 'hr',\n },\n ];\n\n const userInput = input.slice(1).toLocaleLowerCase();\n\n return actions\n .filter((action) => !!nodes[action.typeName] && action.keyword.some((keyword) => keyword.includes(userInput)))\n .map(({ keyword, typeName, ...action }) => action);\n};\n\nexport const defaultConfig: Config = (ctx) => {\n return ({ content, isTopLevel }) => {\n if (!isTopLevel) return null;\n\n if (!content) {\n return { placeholder: 'Type / to use the slash commands...' };\n }\n\n if (content.startsWith('/')) {\n return content === '/'\n ? {\n placeholder: 'Type to filter...',\n actions: defaultActions(ctx),\n }\n : {\n actions: defaultActions(ctx, content),\n };\n }\n\n return null;\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Color, Emotion, ThemeColor, ThemeFont, ThemeManager } from '@milkdown/core';\nimport { findParentNode } from '@milkdown/prose';\nimport { EditorState } from '@milkdown/prose/state';\nimport { Decoration, DecorationSet, EditorView } from '@milkdown/prose/view';\nimport { Utils } from '@milkdown/utils';\n\nimport type { Status } from './status';\n\nexport type Props = ReturnType<typeof createProps>;\n\nconst createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n const typography = themeManager.get(ThemeFont, 'typography');\n\n return css`\n position: relative;\n &::before {\n position: absolute;\n cursor: text;\n font-family: ${typography};\n font-size: 14px;\n color: ${palette('neutral', 0.6)};\n content: attr(data-text);\n height: 100%;\n display: flex;\n align-items: center;\n }\n `;\n};\n\nconst createSlashStyle = (_: ThemeManager, { css }: Emotion) => css`\n &::before {\n left: 8px;\n }\n`;\n\nexport const createProps = (status: Status, utils: Utils) => {\n return {\n handleKeyDown: (_: EditorView, event: Event) => {\n if (status.isEmpty()) {\n return false;\n }\n if (!(event instanceof KeyboardEvent)) {\n return false;\n }\n\n if (!['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {\n return false;\n }\n\n return true;\n },\n decorations: (state: EditorState) => {\n const paragraph = findParentNode(({ type }) => type.name === 'paragraph')(state.selection);\n const uploadPlugin = state.plugins.find(\n (x) => (x as unknown as { key: string }).key === 'MILKDOWN_UPLOAD$',\n );\n const decorations: DecorationSet = uploadPlugin?.getState(state);\n if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {\n status.clear();\n return null;\n }\n\n if (\n !paragraph ||\n paragraph.node.childCount > 1 ||\n state.selection.$from.parentOffset !== paragraph.node.textContent.length ||\n (paragraph.node.firstChild && paragraph.node.firstChild.type.name !== 'text')\n ) {\n status.clear();\n return null;\n }\n\n const { placeholder, actions } = status.update({\n parentNode: state.selection.$from.node(state.selection.$from.depth - 1),\n isTopLevel: state.selection.$from.depth === 1,\n content: paragraph.node.textContent,\n state,\n });\n\n if (!placeholder) {\n return null;\n }\n\n const createDecoration = (text: string, className: (string | undefined)[]) => {\n const pos = paragraph.pos;\n return DecorationSet.create(state.doc, [\n Decoration.node(pos, pos + paragraph.node.nodeSize, {\n class: className.filter((x) => x).join(' '),\n 'data-text': text,\n }),\n ]);\n };\n\n const emptyStyle = utils.getStyle((emotion) => createEmptyStyle(utils.themeManager, emotion));\n const slashStyle = utils.getStyle((emotion) => createSlashStyle(utils.themeManager, emotion));\n\n if (actions.length) {\n return createDecoration(placeholder, [emptyStyle, slashStyle, 'empty-node', 'is-slash']);\n }\n\n return createDecoration(placeholder, [emptyStyle, 'empty-node']);\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport type { Command } from '@milkdown/prose/state';\n\nimport { cleanUpAndCreateNode } from './utility';\n\nexport type Action = {\n id: string;\n $: HTMLElement;\n command: Command;\n};\n\nexport type WrappedAction = Pick<Action, 'id'> & {\n command: () => void;\n dom: HTMLElement;\n};\n\nexport const transformAction = (action: WrappedAction): Action => ({\n id: action.id,\n $: action.dom,\n command: cleanUpAndCreateNode(action.command),\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { StatusConfigBuilder, StatusConfigBuilderParams } from '..';\nimport { Action, transformAction } from '../item';\n\nexport type StatusCtx = {\n placeholder: string | null;\n actions: Action[];\n};\n\nconst createStatusCtx = (): StatusCtx => {\n return {\n placeholder: null,\n actions: [],\n };\n};\n\nexport type Status = ReturnType<typeof createStatus>;\n\nexport const createStatus = (builder: StatusConfigBuilder) => {\n const statusCtx = createStatusCtx();\n\n return {\n get: () => statusCtx,\n clear: () => {\n statusCtx.placeholder = null;\n statusCtx.actions = [];\n },\n update: (builderParams: StatusConfigBuilderParams) => {\n const config = builder(builderParams);\n statusCtx.placeholder = config?.placeholder ?? null;\n statusCtx.actions = (config?.actions ?? []).map(transformAction);\n return statusCtx;\n },\n isEmpty: () => statusCtx.actions.length === 0,\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\ntype Listeners = {\n mouseEnter: EventListener;\n mouseLeave: EventListener;\n};\n\nexport const renderDropdown = (status: Status, dropdownElement: HTMLElement, listeners: Listeners): boolean => {\n const { actions } = status.get();\n\n if (!actions.length) {\n dropdownElement.classList.add('hide');\n return false;\n }\n\n dropdownElement.childNodes.forEach((child) => {\n child.removeEventListener('mouseenter', listeners.mouseEnter);\n child.removeEventListener('mouseleave', listeners.mouseLeave);\n });\n\n while (dropdownElement.firstChild) {\n dropdownElement.firstChild.remove();\n }\n\n actions.forEach(({ $ }) => {\n $.classList.remove('active');\n $.addEventListener('mouseenter', listeners.mouseEnter);\n $.addEventListener('mouseleave', listeners.mouseLeave);\n dropdownElement.appendChild($);\n });\n\n dropdownElement.classList.remove('hide');\n\n const first$ = actions[0];\n if (first$) {\n first$.$.classList.add('active');\n requestAnimationFrame(() => {\n scrollIntoView(first$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n });\n }\n\n return true;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\n\nimport { EditorView } from '@milkdown/prose/view';\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\nexport const createMouseManager = () => {\n let mouseLock = false;\n\n return {\n isLock: () => mouseLock,\n lock: () => {\n mouseLock = true;\n },\n unlock: () => {\n mouseLock = false;\n },\n };\n};\nexport type MouseManager = ReturnType<typeof createMouseManager>;\n\nexport const handleMouseMove = (mouseManager: MouseManager) => () => {\n mouseManager.unlock();\n};\n\nexport const handleMouseEnter = (status: Status, mouseManager: MouseManager) => (e: MouseEvent) => {\n if (mouseManager.isLock()) return;\n const { actions } = status.get();\n const active = actions.findIndex((x) => x.$.classList.contains('active'));\n const active$ = actions[active];\n if (active$ && active >= 0) {\n active$.$.classList.remove('active');\n }\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.add('active');\n};\n\nexport const handleMouseLeave = () => (e: MouseEvent) => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.remove('active');\n};\n\nexport const handleClick =\n (status: Status, view: EditorView, dropdownElement: HTMLElement) =>\n (e: Event): void => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n if (!view) return;\n\n const stop = () => {\n e.stopPropagation();\n e.preventDefault();\n };\n\n const { actions } = status.get();\n\n const el = Object.values(actions).find(({ $ }) => $.contains(target));\n if (!el) {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n stop();\n\n return;\n }\n\n stop();\n el.command(view.state, view.dispatch, view);\n };\n\nexport const handleKeydown =\n (status: Status, view: EditorView, dropdownElement: HTMLElement, mouseManager: MouseManager) => (e: Event) => {\n if (!(e instanceof KeyboardEvent)) return;\n if (!mouseManager.isLock()) mouseManager.lock();\n\n const { key } = e;\n if (status.isEmpty()) return;\n if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(key)) return;\n\n const { actions } = status.get();\n\n let active = actions.findIndex(({ $ }) => $.classList.contains('active'));\n if (active < 0) active = 0;\n\n const moveActive = (next: number) => {\n const active$ = actions[active];\n const next$ = actions[next];\n if (!active$ || !next$) return;\n active$.$.classList.remove('active');\n next$.$.classList.add('active');\n scrollIntoView(next$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n };\n\n if (key === 'ArrowDown') {\n const next = active === actions.length - 1 ? 0 : active + 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'ArrowUp') {\n const next = active === 0 ? actions.length - 1 : active - 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'Escape') {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n return;\n }\n\n const active$ = actions[active];\n if (!active$) return;\n active$.command(view.state, view.dispatch, view);\n active$.$.classList.remove('active');\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { missingRootElement } from '@milkdown/exception';\nimport { calculateNodePosition } from '@milkdown/prose';\nimport { EditorView } from '@milkdown/prose/view';\nimport { Utils } from '@milkdown/utils';\n\nimport { createDropdown } from '../utility';\nimport { renderDropdown } from './dropdown';\nimport {\n createMouseManager,\n handleClick,\n handleKeydown,\n handleMouseEnter,\n handleMouseLeave,\n handleMouseMove,\n} from './input';\nimport { Status } from './status';\n\nconst calculatePosition = (view: EditorView, dropdownElement: HTMLElement) => {\n calculateNodePosition(view, dropdownElement, (selected, target, parent) => {\n const $editor = dropdownElement.parentElement;\n if (!$editor) {\n throw missingRootElement();\n }\n\n let left = selected.left - parent.left;\n let top = selected.bottom - parent.top + 14 + $editor.scrollTop;\n\n if (left < 0) {\n left = 0;\n }\n\n if (parent.height + parent.top - selected.bottom < target.height) {\n const topOffset = selected.top - parent.top - target.height - 14 + $editor.scrollTop;\n if (topOffset > 0) {\n top = topOffset;\n }\n }\n return [top, left];\n });\n};\n\nexport const createView = (status: Status, view: EditorView, utils: Utils, className: string) => {\n const wrapper = view.dom.parentNode;\n if (!wrapper) return {};\n\n const dropdownElement = createDropdown(utils, className);\n const mouseManager = createMouseManager();\n wrapper.appendChild(dropdownElement);\n\n const _mouseMove = handleMouseMove(mouseManager);\n const _mouseDown = handleClick(status, view, dropdownElement);\n const _keydown = handleKeydown(status, view, dropdownElement, mouseManager);\n const _mouseEnter = handleMouseEnter(status, mouseManager);\n const _mouseLeave = handleMouseLeave();\n\n wrapper.addEventListener('mousemove', _mouseMove);\n wrapper.addEventListener('mousedown', _mouseDown);\n wrapper.addEventListener('keydown', _keydown);\n\n return {\n update: (view: EditorView) => {\n const show = renderDropdown(status, dropdownElement, {\n mouseEnter: _mouseEnter as EventListener,\n mouseLeave: _mouseLeave as EventListener,\n });\n\n if (!show) return;\n\n calculatePosition(view, dropdownElement);\n },\n\n destroy: () => {\n wrapper.removeEventListener('mousemove', _mouseMove);\n wrapper.removeEventListener('mousedown', _mouseDown);\n wrapper.removeEventListener('keydown', _keydown);\n dropdownElement.remove();\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Plugin, PluginKey } from '@milkdown/prose/state';\nimport { Utils } from '@milkdown/utils';\n\nimport type { StatusConfigBuilder } from '..';\nimport { createProps } from './props';\nimport { createStatus } from './status';\nimport { createView } from './view';\n\nexport const key = 'MILKDOWN_SLASH';\n\nexport const createSlashPlugin = (utils: Utils, builder: StatusConfigBuilder, className: string) => {\n const status = createStatus(builder);\n\n return new Plugin({\n key: new PluginKey(key),\n props: createProps(status, utils),\n view: (view) => createView(status, view, utils, className),\n });\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { AtomList, createPlugin } from '@milkdown/utils';\n\nimport type { Config } from './config';\nimport { defaultConfig } from './config';\nimport { createSlashPlugin } from './prose-plugin';\n\nexport type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';\nexport { defaultActions, defaultConfig } from './config';\nexport type { Action, WrappedAction } from './item';\nexport { createDropdownItem } from './utility';\n\nexport type Options = {\n config: Config;\n};\n\nexport const slashPlugin = createPlugin<string, Options>((utils, options) => {\n const slashConfig = options?.config ?? defaultConfig;\n\n return {\n prosePlugins: (_, ctx) => {\n const config = slashConfig(ctx);\n\n const plugin = createSlashPlugin(utils, config, 'slash-dropdown');\n\n return [plugin];\n },\n };\n});\n\nexport const slash = AtomList.create([slashPlugin()]);\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,IAAY,CAAC,GAA4B,EAAE,aAAmB;AAC1D,QAAA,IAAU,CAAC,GAAc,IAAU,MAAM,EAAa,IAAI,GAAY,CAAC,GAAO,CAAO,CAAC;AACrF,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUgB,EAAa,IAAI,GAAW,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAO1C,EAAQ,WAAW,IAAI;AAAA;AAAA;AAAA;AAAA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,CAAe;AAAA,IAC3C;AAAA,IAEA,SAAS,MAAM;AACH,QAAA,oBAAoB,aAAa,CAAU,GAC3C,EAAA,oBAAoB,aAAa,CAAU,GAC3C,EAAA,oBAAoB,WAAW,CAAQ,GAC/C,EAAgB,OAAO;AAAA,IAC3B;AAAA,EAAA;AAER,GCtEa,KAAM,kBAEN,KAAoB,CAAC,GAAc,GAA8B,MAAsB;AAC1F,QAAA,IAAS,EAAa,CAAO;AAEnC,SAAO,IAAI,EAAO;AAAA,IACd,KAAK,IAAI,EAAU,EAAG;AAAA,IACtB,OAAO,EAAY,GAAQ,CAAK;AAAA,IAChC,MAAM,CAAC,MAAS,GAAW,GAAQ,GAAM,GAAO,CAAS;AAAA,EAAA,CAC5D;AACL,GCHa,KAAc,EAA8B,CAAC,GAAO,MAAY;;AACnE,QAAA,IAAc,4BAAS,WAAT,WAAmB;AAEhC,SAAA;AAAA,IACH,cAAc,CAAC,GAAG,MAAQ;AAChB,YAAA,IAAS,EAAY,CAAG;AAI9B,aAAO,CAFQ,GAAkB,GAAO,GAAQ,gBAAgB,CAElD;AAAA,IAClB;AAAA,EAAA;AAER,CAAC,GAEY,KAAQ,EAAS,OAAO,CAAC,GAAA,CAAa,CAAC;"}
|
package/lib/item.d.ts
CHANGED
package/lib/item.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIrD,oBAAY,MAAM,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,WAAW,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,oBAAY,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG;IAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,GAAG,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,aAAa,KAAG,MAItD,CAAC"}
|
|
@@ -2,5 +2,5 @@ import { Plugin } from '@milkdown/prose/state';
|
|
|
2
2
|
import { Utils } from '@milkdown/utils';
|
|
3
3
|
import type { StatusConfigBuilder } from '..';
|
|
4
4
|
export declare const key = "MILKDOWN_SLASH";
|
|
5
|
-
export declare const createSlashPlugin: (utils: Utils, builder: StatusConfigBuilder, className: string) => Plugin<any
|
|
5
|
+
export declare const createSlashPlugin: (utils: Utils, builder: StatusConfigBuilder, className: string) => Plugin<any>;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAa,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAK9C,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC,eAAO,MAAM,iBAAiB,UAAW,KAAK,WAAW,mBAAmB,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAa,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAK9C,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC,eAAO,MAAM,iBAAiB,UAAW,KAAK,WAAW,mBAAmB,aAAa,MAAM,gBAQ9F,CAAC"}
|
|
@@ -5,6 +5,6 @@ import type { Status } from './status';
|
|
|
5
5
|
export declare type Props = ReturnType<typeof createProps>;
|
|
6
6
|
export declare const createProps: (status: Status, utils: Utils) => {
|
|
7
7
|
handleKeyDown: (_: EditorView, event: Event) => boolean;
|
|
8
|
-
decorations: (state: EditorState) => DecorationSet
|
|
8
|
+
decorations: (state: EditorState) => DecorationSet | null;
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/view.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/view.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAYxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA0BlC,eAAO,MAAM,UAAU,WAAY,MAAM,QAAQ,UAAU,SAAS,KAAK,aAAa,MAAM;;;;mBAmBrE,UAAU;;CAkBhC,CAAC"}
|
package/lib/utility.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ThemeManager } from '@milkdown/core';
|
|
2
2
|
import type { Icon } from '@milkdown/design-system';
|
|
3
|
-
import type { Command } from '@milkdown/prose/commands';
|
|
4
3
|
import type { Node } from '@milkdown/prose/model';
|
|
4
|
+
import type { Command } from '@milkdown/prose/state';
|
|
5
5
|
import type { Utils } from '@milkdown/utils';
|
|
6
6
|
export declare const createDropdown: (utils: Utils, className: string) => HTMLDivElement;
|
|
7
7
|
declare type ItemOptions = {
|
|
8
8
|
textClassName: string;
|
|
9
9
|
};
|
|
10
|
-
export declare const createDropdownItem: (themeManager: ThemeManager, text: string, icon: Icon, options?: Partial<ItemOptions>
|
|
10
|
+
export declare const createDropdownItem: (themeManager: ThemeManager, text: string, icon: Icon, options?: Partial<ItemOptions>) => HTMLDivElement;
|
|
11
11
|
export declare const getDepth: (node: Node) => number;
|
|
12
12
|
export declare const cleanUpAndCreateNode: (createCommand: () => void) => Command;
|
|
13
13
|
export {};
|
package/lib/utility.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI7C,eAAO,MAAM,cAAc,UAAW,KAAK,aAAa,MAAM,mBAe7D,CAAC;AAEF,aAAK,WAAW,GAAG;IACf,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC;AACF,eAAO,MAAM,kBAAkB,iBACb,YAAY,QACpB,MAAM,QACN,IAAI,YACA,QAAQ,WAAW,CAAC,mBAsBjC,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,IAAI,WASlC,CAAC;AAUF,eAAO,MAAM,oBAAoB,kBACb,MAAM,IAAI,KAAG,OAO5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/plugin-slash",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.es.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -15,18 +15,19 @@
|
|
|
15
15
|
"milkdown plugin"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@milkdown/core": "6.1
|
|
19
|
-
"@milkdown/prose": "6.1
|
|
20
|
-
"@milkdown/design-system": "6.1
|
|
18
|
+
"@milkdown/core": "6.3.1",
|
|
19
|
+
"@milkdown/prose": "6.3.1",
|
|
20
|
+
"@milkdown/design-system": "6.3.1"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@milkdown/core": "^6.0.1",
|
|
24
24
|
"@milkdown/prose": "^6.0.1"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@milkdown/utils": "6.1
|
|
27
|
+
"@milkdown/utils": "6.3.1",
|
|
28
|
+
"@milkdown/exception": "6.3.1",
|
|
28
29
|
"smooth-scroll-into-view-if-needed": "^1.1.32",
|
|
29
|
-
"tslib": "^2.
|
|
30
|
+
"tslib": "^2.4.0"
|
|
30
31
|
},
|
|
31
32
|
"nx": {
|
|
32
33
|
"targets": {
|
package/src/item.ts
CHANGED
|
@@ -19,7 +19,7 @@ const createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {
|
|
|
19
19
|
position: absolute;
|
|
20
20
|
cursor: text;
|
|
21
21
|
font-family: ${typography};
|
|
22
|
-
font-size:
|
|
22
|
+
font-size: 14px;
|
|
23
23
|
color: ${palette('neutral', 0.6)};
|
|
24
24
|
content: attr(data-text);
|
|
25
25
|
height: 100%;
|
|
@@ -31,7 +31,7 @@ const createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {
|
|
|
31
31
|
|
|
32
32
|
const createSlashStyle = (_: ThemeManager, { css }: Emotion) => css`
|
|
33
33
|
&::before {
|
|
34
|
-
left:
|
|
34
|
+
left: 8px;
|
|
35
35
|
}
|
|
36
36
|
`;
|
|
37
37
|
|
|
@@ -59,7 +59,7 @@ export const createProps = (status: Status, utils: Utils) => {
|
|
|
59
59
|
const decorations: DecorationSet = uploadPlugin?.getState(state);
|
|
60
60
|
if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {
|
|
61
61
|
status.clear();
|
|
62
|
-
return;
|
|
62
|
+
return null;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (
|
|
@@ -69,7 +69,7 @@ export const createProps = (status: Status, utils: Utils) => {
|
|
|
69
69
|
(paragraph.node.firstChild && paragraph.node.firstChild.type.name !== 'text')
|
|
70
70
|
) {
|
|
71
71
|
status.clear();
|
|
72
|
-
return;
|
|
72
|
+
return null;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const { placeholder, actions } = status.update({
|
package/src/prose-plugin/view.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
+
import { missingRootElement } from '@milkdown/exception';
|
|
2
3
|
import { calculateNodePosition } from '@milkdown/prose';
|
|
3
4
|
import { EditorView } from '@milkdown/prose/view';
|
|
4
5
|
import { Utils } from '@milkdown/utils';
|
|
@@ -19,7 +20,7 @@ const calculatePosition = (view: EditorView, dropdownElement: HTMLElement) => {
|
|
|
19
20
|
calculateNodePosition(view, dropdownElement, (selected, target, parent) => {
|
|
20
21
|
const $editor = dropdownElement.parentElement;
|
|
21
22
|
if (!$editor) {
|
|
22
|
-
throw
|
|
23
|
+
throw missingRootElement();
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
let left = selected.left - parent.left;
|
package/src/style.ts
CHANGED
|
@@ -16,15 +16,15 @@ const itemStyle = (themeManager: ThemeManager, { css }: Emotion) => {
|
|
|
16
16
|
return css`
|
|
17
17
|
.slash-dropdown-item {
|
|
18
18
|
display: flex;
|
|
19
|
-
gap:
|
|
20
|
-
height:
|
|
21
|
-
padding: 0
|
|
19
|
+
gap: 32px;
|
|
20
|
+
height: 48px;
|
|
21
|
+
padding: 0 16px;
|
|
22
22
|
align-items: center;
|
|
23
23
|
justify-content: flex-start;
|
|
24
24
|
cursor: pointer;
|
|
25
|
-
line-height:
|
|
25
|
+
line-height: 48px;
|
|
26
26
|
font-family: ${themeManager.get(ThemeFont, 'typography')};
|
|
27
|
-
font-size:
|
|
27
|
+
font-size: 14px;
|
|
28
28
|
|
|
29
29
|
transition: all 0.2s ease-in-out;
|
|
30
30
|
|
|
@@ -53,8 +53,8 @@ export const injectStyle = (themeManager: ThemeManager, emotion: Emotion) => {
|
|
|
53
53
|
const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);
|
|
54
54
|
|
|
55
55
|
return emotion.css`
|
|
56
|
-
width:
|
|
57
|
-
max-height:
|
|
56
|
+
width: 320px;
|
|
57
|
+
max-height: 320px;
|
|
58
58
|
overflow-y: auto;
|
|
59
59
|
border-radius: ${themeManager.get(ThemeSize, 'radius')};
|
|
60
60
|
position: absolute;
|
package/src/utility.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { ThemeIcon, ThemeManager } from '@milkdown/core';
|
|
3
3
|
import type { Icon } from '@milkdown/design-system';
|
|
4
|
-
import
|
|
4
|
+
import { missingIcon } from '@milkdown/exception';
|
|
5
5
|
import type { Node } from '@milkdown/prose/model';
|
|
6
|
+
import type { Command } from '@milkdown/prose/state';
|
|
6
7
|
import type { Utils } from '@milkdown/utils';
|
|
7
8
|
|
|
8
9
|
import { injectStyle } from './style';
|
|
@@ -39,11 +40,10 @@ export const createDropdownItem = (
|
|
|
39
40
|
div.setAttribute('role', 'option');
|
|
40
41
|
div.classList.add('slash-dropdown-item');
|
|
41
42
|
|
|
42
|
-
// const iconSpan = themeManager.slots.icon(icon);
|
|
43
43
|
const iconSpan = themeManager.get(ThemeIcon, icon);
|
|
44
44
|
|
|
45
45
|
if (!iconSpan) {
|
|
46
|
-
throw
|
|
46
|
+
throw missingIcon(icon);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const textSpan = document.createElement('span');
|