Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
prosemirror-example-setup
Advanced tools
[ WEBSITE | ISSUES | FORUM | GITTER ]
This is a non-core example module for ProseMirror. ProseMirror is a well-behaved rich semantic content editor based on contentEditable, with support for collaborative editing and custom document schemas.
This module provides an example of the glue code one might write to tie the modules that make up ProseMirror into an actual presentable editor. It is not meant to be very reusable, though it might be helpful to get something up-and-running quickly.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license. There's a forum for general discussion and support requests, and the Github bug tracker is the place to report issues.
This module exports helper functions for deriving a set of basic menu items, input rules, or key bindings from a schema. These values need to know about the schema for two reasons—they need access to specific instances of node and mark types, and they need to know which of the node and mark types that they know about are actually present in the schema.
exampleSetup
(options: Object) → Plugin[]
Create an array of plugins pre-configured for the given schema.
The resulting array will include the following plugins:
Input rules for smart quotes and creating the block types in the
schema using markdown conventions (say "> "
to create a
blockquote)
A keymap that defines keys to create and manipulate the nodes in the schema
A keymap binding the default keys provided by the prosemirror-commands module
The undo history plugin
The drop cursor plugin
The gap cursor plugin
A custom plugin that adds a menuContent
prop for the
prosemirror-menu wrapper, and a CSS class that enables the
additional styling defined in style/style.css
in this package
Probably only useful for quickly setting up a passable editor—you'll need more control over your settings in most real-world situations.
options
: Object
schema
: Schema
The schema to generate key bindings and menu items for.
mapKeys
?: Object
Can be used to adjust the key bindings created.
menuBar
?: boolean
Set to false to disable the menu bar.
history
?: boolean
Set to false to disable the history plugin.
floatingMenu
?: boolean
Set to false to make the menu bar non-floating.
menuContent
?: MenuItem[][]
Can be used to override the menu content.
buildMenuItems
(schema: Schema) → {makeHead2?: MenuItem, makeHead3?: MenuItem, makeHead4?: MenuItem, makeHead5?: MenuItem, makeHead6?: MenuItem}
Given a schema, look for default mark and node types in it and
return an object with relevant menu items relating to those marks.
returns
: {makeHead2?: MenuItem, makeHead3?: MenuItem, makeHead4?: MenuItem, makeHead5?: MenuItem, makeHead6?: MenuItem}
toggleStrong
?: MenuItem
A menu item to toggle the strong mark.
toggleEm
?: MenuItem
A menu item to toggle the emphasis mark.
toggleCode
?: MenuItem
A menu item to toggle the code font mark.
toggleLink
?: MenuItem
A menu item to toggle the link mark.
insertImage
?: MenuItem
A menu item to insert an image.
wrapBulletList
?: MenuItem
A menu item to wrap the selection in a bullet list.
wrapOrderedList
?: MenuItem
A menu item to wrap the selection in an ordered list.
wrapBlockQuote
?: MenuItem
A menu item to wrap the selection in a block quote.
makeParagraph
?: MenuItem
A menu item to set the current textblock to be a normal
paragraph.
makeCodeBlock
?: MenuItem
A menu item to set the current textblock to be a
code block.
makeHead1
?: MenuItem
Menu items to set the current textblock to be a
heading of level N.
insertHorizontalRule
?: MenuItem
A menu item to insert a horizontal rule.
insertMenu
: Dropdown
A dropdown containing the insertImage
and
insertHorizontalRule
items.
typeMenu
: Dropdown
A dropdown containing the items for making the current
textblock a paragraph, code block, or heading.
blockMenu
: MenuElement[][]
Array of block-related menu items.
inlineMenu
: MenuElement[][]
Inline-markup related menu items.
fullMenu
: MenuElement[][]
An array of arrays of menu elements for use as the full menu
for, for example the menu
bar.
buildKeymap
(schema: Schema, mapKeys: Object) → Object
Inspect the given schema looking for marks and nodes from the
basic schema, and if found, add key bindings related to them.
This will add:
joinUp
joinDown
lift
selectParentNode
You can suppress or map these bindings by passing a mapKeys
argument, which maps key names (say "Mod-B"
to either false
, to
remove the binding, or a new key name string.
buildInputRules
(schema: Schema) → Plugin
A set of input rules for creating the basic block quotes, lists,
code blocks, and heading.
FAQs
An example for how to set up a ProseMirror editor
We found that prosemirror-example-setup demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.