prosemirror-schema-list
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -0,1 +1,7 @@ | ||
## 1.1.5 (2021-07-06) | ||
### Bug fixes | ||
Fix an issue where `splitListItem` would delete content when activated in a sublist that had content directly after it. | ||
## 1.1.4 (2020-08-11) | ||
@@ -2,0 +8,0 @@ |
@@ -135,11 +135,20 @@ import { findWrapping, ReplaceAroundStep, canSplit, liftTarget } from 'prosemirror-transform'; | ||
if (dispatch) { | ||
var wrap = Fragment.empty, keepItem = $from.index(-1) > 0; | ||
var wrap = Fragment.empty; | ||
var depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3; | ||
// Build a fragment containing empty versions of the structure | ||
// from the outer list item to the parent node of the cursor | ||
for (var d = $from.depth - (keepItem ? 1 : 2); d >= $from.depth - 3; d--) | ||
for (var d = $from.depth - depthBefore; d >= $from.depth - 3; d--) | ||
{ wrap = Fragment.from($from.node(d).copy(wrap)); } | ||
var depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 | ||
: $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3; | ||
// Add a second list item with an empty default start node | ||
wrap = wrap.append(Fragment.from(itemType.createAndFill())); | ||
var tr$1 = state.tr.replace($from.before(keepItem ? null : -1), $from.after(-3), new Slice(wrap, keepItem ? 3 : 2, 2)); | ||
tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve($from.pos + (keepItem ? 3 : 2)))); | ||
var start = $from.before($from.depth - (depthBefore - 1)); | ||
var tr$1 = state.tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0)); | ||
var sel = -1; | ||
tr$1.doc.nodesBetween(start, tr$1.doc.content.size, function (node, pos) { | ||
if (sel > -1) { return false } | ||
if (node.isTextblock && node.content.size == 0) { sel = pos + 1; } | ||
}); | ||
if (sel > -1) { tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve(sel))); } | ||
dispatch(tr$1.scrollIntoView()); | ||
@@ -146,0 +155,0 @@ } |
@@ -139,11 +139,20 @@ 'use strict'; | ||
if (dispatch) { | ||
var wrap = prosemirrorModel.Fragment.empty, keepItem = $from.index(-1) > 0; | ||
var wrap = prosemirrorModel.Fragment.empty; | ||
var depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3; | ||
// Build a fragment containing empty versions of the structure | ||
// from the outer list item to the parent node of the cursor | ||
for (var d = $from.depth - (keepItem ? 1 : 2); d >= $from.depth - 3; d--) | ||
for (var d = $from.depth - depthBefore; d >= $from.depth - 3; d--) | ||
{ wrap = prosemirrorModel.Fragment.from($from.node(d).copy(wrap)); } | ||
var depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 | ||
: $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3; | ||
// Add a second list item with an empty default start node | ||
wrap = wrap.append(prosemirrorModel.Fragment.from(itemType.createAndFill())); | ||
var tr$1 = state.tr.replace($from.before(keepItem ? null : -1), $from.after(-3), new prosemirrorModel.Slice(wrap, keepItem ? 3 : 2, 2)); | ||
tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve($from.pos + (keepItem ? 3 : 2)))); | ||
var start = $from.before($from.depth - (depthBefore - 1)); | ||
var tr$1 = state.tr.replace(start, $from.after(-depthAfter), new prosemirrorModel.Slice(wrap, 4 - depthBefore, 0)); | ||
var sel = -1; | ||
tr$1.doc.nodesBetween(start, tr$1.doc.content.size, function (node, pos) { | ||
if (sel > -1) { return false } | ||
if (node.isTextblock && node.content.size == 0) { sel = pos + 1; } | ||
}); | ||
if (sel > -1) { tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve(sel))); } | ||
dispatch(tr$1.scrollIntoView()); | ||
@@ -150,0 +159,0 @@ } |
{ | ||
"name": "prosemirror-schema-list", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "List-related schema elements and commands for ProseMirror", | ||
@@ -28,4 +28,4 @@ "main": "dist/index.js", | ||
"prosemirror-test-builder": "^1.0.0", | ||
"rollup": "^1.26.3", | ||
"@rollup/plugin-buble": "^0.20.0" | ||
"rollup": "^2.26.3", | ||
"@rollup/plugin-buble": "^0.21.3" | ||
}, | ||
@@ -32,0 +32,0 @@ "scripts": { |
@@ -13,3 +13,3 @@ module.exports = { | ||
plugins: [require('@rollup/plugin-buble')()], | ||
external(id) { return !/^[\.\/]/.test(id) } | ||
external(id) { return id[0] != "." && !require("path").isAbsolute(id) } | ||
} |
@@ -130,11 +130,20 @@ import {findWrapping, liftTarget, canSplit, ReplaceAroundStep} from "prosemirror-transform" | ||
if (dispatch) { | ||
let wrap = Fragment.empty, keepItem = $from.index(-1) > 0 | ||
let wrap = Fragment.empty | ||
let depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3 | ||
// Build a fragment containing empty versions of the structure | ||
// from the outer list item to the parent node of the cursor | ||
for (let d = $from.depth - (keepItem ? 1 : 2); d >= $from.depth - 3; d--) | ||
for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d--) | ||
wrap = Fragment.from($from.node(d).copy(wrap)) | ||
let depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 | ||
: $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3 | ||
// Add a second list item with an empty default start node | ||
wrap = wrap.append(Fragment.from(itemType.createAndFill())) | ||
let tr = state.tr.replace($from.before(keepItem ? null : -1), $from.after(-3), new Slice(wrap, keepItem ? 3 : 2, 2)) | ||
tr.setSelection(state.selection.constructor.near(tr.doc.resolve($from.pos + (keepItem ? 3 : 2)))) | ||
let start = $from.before($from.depth - (depthBefore - 1)) | ||
let tr = state.tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0)) | ||
let sel = -1 | ||
tr.doc.nodesBetween(start, tr.doc.content.size, (node, pos) => { | ||
if (sel > -1) return false | ||
if (node.isTextblock && node.content.size == 0) sel = pos + 1 | ||
}) | ||
if (sel > -1) tr.setSelection(state.selection.constructor.near(tr.doc.resolve(sel))) | ||
dispatch(tr.scrollIntoView()) | ||
@@ -141,0 +150,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
91872
714