mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 18:39:51 +02:00
Fix splitNode range updates when selection is backward (#2938)
This commit is contained in:
committed by
Ian Storm Taylor
parent
b6a99ce752
commit
0edcc89692
@@ -799,16 +799,16 @@ class Value extends Record(DEFAULTS) {
|
||||
|
||||
value = value.mapRanges(range => {
|
||||
const next = newDocument.getNextText(node.key)
|
||||
const { start, end } = range
|
||||
const { anchor, focus } = range
|
||||
|
||||
// If the start was after the split, move it to the next node.
|
||||
if (node.key === start.key && position <= start.offset) {
|
||||
range = range.moveStartTo(next.key, start.offset - position)
|
||||
// If the anchor was after the split, move it to the next node.
|
||||
if (node.key === anchor.key && position <= anchor.offset) {
|
||||
range = range.moveAnchorTo(next.key, anchor.offset - position)
|
||||
}
|
||||
|
||||
// If the end was after the split, move it to the next node.
|
||||
if (node.key === end.key && position <= end.offset) {
|
||||
range = range.moveEndTo(next.key, end.offset - position)
|
||||
// If the focus was after the split, move it to the next node.
|
||||
if (node.key === focus.key && position <= focus.offset) {
|
||||
range = range.moveFocusTo(next.key, focus.offset - position)
|
||||
}
|
||||
|
||||
range = range.updatePoints(point => point.setPath(null))
|
||||
|
@@ -0,0 +1,30 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
|
||||
export default function(editor) {
|
||||
editor.removeMark('bold')
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<b>
|
||||
wor<focus />d<anchor />
|
||||
</b>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<b>wor</b>
|
||||
<focus />d<anchor />
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
@@ -0,0 +1,30 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
|
||||
export default function(editor) {
|
||||
editor.removeMark('bold')
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<b>
|
||||
wor<anchor />d<focus />
|
||||
</b>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<b>wor</b>
|
||||
<anchor />d<focus />
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
Reference in New Issue
Block a user