Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
modelDoc.enqueueChanges( () => {
modelDoc.selection.setRanges( [ new Range( new Position( root, [ 1, 0 ] ), new Position( root, [ 1, 0 ] ) ) ] );
} );
for ( const range of ranges ) {
const walker = new TreeWalker( { boundaries: range, mergeCharacters: true } );
let step = walker.next();
let last = range.start;
let from = range.start;
const to = range.end;
while ( !step.done ) {
const name = step.value.item.name || '$text';
const itemPosition = Position.createBefore( step.value.item );
if ( !schema.check( { name, inside: itemPosition, attributes: attribute } ) ) {
if ( !from.isEqual( last ) ) {
validRanges.push( new Range( from, last ) );
}
from = walker.position;
}
last = walker.position;
step = walker.next();
}
if ( from && !from.isEqual( to ) ) {
validRanges.push( new Range( from, to ) );
}
}
return validRanges;
}
const itemPosition = Position.createBefore( step.value.item );
if ( !schema.check( { name, inside: itemPosition, attributes: attribute } ) ) {
if ( !from.isEqual( last ) ) {
validRanges.push( new Range( from, last ) );
}
from = walker.position;
}
last = walker.position;
step = walker.next();
}
if ( from && !from.isEqual( to ) ) {
validRanges.push( new Range( from, to ) );
}
}
return validRanges;
}