Sfoglia il codice sorgente

Merge branch 'master' into t/ckeditor5-engine/660

Aleksander Nowodzinski 8 anni fa
parent
commit
5d38e24b2a

+ 2 - 1
packages/ckeditor5-clipboard/README.md

@@ -1,6 +1,7 @@
-CKEditor 5 Clipboard Feature
+CKEditor 5 clipboard feature
 ========================================
 
+[![Join the chat at https://gitter.im/ckeditor/ckeditor5](https://badges.gitter.im/ckeditor/ckeditor5.svg)](https://gitter.im/ckeditor/ckeditor5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
 [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-clipboard.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-clipboard)
 [![Build Status](https://travis-ci.org/ckeditor/ckeditor5-clipboard.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-clipboard)
 [![Test Coverage](https://codeclimate.com/github/ckeditor/ckeditor5-clipboard/badges/coverage.svg)](https://codeclimate.com/github/ckeditor/ckeditor5-clipboard/coverage)

+ 1 - 1
packages/ckeditor5-clipboard/package.json

@@ -15,7 +15,7 @@
     "@ckeditor/ckeditor5-paragraph": "^0.8.0",
     "@ckeditor/ckeditor5-presets": "^0.2.2",
     "@ckeditor/ckeditor5-link": "^0.7.0",
-    "eslint-config-ckeditor5": "^1.0.0",
+    "eslint-config-ckeditor5": "^1.0.5",
     "gulp": "^3.9.1",
     "guppy-pre-commit": "^0.4.0"
   },

+ 13 - 12
packages/ckeditor5-clipboard/tests/clipboard.js

@@ -26,18 +26,19 @@ describe( 'Clipboard feature', () => {
 	let editor, editingView, clipboardPlugin, scrollSpy;
 
 	beforeEach( () => {
-		return VirtualTestEditor.create( {
-			plugins: [ Clipboard, Paragraph ]
-		} )
-		.then( newEditor => {
-			editor = newEditor;
-			editingView = editor.editing.view;
-			clipboardPlugin = editor.plugins.get( 'Clipboard' );
-
-			// VirtualTestEditor has no DOM, so this method must be stubbed for all tests.
-			// Otherwise it will throw as it accesses the DOM to do its job.
-			scrollSpy = sinon.stub( editingView, 'scrollToTheSelection', () => {} );
-		} );
+		return VirtualTestEditor
+			.create( {
+				plugins: [ Clipboard, Paragraph ]
+			} )
+			.then( newEditor => {
+				editor = newEditor;
+				editingView = editor.editing.view;
+				clipboardPlugin = editor.plugins.get( 'Clipboard' );
+
+				// VirtualTestEditor has no DOM, so this method must be stubbed for all tests.
+				// Otherwise it will throw as it accesses the DOM to do its job.
+				scrollSpy = sinon.stub( editingView, 'scrollToTheSelection', () => {} );
+			} );
 	} );
 
 	describe( 'constructor()', () => {

+ 35 - 34
packages/ckeditor5-clipboard/tests/manual/copycut.js

@@ -10,41 +10,42 @@ import ArticlePreset from '@ckeditor/ckeditor5-presets/src/article';
 
 import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
-ClassicEditor.create( document.querySelector( '#editor' ), {
-	plugins: [ ArticlePreset ],
-	toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
-} )
-.then( editor => {
-	window.editor = editor;
-	const clipboard = editor.plugins.get( 'Clipboard' );
-
-	editor.editing.view.on( 'paste', ( evt, data ) => {
-		console.clear();
-		onViewEvent( evt, data );
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePreset ],
+		toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
+	} )
+	.then( editor => {
+		window.editor = editor;
+		const clipboard = editor.plugins.get( 'Clipboard' );
+
+		editor.editing.view.on( 'paste', ( evt, data ) => {
+			console.clear();
+			onViewEvent( evt, data );
+		} );
+		editor.editing.view.on( 'paste', onViewEvent );
+		editor.editing.view.on( 'copy', onViewEvent, { priority: 'lowest' } );
+		editor.editing.view.on( 'cut', onViewEvent, { priority: 'lowest' } );
+
+		clipboard.on( 'inputTransformation', onPipelineEvent );
+		editor.editing.view.on( 'clipboardOutput', ( evt, data ) => {
+			console.clear();
+			onPipelineEvent( evt, data );
+		} );
+
+		function onViewEvent( evt, data ) {
+			console.log( `----- ${ evt.name } -----` );
+			console.log( 'text/html\n', data.dataTransfer.getData( 'text/html' ) );
+		}
+
+		function onPipelineEvent( evt, data ) {
+			console.log( `----- ${ evt.name } -----` );
+			console.log( 'stringify( data.content )\n', stringifyView( data.content ) );
+		}
+	} )
+	.catch( err => {
+		console.error( err.stack );
 	} );
-	editor.editing.view.on( 'paste', onViewEvent );
-	editor.editing.view.on( 'copy', onViewEvent, { priority: 'lowest' } );
-	editor.editing.view.on( 'cut', onViewEvent, { priority: 'lowest' } );
-
-	clipboard.on( 'inputTransformation', onPipelineEvent );
-	editor.editing.view.on( 'clipboardOutput', ( evt, data ) => {
-		console.clear();
-		onPipelineEvent( evt, data );
-	} );
-
-	function onViewEvent( evt, data ) {
-		console.log( `----- ${ evt.name } -----` );
-		console.log( 'text/html\n', data.dataTransfer.getData( 'text/html' ) );
-	}
-
-	function onPipelineEvent( evt, data ) {
-		console.log( `----- ${ evt.name } -----` );
-		console.log( 'stringify( data.content )\n', stringifyView( data.content ) );
-	}
-} )
-.catch( err => {
-	console.error( err.stack );
-} );
 
 document.getElementById( 'native' ).addEventListener( 'paste', onNativeEvent );
 document.getElementById( 'native' ).addEventListener( 'copy', onNativeEvent );

+ 34 - 33
packages/ckeditor5-clipboard/tests/manual/dropping.js

@@ -13,38 +13,39 @@ import Selection from '@ckeditor/ckeditor5-engine/src/model/selection';
 
 // import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
-ClassicEditor.create( document.querySelector( '#editor' ), {
-	plugins: [ ArticlePreset ],
-	toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
-} )
-.then( editor => {
-	window.editor = editor;
-	// const clipboard = editor.plugins.get( 'Clipboard' );
-
-	editor.editing.view.on( 'drop', ( evt, data ) => {
-		console.clear();
-
-		console.log( '----- drop -----' );
-		console.log( data );
-		console.log( 'text/html\n', data.dataTransfer.getData( 'text/html' ) );
-		console.log( 'text/plain\n', data.dataTransfer.getData( 'text/plain' ) );
-
-		data.preventDefault();
-		evt.stop();
-
-		editor.document.enqueueChanges( () => {
-			const insertAtSelection = new Selection( [ editor.editing.mapper.toModelRange( data.dropRange ) ] );
-			editor.data.insertContent( new Text( '@' ), insertAtSelection );
-			editor.document.selection.setTo( insertAtSelection );
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePreset ],
+		toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
+	} )
+	.then( editor => {
+		window.editor = editor;
+		// const clipboard = editor.plugins.get( 'Clipboard' );
+
+		editor.editing.view.on( 'drop', ( evt, data ) => {
+			console.clear();
+
+			console.log( '----- drop -----' );
+			console.log( data );
+			console.log( 'text/html\n', data.dataTransfer.getData( 'text/html' ) );
+			console.log( 'text/plain\n', data.dataTransfer.getData( 'text/plain' ) );
+
+			data.preventDefault();
+			evt.stop();
+
+			editor.document.enqueueChanges( () => {
+				const insertAtSelection = new Selection( [ editor.editing.mapper.toModelRange( data.dropRange ) ] );
+				editor.data.insertContent( new Text( '@' ), insertAtSelection );
+				editor.document.selection.setTo( insertAtSelection );
+			} );
 		} );
-	} );
 
-	// Waiting until a real dropping support...
-	// clipboard.on( 'inputTransformation', ( evt, data ) => {
-	// 	console.log( '----- clipboardInput -----' );
-	// 	console.log( 'stringify( data.dataTransfer )\n', stringifyView( data.content ) );
-	// } );
-} )
-.catch( err => {
-	console.error( err.stack );
-} );
+		// Waiting until a real dropping support...
+		// clipboard.on( 'inputTransformation', ( evt, data ) => {
+		// 	console.log( '----- clipboardInput -----' );
+		// 	console.log( 'stringify( data.dataTransfer )\n', stringifyView( data.content ) );
+		// } );
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 22 - 21
packages/ckeditor5-clipboard/tests/manual/pasting.js

@@ -10,28 +10,29 @@ import ArticlePreset from '@ckeditor/ckeditor5-presets/src/article';
 
 import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
-ClassicEditor.create( document.querySelector( '#editor' ), {
-	plugins: [ ArticlePreset ],
-	toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
-} )
-.then( editor => {
-	window.editor = editor;
-	const clipboard = editor.plugins.get( 'Clipboard' );
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePreset ],
+		toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
+	} )
+	.then( editor => {
+		window.editor = editor;
+		const clipboard = editor.plugins.get( 'Clipboard' );
 
-	editor.editing.view.on( 'paste', ( evt, data ) => {
-		console.clear();
+		editor.editing.view.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' ) );
-	} );
+			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' ) );
+		} );
 
-	clipboard.on( 'inputTransformation', ( evt, data ) => {
-		console.log( '----- clipboardInput -----' );
-		console.log( 'stringify( data.dataTransfer )\n', stringifyView( data.content ) );
+		clipboard.on( 'inputTransformation', ( evt, data ) => {
+			console.log( '----- clipboardInput -----' );
+			console.log( 'stringify( data.dataTransfer )\n', stringifyView( data.content ) );
+		} );
+	} )
+	.catch( err => {
+		console.error( err.stack );
 	} );
-} )
-.catch( err => {
-	console.error( err.stack );
-} );