mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-31 02:49:56 +02:00
more cleanup
This commit is contained in:
@@ -236,7 +236,7 @@ const Node = {
|
|||||||
|
|
||||||
getBlocksAtRange(range) {
|
getBlocksAtRange(range) {
|
||||||
range = range.normalize(this)
|
range = range.normalize(this)
|
||||||
const texts = this.getTextNodesAtRange(range)
|
const texts = this.getTextsAtRange(range)
|
||||||
const blocks = texts.map((text) => {
|
const blocks = texts.map((text) => {
|
||||||
return this.getClosest(text, p => p.kind == 'block')
|
return this.getClosest(text, p => p.kind == 'block')
|
||||||
})
|
})
|
||||||
@@ -253,7 +253,7 @@ const Node = {
|
|||||||
|
|
||||||
getCharactersAtRange(range) {
|
getCharactersAtRange(range) {
|
||||||
range = range.normalize(this)
|
range = range.normalize(this)
|
||||||
const texts = this.getTextNodesAtRange(range)
|
const texts = this.getTextsAtRange(range)
|
||||||
let list = new List()
|
let list = new List()
|
||||||
|
|
||||||
texts.forEach((text) => {
|
texts.forEach((text) => {
|
||||||
@@ -339,7 +339,7 @@ const Node = {
|
|||||||
getInlinesAtRange(range) {
|
getInlinesAtRange(range) {
|
||||||
range = range.normalize(this)
|
range = range.normalize(this)
|
||||||
const node = this
|
const node = this
|
||||||
const texts = node.getTextNodesAtRange(range)
|
const texts = node.getTextsAtRange(range)
|
||||||
const inlines = texts
|
const inlines = texts
|
||||||
.map(text => node.getClosest(text, p => p.kind == 'inline'))
|
.map(text => node.getClosest(text, p => p.kind == 'inline'))
|
||||||
.filter(inline => inline)
|
.filter(inline => inline)
|
||||||
@@ -567,7 +567,7 @@ const Node = {
|
|||||||
* @return {OrderedMap} nodes
|
* @return {OrderedMap} nodes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getTextNodesAtRange(range) {
|
getTextsAtRange(range) {
|
||||||
range = range.normalize(this)
|
range = range.normalize(this)
|
||||||
const { startKey, endKey } = range
|
const { startKey, endKey } = range
|
||||||
|
|
||||||
@@ -672,7 +672,7 @@ const Node = {
|
|||||||
|
|
||||||
// Otherwise, find each of the text nodes within the range.
|
// Otherwise, find each of the text nodes within the range.
|
||||||
const { startKey, startOffset, endKey, endOffset } = range
|
const { startKey, startOffset, endKey, endOffset } = range
|
||||||
let texts = node.getTextNodesAtRange(range)
|
let texts = node.getTextsAtRange(range)
|
||||||
|
|
||||||
// Apply the mark to each of the text nodes's matching characters.
|
// Apply the mark to each of the text nodes's matching characters.
|
||||||
texts = texts.map((text) => {
|
texts = texts.map((text) => {
|
||||||
@@ -921,7 +921,7 @@ const Node = {
|
|||||||
if (range.isCollapsed) return node
|
if (range.isCollapsed) return node
|
||||||
|
|
||||||
// Otherwise, find each of the text nodes within the range.
|
// Otherwise, find each of the text nodes within the range.
|
||||||
let texts = node.getTextNodesAtRange(range)
|
let texts = node.getTextsAtRange(range)
|
||||||
|
|
||||||
// Apply the mark to each of the text nodes's matching characters.
|
// Apply the mark to each of the text nodes's matching characters.
|
||||||
texts = texts.map((text) => {
|
texts = texts.map((text) => {
|
||||||
@@ -1228,7 +1228,7 @@ const Node = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Get the furthest inline nodes in the range.
|
// Get the furthest inline nodes in the range.
|
||||||
const texts = node.getTextNodesAtRange(range)
|
const texts = node.getTextsAtRange(range)
|
||||||
const children = texts.map(text => node.getFurthestInline(text) || text)
|
const children = texts.map(text => node.getFurthestInline(text) || text)
|
||||||
|
|
||||||
// Iterate each of the child nodes, wrapping them.
|
// Iterate each of the child nodes, wrapping them.
|
||||||
|
@@ -47,8 +47,6 @@ class Selection extends SelectionRecord {
|
|||||||
/**
|
/**
|
||||||
* Get whether the selection is expanded.
|
* Get whether the selection is expanded.
|
||||||
*
|
*
|
||||||
* Aliased as `isExtended` since browser implementations refer to it as both.
|
|
||||||
*
|
|
||||||
* @return {Boolean} isExpanded
|
* @return {Boolean} isExpanded
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -56,10 +54,6 @@ class Selection extends SelectionRecord {
|
|||||||
return ! this.isCollapsed
|
return ! this.isCollapsed
|
||||||
}
|
}
|
||||||
|
|
||||||
get isExtended() {
|
|
||||||
return this.isExpanded
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether the range's anchor of focus keys are not set yet.
|
* Get whether the range's anchor of focus keys are not set yet.
|
||||||
*
|
*
|
||||||
@@ -184,17 +178,6 @@ class Selection extends SelectionRecord {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Move the selection to a set of `properties`.
|
|
||||||
*
|
|
||||||
* @param {Object} properties
|
|
||||||
* @return {State} state
|
|
||||||
*/
|
|
||||||
|
|
||||||
moveTo(properties) {
|
|
||||||
return this.merge(properties)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the focus point to the anchor point.
|
* Move the focus point to the anchor point.
|
||||||
*
|
*
|
||||||
@@ -204,7 +187,8 @@ class Selection extends SelectionRecord {
|
|||||||
moveToAnchor() {
|
moveToAnchor() {
|
||||||
return this.merge({
|
return this.merge({
|
||||||
focusKey: this.anchorKey,
|
focusKey: this.anchorKey,
|
||||||
focusOffset: this.anchorOffset
|
focusOffset: this.anchorOffset,
|
||||||
|
isBackward: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +201,8 @@ class Selection extends SelectionRecord {
|
|||||||
moveToFocus() {
|
moveToFocus() {
|
||||||
return this.merge({
|
return this.merge({
|
||||||
anchorKey: this.focusKey,
|
anchorKey: this.focusKey,
|
||||||
anchorOffset: this.focusOffset
|
anchorOffset: this.focusOffset,
|
||||||
|
isBackward: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,6 +81,26 @@ class State extends Record(DEFAULTS) {
|
|||||||
return this.selection.isExpanded
|
return this.selection.isExpanded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the current selection backward?
|
||||||
|
*
|
||||||
|
* @return {Boolean} isBackward
|
||||||
|
*/
|
||||||
|
|
||||||
|
get isCurrentlyBackward() {
|
||||||
|
return this.selection.isBackward
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the current selection forward?
|
||||||
|
*
|
||||||
|
* @return {Boolean} isForward
|
||||||
|
*/
|
||||||
|
|
||||||
|
get isCurrentlyForward() {
|
||||||
|
return this.selection.isForward
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current start key.
|
* Get the current start key.
|
||||||
*
|
*
|
||||||
@@ -121,6 +141,46 @@ class State extends Record(DEFAULTS) {
|
|||||||
return this.selection.endOffset
|
return this.selection.endOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current anchor key.
|
||||||
|
*
|
||||||
|
* @return {String} anchorKey
|
||||||
|
*/
|
||||||
|
|
||||||
|
get currentAnchorKey() {
|
||||||
|
return this.selection.anchorKey
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current focus key.
|
||||||
|
*
|
||||||
|
* @return {String} focusKey
|
||||||
|
*/
|
||||||
|
|
||||||
|
get currentFocusKey() {
|
||||||
|
return this.selection.focusKey
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current anchor offset.
|
||||||
|
*
|
||||||
|
* @return {String} anchorOffset
|
||||||
|
*/
|
||||||
|
|
||||||
|
get currentAnchorOffset() {
|
||||||
|
return this.selection.anchorOffset
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current focus offset.
|
||||||
|
*
|
||||||
|
* @return {String} focusOffset
|
||||||
|
*/
|
||||||
|
|
||||||
|
get currentFocusOffset() {
|
||||||
|
return this.selection.focusOffset
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the characters in the current selection.
|
* Get the characters in the current selection.
|
||||||
*
|
*
|
||||||
@@ -147,7 +207,7 @@ class State extends Record(DEFAULTS) {
|
|||||||
* @return {OrderedMap} nodes
|
* @return {OrderedMap} nodes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get currentBlockNodes() {
|
get currentBlocks() {
|
||||||
return this.document.getBlocksAtRange(this.selection)
|
return this.document.getBlocksAtRange(this.selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +217,7 @@ class State extends Record(DEFAULTS) {
|
|||||||
* @return {OrderedMap} nodes
|
* @return {OrderedMap} nodes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get currentInlineNodes() {
|
get currentInlines() {
|
||||||
return this.document.getInlinesAtRange(this.selection)
|
return this.document.getInlinesAtRange(this.selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +227,8 @@ class State extends Record(DEFAULTS) {
|
|||||||
* @return {OrderedMap} nodes
|
* @return {OrderedMap} nodes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get currentTextNodes() {
|
get currentTexts() {
|
||||||
return this.document.getTextNodesAtRange(this.selection)
|
return this.document.getTextsAtRange(this.selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user