How to use the @ckeditor/ckeditor5-engine/src/model/range function in @ckeditor/ckeditor5-engine

To help you get started, we’ve selected a few @ckeditor/ckeditor5-engine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-core / tests / command / toggleattributecommand.js View on Github external
modelDoc.enqueueChanges( () => {
				modelDoc.selection.setRanges( [ new Range( new Position( root, [ 1, 0 ] ), new Position( root, [ 1, 0 ] ) ) ] );
			} );
github ckeditor / ckeditor5-core / src / command / helpers / getschemavalidranges.js View on Github external
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;
}
github ckeditor / ckeditor5-core / src / command / helpers / getschemavalidranges.js View on Github external
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;
}