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