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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.3.2 (2026-04-17)
2
+
3
+ ### Bug fixes
4
+
5
+ Give menu buttons a `type=button` attribute to make sure they don't try to submit surrounding forms.
6
+
1
7
  ## 1.3.1 (2026-04-15)
2
8
 
3
9
  ### Bug fixes
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", null, translate(view, spec.label)) : null;
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", null, translate(view, spec.label))
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-menu",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Simple menu elements for ProseMirror",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
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", null, translate(view, spec.label)) as HTMLButtonElement
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