1
0
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:
Ian Storm Taylor
2017-10-14 15:36:27 -07:00
committed by GitHub
parent d4a58543b5
commit 6c42f6c9c3
95 changed files with 1938 additions and 1868 deletions

View File

@@ -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