@milkdown/plugin-slash 5.4.0 → 6.0.0-next.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.
Files changed (45) hide show
  1. package/lib/{src/config.d.ts → config.d.ts} +1 -0
  2. package/lib/config.d.ts.map +1 -0
  3. package/lib/index.d.ts +25 -1
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.es.js +104 -86
  6. package/lib/index.es.js.map +1 -1
  7. package/lib/{src/item.d.ts → item.d.ts} +0 -0
  8. package/lib/item.d.ts.map +1 -0
  9. package/lib/{src/prose-plugin → prose-plugin}/dropdown.d.ts +0 -0
  10. package/lib/prose-plugin/dropdown.d.ts.map +1 -0
  11. package/lib/{src/prose-plugin → prose-plugin}/index.d.ts +0 -0
  12. package/lib/prose-plugin/index.d.ts.map +1 -0
  13. package/lib/{src/prose-plugin → prose-plugin}/input.d.ts +0 -0
  14. package/lib/prose-plugin/input.d.ts.map +1 -0
  15. package/lib/{src/prose-plugin → prose-plugin}/props.d.ts +0 -0
  16. package/lib/prose-plugin/props.d.ts.map +1 -0
  17. package/lib/{src/prose-plugin → prose-plugin}/status.d.ts +0 -0
  18. package/lib/prose-plugin/status.d.ts.map +1 -0
  19. package/lib/{src/prose-plugin → prose-plugin}/view.d.ts +0 -0
  20. package/lib/prose-plugin/view.d.ts.map +1 -0
  21. package/lib/style.d.ts +3 -0
  22. package/lib/style.d.ts.map +1 -0
  23. package/lib/{src/utility.d.ts → utility.d.ts} +2 -2
  24. package/lib/utility.d.ts.map +1 -0
  25. package/package.json +33 -11
  26. package/src/config.ts +23 -34
  27. package/src/prose-plugin/dropdown.ts +13 -9
  28. package/src/prose-plugin/input.ts +13 -7
  29. package/src/prose-plugin/props.ts +28 -22
  30. package/src/prose-plugin/view.ts +1 -1
  31. package/src/style.ts +30 -20
  32. package/src/utility.ts +20 -8
  33. package/lib/src/config.d.ts.map +0 -1
  34. package/lib/src/index.d.ts +0 -25
  35. package/lib/src/index.d.ts.map +0 -1
  36. package/lib/src/item.d.ts.map +0 -1
  37. package/lib/src/prose-plugin/dropdown.d.ts.map +0 -1
  38. package/lib/src/prose-plugin/index.d.ts.map +0 -1
  39. package/lib/src/prose-plugin/input.d.ts.map +0 -1
  40. package/lib/src/prose-plugin/props.d.ts.map +0 -1
  41. package/lib/src/prose-plugin/status.d.ts.map +0 -1
  42. package/lib/src/prose-plugin/view.d.ts.map +0 -1
  43. package/lib/src/style.d.ts +0 -3
  44. package/lib/src/style.d.ts.map +0 -1
  45. package/lib/src/utility.d.ts.map +0 -1
@@ -1,3 +1,4 @@
1
+ /// <reference types="prosemirror-model" />
1
2
  import { Ctx } from '@milkdown/core';
2
3
  import { EditorState, Node } from '@milkdown/prose';
3
4
  import { WrappedAction } from './item';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AACA,OAAO,EAAe,GAAG,EAA8B,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,aAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAExC,oBAAY,YAAY,GAAG;IACvB,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;CACvC,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,IAAI,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,oBAAY,mBAAmB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,QAAQ,CAAC,YAAY,CAAC,CAAC;AAEhG,oBAAY,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,mBAAmB,CAAC;AAEvD,eAAO,MAAM,cAAc,QAAS,GAAG,qBAAgB,aAAa,EAuFnE,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAqB3B,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1 +1,25 @@
