@atlaskit/editor-plugin-floating-toolbar
Version:
Floating toolbar plugin for @atlaskit/editor-core
16 lines • 359 B
JavaScript
// find node in descendants by condition
export function findNode(parent, predicate) {
let matchedNode;
parent.descendants(node => {
// dont run predicate if node already found
if (matchedNode) {
return false;
}
if (predicate(node)) {
matchedNode = node;
return false;
}
return true;
});
return matchedNode;
}