How to use the @ckeditor/ckeditor5-utils/src/tomap function in @ckeditor/ckeditor5-utils

To help you get started, we’ve selected a few @ckeditor/ckeditor5-utils 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-engine / src / model / documentselection.js View on Github external
_updateAttributes( clearAll ) {
		const newAttributes = toMap( this._getSurroundingAttributes() );
		const oldAttributes = toMap( this.getAttributes() );

		if ( clearAll ) {
			// If `clearAll` remove all attributes and reset priorities.
			this._attributePriority = new Map();
			this._attrs = new Map();
		} else {
			// If not, remove only attributes added with `low` priority.
			for ( const [ key, priority ] of this._attributePriority ) {
				if ( priority == 'low' ) {
					this._attrs.delete( key );
					this._attributePriority.delete( key );
				}
			}
		}
github ckeditor / ckeditor5-engine / src / model / liveselection.js View on Github external
_updateAttributes( clearAll ) {
		const newAttributes = toMap( this._getSurroundingAttributes() );
		const oldAttributes = toMap( this.getAttributes() );

		if ( clearAll ) {
			// If `clearAll` remove all attributes and reset priorities.
			this._attributePriority = new Map();
			this._attrs = new Map();
		} else {
			// If not, remove only attributes added with `low` priority.
			for ( const [ key, priority ] of this._attributePriority ) {
				if ( priority == 'low' ) {
					this._attrs.delete( key );
					this._attributePriority.delete( key );
				}
			}
		}
github ckeditor / ckeditor5-engine / src / dev-utils / model.js View on Github external
// Convert view selection to model selection.

	if ( viewSelection ) {
		const ranges = [];

		// Convert ranges.
		for ( const viewRange of viewSelection.getRanges() ) {
			ranges.push( mapper.toModelRange( viewRange ) );
		}

		// Create new selection.
		selection = new ModelSelection( ranges, { backward: viewSelection.isBackward } );

		// Set attributes to selection if specified.
		for ( const [ key, value ] of toMap( options.selectionAttributes || [] ) ) {
			selection.setAttribute( key, value );
		}
	}

	// Return model end selection when selection was specified.
	if ( selection ) {
		return { model, selection };
	}

	// Otherwise return model only.
	return model;
}
github ckeditor / ckeditor5-engine / src / model / liveselection.js View on Github external
_updateAttributes( clearAll ) {
		const newAttributes = toMap( this._getSurroundingAttributes() );
		const oldAttributes = toMap( this.getAttributes() );

		if ( clearAll ) {
			// If `clearAll` remove all attributes and reset priorities.
			this._attributePriority = new Map();
			this._attrs = new Map();
		} else {
			// If not, remove only attributes added with `low` priority.
			for ( const [ key, priority ] of this._attributePriority ) {
				if ( priority == 'low' ) {
					this._attrs.delete( key );
					this._attributePriority.delete( key );
				}
			}
		}

		this._setAttributesTo( newAttributes );
github ckeditor / ckeditor5-engine / src / model / selection.js View on Github external
setAttributesTo( attrs ) {
		attrs = toMap( attrs );

		if ( !mapsEqual( attrs, this._attrs ) ) {
			// Create a set from keys of old and new attributes.
			const changed = new Set( Array.from( attrs.keys() ).concat( Array.from( this._attrs.keys() ) ) );

			for ( const [ key, value ] of attrs ) {
				// If the attribute remains unchanged, remove it from changed set.
				if ( this._attrs.get( key ) === value ) {
					changed.delete( key );
				}
			}

			this._attrs = attrs;

			this.fire( 'change:attribute', { attributeKeys: Array.from( changed ), directChange: true } );
		}
github ckeditor / ckeditor5-engine / src / model / writer.js View on Github external
setSelectionAttribute( keyOrObjectOrIterable, value ) {
		this._assertWriterUsedCorrectly();

		if ( typeof keyOrObjectOrIterable === 'string' ) {
			this._setSelectionAttribute( keyOrObjectOrIterable, value );
		} else {
			for ( const [ key, value ] of toMap( keyOrObjectOrIterable ) ) {
				this._setSelectionAttribute( key, value );
			}
		}
	}
github ckeditor / ckeditor5-engine / src / model / node.js View on Github external
_setAttributesTo( attrs ) {
		this._attrs = toMap( attrs );
	}