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:
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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 })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user