Browse Source

Merge pull request #6361 from ckeditor/i/6323

Tests: Added a manual test that contains an editor with all features developed by CKEditor 5 team. Closes #6323.
Piotrek Koszuliński 5 years ago
parent
commit
4108c74ab6
3 changed files with 348 additions and 0 deletions
  1. 175 0
      tests/manual/all-features.html
  2. 135 0
      tests/manual/all-features.js
  3. 38 0
      tests/manual/all-features.md

+ 175 - 0
tests/manual/all-features.html

@@ -0,0 +1,175 @@
+<head>
+	<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://ckeditor.com 'unsafe-inline' 'unsafe-eval'">
+</head>
+
+<div style="margin-bottom: 10px;">
+	<button type="button" id="clear-content">Clear editor</button>
+	<button type="button" id="print-data-action">Open print preview</button>
+	<button id="read-only">Turn on read-only mode</button>
+
+	<iframe id="print-data-container" aria-hidden="true" tabindex="-1"></iframe>
+</div>
+
+<div id="editor">
+	<h2>Lists in the table</h2>
+	<figure class="table">
+		<table style="width: 600px;border-bottom:2px dashed hsl(0, 0%, 60%);border-left:2px dashed hsl(0, 0%, 60%);border-right:2px dashed hsl(0, 0%, 60%);border-top:2px dashed hsl(0, 0%, 60%);">
+			<tbody>
+			<tr>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Bulleted list</span></td>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Numbered list</span></td>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">To do list</span></td>
+			</tr>
+			<tr>
+				<td style="vertical-align:top; width: 33%">
+					<ul>
+						<li>UL List item 1</li>
+						<li>UL List item 2</li>
+					</ul>
+				</td>
+				<td style="vertical-align:top; width: 33%">
+					<ol>
+						<li>OL List item 1</li>
+						<li>OL List item 2</li>
+					</ol>
+				</td>
+				<td style="vertical-align:top; width: 33%">
+					<ul class="todo-list">
+						<li>
+							<label class="todo-list__label">
+								<input type="checkbox" />
+								<span class="todo-list__label__description">Foo</span>
+							</label>
+						</li>
+						<li>
+							<label class="todo-list__label">
+								<input type="checkbox" checked="checked" />
+								<span class="todo-list__label__description">Foo</span>
+							</label>
+						</li>
+					</ul>
+				</td>
+			</tr>
+			</tbody>
+		</table>
+	</figure>
+
+	<h2>Basic features overview</h2>
+	<p>Lorem <b>ipsum dolor sit </b>amet, consectetur <i>adipisicing elit</i>.<sub>1</sub></p>
+	<h3>Basic styles</h3>
+	<p>Ad alias, <s>architecto</s> culpa <b><i>cumque</i></b> dignissimos <code>dolor eos incidunt ipsa itaque</code> <u>laboriosam</u> magnam molestias nihil <i><u>numquam</u></i> odit quam, suscipit <i><s>veritatis</s></i> voluptate voluptatum.<sup>2</sup></p>
+	<h3>Image</h3>
+	<figure class="image">
+		<img alt="bar" src="sample.jpg">
+		<figcaption>Caption</figcaption>
+	</figure>
+	<h3>Blockquote</h3>
+	<blockquote>
+		<p>Quote</p>
+		<ul>
+			<li><a href="#">Quoted</a> UL List item 1</li>
+			<li>Quoted UL List item 2</li>
+		</ul>
+		<p>Quote</p>
+	</blockquote>
+
+	<div class="page-break" style="page-break-after:always;"><span style="display:none;">&nbsp;</span></div>
+
+	<h2>Media with previews in the table</h2>
+	<figure class="table">
+		<table style="background-color:hsl(0,0%,90%);border-bottom:2px solid hsl(0, 0%, 0%);border-left:2px solid hsl(0, 0%, 0%);border-right:2px solid hsl(0, 0%, 0%);border-top:2px solid hsl(0, 0%, 0%);">
+			<tbody>
+			<tr>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Service</span></td>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Preview</span></td>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">URL</span></td>
+			</tr>
+			<tr>
+				<td style="text-align: center"><u>YouTube</u></td>
+				<td>
+					<figure class="media">
+						<oembed url="https://www.youtube.com/watch?v=ZVv7UMQPEWk"></oembed>
+					</figure>
+				</td>
+				<td>
+					<span class="text-small"><a href="https://www.youtube.com/watch?v=ZVv7UMQPEWk">https://www.youtube.com/watch?v=ZVv7UMQPEWk</a></span>
+				</td>
+			</tr>
+			<tr>
+				<td style="text-align: center"><u>Vimeo</u></td>
+				<td>
+					<figure class="media">
+						<oembed url="https://vimeo.com/1084537"></oembed>
+					</figure>
+				</td>
+				<td>
+					<span class="text-small"><a href="https://vimeo.com/1084537">https://vimeo.com/1084537</a></span>
+				</td>
+			</tr>
+			</tbody>
+		</table>
+	</figure>
+
+	<h2>Code blocks in the table</h2>
+	<figure class="table">
+		<table style="border-bottom:2px dashed hsl(0, 0%, 60%);border-left:2px dashed hsl(0, 0%, 60%);border-right:2px dashed hsl(0, 0%, 60%);border-top:2px dashed hsl(0, 0%, 60%);">
+			<tbody>
+			<tr>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Language</span></td>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Code snippet</span></td>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Language</span></td>
+				<td style="text-align: center"><span class="text-big" style="font-weight: bold">Code snippet</span></td>
+			</tr>
+			<tr>
+				<td style="text-align: center;vertical-align:top">CSS</td>
+				<td style="vertical-align:top">
+					<pre><code class="language-css">body {
+	color: red;
+}
+
+p {
+	font-size: 10px;
+}</code></pre></td>
+				<td style="text-align: center;vertical-align:top">PHP</td>
+				<td style="vertical-align:top"><pre><code class="language-php">&lt;?php
+
+function dump( array ...$args ) {
+	foreach ( $args as $item ) {
+		var_dump( $item );
+	}
+
+	die;
+}</code></pre></td>
+			</tr>
+			<tr>
+				<td style="text-align: center;vertical-align:top">JavaScript</td>
+				<td style="vertical-align:top">
+					<pre><code class="language-javascript">function foo() {
+	console.log( 'indented using 1 tab' );
+}
+
+function bar() {
+    console.log( 'indented using spaces' );
+}</code></pre></td>
+				<td style="text-align: center;vertical-align:top">Plaintext</td>
+				<td style="vertical-align:top"><pre><code class="language-plaintext">Plain text</code></pre></td>
+			</tr>
+			</tbody>
+		</table>
+	</figure>
+</div>
+
+<style>
+	#print-data-container {
+		position: absolute;
+		width: 1px;
+		height: 1px;
+		margin: -1px;
+		border: 0;
+		padding: 0;
+		white-space: nowrap;
+		clip-path: inset(100%);
+		clip: rect(0 0 0 0);
+		overflow: hidden;
+	}
+</style>

