mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-08 08:16:30 +02:00
Rename Range
to Leaf
, and Selection
to Range
(#1231)
* rename Range to Leaf * rename Selection to Range * add findDOMRange, findNode, findRange helpers * refactor to remove findDropPoint util * revert findDOMNode to throwing errors * export new helpers, fix linter * update docs * update examples
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
Inline,
|
||||
Mark,
|
||||
Node,
|
||||
Selection,
|
||||
Range,
|
||||
State,
|
||||
Text
|
||||
} from 'slate'
|
||||
@@ -71,13 +71,13 @@ const CREATORS = {
|
||||
},
|
||||
|
||||
selection(tagName, attributes, children) {
|
||||
return Selection.create(attributes)
|
||||
return Range.create(attributes)
|
||||
},
|
||||
|
||||
state(tagName, attributes, children) {
|
||||
const { data } = attributes
|
||||
const document = children.find(Document.isDocument)
|
||||
let selection = children.find(Selection.isSelection) || Selection.create()
|
||||
let selection = children.find(Range.isRange) || Range.create()
|
||||
const props = {}
|
||||
|
||||
// Search the document's texts to see if any of them have the anchor or
|
||||
@@ -211,11 +211,11 @@ function createChildren(children, options = {}) {
|
||||
setNode(node.set('key', child.key))
|
||||
}
|
||||
|
||||
child.getRanges().forEach((range) => {
|
||||
let { marks } = range
|
||||
child.getLeaves().forEach((leaf) => {
|
||||
let { marks } = leaf
|
||||
if (options.marks) marks = marks.union(options.marks)
|
||||
setNode(node.insertText(i, range.text, marks))
|
||||
i += range.text.length
|
||||
setNode(node.insertText(i, leaf.text, marks))
|
||||
i += leaf.text.length
|
||||
})
|
||||
|
||||
if (__anchor != null) node.__anchor = __anchor + length
|
||||
|
Reference in New Issue
Block a user