1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 10:51:44 +02:00

bleh, revert some stuff

This commit is contained in:
Ian Storm Taylor
2016-06-23 23:04:21 -07:00
parent 2b32e0269c
commit a4c8e8fab5
2 changed files with 22 additions and 7 deletions

View File

@@ -63,12 +63,9 @@ const Node = {
// If the start and end nodes are the same, just remove characters.
if (startKey == endKey) {
const startNode = node.getDescendant(startKey)
const characters = startNode.characters.filterNot((char, i) => {
return startOffset <= i && i < endOffset
})
node = node.updateDescendant(startNode.merge({ characters }))
let text = node.getDescendant(startKey)
text = text.removeCharacters(startOffset, endOffset)
node = node.updateDescendant(text)
return node
}

View File

@@ -22,7 +22,7 @@ class Text extends Record(DEFAULTS) {
* Create a new `Text` with `properties`.
*
* @param {Object} properties
* @return {Node} node
* @return {Text} text
*/
static create(properties = {}) {
@@ -64,6 +64,24 @@ class Text extends Record(DEFAULTS) {
.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 })
}
}
/**