How to use @ckeditor/ckeditor5-engine - 10 common examples

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 / tests / imageupload / imageuploadcommand.js View on Github external
it( 'should be false when schema disallows image', () => {
			model.schema.register( 'block', { inheritAllFrom: '$block' } );
			model.schema.extend( 'paragraph', { allowIn: 'block' } );
			// Block image in block.
			model.schema.addChildCheck( ( context, childDefinition ) => {
				if ( childDefinition.name === 'image' && context.last.name === 'block' ) {
					return false;
				}
			} );
			editor.conversion.for( 'downcast' ).elementToElement( { model: 'block', view: 'block' } );

			setModelData( model, '[]' );

			expect( command.isEnabled ).to.be.false;
		} );
	} );
github ckeditor / ckeditor5-image / tests / imagecaption / utils.js View on Github external
it( 'should return null if figcaption\'s parent is not a figure', () => {
			const element = new ViewElement( 'figcaption' );
			new ViewElement( 'div', null, element ); // eslint-disable-line no-new

			expect( matchImageCaption( element ) ).to.be.null;
		} );
github ckeditor / ckeditor5-image / tests / imagecaption / utils.js View on Github external
it( 'should return null if figcaption\'s parent is not a figure', () => {
			const element = new ViewElement( 'figcaption' );
			new ViewElement( 'div', null, element ); // eslint-disable-line no-new

			expect( matchImageCaption( element ) ).to.be.null;
		} );
github ckeditor / ckeditor5-image / tests / imagecaption / utils.js View on Github external
it( 'should return null if parent has no image class', () => {
			const element = new ViewElement( 'figcaption' );
			new ViewElement( 'figure', null, element ); // eslint-disable-line no-new

			expect( matchImageCaption( element ) ).to.be.null;
		} );
github ckeditor / ckeditor5-image / tests / image / imageloadobserver.js View on Github external
it( 'should do nothing with an image when changes are in the other parent', () => {
		setData(
			view,
			'foo<img src="/assets/sample.png">'
		);

		const viewP = viewRoot.getChild( 0 );
		const viewDiv = viewRoot.getChild( 1 );

		const mapSpy = sinon.spy( view.domConverter, 'mapViewToDom' );

		// Change only the paragraph.
		view.change( writer =&gt; {
			const text = writer.createText( 'foo', { b: true } );

			writer.insert( writer.createPositionAt( viewRoot.getChild( 0 ).getChild( 0 ), 0 ), text );
			writer.wrap( writer.createRangeOn( text ), writer.createAttributeElement( 'b' ) );
		} );
github ckeditor / ckeditor5-image / tests / image / utils.js View on Github external
it( 'should return true when image widget is the only element in the selection', () => {
			// We need to create a container for the element to be able to create a Range on this element.
			frag = new ViewDocumentFragment( [ element ] );

			const selection = writer.createSelection( element, 'on' );

			expect( getSelectedImageWidget( selection ) ).to.equal( element );
		} );
github ckeditor / ckeditor5-media-embed / tests / mediaembedediting.js View on Github external
function testMediaUpcast( urls, expected ) {
		for ( const url of urls ) {
			editor.setData( `<figure class="media"><div data-oembed-url="${ url }"></div></figure>` );

			const viewData = getViewData( view, { withoutSelection: true, renderUIElements: true } );
			let expectedRegExp;

			const expectedUrl = url.match( /^https?:\/\// ) ? url : 'https://' + url;

			if ( expected ) {
				expectedRegExp = new RegExp(
					']+&gt;' +
						']+&gt;' +
							normalizeHtml( expected ) +
						'' +
					'' );
			} else {
				expectedRegExp = new RegExp(
					']+&gt;' +
						']+&gt;' +
							'<div class="ck ck-media__placeholder ck-reset_all">' +</div>
github ckeditor / ckeditor5-core / tests / editor / utils / attachtoform.js View on Github external
form = document.createElement( 'form' );
		textarea = document.createElement( 'textarea' );
		form.appendChild( textarea );
		document.body.appendChild( form );
		submitStub = sinon.stub( form, 'submit' );

		// Prevents page realods in Firefox ;|
		form.addEventListener( 'submit', evt => {
			evt.preventDefault();
		} );

		class CustomEditor extends Editor {}
		mix( CustomEditor, ElementApiMixin );

		editor = new CustomEditor();
		editor.data.processor = new HtmlDataProcessor();
		editor.model.document.createRoot();
		editor.model.schema.extend( '$text', { allowIn: '$root' } );
		editor.fire( 'ready' );

		editor.data.set( 'foo bar' );
	} );
github ckeditor / ckeditor5-core / tests / _utils / classictesteditor.js View on Github external
constructor( sourceElementOrData, config ) {
		super( config );

		if ( isElement( sourceElementOrData ) ) {
			this.sourceElement = sourceElementOrData;
		}

		// Use the HTML data processor in this editor.
		this.data.processor = new HtmlDataProcessor();

		// Create the ("main") root element of the model tree.
		this.model.document.createRoot();

		this.ui = new ClassicTestEditorUI( this, new BoxedEditorUIView( this.locale ) );

		// Expose properties normally exposed by the ClassicEditorUI.
		this.ui.view.editable = new InlineEditableUIView( this.ui.view.locale, this.editing.view );
	}
github ckeditor / ckeditor5-core / tests / _utils / virtualtesteditor.js View on Github external
constructor( config ) {
		super( config );

		// Use the HTML data processor in this editor.
		this.data.processor = new HtmlDataProcessor();

		// Create the ("main") root element of the model tree.
		this.model.document.createRoot();
	}