How to use the @ckeditor/ckeditor5-engine/src/model/document 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 / helpers / isattributeallowedinselection.js View on Github external
beforeEach( () => {
		document = new Document();
		document.createRoot();

		document.schema.registerItem( 'p', '$block' );
		document.schema.registerItem( 'h1', '$block' );
		document.schema.registerItem( 'img', '$inline' );

		// Bold text is allowed only in P.
		document.schema.allow( { name: '$text', attributes: 'bold', inside: 'p' } );
		document.schema.allow( { name: 'p', attributes: 'bold', inside: '$root' } );

		// Disallow bold on image.
		document.schema.disallow( { name: 'img', attributes: 'bold', inside: '$root' } );
	} );
github ckeditor / ckeditor5-core / tests / command / toggleattributecommand.js View on Github external
beforeEach( () => {
		editor = new Editor();
		editor.document = new Document();

		modelDoc = editor.document;
		root = modelDoc.createRoot();

		command = new ToggleAttributeCommand( editor, attrKey );

		modelDoc.schema.registerItem( 'p', '$block' );
		modelDoc.schema.registerItem( 'h1', '$block' );
		modelDoc.schema.registerItem( 'img', '$inline' );

		// Allow block in "root" (DIV)
		modelDoc.schema.allow( { name: '$block', inside: '$root' } );

		// Bold text is allowed only in P.
		modelDoc.schema.allow( { name: '$text', attributes: 'bold', inside: 'p' } );
		modelDoc.schema.allow( { name: 'p', attributes: 'bold', inside: '$root' } );
github ckeditor / ckeditor5-core / tests / command / toggleattributecommand.js View on Github external
it( 'should use provided batch for storing undo steps', () => {
			const batch = new Batch( new Document() );
			setData( modelDoc, '<p>a[bc&lt;$text bold="true"&gt;fo]obarxyz</p>' );

			expect( batch.deltas.length ).to.equal( 0 );

			command.execute( { batch } );

			expect( batch.deltas.length ).to.equal( 1 );
			expect( getData( modelDoc ) ).to.equal( '<p>a[&lt;$text bold="true"&gt;bcfo]obarxyz</p>' );
		} );
github ckeditor / ckeditor5-core / tests / command / helpers / getschemavalidranges.js View on Github external
beforeEach( () =&gt; {
		document = new Document();
		schema = document.schema;
		root = document.createRoot();

		schema.registerItem( 'p', '$block' );
		schema.registerItem( 'h1', '$block' );
		schema.registerItem( 'img', '$inline' );

		schema.allow( { name: '$text', attributes: 'bold', inside: 'p' } );
		schema.allow( { name: 'p', attributes: 'bold', inside: '$root' } );

		setData( document, '<p>foo<img>bar</p>' );
		ranges = [ Range.createOn( root.getChild( 0 ) ) ];
	} );