+ 135 - 0
tests/manual/all-features.js

@@ -0,0 +1,135 @@
+/**
+ * @license Copyright (c) 2003-2020, 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 TableProperties from '@ckeditor/ckeditor5-table/src/tableproperties';
+import TableCellProperties from '@ckeditor/ckeditor5-table/src/tablecellproperties';
+import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
+import Code from '@ckeditor/ckeditor5-basic-styles/src/code';
+import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough';
+import Superscript from '@ckeditor/ckeditor5-basic-styles/src/superscript';
+import Subscript from '@ckeditor/ckeditor5-basic-styles/src/subscript';
+import FontColor from '@ckeditor/ckeditor5-font/src/fontcolor';
+import FontBackgroundColor from '@ckeditor/ckeditor5-font/src/fontbackgroundcolor';
+import FontFamily from '@ckeditor/ckeditor5-font/src/fontfamily';
+import FontSize from '@ckeditor/ckeditor5-font/src/fontsize';
+import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock';
+import WordCount from '@ckeditor/ckeditor5-word-count/src/wordcount';
+import TodoList from '@ckeditor/ckeditor5-list/src/todolist';
+import SpecialCharacters from '@ckeditor/ckeditor5-special-characters/src/specialcharacters';
+import SpecialCharactersEssentials from '@ckeditor/ckeditor5-special-characters/src/specialcharactersessentials';
+import PageBreak from '@ckeditor/ckeditor5-page-break/src/pagebreak';
+import HorizontalLine from '@ckeditor/ckeditor5-horizontal-line/src/horizontalline';
+import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight';
+import IndentBlock from '@ckeditor/ckeditor5-indent/src/indentblock';
+import EasyImage from '@ckeditor/ckeditor5-easy-image/src/easyimage';
+import Mention from '@ckeditor/ckeditor5-mention/src/mention';
+import RemoveFormat from '@ckeditor/ckeditor5-remove-format/src/removeformat';
+import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment';
+import TextTransformation from '@ckeditor/ckeditor5-typing/src/texttransformation';
+
+import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [
+			ArticlePluginSet, CodeBlock, Alignment,
+			TableProperties, TableCellProperties, SpecialCharacters, SpecialCharactersEssentials,
+			Code, Underline, Strikethrough, Superscript, Subscript,
+			Highlight, FontColor, FontBackgroundColor, FontFamily, FontSize,
+			IndentBlock, WordCount, EasyImage,
+			TodoList, PageBreak, HorizontalLine, Mention, RemoveFormat, TextTransformation
+		],
+		toolbar: [
+			'heading',
+			'|',
+			'removeFormat', 'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript', 'link',
+			'|',
+			'highlight', 'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor',
+			'|',
+			'bulletedList', 'numberedList', 'todoList',
+			'|',
+			'blockQuote', 'imageUpload', 'insertTable', 'mediaEmbed', 'codeBlock',
+			'|',
+			'alignment', 'outdent', 'indent',
+			'|',
+			'pageBreak', 'horizontalLine', 'specialCharacters',
+			'|',
+			'undo', 'redo'
+		],
+		cloudServices: CS_CONFIG,
+		table: {
+			contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells', 'tableProperties', 'tableCellProperties' ]
+		},
+		image: {
+			styles: [
+				'full',
+				'alignLeft',
+				'alignRight'
+			],
+			toolbar: [ 'imageTextAlternative', '|', 'imageStyle:alignLeft', 'imageStyle:full', 'imageStyle:alignRight' ]
+		},
+		placeholder: 'Type the content here!',
+		mention: {
+			feeds: [
+				{
+					marker: '@',
+					feed: [
+						'@apple', '@bears', '@brownie', '@cake', '@cake', '@candy', '@canes', '@chocolate', '@cookie', '@cotton', '@cream',
+						'@cupcake', '@danish', '@donut', '@dragée', '@fruitcake', '@gingerbread', '@gummi', '@ice', '@jelly-o',
+						'@liquorice', '@macaroon', '@marzipan', '@oat', '@pie', '@plum', '@pudding', '@sesame', '@snaps', '@soufflé',
+						'@sugar', '@sweet', '@topping', '@wafer'
+					],
+					minimumCharacters: 1
+				}
+			]
+		}
+	} )
+	.then( editor => {
+		window.editor = editor;
+
+		editor.plugins.get( 'WordCount' ).on( 'update', ( evt, stats ) => {
+			console.log( `Characters: ${ stats.characters }, words: ${ stats.words }.` );
+		} );
+
+		document.getElementById( 'clear-content' ).addEventListener( 'click', () => {
+			editor.setData( '' );
+		} );
+
+		// The "Print editor data" button logic.
+		document.getElementById( 'print-data-action' ).addEventListener( 'click', () => {
+			const iframeElement = document.getElementById( 'print-data-container' );
+
+			/* eslint-disable max-len */
+			iframeElement.srcdoc = '<html>' +
+				'<head>' +
+					`<title>${ document.title }</title>` +
+					'<link rel="stylesheet" href="https://ckeditor.com/docs/ckeditor5/latest/snippets/features/page-break/snippet.css" type="text/css">' +
+				'</head>' +
+				'<body class="ck-content">' +
+					editor.getData() +
+					'<script>' +
+						'window.addEventListener( \'DOMContentLoaded\', () => { window.print(); } );' +
+					'</script>' +
+				'</body>' +
+			'</html>';
+			/* eslint-enable max-len */
+		} );
+
+		const button = document.getElementById( 'read-only' );
+
+		button.addEventListener( 'click', () => {
+			editor.isReadOnly = !editor.isReadOnly;
+			button.textContent = editor.isReadOnly ? 'Turn off read-only mode' : 'Turn on read-only mode';
+
+			editor.editing.view.focus();
+		} );
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 38 - 0
tests/manual/all-features.md

