mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 06:01:24 +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 { state } = transform
|
||||||
const { document, selection } = state
|
const { document, selection } = state
|
||||||
const node = document.assertDescendant(key)
|
const node = document.assertDescendant(key)
|
||||||
const texts = node.getTexts()
|
const range = selection.moveToRangeOf(node.getFirstText(), node.getLastText())
|
||||||
const range = selection.moveToRangeOf(texts.first(), texts.last())
|
|
||||||
return transform.unwrapInlineAtRange(range, properties, options)
|
return transform.unwrapInlineAtRange(range, properties, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,8 +359,7 @@ export function unwrapBlockByKey(transform, key, properties, options) {
|
|||||||
const { state } = transform
|
const { state } = transform
|
||||||
const { document, selection } = state
|
const { document, selection } = state
|
||||||
const node = document.assertDescendant(key)
|
const node = document.assertDescendant(key)
|
||||||
const texts = node.getTexts()
|
const range = selection.moveToRangeOf(node.getFirstText(), node.getLastText())
|
||||||
const range = selection.moveToRangeOf(texts.first(), texts.last())
|
|
||||||
return transform.unwrapBlockAtRange(range, properties, options)
|
return transform.unwrapBlockAtRange(range, properties, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -273,7 +273,7 @@ export function normalizeSelection(transform) {
|
|||||||
!document.hasDescendant(selection.focusKey)
|
!document.hasDescendant(selection.focusKey)
|
||||||
) {
|
) {
|
||||||
warning('Selection was invalid and reset to start of the document')
|
warning('Selection was invalid and reset to start of the document')
|
||||||
const firstText = document.getTexts().first()
|
const firstText = document.getFirstText()
|
||||||
selection = selection.merge({
|
selection = selection.merge({
|
||||||
anchorKey: firstText.key,
|
anchorKey: firstText.key,
|
||||||
anchorOffset: 0,
|
anchorOffset: 0,
|
||||||
|
Reference in New Issue
Block a user