@kerebron/extension-menu 0.4.7 → 0.4.9
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/esm/CustomMenuPlugin.js +19 -96
- package/esm/ExtensionCustomMenu.js +1 -9
- package/esm/menu.d.ts +1 -1
- package/esm/menu.js +12 -44
- package/esm/prompt.js +2 -6
- package/package.json +5 -2
package/esm/CustomMenuPlugin.js
CHANGED
|
@@ -7,103 +7,26 @@ const STORAGE_KEY = 'kb-custom-menu-pinned';
|
|
|
7
7
|
// Bootstrap md breakpoint: 768px (mobile is < 768px, desktop is >= 768px)
|
|
8
8
|
const MOBILE_BREAKPOINT = 768;
|
|
9
9
|
export class CustomMenuView {
|
|
10
|
+
editorView;
|
|
11
|
+
editor;
|
|
12
|
+
content;
|
|
13
|
+
wrapper;
|
|
14
|
+
toolbar;
|
|
15
|
+
overflowMenu;
|
|
16
|
+
pinnedDropdownMenu = null;
|
|
17
|
+
modal = null;
|
|
18
|
+
tools = [];
|
|
19
|
+
root;
|
|
20
|
+
resizeHandle;
|
|
21
|
+
editorContainer;
|
|
22
|
+
closeOverflowHandler = null;
|
|
23
|
+
closePinnedDropdownHandler = null;
|
|
24
|
+
submenuStack = [];
|
|
25
|
+
pinnedDropdownStack = [];
|
|
10
26
|
constructor(editorView, editor, content) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
writable: true,
|
|
15
|
-
value: editorView
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(this, "editor", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: editor
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(this, "content", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: content
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "wrapper", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "toolbar", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(this, "overflowMenu", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: void 0
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(this, "pinnedDropdownMenu", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: null
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "modal", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: null
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "tools", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: []
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "root", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: void 0
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(this, "resizeHandle", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
configurable: true,
|
|
74
|
-
writable: true,
|
|
75
|
-
value: void 0
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(this, "editorContainer", {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
configurable: true,
|
|
80
|
-
writable: true,
|
|
81
|
-
value: void 0
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(this, "closeOverflowHandler", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
configurable: true,
|
|
86
|
-
writable: true,
|
|
87
|
-
value: null
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(this, "closePinnedDropdownHandler", {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
configurable: true,
|
|
92
|
-
writable: true,
|
|
93
|
-
value: null
|
|
94
|
-
});
|
|
95
|
-
Object.defineProperty(this, "submenuStack", {
|
|
96
|
-
enumerable: true,
|
|
97
|
-
configurable: true,
|
|
98
|
-
writable: true,
|
|
99
|
-
value: []
|
|
100
|
-
});
|
|
101
|
-
Object.defineProperty(this, "pinnedDropdownStack", {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
configurable: true,
|
|
104
|
-
writable: true,
|
|
105
|
-
value: []
|
|
106
|
-
});
|
|
27
|
+
this.editorView = editorView;
|
|
28
|
+
this.editor = editor;
|
|
29
|
+
this.content = content;
|
|
107
30
|
this.root = editorView.root;
|
|
108
31
|
// Create wrapper
|
|
109
32
|
this.wrapper = document.createElement('div');
|
|
@@ -3,15 +3,7 @@ import { buildMenu } from './buildMenu.js';
|
|
|
3
3
|
import { CustomMenuPlugin } from './CustomMenuPlugin.js';
|
|
4
4
|
/// Extension for a customizable menu with pinned items
|
|
5
5
|
export class ExtensionCustomMenu extends Extension {
|
|
6
|
-
|
|
7
|
-
super(...arguments);
|
|
8
|
-
Object.defineProperty(this, "name", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: 'customMenu'
|
|
13
|
-
});
|
|
14
|
-
}
|
|
6
|
+
name = 'customMenu';
|
|
15
7
|
getProseMirrorPlugins() {
|
|
16
8
|
const content = buildMenu(this.editor, this.editor.schema);
|
|
17
9
|
return [
|
package/esm/menu.d.ts
CHANGED
package/esm/menu.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { getIcon } from './icons.js';
|
|
2
2
|
/// An icon or label that, when clicked, executes a command.
|
|
3
3
|
export class MenuItem {
|
|
4
|
+
spec;
|
|
5
|
+
CSS_PREFIX = 'kb-menu__button';
|
|
4
6
|
/// Create a menu item.
|
|
5
7
|
constructor(
|
|
6
8
|
/// The spec used to create this item.
|
|
7
9
|
spec) {
|
|
8
|
-
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: spec
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "CSS_PREFIX", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: 'kb-menu__button'
|
|
19
|
-
});
|
|
10
|
+
this.spec = spec;
|
|
20
11
|
}
|
|
21
12
|
/// Renders the icon according to its [display
|
|
22
13
|
/// spec](#menu.MenuItemSpec.display), and adds an event handler which
|
|
@@ -107,29 +98,15 @@ function isMenuEvent(wrapper) {
|
|
|
107
98
|
/// A drop-down menu, displayed as a label with a downwards-pointing
|
|
108
99
|
/// triangle to the right of it.
|
|
109
100
|
export class Dropdown {
|
|
101
|
+
options;
|
|
102
|
+
CSS_PREFIX = 'kb-dropdown';
|
|
103
|
+
/// @internal
|
|
104
|
+
content;
|
|
110
105
|
/// Create a dropdown wrapping the elements.
|
|
111
106
|
constructor(content,
|
|
112
107
|
/// @internal
|
|
113
108
|
options = {}) {
|
|
114
|
-
|
|
115
|
-
enumerable: true,
|
|
116
|
-
configurable: true,
|
|
117
|
-
writable: true,
|
|
118
|
-
value: options
|
|
119
|
-
});
|
|
120
|
-
Object.defineProperty(this, "CSS_PREFIX", {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
configurable: true,
|
|
123
|
-
writable: true,
|
|
124
|
-
value: 'kb-dropdown'
|
|
125
|
-
});
|
|
126
|
-
/// @internal
|
|
127
|
-
Object.defineProperty(this, "content", {
|
|
128
|
-
enumerable: true,
|
|
129
|
-
configurable: true,
|
|
130
|
-
writable: true,
|
|
131
|
-
value: void 0
|
|
132
|
-
});
|
|
109
|
+
this.options = options;
|
|
133
110
|
this.options = options || {};
|
|
134
111
|
this.content = Array.isArray(content) ? content : [content];
|
|
135
112
|
}
|
|
@@ -237,24 +214,15 @@ function combineUpdates(updates, nodes) {
|
|
|
237
214
|
/// Represents a submenu wrapping a group of elements that start
|
|
238
215
|
/// hidden and expand to the right when hovered over or tapped.
|
|
239
216
|
export class DropdownSubmenu {
|
|
217
|
+
options;
|
|
218
|
+
/// @internal
|
|
219
|
+
content;
|
|
240
220
|
/// Creates a submenu for the given group of menu elements. The
|
|
241
221
|
/// following options are recognized:
|
|
242
222
|
constructor(content,
|
|
243
223
|
/// @internal
|
|
244
224
|
options = {}) {
|
|
245
|
-
|
|
246
|
-
enumerable: true,
|
|
247
|
-
configurable: true,
|
|
248
|
-
writable: true,
|
|
249
|
-
value: options
|
|
250
|
-
});
|
|
251
|
-
/// @internal
|
|
252
|
-
Object.defineProperty(this, "content", {
|
|
253
|
-
enumerable: true,
|
|
254
|
-
configurable: true,
|
|
255
|
-
writable: true,
|
|
256
|
-
value: void 0
|
|
257
|
-
});
|
|
225
|
+
this.options = options;
|
|
258
226
|
this.content = Array.isArray(content) ? content : [content];
|
|
259
227
|
}
|
|
260
228
|
/// Renders the submenu.
|
package/esm/prompt.js
CHANGED
|
@@ -96,17 +96,13 @@ function reportInvalid(dom, message) {
|
|
|
96
96
|
}
|
|
97
97
|
/// The type of field that `openPrompt` expects to be passed to it.
|
|
98
98
|
export class Field {
|
|
99
|
+
options;
|
|
99
100
|
/// Create a field with the given options. Options support by all
|
|
100
101
|
/// field types are:
|
|
101
102
|
constructor(
|
|
102
103
|
/// @internal
|
|
103
104
|
options) {
|
|
104
|
-
|
|
105
|
-
enumerable: true,
|
|
106
|
-
configurable: true,
|
|
107
|
-
writable: true,
|
|
108
|
-
value: options
|
|
109
|
-
});
|
|
105
|
+
this.options = options;
|
|
110
106
|
}
|
|
111
107
|
/// Read the field's value from its DOM node.
|
|
112
108
|
read(dom) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-menu",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/mod.js",
|
|
6
6
|
"exports": {
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
},
|
|
10
10
|
"./ExtensionCustomMenu": {
|
|
11
11
|
"import": "./esm/ExtensionCustomMenu.js"
|
|
12
|
+
},
|
|
13
|
+
"./assets/*.css": {
|
|
14
|
+
"import": "./assets/*.css"
|
|
12
15
|
}
|
|
13
16
|
},
|
|
14
17
|
"scripts": {},
|
|
15
18
|
"dependencies": {
|
|
16
|
-
"@kerebron/editor": "0.4.
|
|
19
|
+
"@kerebron/editor": "0.4.9",
|
|
17
20
|
"prosemirror-model": "1.25.3",
|
|
18
21
|
"prosemirror-state": "1.4.3",
|
|
19
22
|
"prosemirror-view": "1.40.0"
|