( editor: Editor, rootElement: ModelElement, predicate: ( item: ModelElement ) => boolean = _ => true )
| 10 | * the root for which the provided predicate returns true. |
| 11 | */ |
| 12 | export const modelQueryElementsAll = ( |
| 13 | editor: Editor, |
| 14 | rootElement: ModelElement, |
| 15 | predicate: ( item: ModelElement ) => boolean = _ => true |
| 16 | ): Array<ModelElement> => { |
| 17 | const range = editor.model.createRangeIn( rootElement ); |
| 18 | const output: Array<ModelElement> = []; |
| 19 | |
| 20 | for ( const item of range.getItems() ) { |
| 21 | if ( !( item instanceof ModelElement ) ) { |
| 22 | continue; |
| 23 | } |
| 24 | |
| 25 | if ( predicate( item ) ) { |
| 26 | output.push( item ); |
| 27 | } |
| 28 | } |
| 29 | return output; |
| 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * Returns an array of all descendant text nodes and text proxies of |
no test coverage detected