@milkdown/plugin-slash 6.4.1 → 6.5.0
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 +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +109 -109
- package/lib/index.es.js.map +1 -1
- package/lib/prose-plugin/index.d.ts +2 -1
- package/lib/prose-plugin/index.d.ts.map +1 -1
- package/lib/prose-plugin/view.d.ts +3 -1
- package/lib/prose-plugin/view.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +4 -1
- package/src/prose-plugin/index.ts +8 -3
- package/src/prose-plugin/view.ts +11 -3
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { AtomList } from '@milkdown/utils';
|
|
2
2
|
import type { Config } from './config';
|
|
3
|
+
import { CalcPosition } from './prose-plugin/view';
|
|
3
4
|
export type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';
|
|
4
5
|
export { defaultActions, defaultConfig } from './config';
|
|
5
6
|
export type { Action, WrappedAction } from './item';
|
|
6
7
|
export { createDropdownItem } from './utility';
|
|
7
8
|
export declare type Options = {
|
|
8
9
|
config: Config;
|
|
10
|
+
calcPosition: CalcPosition;
|
|
9
11
|
};
|
|
10
12
|
export declare const slashPlugin: import("@milkdown/utils").WithExtend<string, Options, import("@milkdown/utils").TypeMapping<string, string>, import("@milkdown/utils").PluginRest<string, string>>;
|
|
11
13
|
export declare const slash: AtomList<import("@milkdown/utils").Metadata<import("@milkdown/utils").GetPlugin<string, Options>> & import("@milkdown/core").MilkdownPlugin>;
|
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;
|
|
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;AAGvC,OAAO,EAAE,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAExE,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;IACf,YAAY,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,WAAW,oKAatB,CAAC;AAEH,eAAO,MAAM,KAAK,8IAAmC,CAAC"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
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
|
|
2
|
+
import { ThemeSize as $, ThemeBorder as C, ThemeShadow as N, ThemeScrollbar as S, ThemeFont as k, ThemeColor as y, ThemeIcon as T, schemaCtx as I, themeManagerCtx as m, commandsCtx as u } from "@milkdown/core";
|
|
3
3
|
import { missingIcon as A, missingRootElement as D } from "@milkdown/exception";
|
|
4
4
|
import { Plugin as x, PluginKey as _ } from "@milkdown/prose/state";
|
|
5
|
-
import { findParentNode as M, calculateNodePosition as
|
|
6
|
-
import { DecorationSet as
|
|
7
|
-
import
|
|
5
|
+
import { findParentNode as M, calculateNodePosition as P } from "@milkdown/prose";
|
|
6
|
+
import { DecorationSet as H, Decoration as O } from "@milkdown/prose/view";
|
|
7
|
+
import w from "smooth-scroll-into-view-if-needed";
|
|
8
8
|
const q = (e, { css: t }) => {
|
|
9
|
-
const
|
|
9
|
+
const o = (n, s = 1) => e.get(y, [n, s]);
|
|
10
10
|
return t`
|
|
11
11
|
.slash-dropdown-item {
|
|
12
12
|
display: flex;
|
|
@@ -17,14 +17,14 @@ const q = (e, { css: t }) => {
|
|
|
17
17
|
justify-content: flex-start;
|
|
18
18
|
cursor: pointer;
|
|
19
19
|
line-height: 48px;
|
|
20
|
-
font-family: ${e.get(
|
|
20
|
+
font-family: ${e.get(k, "typography")};
|
|
21
21
|
font-size: 14px;
|
|
22
22
|
|
|
23
23
|
transition: all 0.2s ease-in-out;
|
|
24
24
|
|
|
25
25
|
&,
|
|
26
26
|
.icon {
|
|
27
|
-
color: ${
|
|
27
|
+
color: ${o("neutral", 0.87)};
|
|
28
28
|
transition: all 0.2s ease-in-out;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -33,23 +33,23 @@ const q = (e, { css: t }) => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&.active {
|
|
36
|
-
background: ${
|
|
36
|
+
background: ${o("secondary", 0.12)};
|
|
37
37
|
&,
|
|
38
38
|
.icon {
|
|
39
|
-
color: ${
|
|
39
|
+
color: ${o("primary")};
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
`;
|
|
44
44
|
}, K = (e, t) => {
|
|
45
|
-
const
|
|
45
|
+
const o = (n, s = 1) => e.get(y, [n, s]);
|
|
46
46
|
return t.css`
|
|
47
47
|
width: 320px;
|
|
48
48
|
max-height: 320px;
|
|
49
49
|
overflow-y: auto;
|
|
50
50
|
border-radius: ${e.get($, "radius")};
|
|
51
51
|
position: absolute;
|
|
52
|
-
background: ${
|
|
52
|
+
background: ${o("surface")};
|
|
53
53
|
|
|
54
54
|
${e.get(C, void 0)}
|
|
55
55
|
${e.get(N, void 0)}
|
|
@@ -62,25 +62,25 @@ const q = (e, { css: t }) => {
|
|
|
62
62
|
${q(e, t)}
|
|
63
63
|
`;
|
|
64
64
|
}, U = (e, t) => {
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
}),
|
|
70
|
-
}, p = (e, t,
|
|
65
|
+
const o = document.createElement("div");
|
|
66
|
+
return o.setAttribute("role", "listbox"), o.setAttribute("tabindex", "-1"), e.themeManager.onFlush(() => {
|
|
67
|
+
const n = e.getStyle((s) => K(e.themeManager, s));
|
|
68
|
+
n && o.classList.add(n);
|
|
69
|
+
}), o.classList.add(e.getClassName({}, t), "hide"), o;
|
|
70
|
+
}, p = (e, t, o, n) => {
|
|
71
71
|
var l;
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const a = e.get(T,
|
|
72
|
+
const s = (l = n == null ? void 0 : n.textClassName) != null ? l : "text", r = document.createElement("div");
|
|
73
|
+
r.setAttribute("role", "option"), r.classList.add("slash-dropdown-item");
|
|
74
|
+
const a = e.get(T, o);
|
|
75
75
|
if (!a)
|
|
76
|
-
throw A(
|
|
76
|
+
throw A(o);
|
|
77
77
|
const i = document.createElement("span");
|
|
78
|
-
return i.textContent = t, i.className =
|
|
78
|
+
return i.textContent = t, i.className = s, r.appendChild(a.dom), r.appendChild(i), r;
|
|
79
79
|
}, W = (e, t) => {
|
|
80
|
-
const { selection:
|
|
81
|
-
return t == null || t(
|
|
82
|
-
}, F = (e) => (t,
|
|
83
|
-
const { nodes:
|
|
80
|
+
const { selection: o } = e, { $from: n } = o, s = e.tr.deleteRange(n.start(), n.pos);
|
|
81
|
+
return t == null || t(s), !1;
|
|
82
|
+
}, F = (e) => (t, o, n) => (n && (W(t, o), e()), !0), L = (e, t = "/") => {
|
|
83
|
+
const { nodes: o } = e.get(I), n = [
|
|
84
84
|
{
|
|
85
85
|
id: "h1",
|
|
86
86
|
dom: p(e.get(m), "Large Heading", "h1"),
|
|
@@ -158,23 +158,23 @@ const q = (e, { css: t }) => {
|
|
|
158
158
|
keyword: ["divider", "hr"],
|
|
159
159
|
typeName: "hr"
|
|
160
160
|
}
|
|
161
|
-
],
|
|
162
|
-
return
|
|
163
|
-
}, j = (e) => ({ content: t, isTopLevel:
|
|
161
|
+
], s = t.slice(1).toLocaleLowerCase();
|
|
162
|
+
return n.filter((r) => !!o[r.typeName] && r.keyword.some((a) => a.includes(s))).map(({ keyword: r, typeName: a, ...i }) => i);
|
|
163
|
+
}, j = (e) => ({ content: t, isTopLevel: o }) => o ? t ? t.startsWith("/") ? t === "/" ? {
|
|
164
164
|
placeholder: "Type to filter...",
|
|
165
|
-
actions:
|
|
165
|
+
actions: L(e)
|
|
166
166
|
} : {
|
|
167
|
-
actions:
|
|
167
|
+
actions: L(e, t)
|
|
168
168
|
} : null : { placeholder: "Type / to use the slash commands..." } : null, z = (e, { css: t }) => {
|
|
169
|
-
const
|
|
169
|
+
const o = (s, r = 1) => e.get(y, [s, r]), n = e.get(k, "typography");
|
|
170
170
|
return t`
|
|
171
171
|
position: relative;
|
|
172
172
|
&::before {
|
|
173
173
|
position: absolute;
|
|
174
174
|
cursor: text;
|
|
175
|
-
font-family: ${
|
|
175
|
+
font-family: ${n};
|
|
176
176
|
font-size: 14px;
|
|
177
|
-
color: ${
|
|
177
|
+
color: ${o("neutral", 0.6)};
|
|
178
178
|
content: attr(data-text);
|
|
179
179
|
height: 100%;
|
|
180
180
|
display: flex;
|
|
@@ -186,24 +186,24 @@ const q = (e, { css: t }) => {
|
|
|
186
186
|
left: 8px;
|
|
187
187
|
}
|
|
188
188
|
`, R = (e, t) => ({
|
|
189
|
-
handleKeyDown: (
|
|
190
|
-
decorations: (
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
189
|
+
handleKeyDown: (o, n) => !(e.isEmpty() || !(n instanceof KeyboardEvent) || !["ArrowUp", "ArrowDown", "Enter"].includes(n.key)),
|
|
190
|
+
decorations: (o) => {
|
|
191
|
+
const n = M(({ type: c }) => c.name === "paragraph")(o.selection), s = o.plugins.find((c) => c.key === "MILKDOWN_UPLOAD$"), r = s == null ? void 0 : s.getState(o);
|
|
192
|
+
if (r != null && r.find(o.selection.from, o.selection.to).length > 0 || !n || n.node.childCount > 1 || o.selection.$from.parentOffset !== n.node.textContent.length || n.node.firstChild && n.node.firstChild.type.name !== "text")
|
|
193
193
|
return e.clear(), null;
|
|
194
194
|
const { placeholder: a, actions: i } = e.update({
|
|
195
|
-
parentNode:
|
|
196
|
-
isTopLevel:
|
|
197
|
-
content:
|
|
198
|
-
state:
|
|
195
|
+
parentNode: o.selection.$from.node(o.selection.$from.depth - 1),
|
|
196
|
+
isTopLevel: o.selection.$from.depth === 1,
|
|
197
|
+
content: n.node.textContent,
|
|
198
|
+
state: o
|
|
199
199
|
});
|
|
200
200
|
if (!a)
|
|
201
201
|
return null;
|
|
202
202
|
const l = (c, g) => {
|
|
203
|
-
const h =
|
|
204
|
-
return
|
|
205
|
-
O.node(h, h +
|
|
206
|
-
class: g.filter((
|
|
203
|
+
const h = n.pos;
|
|
204
|
+
return H.create(o.doc, [
|
|
205
|
+
O.node(h, h + n.node.nodeSize, {
|
|
206
|
+
class: g.filter((v) => v).join(" "),
|
|
207
207
|
"data-text": c
|
|
208
208
|
})
|
|
209
209
|
]);
|
|
@@ -224,27 +224,27 @@ const q = (e, { css: t }) => {
|
|
|
224
224
|
clear: () => {
|
|
225
225
|
t.placeholder = null, t.actions = [];
|
|
226
226
|
},
|
|
227
|
-
update: (
|
|
228
|
-
var
|
|
229
|
-
const
|
|
230
|
-
return t.placeholder = (
|
|
227
|
+
update: (o) => {
|
|
228
|
+
var s, r;
|
|
229
|
+
const n = e(o);
|
|
230
|
+
return t.placeholder = (s = n == null ? void 0 : n.placeholder) != null ? s : null, t.actions = ((r = n == null ? void 0 : n.actions) != null ? r : []).map(V), t;
|
|
231
231
|
},
|
|
232
232
|
isEmpty: () => t.actions.length === 0
|
|
233
233
|
};
|
|
234
|
-
}, J = (e, t,
|
|
235
|
-
const { actions:
|
|
236
|
-
if (!
|
|
234
|
+
}, J = (e, t, o) => {
|
|
235
|
+
const { actions: n } = e.get();
|
|
236
|
+
if (!n.length)
|
|
237
237
|
return t.classList.add("hide"), !1;
|
|
238
|
-
for (t.childNodes.forEach((
|
|
239
|
-
|
|
238
|
+
for (t.childNodes.forEach((r) => {
|
|
239
|
+
r.removeEventListener("mouseenter", o.mouseEnter), r.removeEventListener("mouseleave", o.mouseLeave);
|
|
240
240
|
}); t.firstChild; )
|
|
241
241
|
t.firstChild.remove();
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
n.forEach(({ $: r }) => {
|
|
243
|
+
r.classList.remove("active"), r.addEventListener("mouseenter", o.mouseEnter), r.addEventListener("mouseleave", o.mouseLeave), t.appendChild(r);
|
|
244
244
|
}), t.classList.remove("hide");
|
|
245
|
-
const
|
|
246
|
-
return
|
|
247
|
-
|
|
245
|
+
const s = n[0];
|
|
246
|
+
return s && (s.$.classList.add("active"), requestAnimationFrame(() => {
|
|
247
|
+
w(s.$, {
|
|
248
248
|
scrollMode: "if-needed",
|
|
249
249
|
block: "nearest",
|
|
250
250
|
inline: "nearest"
|
|
@@ -263,116 +263,116 @@ const q = (e, { css: t }) => {
|
|
|
263
263
|
};
|
|
264
264
|
}, Y = (e) => () => {
|
|
265
265
|
e.unlock();
|
|
266
|
-
}, Z = (e, t) => (
|
|
266
|
+
}, Z = (e, t) => (o) => {
|
|
267
267
|
if (t.isLock())
|
|
268
268
|
return;
|
|
269
|
-
const { actions:
|
|
270
|
-
|
|
271
|
-
const { target: a } =
|
|
269
|
+
const { actions: n } = e.get(), s = n.findIndex((i) => i.$.classList.contains("active")), r = n[s];
|
|
270
|
+
r && s >= 0 && r.$.classList.remove("active");
|
|
271
|
+
const { target: a } = o;
|
|
272
272
|
a instanceof HTMLElement && a.classList.add("active");
|
|
273
273
|
}, ee = () => (e) => {
|
|
274
274
|
const { target: t } = e;
|
|
275
275
|
t instanceof HTMLElement && t.classList.remove("active");
|
|
276
|
-
}, te = (e, t,
|
|
277
|
-
const { target:
|
|
278
|
-
if (!(
|
|
276
|
+
}, te = (e, t, o) => (n) => {
|
|
277
|
+
const { target: s } = n;
|
|
278
|
+
if (!(s instanceof HTMLElement) || !t)
|
|
279
279
|
return;
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
}, { actions: a } = e.get(), i = Object.values(a).find(({ $: l }) => l.contains(
|
|
280
|
+
const r = () => {
|
|
281
|
+
n.stopPropagation(), n.preventDefault();
|
|
282
|
+
}, { actions: a } = e.get(), i = Object.values(a).find(({ $: l }) => l.contains(s));
|
|
283
283
|
if (!i) {
|
|
284
284
|
if (e.isEmpty())
|
|
285
285
|
return;
|
|
286
|
-
e.clear(),
|
|
286
|
+
e.clear(), o.classList.add("hide"), r();
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
}, oe = (e, t,
|
|
291
|
-
if (!(
|
|
289
|
+
r(), i.command(t.state, t.dispatch, t);
|
|
290
|
+
}, oe = (e, t, o, n) => (s) => {
|
|
291
|
+
if (!(s instanceof KeyboardEvent))
|
|
292
292
|
return;
|
|
293
|
-
|
|
294
|
-
const { key:
|
|
295
|
-
if (e.isEmpty() || !["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(
|
|
293
|
+
n.isLock() || n.lock();
|
|
294
|
+
const { key: r } = s;
|
|
295
|
+
if (e.isEmpty() || !["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(r))
|
|
296
296
|
return;
|
|
297
297
|
const { actions: a } = e.get();
|
|
298
298
|
let i = a.findIndex(({ $: d }) => d.classList.contains("active"));
|
|
299
299
|
i < 0 && (i = 0);
|
|
300
300
|
const l = (d) => {
|
|
301
301
|
const c = a[i], g = a[d];
|
|
302
|
-
!c || !g || (c.$.classList.remove("active"), g.$.classList.add("active"),
|
|
302
|
+
!c || !g || (c.$.classList.remove("active"), g.$.classList.add("active"), w(g.$, {
|
|
303
303
|
scrollMode: "if-needed",
|
|
304
304
|
block: "nearest",
|
|
305
305
|
inline: "nearest"
|
|
306
306
|
}));
|
|
307
307
|
};
|
|
308
|
-
if (
|
|
308
|
+
if (r === "ArrowDown") {
|
|
309
309
|
const d = i === a.length - 1 ? 0 : i + 1;
|
|
310
310
|
l(d);
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
|
-
if (
|
|
313
|
+
if (r === "ArrowUp") {
|
|
314
314
|
const d = i === 0 ? a.length - 1 : i - 1;
|
|
315
315
|
l(d);
|
|
316
316
|
return;
|
|
317
317
|
}
|
|
318
|
-
if (
|
|
318
|
+
if (r === "Escape") {
|
|
319
319
|
if (e.isEmpty())
|
|
320
320
|
return;
|
|
321
|
-
e.clear(),
|
|
321
|
+
e.clear(), o.classList.add("hide");
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
324
|
const f = a[i];
|
|
325
325
|
!f || (f.command(t.state, t.dispatch, t), f.$.classList.remove("active"));
|
|
326
326
|
}, ne = (e, t) => {
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
if (!
|
|
327
|
+
P(e, t, (o, n, s) => {
|
|
328
|
+
const r = t.parentElement;
|
|
329
|
+
if (!r)
|
|
330
330
|
throw D();
|
|
331
|
-
let a =
|
|
332
|
-
if (a < 0 && (a = 0),
|
|
333
|
-
const l =
|
|
331
|
+
let a = o.left - s.left, i = o.bottom - s.top + 14 + r.scrollTop;
|
|
332
|
+
if (a < 0 && (a = 0), s.height + s.top - o.bottom < n.height) {
|
|
333
|
+
const l = o.top - s.top - n.height - 14 + r.scrollTop;
|
|
334
334
|
l > 0 && (i = l);
|
|
335
335
|
}
|
|
336
336
|
return [i, a];
|
|
337
337
|
});
|
|
338
|
-
}, re = (e, t, n,
|
|
338
|
+
}, re = (e, t, o, n, s) => {
|
|
339
339
|
const r = t.dom.parentNode;
|
|
340
340
|
if (!r)
|
|
341
341
|
return {};
|
|
342
|
-
const
|
|
343
|
-
r.appendChild(
|
|
344
|
-
const
|
|
345
|
-
return r.addEventListener("mousemove",
|
|
346
|
-
update: (
|
|
347
|
-
!J(e,
|
|
348
|
-
mouseEnter:
|
|
349
|
-
mouseLeave:
|
|
350
|
-
}) ||
|
|
342
|
+
const a = U(o, n), i = X();
|
|
343
|
+
r.appendChild(a);
|
|
344
|
+
const l = Y(i), f = te(e, t, a), d = oe(e, t, a, i), c = Z(e, i), g = ee();
|
|
345
|
+
return r.addEventListener("mousemove", l), r.addEventListener("mousedown", f), r.addEventListener("keydown", d), {
|
|
346
|
+
update: (h) => {
|
|
347
|
+
!J(e, a, {
|
|
348
|
+
mouseEnter: c,
|
|
349
|
+
mouseLeave: g
|
|
350
|
+
}) || s(h, a);
|
|
351
351
|
},
|
|
352
352
|
destroy: () => {
|
|
353
|
-
r.removeEventListener("mousemove",
|
|
353
|
+
r.removeEventListener("mousemove", l), r.removeEventListener("mousedown", f), r.removeEventListener("keydown", d), a.remove();
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
|
-
}, se = "MILKDOWN_SLASH", ae = (e, t, n) => {
|
|
357
|
-
const
|
|
356
|
+
}, se = "MILKDOWN_SLASH", ae = (e, t, o, n) => {
|
|
357
|
+
const s = G(t);
|
|
358
358
|
return new x({
|
|
359
359
|
key: new _(se),
|
|
360
|
-
props: R(
|
|
361
|
-
view: (r) => re(
|
|
360
|
+
props: R(s, e),
|
|
361
|
+
view: (r) => re(s, r, e, o, n)
|
|
362
362
|
});
|
|
363
363
|
}, ie = b((e, t) => {
|
|
364
|
-
var
|
|
365
|
-
const
|
|
364
|
+
var s, r;
|
|
365
|
+
const o = (s = t == null ? void 0 : t.config) != null ? s : j, n = (r = t == null ? void 0 : t.calcPosition) != null ? r : ne;
|
|
366
366
|
return {
|
|
367
|
-
prosePlugins: (
|
|
368
|
-
const
|
|
369
|
-
return [ae(e,
|
|
367
|
+
prosePlugins: (a, i) => {
|
|
368
|
+
const l = o(i);
|
|
369
|
+
return [ae(e, l, "slash-dropdown", n)];
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
372
|
}), ge = E.create([ie()]);
|
|
373
373
|
export {
|
|
374
374
|
p as createDropdownItem,
|
|
375
|
-
|
|
375
|
+
L as defaultActions,
|
|
376
376
|
j as defaultConfig,
|
|
377
377
|
ge as slash,
|
|
378
378
|
ie as slashPlugin
|
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: 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 { ThemeUtils } from '@milkdown/utils';\n\nimport { injectStyle } from './style';\n\nexport const createDropdown = (utils: ThemeUtils, 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 { ThemeUtils } 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: ThemeUtils) => {\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 { ThemeUtils } 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: ThemeUtils, 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 { ThemeUtils } 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: ThemeUtils, 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;AA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AAQ,GAAiB;AAAA,QACjD,YAAY;AAAA,QACZ,YAAY;AAAA,MAAA,CACf,KAID,GAAkB,GAAM,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,GAAmB,GAA8B,MAAsB;AAC/F,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;"}
|
|
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 { ThemeUtils } from '@milkdown/utils';\n\nimport { injectStyle } from './style';\n\nexport const createDropdown = (utils: ThemeUtils, 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 { ThemeUtils } 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: ThemeUtils) => {\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 { ThemeUtils } 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\nexport const defaultCalcPosition = (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 type CalcPosition = (view: EditorView, dropdownElement: HTMLElement) => void;\n\nexport const createView = (\n status: Status,\n view: EditorView,\n utils: ThemeUtils,\n className: string,\n calcPosition: CalcPosition,\n) => {\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 calcPosition(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 { ThemeUtils } from '@milkdown/utils';\n\nimport type { StatusConfigBuilder } from '..';\nimport { createProps } from './props';\nimport { createStatus } from './status';\nimport { CalcPosition, createView } from './view';\n\nexport const key = 'MILKDOWN_SLASH';\n\nexport const createSlashPlugin = (\n utils: ThemeUtils,\n builder: StatusConfigBuilder,\n className: string,\n calcPosition: CalcPosition,\n) => {\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, calcPosition),\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';\nimport { CalcPosition, defaultCalcPosition } from './prose-plugin/view';\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 calcPosition: CalcPosition;\n};\n\nexport const slashPlugin = createPlugin<string, Options>((utils, options) => {\n const slashConfig = options?.config ?? defaultConfig;\n const calcPosition = options?.calcPosition ?? defaultCalcPosition;\n\n return {\n prosePlugins: (_, ctx) => {\n const config = slashConfig(ctx);\n\n const plugin = createSlashPlugin(utils, config, 'slash-dropdown', calcPosition);\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;AAAA;AAAA;AAAA;AAAA;AAAA,8BASlB,EAAQ,aAAa,IAAI;AAAA;AAAA;AAAA,6BAG1B,EAAQ,SAAS;AAAA;AAAA;AAAA;AAAA;AAK9C,GAEa,IAAc,CAAC,GAA4B,MAAqB;AACnE,QAAA,IAAU,CAAC,GAAc,IAAU,MAAM,EAAa,IAAI,GAAY,CAAC,GAAO,CAAO,CAAC;AAE5F,SAAO,EAAQ;AAAA;AAAA;AAAA;AAAA,yBAIM,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;AAAA,IACd,KAAK,IAAI,EAAU,EAAG;AAAA,IACtB,OAAO,EAAY,GAAQ,CAAK;AAAA,IAChC,MAAM,CAAC,MAAS,GAAW,GAAQ,GAAM,GAAO,GAAW,CAAY;AAAA,EAAA,CAC1E;AACL,GCNa,KAAc,EAA8B,CAAC,GAAO,MAAY;;AACnE,QAAA,IAAc,4BAAS,WAAT,WAAmB,GACjC,IAAe,4BAAS,iBAAT,WAAyB;AAEvC,SAAA;AAAA,IACH,cAAc,CAAC,GAAG,MAAQ;AAChB,YAAA,IAAS,EAAY,CAAG;AAI9B,aAAO,CAFQ,GAAkB,GAAO,GAAQ,kBAAkB,CAAY,CAEhE;AAAA,IAClB;AAAA,EAAA;AAER,CAAC,GAEY,KAAQ,EAAS,OAAO,CAAC,GAAA,CAAa,CAAC;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Plugin } from '@milkdown/prose/state';
|
|
2
2
|
import { ThemeUtils } from '@milkdown/utils';
|
|
3
3
|
import type { StatusConfigBuilder } from '..';
|
|
4
|
+
import { CalcPosition } from './view';
|
|
4
5
|
export declare const key = "MILKDOWN_SLASH";
|
|
5
|
-
export declare const createSlashPlugin: (utils: ThemeUtils, builder: StatusConfigBuilder, className: string) => Plugin<any>;
|
|
6
|
+
export declare const createSlashPlugin: (utils: ThemeUtils, builder: StatusConfigBuilder, className: string, calcPosition: CalcPosition) => Plugin<any>;
|
|
6
7
|
//# 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,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;
|
|
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,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAc,MAAM,QAAQ,CAAC;AAElD,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC,eAAO,MAAM,iBAAiB,UACnB,UAAU,WACR,mBAAmB,aACjB,MAAM,gBACH,YAAY,gBAS7B,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { EditorView } from '@milkdown/prose/view';
|
|
2
2
|
import { ThemeUtils } from '@milkdown/utils';
|
|
3
3
|
import { Status } from './status';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const defaultCalcPosition: (view: EditorView, dropdownElement: HTMLElement) => void;
|
|
5
|
+
export declare type CalcPosition = (view: EditorView, dropdownElement: HTMLElement) => void;
|
|
6
|
+
export declare const createView: (status: Status, view: EditorView, utils: ThemeUtils, className: string, calcPosition: CalcPosition) => {
|
|
5
7
|
update?: undefined;
|
|
6
8
|
destroy?: undefined;
|
|
7
9
|
} | {
|
|
@@ -1 +1 @@
|
|
|
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,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAY7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
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,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAY7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,mBAAmB,SAAU,UAAU,mBAAmB,WAAW,SAsBjF,CAAC;AAEF,oBAAY,YAAY,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,KAAK,IAAI,CAAC;AAEpF,eAAO,MAAM,UAAU,WACX,MAAM,QACR,UAAU,SACT,UAAU,aACN,MAAM,gBACH,YAAY;;;;mBAoBP,UAAU;;CAkBhC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/plugin-slash",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.es.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"milkdown plugin"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@milkdown/core": "6.
|
|
19
|
-
"@milkdown/prose": "6.
|
|
20
|
-
"@milkdown/design-system": "6.
|
|
18
|
+
"@milkdown/core": "6.5.0",
|
|
19
|
+
"@milkdown/prose": "6.5.0",
|
|
20
|
+
"@milkdown/design-system": "6.5.0"
|
|
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.
|
|
28
|
-
"@milkdown/exception": "6.
|
|
27
|
+
"@milkdown/utils": "6.5.0",
|
|
28
|
+
"@milkdown/exception": "6.5.0",
|
|
29
29
|
"smooth-scroll-into-view-if-needed": "^1.1.32",
|
|
30
30
|
"tslib": "^2.4.0"
|
|
31
31
|
},
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AtomList, createPlugin } from '@milkdown/utils';
|
|
|
4
4
|
import type { Config } from './config';
|
|
5
5
|
import { defaultConfig } from './config';
|
|
6
6
|
import { createSlashPlugin } from './prose-plugin';
|
|
7
|
+
import { CalcPosition, defaultCalcPosition } from './prose-plugin/view';
|
|
7
8
|
|
|
8
9
|
export type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';
|
|
9
10
|
export { defaultActions, defaultConfig } from './config';
|
|
@@ -12,16 +13,18 @@ export { createDropdownItem } from './utility';
|
|
|
12
13
|
|
|
13
14
|
export type Options = {
|
|
14
15
|
config: Config;
|
|
16
|
+
calcPosition: CalcPosition;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
export const slashPlugin = createPlugin<string, Options>((utils, options) => {
|
|
18
20
|
const slashConfig = options?.config ?? defaultConfig;
|
|
21
|
+
const calcPosition = options?.calcPosition ?? defaultCalcPosition;
|
|
19
22
|
|
|
20
23
|
return {
|
|
21
24
|
prosePlugins: (_, ctx) => {
|
|
22
25
|
const config = slashConfig(ctx);
|
|
23
26
|
|
|
24
|
-
const plugin = createSlashPlugin(utils, config, 'slash-dropdown');
|
|
27
|
+
const plugin = createSlashPlugin(utils, config, 'slash-dropdown', calcPosition);
|
|
25
28
|
|
|
26
29
|
return [plugin];
|
|
27
30
|
},
|
|
@@ -5,16 +5,21 @@ import { ThemeUtils } from '@milkdown/utils';
|
|
|
5
5
|
import type { StatusConfigBuilder } from '..';
|
|
6
6
|
import { createProps } from './props';
|
|
7
7
|
import { createStatus } from './status';
|
|
8
|
-
import { createView } from './view';
|
|
8
|
+
import { CalcPosition, createView } from './view';
|
|
9
9
|
|
|
10
10
|
export const key = 'MILKDOWN_SLASH';
|
|
11
11
|
|
|
12
|
-
export const createSlashPlugin = (
|
|
12
|
+
export const createSlashPlugin = (
|
|
13
|
+
utils: ThemeUtils,
|
|
14
|
+
builder: StatusConfigBuilder,
|
|
15
|
+
className: string,
|
|
16
|
+
calcPosition: CalcPosition,
|
|
17
|
+
) => {
|
|
13
18
|
const status = createStatus(builder);
|
|
14
19
|
|
|
15
20
|
return new Plugin({
|
|
16
21
|
key: new PluginKey(key),
|
|
17
22
|
props: createProps(status, utils),
|
|
18
|
-
view: (view) => createView(status, view, utils, className),
|
|
23
|
+
view: (view) => createView(status, view, utils, className, calcPosition),
|
|
19
24
|
});
|
|
20
25
|
};
|
package/src/prose-plugin/view.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from './input';
|
|
17
17
|
import { Status } from './status';
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
export const defaultCalcPosition = (view: EditorView, dropdownElement: HTMLElement) => {
|
|
20
20
|
calculateNodePosition(view, dropdownElement, (selected, target, parent) => {
|
|
21
21
|
const $editor = dropdownElement.parentElement;
|
|
22
22
|
if (!$editor) {
|
|
@@ -40,7 +40,15 @@ const calculatePosition = (view: EditorView, dropdownElement: HTMLElement) => {
|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export
|
|
43
|
+
export type CalcPosition = (view: EditorView, dropdownElement: HTMLElement) => void;
|
|
44
|
+
|
|
45
|
+
export const createView = (
|
|
46
|
+
status: Status,
|
|
47
|
+
view: EditorView,
|
|
48
|
+
utils: ThemeUtils,
|
|
49
|
+
className: string,
|
|
50
|
+
calcPosition: CalcPosition,
|
|
51
|
+
) => {
|
|
44
52
|
const wrapper = view.dom.parentNode;
|
|
45
53
|
if (!wrapper) return {};
|
|
46
54
|
|
|
@@ -67,7 +75,7 @@ export const createView = (status: Status, view: EditorView, utils: ThemeUtils,
|
|
|
67
75
|
|
|
68
76
|
if (!show) return;
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
calcPosition(view, dropdownElement);
|
|
71
79
|
},
|
|
72
80
|
|
|
73
81
|
destroy: () => {
|