@milkdown/plugin-slash 6.3.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.es.js CHANGED
@@ -1,24 +1,24 @@
1
1
  import { createPlugin as b, AtomList as E } from "@milkdown/utils";
2
2
  import { ThemeSize as $, ThemeBorder as C, ThemeShadow as N, ThemeScrollbar as S, ThemeFont as L, ThemeColor as y, ThemeIcon as T, schemaCtx as I, themeManagerCtx as m, commandsCtx as u } from "@milkdown/core";
3
3
  import { missingIcon as A, missingRootElement as D } from "@milkdown/exception";
4
- import { Plugin as _, PluginKey as M } from "@milkdown/prose/state";
5
- import { findParentNode as H, calculateNodePosition as P } from "@milkdown/prose";
6
- import { DecorationSet as O, Decoration as q } from "@milkdown/prose/view";
4
+ import { Plugin as x, PluginKey as _ } from "@milkdown/prose/state";
5
+ import { findParentNode as M, calculateNodePosition as H } from "@milkdown/prose";
6
+ import { DecorationSet as P, Decoration as O } from "@milkdown/prose/view";
7
7
  import k from "smooth-scroll-into-view-if-needed";
8
- const K = (e, { css: t }) => {
8
+ const q = (e, { css: t }) => {
9
9
  const n = (o, r = 1) => e.get(y, [o, r]);
10
10
  return t`
11
11
  .slash-dropdown-item {
12
12
  display: flex;
13
- gap: 2em;
14
- height: 3.4286em;
15
- padding: 0 1em;
13
+ gap: 32px;
14
+ height: 48px;
15
+ padding: 0 16px;
16
16
  align-items: center;
17
17
  justify-content: flex-start;
18
18
  cursor: pointer;
19
- line-height: 3.4286em;
19
+ line-height: 48px;
20
20
  font-family: ${e.get(L, "typography")};
21
- font-size: 0.875em;
21
+ font-size: 14px;
22
22
 
23
23
  transition: all 0.2s ease-in-out;
24
24
 
@@ -41,11 +41,11 @@ const K = (e, { css: t }) => {
41
41
  }
42
42
  }
43
43
  `;
44
- }, U = (e, t) => {
44
+ }, K = (e, t) => {
45
45
  const n = (o, r = 1) => e.get(y, [o, r]);
46
46
  return t.css`
47
- width: 20.5em;
48
- max-height: 20.5em;
47
+ width: 320px;
48
+ max-height: 320px;
49
49
  overflow-y: auto;
50
50
  border-radius: ${e.get($, "radius")};
51
51
  position: absolute;
@@ -59,15 +59,15 @@ const K = (e, { css: t }) => {
59
59
  display: none;
60
60
  }
61
61
 
62
- ${K(e, t)}
62
+ ${q(e, t)}
63
63
  `;
64
- }, W = (e, t) => {
64
+ }, U = (e, t) => {
65
65
  const n = document.createElement("div");
66
66
  return n.setAttribute("role", "listbox"), n.setAttribute("tabindex", "-1"), e.themeManager.onFlush(() => {
67
- const o = e.getStyle((r) => U(e.themeManager, r));
67
+ const o = e.getStyle((r) => K(e.themeManager, r));
68
68
  o && n.classList.add(o);
69
69
  }), n.classList.add(e.getClassName({}, t), "hide"), n;
70
- }, f = (e, t, n, o) => {
70
+ }, p = (e, t, n, o) => {
71
71
  var l;
72
72
  const r = (l = o == null ? void 0 : o.textClassName) != null ? l : "text", s = document.createElement("div");
73
73
  s.setAttribute("role", "option"), s.classList.add("slash-dropdown-item");
@@ -76,84 +76,84 @@ const K = (e, { css: t }) => {
76
76
  throw A(n);
77
77
  const i = document.createElement("span");
78
78
  return i.textContent = t, i.className = r, s.appendChild(a.dom), s.appendChild(i), s;
79
- }, x = (e, t) => {
79
+ }, W = (e, t) => {
80
80
  const { selection: n } = e, { $from: o } = n, r = e.tr.deleteRange(o.start(), o.pos);
81
81
  return t == null || t(r), !1;
82
- }, F = (e) => (t, n, o) => (o && (x(t, n), e()), !0), v = (e, t = "/") => {
82
+ }, F = (e) => (t, n, o) => (o && (W(t, n), e()), !0), v = (e, t = "/") => {
83
83
  const { nodes: n } = e.get(I), o = [
84
84
  {
85
85
  id: "h1",
86
- dom: f(e.get(m), "Large Heading", "h1"),
86
+ dom: p(e.get(m), "Large Heading", "h1"),
87
87
  command: () => e.get(u).call("TurnIntoHeading", 1),
88
88
  keyword: ["h1", "large heading"],
89
89
  typeName: "heading"
90
90
  },
91
91
  {
92
92
  id: "h2",
93
- dom: f(e.get(m), "Medium Heading", "h2"),
93
+ dom: p(e.get(m), "Medium Heading", "h2"),
94
94
  command: () => e.get(u).call("TurnIntoHeading", 2),
95
95
  keyword: ["h2", "medium heading"],
96
96
  typeName: "heading"
97
97
  },
98
98
  {
99
99
  id: "h3",
100
- dom: f(e.get(m), "Small Heading", "h3"),
100
+ dom: p(e.get(m), "Small Heading", "h3"),
101
101
  command: () => e.get(u).call("TurnIntoHeading", 3),
102
102
  keyword: ["h3", "small heading"],
103
103
  typeName: "heading"
104
104
  },
105
105
  {
106
106
  id: "bulletList",
107
- dom: f(e.get(m), "Bullet List", "bulletList"),
107
+ dom: p(e.get(m), "Bullet List", "bulletList"),
108
108
  command: () => e.get(u).call("WrapInBulletList"),
109
109
  keyword: ["bullet list", "ul"],
110
110
  typeName: "bullet_list"
111
111
  },
112
112
  {
113
113
  id: "orderedList",
114
- dom: f(e.get(m), "Ordered List", "orderedList"),
114
+ dom: p(e.get(m), "Ordered List", "orderedList"),
115
115
  command: () => e.get(u).call("WrapInOrderedList"),
116
116
  keyword: ["ordered list", "ol"],
117
117
  typeName: "ordered_list"
118
118
  },
119
119
  {
120
120
  id: "taskList",
121
- dom: f(e.get(m), "Task List", "taskList"),
121
+ dom: p(e.get(m), "Task List", "taskList"),
122
122
  command: () => e.get(u).call("TurnIntoTaskList"),
123
123
  keyword: ["task list", "task"],
124
124
  typeName: "task_list_item"
125
125
  },
126
126
  {
127
127
  id: "image",
128
- dom: f(e.get(m), "Image", "image"),
128
+ dom: p(e.get(m), "Image", "image"),
129
129
  command: () => e.get(u).call("InsertImage"),
130
130
  keyword: ["image"],
131
131
  typeName: "image"
132
132
  },
133
133
  {
134
134
  id: "blockquote",
135
- dom: f(e.get(m), "Quote", "quote"),
135
+ dom: p(e.get(m), "Quote", "quote"),
136
136
  command: () => e.get(u).call("WrapInBlockquote"),
137
137
  keyword: ["quote", "blockquote"],
138
138
  typeName: "blockquote"
139
139
  },
140
140
  {
141
141
  id: "table",
142
- dom: f(e.get(m), "Table", "table"),
142
+ dom: p(e.get(m), "Table", "table"),
143
143
  command: () => e.get(u).call("InsertTable"),
144
144
  keyword: ["table"],
145
145
  typeName: "table"
146
146
  },
147
147
  {
148
148
  id: "code",
149
- dom: f(e.get(m), "Code Fence", "code"),
149
+ dom: p(e.get(m), "Code Fence", "code"),
150
150
  command: () => e.get(u).call("TurnIntoCodeFence"),
151
151
  keyword: ["code"],
152
152
  typeName: "fence"
153
153
  },
154
154
  {
155
155
  id: "divider",
156
- dom: f(e.get(m), "Divide Line", "divider"),
156
+ dom: p(e.get(m), "Divide Line", "divider"),
157
157
  command: () => e.get(u).call("InsertHr"),
158
158
  keyword: ["divider", "hr"],
159
159
  typeName: "hr"
@@ -173,7 +173,7 @@ const K = (e, { css: t }) => {
173
173
  position: absolute;
174
174
  cursor: text;
175
175
  font-family: ${o};
176
- font-size: 0.875em;
176
+ font-size: 14px;
177
177
  color: ${n("neutral", 0.6)};
178
178
  content: attr(data-text);
179
179
  height: 100%;
@@ -183,12 +183,12 @@ const K = (e, { css: t }) => {
183
183
  `;
184
184
  }, B = (e, { css: t }) => t`
185
185
  &::before {
186
- left: 0.5em;
186
+ left: 8px;
187
187
  }
188
188
  `, R = (e, t) => ({
189
189
  handleKeyDown: (n, o) => !(e.isEmpty() || !(o instanceof KeyboardEvent) || !["ArrowUp", "ArrowDown", "Enter"].includes(o.key)),
190
190
  decorations: (n) => {
191
- const o = H(({ type: c }) => c.name === "paragraph")(n.selection), r = n.plugins.find((c) => c.key === "MILKDOWN_UPLOAD$"), s = r == null ? void 0 : r.getState(n);
191
+ const o = M(({ type: c }) => c.name === "paragraph")(n.selection), r = n.plugins.find((c) => c.key === "MILKDOWN_UPLOAD$"), s = r == null ? void 0 : r.getState(n);
192
192
  if (s != null && s.find(n.selection.from, n.selection.to).length > 0 || !o || o.node.childCount > 1 || n.selection.$from.parentOffset !== o.node.textContent.length || o.node.firstChild && o.node.firstChild.type.name !== "text")
193
193
  return e.clear(), null;
194
194
  const { placeholder: a, actions: i } = e.update({
@@ -201,14 +201,14 @@ const K = (e, { css: t }) => {
201
201
  return null;
202
202
  const l = (c, g) => {
203
203
  const h = o.pos;
204
- return O.create(n.doc, [
205
- q.node(h, h + o.node.nodeSize, {
204
+ return P.create(n.doc, [
205
+ O.node(h, h + o.node.nodeSize, {
206
206
  class: g.filter((w) => w).join(" "),
207
207
  "data-text": c
208
208
  })
209
209
  ]);
210
- }, p = t.getStyle((c) => z(t.themeManager, c)), d = t.getStyle((c) => B(t.themeManager, c));
211
- return i.length ? l(a, [p, d, "empty-node", "is-slash"]) : l(a, [p, "empty-node"]);
210
+ }, f = t.getStyle((c) => z(t.themeManager, c)), d = t.getStyle((c) => B(t.themeManager, c));
211
+ return i.length ? l(a, [f, d, "empty-node", "is-slash"]) : l(a, [f, "empty-node"]);
212
212
  }
213
213
  }), V = (e) => ({
214
214
  id: e.id,
@@ -321,10 +321,10 @@ const K = (e, { css: t }) => {
321
321
  e.clear(), n.classList.add("hide");
322
322
  return;
323
323
  }
324
- const p = a[i];
325
- !p || (p.command(t.state, t.dispatch, t), p.$.classList.remove("active"));
324
+ const f = a[i];
325
+ !f || (f.command(t.state, t.dispatch, t), f.$.classList.remove("active"));
326
326
  }, ne = (e, t) => {
327
- P(e, t, (n, o, r) => {
327
+ H(e, t, (n, o, r) => {
328
328
  const s = t.parentElement;
329
329
  if (!s)
330
330
  throw D();
@@ -339,10 +339,10 @@ const K = (e, { css: t }) => {
339
339
  const r = t.dom.parentNode;
340
340
  if (!r)
341
341
  return {};
342
- const s = W(n, o), a = X();
342
+ const s = U(n, o), a = X();
343
343
  r.appendChild(s);
344
- const i = Y(a), l = te(e, t, s), p = oe(e, t, s, a), d = Z(e, a), c = ee();
345
- return r.addEventListener("mousemove", i), r.addEventListener("mousedown", l), r.addEventListener("keydown", p), {
344
+ const i = Y(a), l = te(e, t, s), f = oe(e, t, s, a), d = Z(e, a), c = ee();
345
+ return r.addEventListener("mousemove", i), r.addEventListener("mousedown", l), r.addEventListener("keydown", f), {
346
346
  update: (g) => {
347
347
  !J(e, s, {
348
348
  mouseEnter: d,
@@ -350,13 +350,13 @@ const K = (e, { css: t }) => {
350
350
  }) || ne(g, s);
351
351
  },
352
352
  destroy: () => {
353
- r.removeEventListener("mousemove", i), r.removeEventListener("mousedown", l), r.removeEventListener("keydown", p), s.remove();
353
+ r.removeEventListener("mousemove", i), r.removeEventListener("mousedown", l), r.removeEventListener("keydown", f), s.remove();
354
354
  }
355
355
  };
356
356
  }, se = "MILKDOWN_SLASH", ae = (e, t, n) => {
357
357
  const o = G(t);
358
- return new _({
359
- key: new M(se),
358
+ return new x({
359
+ key: new _(se),
360
360
  props: R(o, e),
361
361
  view: (r) => re(o, r, e, n)
362
362
  });
@@ -371,7 +371,7 @@ const K = (e, { css: t }) => {
371
371
  };
372
372
  }), ge = E.create([ie()]);
373
373
  export {
374
- f as createDropdownItem,
374
+ p as createDropdownItem,
375
375
  v as defaultActions,
376
376
  j as defaultConfig,
377
377
  ge as slash,
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/style.ts","../src/utility.ts","../src/config.ts","../src/prose-plugin/props.ts","../src/item.ts","../src/prose-plugin/status.ts","../src/prose-plugin/dropdown.ts","../src/prose-plugin/input.ts","../src/prose-plugin/view.ts","../src/prose-plugin/index.ts","../src/index.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nimport {\n Color,\n Emotion,\n ThemeBorder,\n ThemeColor,\n ThemeFont,\n ThemeManager,\n ThemeScrollbar,\n ThemeShadow,\n ThemeSize,\n} from '@milkdown/core';\n\nconst itemStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n return css`\n .slash-dropdown-item {\n display: flex;\n gap: 2em;\n height: 3.4286em;\n padding: 0 1em;\n align-items: center;\n justify-content: flex-start;\n cursor: pointer;\n line-height: 3.4286em;\n font-family: ${themeManager.get(ThemeFont, 'typography')};\n font-size: 0.875em;\n\n transition: all 0.2s ease-in-out;\n\n &,\n .icon {\n color: ${palette('neutral', 0.87)};\n transition: all 0.2s ease-in-out;\n }\n\n &.hide {\n display: none;\n }\n\n &.active {\n background: ${palette('secondary', 0.12)};\n &,\n .icon {\n color: ${palette('primary')};\n }\n }\n }\n `;\n};\n\nexport const injectStyle = (themeManager: ThemeManager, emotion: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n\n return emotion.css`\n width: 20.5em;\n max-height: 20.5em;\n overflow-y: auto;\n border-radius: ${themeManager.get(ThemeSize, 'radius')};\n position: absolute;\n background: ${palette('surface')};\n\n ${themeManager.get(ThemeBorder, undefined)}\n ${themeManager.get(ThemeShadow, undefined)}\n ${themeManager.get(ThemeScrollbar, undefined)}\n\n &.hide {\n display: none;\n }\n\n ${itemStyle(themeManager, emotion)}\n `;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { ThemeIcon, ThemeManager } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport { missingIcon } from '@milkdown/exception';\nimport type { Node } from '@milkdown/prose/model';\nimport type { Command } from '@milkdown/prose/state';\nimport type { Utils } from '@milkdown/utils';\n\nimport { injectStyle } from './style';\n\nexport const createDropdown = (utils: Utils, className: string) => {\n const div = document.createElement('div');\n div.setAttribute('role', 'listbox');\n div.setAttribute('tabindex', '-1');\n utils.themeManager.onFlush(() => {\n const style = utils.getStyle((emotion) => injectStyle(utils.themeManager, emotion));\n\n if (style) {\n div.classList.add(style);\n }\n });\n\n div.classList.add(utils.getClassName({}, className), 'hide');\n\n return div;\n};\n\ntype ItemOptions = {\n textClassName: string;\n};\nexport const createDropdownItem = (\n themeManager: ThemeManager,\n text: string,\n icon: Icon,\n options?: Partial<ItemOptions>,\n) => {\n const textClassName = options?.textClassName ?? 'text';\n\n const div = document.createElement('div');\n div.setAttribute('role', 'option');\n div.classList.add('slash-dropdown-item');\n\n const iconSpan = themeManager.get(ThemeIcon, icon);\n\n if (!iconSpan) {\n throw missingIcon(icon);\n }\n\n const textSpan = document.createElement('span');\n textSpan.textContent = text;\n textSpan.className = textClassName;\n\n div.appendChild(iconSpan.dom);\n div.appendChild(textSpan);\n\n return div;\n};\n\nexport const getDepth = (node: Node) => {\n let cur = node;\n let depth = 0;\n while (cur.childCount) {\n cur = cur.child(0);\n depth += 1;\n }\n\n return depth;\n};\n\nconst cleanUp: Command = (state, dispatch) => {\n const { selection } = state;\n const { $from } = selection;\n const tr = state.tr.deleteRange($from.start(), $from.pos);\n dispatch?.(tr);\n return false;\n};\n\nexport const cleanUpAndCreateNode =\n (createCommand: () => void): Command =>\n (state, dispatch, view) => {\n if (view) {\n cleanUp(state, dispatch, view);\n createCommand();\n }\n return true;\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { commandsCtx, Ctx, schemaCtx, themeManagerCtx } from '@milkdown/core';\nimport { Node } from '@milkdown/prose/model';\nimport { EditorState } from '@milkdown/prose/state';\n\nimport { WrappedAction } from './item';\nimport { createDropdownItem } from './utility';\n\ntype Nullable<T> = T | null | undefined;\n\nexport type StatusConfig = {\n placeholder?: Nullable<string>;\n actions?: Nullable<WrappedAction[]>;\n};\n\nexport type StatusConfigBuilderParams = {\n content: string;\n isTopLevel: boolean;\n parentNode: Node;\n state: EditorState;\n};\n\nexport type StatusConfigBuilder = (params: StatusConfigBuilderParams) => Nullable<StatusConfig>;\n\nexport type Config = (ctx: Ctx) => StatusConfigBuilder;\n\nexport const defaultActions = (ctx: Ctx, input = '/'): WrappedAction[] => {\n const { nodes } = ctx.get(schemaCtx);\n const actions: Array<WrappedAction & { keyword: string[]; typeName: string }> = [\n {\n id: 'h1',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Large Heading', 'h1'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 1),\n keyword: ['h1', 'large heading'],\n typeName: 'heading',\n },\n {\n id: 'h2',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Medium Heading', 'h2'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 2),\n keyword: ['h2', 'medium heading'],\n typeName: 'heading',\n },\n {\n id: 'h3',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Small Heading', 'h3'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 3),\n keyword: ['h3', 'small heading'],\n typeName: 'heading',\n },\n {\n id: 'bulletList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Bullet List', 'bulletList'),\n command: () => ctx.get(commandsCtx).call('WrapInBulletList'),\n keyword: ['bullet list', 'ul'],\n typeName: 'bullet_list',\n },\n {\n id: 'orderedList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Ordered List', 'orderedList'),\n command: () => ctx.get(commandsCtx).call('WrapInOrderedList'),\n keyword: ['ordered list', 'ol'],\n typeName: 'ordered_list',\n },\n {\n id: 'taskList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Task List', 'taskList'),\n command: () => ctx.get(commandsCtx).call('TurnIntoTaskList'),\n keyword: ['task list', 'task'],\n typeName: 'task_list_item',\n },\n {\n id: 'image',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Image', 'image'),\n command: () => ctx.get(commandsCtx).call('InsertImage'),\n keyword: ['image'],\n typeName: 'image',\n },\n {\n id: 'blockquote',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Quote', 'quote'),\n command: () => ctx.get(commandsCtx).call('WrapInBlockquote'),\n keyword: ['quote', 'blockquote'],\n typeName: 'blockquote',\n },\n {\n id: 'table',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Table', 'table'),\n command: () => ctx.get(commandsCtx).call('InsertTable'),\n keyword: ['table'],\n typeName: 'table',\n },\n {\n id: 'code',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Code Fence', 'code'),\n command: () => ctx.get(commandsCtx).call('TurnIntoCodeFence'),\n keyword: ['code'],\n typeName: 'fence',\n },\n {\n id: 'divider',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Divide Line', 'divider'),\n command: () => ctx.get(commandsCtx).call('InsertHr'),\n keyword: ['divider', 'hr'],\n typeName: 'hr',\n },\n ];\n\n const userInput = input.slice(1).toLocaleLowerCase();\n\n return actions\n .filter((action) => !!nodes[action.typeName] && action.keyword.some((keyword) => keyword.includes(userInput)))\n .map(({ keyword, typeName, ...action }) => action);\n};\n\nexport const defaultConfig: Config = (ctx) => {\n return ({ content, isTopLevel }) => {\n if (!isTopLevel) return null;\n\n if (!content) {\n return { placeholder: 'Type / to use the slash commands...' };\n }\n\n if (content.startsWith('/')) {\n return content === '/'\n ? {\n placeholder: 'Type to filter...',\n actions: defaultActions(ctx),\n }\n : {\n actions: defaultActions(ctx, content),\n };\n }\n\n return null;\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Color, Emotion, ThemeColor, ThemeFont, ThemeManager } from '@milkdown/core';\nimport { findParentNode } from '@milkdown/prose';\nimport { EditorState } from '@milkdown/prose/state';\nimport { Decoration, DecorationSet, EditorView } from '@milkdown/prose/view';\nimport { Utils } from '@milkdown/utils';\n\nimport type { Status } from './status';\n\nexport type Props = ReturnType<typeof createProps>;\n\nconst createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n const typography = themeManager.get(ThemeFont, 'typography');\n\n return css`\n position: relative;\n &::before {\n position: absolute;\n cursor: text;\n font-family: ${typography};\n font-size: 0.875em;\n color: ${palette('neutral', 0.6)};\n content: attr(data-text);\n height: 100%;\n display: flex;\n align-items: center;\n }\n `;\n};\n\nconst createSlashStyle = (_: ThemeManager, { css }: Emotion) => css`\n &::before {\n left: 0.5em;\n }\n`;\n\nexport const createProps = (status: Status, utils: Utils) => {\n return {\n handleKeyDown: (_: EditorView, event: Event) => {\n if (status.isEmpty()) {\n return false;\n }\n if (!(event instanceof KeyboardEvent)) {\n return false;\n }\n\n if (!['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {\n return false;\n }\n\n return true;\n },\n decorations: (state: EditorState) => {\n const paragraph = findParentNode(({ type }) => type.name === 'paragraph')(state.selection);\n const uploadPlugin = state.plugins.find(\n (x) => (x as unknown as { key: string }).key === 'MILKDOWN_UPLOAD$',\n );\n const decorations: DecorationSet = uploadPlugin?.getState(state);\n if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {\n status.clear();\n return null;\n }\n\n if (\n !paragraph ||\n paragraph.node.childCount > 1 ||\n state.selection.$from.parentOffset !== paragraph.node.textContent.length ||\n (paragraph.node.firstChild && paragraph.node.firstChild.type.name !== 'text')\n ) {\n status.clear();\n return null;\n }\n\n const { placeholder, actions } = status.update({\n parentNode: state.selection.$from.node(state.selection.$from.depth - 1),\n isTopLevel: state.selection.$from.depth === 1,\n content: paragraph.node.textContent,\n state,\n });\n\n if (!placeholder) {\n return null;\n }\n\n const createDecoration = (text: string, className: (string | undefined)[]) => {\n const pos = paragraph.pos;\n return DecorationSet.create(state.doc, [\n Decoration.node(pos, pos + paragraph.node.nodeSize, {\n class: className.filter((x) => x).join(' '),\n 'data-text': text,\n }),\n ]);\n };\n\n const emptyStyle = utils.getStyle((emotion) => createEmptyStyle(utils.themeManager, emotion));\n const slashStyle = utils.getStyle((emotion) => createSlashStyle(utils.themeManager, emotion));\n\n if (actions.length) {\n return createDecoration(placeholder, [emptyStyle, slashStyle, 'empty-node', 'is-slash']);\n }\n\n return createDecoration(placeholder, [emptyStyle, 'empty-node']);\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport type { Command } from '@milkdown/prose/state';\n\nimport { cleanUpAndCreateNode } from './utility';\n\nexport type Action = {\n id: string;\n $: HTMLElement;\n command: Command;\n};\n\nexport type WrappedAction = Pick<Action, 'id'> & {\n command: () => void;\n dom: HTMLElement;\n};\n\nexport const transformAction = (action: WrappedAction): Action => ({\n id: action.id,\n $: action.dom,\n command: cleanUpAndCreateNode(action.command),\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { StatusConfigBuilder, StatusConfigBuilderParams } from '..';\nimport { Action, transformAction } from '../item';\n\nexport type StatusCtx = {\n placeholder: string | null;\n actions: Action[];\n};\n\nconst createStatusCtx = (): StatusCtx => {\n return {\n placeholder: null,\n actions: [],\n };\n};\n\nexport type Status = ReturnType<typeof createStatus>;\n\nexport const createStatus = (builder: StatusConfigBuilder) => {\n const statusCtx = createStatusCtx();\n\n return {\n get: () => statusCtx,\n clear: () => {\n statusCtx.placeholder = null;\n statusCtx.actions = [];\n },\n update: (builderParams: StatusConfigBuilderParams) => {\n const config = builder(builderParams);\n statusCtx.placeholder = config?.placeholder ?? null;\n statusCtx.actions = (config?.actions ?? []).map(transformAction);\n return statusCtx;\n },\n isEmpty: () => statusCtx.actions.length === 0,\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\ntype Listeners = {\n mouseEnter: EventListener;\n mouseLeave: EventListener;\n};\n\nexport const renderDropdown = (status: Status, dropdownElement: HTMLElement, listeners: Listeners): boolean => {\n const { actions } = status.get();\n\n if (!actions.length) {\n dropdownElement.classList.add('hide');\n return false;\n }\n\n dropdownElement.childNodes.forEach((child) => {\n child.removeEventListener('mouseenter', listeners.mouseEnter);\n child.removeEventListener('mouseleave', listeners.mouseLeave);\n });\n\n while (dropdownElement.firstChild) {\n dropdownElement.firstChild.remove();\n }\n\n actions.forEach(({ $ }) => {\n $.classList.remove('active');\n $.addEventListener('mouseenter', listeners.mouseEnter);\n $.addEventListener('mouseleave', listeners.mouseLeave);\n dropdownElement.appendChild($);\n });\n\n dropdownElement.classList.remove('hide');\n\n const first$ = actions[0];\n if (first$) {\n first$.$.classList.add('active');\n requestAnimationFrame(() => {\n scrollIntoView(first$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n });\n }\n\n return true;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\n\nimport { EditorView } from '@milkdown/prose/view';\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\nexport const createMouseManager = () => {\n let mouseLock = false;\n\n return {\n isLock: () => mouseLock,\n lock: () => {\n mouseLock = true;\n },\n unlock: () => {\n mouseLock = false;\n },\n };\n};\nexport type MouseManager = ReturnType<typeof createMouseManager>;\n\nexport const handleMouseMove = (mouseManager: MouseManager) => () => {\n mouseManager.unlock();\n};\n\nexport const handleMouseEnter = (status: Status, mouseManager: MouseManager) => (e: MouseEvent) => {\n if (mouseManager.isLock()) return;\n const { actions } = status.get();\n const active = actions.findIndex((x) => x.$.classList.contains('active'));\n const active$ = actions[active];\n if (active$ && active >= 0) {\n active$.$.classList.remove('active');\n }\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.add('active');\n};\n\nexport const handleMouseLeave = () => (e: MouseEvent) => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.remove('active');\n};\n\nexport const handleClick =\n (status: Status, view: EditorView, dropdownElement: HTMLElement) =>\n (e: Event): void => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n if (!view) return;\n\n const stop = () => {\n e.stopPropagation();\n e.preventDefault();\n };\n\n const { actions } = status.get();\n\n const el = Object.values(actions).find(({ $ }) => $.contains(target));\n if (!el) {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n stop();\n\n return;\n }\n\n stop();\n el.command(view.state, view.dispatch, view);\n };\n\nexport const handleKeydown =\n (status: Status, view: EditorView, dropdownElement: HTMLElement, mouseManager: MouseManager) => (e: Event) => {\n if (!(e instanceof KeyboardEvent)) return;\n if (!mouseManager.isLock()) mouseManager.lock();\n\n const { key } = e;\n if (status.isEmpty()) return;\n if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(key)) return;\n\n const { actions } = status.get();\n\n let active = actions.findIndex(({ $ }) => $.classList.contains('active'));\n if (active < 0) active = 0;\n\n const moveActive = (next: number) => {\n const active$ = actions[active];\n const next$ = actions[next];\n if (!active$ || !next$) return;\n active$.$.classList.remove('active');\n next$.$.classList.add('active');\n scrollIntoView(next$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n };\n\n if (key === 'ArrowDown') {\n const next = active === actions.length - 1 ? 0 : active + 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'ArrowUp') {\n const next = active === 0 ? actions.length - 1 : active - 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'Escape') {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n return;\n }\n\n const active$ = actions[active];\n if (!active$) return;\n active$.command(view.state, view.dispatch, view);\n active$.$.classList.remove('active');\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { missingRootElement } from '@milkdown/exception';\nimport { calculateNodePosition } from '@milkdown/prose';\nimport { EditorView } from '@milkdown/prose/view';\nimport { Utils } from '@milkdown/utils';\n\nimport { createDropdown } from '../utility';\nimport { renderDropdown } from './dropdown';\nimport {\n createMouseManager,\n handleClick,\n handleKeydown,\n handleMouseEnter,\n handleMouseLeave,\n handleMouseMove,\n} from './input';\nimport { Status } from './status';\n\nconst calculatePosition = (view: EditorView, dropdownElement: HTMLElement) => {\n calculateNodePosition(view, dropdownElement, (selected, target, parent) => {\n const $editor = dropdownElement.parentElement;\n if (!$editor) {\n throw missingRootElement();\n }\n\n let left = selected.left - parent.left;\n let top = selected.bottom - parent.top + 14 + $editor.scrollTop;\n\n if (left < 0) {\n left = 0;\n }\n\n if (parent.height + parent.top - selected.bottom < target.height) {\n const topOffset = selected.top - parent.top - target.height - 14 + $editor.scrollTop;\n if (topOffset > 0) {\n top = topOffset;\n }\n }\n return [top, left];\n });\n};\n\nexport const createView = (status: Status, view: EditorView, utils: Utils, className: string) => {\n const wrapper = view.dom.parentNode;\n if (!wrapper) return {};\n\n const dropdownElement = createDropdown(utils, className);\n const mouseManager = createMouseManager();\n wrapper.appendChild(dropdownElement);\n\n const _mouseMove = handleMouseMove(mouseManager);\n const _mouseDown = handleClick(status, view, dropdownElement);\n const _keydown = handleKeydown(status, view, dropdownElement, mouseManager);\n const _mouseEnter = handleMouseEnter(status, mouseManager);\n const _mouseLeave = handleMouseLeave();\n\n wrapper.addEventListener('mousemove', _mouseMove);\n wrapper.addEventListener('mousedown', _mouseDown);\n wrapper.addEventListener('keydown', _keydown);\n\n return {\n update: (view: EditorView) => {\n const show = renderDropdown(status, dropdownElement, {\n mouseEnter: _mouseEnter as EventListener,\n mouseLeave: _mouseLeave as EventListener,\n });\n\n if (!show) return;\n\n calculatePosition(view, dropdownElement);\n },\n\n destroy: () => {\n wrapper.removeEventListener('mousemove', _mouseMove);\n wrapper.removeEventListener('mousedown', _mouseDown);\n wrapper.removeEventListener('keydown', _keydown);\n dropdownElement.remove();\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Plugin, PluginKey } from '@milkdown/prose/state';\nimport { Utils } from '@milkdown/utils';\n\nimport type { StatusConfigBuilder } from '..';\nimport { createProps } from './props';\nimport { createStatus } from './status';\nimport { createView } from './view';\n\nexport const key = 'MILKDOWN_SLASH';\n\nexport const createSlashPlugin = (utils: Utils, builder: StatusConfigBuilder, className: string) => {\n const status = createStatus(builder);\n\n return new Plugin({\n key: new PluginKey(key),\n props: createProps(status, utils),\n view: (view) => createView(status, view, utils, className),\n });\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { AtomList, createPlugin } from '@milkdown/utils';\n\nimport type { Config } from './config';\nimport { defaultConfig } from './config';\nimport { createSlashPlugin } from './prose-plugin';\n\nexport type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';\nexport { defaultActions, defaultConfig } from './config';\nexport type { Action, WrappedAction } from './item';\nexport { createDropdownItem } from './utility';\n\nexport type Options = {\n config: Config;\n};\n\nexport const slashPlugin = createPlugin<string, Options>((utils, options) => {\n const slashConfig = options?.config ?? defaultConfig;\n\n return {\n prosePlugins: (_, ctx) => {\n const config = slashConfig(ctx);\n\n const plugin = createSlashPlugin(utils, config, 'slash-dropdown');\n\n return [plugin];\n },\n };\n});\n\nexport const slash = AtomList.create([slashPlugin()]);\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,IAAY,CAAC,GAA4B,EAAE,aAAmB;AAC1D,QAAA,IAAU,CAAC,GAAc,IAAU,MAAM,EAAa,IAAI,GAAY,CAAC,GAAO,CAAO,CAAC;AACrF,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUgB,EAAa,IAAI,GAAW,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAO1C,EAAQ,WAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BASlB,EAAQ,aAAa,IAAI;AAAA;AAAA;AAAA,6BAG1B,EAAQ,SAAS;AAAA;AAAA;AAAA;AAAA;AAK9C,GAEa,IAAc,CAAC,GAA4B,MAAqB;AACnE,QAAA,IAAU,CAAC,GAAc,IAAU,MAAM,EAAa,IAAI,GAAY,CAAC,GAAO,CAAO,CAAC;AAE5F,SAAO,EAAQ;AAAA;AAAA;AAAA;AAAA,yBAIM,EAAa,IAAI,GAAW,QAAQ;AAAA;AAAA,sBAEvC,EAAQ,SAAS;AAAA;AAAA,UAE7B,EAAa,IAAI,GAAa,MAAS;AAAA,UACvC,EAAa,IAAI,GAAa,MAAS;AAAA,UACvC,EAAa,IAAI,GAAgB,MAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAM1C,EAAU,GAAc,CAAO;AAAA;AAEzC,GC9Da,IAAiB,CAAC,GAAc,MAAsB;AACzD,QAAA,IAAM,SAAS,cAAc,KAAK;AACpC,WAAA,aAAa,QAAQ,SAAS,GAC9B,EAAA,aAAa,YAAY,IAAI,GAC3B,EAAA,aAAa,QAAQ,MAAM;AACvB,UAAA,IAAQ,EAAM,SAAS,CAAC,MAAY,EAAY,EAAM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 {"version":3,"file":"index.es.js","sources":["../src/style.ts","../src/utility.ts","../src/config.ts","../src/prose-plugin/props.ts","../src/item.ts","../src/prose-plugin/status.ts","../src/prose-plugin/dropdown.ts","../src/prose-plugin/input.ts","../src/prose-plugin/view.ts","../src/prose-plugin/index.ts","../src/index.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nimport {\n Color,\n Emotion,\n ThemeBorder,\n ThemeColor,\n ThemeFont,\n ThemeManager,\n ThemeScrollbar,\n ThemeShadow,\n ThemeSize,\n} from '@milkdown/core';\n\nconst itemStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n return css`\n .slash-dropdown-item {\n display: flex;\n gap: 32px;\n height: 48px;\n padding: 0 16px;\n align-items: center;\n justify-content: flex-start;\n cursor: pointer;\n line-height: 48px;\n font-family: ${themeManager.get(ThemeFont, 'typography')};\n font-size: 14px;\n\n transition: all 0.2s ease-in-out;\n\n &,\n .icon {\n color: ${palette('neutral', 0.87)};\n transition: all 0.2s ease-in-out;\n }\n\n &.hide {\n display: none;\n }\n\n &.active {\n background: ${palette('secondary', 0.12)};\n &,\n .icon {\n color: ${palette('primary')};\n }\n }\n }\n `;\n};\n\nexport const injectStyle = (themeManager: ThemeManager, emotion: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n\n return emotion.css`\n width: 320px;\n max-height: 320px;\n overflow-y: auto;\n border-radius: ${themeManager.get(ThemeSize, 'radius')};\n position: absolute;\n background: ${palette('surface')};\n\n ${themeManager.get(ThemeBorder, undefined)}\n ${themeManager.get(ThemeShadow, undefined)}\n ${themeManager.get(ThemeScrollbar, undefined)}\n\n &.hide {\n display: none;\n }\n\n ${itemStyle(themeManager, emotion)}\n `;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { ThemeIcon, ThemeManager } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport { missingIcon } from '@milkdown/exception';\nimport type { Node } from '@milkdown/prose/model';\nimport type { Command } from '@milkdown/prose/state';\nimport type { ThemeUtils } from '@milkdown/utils';\n\nimport { injectStyle } from './style';\n\nexport const createDropdown = (utils: ThemeUtils, className: string) => {\n const div = document.createElement('div');\n div.setAttribute('role', 'listbox');\n div.setAttribute('tabindex', '-1');\n utils.themeManager.onFlush(() => {\n const style = utils.getStyle((emotion) => injectStyle(utils.themeManager, emotion));\n\n if (style) {\n div.classList.add(style);\n }\n });\n\n div.classList.add(utils.getClassName({}, className), 'hide');\n\n return div;\n};\n\ntype ItemOptions = {\n textClassName: string;\n};\nexport const createDropdownItem = (\n themeManager: ThemeManager,\n text: string,\n icon: Icon,\n options?: Partial<ItemOptions>,\n) => {\n const textClassName = options?.textClassName ?? 'text';\n\n const div = document.createElement('div');\n div.setAttribute('role', 'option');\n div.classList.add('slash-dropdown-item');\n\n const iconSpan = themeManager.get(ThemeIcon, icon);\n\n if (!iconSpan) {\n throw missingIcon(icon);\n }\n\n const textSpan = document.createElement('span');\n textSpan.textContent = text;\n textSpan.className = textClassName;\n\n div.appendChild(iconSpan.dom);\n div.appendChild(textSpan);\n\n return div;\n};\n\nexport const getDepth = (node: Node) => {\n let cur = node;\n let depth = 0;\n while (cur.childCount) {\n cur = cur.child(0);\n depth += 1;\n }\n\n return depth;\n};\n\nconst cleanUp: Command = (state, dispatch) => {\n const { selection } = state;\n const { $from } = selection;\n const tr = state.tr.deleteRange($from.start(), $from.pos);\n dispatch?.(tr);\n return false;\n};\n\nexport const cleanUpAndCreateNode =\n (createCommand: () => void): Command =>\n (state, dispatch, view) => {\n if (view) {\n cleanUp(state, dispatch, view);\n createCommand();\n }\n return true;\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { commandsCtx, Ctx, schemaCtx, themeManagerCtx } from '@milkdown/core';\nimport { Node } from '@milkdown/prose/model';\nimport { EditorState } from '@milkdown/prose/state';\n\nimport { WrappedAction } from './item';\nimport { createDropdownItem } from './utility';\n\ntype Nullable<T> = T | null | undefined;\n\nexport type StatusConfig = {\n placeholder?: Nullable<string>;\n actions?: Nullable<WrappedAction[]>;\n};\n\nexport type StatusConfigBuilderParams = {\n content: string;\n isTopLevel: boolean;\n parentNode: Node;\n state: EditorState;\n};\n\nexport type StatusConfigBuilder = (params: StatusConfigBuilderParams) => Nullable<StatusConfig>;\n\nexport type Config = (ctx: Ctx) => StatusConfigBuilder;\n\nexport const defaultActions = (ctx: Ctx, input = '/'): WrappedAction[] => {\n const { nodes } = ctx.get(schemaCtx);\n const actions: Array<WrappedAction & { keyword: string[]; typeName: string }> = [\n {\n id: 'h1',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Large Heading', 'h1'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 1),\n keyword: ['h1', 'large heading'],\n typeName: 'heading',\n },\n {\n id: 'h2',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Medium Heading', 'h2'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 2),\n keyword: ['h2', 'medium heading'],\n typeName: 'heading',\n },\n {\n id: 'h3',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Small Heading', 'h3'),\n command: () => ctx.get(commandsCtx).call('TurnIntoHeading', 3),\n keyword: ['h3', 'small heading'],\n typeName: 'heading',\n },\n {\n id: 'bulletList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Bullet List', 'bulletList'),\n command: () => ctx.get(commandsCtx).call('WrapInBulletList'),\n keyword: ['bullet list', 'ul'],\n typeName: 'bullet_list',\n },\n {\n id: 'orderedList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Ordered List', 'orderedList'),\n command: () => ctx.get(commandsCtx).call('WrapInOrderedList'),\n keyword: ['ordered list', 'ol'],\n typeName: 'ordered_list',\n },\n {\n id: 'taskList',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Task List', 'taskList'),\n command: () => ctx.get(commandsCtx).call('TurnIntoTaskList'),\n keyword: ['task list', 'task'],\n typeName: 'task_list_item',\n },\n {\n id: 'image',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Image', 'image'),\n command: () => ctx.get(commandsCtx).call('InsertImage'),\n keyword: ['image'],\n typeName: 'image',\n },\n {\n id: 'blockquote',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Quote', 'quote'),\n command: () => ctx.get(commandsCtx).call('WrapInBlockquote'),\n keyword: ['quote', 'blockquote'],\n typeName: 'blockquote',\n },\n {\n id: 'table',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Table', 'table'),\n command: () => ctx.get(commandsCtx).call('InsertTable'),\n keyword: ['table'],\n typeName: 'table',\n },\n {\n id: 'code',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Code Fence', 'code'),\n command: () => ctx.get(commandsCtx).call('TurnIntoCodeFence'),\n keyword: ['code'],\n typeName: 'fence',\n },\n {\n id: 'divider',\n dom: createDropdownItem(ctx.get(themeManagerCtx), 'Divide Line', 'divider'),\n command: () => ctx.get(commandsCtx).call('InsertHr'),\n keyword: ['divider', 'hr'],\n typeName: 'hr',\n },\n ];\n\n const userInput = input.slice(1).toLocaleLowerCase();\n\n return actions\n .filter((action) => !!nodes[action.typeName] && action.keyword.some((keyword) => keyword.includes(userInput)))\n .map(({ keyword, typeName, ...action }) => action);\n};\n\nexport const defaultConfig: Config = (ctx) => {\n return ({ content, isTopLevel }) => {\n if (!isTopLevel) return null;\n\n if (!content) {\n return { placeholder: 'Type / to use the slash commands...' };\n }\n\n if (content.startsWith('/')) {\n return content === '/'\n ? {\n placeholder: 'Type to filter...',\n actions: defaultActions(ctx),\n }\n : {\n actions: defaultActions(ctx, content),\n };\n }\n\n return null;\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Color, Emotion, ThemeColor, ThemeFont, ThemeManager } from '@milkdown/core';\nimport { findParentNode } from '@milkdown/prose';\nimport { EditorState } from '@milkdown/prose/state';\nimport { Decoration, DecorationSet, EditorView } from '@milkdown/prose/view';\nimport { ThemeUtils } from '@milkdown/utils';\n\nimport type { Status } from './status';\n\nexport type Props = ReturnType<typeof createProps>;\n\nconst createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {\n const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);\n const typography = themeManager.get(ThemeFont, 'typography');\n\n return css`\n position: relative;\n &::before {\n position: absolute;\n cursor: text;\n font-family: ${typography};\n font-size: 14px;\n color: ${palette('neutral', 0.6)};\n content: attr(data-text);\n height: 100%;\n display: flex;\n align-items: center;\n }\n `;\n};\n\nconst createSlashStyle = (_: ThemeManager, { css }: Emotion) => css`\n &::before {\n left: 8px;\n }\n`;\n\nexport const createProps = (status: Status, utils: ThemeUtils) => {\n return {\n handleKeyDown: (_: EditorView, event: Event) => {\n if (status.isEmpty()) {\n return false;\n }\n if (!(event instanceof KeyboardEvent)) {\n return false;\n }\n\n if (!['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {\n return false;\n }\n\n return true;\n },\n decorations: (state: EditorState) => {\n const paragraph = findParentNode(({ type }) => type.name === 'paragraph')(state.selection);\n const uploadPlugin = state.plugins.find(\n (x) => (x as unknown as { key: string }).key === 'MILKDOWN_UPLOAD$',\n );\n const decorations: DecorationSet = uploadPlugin?.getState(state);\n if (decorations != null && decorations.find(state.selection.from, state.selection.to).length > 0) {\n status.clear();\n return null;\n }\n\n if (\n !paragraph ||\n paragraph.node.childCount > 1 ||\n state.selection.$from.parentOffset !== paragraph.node.textContent.length ||\n (paragraph.node.firstChild && paragraph.node.firstChild.type.name !== 'text')\n ) {\n status.clear();\n return null;\n }\n\n const { placeholder, actions } = status.update({\n parentNode: state.selection.$from.node(state.selection.$from.depth - 1),\n isTopLevel: state.selection.$from.depth === 1,\n content: paragraph.node.textContent,\n state,\n });\n\n if (!placeholder) {\n return null;\n }\n\n const createDecoration = (text: string, className: (string | undefined)[]) => {\n const pos = paragraph.pos;\n return DecorationSet.create(state.doc, [\n Decoration.node(pos, pos + paragraph.node.nodeSize, {\n class: className.filter((x) => x).join(' '),\n 'data-text': text,\n }),\n ]);\n };\n\n const emptyStyle = utils.getStyle((emotion) => createEmptyStyle(utils.themeManager, emotion));\n const slashStyle = utils.getStyle((emotion) => createSlashStyle(utils.themeManager, emotion));\n\n if (actions.length) {\n return createDecoration(placeholder, [emptyStyle, slashStyle, 'empty-node', 'is-slash']);\n }\n\n return createDecoration(placeholder, [emptyStyle, 'empty-node']);\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport type { Command } from '@milkdown/prose/state';\n\nimport { cleanUpAndCreateNode } from './utility';\n\nexport type Action = {\n id: string;\n $: HTMLElement;\n command: Command;\n};\n\nexport type WrappedAction = Pick<Action, 'id'> & {\n command: () => void;\n dom: HTMLElement;\n};\n\nexport const transformAction = (action: WrappedAction): Action => ({\n id: action.id,\n $: action.dom,\n command: cleanUpAndCreateNode(action.command),\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { StatusConfigBuilder, StatusConfigBuilderParams } from '..';\nimport { Action, transformAction } from '../item';\n\nexport type StatusCtx = {\n placeholder: string | null;\n actions: Action[];\n};\n\nconst createStatusCtx = (): StatusCtx => {\n return {\n placeholder: null,\n actions: [],\n };\n};\n\nexport type Status = ReturnType<typeof createStatus>;\n\nexport const createStatus = (builder: StatusConfigBuilder) => {\n const statusCtx = createStatusCtx();\n\n return {\n get: () => statusCtx,\n clear: () => {\n statusCtx.placeholder = null;\n statusCtx.actions = [];\n },\n update: (builderParams: StatusConfigBuilderParams) => {\n const config = builder(builderParams);\n statusCtx.placeholder = config?.placeholder ?? null;\n statusCtx.actions = (config?.actions ?? []).map(transformAction);\n return statusCtx;\n },\n isEmpty: () => statusCtx.actions.length === 0,\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\ntype Listeners = {\n mouseEnter: EventListener;\n mouseLeave: EventListener;\n};\n\nexport const renderDropdown = (status: Status, dropdownElement: HTMLElement, listeners: Listeners): boolean => {\n const { actions } = status.get();\n\n if (!actions.length) {\n dropdownElement.classList.add('hide');\n return false;\n }\n\n dropdownElement.childNodes.forEach((child) => {\n child.removeEventListener('mouseenter', listeners.mouseEnter);\n child.removeEventListener('mouseleave', listeners.mouseLeave);\n });\n\n while (dropdownElement.firstChild) {\n dropdownElement.firstChild.remove();\n }\n\n actions.forEach(({ $ }) => {\n $.classList.remove('active');\n $.addEventListener('mouseenter', listeners.mouseEnter);\n $.addEventListener('mouseleave', listeners.mouseLeave);\n dropdownElement.appendChild($);\n });\n\n dropdownElement.classList.remove('hide');\n\n const first$ = actions[0];\n if (first$) {\n first$.$.classList.add('active');\n requestAnimationFrame(() => {\n scrollIntoView(first$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n });\n }\n\n return true;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\n\nimport { EditorView } from '@milkdown/prose/view';\nimport scrollIntoView from 'smooth-scroll-into-view-if-needed';\n\nimport { Status } from './status';\n\nexport const createMouseManager = () => {\n let mouseLock = false;\n\n return {\n isLock: () => mouseLock,\n lock: () => {\n mouseLock = true;\n },\n unlock: () => {\n mouseLock = false;\n },\n };\n};\nexport type MouseManager = ReturnType<typeof createMouseManager>;\n\nexport const handleMouseMove = (mouseManager: MouseManager) => () => {\n mouseManager.unlock();\n};\n\nexport const handleMouseEnter = (status: Status, mouseManager: MouseManager) => (e: MouseEvent) => {\n if (mouseManager.isLock()) return;\n const { actions } = status.get();\n const active = actions.findIndex((x) => x.$.classList.contains('active'));\n const active$ = actions[active];\n if (active$ && active >= 0) {\n active$.$.classList.remove('active');\n }\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.add('active');\n};\n\nexport const handleMouseLeave = () => (e: MouseEvent) => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n target.classList.remove('active');\n};\n\nexport const handleClick =\n (status: Status, view: EditorView, dropdownElement: HTMLElement) =>\n (e: Event): void => {\n const { target } = e;\n if (!(target instanceof HTMLElement)) return;\n if (!view) return;\n\n const stop = () => {\n e.stopPropagation();\n e.preventDefault();\n };\n\n const { actions } = status.get();\n\n const el = Object.values(actions).find(({ $ }) => $.contains(target));\n if (!el) {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n stop();\n\n return;\n }\n\n stop();\n el.command(view.state, view.dispatch, view);\n };\n\nexport const handleKeydown =\n (status: Status, view: EditorView, dropdownElement: HTMLElement, mouseManager: MouseManager) => (e: Event) => {\n if (!(e instanceof KeyboardEvent)) return;\n if (!mouseManager.isLock()) mouseManager.lock();\n\n const { key } = e;\n if (status.isEmpty()) return;\n if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(key)) return;\n\n const { actions } = status.get();\n\n let active = actions.findIndex(({ $ }) => $.classList.contains('active'));\n if (active < 0) active = 0;\n\n const moveActive = (next: number) => {\n const active$ = actions[active];\n const next$ = actions[next];\n if (!active$ || !next$) return;\n active$.$.classList.remove('active');\n next$.$.classList.add('active');\n scrollIntoView(next$.$, {\n scrollMode: 'if-needed',\n block: 'nearest',\n inline: 'nearest',\n });\n };\n\n if (key === 'ArrowDown') {\n const next = active === actions.length - 1 ? 0 : active + 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'ArrowUp') {\n const next = active === 0 ? actions.length - 1 : active - 1;\n\n moveActive(next);\n return;\n }\n\n if (key === 'Escape') {\n if (status.isEmpty()) return;\n\n status.clear();\n dropdownElement.classList.add('hide');\n return;\n }\n\n const active$ = actions[active];\n if (!active$) return;\n active$.command(view.state, view.dispatch, view);\n active$.$.classList.remove('active');\n };\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { missingRootElement } from '@milkdown/exception';\nimport { calculateNodePosition } from '@milkdown/prose';\nimport { EditorView } from '@milkdown/prose/view';\nimport { ThemeUtils } from '@milkdown/utils';\n\nimport { createDropdown } from '../utility';\nimport { renderDropdown } from './dropdown';\nimport {\n createMouseManager,\n handleClick,\n handleKeydown,\n handleMouseEnter,\n handleMouseLeave,\n handleMouseMove,\n} from './input';\nimport { Status } from './status';\n\nconst calculatePosition = (view: EditorView, dropdownElement: HTMLElement) => {\n calculateNodePosition(view, dropdownElement, (selected, target, parent) => {\n const $editor = dropdownElement.parentElement;\n if (!$editor) {\n throw missingRootElement();\n }\n\n let left = selected.left - parent.left;\n let top = selected.bottom - parent.top + 14 + $editor.scrollTop;\n\n if (left < 0) {\n left = 0;\n }\n\n if (parent.height + parent.top - selected.bottom < target.height) {\n const topOffset = selected.top - parent.top - target.height - 14 + $editor.scrollTop;\n if (topOffset > 0) {\n top = topOffset;\n }\n }\n return [top, left];\n });\n};\n\nexport const createView = (status: Status, view: EditorView, utils: ThemeUtils, className: string) => {\n const wrapper = view.dom.parentNode;\n if (!wrapper) return {};\n\n const dropdownElement = createDropdown(utils, className);\n const mouseManager = createMouseManager();\n wrapper.appendChild(dropdownElement);\n\n const _mouseMove = handleMouseMove(mouseManager);\n const _mouseDown = handleClick(status, view, dropdownElement);\n const _keydown = handleKeydown(status, view, dropdownElement, mouseManager);\n const _mouseEnter = handleMouseEnter(status, mouseManager);\n const _mouseLeave = handleMouseLeave();\n\n wrapper.addEventListener('mousemove', _mouseMove);\n wrapper.addEventListener('mousedown', _mouseDown);\n wrapper.addEventListener('keydown', _keydown);\n\n return {\n update: (view: EditorView) => {\n const show = renderDropdown(status, dropdownElement, {\n mouseEnter: _mouseEnter as EventListener,\n mouseLeave: _mouseLeave as EventListener,\n });\n\n if (!show) return;\n\n calculatePosition(view, dropdownElement);\n },\n\n destroy: () => {\n wrapper.removeEventListener('mousemove', _mouseMove);\n wrapper.removeEventListener('mousedown', _mouseDown);\n wrapper.removeEventListener('keydown', _keydown);\n dropdownElement.remove();\n },\n };\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Plugin, PluginKey } from '@milkdown/prose/state';\nimport { ThemeUtils } from '@milkdown/utils';\n\nimport type { StatusConfigBuilder } from '..';\nimport { createProps } from './props';\nimport { createStatus } from './status';\nimport { createView } from './view';\n\nexport const key = 'MILKDOWN_SLASH';\n\nexport const createSlashPlugin = (utils: ThemeUtils, builder: StatusConfigBuilder, className: string) => {\n const status = createStatus(builder);\n\n return new Plugin({\n key: new PluginKey(key),\n props: createProps(status, utils),\n view: (view) => createView(status, view, utils, className),\n });\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { AtomList, createPlugin } from '@milkdown/utils';\n\nimport type { Config } from './config';\nimport { defaultConfig } from './config';\nimport { createSlashPlugin } from './prose-plugin';\n\nexport type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';\nexport { defaultActions, defaultConfig } from './config';\nexport type { Action, WrappedAction } from './item';\nexport { createDropdownItem } from './utility';\n\nexport type Options = {\n config: Config;\n};\n\nexport const slashPlugin = createPlugin<string, Options>((utils, options) => {\n const slashConfig = options?.config ?? defaultConfig;\n\n return {\n prosePlugins: (_, ctx) => {\n const config = slashConfig(ctx);\n\n const plugin = createSlashPlugin(utils, config, 'slash-dropdown');\n\n return [plugin];\n },\n };\n});\n\nexport const slash = AtomList.create([slashPlugin()]);\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,IAAY,CAAC,GAA4B,EAAE,aAAmB;AAC1D,QAAA,IAAU,CAAC,GAAc,IAAU,MAAM,EAAa,IAAI,GAAY,CAAC,GAAO,CAAO,CAAC;AACrF,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUgB,EAAa,IAAI,GAAW,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAO1C,EAAQ,WAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BASlB,EAAQ,aAAa,IAAI;AAAA;AAAA;AAAA,6BAG1B,EAAQ,SAAS;AAAA;AAAA;AAAA;AAAA;AAK9C,GAEa,IAAc,CAAC,GAA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AC/C,EAAgB,OAAO;AAAA,IAC3B;AAAA,EAAA;AAER,GCtEa,KAAM,kBAEN,KAAoB,CAAC,GAAmB,GAA8B,MAAsB;AAC/F,QAAA,IAAS,EAAa,CAAO;AAEnC,SAAO,IAAI,EAAO;AAAA,IACd,KAAK,IAAI,EAAU,EAAG;AAAA,IACtB,OAAO,EAAY,GAAQ,CAAK;AAAA,IAChC,MAAM,CAAC,MAAS,GAAW,GAAQ,GAAM,GAAO,CAAS;AAAA,EAAA,CAC5D;AACL,GCHa,KAAc,EAA8B,CAAC,GAAO,MAAY;;AACnE,QAAA,IAAc,4BAAS,WAAT,WAAmB;AAEhC,SAAA;AAAA,IACH,cAAc,CAAC,GAAG,MAAQ;AAChB,YAAA,IAAS,EAAY,CAAG;AAI9B,aAAO,CAFQ,GAAkB,GAAO,GAAQ,gBAAgB,CAElD;AAAA,IAClB;AAAA,EAAA;AAER,CAAC,GAEY,KAAQ,EAAS,OAAO,CAAC,GAAA,CAAa,CAAC;"}
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from '@milkdown/prose/state';
2
- import { Utils } from '@milkdown/utils';
2
+ import { ThemeUtils } from '@milkdown/utils';
3
3
  import type { StatusConfigBuilder } from '..';
4
4
  export declare const key = "MILKDOWN_SLASH";
5
- export declare const createSlashPlugin: (utils: Utils, builder: StatusConfigBuilder, className: string) => Plugin<any>;
5
+ export declare const createSlashPlugin: (utils: ThemeUtils, builder: StatusConfigBuilder, className: string) => Plugin<any>;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAa,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAK9C,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC,eAAO,MAAM,iBAAiB,UAAW,KAAK,WAAW,mBAAmB,aAAa,MAAM,gBAQ9F,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAa,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAK9C,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC,eAAO,MAAM,iBAAiB,UAAW,UAAU,WAAW,mBAAmB,aAAa,MAAM,gBAQnG,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { EditorState } from '@milkdown/prose/state';
2
2
  import { DecorationSet, EditorView } from '@milkdown/prose/view';
3
- import { Utils } from '@milkdown/utils';
3
+ import { ThemeUtils } from '@milkdown/utils';
4
4
  import type { Status } from './status';
5
5
  export declare type Props = ReturnType<typeof createProps>;
6
- export declare const createProps: (status: Status, utils: Utils) => {
6
+ export declare const createProps: (status: Status, utils: ThemeUtils) => {
7
7
  handleKeyDown: (_: EditorView, event: Event) => boolean;
8
8
  decorations: (state: EditorState) => DecorationSet | null;
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/props.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAc,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC7E,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"}
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/props.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAc,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,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,UAAU;uBAElC,UAAU,SAAS,KAAK;yBActB,WAAW;CAoDvC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { EditorView } from '@milkdown/prose/view';
2
- import { Utils } from '@milkdown/utils';
2
+ import { ThemeUtils } from '@milkdown/utils';
3
3
  import { Status } from './status';
4
- export declare const createView: (status: Status, view: EditorView, utils: Utils, className: string) => {
4
+ export declare const createView: (status: Status, view: EditorView, utils: ThemeUtils, className: string) => {
5
5
  update?: undefined;
6
6
  destroy?: undefined;
7
7
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/view.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAYxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA0BlC,eAAO,MAAM,UAAU,WAAY,MAAM,QAAQ,UAAU,SAAS,KAAK,aAAa,MAAM;;;;mBAmBrE,UAAU;;CAkBhC,CAAC"}
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/prose-plugin/view.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAY7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA0BlC,eAAO,MAAM,UAAU,WAAY,MAAM,QAAQ,UAAU,SAAS,UAAU,aAAa,MAAM;;;;mBAmB1E,UAAU;;CAkBhC,CAAC"}
package/lib/utility.d.ts CHANGED
@@ -2,8 +2,8 @@ import { ThemeManager } from '@milkdown/core';
2
2
  import type { Icon } from '@milkdown/design-system';
3
3
  import type { Node } from '@milkdown/prose/model';
4
4
  import type { Command } from '@milkdown/prose/state';
5
- import type { Utils } from '@milkdown/utils';
6
- export declare const createDropdown: (utils: Utils, className: string) => HTMLDivElement;
5
+ import type { ThemeUtils } from '@milkdown/utils';
6
+ export declare const createDropdown: (utils: ThemeUtils, className: string) => HTMLDivElement;
7
7
  declare type ItemOptions = {
8
8
  textClassName: string;
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI7C,eAAO,MAAM,cAAc,UAAW,KAAK,aAAa,MAAM,mBAe7D,CAAC;AAEF,aAAK,WAAW,GAAG;IACf,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC;AACF,eAAO,MAAM,kBAAkB,iBACb,YAAY,QACpB,MAAM,QACN,IAAI,YACA,QAAQ,WAAW,CAAC,mBAsBjC,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,IAAI,WASlC,CAAC;AAUF,eAAO,MAAM,oBAAoB,kBACb,MAAM,IAAI,KAAG,OAO5B,CAAC"}
1
+ {"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,eAAO,MAAM,cAAc,UAAW,UAAU,aAAa,MAAM,mBAelE,CAAC;AAEF,aAAK,WAAW,GAAG;IACf,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC;AACF,eAAO,MAAM,kBAAkB,iBACb,YAAY,QACpB,MAAM,QACN,IAAI,YACA,QAAQ,WAAW,CAAC,mBAsBjC,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,IAAI,WASlC,CAAC;AAUF,eAAO,MAAM,oBAAoB,kBACb,MAAM,IAAI,KAAG,OAO5B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkdown/plugin-slash",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "type": "module",
5
5
  "main": "./lib/index.es.js",
6
6
  "types": "./lib/index.d.ts",
@@ -15,17 +15,17 @@
15
15
  "milkdown plugin"
16
16
  ],
17
17
  "devDependencies": {
18
- "@milkdown/core": "6.3.0",
19
- "@milkdown/prose": "6.3.0",
20
- "@milkdown/design-system": "6.3.0"
18
+ "@milkdown/core": "6.4.0",
19
+ "@milkdown/prose": "6.4.0",
20
+ "@milkdown/design-system": "6.4.0"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@milkdown/core": "^6.0.1",
24
24
  "@milkdown/prose": "^6.0.1"
25
25
  },
26
26
  "dependencies": {
27
- "@milkdown/utils": "6.3.0",
28
- "@milkdown/exception": "6.3.0",
27
+ "@milkdown/utils": "6.4.0",
28
+ "@milkdown/exception": "6.4.0",
29
29
  "smooth-scroll-into-view-if-needed": "^1.1.32",
30
30
  "tslib": "^2.4.0"
31
31
  },
@@ -1,6 +1,6 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { Plugin, PluginKey } from '@milkdown/prose/state';
3
- import { Utils } from '@milkdown/utils';
3
+ import { ThemeUtils } from '@milkdown/utils';
4
4
 
5
5
  import type { StatusConfigBuilder } from '..';
6
6
  import { createProps } from './props';
@@ -9,7 +9,7 @@ import { createView } from './view';
9
9
 
10
10
  export const key = 'MILKDOWN_SLASH';
11
11
 
12
- export const createSlashPlugin = (utils: Utils, builder: StatusConfigBuilder, className: string) => {
12
+ export const createSlashPlugin = (utils: ThemeUtils, builder: StatusConfigBuilder, className: string) => {
13
13
  const status = createStatus(builder);
14
14
 
15
15
  return new Plugin({
@@ -3,7 +3,7 @@ import { Color, Emotion, ThemeColor, ThemeFont, ThemeManager } from '@milkdown/c
3
3
  import { findParentNode } from '@milkdown/prose';
4
4
  import { EditorState } from '@milkdown/prose/state';
5
5
  import { Decoration, DecorationSet, EditorView } from '@milkdown/prose/view';
6
- import { Utils } from '@milkdown/utils';
6
+ import { ThemeUtils } from '@milkdown/utils';
7
7
 
8
8
  import type { Status } from './status';
9
9
 
@@ -19,7 +19,7 @@ const createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {
19
19
  position: absolute;
20
20
  cursor: text;
21
21
  font-family: ${typography};
22
- font-size: 0.875em;
22
+ font-size: 14px;
23
23
  color: ${palette('neutral', 0.6)};
24
24
  content: attr(data-text);
25
25
  height: 100%;
@@ -31,11 +31,11 @@ const createEmptyStyle = (themeManager: ThemeManager, { css }: Emotion) => {
31
31
 
32
32
  const createSlashStyle = (_: ThemeManager, { css }: Emotion) => css`
33
33
  &::before {
34
- left: 0.5em;
34
+ left: 8px;
35
35
  }
36
36
  `;
37
37
 
38
- export const createProps = (status: Status, utils: Utils) => {
38
+ export const createProps = (status: Status, utils: ThemeUtils) => {
39
39
  return {
40
40
  handleKeyDown: (_: EditorView, event: Event) => {
41
41
  if (status.isEmpty()) {
@@ -2,7 +2,7 @@
2
2
  import { missingRootElement } from '@milkdown/exception';
3
3
  import { calculateNodePosition } from '@milkdown/prose';
4
4
  import { EditorView } from '@milkdown/prose/view';
5
- import { Utils } from '@milkdown/utils';
5
+ import { ThemeUtils } from '@milkdown/utils';
6
6
 
7
7
  import { createDropdown } from '../utility';
8
8
  import { renderDropdown } from './dropdown';
@@ -40,7 +40,7 @@ const calculatePosition = (view: EditorView, dropdownElement: HTMLElement) => {
40
40
  });
41
41
  };
42
42
 
43
- export const createView = (status: Status, view: EditorView, utils: Utils, className: string) => {
43
+ export const createView = (status: Status, view: EditorView, utils: ThemeUtils, className: string) => {
44
44
  const wrapper = view.dom.parentNode;
45
45
  if (!wrapper) return {};
46
46
 
package/src/style.ts CHANGED
@@ -16,15 +16,15 @@ const itemStyle = (themeManager: ThemeManager, { css }: Emotion) => {
16
16
  return css`
17
17
  .slash-dropdown-item {
18
18
  display: flex;
19
- gap: 2em;
20
- height: 3.4286em;
21
- padding: 0 1em;
19
+ gap: 32px;
20
+ height: 48px;
21
+ padding: 0 16px;
22
22
  align-items: center;
23
23
  justify-content: flex-start;
24
24
  cursor: pointer;
25
- line-height: 3.4286em;
25
+ line-height: 48px;
26
26
  font-family: ${themeManager.get(ThemeFont, 'typography')};
27
- font-size: 0.875em;
27
+ font-size: 14px;
28
28
 
29
29
  transition: all 0.2s ease-in-out;
30
30
 
@@ -53,8 +53,8 @@ export const injectStyle = (themeManager: ThemeManager, emotion: Emotion) => {
53
53
  const palette = (color: Color, opacity = 1) => themeManager.get(ThemeColor, [color, opacity]);
54
54
 
55
55
  return emotion.css`
56
- width: 20.5em;
57
- max-height: 20.5em;
56
+ width: 320px;
57
+ max-height: 320px;
58
58
  overflow-y: auto;
59
59
  border-radius: ${themeManager.get(ThemeSize, 'radius')};
60
60
  position: absolute;
package/src/utility.ts CHANGED
@@ -4,11 +4,11 @@ import type { Icon } from '@milkdown/design-system';
4
4
  import { missingIcon } from '@milkdown/exception';
5
5
  import type { Node } from '@milkdown/prose/model';
6
6
  import type { Command } from '@milkdown/prose/state';
7
- import type { Utils } from '@milkdown/utils';
7
+ import type { ThemeUtils } from '@milkdown/utils';
8
8
 
9
9
  import { injectStyle } from './style';
10
10
 
11
- export const createDropdown = (utils: Utils, className: string) => {
11
+ export const createDropdown = (utils: ThemeUtils, className: string) => {
12
12
  const div = document.createElement('div');
13
13
  div.setAttribute('role', 'listbox');
14
14
  div.setAttribute('tabindex', '-1');