{"name":"prosemirror-menu","version":"1.3.2","description":"Simple menu elements for ProseMirror","type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs"},"./style/menu.css":"./style/menu.css"},"sideEffects":["./style/menu.css"],"style":"style/menu.css","license":"MIT","maintainers":[{"name":"marijn","email":"marijn@haverbeke.berlin"}],"repository":{"type":"git","url":"git+https://code.haverbeke.berlin/prosemirror/prosemirror-menu.git"},"dependencies":{"crelt":"^1.0.0","prosemirror-state":"^1.0.0","prosemirror-commands":"^1.0.0","prosemirror-history":"^1.0.0"},"devDependencies":{"@prosemirror/buildhelper":"^0.1.5"},"scripts":{"prepare":"pm-buildhelper src/index.ts"},"gitHead":"fae4f6f74aa06cdbd0e425871542876bdc42a26d","_id":"prosemirror-menu@1.3.2","_nodeVersion":"22.20.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-6VgUJTYod0nMBlCaYJGhXGLu7Gt4AvcwcOq0YfJCY/6Uh+3S7UsWhpy6rJFCBFOmonq1hD8KyWOtZhkppd4YPg==","shasum":"84bcc9756ae1f790a5e62f10df61aec8b71e12cb","tarball":"http://registry-npm.ywwl.com/prosemirror-menu/download/prosemirror-menu-1.3.2.tgz","fileCount":16,"unpackedSize":142123,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDZbaCoOD8B/WhHBZYAbMvwvZdqTLmXK+FT1ZYGEhZ5IgIgfe/kaMApxZt3ejFalBhPtcQoyTZpTLEea84rM85d/2o="}],"size":35990,"noattachment":false,"key":"/prosemirror-menu/-/prosemirror-menu-1.3.2.tgz"},"_npmUser":{"name":"marijn","email":"marijn@haverbeke.berlin"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prosemirror-menu_1.3.2_1776417087681_0.17694492381959592"},"_hasShrinkwrap":false,"readme":"# prosemirror-menu\n\n[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://code.haverbeke.berlin/prosemirror/prosemirror-menu/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**GITTER**](https://gitter.im/ProseMirror/prosemirror) ]\n\nThis is a non-core example module for [ProseMirror](https://prosemirror.net).\nProseMirror is a well-behaved rich semantic content editor based on\ncontentEditable, with support for collaborative editing and custom\ndocument schemas.\n\nThis module defines an abstraction for building a menu for the\nProseMirror editor, along with an implementation of a menubar.\n\n**Note** that this module exists mostly as an example of how you\n_might_ want to approach adding a menu to ProseMirror, but is not\nmaintained as actively as the core modules related to actual editing.\nIf you want to extend or improve it, the recommended way is to fork\nit. If you are interested in maintaining a serious menu component for\nProseMirror, publish your fork, and if it works for me, I'll gladly\ndeprecate this in favor of your module.\n\nThis code is released under an\n[MIT license](https://code.haverbeke.berlin/prosemirror/prosemirror/src/branch/main/LICENSE).\nThere's a [forum](http://discuss.prosemirror.net) for general\ndiscussion and support requests, and the\n[bug tracker](https://code.haverbeke.berlin/prosemirror/prosemirror-menu/issues)\nis the place to report issues.\n\n## Documentation\n\nThis module defines a number of building blocks for ProseMirror menus,\nalong with a [menu bar](#menu.menuBar) implementation.\n\nWhen using this module, you should make sure its\n[`style/menu.css`](https://code.haverbeke.berlin/prosemirror/prosemirror-menu/src/branch/main/style/menu.css)\nfile is loaded into your page.\n\n### interface MenuElement\n\nThe types defined in this module aren't the only thing you can\ndisplay in your menu. Anything that conforms to this interface can\nbe put into a menu structure.\n\n * **`render`**`(pm: EditorView) → {dom: HTMLElement, update: fn(state: EditorState) → boolean, focusable?: HTMLElement}`\\\n   Render the element for display in the menu. Must return a DOM\n   element and a function that can be used to update the element to\n   a new state. The `update` function must return false if the\n   update hid the entire element. May also return a `focusable`\n   DOM node, which is the node that should receive focus when this\n   element is focused. If not provided, the `dom` element will be used.\n\n### class MenuItem`<E extends HTMLElement = HTMLButtonElement>`\n\n implements `MenuElement`An icon or label that, when clicked, executes a command.\n\n * `new `**`MenuItem`**`(spec: MenuItemSpec)`\\\n   Create a menu item.\n\n * **`spec`**`: MenuItemSpec`\\\n   The spec used to create this item.\n\n * **`render`**`(view: EditorView) → {dom: E | HTMLButtonElement, update: fn(state: EditorState) → boolean}`\\\n   Renders the icon according to its [display\n   spec](#menu.MenuItemSpec.display), and adds an event handler which\n   executes the command when the representation is clicked.\n\n### interface MenuItemSpec`<E extends HTMLElement = HTMLButtonElement>`\n\nThe configuration object passed to the `MenuItem` constructor.\n\n * **`run`**`(state: EditorState, dispatch: fn(tr: Transaction), view: EditorView, event: Event)`\\\n   The function to execute when the menu item is activated.\n\n * **`select`**`?: fn(state: EditorState) → boolean`\\\n   Optional function that is used to determine whether the item is\n   appropriate at the moment. Deselected items will be hidden.\n\n * **`enable`**`?: fn(state: EditorState) → boolean`\\\n   Function that is used to determine if the item is enabled. If\n   given and returning false, the item will be given a disabled\n   styling.\n\n * **`active`**`?: fn(state: EditorState) → boolean`\\\n   A predicate function to determine whether the item is 'active' (for\n   example, the item for toggling the strong mark might be active then\n   the cursor is in strong text).\n\n * **`render`**`?: fn(view: EditorView) → E`\\\n   A function that renders the item. You must provide either this,\n   [`icon`](#menu.MenuItemSpec.icon), or [`label`](#MenuItemSpec.label).\n\n * **`icon`**`?: IconSpec`\\\n   Describes an icon to show for this item.\n\n * **`label`**`?: string`\\\n   Makes the item show up as a text label. Mostly useful for items\n   wrapped in a [drop-down](#menu.Dropdown) or similar menu. The object\n   should have a `label` property providing the text to display.\n\n * **`title`**`?: string | fn(state: EditorState) → string`\\\n   Defines DOM title (mouseover) text for the item.\n\n * **`class`**`?: string`\\\n   Optionally adds a CSS class to the item's DOM representation.\n\n * **`css`**`?: string`\\\n   Optionally adds a string of inline CSS to the item's DOM\n   representation.\n\n * type **`IconSpec`**\n   ` = {path: string, width: number, height: number} | {text: string, css?: string} | {dom: Node}`\\\n   Specifies an icon. May be either an SVG icon, in which case its\n   `path` property should be an [SVG path\n   spec](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d),\n   and `width` and `height` should provide the viewbox in which that\n   path exists. Alternatively, it may have a `text` property\n   specifying a string of text that makes up the icon, with an\n   optional `css` property giving additional CSS styling for the\n   text. _Or_ it may contain `dom` property containing a DOM node.\n\n### class Dropdown\n\n implements `MenuElement`A drop-down menu, displayed as a label with a downwards-pointing\ntriangle to the right of it.\n\n * `new `**`Dropdown`**`(content: readonly MenuElement[] | MenuElement, options?: Object = {})`\\\n   Create a dropdown wrapping the elements.\n\n    * **`options`**`?: Object`\n\n       * **`label`**`?: string`\\\n         The label to show on the drop-down control.\n\n       * **`title`**`?: string`\\\n         Sets the\n         [`title`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title)\n         attribute given to the menu control.\n\n       * **`class`**`?: string`\\\n         When given, adds an extra CSS class to the menu control.\n\n       * **`css`**`?: string`\\\n         When given, adds an extra set of CSS styles to the menu control.\n\n * **`render`**`(view: EditorView) → {dom: HTMLElement, update: fn(state: EditorState) → boolean, focusable: HTMLElement}`\\\n   Render the dropdown menu and sub-items.\n\n * **`setFocusIndex`**`(index: number)`\n\n### class DropdownSubmenu\n\n implements `MenuElement`Represents a submenu wrapping a group of elements that start\nhidden and expand to the right when hovered over or tapped.\n\n * `new `**`DropdownSubmenu`**`(content: readonly MenuElement[] | MenuElement, options?: Object = {})`\\\n   Creates a submenu for the given group of menu elements. The\n   following options are recognized:\n\n    * **`options`**`?: Object`\n\n       * **`label`**`?: string`\\\n         The label to show on the submenu.\n\n * **`render`**`(view: EditorView) → {dom: HTMLElement, update: fn(state: EditorState) → boolean, focusable: HTMLElement}`\\\n   Renders the submenu.\n\n * **`setFocusIndex`**`(index: number)`\n\n * **`menuBar`**`(options: Object) → Plugin`\\\n   A plugin that will place a menu bar above the editor. Note that\n   this involves wrapping the editor in an additional `<div>`.\n\n    * **`options`**`: Object`\n\n       * **`content`**`: readonly readonly MenuElement[][]`\\\n         Provides the content of the menu, as a nested array to be\n         passed to `renderGrouped`.\n\n       * **`position`**`?: \"before\" | \"after\"`\\\n         Determines whether the menu is placed before or after the editor in the DOM.\n         The default is \"before\".\n\n       * **`floating`**`?: boolean`\\\n         Determines whether the menu floats, i.e. whether it sticks to\n         the top of the viewport when the editor is partially scrolled\n         out of view.\n\n\nThis module exports the following pre-built items or item\nconstructors:\n\n * **`joinUpItem`**`: MenuItem`\\\n   Menu item for the `joinUp` command.\n\n * **`liftItem`**`: MenuItem`\\\n   Menu item for the `lift` command.\n\n * **`selectParentNodeItem`**`: MenuItem`\\\n   Menu item for the `selectParentNode` command.\n\n * **`undoItem`**`: MenuItem`\\\n   Menu item for the `undo` command.\n\n * **`redoItem`**`: MenuItem`\\\n   Menu item for the `redo` command.\n\n * **`wrapItem`**`(nodeType: NodeType, options: Partial & {attrs?: Attrs}) → MenuItem`\\\n   Build a menu item for wrapping the selection in a given node type.\n   Adds `run` and `select` properties to the ones present in\n   `options`. `options.attrs` may be an object that provides\n   attributes for the wrapping node.\n\n * **`blockTypeItem`**`(nodeType: NodeType, options: Partial & {attrs?: Attrs}) → MenuItem`\\\n   Build a menu item for changing the type of the textblock around the\n   selection to the given type. Provides `run`, `active`, and `select`\n   properties. Others must be given in `options`. `options.attrs` may\n   be an object to provide the attributes for the textblock node.\n\n\nTo construct your own items, these icons may be useful:\n\n * **`icons`**`: Object`\\\n   A set of basic editor-related icons. Contains the properties\n   `join`, `lift`, `selectParentNode`, `undo`, `redo`, `strong`, `em`,\n   `code`, `link`, `bulletList`, `orderedList`, and `blockquote`, each\n   holding an object that can be used as the `icon` option to\n   `MenuItem`.\n\n\n * **`renderGrouped`**`(view: EditorView, content: readonly readonly MenuElement[][]) → {dom: DocumentFragment, update: fn(state: EditorState) → boolean, focusables: HTMLElement[]}`\\\n   Render the given, possibly nested, array of menu elements into a\n   document fragment, placing separators between them (and ensuring no\n   superfluous separators appear when some of the groups turn out to\n   be empty).\n\n\n","publish_time":1776417087837,"_cnpm_publish_time":1776417087837,"dist-tags":{"beta":"1.3.0-beta.1","latest":"1.3.2"}}