1
- export * from './src/index'
1
+ import { AtomList } from '@milkdown/utils';
2
+ import type { Config } from './config';
3
+ export type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';
4
+ export { defaultActions, defaultConfig } from './config';
5
+ export { createDropdownItem } from './utility';
6
+ export declare type Options = {
7
+ config: Config;
8
+ };
9
+ export declare const slashPlugin: import("@milkdown/utils/lib/types").WithExtend<string, Options, {
10
+ [x: string]: import("prosemirror-model").NodeType<any>;
11
+ } & {
12
+ [x: string]: import("prosemirror-model").MarkType<any>;
13
+ }, {
14
+ schema?: ((ctx: import("@milkdown/core").Ctx) => {
15
+ node?: Record<string, import("@milkdown/core").NodeSchema> | undefined;
16
+ mark?: Record<string, import("@milkdown/core").MarkSchema> | undefined;
17
+ }) | undefined;
18
+ view?: ((ctx: import("@milkdown/core").Ctx) => Partial<{
19
+ [x: string]: import("@milkdown/prose").NodeViewFactory;
20
+ } & {
21
+ [x: string]: import("@milkdown/prose").MarkViewFactory;
22
+ }>) | undefined;
23
+ }>;
24
+ export declare const slash: AtomList<import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<string, Options>> & import("@milkdown/core").MilkdownPlugin>;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,oBAAY,OAAO,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;EAYtB,CAAC;AAEH,eAAO,MAAM,KAAK,kKAAmC,CAAC"}
package/lib/index.es.js CHANGED
@@ -14,24 +14,23 @@ var __objRest = (source, exclude) => {
14
14
  return target;
15
15
  };
16
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";
17
+ import { ThemeSize, ThemeColor, ThemeBorder, ThemeShadow, ThemeScrollbar, ThemeFont, ThemeIcon, schemaCtx, themeManagerCtx, commandsCtx } from "@milkdown/core";
19
18
  import { findParentNode, DecorationSet, Decoration, calculateNodePosition, Plugin, PluginKey } from "@milkdown/prose";
20
- import { key as key$1 } from "@milkdown/plugin-upload";
21
19
  import scrollIntoView from "smooth-scroll-into-view-if-needed";
