mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 06:31:28 +02:00
Rewrite getFirstText to not use findDescendant
This commit is contained in:
@@ -955,7 +955,15 @@ const Node = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getFirstText() {
|
getFirstText() {
|
||||||
return this.findDescendantDeep(node => node.kind == 'text')
|
let descendantFound = null
|
||||||
|
|
||||||
|
const found = this.nodes.find((node) => {
|
||||||
|
if (node.kind == 'text') return true
|
||||||
|
descendantFound = node.getFirstText()
|
||||||
|
return descendantFound
|
||||||
|
})
|
||||||
|
|
||||||
|
return descendantFound || found
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user