diff --git a/editcheck/modules/BaseEditCheck.js b/editcheck/modules/BaseEditCheck.js index cb472da79d..6e130e02dd 100644 --- a/editcheck/modules/BaseEditCheck.js +++ b/editcheck/modules/BaseEditCheck.js @@ -107,6 +107,26 @@ mw.editcheck.BaseEditCheck.prototype.getModifiedContentRanges = function ( docum return this.getModifiedRanges( documentModel, this.constructor.static.onlyCoveredNodes, true ); }; +/** + * Find nodes that were added during the edit session + * + * @param {ve.dm.Document} documentModel + * @param {string} [type] Type of nodes to find, or all nodes if false + * @return {ve.dm.Node[]} + */ +mw.editcheck.BaseEditCheck.prototype.getAddedNodes = function ( documentModel, type ) { + const matchedNodes = []; + this.getModifiedRanges( documentModel ).forEach( ( range ) => { + const nodes = documentModel.selectNodes( range, 'covered' ); + nodes.forEach( ( node ) => { + if ( !type || node.node.getType() === type ) { + matchedNodes.push( node.node ); + } + } ); + } ); + return matchedNodes; +}; + /** * Get content ranges which have been inserted *