22
- const itemStyle = ({ font, palette }, { css }) => {
20
+ const itemStyle = (themeManager, { css }) => {
21
+ const palette = (color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);
23
22
  return css`
24
23
  .slash-dropdown-item {
25
24
  display: flex;
26
- gap: 2rem;
27
- height: 3rem;
28
- padding: 0 1rem;
25
+ gap: 2em;
26
+ height: 3.4286em;
27
+ padding: 0 1em;
29
28
  align-items: center;
30
29
  justify-content: flex-start;
31
30
  cursor: pointer;
32
- line-height: 2;
33
- font-family: ${font.typography};
34
- font-size: 0.875rem;
31
+ line-height: 3.4286em;
32
+ font-family: ${themeManager.get(ThemeFont, "typography")};
33
+ font-size: 0.875em;
35
34
 
36
35
  transition: all 0.2s ease-in-out;
37
36
 
@@ -54,52 +53,54 @@ const itemStyle = ({ font, palette }, { css }) => {
54
53
  }
55
54
  `;
56
55
  };
57
- const injectStyle = (themeTool, emotion) => {
58
- var _a, _b, _c;
59
- const { mixin, size, palette } = themeTool;
60
- const style = emotion.css`
61
- width: 20.5rem;
62
- max-height: 20.5rem;
56
+ const injectStyle = (themeManager, emotion) => {
57
+ const palette = (color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);
58
+ return emotion.css`
59
+ width: 20.5em;
60
+ max-height: 20.5em;
63
61
  overflow-y: auto;
64
- ${(_a = mixin.border) == null ? void 0 : _a.call(mixin)};
65
- border-radius: ${size.radius};
62
+ border-radius: ${themeManager.get(ThemeSize, "radius")};
66
63
  position: absolute;
67
64
  background: ${palette("surface")};
68
65
 
69
- ${(_b = mixin.shadow) == null ? void 0 : _b.call(mixin)};
66
+ ${themeManager.get(ThemeBorder, void 0)}
67
+ ${themeManager.get(ThemeShadow, void 0)}
68
+ ${themeManager.get(ThemeScrollbar, void 0)}
70
69
 
71
70
  &.hide {
72
71
  display: none;
73
72
  }
74
73
 
75
- ${(_c = mixin.scrollbar) == null ? void 0 : _c.call(mixin)};
76
-
77
- ${itemStyle(themeTool, emotion)}
74
+ ${itemStyle(themeManager, emotion)}
78
75
  `;
79
- return style;
80
76
  };
81
77
  const createDropdown = (utils) => {
82
78
  const div = document.createElement("div");
83
79
  div.setAttribute("role", "listbox");
84
80
  div.setAttribute("tabindex", "-1");
85
- const style = utils.getStyle(injectStyle);
86
- if (style) {
87
- div.classList.add(style);
88
- }
81
+ utils.themeManager.onFlush(() => {
82
+ const style = utils.getStyle(injectStyle);
83
+ if (style) {
84
+ div.classList.add(style);
85
+ }
86
+ });
89
87
  div.classList.add("slash-dropdown", "hide");
90
88
  return div;
91
89
  };
92
- const createDropdownItem = (themeTool, text, icon, options) => {
90
+ const createDropdownItem = (themeManager, text, icon, options) => {
93
91
  var _a;
94
92
  const textClassName = (_a = options == null ? void 0 : options.textClassName) != null ? _a : "text";
95
93
  const div = document.createElement("div");
96
94
  div.setAttribute("role", "option");
97
95
  div.classList.add("slash-dropdown-item");
98
- const iconSpan = themeTool.slots.icon(icon);
96
+ const iconSpan = themeManager.get(ThemeIcon, icon);
97
+ if (!iconSpan) {
98
+ throw new Error("icon not found");
99
+ }
99
100
  const textSpan = document.createElement("span");
100
101
  textSpan.textContent = text;
101
102
  textSpan.className = textClassName;
102
- div.appendChild(iconSpan);
103
+ div.appendChild(iconSpan.dom);
103
104
  div.appendChild(textSpan);
104
105
  return div;
105
106
  };
@@ -122,78 +123,78 @@ const defaultActions = (ctx, input = "/") => {
122
123
  const actions = [
123
124
  {
124
125
  id: "h1",
125
- dom: createDropdownItem(ctx.get(themeToolCtx), "Large Heading", "h1"),
126
- command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 1),
126
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Large Heading", "h1"),
127
+ command: () => ctx.get(commandsCtx).callByName("TurnIntoHeading", 1),
127
128
  keyword: ["h1", "large heading"],
128
129
  typeName: "heading"
129
130
  },
130
131
  {
131
132
  id: "h2",
132
- dom: createDropdownItem(ctx.get(themeToolCtx), "Medium Heading", "h2"),
133
- command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 2),
133
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Medium Heading", "h2"),
134
+ command: () => ctx.get(commandsCtx).callByName("TurnIntoHeading", 2),
134
135
  keyword: ["h2", "medium heading"],
135
136
  typeName: "heading"
136
137
  },
137
138
  {
138
139
  id: "h3",
139
- dom: createDropdownItem(ctx.get(themeToolCtx), "Small Heading", "h3"),
140
- command: () => ctx.get(commandsCtx).call(TurnIntoHeading, 3),
140
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Small Heading", "h3"),
141
+ command: () => ctx.get(commandsCtx).callByName("TurnIntoHeading", 3),
141
142
  keyword: ["h3", "small heading"],
142
143
  typeName: "heading"
143
144
  },
144
145
  {
145
146
  id: "bulletList",
146
- dom: createDropdownItem(ctx.get(themeToolCtx), "Bullet List", "bulletList"),
147
- command: () => ctx.get(commandsCtx).call(WrapInBulletList),
147
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Bullet List", "bulletList"),
148
+ command: () => ctx.get(commandsCtx).callByName("WrapInBulletList"),
148
149
  keyword: ["bullet list", "ul"],
149
150
  typeName: "bullet_list"
150
151
  },
151
152
  {
152
153
  id: "orderedList",
153
- dom: createDropdownItem(ctx.get(themeToolCtx), "Ordered List", "orderedList"),
154
- command: () => ctx.get(commandsCtx).call(WrapInOrderedList),
154
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Ordered List", "orderedList"),
155
+ command: () => ctx.get(commandsCtx).callByName("WrapInOrderedList"),
155
156
  keyword: ["ordered list", "ol"],
156
157
  typeName: "ordered_list"
157
158
  },
158
159
  {
159
160
  id: "taskList",
160
- dom: createDropdownItem(ctx.get(themeToolCtx), "Task List", "taskList"),
161
- command: () => ctx.get(commandsCtx).call(TurnIntoTaskList),
161
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Task List", "taskList"),
162
+ command: () => ctx.get(commandsCtx).callByName("TurnIntoTaskList"),
162
163
  keyword: ["task list", "task"],
163
164
  typeName: "task_list_item"
164
165
  },
165
166
  {
166
167
  id: "image",
167
- dom: createDropdownItem(ctx.get(themeToolCtx), "Image", "image"),
168
- command: () => ctx.get(commandsCtx).call(InsertImage),
168
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Image", "image"),
169
+ command: () => ctx.get(commandsCtx).callByName("InsertImage"),
169
170
  keyword: ["image"],
170
171
  typeName: "image"
171
172
  },
172
173
  {
173
174
  id: "blockquote",
174
- dom: createDropdownItem(ctx.get(themeToolCtx), "Quote", "quote"),
175
- command: () => ctx.get(commandsCtx).call(WrapInBlockquote),
175
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Quote", "quote"),
176
+ command: () => ctx.get(commandsCtx).callByName("WrapInBlockquote"),
176
177
  keyword: ["quote", "blockquote"],
177
178
  typeName: "blockquote"
178
179
  },
179
180
  {
180
181
  id: "table",
181
- dom: createDropdownItem(ctx.get(themeToolCtx), "Table", "table"),
182
- command: () => ctx.get(commandsCtx).call(InsertTable),
182
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Table", "table"),
183
+ command: () => ctx.get(commandsCtx).callByName("InsertTable"),
183
184
  keyword: ["table"],
184
185
  typeName: "table"
185
186
  },
186
187
  {
187
188
  id: "code",
188
- dom: createDropdownItem(ctx.get(themeToolCtx), "Code Fence", "code"),
189
- command: () => ctx.get(commandsCtx).call(TurnIntoCodeFence),
189
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Code Fence", "code"),
190
+ command: () => ctx.get(commandsCtx).callByName("TurnIntoCodeFence"),
190
191
  keyword: ["code"],
191
192
  typeName: "fence"
192
193
  },
193
194
  {
194
195
  id: "divider",
195
- dom: createDropdownItem(ctx.get(themeToolCtx), "Divide Line", "divider"),
196
- command: () => ctx.get(commandsCtx).call(InsertHr),
196
+ dom: createDropdownItem(ctx.get(themeManagerCtx), "Divide Line", "divider"),
197
+ command: () => ctx.get(commandsCtx).callByName("InsertHr"),
197
198
  keyword: ["divider", "hr"],
198
199
  typeName: "hr"
199
200
  }
@@ -222,28 +223,30 @@ const defaultConfig = (ctx) => {
222
223
  return null;
223
224
  };
224
225
  };
225
- const createEmptyStyle = ({ font, palette }, { css }) => 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
- `;
226
+ const createEmptyStyle = (themeManager, { css }) => {
227
+ const palette = (color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);
228
+ const typography = themeManager.get(ThemeFont, "typography");
229
+ return css`
230
+ position: relative;
231
+ &::before {
232
+ position: absolute;
233
+ cursor: text;
234
+ font-family: ${typography};
235
+ font-size: 0.875em;
236
+ color: ${palette("neutral", 0.6)};
237
+ content: attr(data-text);
238
+ height: 100%;
239
+ display: flex;
240
+ align-items: center;
241
+ }
242
+ `;
243
+ };
239
244
  const createSlashStyle = (_, { css }) => css`
240
245
  &::before {
241
- left: 0.5rem;
246
+ left: 0.5em;
242
247
  }
243
248
  `;
244
249
  const createProps = (status, utils) => {
245
- const emptyStyle = utils.getStyle(createEmptyStyle);
246
- const slashStyle = utils.getStyle(createSlashStyle);
247
250
  return {
248
251
  handleKeyDown: (_, event) => {
249
252
  if (status.isEmpty()) {
@@ -259,7 +262,7 @@ const createProps = (status, utils) => {
259
262
  },
260
263
  decorations: (state) => {
261
264
  const paragraph = findParentNode(({ type }) => type.name === "paragraph")(state.selection);
262
- const uploadPlugin = state.plugins.find((x) => x.spec.key === key$1);
265
+ const uploadPlugin = state.plugins.find((x) => x.key === "MILKDOWN_PLUGIN_UPLOAD$");
263
266
  const decorations = uploadPlugin == null ? void 0 : uploadPlugin.getState(state);
264
267
  if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {
265
268
  status.clear();
@@ -287,6 +290,8 @@ const createProps = (status, utils) => {
287
290
  })
288
291
  ]);
289
292
  };
293
+ const emptyStyle = utils.getStyle(createEmptyStyle);
294
+ const slashStyle = utils.getStyle(createSlashStyle);
290
295
  if (actions.length) {
291
296
  return createDecoration(placeholder, [emptyStyle, slashStyle, "empty-node", "is-slash"]);
292
297
  }
@@ -333,7 +338,9 @@ const renderDropdown = (status, dropdownElement, listeners) => {
333
338
  child.removeEventListener("mouseenter", listeners.mouseEnter);
334
339
  child.removeEventListener("mouseleave", listeners.mouseLeave);
335
340
  });
336
- dropdownElement.textContent = "";
341
+ while (dropdownElement.firstChild) {
342
+ dropdownElement.firstChild.remove();
343
+ }
337
344
  actions.forEach(({ $ }) => {
338
345
  $.classList.remove("active");
339
346
  $.addEventListener("mouseenter", listeners.mouseEnter);
@@ -341,14 +348,17 @@ const renderDropdown = (status, dropdownElement, listeners) => {
341
348
  dropdownElement.appendChild($);
342
349
  });
343
350
  dropdownElement.classList.remove("hide");
344
- actions[0].$.classList.add("active");
345
- requestAnimationFrame(() => {
346
- scrollIntoView(actions[0].$, {
347
- scrollMode: "if-needed",
348
- block: "nearest",
349
- inline: "nearest"
351
+ const first$ = actions[0];
352
+ if (first$) {
353
+ first$.$.classList.add("active");
354
+ requestAnimationFrame(() => {
355
+ scrollIntoView(first$.$, {
356
+ scrollMode: "if-needed",
357
+ block: "nearest",
358
+ inline: "nearest"
359
+ });
350
360
  });
351
- });
361
+ }
352
362
  return true;
353
363
  };
354
364
  const createMouseManager = () => {
@@ -371,8 +381,9 @@ const handleMouseEnter = (status, mouseManager) => (e) => {
371
381
  return;
372
382
  const { actions } = status.get();
373
383
  const active = actions.findIndex((x) => x.$.classList.contains("active"));
374
- if (active >= 0) {
375
- actions[active].$.classList.remove("active");
384
+ const active$ = actions[active];
385
+ if (active$ && active >= 0) {
386
+ active$.$.classList.remove("active");
376
387
  }
377
388
  const { target } = e;
378
389
  if (!(target instanceof HTMLElement))
@@ -423,9 +434,13 @@ const handleKeydown = (status, view, dropdownElement, mouseManager) => (e) => {
423
434
  if (active < 0)
424
435
  active = 0;
425
436
  const moveActive = (next) => {
426
- actions[active].$.classList.remove("active");
427
- actions[next].$.classList.add("active");
428
- scrollIntoView(actions[next].$, {
437
+ const active$2 = actions[active];
438
+ const next$ = actions[next];
439
+ if (!active$2 || !next$)
440
+ return;
441
+ active$2.$.classList.remove("active");
442
+ next$.$.classList.add("active");
443
+ scrollIntoView(next$.$, {
429
444
  scrollMode: "if-needed",
430
445
  block: "nearest",
431
446
  inline: "nearest"
@@ -448,8 +463,11 @@ const handleKeydown = (status, view, dropdownElement, mouseManager) => (e) => {
448
463
  dropdownElement.classList.add("hide");
449
464
  return;
450
465
  }
451
- actions[active].command(view.state, view.dispatch, view);
452
- actions[active].$.classList.remove("active");
466
+ const active$ = actions[active];
467
+ if (!active$)
468
+ return;
469
+ active$.command(view.state, view.dispatch, view);
470
+ active$.$.classList.remove("active");
453
471
  };
454
472
  const calculatePosition = (view, dropdownElement) => {
455
473
  calculateNodePosition(view, dropdownElement, (selected, target, parent) => {
@@ -462,7 +480,7 @@ const calculatePosition = (view, dropdownElement) => {
462
480
  if (left < 0) {
463
481
  left = 0;
464
482
  }
465
- if (window.innerHeight - selected.bottom < target.height) {
483
+ if (parent.height + parent.top - selected.bottom < target.height) {
466
484
  top = selected.top - parent.top - target.height - 14 + $editor.scrollTop;
467
485
  }
468
486
  return [top, left];
@@ -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 { Emotion, ThemeTool } from '@milkdown/core';\n\nconst itemStyle = ({ font, palette }: ThemeTool, { css }: Emotion) => {\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, emotion: Emotion) => {\n const { mixin, size, palette } = themeTool;\n const style = emotion.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, emotion)}\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, Ctx, schemaCtx, themeToolCtx } from '@milkdown/core';\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 { Emotion, ThemeTool } from '@milkdown/core';\nimport { key as uploadKey } from '@milkdown/plugin-upload';\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 }: Emotion) => 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 = (_: ThemeTool, { css }: Emotion) => 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 const uploadPlugin = state.plugins.find((x) => x.spec.key === uploadKey);\n const decorations: DecorationSet = uploadPlugin?.getState(state);\n if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {\n status.clear();\n return;\n }\n\n if (\n !paragraph ||\n paragraph.node.childCount > 1 ||\n state.selection.$from.parentOffset !== paragraph.node.textContent.length ||\n (paragraph.node.firstChild && paragraph.node.firstChild.type.name !== 'text')\n ) {\n status.clear();\n return;\n }\n\n const { placeholder, actions } = status.update({\n parentNode: state.selection.$from.node(state.selection.$from.depth - 1),\n isTopLevel: state.selection.$from.depth === 1,\n content: paragraph.node.textContent,\n state,\n });\n\n if (!placeholder) {\n return null;\n }\n\n const createDecoration = (text: string, className: (string | undefined)[]) => {\n const pos = paragraph.pos;\n return DecorationSet.create(state.doc, [\n Decoration.node(pos, pos + paragraph.node.nodeSize, {\n class: className.filter((x) => x).join(' '),\n 'data-text': text,\n }),\n ]);\n };\n\n 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 const $editor = dropdownElement.parentElement;\n if (!$editor) {\n throw new Error();\n }\n\n let left = selected.left - parent.left;\n let top = selected.bottom - parent.top + 14 + $editor.scrollTop;\n\n if (left < 0) {\n left = 0;\n }\n\n if (window.innerHeight - selected.bottom < target.height) {\n top = selected.top - parent.top - target.height - 14 + $editor.scrollTop;\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":["uploadKey"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,YAAY,CAAC,EAAE,MAAM,WAAsB,EAAE,UAAmB;SAC3D;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,WAAsB,YAAqB;;QAC7D,EAAE,OAAO,MAAM,YAAY;QAC3B,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA,UAIhB,YAAM,WAAN;AAAA,yBACe,KAAK;AAAA;AAAA,sBAER,QAAQ;AAAA;AAAA,UAEpB,YAAM,WAAN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAMA,YAAM,cAAN;AAAA;AAAA,UAEA,UAAU,WAAW;AAAA;SAEpB;AAAA;MCpDE,iBAAiB,CAAC,UAAiB;QACtC,MAAM,SAAS,cAAc;MAC/B,aAAa,QAAQ;MACrB,aAAa,YAAY;QACvB,QAAQ,MAAM,SAAS;MAEzB,OAAO;QACH,UAAU,IAAI;AAAA;MAGlB,UAAU,IAAI,kBAA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AChB,SAAS,YAAY;YAErB,SAAS,kBAAkB,OAAO;aAEjC,CAAC;AAAA;AAAA;AAAA;MAKP,QAAQ,SAAS,OAAO,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: 2em;\n height: 3.4286em;\n padding: 0 1em;\n align-items: center;\n justify-content: flex-start;\n cursor: pointer;\n line-height: 3.4286em;\n font-family: ${themeManager.get(ThemeFont, 'typography')};\n font-size: 0.875em;\n\n transition: all 0.2s ease-in-out;\n\n &,\n .icon {\n color: ${palette('neutral', 0.87)};\n transition: all 0.2s ease-in-out;\n }\n\n &.hide {\n display: none;\n }\n\n &.active {\n background: ${palette('secondary', 0.12)};\n &,\n .icon {\n color: ${palette('primary')};\n }\n }\n `;\n};\n\nexport const injectStyle = (themeManager: ThemeManager, emotion: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n\n return emotion.css`\n width: 20.5em;\n max-height: 20.5em;\n overflow-y: auto;\n border-radius: ${themeManager.get(ThemeSize, 'radius')};\n position: absolute;\n background: ${palette('surface')};\n\n ${themeManager.get(ThemeBorder, undefined)}\n ${themeManager.get(ThemeShadow, undefined)}\n ${themeManager.get(ThemeScrollbar, undefined)}\n\n &.hide {\n display: none;\n }\n\n ${itemStyle(themeManager, emotion)}\n `;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { ThemeIcon, ThemeManager } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport type { Command, 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 utils.themeManager.onFlush(() => {\n const style = utils.getStyle(injectStyle);\n\n if (style) {\n div.classList.add(style);\n }\n });\n\n div.classList.add('slash-dropdown', 'hide');\n\n return div;\n};\n\ntype ItemOptions = {\n textClassName: string;\n};\nexport const createDropdownItem = (\n themeManager: ThemeManager,\n text: string,\n icon: Icon,\n options?: Partial<ItemOptions>,\n) => {\n const textClassName = options?.textClassName ?? 'text';\n\n const div = document.createElement('div');\n div.setAttribute('role', 'option');\n div.classList.add('slash-dropdown-item');\n\n // const iconSpan = themeManager.slots.icon(icon);\n const iconSpan = themeManager.get(ThemeIcon, icon);\n\n if (!iconSpan) {\n throw new Error('icon not found');\n }\n\n const textSpan = document.createElement('span');\n textSpan.textContent = text;\n textSpan.className = textClassName;\n\n div.appendChild(iconSpan.dom);\n div.appendChild(textSpan);\n\n return div;\n};\n\nexport const getDepth = (node: Node) => {\n let cur = node;\n let depth = 0;\n while (cur.childCount) {\n cur = cur.child(0);\n depth += 1;\n }\n\n return depth;\n};\n\nconst cleanUp: Command = (state, dispatch) => {\n const { selection } = state;\n const { $from } = selection;\n const tr = state.tr.deleteRange($from.start(), $from.pos);\n dispatch?.(tr);\n return false;\n};\n\nexport const cleanUpAndCreateNode =\n (createCommand: () => void): Command =>\n (state, dispatch, view) => {\n if (view) {\n cleanUp(state, dispatch, view);\n createCommand();\n }\n return true;\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { commandsCtx, Ctx, schemaCtx, themeManagerCtx } from '@milkdown/core';\nimport { 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(themeManagerCtx), 'Large Heading', 'h1'),\n command: () => ctx.get(commandsCtx).callByName('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).callByName('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).callByName('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).callByName('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).callByName('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).callByName('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).callByName('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).callByName('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).callByName('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).callByName('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).callByName('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 { 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 = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n const typography = themeManager.get(ThemeFont, 'typography');\n\n return css`\n position: relative;\n &::before {\n position: absolute;\n cursor: text;\n font-family: ${typography};\n font-size: 0.875em;\n color: ${palette('neutral', 0.6)};\n content: attr(data-text);\n height: 100%;\n display: flex;\n align-items: center;\n }\n `;\n};\n\nconst createSlashStyle = (_: ThemeManager, { css }: Emotion) => css`\n &::before {\n left: 0.5em;\n }\n`;\n\nexport const createProps = (status: Status, utils: Utils) => {\n return {\n handleKeyDown: (_: EditorView, event: Event) => {\n if (status.isEmpty()) {\n return false;\n }\n if (!(event instanceof KeyboardEvent)) {\n return false;\n }\n\n if (!['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {\n return false;\n }\n\n return true;\n },\n decorations: (state: EditorState) => {\n const paragraph = findParentNode(({ type }) => type.name === 'paragraph')(state.selection);\n const uploadPlugin = state.plugins.find(\n (x) => (x as unknown as { key: string }).key === 'MILKDOWN_PLUGIN_UPLOAD$',\n );\n const decorations: DecorationSet = uploadPlugin?.getState(state);\n if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {\n status.clear();\n return;\n }\n\n if (\n !paragraph ||\n paragraph.node.childCount > 1 ||\n state.selection.$from.parentOffset !== paragraph.node.textContent.length ||\n (paragraph.node.firstChild && paragraph.node.firstChild.type.name !== 'text')\n ) {\n status.clear();\n return;\n }\n\n const { placeholder, actions } = status.update({\n parentNode: state.selection.$from.node(state.selection.$from.depth - 1),\n isTopLevel: state.selection.$from.depth === 1,\n content: paragraph.node.textContent,\n state,\n });\n\n if (!placeholder) {\n return null;\n }\n\n const createDecoration = (text: string, className: (string | undefined)[]) => {\n const pos = paragraph.pos;\n return DecorationSet.create(state.doc, [\n Decoration.node(pos, pos + paragraph.node.nodeSize, {\n class: className.filter((x) => x).join(' '),\n 'data-text': text,\n }),\n ]);\n };\n\n const emptyStyle = utils.getStyle(createEmptyStyle);\n const slashStyle = utils.getStyle(createSlashStyle);\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 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';\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\nexport const createMouseManager = () => {\n let mouseLock = false;\n\n return {\n isLock: () => mouseLock,\n lock: () => {\n mouseLock = true;\n },\n unlock: () => {\n mouseLock = false;\n },\n };\n};\nexport type MouseManager = ReturnType<typeof createMouseManager>;\n\nexport const handleMouseMove = (mouseManager: MouseManager) => () => {\n mouseManager.unlock();\n};\n\nexport const handleMouseEnter = (status: Status, mouseManager: MouseManager) => (e: MouseEvent) => {\n if (mouseManager.isLock()) return;\n const { actions } = status.get();\n const active = actions.findIndex((x) => x.$.classList.contains('active'));\n const active$ = actions[active];\n if (active$ && active >= 0) {\n active$.$.classList.remove('active');\n }\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.add('active');\n};\n\nexport const handleMouseLeave = () => (e: MouseEvent) => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.remove('active');\n};\n\nexport const handleClick =\n (status: Status, view: EditorView, dropdownElement: HTMLElement) =>\n (e: Event): void => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n if (!view) return;\n\n const stop = () => {\n e.stopPropagation();\n e.preventDefault();\n };\n\n const { actions } = status.get();\n\n const el = Object.values(actions).find(({ $ }) => $.contains(target));\n if (!el) {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n stop();\n\n return;\n }\n\n stop();\n el.command(view.state, view.dispatch, view);\n };\n\nexport const handleKeydown =\n (status: Status, view: EditorView, dropdownElement: HTMLElement, mouseManager: MouseManager) => (e: Event) => {\n if (!(e instanceof KeyboardEvent)) return;\n if (!mouseManager.isLock()) mouseManager.lock();\n\n const { key } = e;\n if (status.isEmpty()) return;\n if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(key)) return;\n\n const { actions } = status.get();\n\n let active = actions.findIndex(({ $ }) => $.classList.contains('active'));\n if (active < 0) active = 0;\n\n const moveActive = (next: number) => {\n const active$ = actions[active];\n const next$ = actions[next];\n if (!active$ || !next$) return;\n active$.$.classList.remove('active');\n next$.$.classList.add('active');\n scrollIntoView(next$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n };\n\n if (key === 'ArrowDown') {\n const next = active === actions.length - 1 ? 0 : active + 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'ArrowUp') {\n const next = active === 0 ? actions.length - 1 : active - 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'Escape') {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n return;\n }\n\n const active$ = actions[active];\n if (!active$) return;\n active$.command(view.state, view.dispatch, view);\n active$.$.classList.remove('active');\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { calculateNodePosition, 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 const $editor = dropdownElement.parentElement;\n if (!$editor) {\n throw new Error();\n }\n\n let left = selected.left - parent.left;\n let top = selected.bottom - parent.top + 14 + $editor.scrollTop;\n\n if (left < 0) {\n left = 0;\n }\n\n if (parent.height + parent.top - selected.bottom < target.height) {\n top = selected.top - parent.top - target.height - 14 + $editor.scrollTop;\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":";;;;;;;;;;;;;;;;;;;AAaA,MAAM,YAAY,CAAC,cAA4B,EAAE,UAAmB;QAC1D,UAAU,CAAC,OAAc,UAAU,MAAM,aAAa,IAAI,YAAY,CAAC,OAAO;SAC7E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUgB,aAAa,IAAI,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAO9B,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,cAA4B,YAAqB;QACnE,UAAU,CAAC,OAAc,UAAU,MAAM,aAAa,IAAI,YAAY,CAAC,OAAO;SAE7E,QAAQ;AAAA;AAAA;AAAA;AAAA,yBAIM,aAAa,IAAI,WAAW;AAAA;AAAA,sBAE/B,QAAQ;AAAA;AAAA,UAEpB,aAAa,IAAI,aAAa;AAAA,UA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
+ {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/dropdown.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,aAAK,SAAS,GAAG;IACb,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,MAAM,mBAAmB,WAAW,aAAa,SAAS,KAAG,OAuCnG,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAa,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAK9C,eAAO,MAAM,GAAG,0BAA0B,CAAC;AAE3C,eAAO,MAAM,iBAAiB,UAAW,KAAK,WAAW,mBAAmB,qBAQ3E,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/input.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,kBAAkB;;;;CAY9B,CAAC;AACF,oBAAY,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEjE,eAAO,MAAM,eAAe,iBAAkB,YAAY,eAEzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,WAAY,MAAM,gBAAgB,YAAY,SAAS,UAAU,SAW7F,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,UAAU,SAInD,CAAC;AAEF,eAAO,MAAM,WAAW,WACX,MAAM,QAAQ,UAAU,mBAAmB,WAAW,SAC3D,KAAK,KAAG,IAyBX,CAAC;AAEN,eAAO,MAAM,aAAa,WACb,MAAM,QAAQ,UAAU,mBAAmB,WAAW,gBAAgB,YAAY,SAAS,KAAK,SAoDxG,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/props.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,aAAa,EAAE,WAAW,EAAE,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,oBAAY,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AA4BnD,eAAO,MAAM,WAAW,WAAY,MAAM,SAAS,KAAK;uBAE7B,UAAU,SAAS,KAAK;yBActB,WAAW;CAoDvC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,IAAI,CAAC;AACpE,OAAO,EAAE,MAAM,EAAmB,MAAM,SAAS,CAAC;AAElD,oBAAY,SAAS,GAAG;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AASF,oBAAY,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD,eAAO,MAAM,YAAY,YAAa,mBAAmB;;;4BASzB,yBAAyB;;CAQxD,CAAC"}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAYxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAuBlC,eAAO,MAAM,UAAU,WAAY,MAAM,QAAQ,UAAU,SAAS,KAAK;;;;mBAmBlD,UAAU;;CAkBhC,CAAC"}
package/lib/style.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Emotion, ThemeManager } from '@milkdown/core';
2
+ export declare const injectStyle: (themeManager: ThemeManager, emotion: Emotion) => string;
3
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,OAAO,EAIP,YAAY,EAIf,MAAM,gBAAgB,CAAC;AAuCxB,eAAO,MAAM,WAAW,iBAAkB,YAAY,WAAW,OAAO,WAqBvE,CAAC"}