@milkdown/plugin-slash 6.5.0 → 6.5.3

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/config.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- import { Ctx } from '@milkdown/core';
2
- import { Node } from '@milkdown/prose/model';
3
- import { EditorState } from '@milkdown/prose/state';
4
- import { WrappedAction } from './item';
5
- declare type Nullable<T> = T | null | undefined;
6
- export declare type StatusConfig = {
1
+ import type { Ctx } from '@milkdown/core';
2
+ import type { Node } from '@milkdown/prose/model';
3
+ import type { EditorState } from '@milkdown/prose/state';
4
+ import type { WrappedAction } from './item';
5
+ type Nullable<T> = T | null | undefined;
6
+ export interface StatusConfig {
7
7
  placeholder?: Nullable<string>;
8
8
  actions?: Nullable<WrappedAction[]>;
9
- };
10
- export declare type StatusConfigBuilderParams = {
9
+ }
10
+ export interface StatusConfigBuilderParams {
11
11
  content: string;
12
12
  isTopLevel: boolean;
13
13
  parentNode: Node;
14
14
  state: EditorState;
15
- };
16
- export declare type StatusConfigBuilder = (params: StatusConfigBuilderParams) => Nullable<StatusConfig>;
17
- export declare type Config = (ctx: Ctx) => StatusConfigBuilder;
15
+ }
16
+ export type StatusConfigBuilder = (params: StatusConfigBuilderParams) => Nullable<StatusConfig>;
17
+ export type Config = (ctx: Ctx) => StatusConfigBuilder;
18
18
  export declare const defaultActions: (ctx: Ctx, input?: string) => WrappedAction[];
19
19
  export declare const defaultConfig: Config;
20
20
  export {};
@@ -1 +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,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,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"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAG3C,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;AAEvC,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC9B,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,IAAI,CAAA;IAChB,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,QAAQ,CAAC,YAAY,CAAC,CAAA;AAE/F,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,mBAAmB,CAAA;AAEtD,eAAO,MAAM,cAAc,QAAS,GAAG,qBAAgB,aAAa,EAuFnE,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,MAyB3B,CAAA"}
package/lib/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { AtomList } from '@milkdown/utils';
2
2
  import type { Config } from './config';
3
- import { CalcPosition } from './prose-plugin/view';
3
+ import type { CalcPosition } from './prose-plugin/view';
4
4
  export type { Config, StatusConfig, StatusConfigBuilder, StatusConfigBuilderParams } from './config';
5
5
  export { defaultActions, defaultConfig } from './config';
6
6
  export type { Action, WrappedAction } from './item';
7
7
  export { createDropdownItem } from './utility';
8
- export declare type Options = {
8
+ export interface Options {
9
9
  config: Config;
10
10
  calcPosition: CalcPosition;
11
- };
11
+ }
12
12
  export declare const slashPlugin: import("@milkdown/utils").WithExtend<string, Options, import("@milkdown/utils").TypeMapping<string, string>, import("@milkdown/utils").PluginRest<string, string>>;
13
13
  export declare const slash: AtomList<import("@milkdown/utils").Metadata<import("@milkdown/utils").GetPlugin<string, Options>> & import("@milkdown/core").MilkdownPlugin>;
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAExE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,oBAAY,OAAO,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,WAAW,oKAatB,CAAC;AAEH,eAAO,MAAM,KAAK,8IAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAA;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGvD,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AACpG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE9C,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED,eAAO,MAAM,WAAW,oKAatB,CAAA;AAEF,eAAO,MAAM,KAAK,8IAAmC,CAAA"}
package/lib/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
- import { createPlugin as b, AtomList as E } from "@milkdown/utils";
2
- import { ThemeSize as $, ThemeBorder as C, ThemeShadow as N, ThemeScrollbar as S, ThemeFont as k, ThemeColor as y, ThemeIcon as T, schemaCtx as I, themeManagerCtx as m, commandsCtx as u } from "@milkdown/core";
1
+ import { createPlugin as b, AtomList as $ } from "@milkdown/utils";
2
+ import { ThemeSize as C, ThemeBorder as E, ThemeShadow as T, ThemeScrollbar as N, ThemeFont as k, ThemeColor as y, ThemeIcon as S, schemaCtx as I, themeManagerCtx as u, commandsCtx as p, editorViewCtx as x } from "@milkdown/core";
3
3
  import { missingIcon as A, missingRootElement as D } from "@milkdown/exception";