@@ -0,0 +1,38 @@
+# All features test
+
+## Toolbar
+
+It should contain as many features as we developed. By resizing your viewport you can observe whether grouping toolbar items work.
+
+## Editor
+
+There should be "two pages" with two sections per each page. Pages should be separated by the page break feature.
+
+### First page
+
+**Lists in the table** – in the table (2x3) in the second row should be 3 lists (bulleted, numbered and todo).
+
+**Basic features overview** - a few paragraphs of text (that contain text formatted using basic styles feature), an image, and a blockquote.
+
+### Second page
+
+**Media with previews in the table** - in the table (3x3), in the middle column you should see a preview of attached media embed elements.
+
+**Code blocks in the table** - in the table (4x3), in the second and fourth columns should be visible code snippets.
+
+## Action buttons
+
+- Clear editor - calls `editor.setData( '' )`
+- Open print preview - opens the print preview window
+- Turn on/off read-only mode - toggle read-only mode
+
+## Console
+
+Wordcount plugin logs into the console number of characters and words in the editor's data.
+
+## Additional
+
+- Empty editor should display a placeholder: `'Type the content here!'`
+- Mention plugin is configured with an array of feed: `[ '@Barney', '@Lily', '@Marshall', '@Robin', '@Ted' ],`
+- ImageUpload uses EasyImage
+- Styles for printing preview are served by official docs