Ver código fonte

Add manual tests for classes mode.

Maciej Gołaszewski 6 anos atrás
pai
commit
45c7e0fc86

+ 49 - 0
packages/ckeditor5-indent/tests/manual/indent-block-classes.html

@@ -0,0 +1,49 @@
+<head>
+	<style>
+		body {
+			max-width: 800px;
+			margin: 20px auto;
+		}
+
+		.indent-1 {
+			margin-left: 20px;
+		}
+
+		.indent-2 {
+			margin-left: 40px;
+		}
+
+		.indent-3 {
+			margin-left: 60px;
+		}
+
+		.indent-4 {
+			margin-left: 80px;
+		}
+	</style>
+</head>
+<div id="editor">
+	<h2>Heading 1</h2>
+	<p class="indent-1">Paragraph</p>
+	<p><strong>Bold</strong> <i>Italic</i> <a href="https://ckeditor.com">Link</a></p>
+	<ul>
+		<li>UL List item 1</li>
+		<li>UL List item 2</li>
+	</ul>
+	<ol>
+		<li>OL List item 1</li>
+		<li>OL List item 2</li>
+	</ol>
+	<figure class="image image-style-side">
+		<img alt="bar" src="sample.jpg">
+		<figcaption>Caption</figcaption>
+	</figure>
+	<blockquote>
+		<p>Quote</p>
+		<ul>
+			<li>Quoted UL List item 1</li>
+			<li>Quoted UL List item 2</li>
+		</ul>
+		<p>Quote</p>
+	</blockquote>
+</div>

+ 107 - 0
packages/ckeditor5-indent/tests/manual/indent-block-classes.js

@@ -0,0 +1,107 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/* globals console, window, document */
+
+import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
+
+import MultiCommand from '@ckeditor/ckeditor5-core/src/multicommand';
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
+import IndentBlock from '../../src/indentblock';
+
+import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+
+class Indent extends Plugin {
+	init() {
+		const editor = this.editor;
+		const t = editor.t;
+
+		editor.commands.add( 'indent', new MultiCommand( editor ) );
+		editor.commands.add( 'outdent', new MultiCommand( editor ) );
+
+		this._createButton( 'indent', t( '>' ) );
+		this._createButton( 'outdent', t( '<' ) );
+
+		// TODO: temporary - tests only
+		this._createButton( 'indentList', t( '> List' ) );
+		this._createButton( 'outdentList', t( '< List' ) );
+
+		// TODO: temporary - tests only
+		this._createButton( 'indentBlock', t( '> Block' ) );
+		this._createButton( 'outdentBlock', t( '< Block' ) );
+	}
+
+	_createButton( commandName, label ) {
+		const editor = this.editor;
+
+		editor.ui.componentFactory.add( commandName, locale => {
+			const command = editor.commands.get( commandName );
+			const view = new ButtonView( locale );
+
+			view.set( {
+				label,
+				withText: true,
+				tooltip: true
+			} );
+
+			view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
+
+			// Execute command.
+			this.listenTo( view, 'execute', () => editor.execute( commandName ) );
+
+			return view;
+		} );
+	}
+}
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePluginSet, Indent, IndentBlock ],
+		toolbar: [
+			'heading',
+			'|',
+			'indent',
+			'outdent',
+			'|',
+			'indentList',
+			'outdentList',
+			'|',
+			'indentBlock',
+			'outdentBlock',
+			'|',
+			'bulletedList',
+			'numberedList',
+			'|',
+			'blockQuote',
+			'insertTable',
+			'undo',
+			'redo'
+		],
+		image: {
+			toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
+		},
+		table: {
+			contentToolbar: [
+				'tableColumn',
+				'tableRow',
+				'mergeTableCells'
+			]
+		},
+		indentBlock: {
+			classes: [
+				'indent-1',
+				'indent-2',
+				'indent-3',
+				'indent-4'
+			]
+		}
+	} )
+	.then( editor => {
+		window.editor = editor;
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 3 - 0
packages/ckeditor5-indent/tests/manual/indent-block-classes.md

@@ -0,0 +1,3 @@
+# Block indentation
+
+TODO