Exemplo n.º 1
0
	beforeEach( () => {
		listenter = Object.create( EmitterMixin );

		const domElement = document.createElement( 'div' );
		document.body.appendChild( domElement );

		return ClassicTestEditor.create( domElement, { plugins: [ Input, Paragraph, Bold, Italic, List, ShiftEnter, Link ] } )
			.then( newEditor => {
				// Mock image feature.
				newEditor.model.schema.register( 'image', { allowWhere: '$text' } );

				newEditor.conversion.elementToElement( {
					model: 'image',
					view: 'img'
				} );

				editor = newEditor;
				model = editor.model;
				modelRoot = model.document.getRoot();
				view = editor.editing.view;
				viewDocument = view.document;
				viewRoot = viewDocument.getRoot();

				editor.setData( '<p>foobar</p>' );

				model.change( writer => {
					writer.setSelection( modelRoot.getChild( 0 ), 3 );
				} );
			} );
	} );
Exemplo n.º 2
0
	beforeEach( () => {
		domElement = document.createElement( 'div' );
		document.body.appendChild( domElement );

		return ClassicTestEditor.create( domElement, { plugins: [ Input, Paragraph, Bold, Italic, LinkEditing ] } )
			.then( newEditor => {
				editor = newEditor;
				model = editor.model;
				view = editor.editing.view;
				viewDocument = view.document;
				viewRoot = viewDocument.getRoot();
				domRoot = view.getDomRoot();

				// Mock image feature.
				newEditor.model.schema.register( 'image', { allowWhere: '$text' } );

				editor.conversion.for( 'downcast' ).elementToElement( {
					model: 'image',
					view: 'img'
				} );

				editor.conversion.for( 'upcast' ).elementToElement( {
					view: 'img',
					model: 'image'
				} );

				// Disable MO completely and in a way it won't be reenabled on some Document#render() call.
				const mutationObserver = view.getObserver( MutationObserver );

				mutationObserver.disable();
				mutationObserver.enable = () => {};
			} );
	} );
	beforeEach( () => {
		editorElement = document.createElement( 'div' );
		document.body.appendChild( editorElement );

		return ClassicTestEditor
			.create( editorElement, {
				plugins: [ Typing, Paragraph, Bold ]
			} )
			.then( newEditor => {
				editor = newEditor;
				domRoot = editor.editing.view.getDomRoot();
				mutationObserver = editor.editing.view.getObserver( MutationObserver );
			} );
	} );
	beforeEach( () => {
		const editorElement = document.createElement( 'div' );
		document.body.appendChild( editorElement );

		return ClassicTestEditor
			.create( editorElement, {
				plugins: [ Paragraph, SubscriptEditing, SubscriptUI ]
			} )
			.then( newEditor => {
				editor = newEditor;

				subView = editor.ui.componentFactory.create( 'subscript' );
			} );
	} );
		beforeEach( () => {
			editorElement = document.createElement( 'div' );
			document.body.appendChild( editorElement );

			return ClassicTestEditor
				.create( editorElement, {
					plugins: [ Paragraph, ParagraphButtonUI, Heading ],
					toolbar: [ 'paragraph' ]
				} )
				.then( newEditor => {
					editor = newEditor;
					setData( editor.model, '<paragraph>f{}oo</paragraph>' );
				} );
		} );
Exemplo n.º 6
0
	beforeEach( () => {
		editorElement = document.createElement( 'div' );
		document.body.appendChild( editorElement );

		return ClassicTestEditor
			.create( editorElement, {
				plugins: [ HeadingUI, HeadingEditing ],
				toolbar: [ 'heading' ]
			} )
			.then( newEditor => {
				editor = newEditor;
				dropdown = editor.ui.componentFactory.create( 'heading' );

				// Set data so the commands will be enabled.
				setData( editor.model, '<paragraph>f{}oo</paragraph>' );
			} );
	} );
Exemplo n.º 7
0
			function localizedEditor( options ) {
				const editorElement = document.createElement( 'div' );
				document.body.appendChild( editorElement );

				return ClassicTestEditor
					.create( editorElement, {
						plugins: [ Heading ],
						toolbar: [ 'heading' ],
						language: 'pl',
						heading: {
							options
						}
					} )
					.then( newEditor => {
						editor = newEditor;
						dropdown = editor.ui.componentFactory.create( 'heading' );
						command = editor.commands.get( 'heading' );
						paragraphCommand = editor.commands.get( 'paragraph' );

						editorElement.remove();

						return editor.destroy();
					} );
			}