@milkdown/plugin-slash 5.1.2 → 5.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.es.js +516 -0
- package/lib/index.es.js.map +1 -0
- package/package.json +15 -10
- package/lib/config.js +0 -115
- package/lib/config.js.map +0 -1
- package/lib/index.js +0 -19
- package/lib/index.js.map +0 -1
- package/lib/item.js +0 -7
- package/lib/item.js.map +0 -1
- package/lib/prose-plugin/dropdown.js +0 -32
- package/lib/prose-plugin/dropdown.js.map +0 -1
- package/lib/prose-plugin/index.js +0 -15
- package/lib/prose-plugin/index.js.map +0 -1
- package/lib/prose-plugin/input.js +0 -103
- package/lib/prose-plugin/input.js.map +0 -1
- package/lib/prose-plugin/props.js +0 -72
- package/lib/prose-plugin/props.js.map +0 -1
- package/lib/prose-plugin/status.js +0 -26
- package/lib/prose-plugin/status.js.map +0 -1
- package/lib/prose-plugin/view.js +0 -52
- package/lib/prose-plugin/view.js.map +0 -1
- package/lib/style.js +0 -62
- package/lib/style.js.map +0 -1
- package/lib/utility.js +0 -50
- package/lib/utility.js.map +0 -1
package/lib/index.es.js
ADDED
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var __objRest = (source, exclude) => {
|
|
5
|
+
var target = {};
|
|
6
|
+
for (var prop in source)
|
|
7
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
+
target[prop] = source[prop];
|
|
9
|
+
if (source != null && __getOwnPropSymbols)
|
|
10
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
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 { schemaCtx, themeToolCtx, commandsCtx } from "@milkdown/core";
|
|
18
|
+
import { TurnIntoHeading, WrapInBulletList, WrapInOrderedList, TurnIntoTaskList, InsertImage, WrapInBlockquote, InsertTable, TurnIntoCodeFence, InsertHr } from "@milkdown/preset-gfm";
|
|
19
|
+
import { css } from "@emotion/css";
|
|
20
|
+
import { findParentNode, DecorationSet, Decoration, calculateNodePosition, Plugin, PluginKey } from "@milkdown/prose";
|
|
21
|
+
import scrollIntoView from "smooth-scroll-into-view-if-needed";
|
|
22
|
+
const itemStyle = ({ font, palette }) => {
|
|
23
|
+
return css`
|
|
24
|
+
.slash-dropdown-item {
|
|
25
|
+
display: flex;
|
|
26
|
+
gap: 2rem;
|
|
27
|
+
height: 3rem;
|
|
28
|
+
padding: 0 1rem;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: flex-start;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
line-height: 2;
|
|
33
|
+
font-family: ${font.typography};
|
|
34
|
+
font-size: 0.875rem;
|
|
35
|
+
|
|
36
|
+
transition: all 0.2s ease-in-out;
|
|
37
|
+
|
|
38
|
+
&,
|
|
39
|
+
.icon {
|
|
40
|
+
color: ${palette("neutral", 0.87)};
|
|
41
|
+
transition: all 0.2s ease-in-out;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.hide {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.active {
|
|
49
|
+
background: ${palette("secondary", 0.12)};
|
|
50
|
+
&,
|
|
51
|
+
.icon {
|
|
52
|
+
color: ${palette("primary")};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
};
|
|
57
|
+
const injectStyle = (themeTool) => {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
const { mixin, size, palette } = themeTool;
|
|
60
|
+
const style = css`
|
|
61
|
+
width: 20.5rem;
|
|
62
|
+
max-height: 20.5rem;
|
|
63
|
+
overflow-y: auto;
|
|
64
|
+
${(_a = mixin.border) == null ? void 0 : _a.call(mixin)};
|
|
65
|
+
border-radius: ${size.radius};
|
|
66
|
+
position: absolute;
|
|
67
|
+
background: ${palette("surface")};
|
|
68
|
+
|
|
69
|
+
${(_b = mixin.shadow) == null ? void 0 : _b.call(mixin)};
|
|
70
|
+
|
|
71
|
+
&.hide {
|
|
72
|
+
display: none;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
${(_c = mixin.scrollbar) == null ? void 0 : _c.call(mixin)};
|
|
76
|
+
|
|
77
|
+
${itemStyle(themeTool)}
|
|
78
|
+
`;
|
|
79
|
+
return style;
|
|
80
|
+
};
|
|
81
|
+
const createDropdown = (utils) => {
|
|
82
|
+
const div = document.createElement("div");
|
|
83
|
+
div.setAttribute("role", "listbox");
|
|
84
|
+
div.setAttribute("tabindex", "-1");
|
|
85
|
+
const style = utils.getStyle(injectStyle);
|
|
86
|
+
if (style) {
|
|
87
|
+
div.classList.add(style);
|
|
88
|
+
}
|
|
89
|
+
div.classList.add("slash-dropdown", "hide");
|
|
90
|
+
return div;
|
|
91
|
+
};
|
|
92
|
+
const createDropdownItem = (themeTool, text, icon, options) => {
|
|
93
|
+
var _a;
|
|
94
|
+
const textClassName = (_a = options == null ? void 0 : options.textClassName) != null ? _a : "text";
|
|
95
|
+
const div = document.createElement("div");
|
|
96
|
+
div.setAttribute("role", "option");
|
|
97
|
+
div.classList.add("slash-dropdown-item");
|
|
98
|
+
const iconSpan = themeTool.slots.icon(icon);
|
|
99
|
+
const textSpan = document.createElement("span");
|
|
100
|
+
textSpan.textContent = text;
|
|
101
|
+
textSpan.className = textClassName;
|
|
102
|
+
div.appendChild(iconSpan);
|
|
103
|
+
div.appendChild(textSpan);
|
|
104
|
+
return div;
|
|
105
|
+
};
|
|
106
|
+
const cleanUp = (state, dispatch) => {
|
|
107
|
+
const { selection } = state;
|
|
108
|
+
const { $from } = selection;
|
|
109
|
+
const tr = state.tr.deleteRange($from.start(), $from.pos);
|
|
110
|
+
dispatch == null ? void 0 : dispatch(tr);
|
|
111
|
+
return false;
|
|
112
|
+
};
|
|
113
|
+
const cleanUpAndCreateNode = (createCommand) => (state, dispatch, view) => {
|
|
114
|
+
if (view) {
|
|
115
|
+
cleanUp(state, dispatch);
|
|
116
|
+
createCommand();
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
};
|
|
120
|
+
const defaultActions = (ctx, input = "/") => {
|
|
121
|
+
const { nodes } = ctx.get(schemaCtx);
|
|
122
|
+
const actions = [
|
|
123
|
+
{
|
|
124
|
+
id: "h1",
|
|
125
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Large Heading", "h1"),
|
|
126
|
+
command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 1),
|
|
127
|
+
keyword: ["h1", "large heading"],
|
|
128
|
+
typeName: "heading"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "h2",
|
|
132
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Medium Heading", "h2"),
|
|
133
|
+
command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 2),
|
|
134
|
+
keyword: ["h2", "medium heading"],
|
|
135
|
+
typeName: "heading"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "h3",
|
|
139
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Small Heading", "h3"),
|
|
140
|
+
command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 3),
|
|
141
|
+
keyword: ["h3", "small heading"],
|
|
142
|
+
typeName: "heading"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "bulletList",
|
|
146
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Bullet List", "bulletList"),
|
|
147
|
+
command: () => ctx.get(commandsCtx).call(WrapInBulletList),
|
|
148
|
+
keyword: ["bullet list", "ul"],
|
|
149
|
+
typeName: "bullet_list"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: "orderedList",
|
|
153
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Ordered List", "orderedList"),
|
|
154
|
+
command: () => ctx.get(commandsCtx).call(WrapInOrderedList),
|
|
155
|
+
keyword: ["ordered list", "ol"],
|
|
156
|
+
typeName: "ordered_list"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "taskList",
|
|
160
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Task List", "taskList"),
|
|
161
|
+
command: () => ctx.get(commandsCtx).call(TurnIntoTaskList),
|
|
162
|
+
keyword: ["task list", "task"],
|
|
163
|
+
typeName: "task_list_item"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "image",
|
|
167
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Image", "image"),
|
|
168
|
+
command: () => ctx.get(commandsCtx).call(InsertImage),
|
|
169
|
+
keyword: ["image"],
|
|
170
|
+
typeName: "image"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: "blockquote",
|
|
174
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Quote", "quote"),
|
|
175
|
+
command: () => ctx.get(commandsCtx).call(WrapInBlockquote),
|
|
176
|
+
keyword: ["quote", "blockquote"],
|
|
177
|
+
typeName: "blockquote"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: "table",
|
|
181
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Table", "table"),
|
|
182
|
+
command: () => ctx.get(commandsCtx).call(InsertTable),
|
|
183
|
+
keyword: ["table"],
|
|
184
|
+
typeName: "table"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: "code",
|
|
188
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Code Fence", "code"),
|
|
189
|
+
command: () => ctx.get(commandsCtx).call(TurnIntoCodeFence),
|
|
190
|
+
keyword: ["code"],
|
|
191
|
+
typeName: "fence"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: "divider",
|
|
195
|
+
dom: createDropdownItem(ctx.get(themeToolCtx), "Divide Line", "divider"),
|
|
196
|
+
command: () => ctx.get(commandsCtx).call(InsertHr),
|
|
197
|
+
keyword: ["divider", "hr"],
|
|
198
|
+
typeName: "hr"
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
const userInput = input.slice(1).toLocaleLowerCase();
|
|
202
|
+
return actions.filter((action) => !!nodes[action.typeName] && action.keyword.some((keyword) => keyword.includes(userInput))).map((_a) => {
|
|
203
|
+
var _b = _a, { keyword, typeName } = _b, action = __objRest(_b, ["keyword", "typeName"]);
|
|
204
|
+
return action;
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const defaultConfig = (ctx) => {
|
|
208
|
+
return ({ content, isTopLevel }) => {
|
|
209
|
+
if (!isTopLevel)
|
|
210
|
+
return null;
|
|
211
|
+
if (!content) {
|
|
212
|
+
return { placeholder: "Type / to use the slash commands..." };
|
|
213
|
+
}
|
|
214
|
+
if (content.startsWith("/")) {
|
|
215
|
+
return content === "/" ? {
|
|
216
|
+
placeholder: "Type to filter...",
|
|
217
|
+
actions: defaultActions(ctx)
|
|
218
|
+
} : {
|
|
219
|
+
actions: defaultActions(ctx, content)
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
const createEmptyStyle = ({ font, palette }) => css`
|
|
226
|
+
position: relative;
|
|
227
|
+
&::before {
|
|
228
|
+
position: absolute;
|
|
229
|
+
cursor: text;
|
|
230
|
+
font-family: ${font.typography};
|
|
231
|
+
font-size: 0.875rem;
|
|
232
|
+
color: ${palette("neutral", 0.6)};
|
|
233
|
+
content: attr(data-text);
|
|
234
|
+
height: 100%;
|
|
235
|
+
display: flex;
|
|
236
|
+
align-items: center;
|
|
237
|
+
}
|
|
238
|
+
`;
|
|
239
|
+
const createSlashStyle = () => css`
|
|
240
|
+
&::before {
|
|
241
|
+
left: 0.5rem;
|
|
242
|
+
}
|
|
243
|
+
`;
|
|
244
|
+
const createProps = (status, utils) => {
|
|
245
|
+
const emptyStyle = utils.getStyle(createEmptyStyle);
|
|
246
|
+
const slashStyle = utils.getStyle(createSlashStyle);
|
|
247
|
+
return {
|
|
248
|
+
handleKeyDown: (_, event) => {
|
|
249
|
+
if (status.isEmpty()) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (!(event instanceof KeyboardEvent)) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
if (!["ArrowUp", "ArrowDown", "Enter"].includes(event.key)) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
return true;
|
|
259
|
+
},
|
|
260
|
+
decorations: (state) => {
|
|
261
|
+
const paragraph = findParentNode(({ type }) => type.name === "paragraph")(state.selection);
|
|
262
|
+
if (!paragraph || paragraph.node.childCount > 1 || state.selection.$from.parentOffset !== paragraph.node.textContent.length) {
|
|
263
|
+
status.clear();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const { placeholder, actions } = status.update({
|
|
267
|
+
parentNode: state.selection.$from.node(state.selection.$from.depth - 1),
|
|
268
|
+
isTopLevel: state.selection.$from.depth === 1,
|
|
269
|
+
content: paragraph.node.textContent,
|
|
270
|
+
state
|
|
271
|
+
});
|
|
272
|
+
if (!placeholder) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
const createDecoration = (text, className) => {
|
|
276
|
+
const pos = paragraph.pos;
|
|
277
|
+
return DecorationSet.create(state.doc, [
|
|
278
|
+
Decoration.node(pos, pos + paragraph.node.nodeSize, {
|
|
279
|
+
class: className.filter((x) => x).join(" "),
|
|
280
|
+
"data-text": text
|
|
281
|
+
})
|
|
282
|
+
]);
|
|
283
|
+
};
|
|
284
|
+
if (actions.length) {
|
|
285
|
+
return createDecoration(placeholder, [emptyStyle, slashStyle, "empty-node", "is-slash"]);
|
|
286
|
+
}
|
|
287
|
+
return createDecoration(placeholder, [emptyStyle, "empty-node"]);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
const transformAction = (action) => ({
|
|
292
|
+
id: action.id,
|
|
293
|
+
$: action.dom,
|
|
294
|
+
command: cleanUpAndCreateNode(action.command)
|
|
295
|
+
});
|
|
296
|
+
const createStatusCtx = () => {
|
|
297
|
+
return {
|
|
298
|
+
placeholder: null,
|
|
299
|
+
actions: []
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
const createStatus = (builder) => {
|
|
303
|
+
const statusCtx = createStatusCtx();
|
|
304
|
+
return {
|
|
305
|
+
get: () => statusCtx,
|
|
306
|
+
clear: () => {
|
|
307
|
+
statusCtx.placeholder = null;
|
|
308
|
+
statusCtx.actions = [];
|
|
309
|
+
},
|
|
310
|
+
update: (builderParams) => {
|
|
311
|
+
var _a, _b;
|
|
312
|
+
const config = builder(builderParams);
|
|
313
|
+
statusCtx.placeholder = (_a = config == null ? void 0 : config.placeholder) != null ? _a : null;
|
|
314
|
+
statusCtx.actions = ((_b = config == null ? void 0 : config.actions) != null ? _b : []).map(transformAction);
|
|
315
|
+
return statusCtx;
|
|
316
|
+
},
|
|
317
|
+
isEmpty: () => statusCtx.actions.length === 0
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
const renderDropdown = (status, dropdownElement, listeners) => {
|
|
321
|
+
const { actions } = status.get();
|
|
322
|
+
if (!actions.length) {
|
|
323
|
+
dropdownElement.classList.add("hide");
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
dropdownElement.childNodes.forEach((child) => {
|
|
327
|
+
child.removeEventListener("mouseenter", listeners.mouseEnter);
|
|
328
|
+
child.removeEventListener("mouseleave", listeners.mouseLeave);
|
|
329
|
+
});
|
|
330
|
+
dropdownElement.textContent = "";
|
|
331
|
+
actions.forEach(({ $ }) => {
|
|
332
|
+
$.classList.remove("active");
|
|
333
|
+
$.addEventListener("mouseenter", listeners.mouseEnter);
|
|
334
|
+
$.addEventListener("mouseleave", listeners.mouseLeave);
|
|
335
|
+
dropdownElement.appendChild($);
|
|
336
|
+
});
|
|
337
|
+
dropdownElement.classList.remove("hide");
|
|
338
|
+
actions[0].$.classList.add("active");
|
|
339
|
+
requestAnimationFrame(() => {
|
|
340
|
+
scrollIntoView(actions[0].$, {
|
|
341
|
+
scrollMode: "if-needed",
|
|
342
|
+
block: "nearest",
|
|
343
|
+
inline: "nearest"
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
return true;
|
|
347
|
+
};
|
|
348
|
+
const createMouseManager = () => {
|
|
349
|
+
let mouseLock = false;
|
|
350
|
+
return {
|
|
351
|
+
isLock: () => mouseLock,
|
|
352
|
+
lock: () => {
|
|
353
|
+
mouseLock = true;
|
|
354
|
+
},
|
|
355
|
+
unlock: () => {
|
|
356
|
+
mouseLock = false;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
const handleMouseMove = (mouseManager) => () => {
|
|
361
|
+
mouseManager.unlock();
|
|
362
|
+
};
|
|
363
|
+
const handleMouseEnter = (status, mouseManager) => (e) => {
|
|
364
|
+
if (mouseManager.isLock())
|
|
365
|
+
return;
|
|
366
|
+
const { actions } = status.get();
|
|
367
|
+
const active = actions.findIndex((x) => x.$.classList.contains("active"));
|
|
368
|
+
if (active >= 0) {
|
|
369
|
+
actions[active].$.classList.remove("active");
|
|
370
|
+
}
|
|
371
|
+
const { target } = e;
|
|
372
|
+
if (!(target instanceof HTMLElement))
|
|
373
|
+
return;
|
|
374
|
+
target.classList.add("active");
|
|
375
|
+
};
|
|
376
|
+
const handleMouseLeave = () => (e) => {
|
|
377
|
+
const { target } = e;
|
|
378
|
+
if (!(target instanceof HTMLElement))
|
|
379
|
+
return;
|
|
380
|
+
target.classList.remove("active");
|
|
381
|
+
};
|
|
382
|
+
const handleClick = (status, view, dropdownElement) => (e) => {
|
|
383
|
+
const { target } = e;
|
|
384
|
+
if (!(target instanceof HTMLElement))
|
|
385
|
+
return;
|
|
386
|
+
if (!view)
|
|
387
|
+
return;
|
|
388
|
+
const stop = () => {
|
|
389
|
+
e.stopPropagation();
|
|
390
|
+
e.preventDefault();
|
|
391
|
+
};
|
|
392
|
+
const { actions } = status.get();
|
|
393
|
+
const el = Object.values(actions).find(({ $ }) => $.contains(target));
|
|
394
|
+
if (!el) {
|
|
395
|
+
if (status.isEmpty())
|
|
396
|
+
return;
|
|
397
|
+
status.clear();
|
|
398
|
+
dropdownElement.classList.add("hide");
|
|
399
|
+
stop();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
stop();
|
|
403
|
+
el.command(view.state, view.dispatch, view);
|
|
404
|
+
};
|
|
405
|
+
const handleKeydown = (status, view, dropdownElement, mouseManager) => (e) => {
|
|
406
|
+
if (!(e instanceof KeyboardEvent))
|
|
407
|
+
return;
|
|
408
|
+
if (!mouseManager.isLock())
|
|
409
|
+
mouseManager.lock();
|
|
410
|
+
const { key: key2 } = e;
|
|
411
|
+
if (status.isEmpty())
|
|
412
|
+
return;
|
|
413
|
+
if (!["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(key2))
|
|
414
|
+
return;
|
|
415
|
+
const { actions } = status.get();
|
|
416
|
+
let active = actions.findIndex(({ $ }) => $.classList.contains("active"));
|
|
417
|
+
if (active < 0)
|
|
418
|
+
active = 0;
|
|
419
|
+
const moveActive = (next) => {
|
|
420
|
+
actions[active].$.classList.remove("active");
|
|
421
|
+
actions[next].$.classList.add("active");
|
|
422
|
+
scrollIntoView(actions[next].$, {
|
|
423
|
+
scrollMode: "if-needed",
|
|
424
|
+
block: "nearest",
|
|
425
|
+
inline: "nearest"
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
if (key2 === "ArrowDown") {
|
|
429
|
+
const next = active === actions.length - 1 ? 0 : active + 1;
|
|
430
|
+
moveActive(next);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (key2 === "ArrowUp") {
|
|
434
|
+
const next = active === 0 ? actions.length - 1 : active - 1;
|
|
435
|
+
moveActive(next);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (key2 === "Escape") {
|
|
439
|
+
if (status.isEmpty())
|
|
440
|
+
return;
|
|
441
|
+
status.clear();
|
|
442
|
+
dropdownElement.classList.add("hide");
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
actions[active].command(view.state, view.dispatch, view);
|
|
446
|
+
actions[active].$.classList.remove("active");
|
|
447
|
+
};
|
|
448
|
+
const calculatePosition = (view, dropdownElement) => {
|
|
449
|
+
calculateNodePosition(view, dropdownElement, (selected, target, parent) => {
|
|
450
|
+
let left = selected.left - parent.left;
|
|
451
|
+
let top = selected.bottom - parent.top + 14;
|
|
452
|
+
if (left < 0) {
|
|
453
|
+
left = 0;
|
|
454
|
+
}
|
|
455
|
+
if (window.innerHeight - selected.bottom < target.height) {
|
|
456
|
+
top = selected.top - parent.top - target.height - 14;
|
|
457
|
+
}
|
|
458
|
+
return [top, left];
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
const createView = (status, view, utils) => {
|
|
462
|
+
const wrapper = view.dom.parentNode;
|
|
463
|
+
if (!wrapper)
|
|
464
|
+
return {};
|
|
465
|
+
const dropdownElement = createDropdown(utils);
|
|
466
|
+
const mouseManager = createMouseManager();
|
|
467
|
+
wrapper.appendChild(dropdownElement);
|
|
468
|
+
const _mouseMove = handleMouseMove(mouseManager);
|
|
469
|
+
const _mouseDown = handleClick(status, view, dropdownElement);
|
|
470
|
+
const _keydown = handleKeydown(status, view, dropdownElement, mouseManager);
|
|
471
|
+
const _mouseEnter = handleMouseEnter(status, mouseManager);
|
|
472
|
+
const _mouseLeave = handleMouseLeave();
|
|
473
|
+
wrapper.addEventListener("mousemove", _mouseMove);
|
|
474
|
+
wrapper.addEventListener("mousedown", _mouseDown);
|
|
475
|
+
wrapper.addEventListener("keydown", _keydown);
|
|
476
|
+
return {
|
|
477
|
+
update: (view2) => {
|
|
478
|
+
const show = renderDropdown(status, dropdownElement, {
|
|
479
|
+
mouseEnter: _mouseEnter,
|
|
480
|
+
mouseLeave: _mouseLeave
|
|
481
|
+
});
|
|
482
|
+
if (!show)
|
|
483
|
+
return;
|
|
484
|
+
calculatePosition(view2, dropdownElement);
|
|
485
|
+
},
|
|
486
|
+
destroy: () => {
|
|
487
|
+
wrapper.removeEventListener("mousemove", _mouseMove);
|
|
488
|
+
wrapper.removeEventListener("mousedown", _mouseDown);
|
|
489
|
+
wrapper.removeEventListener("keydown", _keydown);
|
|
490
|
+
dropdownElement.remove();
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
const key = "MILKDOWN_PLUGIN_SLASH";
|
|
495
|
+
const createSlashPlugin = (utils, builder) => {
|
|
496
|
+
const status = createStatus(builder);
|
|
497
|
+
return new Plugin({
|
|
498
|
+
key: new PluginKey(key),
|
|
499
|
+
props: createProps(status, utils),
|
|
500
|
+
view: (view) => createView(status, view, utils)
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
const slashPlugin = createPlugin((utils, options) => {
|
|
504
|
+
var _a;
|
|
505
|
+
const slashConfig = (_a = options == null ? void 0 : options.config) != null ? _a : defaultConfig;
|
|
506
|
+
return {
|
|
507
|
+
prosePlugins: (_, ctx) => {
|
|
508
|
+
const config = slashConfig(ctx);
|
|
509
|
+
const plugin = createSlashPlugin(utils, config);
|
|
510
|
+
return [plugin];
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
});
|
|
514
|
+
const slash = AtomList.create([slashPlugin()]);
|
|
515
|
+
export { createDropdownItem, defaultActions, defaultConfig, slash, slashPlugin };
|
|
516
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +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 { css } from '@emotion/css';\nimport { ThemeTool } from '@milkdown/core';\n\nconst itemStyle = ({ font, palette }: ThemeTool) => {\n return css`\n .slash-dropdown-item {\n display: flex;\n gap: 2rem;\n height: 3rem;\n padding: 0 1rem;\n align-items: center;\n justify-content: flex-start;\n cursor: pointer;\n line-height: 2;\n font-family: ${font.typography};\n font-size: 0.875rem;\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\nexport const injectStyle = (themeTool: ThemeTool) => {\n const { mixin, size, palette } = themeTool;\n const style = css`\n width: 20.5rem;\n max-height: 20.5rem;\n overflow-y: auto;\n ${mixin.border?.()};\n border-radius: ${size.radius};\n position: absolute;\n background: ${palette('surface')};\n\n ${mixin.shadow?.()};\n\n &.hide {\n display: none;\n }\n\n ${mixin.scrollbar?.()};\n\n ${itemStyle(themeTool)}\n `;\n return style;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport type { ThemeTool } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport type { Command, Node } from '@milkdown/prose';\nimport type { Utils } from '@milkdown/utils';\n\nimport { injectStyle } from './style';\n\nexport const createDropdown = (utils: Utils) => {\n const div = document.createElement('div');\n div.setAttribute('role', 'listbox');\n div.setAttribute('tabindex', '-1');\n const style = utils.getStyle(injectStyle);\n\n if (style) {\n div.classList.add(style);\n }\n\n div.classList.add('slash-dropdown', 'hide');\n\n return div;\n};\n\ntype ItemOptions = {\n textClassName: string;\n};\nexport const createDropdownItem = (themeTool: ThemeTool, text: string, icon: Icon, options?: Partial<ItemOptions>) => {\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 = themeTool.slots.icon(icon);\n\n const textSpan = document.createElement('span');\n textSpan.textContent = text;\n textSpan.className = textClassName;\n\n div.appendChild(iconSpan);\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, schemaCtx, themeToolCtx } from '@milkdown/core';\nimport type { Ctx } from '@milkdown/ctx';\nimport {\n InsertHr,\n InsertImage,\n InsertTable,\n TurnIntoCodeFence,\n TurnIntoHeading,\n TurnIntoTaskList,\n WrapInBlockquote,\n WrapInBulletList,\n WrapInOrderedList,\n} from '@milkdown/preset-gfm';\nimport { EditorState, Node } from '@milkdown/prose';\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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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(themeToolCtx), '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 { css } from '@emotion/css';\nimport { ThemeTool } from '@milkdown/core';\nimport { Decoration, DecorationSet, EditorState, EditorView, findParentNode } from '@milkdown/prose';\nimport { Utils } from '@milkdown/utils';\n\nimport type { Status } from './status';\n\nexport type Props = ReturnType<typeof createProps>;\n\nconst createEmptyStyle = ({ font, palette }: ThemeTool) => css`\n position: relative;\n &::before {\n position: absolute;\n cursor: text;\n font-family: ${font.typography};\n font-size: 0.875rem;\n color: ${palette('neutral', 0.6)};\n content: attr(data-text);\n height: 100%;\n display: flex;\n align-items: center;\n }\n`;\n\nconst createSlashStyle = () => css`\n &::before {\n left: 0.5rem;\n }\n`;\n\nexport const createProps = (status: Status, utils: Utils) => {\n const emptyStyle = utils.getStyle(createEmptyStyle);\n const slashStyle = utils.getStyle(createSlashStyle);\n\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\n if (\n !paragraph ||\n paragraph.node.childCount > 1 ||\n state.selection.$from.parentOffset !== paragraph.node.textContent.length\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 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';\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 // Reset dropdownElement children\n dropdownElement.textContent = '';\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 actions[0].$.classList.add('active');\n requestAnimationFrame(() => {\n scrollIntoView(actions[0].$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n });\n\n return true;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\n\nimport { EditorView } from '@milkdown/prose';\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 if (active >= 0) {\n actions[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 actions[active].$.classList.remove('active');\n actions[next].$.classList.add('active');\n scrollIntoView(actions[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 actions[active].command(view.state, view.dispatch, view);\n actions[active].$.classList.remove('active');\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { calculateNodePosition, EditorView } from '@milkdown/prose';\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 let left = selected.left - parent.left;\n let top = selected.bottom - parent.top + 14;\n\n if (left < 0) {\n left = 0;\n }\n\n if (window.innerHeight - selected.bottom < target.height) {\n top = selected.top - parent.top - target.height - 14;\n }\n return [top, left];\n });\n};\n\nexport const createView = (status: Status, view: EditorView, utils: Utils) => {\n const wrapper = view.dom.parentNode;\n if (!wrapper) return {};\n\n const dropdownElement = createDropdown(utils);\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';\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_PLUGIN_SLASH';\n\nexport const createSlashPlugin = (utils: Utils, builder: StatusConfigBuilder) => {\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),\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 { 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);\n\n return [plugin];\n },\n };\n});\n\nexport const slash = AtomList.create([slashPlugin()]);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,YAAY,CAAC,EAAE,MAAM,cAAyB;SACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUgB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAOP,QAAQ,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BASd,QAAQ,aAAa;AAAA;AAAA;AAAA,6BAGtB,QAAQ;AAAA;AAAA;AAAA;AAAA;MAMxB,cAAc,CAAC,cAAyB;;QAC3C,EAAE,OAAO,MAAM,YAAY;QAC3B,QAAQ;AAAA;AAAA;AAAA;AAAA,UAIR,Y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QAAQ;YAChB,SAAS,YAAY;YAErB,SAAS,kBAAkB,OAAO;aAEjC,CAAC;AAAA;AAAA;AAAA;MAKP,QAAQ,SAAS,OAAO,CAAC;;"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/plugin-slash",
|
|
3
|
-
"version": "5.1
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
3
|
+
"version": "5.3.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./lib/index.es.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"files": [
|
|
@@ -20,18 +20,23 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/css": "^11.1.3",
|
|
23
|
-
"@milkdown/utils": "5.1
|
|
23
|
+
"@milkdown/utils": "5.3.1",
|
|
24
24
|
"smooth-scroll-into-view-if-needed": "^1.1.32",
|
|
25
25
|
"tslib": "^2.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"
|
|
28
|
+
"@milkdown/core": "5.3.1",
|
|
29
|
+
"@milkdown/prose": "5.3.1",
|
|
30
|
+
"@milkdown/ctx": "5.3.1",
|
|
31
|
+
"@milkdown/design-system": "5.3.1",
|
|
32
|
+
"@milkdown/preset-gfm": "5.3.1"
|
|
29
33
|
},
|
|
30
34
|
"scripts": {
|
|
31
35
|
"start": "vite",
|
|
32
|
-
"watch": "
|
|
33
|
-
"test": "
|
|
36
|
+
"watch": "vite build --watch",
|
|
37
|
+
"test": "vitest",
|
|
34
38
|
"tsc": "tsc --noEmit",
|
|
35
|
-
"build": "tsc"
|
|
36
|
-
}
|
|
39
|
+
"build": "vite build && tsc --emitDeclarationOnly"
|
|
40
|
+
},
|
|
41
|
+
"readme": "# @milkdown/plugin-slash\n\nSlash plugin for [milkdown](https://saul-mirone.github.io/milkdown/).\nAdd support for slash commands.\n\n# Example Usage\n\n```typescript\nimport { Editor } from '@milkdown/core';\nimport { commonmark } from '@milkdown/preset-commonmark';\nimport { nord } from '@milkdown/theme-nord';\n\nimport { slash } from '@milkdown/plugin-slash';\n\nEditor.make().use(nord).use(commonmark).use(slash).create();\n```\n\n# Options\n\n## config\n\nConfigure the slash plugin placeholders & items with custom status builder.\n\nExample:\n\n```typescript\nimport { slashPlugin, slash, createDropdownItem, defaultActions } from '@milkdown/plugin-slash';\nimport { themeToolCtx, commandsCtx } from '@milkdown/core';\n\nEditor.make().use(\n slash.configure(slashPlugin, {\n config: (ctx) => {\n // Get default slash plugin items\n const actions = defaultActions(ctx);\n\n // Define a status builder\n return ({ isTopLevel, content, parentNode }) => {\n // You can only show something at root level\n if (!isTopLevel) return null;\n\n // Empty content ? Set your custom empty placeholder !\n if (!content) {\n return { placeholder: 'Type / to use the slash commands...' };\n }\n\n // Define the placeholder & actions (dropdown items) you want to display depending on content\n if (content.startsWith('/')) {\n // Add some actions depending on your content's parent node\n if (parentNode.type.name === 'customNode') {\n actions.push({\n id: 'custom',\n dom: createDropdownItem(ctx.get(themeToolCtx), 'Custom', 'h1'),\n command: () => ctx.get(commandsCtx).call(/* Add custom command here */),\n keyword: ['custom'],\n enable: () => true,\n });\n }\n\n return content === '/'\n ? {\n placeholder: 'Type to filter...',\n actions,\n }\n : {\n actions: actions.filter(({ keyword }) =>\n keyword.some((key) => key.includes(content.slice(1).toLocaleLowerCase())),\n ),\n };\n }\n };\n },\n }),\n);\n```\n\n# License\n\nMilkdown is open sourced software licensed under [MIT license](https://github.com/Saul-Mirone/milkdown/blob/main/LICENSE).\n"
|
|
37
42
|
}
|
package/lib/config.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
3
|
-
import { commandsCtx, schemaCtx, themeToolCtx } from '@milkdown/core';
|
|
4
|
-
import { InsertHr, InsertImage, InsertTable, TurnIntoCodeFence, TurnIntoHeading, TurnIntoTaskList, WrapInBlockquote, WrapInBulletList, WrapInOrderedList, } from '@milkdown/preset-gfm';
|
|
5
|
-
import { createDropdownItem } from './utility';
|
|
6
|
-
export const defaultActions = (ctx, input = '/') => {
|
|
7
|
-
const { nodes } = ctx.get(schemaCtx);
|
|
8
|
-
const actions = [
|
|
9
|
-
{
|
|
10
|
-
id: 'h1',
|
|
11
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Large Heading', 'h1'),
|
|
12
|
-
command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 1),
|
|
13
|
-
keyword: ['h1', 'large heading'],
|
|
14
|
-
typeName: 'heading',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: 'h2',
|
|
18
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Medium Heading', 'h2'),
|
|
19
|
-
command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 2),
|
|
20
|
-
keyword: ['h2', 'medium heading'],
|
|
21
|
-
typeName: 'heading',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: 'h3',
|
|
25
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Small Heading', 'h3'),
|
|
26
|
-
command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 3),
|
|
27
|
-
keyword: ['h3', 'small heading'],
|
|
28
|
-
typeName: 'heading',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: 'bulletList',
|
|
32
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Bullet List', 'bulletList'),
|
|
33
|
-
command: () => ctx.get(commandsCtx).call(WrapInBulletList),
|
|
34
|
-
keyword: ['bullet list', 'ul'],
|
|
35
|
-
typeName: 'bullet_list',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 'orderedList',
|
|
39
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Ordered List', 'orderedList'),
|
|
40
|
-
command: () => ctx.get(commandsCtx).call(WrapInOrderedList),
|
|
41
|
-
keyword: ['ordered list', 'ol'],
|
|
42
|
-
typeName: 'ordered_list',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'taskList',
|
|
46
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Task List', 'taskList'),
|
|
47
|
-
command: () => ctx.get(commandsCtx).call(TurnIntoTaskList),
|
|
48
|
-
keyword: ['task list', 'task'],
|
|
49
|
-
typeName: 'task_list_item',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: 'image',
|
|
53
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Image', 'image'),
|
|
54
|
-
command: () => ctx.get(commandsCtx).call(InsertImage),
|
|
55
|
-
keyword: ['image'],
|
|
56
|
-
typeName: 'image',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: 'blockquote',
|
|
60
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Quote', 'quote'),
|
|
61
|
-
command: () => ctx.get(commandsCtx).call(WrapInBlockquote),
|
|
62
|
-
keyword: ['quote', 'blockquote'],
|
|
63
|
-
typeName: 'blockquote',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
id: 'table',
|
|
67
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Table', 'table'),
|
|
68
|
-
command: () => ctx.get(commandsCtx).call(InsertTable),
|
|
69
|
-
keyword: ['table'],
|
|
70
|
-
typeName: 'table',
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
id: 'code',
|
|
74
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Code Fence', 'code'),
|
|
75
|
-
command: () => ctx.get(commandsCtx).call(TurnIntoCodeFence),
|
|
76
|
-
keyword: ['code'],
|
|
77
|
-
typeName: 'fence',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: 'divider',
|
|
81
|
-
dom: createDropdownItem(ctx.get(themeToolCtx), 'Divide Line', 'divider'),
|
|
82
|
-
command: () => ctx.get(commandsCtx).call(InsertHr),
|
|
83
|
-
keyword: ['divider', 'hr'],
|
|
84
|
-
typeName: 'hr',
|
|
85
|
-
},
|
|
86
|
-
];
|
|
87
|
-
const userInput = input.slice(1).toLocaleLowerCase();
|
|
88
|
-
return actions
|
|
89
|
-
.filter((action) => !!nodes[action.typeName] && action.keyword.some((keyword) => keyword.includes(userInput)))
|
|
90
|
-
.map((_a) => {
|
|
91
|
-
var { keyword, typeName } = _a, action = __rest(_a, ["keyword", "typeName"]);
|
|
92
|
-
return action;
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
export const defaultConfig = (ctx) => {
|
|
96
|
-
return ({ content, isTopLevel }) => {
|
|
97
|
-
if (!isTopLevel)
|
|
98
|
-
return null;
|
|
99
|
-
if (!content) {
|
|
100
|
-
return { placeholder: 'Type / to use the slash commands...' };
|
|
101
|
-
}
|
|
102
|
-
if (content.startsWith('/')) {
|
|
103
|
-
return content === '/'
|
|
104
|
-
? {
|
|
105
|
-
placeholder: 'Type to filter...',
|
|
106
|
-
actions: defaultActions(ctx),
|
|
107
|
-
}
|
|
108
|
-
: {
|
|
109
|
-
actions: defaultActions(ctx, content),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
//# sourceMappingURL=config.js.map
|
package/lib/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EACH,QAAQ,EACR,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,sB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MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAErD,OAAO,OAAO;SACT,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;SAC7G,GAAG,CAAC,CAAC,EAAgC,EAAE,EAAE;YAApC,EAAE,OAAO,EAAE,QAAQ,OAAa,EAAR,MAAM,cAA9B,uBAAgC,CAAF;QAAO,OAAA,MAAM,CAAA;KAAA,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAW,CAAC,GAAG,EAAE,EAAE;IACzC,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;QAC/B,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC;QAE7B,IAAI,CAAC,OAAO,EAAE;YACV,OAAO,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;SACjE;QAED,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACzB,OAAO,OAAO,KAAK,GAAG;gBAClB,CAAC,CAAC;oBACI,WAAW,EAAE,mBAAmB;oBAChC,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC;iBAC/B;gBACH,CAAC,CAAC;oBACI,OAAO,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC;iBACxC,CAAC;SACX;QAED,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { AtomList, createPlugin } from '@milkdown/utils';
|
|
3
|
-
import { defaultConfig } from './config';
|
|
4
|
-
import { createSlashPlugin } from './prose-plugin';
|
|
5
|
-
export { defaultActions, defaultConfig } from './config';
|
|
6
|
-
export { createDropdownItem } from './utility';
|
|
7
|
-
export const slashPlugin = createPlugin((utils, options) => {
|
|
8
|
-
var _a;
|
|
9
|
-
const slashConfig = (_a = options === null || options === void 0 ? void 0 : options.config) !== null && _a !== void 0 ? _a : defaultConfig;
|
|
10
|
-
return {
|
|
11
|
-
prosePlugins: (_, ctx) => {
|
|
12
|
-
const config = slashConfig(ctx);
|
|
13
|
-
const plugin = createSlashPlugin(utils, config);
|
|
14
|
-
return [plugin];
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
export const slash = AtomList.create([slashPlugin()]);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAM/C,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;;IACxE,MAAM,WAAW,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,aAAa,CAAC;IAErD,OAAO;QACH,YAAY,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YAEhC,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAEhD,OAAO,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC"}
|
package/lib/item.js
DELETED
package/lib/item.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAajD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAqB,EAAU,EAAE,CAAC,CAAC;IAC/D,EAAE,EAAE,MAAM,CAAC,EAAE;IACb,CAAC,EAAE,MAAM,CAAC,GAAG;IACb,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC;CAChD,CAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
|
|
3
|
-
export const renderDropdown = (status, dropdownElement, listeners) => {
|
|
4
|
-
const { actions } = status.get();
|
|
5
|
-
if (!actions.length) {
|
|
6
|
-
dropdownElement.classList.add('hide');
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
dropdownElement.childNodes.forEach((child) => {
|
|
10
|
-
child.removeEventListener('mouseenter', listeners.mouseEnter);
|
|
11
|
-
child.removeEventListener('mouseleave', listeners.mouseLeave);
|
|
12
|
-
});
|
|
13
|
-
// Reset dropdownElement children
|
|
14
|
-
dropdownElement.textContent = '';
|
|
15
|
-
actions.forEach(({ $ }) => {
|
|
16
|
-
$.classList.remove('active');
|
|
17
|
-
$.addEventListener('mouseenter', listeners.mouseEnter);
|
|
18
|
-
$.addEventListener('mouseleave', listeners.mouseLeave);
|
|
19
|
-
dropdownElement.appendChild($);
|
|
20
|
-
});
|
|
21
|
-
dropdownElement.classList.remove('hide');
|
|
22
|
-
actions[0].$.classList.add('active');
|
|
23
|
-
requestAnimationFrame(() => {
|
|
24
|
-
scrollIntoView(actions[0].$, {
|
|
25
|
-
scrollMode: 'if-needed',
|
|
26
|
-
block: 'nearest',
|
|
27
|
-
inline: 'nearest',
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
return true;
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=dropdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/prose-plugin/dropdown.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAS/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,eAA4B,EAAE,SAAoB,EAAW,EAAE;IAC1G,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;IAEjC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACjB,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC;KAChB;IAED,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACzC,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QAC9D,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,iCAAiC;IACjC,eAAe,CAAC,WAAW,GAAG,EAAE,CAAC;IAEjC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE;QACtB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CAAC,gBAAgB,CAAC,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC,CAAC,gBAAgB,CAAC,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QACvD,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEzC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrC,qBAAqB,CAAC,GAAG,EAAE;QACvB,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACzB,UAAU,EAAE,WAAW;YACvB,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;SACpB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { Plugin, PluginKey } from '@milkdown/prose';
|
|
3
|
-
import { createProps } from './props';
|
|
4
|
-
import { createStatus } from './status';
|
|
5
|
-
import { createView } from './view';
|
|
6
|
-
export const key = 'MILKDOWN_PLUGIN_SLASH';
|
|
7
|
-
export const createSlashPlugin = (utils, builder) => {
|
|
8
|
-
const status = createStatus(builder);
|
|
9
|
-
return new Plugin({
|
|
10
|
-
key: new PluginKey(key),
|
|
11
|
-
props: createProps(status, utils),
|
|
12
|
-
view: (view) => createView(status, view, utils),
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prose-plugin/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIpD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,CAAC,MAAM,GAAG,GAAG,uBAAuB,CAAC;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAY,EAAE,OAA4B,EAAE,EAAE;IAC5E,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAErC,OAAO,IAAI,MAAM,CAAC;QACd,GAAG,EAAE,IAAI,SAAS,CAAC,GAAG,CAAC;QACvB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC;QACjC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC;KAClD,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
|
|
3
|
-
export const createMouseManager = () => {
|
|
4
|
-
let mouseLock = false;
|
|
5
|
-
return {
|
|
6
|
-
isLock: () => mouseLock,
|
|
7
|
-
lock: () => {
|
|
8
|
-
mouseLock = true;
|
|
9
|
-
},
|
|
10
|
-
unlock: () => {
|
|
11
|
-
mouseLock = false;
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export const handleMouseMove = (mouseManager) => () => {
|
|
16
|
-
mouseManager.unlock();
|
|
17
|
-
};
|
|
18
|
-
export const handleMouseEnter = (status, mouseManager) => (e) => {
|
|
19
|
-
if (mouseManager.isLock())
|
|
20
|
-
return;
|
|
21
|
-
const { actions } = status.get();
|
|
22
|
-
const active = actions.findIndex((x) => x.$.classList.contains('active'));
|
|
23
|
-
if (active >= 0) {
|
|
24
|
-
actions[active].$.classList.remove('active');
|
|
25
|
-
}
|
|
26
|
-
const { target } = e;
|
|
27
|
-
if (!(target instanceof HTMLElement))
|
|
28
|
-
return;
|
|
29
|
-
target.classList.add('active');
|
|
30
|
-
};
|
|
31
|
-
export const handleMouseLeave = () => (e) => {
|
|
32
|
-
const { target } = e;
|
|
33
|
-
if (!(target instanceof HTMLElement))
|
|
34
|
-
return;
|
|
35
|
-
target.classList.remove('active');
|
|
36
|
-
};
|
|
37
|
-
export const handleClick = (status, view, dropdownElement) => (e) => {
|
|
38
|
-
const { target } = e;
|
|
39
|
-
if (!(target instanceof HTMLElement))
|
|
40
|
-
return;
|
|
41
|
-
if (!view)
|
|
42
|
-
return;
|
|
43
|
-
const stop = () => {
|
|
44
|
-
e.stopPropagation();
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
};
|
|
47
|
-
const { actions } = status.get();
|
|
48
|
-
const el = Object.values(actions).find(({ $ }) => $.contains(target));
|
|
49
|
-
if (!el) {
|
|
50
|
-
if (status.isEmpty())
|
|
51
|
-
return;
|
|
52
|
-
status.clear();
|
|
53
|
-
dropdownElement.classList.add('hide');
|
|
54
|
-
stop();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
stop();
|
|
58
|
-
el.command(view.state, view.dispatch, view);
|
|
59
|
-
};
|
|
60
|
-
export const handleKeydown = (status, view, dropdownElement, mouseManager) => (e) => {
|
|
61
|
-
if (!(e instanceof KeyboardEvent))
|
|
62
|
-
return;
|
|
63
|
-
if (!mouseManager.isLock())
|
|
64
|
-
mouseManager.lock();
|
|
65
|
-
const { key } = e;
|
|
66
|
-
if (status.isEmpty())
|
|
67
|
-
return;
|
|
68
|
-
if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(key))
|
|
69
|
-
return;
|
|
70
|
-
const { actions } = status.get();
|
|
71
|
-
let active = actions.findIndex(({ $ }) => $.classList.contains('active'));
|
|
72
|
-
if (active < 0)
|
|
73
|
-
active = 0;
|
|
74
|
-
const moveActive = (next) => {
|
|
75
|
-
actions[active].$.classList.remove('active');
|
|
76
|
-
actions[next].$.classList.add('active');
|
|
77
|
-
scrollIntoView(actions[next].$, {
|
|
78
|
-
scrollMode: 'if-needed',
|
|
79
|
-
block: 'nearest',
|
|
80
|
-
inline: 'nearest',
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
if (key === 'ArrowDown') {
|
|
84
|
-
const next = active === actions.length - 1 ? 0 : active + 1;
|
|
85
|
-
moveActive(next);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (key === 'ArrowUp') {
|
|
89
|
-
const next = active === 0 ? actions.length - 1 : active - 1;
|
|
90
|
-
moveActive(next);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (key === 'Escape') {
|
|
94
|
-
if (status.isEmpty())
|
|
95
|
-
return;
|
|
96
|
-
status.clear();
|
|
97
|
-
dropdownElement.classList.add('hide');
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
actions[active].command(view.state, view.dispatch, view);
|
|
101
|
-
actions[active].$.classList.remove('active');
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/prose-plugin/input.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAGzC,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAI/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACnC,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,OAAO;QACH,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS;QACvB,IAAI,EAAE,GAAG,EAAE;YACP,SAAS,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,MAAM,EAAE,GAAG,EAAE;YACT,SAAS,GAAG,KAAK,CAAC;QACtB,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,eAAe,GAAG,C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IAAI,MAAM,CAAC,OAAO,EAAE;YAAE,OAAO;QAE7B,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO;KACV;IAED,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
|
-
import { Decoration, DecorationSet, findParentNode } from '@milkdown/prose';
|
|
4
|
-
const createEmptyStyle = ({ font, palette }) => css `
|
|
5
|
-
position: relative;
|
|
6
|
-
&::before {
|
|
7
|
-
position: absolute;
|
|
8
|
-
cursor: text;
|
|
9
|
-
font-family: ${font.typography};
|
|
10
|
-
font-size: 0.875rem;
|
|
11
|
-
color: ${palette('neutral', 0.6)};
|
|
12
|
-
content: attr(data-text);
|
|
13
|
-
height: 100%;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
const createSlashStyle = () => css `
|
|
19
|
-
&::before {
|
|
20
|
-
left: 0.5rem;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
export const createProps = (status, utils) => {
|
|
24
|
-
const emptyStyle = utils.getStyle(createEmptyStyle);
|
|
25
|
-
const slashStyle = utils.getStyle(createSlashStyle);
|
|
26
|
-
return {
|
|
27
|
-
handleKeyDown: (_, event) => {
|
|
28
|
-
if (status.isEmpty()) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
if (!(event instanceof KeyboardEvent)) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
if (!['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
},
|
|
39
|
-
decorations: (state) => {
|
|
40
|
-
const paragraph = findParentNode(({ type }) => type.name === 'paragraph')(state.selection);
|
|
41
|
-
if (!paragraph ||
|
|
42
|
-
paragraph.node.childCount > 1 ||
|
|
43
|
-
state.selection.$from.parentOffset !== paragraph.node.textContent.length) {
|
|
44
|
-
status.clear();
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const { placeholder, actions } = status.update({
|
|
48
|
-
parentNode: state.selection.$from.node(state.selection.$from.depth - 1),
|
|
49
|
-
isTopLevel: state.selection.$from.depth === 1,
|
|
50
|
-
content: paragraph.node.textContent,
|
|
51
|
-
state,
|
|
52
|
-
});
|
|
53
|
-
if (!placeholder) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const createDecoration = (text, className) => {
|
|
57
|
-
const pos = paragraph.pos;
|
|
58
|
-
return DecorationSet.create(state.doc, [
|
|
59
|
-
Decoration.node(pos, pos + paragraph.node.nodeSize, {
|
|
60
|
-
class: className.filter((x) => x).join(' '),
|
|
61
|
-
'data-text': text,
|
|
62
|
-
}),
|
|
63
|
-
]);
|
|
64
|
-
};
|
|
65
|
-
if (actions.length) {
|
|
66
|
-
return createDecoration(placeholder, [emptyStyle, slashStyle, 'empty-node', 'is-slash']);
|
|
67
|
-
}
|
|
68
|
-
return createDecoration(placeholder, [emptyStyle, 'empty-node']);
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=props.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/prose-plugin/props.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,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;KACJ,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { transformAction } from '../item';
|
|
2
|
-
const createStatusCtx = () => {
|
|
3
|
-
return {
|
|
4
|
-
placeholder: null,
|
|
5
|
-
actions: [],
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export const createStatus = (builder) => {
|
|
9
|
-
const statusCtx = createStatusCtx();
|
|
10
|
-
return {
|
|
11
|
-
get: () => statusCtx,
|
|
12
|
-
clear: () => {
|
|
13
|
-
statusCtx.placeholder = null;
|
|
14
|
-
statusCtx.actions = [];
|
|
15
|
-
},
|
|
16
|
-
update: (builderParams) => {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
const config = builder(builderParams);
|
|
19
|
-
statusCtx.placeholder = (_a = config === null || config === void 0 ? void 0 : config.placeholder) !== null && _a !== void 0 ? _a : null;
|
|
20
|
-
statusCtx.actions = ((_b = config === null || config === void 0 ? void 0 : config.actions) !== null && _b !== void 0 ? _b : []).map(transformAction);
|
|
21
|
-
return statusCtx;
|
|
22
|
-
},
|
|
23
|
-
isEmpty: () => statusCtx.actions.length === 0,
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/prose-plugin/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,eAAe,EAAE,MAAM,SAAS,CAAC;AAOlD,MAAM,eAAe,GAAG,GAAc,EAAE;IACpC,OAAO;QACH,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,EAAE;KACd,CAAC;AACN,CAAC,CAAC;AAIF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAA4B,EAAE,EAAE;IACzD,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;IAEpC,OAAO;QACH,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;QACpB,KAAK,EAAE,GAAG,EAAE;YACR,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC;YAC7B,SAAS,CAAC,OAAO,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,MAAM,EAAE,CAAC,aAAwC,EAAE,EAAE;;YACjD,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;YACtC,SAAS,CAAC,WAAW,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,mCAAI,IAAI,CAAC;YACpD,SAAS,CAAC,OAAO,GAAG,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YACjE,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;KAChD,CAAC;AACN,CAAC,CAAC"}
|
package/lib/prose-plugin/view.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { calculateNodePosition } from '@milkdown/prose';
|
|
3
|
-
import { createDropdown } from '../utility';
|
|
4
|
-
import { renderDropdown } from './dropdown';
|
|
5
|
-
import { createMouseManager, handleClick, handleKeydown, handleMouseEnter, handleMouseLeave, handleMouseMove, } from './input';
|
|
6
|
-
const calculatePosition = (view, dropdownElement) => {
|
|
7
|
-
calculateNodePosition(view, dropdownElement, (selected, target, parent) => {
|
|
8
|
-
let left = selected.left - parent.left;
|
|
9
|
-
let top = selected.bottom - parent.top + 14;
|
|
10
|
-
if (left < 0) {
|
|
11
|
-
left = 0;
|
|
12
|
-
}
|
|
13
|
-
if (window.innerHeight - selected.bottom < target.height) {
|
|
14
|
-
top = selected.top - parent.top - target.height - 14;
|
|
15
|
-
}
|
|
16
|
-
return [top, left];
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
export const createView = (status, view, utils) => {
|
|
20
|
-
const wrapper = view.dom.parentNode;
|
|
21
|
-
if (!wrapper)
|
|
22
|
-
return {};
|
|
23
|
-
const dropdownElement = createDropdown(utils);
|
|
24
|
-
const mouseManager = createMouseManager();
|
|
25
|
-
wrapper.appendChild(dropdownElement);
|
|
26
|
-
const _mouseMove = handleMouseMove(mouseManager);
|
|
27
|
-
const _mouseDown = handleClick(status, view, dropdownElement);
|
|
28
|
-
const _keydown = handleKeydown(status, view, dropdownElement, mouseManager);
|
|
29
|
-
const _mouseEnter = handleMouseEnter(status, mouseManager);
|
|
30
|
-
const _mouseLeave = handleMouseLeave();
|
|
31
|
-
wrapper.addEventListener('mousemove', _mouseMove);
|
|
32
|
-
wrapper.addEventListener('mousedown', _mouseDown);
|
|
33
|
-
wrapper.addEventListener('keydown', _keydown);
|
|
34
|
-
return {
|
|
35
|
-
update: (view) => {
|
|
36
|
-
const show = renderDropdown(status, dropdownElement, {
|
|
37
|
-
mouseEnter: _mouseEnter,
|
|
38
|
-
mouseLeave: _mouseLeave,
|
|
39
|
-
});
|
|
40
|
-
if (!show)
|
|
41
|
-
return;
|
|
42
|
-
calculatePosition(view, dropdownElement);
|
|
43
|
-
},
|
|
44
|
-
destroy: () => {
|
|
45
|
-
wrapper.removeEventListener('mousemove', _mouseMove);
|
|
46
|
-
wrapper.removeEventListener('mousedown', _mouseDown);
|
|
47
|
-
wrapper.removeEventListener('keydown', _keydown);
|
|
48
|
-
dropdownElement.remove();
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=view.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/prose-plugin/view.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,qBAAqB,EAAc,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YA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M,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;IAC5E,MAAM,WAAW,GAAG,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,gBAAgB,EAAE,CAAC;IAEvC,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAClD,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAClD,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAE9C,OAAO;QACH,MAAM,EAAE,CAAC,IAAgB,EAAE,EAAE;YACzB,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE;gBACjD,UAAU,EAAE,WAA4B;gBACxC,UAAU,EAAE,WAA4B;aAC3C,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI;gBAAE,OAAO;YAElB,iBAAiB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,EAAE,GAAG,EAAE;YACV,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;YACrD,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;YACrD,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACjD,eAAe,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC;KACJ,CAAC;AACN,CAAC,CAAC"}
|
package/lib/style.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
|
-
const itemStyle = ({ font, palette }) => {
|
|
4
|
-
return css `
|
|
5
|
-
.slash-dropdown-item {
|
|
6
|
-
display: flex;
|
|
7
|
-
gap: 2rem;
|
|
8
|
-
height: 3rem;
|
|
9
|
-
padding: 0 1rem;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: flex-start;
|
|
12
|
-
cursor: pointer;
|
|
13
|
-
line-height: 2;
|
|
14
|
-
font-family: ${font.typography};
|
|
15
|
-
font-size: 0.875rem;
|
|
16
|
-
|
|
17
|
-
transition: all 0.2s ease-in-out;
|
|
18
|
-
|
|
19
|
-
&,
|
|
20
|
-
.icon {
|
|
21
|
-
color: ${palette('neutral', 0.87)};
|
|
22
|
-
transition: all 0.2s ease-in-out;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&.hide {
|
|
26
|
-
display: none;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&.active {
|
|
30
|
-
background: ${palette('secondary', 0.12)};
|
|
31
|
-
&,
|
|
32
|
-
.icon {
|
|
33
|
-
color: ${palette('primary')};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
};
|
|
38
|
-
export const injectStyle = (themeTool) => {
|
|
39
|
-
var _a, _b, _c;
|
|
40
|
-
const { mixin, size, palette } = themeTool;
|
|
41
|
-
const style = css `
|
|
42
|
-
width: 20.5rem;
|
|
43
|
-
max-height: 20.5rem;
|
|
44
|
-
overflow-y: auto;
|
|
45
|
-
${(_a = mixin.border) === null || _a === void 0 ? void 0 : _a.call(mixin)};
|
|
46
|
-
border-radius: ${size.radius};
|
|
47
|
-
position: absolute;
|
|
48
|
-
background: ${palette('surface')};
|
|
49
|
-
|
|
50
|
-
${(_b = mixin.shadow) === null || _b === void 0 ? void 0 : _b.call(mixin)};
|
|
51
|
-
|
|
52
|
-
&.hide {
|
|
53
|
-
display: none;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
${(_c = mixin.scrollbar) === null || _c === void 0 ? void 0 : _c.call(mixin)};
|
|
57
|
-
|
|
58
|
-
${itemStyle(themeTool)}
|
|
59
|
-
`;
|
|
60
|
-
return style;
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=style.js.map
|
package/lib/style.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGnC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAa,EAAE,EAAE;IAC/C,OAAO,GAAG,CAAA;;;;;;;;;;2BAUa,IAAI,CAAC,UAAU;;;;;;;yBAOjB,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC;;;;;;;;;8BASnB,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;;;6BAG3B,OAAO,CAAC,SAAS,CAAC;;;aAGlC,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAAoB,EAAE,EAAE;;IAChD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;IAC3C,MAAM,KAAK,GAAG,GAAG,CAAA;;;;UAIX,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW;yBACD,IAAI,CAAC,MAAM;;sBAEd,OAAO,CAAC,SAAS,CAAC;;UAE9B,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW;;;;;;UAMhB,MAAA,KAAK,CAAC,SAAS,+CAAf,KAAK,CAAc;;UAEnB,SAAS,CAAC,SAAS,CAAC;KACzB,CAAC;IACF,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC"}
|
package/lib/utility.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { injectStyle } from './style';
|
|
2
|
-
export const createDropdown = (utils) => {
|
|
3
|
-
const div = document.createElement('div');
|
|
4
|
-
div.setAttribute('role', 'listbox');
|
|
5
|
-
div.setAttribute('tabindex', '-1');
|
|
6
|
-
const style = utils.getStyle(injectStyle);
|
|
7
|
-
if (style) {
|
|
8
|
-
div.classList.add(style);
|
|
9
|
-
}
|
|
10
|
-
div.classList.add('slash-dropdown', 'hide');
|
|
11
|
-
return div;
|
|
12
|
-
};
|
|
13
|
-
export const createDropdownItem = (themeTool, text, icon, options) => {
|
|
14
|
-
var _a;
|
|
15
|
-
const textClassName = (_a = options === null || options === void 0 ? void 0 : options.textClassName) !== null && _a !== void 0 ? _a : 'text';
|
|
16
|
-
const div = document.createElement('div');
|
|
17
|
-
div.setAttribute('role', 'option');
|
|
18
|
-
div.classList.add('slash-dropdown-item');
|
|
19
|
-
const iconSpan = themeTool.slots.icon(icon);
|
|
20
|
-
const textSpan = document.createElement('span');
|
|
21
|
-
textSpan.textContent = text;
|
|
22
|
-
textSpan.className = textClassName;
|
|
23
|
-
div.appendChild(iconSpan);
|
|
24
|
-
div.appendChild(textSpan);
|
|
25
|
-
return div;
|
|
26
|
-
};
|
|
27
|
-
export const getDepth = (node) => {
|
|
28
|
-
let cur = node;
|
|
29
|
-
let depth = 0;
|
|
30
|
-
while (cur.childCount) {
|
|
31
|
-
cur = cur.child(0);
|
|
32
|
-
depth += 1;
|
|
33
|
-
}
|
|
34
|
-
return depth;
|
|
35
|
-
};
|
|
36
|
-
const cleanUp = (state, dispatch) => {
|
|
37
|
-
const { selection } = state;
|
|
38
|
-
const { $from } = selection;
|
|
39
|
-
const tr = state.tr.deleteRange($from.start(), $from.pos);
|
|
40
|
-
dispatch === null || dispatch === void 0 ? void 0 : dispatch(tr);
|
|
41
|
-
return false;
|
|
42
|
-
};
|
|
43
|
-
export const cleanUpAndCreateNode = (createCommand) => (state, dispatch, view) => {
|
|
44
|
-
if (view) {
|
|
45
|
-
cleanUp(state, dispatch, view);
|
|
46
|
-
createCommand();
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=utility.js.map
|
package/lib/utility.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{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