prosemirror-menu 1.3.1 → 1.3.2
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +6 -1
- package/dist/index.js +4 -2
- package/package.json +1 -1
- package/src/icons.ts +1 -0
- package/src/menu.ts +3 -2
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ function getIcon(root, icon) {
|
|
|
28
28
|
var doc = (root.nodeType == 9 ? root : root.ownerDocument) || document;
|
|
29
29
|
var node = doc.createElement("button");
|
|
30
30
|
node.className = prefix$2;
|
|
31
|
+
node.type = "button";
|
|
31
32
|
if (icon.path) {
|
|
32
33
|
var path = icon.path,
|
|
33
34
|
width = icon.width,
|
|
@@ -77,7 +78,9 @@ var MenuItem = function () {
|
|
|
77
78
|
key: "render",
|
|
78
79
|
value: function render(view) {
|
|
79
80
|
var spec = this.spec;
|
|
80
|
-
var dom = spec.render ? spec.render(view) : spec.icon ? getIcon(view.root, spec.icon) : spec.label ? crel("button",
|
|
81
|
+
var dom = spec.render ? spec.render(view) : spec.icon ? getIcon(view.root, spec.icon) : spec.label ? crel("button", {
|
|
82
|
+
type: "button"
|
|
83
|
+
}, translate(view, spec.label)) : null;
|
|
81
84
|
if (!dom) throw new RangeError("MenuItem without icon or label property");
|
|
82
85
|
if (spec.title) {
|
|
83
86
|
var title = typeof spec.title === "function" ? spec.title(view.state) : spec.title;
|
|
@@ -155,6 +158,7 @@ var Dropdown = function () {
|
|
|
155
158
|
this.focusables = content.focusables;
|
|
156
159
|
var win = view.dom.ownerDocument.defaultView || window;
|
|
157
160
|
var btn = crel("button", {
|
|
161
|
+
type: "button",
|
|
158
162
|
"class": prefix$1 + "-dropdown " + (this.options["class"] || ""),
|
|
159
163
|
style: this.options.css,
|
|
160
164
|
"aria-haspopup": "menu",
|
|
@@ -336,6 +340,7 @@ var DropdownSubmenu = function () {
|
|
|
336
340
|
this.focusables = items.focusables;
|
|
337
341
|
var win = view.dom.ownerDocument.defaultView || window;
|
|
338
342
|
var btn = crel("button", {
|
|
343
|
+
type: "button",
|
|
339
344
|
"class": prefix$1 + "-submenu-label"
|
|
340
345
|
}, translate(view, this.options.label || ""));
|
|
341
346
|
var wrap = crel("div", {
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ function getIcon(root, icon) {
|
|
|
16
16
|
let doc = (root.nodeType == 9 ? root : root.ownerDocument) || document;
|
|
17
17
|
let node = doc.createElement("button");
|
|
18
18
|
node.className = prefix$2;
|
|
19
|
+
node.type = "button";
|
|
19
20
|
if (icon.path) {
|
|
20
21
|
let { path, width, height } = icon;
|
|
21
22
|
let name = "pm-icon-" + hashPath(path).toString(16);
|
|
@@ -78,7 +79,7 @@ class MenuItem {
|
|
|
78
79
|
let spec = this.spec;
|
|
79
80
|
let dom = spec.render ? spec.render(view)
|
|
80
81
|
: spec.icon ? getIcon(view.root, spec.icon)
|
|
81
|
-
: spec.label ? crel("button",
|
|
82
|
+
: spec.label ? crel("button", { type: "button" }, translate(view, spec.label))
|
|
82
83
|
: null;
|
|
83
84
|
if (!dom)
|
|
84
85
|
throw new RangeError("MenuItem without icon or label property");
|
|
@@ -169,6 +170,7 @@ class Dropdown {
|
|
|
169
170
|
this.focusables = content.focusables;
|
|
170
171
|
let win = view.dom.ownerDocument.defaultView || window;
|
|
171
172
|
let btn = crel("button", {
|
|
173
|
+
type: "button",
|
|
172
174
|
class: prefix$1 + "-dropdown " + (this.options.class || ""),
|
|
173
175
|
style: this.options.css,
|
|
174
176
|
"aria-haspopup": "menu",
|
|
@@ -354,7 +356,7 @@ class DropdownSubmenu {
|
|
|
354
356
|
let items = renderDropdownItems(this.content, view);
|
|
355
357
|
this.focusables = items.focusables;
|
|
356
358
|
let win = view.dom.ownerDocument.defaultView || window;
|
|
357
|
-
let btn = crel("button", { class: prefix$1 + "-submenu-label" }, translate(view, this.options.label || ""));
|
|
359
|
+
let btn = crel("button", { type: "button", class: prefix$1 + "-submenu-label" }, translate(view, this.options.label || ""));
|
|
358
360
|
let wrap = crel("div", { class: prefix$1 + "-submenu-wrap" }, btn, crel("div", { class: prefix$1 + "-submenu" }, items.dom));
|
|
359
361
|
let listeningOnClose = null;
|
|
360
362
|
let openSubmenu = (e) => {
|
package/package.json
CHANGED
package/src/icons.ts
CHANGED
|
@@ -17,6 +17,7 @@ export function getIcon(
|
|
|
17
17
|
let doc = (root.nodeType == 9 ? root as Document : root.ownerDocument) || document
|
|
18
18
|
let node = doc.createElement("button")
|
|
19
19
|
node.className = prefix
|
|
20
|
+
node.type = "button"
|
|
20
21
|
if ((icon as any).path) {
|
|
21
22
|
let {path, width, height} = icon as {path: string, width: number, height: number}
|
|
22
23
|
let name = "pm-icon-" + hashPath(path).toString(16)
|
package/src/menu.ts
CHANGED
|
@@ -37,7 +37,7 @@ export class MenuItem<E extends HTMLElement = HTMLButtonElement> implements Menu
|
|
|
37
37
|
let spec = this.spec
|
|
38
38
|
let dom = spec.render ? spec.render(view)
|
|
39
39
|
: spec.icon ? getIcon(view.root, spec.icon)
|
|
40
|
-
: spec.label ? crel("button",
|
|
40
|
+
: spec.label ? crel("button", {type: "button"}, translate(view, spec.label)) as HTMLButtonElement
|
|
41
41
|
: null
|
|
42
42
|
if (!dom) throw new RangeError("MenuItem without icon or label property")
|
|
43
43
|
if (spec.title) {
|
|
@@ -189,6 +189,7 @@ export class Dropdown implements MenuElement {
|
|
|
189
189
|
|
|
190
190
|
let btn = crel(
|
|
191
191
|
"button", {
|
|
192
|
+
type: "button",
|
|
192
193
|
class: prefix + "-dropdown " + (this.options.class || ""),
|
|
193
194
|
style: this.options.css,
|
|
194
195
|
"aria-haspopup": "menu",
|
|
@@ -382,7 +383,7 @@ export class DropdownSubmenu implements MenuElement {
|
|
|
382
383
|
this.focusables = items.focusables
|
|
383
384
|
let win = view.dom.ownerDocument.defaultView || window
|
|
384
385
|
|
|
385
|
-
let btn = crel("button", {class: prefix + "-submenu-label"}, translate(view, this.options.label || ""))
|
|
386
|
+
let btn = crel("button", {type: "button", class: prefix + "-submenu-label"}, translate(view, this.options.label || ""))
|
|
386
387
|
let wrap = crel("div", {class: prefix + "-submenu-wrap"}, btn,
|
|
387
388
|
crel("div", {class: prefix + "-submenu"}, items.dom))
|
|
388
389
|
let listeningOnClose: (() => void) | null = null
|