How to use the @ckeditor/ckeditor5-engine/src/view/writer.insert 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-image / src / conversionutils / utils / elementtoelement.js View on Github external
}

		if ( !consumable.consume( modelElement, 'insert' ) ) {
			return;
		}

		const modelPosition = data.range.start;
		let viewPosition = conversionApi.mapper.toViewPosition( modelPosition );

		// When present - use options.insertPosition function to alter insertion position.
		if ( options.insertPosition ) {
			viewPosition = options.insertPosition( viewPosition );
		}

		conversionApi.mapper.bindElements( modelElement, viewElement );
		viewWriter.insert( viewPosition, viewElement );
	};
}
github ckeditor / ckeditor5-image / src / imagecaptioning / converters.js View on Github external
return ( evt, data, consumable, conversionApi ) => {
		const captionElement = data.item;

		if ( isImage( captionElement.parent ) && ( captionElement.childCount > 0 ) ) {
			if ( !consumable.consume( data.item, 'insert' ) ) {
				return;
			}

			const imageFigure = conversionApi.mapper.toViewElement( data.range.start.parent );
			const viewElement = ( elementCreator instanceof ViewElement ) ?
				elementCreator.clone( true ) :
				elementCreator( data, consumable, conversionApi );

			const viewPosition = ViewPosition.createAt( imageFigure, 'end' );
			conversionApi.mapper.bindElements( data.item, viewElement );
			viewWriter.insert( viewPosition, viewElement );
		}
	};
}
github ckeditor / ckeditor5-image / src / conversionutils / modelconversionutils.js View on Github external
return;
		}

		if ( !consumable.consume( modelElement, 'insert' ) ) {
			return;
		}

		const modelPosition = data.range.start;
		let viewPosition = conversionApi.mapper.toViewPosition( modelPosition );

		if ( options.insertPosition ) {
			viewPosition = options.insertPosition( viewPosition )
		}

		conversionApi.mapper.bindElements( modelElement, viewElement );
		viewWriter.insert( viewPosition, viewElement );
	};
}