prosemirror-schema-list
Advanced tools
Comparing version 1.2.3 to 1.3.0
@@ -0,1 +1,7 @@ | ||
## 1.3.0 (2023-06-01) | ||
### New features | ||
`splitListItem` now takes an optional second argument to set the attributes of the new list item node. Rename parameter | ||
## 1.2.3 (2023-05-17) | ||
@@ -2,0 +8,0 @@ |
@@ -46,3 +46,3 @@ import { NodeSpec, NodeType, Attrs } from 'prosemirror-model'; | ||
*/ | ||
declare function splitListItem(itemType: NodeType): Command; | ||
declare function splitListItem(itemType: NodeType, itemAttrs?: Attrs): Command; | ||
/** | ||
@@ -49,0 +49,0 @@ Create a command to lift the list item around the selection up into |
@@ -120,3 +120,3 @@ import { findWrapping, ReplaceAroundStep, canSplit, liftTarget, canJoin } from 'prosemirror-transform'; | ||
*/ | ||
function splitListItem(itemType) { | ||
function splitListItem(itemType, itemAttrs) { | ||
return function (state, dispatch) { | ||
@@ -164,3 +164,3 @@ let { $from, $to, node } = state.selection; | ||
let tr = state.tr.delete($from.pos, $to.pos); | ||
let types = nextType ? [null, { type: nextType }] : undefined; | ||
let types = nextType ? [itemAttrs ? { type: itemType, attrs: itemAttrs } : null, { type: nextType }] : undefined; | ||
if (!canSplit(tr.doc, $from.pos, 2, types)) | ||
@@ -167,0 +167,0 @@ return false; |
{ | ||
"name": "prosemirror-schema-list", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "List-related schema elements and commands for ProseMirror", | ||
@@ -28,3 +28,3 @@ "type": "module", | ||
"prosemirror-model": "^1.0.0", | ||
"prosemirror-transform": "^1.0.0", | ||
"prosemirror-transform": "^1.7.3", | ||
"prosemirror-state": "^1.0.0" | ||
@@ -31,0 +31,0 @@ }, |
@@ -114,3 +114,3 @@ import {findWrapping, liftTarget, canSplit, ReplaceAroundStep, canJoin} from "prosemirror-transform" | ||
/// of a list item by also splitting that list item. | ||
export function splitListItem(itemType: NodeType): Command { | ||
export function splitListItem(itemType: NodeType, itemAttrs?: Attrs): Command { | ||
return function(state: EditorState, dispatch?: (tr: Transaction) => void) { | ||
@@ -152,3 +152,3 @@ let {$from, $to, node} = state.selection as NodeSelection | ||
let tr = state.tr.delete($from.pos, $to.pos) | ||
let types = nextType ? [null, {type: nextType}] : undefined | ||
let types = nextType ? [itemAttrs ? {type: itemType, attrs: itemAttrs} : null, {type: nextType}] : undefined | ||
if (!canSplit(tr.doc, $from.pos, 2, types)) return false | ||
@@ -155,0 +155,0 @@ if (dispatch) dispatch(tr.split($from.pos, 2, types).scrollIntoView()) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49460
779
Updatedprosemirror-transform@^1.7.3