Browse Source

Tests: Added simple manual test.

Krzysztof Krztoń 7 years ago
parent
commit
ebc2c960c3

+ 2 - 0
packages/ckeditor5-paste-from-office/package.json

@@ -14,9 +14,11 @@
     "@ckeditor/ckeditor5-basic-styles": "^10.0.2",
     "@ckeditor/ckeditor5-clipboard": "^10.0.2",
     "@ckeditor/ckeditor5-core": "^11.0.0",
+    "@ckeditor/ckeditor5-editor-classic": "^11.0.0",
     "@ckeditor/ckeditor5-engine": "^10.2.0",
     "@ckeditor/ckeditor5-heading": "^10.0.2",
     "@ckeditor/ckeditor5-paragraph": "^10.0.2",
+    "@ckeditor/ckeditor5-table": "^10.1.0",
     "eslint": "^4.15.0",
     "eslint-config-ckeditor5": "^1.0.7",
     "husky": "^0.14.3",

+ 20 - 0
packages/ckeditor5-paste-from-office/tests/manual/integration.html

@@ -0,0 +1,20 @@
+<div id="editor">
+	<h2>Paste here:</h2>
+
+	<p></p>
+
+	<p>or <strong>here:</strong></p>
+
+	<ul>
+		<li>Maybe <a href="https://github.com/ckeditor/ckeditor5">somewhere <i>here</i>?</a></li>
+	</ul>
+</div>
+
+Clipboard HTML
+<div id="html" contenteditable="true" style="width:100%;height:300px;background-color:#EEE;overflow:auto;"></div>
+
+Clipboard text
+<div id="text" contenteditable="true" style="width:100%;height:100px;background-color:#DDD;overflow:auto;"></div>
+
+Clipboard HTML after transformation
+<div id="data" contenteditable="true" style="width:100%;height:100px;background-color:#CCC;overflow:auto;"></div>

+ 52 - 0
packages/ckeditor5-paste-from-office/tests/manual/integration.js

@@ -0,0 +1,52 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals console, window, document */
+
+import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
+import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+
+import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough';
+import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
+import Table from '@ckeditor/ckeditor5-table/src/table';
+
+import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
+
+const htmlDiv = document.querySelector( '#html' );
+const textDiv = document.querySelector( '#text' );
+const dataDiv = document.querySelector( '#data' );
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePluginSet, Strikethrough, Underline, Table ],
+		toolbar: [ 'heading', '|', 'bold', 'italic', 'strikethrough', 'underline', 'link',
+			'bulletedList', 'numberedList', 'blockQuote', 'table', 'undo', 'redo' ]
+	} )
+	.then( editor => {
+		window.editor = editor;
+		const clipboard = editor.plugins.get( 'Clipboard' );
+
+		editor.editing.view.document.on( 'paste', ( evt, data ) => {
+			console.clear();
+
+			console.log( '----- paste -----' );
+			console.log( data );
+			console.log( 'text/html\n', data.dataTransfer.getData( 'text/html' ) );
+			console.log( 'text/plain\n', data.dataTransfer.getData( 'text/plain' ) );
+
+			htmlDiv.innerText = data.dataTransfer.getData( 'text/html' );
+			textDiv.innerText = data.dataTransfer.getData( 'text/plain' );
+		} );
+
+		clipboard.on( 'inputTransformation', ( evt, data ) => {
+			console.log( '----- clipboardInput -----' );
+			console.log( 'stringify( data.dataTransfer )\n', stringifyView( data.content ) );
+
+			dataDiv.innerText = stringifyView( data.content );
+		} );
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 7 - 0
packages/ckeditor5-paste-from-office/tests/manual/integration.md

@@ -0,0 +1,7 @@
+## Paste from Word
+
+Simple test for Paste from Word.
+
+Check:
+
+1. Copy & paste some content from Word.