prosemirror-utils
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "prosemirror-utils", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Utils library for ProseMirror", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -100,5 +100,4 @@ # Utils library for ProseMirror | ||
- **`safeInsert`**`(content: Fragment | Node | [Node]) → fn(tr: Transaction) → ?Transaction`\ | ||
Returns an `insert` transaction that inserts a given `content` at the current cursor position if its allowed. | ||
Otherwise it will try to find the appropriate place for such `content` in the document, looping through parent nodes up until the root document node. | ||
- **`safeInsert`**`(node: ProseMirrorNode) → fn(tr: Transaction) → ?Transaction`\ | ||
Returns an `insert` transaction that inserts a given `node` at the current cursor position if it is allowed by schema. If schema restricts such nesting, it will try to find the appropriate place for the given `node` in the document, looping through parent nodes up until the root document node. | ||
@@ -105,0 +104,0 @@ ## License |
@@ -58,5 +58,4 @@ import { findParentNodeOfType } from "./ancestors"; | ||
// :: (content: union<Fragment, Node, [Node]>) → (tr: Transaction) → ?Transaction | ||
// Returns an `insert` transaction that inserts a given `content` at the current cursor position if its allowed. | ||
// Otherwise it will try to find the appropriate place for such `content` in the document, looping through parent nodes up until the root document node. | ||
// :: (node: ProseMirrorNode) → (tr: Transaction) → ?Transaction | ||
// Returns an `insert` transaction that inserts a given `node` at the current cursor position if it is allowed by schema. If schema restricts such nesting, it will try to find the appropriate place for the given `node` in the document, looping through parent nodes up until the root document node. | ||
export const safeInsert = content => tr => { | ||
@@ -63,0 +62,0 @@ const { $from } = tr.curSelection; |
48387
924
106