1
0
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:
Soreine
2016-11-02 12:29:07 +01:00
parent cb333a4882
commit ee29523789

View File

@@ -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
}, },
/** /**