Skip to content

MH4GF/prosemirror-details

Repository files navigation

ProseMirror details module

This module defines an open/closeable details element that works with rich text editor based on ProseMirror.

Documentation

detailsNodes (options: DetailsNodesOptions) → Object

This function creates a set of node specs for details and summary.

DetailsNodesOptions

  • detailsGroup: string
    • A group name (something like "block") to add to the details node type.
  • detailsContent: string
    • The content expression for details node. The first child is already added in summary, and summary is optional.
  • summaryContent: string
    • The content expression for summary node. A text or inline group would be specified. Check to see if the element can be included internally as part of the HTML specification for summary element.

DetailsNode class implements NodeView

NodeView for open/close interaction. Use it in EditorView as follows:

new EditorView(document.querySelector('#editor'), {
  state,
  nodeViews: {
    details: (node, view, getPos) => new DetailsView(node, view, getPos),
  },
})