mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-01 03:11:44 +02:00
bleh, revert some stuff
This commit is contained in:
@@ -63,12 +63,9 @@ const Node = {
|
|||||||
|
|
||||||
// If the start and end nodes are the same, just remove characters.
|
// If the start and end nodes are the same, just remove characters.
|
||||||
if (startKey == endKey) {
|
if (startKey == endKey) {
|
||||||
const startNode = node.getDescendant(startKey)
|
let text = node.getDescendant(startKey)
|
||||||
const characters = startNode.characters.filterNot((char, i) => {
|
text = text.removeCharacters(startOffset, endOffset)
|
||||||
return startOffset <= i && i < endOffset
|
node = node.updateDescendant(text)
|
||||||
})
|
|
||||||
|
|
||||||
node = node.updateDescendant(startNode.merge({ characters }))
|
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ class Text extends Record(DEFAULTS) {
|
|||||||
* Create a new `Text` with `properties`.
|
* Create a new `Text` with `properties`.
|
||||||
*
|
*
|
||||||
* @param {Object} properties
|
* @param {Object} properties
|
||||||
* @return {Node} node
|
* @return {Text} text
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static create(properties = {}) {
|
static create(properties = {}) {
|
||||||
@@ -64,6 +64,24 @@ class Text extends Record(DEFAULTS) {
|
|||||||
.join('')
|
.join('')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove characters from the text node from `start` to `end`.
|
||||||
|
*
|
||||||
|
* @param {Number} start
|
||||||
|
* @param {Number} end
|
||||||
|
* @return {Text} text
|
||||||
|
*/
|
||||||
|
|
||||||
|
removeCharacters(start, end) {
|
||||||
|
let { characters } = this
|
||||||
|
|
||||||
|
characters = characters.filterNot((char, i) => {
|
||||||
|
return start <= i && i < end
|
||||||
|
})
|
||||||
|
|
||||||
|
return this.merge({ characters })
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user