How to use the @ckeditor/ckeditor5-engine/src/dev-utils/model.setData 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 / 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 / imageupload / imageuploadui.js View on Github external
it( 'should optimize the insertion position', () => {
		const button = editor.ui.componentFactory.create( 'imageUpload' );
		const files = [ createNativeFileMock() ];

		setModelData( model, 'f[]oo' );

		button.fire( 'done', files );

		const id = fileRepository.getLoader( files[ 0 ] ).id;

		expect( getModelData( model ) ).to.equal(
			`[<img>]` +
			'foo'
		);
	} );
github ckeditor / ckeditor5-image / tests / widget / widget.js View on Github external
it( 'should prevent default behaviour and stop event propagation', () =&gt; {
				const keydownHandler = sinon.spy();
				const domEventDataMock = {
					keyCode: keyCodes.delete,
					preventDefault: sinon.spy(),
				};
				setModelData( doc, 'foo[]' );
				viewDocument.on( 'keydown',  keydownHandler );

				viewDocument.fire( 'keydown', domEventDataMock );

				expect( getModelData( doc ) ).to.equal( 'foo[]' );
				sinon.assert.calledOnce( domEventDataMock.preventDefault );
				sinon.assert.notCalled( keydownHandler );
			} );
		} );
github ckeditor / ckeditor5-core / tests / command / toggleattributecommand.js View on Github external
it( 'collapsed selection in non-empty parent', () =&gt; {
				setData( modelDoc, '<p>x[]y</p>' );

				modelDoc.on( 'changesDone', spy );

				command.execute();

				expect( spy.calledOnce ).to.be.true;
			} );
github ckeditor / ckeditor5-image / tests / imagestyle / imagestyleediting.js View on Github external
it( 'should not convert from model to view if style is not present: remove attribute', () =&gt; {
			setModelData( model, '<img src="/assets/sample.png">' );
			const image = document.getRoot().getChild( 0 );

			model.change( writer =&gt; {
				writer.setAttribute( 'imageStyle', null, image );
			} );

			expect( editor.getData() ).to.equal( '<figure class="image"><img src="/assets/sample.png"></figure>' );
			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
				'<figure class="ck-widget image"><img src="/assets/sample.png"></figure>'
			);
		} );
	} );
github ckeditor / ckeditor5-image / tests / imagecaption / imagecaptionediting.js View on Github external
it( 'should not remove figcaption when selection is moved from it to other image', () =&gt; {
			setModelData( model, '<img src="">[foo bar]<img src="">' );
			const image = doc.getRoot().getChild( 1 );

			model.change( writer =&gt; {
				writer.setSelection( writer.createRangeOn( image ) );
			} );

			expect( getViewData( view ) ).to.equal(
				'<figure class="ck-widget image">' +
					'<img src="">' +
					'<figcaption data-placeholder="Enter image caption" class="ck-editor__editable ck-editor__nested-editable">foo bar</figcaption>' +
				'</figure>' +
				'[<figure class="ck-widget image">' +
					'<img src="">' +
					'<figcaption data-placeholder="Enter image caption" class="ck-editor__editable ck-editor__nested-editable ck-placeholder"></figcaption>' +</figure>
github ckeditor / ckeditor5-image / tests / imagestyle / imagestylecommand.js View on Github external
it( 'should match default style if no imageStyle attribute is present', () =&gt; {
		setData( model, '[<img>]' );

		expect( command.value ).to.equal( 'defaultStyle' );
	} );
github ckeditor / ckeditor5-image / tests / image / imageinsertcommand.js View on Github external
it( 'should be true when the selection directly in a paragraph', () =&gt; {
			setModelData( model, 'foo[]' );
			expect( command.isEnabled ).to.be.true;
		} );
github ckeditor / ckeditor5-core / tests / command / toggleattributecommand.js View on Github external
it( 'should return false if there are no nodes in selection that can have the attribute', () =&gt; {
				setData( modelDoc, '[foo]' );
				expect( command.isEnabled ).to.be.false;
			} );
		} );
github ckeditor / ckeditor5-table / tests / tablecolumnrowproperties.js View on Github external
beforeEach( () =&gt; {
				setModelData(
					model,
					'' +
					'' +
					'' +
					'foo' +
					'' +
					'<table></table>' +
					''
				);

				tableCell = model.document.getRoot().getNodeByPath( [ 0, 0, 0 ] );
			} );