4
- import { Plugin as x, PluginKey as _ } from "@milkdown/prose/state";
5
- import { findParentNode as M, calculateNodePosition as P } from "@milkdown/prose";
6
- import { DecorationSet as H, Decoration as O } from "@milkdown/prose/view";
4
+ import { Plugin as _, PluginKey as M } from "@milkdown/prose/state";
5
+ import { findParentNode as P, calculateNodePosition as H } from "@milkdown/prose";
6
+ import { DecorationSet as q, Decoration as K } from "@milkdown/prose/view";
7
7
  import w from "smooth-scroll-into-view-if-needed";
8
- const q = (e, { css: t }) => {
9
- const o = (n, s = 1) => e.get(y, [n, s]);
8
+ const O = (e, { css: t }) => {
9
+ const n = (o, s = 1) => e.get(y, [o, s]);
10
10
  return t`
11
11
  .slash-dropdown-item {
12
12
  display: flex;
@@ -24,7 +24,7 @@ const q = (e, { css: t }) => {
24
24
 
25
25
  &,
26
26
  .icon {
27
- color: ${o("neutral", 0.87)};
27
+ color: ${n("neutral", 0.87)};
28
28
  transition: all 0.2s ease-in-out;
29
29
  }
30
30
 
@@ -33,216 +33,224 @@ const q = (e, { css: t }) => {
33
33
  }
34
34
 
35
35
  &.active {
36
- background: ${o("secondary", 0.12)};
36
+ background: ${n("secondary", 0.12)};
37
37
  &,
38
38
  .icon {
39
- color: ${o("primary")};
39
+ color: ${n("primary")};
40
40
  }
41
41
  }
42
42
  }
43
43
  `;
44
- }, K = (e, t) => {
45
- const o = (n, s = 1) => e.get(y, [n, s]);
44
+ }, U = (e, t) => {
45
+ const n = (o, s = 1) => e.get(y, [o, s]);
46
46
  return t.css`
47
47
  width: 320px;
48
+ min-height: 48px;
48
49
  max-height: 320px;
49
50
  overflow-y: auto;
50
- border-radius: ${e.get($, "radius")};
51
+ border-radius: ${e.get(C, "radius")};
51
52
  position: absolute;
52
- background: ${o("surface")};
53
+ background: ${n("surface")};
53
54
 
54
- ${e.get(C, void 0)}
55
+ ${e.get(E, void 0)}
56
+ ${e.get(T, void 0)}
55
57
  ${e.get(N, void 0)}
56
- ${e.get(S, void 0)}
57
58
 
58
59
  &.hide {
59
60
  display: none;
60
61
  }
61
62
 
62
- ${q(e, t)}
63
+ ${O(e, t)}
63
64
  `;
64
- }, U = (e, t) => {
65
- const o = document.createElement("div");
66
- return o.setAttribute("role", "listbox"), o.setAttribute("tabindex", "-1"), e.themeManager.onFlush(() => {
67
- const n = e.getStyle((s) => K(e.themeManager, s));
68
- n && o.classList.add(n);
69
- }), o.classList.add(e.getClassName({}, t), "hide"), o;
70
- }, p = (e, t, o, n) => {
65
+ }, W = (e, t) => {
66
+ const n = document.createElement("div");
67
+ return n.setAttribute("role", "listbox"), n.setAttribute("tabindex", "-1"), e.themeManager.onFlush(() => {
68
+ const o = e.getStyle((s) => U(e.themeManager, s));
69
+ o && n.classList.add(o);
70
+ }), n.classList.add(e.getClassName({}, t), "hide"), n;
71
+ }, f = (e, t, n, o) => {
71
72
  var l;
72
- const s = (l = n == null ? void 0 : n.textClassName) != null ? l : "text", r = document.createElement("div");
73
+ const s = (l = o == null ? void 0 : o.textClassName) != null ? l : "text", r = document.createElement("div");
73
74
  r.setAttribute("role", "option"), r.classList.add("slash-dropdown-item");
74
- const a = e.get(T, o);
75
- if (!a)
76
- throw A(o);
77
- const i = document.createElement("span");
78
- return i.textContent = t, i.className = s, r.appendChild(a.dom), r.appendChild(i), r;
79
- }, W = (e, t) => {
80
- const { selection: o } = e, { $from: n } = o, s = e.tr.deleteRange(n.start(), n.pos);
75
+ const i = e.get(S, n);
76
+ if (!i)
77
+ throw A(n);
78
+ const a = document.createElement("span");
79
+ return a.textContent = t, a.className = s, r.appendChild(i.dom), r.appendChild(a), r;
80
+ }, B = (e, t) => {
81
+ const { selection: n } = e, { $from: o } = n, s = e.tr.deleteRange(o.start(), o.pos);
81
82
  return t == null || t(s), !1;
82
- }, F = (e) => (t, o, n) => (n && (W(t, o), e()), !0), L = (e, t = "/") => {
83
- const { nodes: o } = e.get(I), n = [
83
+ }, F = (e) => (t, n, o) => (o && (B(t, n), e()), !0), L = (e, t = "/") => {
84
+ const { nodes: n } = e.get(I), o = [
84
85
  {
85
86
  id: "h1",
86
- dom: p(e.get(m), "Large Heading", "h1"),
87
- command: () => e.get(u).call("TurnIntoHeading", 1),
87
+ dom: f(e.get(u), "Large Heading", "h1"),
88
+ command: () => e.get(p).call("TurnIntoHeading", 1),
88
89
  keyword: ["h1", "large heading"],
89
90
  typeName: "heading"
90
91
  },
91
92
  {
92
93
  id: "h2",
93
- dom: p(e.get(m), "Medium Heading", "h2"),
94
- command: () => e.get(u).call("TurnIntoHeading", 2),
94
+ dom: f(e.get(u), "Medium Heading", "h2"),
95
+ command: () => e.get(p).call("TurnIntoHeading", 2),
95
96
  keyword: ["h2", "medium heading"],
96
97
  typeName: "heading"
97
98
  },
98
99
  {
99
100
  id: "h3",
100
- dom: p(e.get(m), "Small Heading", "h3"),
101
- command: () => e.get(u).call("TurnIntoHeading", 3),
101
+ dom: f(e.get(u), "Small Heading", "h3"),
102
+ command: () => e.get(p).call("TurnIntoHeading", 3),
102
103
  keyword: ["h3", "small heading"],
103
104
  typeName: "heading"
104
105
  },
105
106
  {
106
107
  id: "bulletList",
107
- dom: p(e.get(m), "Bullet List", "bulletList"),
108
- command: () => e.get(u).call("WrapInBulletList"),
108
+ dom: f(e.get(u), "Bullet List", "bulletList"),
109
+ command: () => e.get(p).call("WrapInBulletList"),
109
110
  keyword: ["bullet list", "ul"],
110
111
  typeName: "bullet_list"
111
112
  },
112
113
  {
113
114
  id: "orderedList",
114
- dom: p(e.get(m), "Ordered List", "orderedList"),
115
- command: () => e.get(u).call("WrapInOrderedList"),
115
+ dom: f(e.get(u), "Ordered List", "orderedList"),
116
+ command: () => e.get(p).call("WrapInOrderedList"),
116
117
  keyword: ["ordered list", "ol"],
117
118
  typeName: "ordered_list"
118
119
  },
119
120
  {
120
121
  id: "taskList",
121
- dom: p(e.get(m), "Task List", "taskList"),
122
- command: () => e.get(u).call("TurnIntoTaskList"),
122
+ dom: f(e.get(u), "Task List", "taskList"),
123
+ command: () => e.get(p).call("TurnIntoTaskList"),
123
124
  keyword: ["task list", "task"],
124
125
  typeName: "task_list_item"
125
126
  },
126
127
  {
127
128
  id: "image",
128
- dom: p(e.get(m), "Image", "image"),
129
- command: () => e.get(u).call("InsertImage"),
129
+ dom: f(e.get(u), "Image", "image"),
130
+ command: () => e.get(p).call("InsertImage"),
130
131
  keyword: ["image"],
131
132
  typeName: "image"
132
133
  },
133
134
  {
134
135
  id: "blockquote",
135
- dom: p(e.get(m), "Quote", "quote"),
136
- command: () => e.get(u).call("WrapInBlockquote"),
136
+ dom: f(e.get(u), "Quote", "quote"),
137
+ command: () => e.get(p).call("WrapInBlockquote"),
137
138
  keyword: ["quote", "blockquote"],
138
139
  typeName: "blockquote"
139
140
  },
140
141
  {
141
142
  id: "table",
142
- dom: p(e.get(m), "Table", "table"),
143
- command: () => e.get(u).call("InsertTable"),
143
+ dom: f(e.get(u), "Table", "table"),
144
+ command: () => e.get(p).call("InsertTable"),
144
145
  keyword: ["table"],
145
146
  typeName: "table"
146
147
  },
147
148
  {
148
149
  id: "code",
149
- dom: p(e.get(m), "Code Fence", "code"),
150
- command: () => e.get(u).call("TurnIntoCodeFence"),
150
+ dom: f(e.get(u), "Code Fence", "code"),
151
+ command: () => e.get(p).call("TurnIntoCodeFence"),
151
152
  keyword: ["code"],
152
153
  typeName: "fence"
153
154
  },
154
155
  {
155
156
  id: "divider",
156
- dom: p(e.get(m), "Divide Line", "divider"),
157
- command: () => e.get(u).call("InsertHr"),
157
+ dom: f(e.get(u), "Divide Line", "divider"),
158
+ command: () => e.get(p).call("InsertHr"),
158
159
  keyword: ["divider", "hr"],
159
160
  typeName: "hr"
160
161
  }
161
162
  ], s = t.slice(1).toLocaleLowerCase();
162
- return n.filter((r) => !!o[r.typeName] && r.keyword.some((a) => a.includes(s))).map(({ keyword: r, typeName: a, ...i }) => i);
163
- }, j = (e) => ({ content: t, isTopLevel: o }) => o ? t ? t.startsWith("/") ? t === "/" ? {
164
- placeholder: "Type to filter...",
165
- actions: L(e)
166
- } : {
167
- actions: L(e, t)
168
- } : null : { placeholder: "Type / to use the slash commands..." } : null, z = (e, { css: t }) => {
169
- const o = (s, r = 1) => e.get(y, [s, r]), n = e.get(k, "typography");
163
+ return o.filter((r) => !!n[r.typeName] && r.keyword.some((i) => i.includes(s))).map(({ keyword: r, typeName: i, ...a }) => a);
164
+ }, j = (e) => ({ content: t, isTopLevel: n }) => {
165
+ if (!n)
166
+ return null;
167
+ const o = e.get(x);
168
+ return o != null && o.editable ? t ? t.startsWith("/") ? t === "/" ? {
169
+ placeholder: "Type to filter...",
170
+ actions: L(e)
171
+ } : {
172
+ actions: L(e, t)
173
+ } : null : { placeholder: "Type / to use the slash commands..." } : null;
174
+ }, z = (e, { css: t }) => {
175
+ const n = (s, r = 1) => e.get(y, [s, r]), o = e.get(k, "typography");
170
176
  return t`
171
177
  position: relative;
172
178
  &::before {
173
179
  position: absolute;
174
180
  cursor: text;
175
- font-family: ${n};
181
+ font-family: ${o};
176
182
  font-size: 14px;
177
- color: ${o("neutral", 0.6)};
183
+ color: ${n("neutral", 0.6)};
178
184
  content: attr(data-text);
179
185
  height: 100%;
180
186
  display: flex;
181
187
  align-items: center;
182
188
  }
183
189
  `;
184
- }, B = (e, { css: t }) => t`
190
+ }, V = (e, { css: t }) => t`
185
191
  &::before {
186
192
  left: 8px;
187
193
  }
188
194
  `, R = (e, t) => ({
189
- handleKeyDown: (o, n) => !(e.isEmpty() || !(n instanceof KeyboardEvent) || !["ArrowUp", "ArrowDown", "Enter"].includes(n.key)),
190
- decorations: (o) => {
191
- const n = M(({ type: c }) => c.name === "paragraph")(o.selection), s = o.plugins.find((c) => c.key === "MILKDOWN_UPLOAD$"), r = s == null ? void 0 : s.getState(o);
192
- if (r != null && r.find(o.selection.from, o.selection.to).length > 0 || !n || n.node.childCount > 1 || o.selection.$from.parentOffset !== n.node.textContent.length || n.node.firstChild && n.node.firstChild.type.name !== "text")
195
+ handleKeyDown: (n, o) => !(e.isEmpty() || !(o instanceof KeyboardEvent) || !["ArrowUp", "ArrowDown", "Enter"].includes(o.key)),
196
+ decorations: (n) => {
197
+ const o = P(({ type: d }) => d.name === "paragraph")(n.selection), s = n.plugins.find(
198
+ (d) => d.key === "MILKDOWN_UPLOAD$"
199
+ ), r = s == null ? void 0 : s.getState(n);
200
+ if (r != null && r.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
201
  return e.clear(), null;
194
- const { placeholder: a, actions: i } = e.update({
195
- parentNode: o.selection.$from.node(o.selection.$from.depth - 1),
196
- isTopLevel: o.selection.$from.depth === 1,
197
- content: n.node.textContent,
198
- state: o
202
+ const { placeholder: i, actions: a } = e.update({
203
+ parentNode: n.selection.$from.node(n.selection.$from.depth - 1),
204
+ isTopLevel: n.selection.$from.depth === 1,
205
+ content: o.node.textContent,
206
+ state: n
199
207
  });
200
- if (!a)
208
+ if (!i)
201
209
  return null;
202
- const l = (c, g) => {
203
- const h = n.pos;
204
- return H.create(o.doc, [
205
- O.node(h, h + n.node.nodeSize, {
206
- class: g.filter((v) => v).join(" "),
207
- "data-text": c
210
+ const l = (d, h) => {
211
+ const g = o.pos;
212
+ return q.create(n.doc, [
213
+ K.node(g, g + o.node.nodeSize, {
214
+ class: h.filter((v) => v).join(" "),
215
+ "data-text": d
208
216
  })
209
217
  ]);
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"]);
218
+ }, m = t.getStyle((d) => z(t.themeManager, d)), c = t.getStyle((d) => V(t.themeManager, d));
219
+ return a.length ? l(i, [m, c, "empty-node", "is-slash"]) : l(i, [m, "empty-node"]);
212
220
  }
213
- }), V = (e) => ({
221
+ }), Q = (e) => ({
214
222
  id: e.id,
215
223
  $: e.dom,
216
224
  command: F(e.command)
217
- }), Q = () => ({
225
+ }), G = () => ({
218
226
  placeholder: null,
219
227
  actions: []
220
- }), G = (e) => {
221
- const t = Q();
228
+ }), J = (e) => {
229
+ const t = G();
222
230
  return {
223
231
  get: () => t,
224
232
  clear: () => {
225
233
  t.placeholder = null, t.actions = [];
226
234
  },
227
- update: (o) => {
235
+ update: (n) => {
228
236
  var s, r;
229
- const n = e(o);
230
- return t.placeholder = (s = n == null ? void 0 : n.placeholder) != null ? s : null, t.actions = ((r = n == null ? void 0 : n.actions) != null ? r : []).map(V), t;
237
+ const o = e(n);
238
+ return t.placeholder = (s = o == null ? void 0 : o.placeholder) != null ? s : null, t.actions = ((r = o == null ? void 0 : o.actions) != null ? r : []).map(Q), t;
231
239
  },
232
240
  isEmpty: () => t.actions.length === 0
233
241
  };
234
- }, J = (e, t, o) => {
235
- const { actions: n } = e.get();
236
- if (!n.length)
242
+ }, X = (e, t, n) => {
243
+ const { actions: o } = e.get();
244
+ if (!o.length)
237
245
  return t.classList.add("hide"), !1;
238
246
  for (t.childNodes.forEach((r) => {
239
- r.removeEventListener("mouseenter", o.mouseEnter), r.removeEventListener("mouseleave", o.mouseLeave);
247
+ r.removeEventListener("mouseenter", n.mouseEnter), r.removeEventListener("mouseleave", n.mouseLeave);
240
248
  }); t.firstChild; )
241
249
  t.firstChild.remove();
242
- n.forEach(({ $: r }) => {
243
- r.classList.remove("active"), r.addEventListener("mouseenter", o.mouseEnter), r.addEventListener("mouseleave", o.mouseLeave), t.appendChild(r);
244
- }), t.classList.remove("hide");
245
- const s = n[0];
250
+ o.forEach(({ $: r }) => {
251
+ r.classList.remove("active"), r.addEventListener("mouseenter", n.mouseEnter), r.addEventListener("mouseleave", n.mouseLeave), t.appendChild(r);
252
+ }), t.style.maxHeight = "", t.classList.remove("hide");
253
+ const s = o[0];
246
254
  return s && (s.$.classList.add("active"), requestAnimationFrame(() => {
247
255
  w(s.$, {
248
256
  scrollMode: "if-needed",
@@ -250,7 +258,7 @@ const q = (e, { css: t }) => {
250
258
  inline: "nearest"
251
259
  });
252
260
  })), !0;
253
- }, X = () => {
261
+ }, Y = () => {
254
262
  let e = !1;
255
263
  return {
256
264
  isLock: () => e,
@@ -261,120 +269,121 @@ const q = (e, { css: t }) => {
261
269
  e = !1;
262
270
  }
263
271
  };
264
- }, Y = (e) => () => {
272
+ }, Z = (e) => () => {
265
273
  e.unlock();
266
- }, Z = (e, t) => (o) => {
274
+ }, ee = (e, t) => (n) => {
267
275
  if (t.isLock())
268
276
  return;
269
- const { actions: n } = e.get(), s = n.findIndex((i) => i.$.classList.contains("active")), r = n[s];
277
+ const { actions: o } = e.get(), s = o.findIndex((a) => a.$.classList.contains("active")), r = o[s];
270
278
  r && s >= 0 && r.$.classList.remove("active");
271
- const { target: a } = o;
272
- a instanceof HTMLElement && a.classList.add("active");
273
- }, ee = () => (e) => {
279
+ const { target: i } = n;
280
+ i instanceof HTMLElement && i.classList.add("active");
281
+ }, te = () => (e) => {
274
282
  const { target: t } = e;
275
283
  t instanceof HTMLElement && t.classList.remove("active");
276
- }, te = (e, t, o) => (n) => {
277
- const { target: s } = n;
284
+ }, oe = (e, t, n) => (o) => {
285
+ const { target: s } = o;
278
286
  if (!(s instanceof HTMLElement) || !t)
279
287
  return;
280
288
  const r = () => {
281
- n.stopPropagation(), n.preventDefault();
282
- }, { actions: a } = e.get(), i = Object.values(a).find(({ $: l }) => l.contains(s));
283
- if (!i) {
289
+ o.stopPropagation(), o.preventDefault();
290
+ }, { actions: i } = e.get(), a = Object.values(i).find(({ $: l }) => l.contains(s));
291
+ if (!a) {
284
292
  if (e.isEmpty())
285
293
  return;
286
- e.clear(), o.classList.add("hide"), r();
294
+ e.clear(), n.classList.add("hide"), r();
287
295
  return;
288
296
  }
289
- r(), i.command(t.state, t.dispatch, t);
290
- }, oe = (e, t, o, n) => (s) => {
297
+ r(), a.command(t.state, t.dispatch, t);
298
+ }, ne = (e, t, n, o) => (s) => {
291
299
  if (!(s instanceof KeyboardEvent))
292
300
  return;
293
- n.isLock() || n.lock();
301
+ o.isLock() || o.lock();
294
302
  const { key: r } = s;
295
303
  if (e.isEmpty() || !["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(r))
296
304
  return;
297
- const { actions: a } = e.get();
298
- let i = a.findIndex(({ $: d }) => d.classList.contains("active"));
299
- i < 0 && (i = 0);
300
- const l = (d) => {
301
- const c = a[i], g = a[d];
302
- !c || !g || (c.$.classList.remove("active"), g.$.classList.add("active"), w(g.$, {
305
+ const { actions: i } = e.get();
306
+ let a = i.findIndex(({ $: c }) => c.classList.contains("active"));
307
+ a < 0 && (a = 0);
308
+ const l = (c) => {
309
+ const d = i[a], h = i[c];
310
+ !d || !h || (d.$.classList.remove("active"), h.$.classList.add("active"), w(h.$, {
303
311
  scrollMode: "if-needed",
304
312
  block: "nearest",
305
313
  inline: "nearest"
306
314
  }));
307
315
  };
308
316
  if (r === "ArrowDown") {
309
- const d = i === a.length - 1 ? 0 : i + 1;
310
- l(d);
317
+ const c = a === i.length - 1 ? 0 : a + 1;
318
+ l(c);
311
319
  return;
312
320
  }
313
321
  if (r === "ArrowUp") {
314
- const d = i === 0 ? a.length - 1 : i - 1;
315
- l(d);
322
+ const c = a === 0 ? i.length - 1 : a - 1;
323
+ l(c);
316
324
  return;
317
325
  }
318
326
  if (r === "Escape") {
319
327
  if (e.isEmpty())
320
328
  return;
321
- e.clear(), o.classList.add("hide");
329
+ e.clear(), n.classList.add("hide");
322
330
  return;
323
331
  }
324
- const f = a[i];
325
- !f || (f.command(t.state, t.dispatch, t), f.$.classList.remove("active"));
326
- }, ne = (e, t) => {
327
- P(e, t, (o, n, s) => {
332
+ const m = i[a];
333
+ !m || (m.command(t.state, t.dispatch, t), m.$.classList.remove("active"));
334
+ }, re = (e, t) => {
335
+ H(e, t, (n, o, s) => {
328
336
  const r = t.parentElement;
329
337
  if (!r)
330
338
  throw D();
331
- let a = o.left - s.left, i = o.bottom - s.top + 14 + r.scrollTop;
332
- if (a < 0 && (a = 0), s.height + s.top - o.bottom < n.height) {
333
- const l = o.top - s.top - n.height - 14 + r.scrollTop;
334
- l > 0 && (i = l);
335
- }
336
- return [i, a];
339
+ let i = n.left - s.left;
340
+ i < 0 && (i = 0);
341
+ let a, l;
342
+ const m = n.top - s.top, c = s.height + s.top - n.bottom;
343
+ c >= o.height + 28 ? a = "bottom" : m >= o.height + 28 ? a = "top" : c >= m ? (a = "bottom", l = c - 28) : (a = "top", l = m - 28), (m < 0 || c < 0) && (l = s.height - n.height - 28, l > o.height && (l = void 0));
344
+ const d = a === "top" ? n.top - s.top - (l != null ? l : o.height) - 14 + r.scrollTop : n.bottom - s.top + 14 + r.scrollTop;
345
+ return t.style.maxHeight = l !== void 0 && l > 0 ? `${l}px` : "", [d, i];
337
346
  });
338
- }, re = (e, t, o, n, s) => {
347
+ }, se = (e, t, n, o, s) => {
339
348
  const r = t.dom.parentNode;
340
349
  if (!r)
341
350
  return {};
342
- const a = U(o, n), i = X();
343
- r.appendChild(a);
344
- const l = Y(i), f = te(e, t, a), d = oe(e, t, a, i), c = Z(e, i), g = ee();
345
- return r.addEventListener("mousemove", l), r.addEventListener("mousedown", f), r.addEventListener("keydown", d), {
346
- update: (h) => {
347
- !J(e, a, {
348
- mouseEnter: c,
349
- mouseLeave: g
350
- }) || s(h, a);
351
+ const i = W(n, o), a = Y();
352
+ r.appendChild(i);
353
+ const l = Z(a), m = oe(e, t, i), c = ne(e, t, i, a), d = ee(e, a), h = te();
354
+ return r.addEventListener("mousemove", l), r.addEventListener("mousedown", m), r.addEventListener("keydown", c), {
355
+ update: (g) => {
356
+ !X(e, i, {
357
+ mouseEnter: d,
358
+ mouseLeave: h
359
+ }) || s(g, i);
351
360
  },
352
361
  destroy: () => {
353
- r.removeEventListener("mousemove", l), r.removeEventListener("mousedown", f), r.removeEventListener("keydown", d), a.remove();
362
+ r.removeEventListener("mousemove", l), r.removeEventListener("mousedown", m), r.removeEventListener("keydown", c), i.remove();
354
363
  }
355
364
  };
356
- }, se = "MILKDOWN_SLASH", ae = (e, t, o, n) => {
357
- const s = G(t);
358
- return new x({
359
- key: new _(se),
365
+ }, ie = "MILKDOWN_SLASH", ae = (e, t, n, o) => {
366
+ const s = J(t);
367
+ return new _({
368
+ key: new M(ie),
360
369
  props: R(s, e),
361
- view: (r) => re(s, r, e, o, n)
370
+ view: (r) => se(s, r, e, n, o)
362
371
  });
363
- }, ie = b((e, t) => {
372
+ }, le = b((e, t) => {
364
373
  var s, r;
365
- const o = (s = t == null ? void 0 : t.config) != null ? s : j, n = (r = t == null ? void 0 : t.calcPosition) != null ? r : ne;
374
+ const n = (s = t == null ? void 0 : t.config) != null ? s : j, o = (r = t == null ? void 0 : t.calcPosition) != null ? r : re;
366
375
  return {
367
- prosePlugins: (a, i) => {
368
- const l = o(i);
369
- return [ae(e, l, "slash-dropdown", n)];
376
+ prosePlugins: (i, a) => {
377
+ const l = n(a);
378
+ return [ae(e, l, "slash-dropdown", o)];
370
379
  }
371
380
  };
372
- }), ge = E.create([ie()]);
381
+ }), ge = $.create([le()]);
373
382
  export {
374
- p as createDropdownItem,
383
+ f as createDropdownItem,
375
384
  L as defaultActions,
376
385
  j as defaultConfig,
377
386
  ge as slash,
378
- ie as slashPlugin
387
+ le as slashPlugin
379
388
  };
380
389
  //# sourceMappingURL=index.es.js.map