prosemirror-commands
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -0,1 +1,7 @@ | ||
## 1.2.1 (2022-01-20) | ||
### Bug fixes | ||
Fix an issue where `joinBackward` and `joinForward` would return true when activated with the cursor in an empty but undeletable block, but not make any change. | ||
## 1.2.0 (2022-01-17) | ||
@@ -2,0 +8,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { liftTarget, canJoin, joinPoint, canSplit, ReplaceAroundStep, findWrapping } from 'prosemirror-transform'; | ||
import { Fragment, Slice } from 'prosemirror-model'; | ||
import { liftTarget, replaceStep, canJoin, joinPoint, canSplit, ReplaceAroundStep, findWrapping } from 'prosemirror-transform'; | ||
import { Slice, Fragment } from 'prosemirror-model'; | ||
import { NodeSelection, Selection, AllSelection, TextSelection } from 'prosemirror-state'; | ||
@@ -47,9 +47,12 @@ | ||
(textblockAt(before, "end") || NodeSelection.isSelectable(before))) { | ||
if (dispatch) { | ||
var tr = state.tr.deleteRange($cursor.before(), $cursor.after()); | ||
tr.setSelection(textblockAt(before, "end") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) | ||
: NodeSelection.create(tr.doc, $cut.pos - before.nodeSize)); | ||
dispatch(tr.scrollIntoView()); | ||
var delStep = replaceStep(state.doc, $cursor.before(), $cursor.after(), Slice.empty); | ||
if (delStep.slice.size < delStep.to - delStep.from) { | ||
if (dispatch) { | ||
var tr = state.tr.step(delStep); | ||
tr.setSelection(textblockAt(before, "end") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) | ||
: NodeSelection.create(tr.doc, $cut.pos - before.nodeSize)); | ||
dispatch(tr.scrollIntoView()); | ||
} | ||
return true | ||
} | ||
return true | ||
} | ||
@@ -133,9 +136,12 @@ | ||
(textblockAt(after, "start") || NodeSelection.isSelectable(after))) { | ||
if (dispatch) { | ||
var tr = state.tr.deleteRange($cursor.before(), $cursor.after()); | ||
tr.setSelection(textblockAt(after, "start") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) | ||
: NodeSelection.create(tr.doc, tr.mapping.map($cut.pos))); | ||
dispatch(tr.scrollIntoView()); | ||
var delStep = replaceStep(state.doc, $cursor.before(), $cursor.after(), Slice.empty); | ||
if (delStep.slice.size < delStep.to - delStep.from) { | ||
if (dispatch) { | ||
var tr = state.tr.step(delStep); | ||
tr.setSelection(textblockAt(after, "start") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) | ||
: NodeSelection.create(tr.doc, tr.mapping.map($cut.pos))); | ||
dispatch(tr.scrollIntoView()); | ||
} | ||
return true | ||
} | ||
return true | ||
} | ||
@@ -142,0 +148,0 @@ |
@@ -51,9 +51,12 @@ 'use strict'; | ||
(textblockAt(before, "end") || prosemirrorState.NodeSelection.isSelectable(before))) { | ||
if (dispatch) { | ||
var tr = state.tr.deleteRange($cursor.before(), $cursor.after()); | ||
tr.setSelection(textblockAt(before, "end") ? prosemirrorState.Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) | ||
: prosemirrorState.NodeSelection.create(tr.doc, $cut.pos - before.nodeSize)); | ||
dispatch(tr.scrollIntoView()); | ||
var delStep = prosemirrorTransform.replaceStep(state.doc, $cursor.before(), $cursor.after(), prosemirrorModel.Slice.empty); | ||
if (delStep.slice.size < delStep.to - delStep.from) { | ||
if (dispatch) { | ||
var tr = state.tr.step(delStep); | ||
tr.setSelection(textblockAt(before, "end") ? prosemirrorState.Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) | ||
: prosemirrorState.NodeSelection.create(tr.doc, $cut.pos - before.nodeSize)); | ||
dispatch(tr.scrollIntoView()); | ||
} | ||
return true | ||
} | ||
return true | ||
} | ||
@@ -137,9 +140,12 @@ | ||
(textblockAt(after, "start") || prosemirrorState.NodeSelection.isSelectable(after))) { | ||
if (dispatch) { | ||
var tr = state.tr.deleteRange($cursor.before(), $cursor.after()); | ||
tr.setSelection(textblockAt(after, "start") ? prosemirrorState.Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) | ||
: prosemirrorState.NodeSelection.create(tr.doc, tr.mapping.map($cut.pos))); | ||
dispatch(tr.scrollIntoView()); | ||
var delStep = prosemirrorTransform.replaceStep(state.doc, $cursor.before(), $cursor.after(), prosemirrorModel.Slice.empty); | ||
if (delStep.slice.size < delStep.to - delStep.from) { | ||
if (dispatch) { | ||
var tr = state.tr.step(delStep); | ||
tr.setSelection(textblockAt(after, "start") ? prosemirrorState.Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) | ||
: prosemirrorState.NodeSelection.create(tr.doc, tr.mapping.map($cut.pos))); | ||
dispatch(tr.scrollIntoView()); | ||
} | ||
return true | ||
} | ||
return true | ||
} | ||
@@ -146,0 +152,0 @@ |
{ | ||
"name": "prosemirror-commands", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Editing commands for ProseMirror", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,2 +0,2 @@ | ||
import {joinPoint, canJoin, findWrapping, liftTarget, canSplit, ReplaceAroundStep} from "prosemirror-transform" | ||
import {joinPoint, canJoin, findWrapping, liftTarget, canSplit, ReplaceAroundStep, replaceStep} from "prosemirror-transform" | ||
import {Slice, Fragment} from "prosemirror-model" | ||
@@ -46,9 +46,12 @@ import {Selection, TextSelection, NodeSelection, AllSelection} from "prosemirror-state" | ||
(textblockAt(before, "end") || NodeSelection.isSelectable(before))) { | ||
if (dispatch) { | ||
let tr = state.tr.deleteRange($cursor.before(), $cursor.after()) | ||
tr.setSelection(textblockAt(before, "end") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) | ||
: NodeSelection.create(tr.doc, $cut.pos - before.nodeSize)) | ||
dispatch(tr.scrollIntoView()) | ||
let delStep = replaceStep(state.doc, $cursor.before(), $cursor.after(), Slice.empty) | ||
if (delStep.slice.size < delStep.to - delStep.from) { | ||
if (dispatch) { | ||
let tr = state.tr.step(delStep) | ||
tr.setSelection(textblockAt(before, "end") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) | ||
: NodeSelection.create(tr.doc, $cut.pos - before.nodeSize)) | ||
dispatch(tr.scrollIntoView()) | ||
} | ||
return true | ||
} | ||
return true | ||
} | ||
@@ -128,9 +131,12 @@ | ||
(textblockAt(after, "start") || NodeSelection.isSelectable(after))) { | ||
if (dispatch) { | ||
let tr = state.tr.deleteRange($cursor.before(), $cursor.after()) | ||
tr.setSelection(textblockAt(after, "start") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) | ||
: NodeSelection.create(tr.doc, tr.mapping.map($cut.pos))) | ||
dispatch(tr.scrollIntoView()) | ||
let delStep = replaceStep(state.doc, $cursor.before(), $cursor.after(), Slice.empty) | ||
if (delStep.slice.size < delStep.to - delStep.from) { | ||
if (dispatch) { | ||
let tr = state.tr.step(delStep) | ||
tr.setSelection(textblockAt(after, "start") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) | ||
: NodeSelection.create(tr.doc, tr.mapping.map($cut.pos))) | ||
dispatch(tr.scrollIntoView()) | ||
} | ||
return true | ||
} | ||
return true | ||
} | ||
@@ -137,0 +143,0 @@ |
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
215257
1978