1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 21:21:21 +02:00

Use getFirstText when fit

This commit is contained in:
Soreine
2016-11-10 11:09:47 +01:00
parent a319499f7c
commit 02d1531822
2 changed files with 3 additions and 5 deletions

View File

@@ -340,8 +340,7 @@ export function unwrapInlineByKey(transform, key, properties, options) {
const { state } = transform
const { document, selection } = state
const node = document.assertDescendant(key)
const texts = node.getTexts()
const range = selection.moveToRangeOf(texts.first(), texts.last())
const range = selection.moveToRangeOf(node.getFirstText(), node.getLastText())
return transform.unwrapInlineAtRange(range, properties, options)
}
@@ -360,8 +359,7 @@ export function unwrapBlockByKey(transform, key, properties, options) {
const { state } = transform
const { document, selection } = state
const node = document.assertDescendant(key)
const texts = node.getTexts()
const range = selection.moveToRangeOf(texts.first(), texts.last())
const range = selection.moveToRangeOf(node.getFirstText(), node.getLastText())
return transform.unwrapBlockAtRange(range, properties, options)
}

View File

@@ -273,7 +273,7 @@ export function normalizeSelection(transform) {
!document.hasDescendant(selection.focusKey)
) {
warning('Selection was invalid and reset to start of the document')
const firstText = document.getTexts().first()
const firstText = document.getFirstText()
selection = selection.merge({
anchorKey: firstText.key,
anchorOffset: 0,