Browse Source

Merge tag 'v1.0.0-beta.1' into stable

Release: v1.0.0-beta.1.
Piotrek Koszuliński 7 years ago
parent
commit
cc63e29add

+ 1 - 1
packages/ckeditor5-clipboard/.eslintrc.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 15 - 11
packages/ckeditor5-clipboard/.travis.yml

@@ -1,24 +1,28 @@
 sudo: required
 dist: trusty
 addons:
+  firefox: "latest"
   apt:
     sources:
-      - google-chrome
+    - google-chrome
     packages:
-      - google-chrome-stable
+    - google-chrome-stable
 language: node_js
 node_js:
-  - "6"
+- '6'
 cache:
-  - node_modules
+- node_modules
 before_install:
-  - export DISPLAY=:99.0
-  - sh -e /etc/init.d/xvfb start
+- export DISPLAY=:99.0
+- sh -e /etc/init.d/xvfb start
 install:
-  - npm install @ckeditor/ckeditor5-dev-tests
-  - ckeditor5-dev-tests-install-dependencies
+- npm install @ckeditor/ckeditor5-dev-tests
+- ckeditor5-dev-tests-install-dependencies
 script:
-  - ckeditor5-dev-tests-travis
+- ckeditor5-dev-tests-travis
 after_success:
-  - codeclimate-test-reporter < coverage/lcov.info
-  - ckeditor5-dev-tests-save-revision
+- ckeditor5-dev-tests-save-revision
+env:
+  global:
+  - secure: 2B2J4L85DoU7hgeZdoczdDbq3M/MV45hZ1k+RngBq4Nb33JiqHJq4M9IvaJWmiFJijwoyKILPZc80B3JcJslb34+zoFTIVgvO/YRJLOdGj9hXHyfelt2uKO+jsGYE1DU/MLDwwzm0gguM0QoFMzo7OUTj80Rlp0BdH/yCIlsohv+A1b0avVOwsk4lkdasRr5xpRw0bTq/hzSTChCF4W2Z4ru7rD2hOew1EStKTVhSOhsZylaTgeRrghpdigsCAlGwxkd3CIdaGkfMP2V/NwRHU9d4rSVbkoQLJUanBXjVDPpILA1LwOW3JiLwBvEAlkc/9CNmWgSzlPrVNrBO4T2JqCzQhZ2/oBUbfId7ylKuRwvJsOObNlVdLs2w3zrSRY1T5RTYRUGCuPzecwsOYW3KRIcCp9r3PnUJ5O5fTD31uC6saMiHUbnDOqzRpu4ypp7eYm7ZmwIsN9T29pqly3m/XMEc7YdpsTyDd3A+mxNb2TcnyqbbBnzH6E/WMsjv/TLBYh897VaTAwCMtxFQ0CIPoYklXOH4E69TL54w2lK+W5NE5+1fPi/mULDfwB/eyQZ16iFLvCtsSDrc9US8TJm9QBrHhBzZA9KGo/TnJVNVg6R9J06IvixUHP+RZja7UbQ00gfRkCJc4fIGL47UjBNuhayhlR0GIJ1Bf1s/vjA7S0=
+  - secure: qVBid2b/hiCAohgaF7S07xnvm4kVppS2tGniJ31RDTAVbYXcxnNJr69kHqLlAy9Fby2diOFxy0Td6lpyjFn1piqBTR5x32YN8P+SnFgrzKCCkOc3wCNmESaAPuVLrMAk6wxqyEvwhWpd2/bgZyK3LT3jE2vrvK9SQhM19TwyoBrVGyo5MiFANCtECN8SfCkj20Ndpc5Mj0P+ECg/0OQO4YiTq5vzQpV11hf/ElDLg3Q2KkoefBTYDo/FuuMvnTd14IZlKmNV+MQEazIWyygT4cAaaVuKpHTqzvkH419XvFJ4Bo4QxNsafCHH+AM+ryaAdiQ5D8qYRzbVLuDkKqXU2nkSZbxpK0St8s1WNofXDOXqfNKSQsJP4lWrvV4LMbshnxJGZEvbVN2fzaMl5mjS1MT2NES+wxW0vSdA4k2IagOELzeQGOAQ6WIePx0jE0yaLaM3wpZwwleITCOlEmpZ1VGgQDcQ9g2MFypDbmzXObmGpjc88AvvPAgyPozXr8DEn3nCViQtcnm42/kLMbc38Yca5fBBsXHpDMbQOFDk5qJIeDfLdxypExu4IMamqQ6zhCeW4M7IoRapLBZRHdA+K1KAYrYvDLMFbSf7c1QKGSXY+HJzeudzUKNRI80dgIoy4uzIbA4Z7ksUoQfJqINHUu5r5NFqOFJCfBF3o+5Fpoc=

+ 6 - 0
packages/ckeditor5-clipboard/CHANGELOG.md

@@ -1,10 +1,16 @@
 Changelog
 =========
 
+## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (2018-03-15)
+
+Internal changes only (updated dependencies, documentation, etc.).
+
+
 ## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-clipboard/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017-11-14)
 
 Internal changes only (updated dependencies, documentation, etc.).
 
+
 ## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v0.7.0...v1.0.0-alpha.1) (2017-10-03)
 
 Internal changes only (updated dependencies, documentation, etc.).

+ 1 - 1
packages/ckeditor5-clipboard/LICENSE.md

@@ -2,7 +2,7 @@ Software License Agreement
 ==========================
 
 **CKEditor 5 Clipboard Feature** – https://github.com/ckeditor/ckeditor5-clipboard <br>
-Copyright (c) 2003-2017, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2018, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.
 
 Licensed under the terms of any of the following licenses at your choice:
 

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

@@ -4,7 +4,9 @@ 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)
+[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)](https://www.browserstack.com/automate/public-build/d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)
+[![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-clipboard/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-clipboard?branch=master)
+<br>
 [![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-clipboard/status.svg)](https://david-dm.org/ckeditor/ckeditor5-clipboard)
 [![devDependency Status](https://david-dm.org/ckeditor/ckeditor5-clipboard/dev-status.svg)](https://david-dm.org/ckeditor/ckeditor5-clipboard?type=dev)
 

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

@@ -1,26 +1,26 @@
 {
   "name": "@ckeditor/ckeditor5-clipboard",
-  "version": "1.0.0-alpha.2",
+  "version": "1.0.0-beta.1",
   "description": "Clipboard integration for CKEditor 5.",
   "keywords": [
     "ckeditor5",
     "ckeditor5-feature"
   ],
   "dependencies": {
-    "@ckeditor/ckeditor5-core": "^1.0.0-alpha.2",
-    "@ckeditor/ckeditor5-engine": "^1.0.0-alpha.2"
+    "@ckeditor/ckeditor5-core": "^1.0.0-beta.1",
+    "@ckeditor/ckeditor5-engine": "^1.0.0-beta.1"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-basic-styles": "^1.0.0-alpha.2",
-    "@ckeditor/ckeditor5-block-quote": "^1.0.0-alpha.2",
-    "@ckeditor/ckeditor5-editor-classic": "^1.0.0-alpha.2",
-    "@ckeditor/ckeditor5-essentials": "^1.0.0-alpha.2",
-    "@ckeditor/ckeditor5-link": "^1.0.0-alpha.2",
-    "@ckeditor/ckeditor5-paragraph": "^1.0.0-alpha.2",
-    "eslint": "^4.8.0",
-    "eslint-config-ckeditor5": "^1.0.6",
+    "@ckeditor/ckeditor5-basic-styles": "^1.0.0-beta.1",
+    "@ckeditor/ckeditor5-block-quote": "^1.0.0-beta.1",
+    "@ckeditor/ckeditor5-editor-classic": "^1.0.0-beta.1",
+    "@ckeditor/ckeditor5-essentials": "^1.0.0-beta.1",
+    "@ckeditor/ckeditor5-link": "^1.0.0-beta.1",
+    "@ckeditor/ckeditor5-paragraph": "^1.0.0-beta.1",
+    "eslint": "^4.15.0",
+    "eslint-config-ckeditor5": "^1.0.7",
     "husky": "^0.14.3",
-    "lint-staged": "^4.2.3"
+    "lint-staged": "^6.0.0"
   },
   "engines": {
     "node": ">=6.0.0",

+ 17 - 18
packages/ckeditor5-clipboard/src/clipboard.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
@@ -88,7 +88,7 @@ import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/html
  *
  * The default action is to:
  *
- * 1. {@link module:engine/controller/datacontroller~DataController#getSelectedContent get selected content} from the editor,
+ * 1. {@link module:engine/model/model~Model#getSelectedContent get selected content} from the editor,
  * 2. prevent the default action of the native `copy` or `cut` event,
  * 3. fire {@link module:engine/view/document~Document#event:clipboardOutput} with a clone of the selected content
  * converted to a {@link module:engine/view/documentfragment~DocumentFragment view document fragment}.
@@ -118,8 +118,9 @@ export default class Clipboard extends Plugin {
 	 */
 	init() {
 		const editor = this.editor;
-		const doc = editor.document;
-		const editingView = editor.editing.view;
+		const modelDocument = editor.model.document;
+		const view = editor.editing.view;
+		const viewDocument = view.document;
 
 		/**
 		 * Data processor used to convert pasted HTML to a view structure.
@@ -129,11 +130,11 @@ export default class Clipboard extends Plugin {
 		 */
 		this._htmlDataProcessor = new HtmlDataProcessor();
 
-		editingView.addObserver( ClipboardObserver );
+		view.addObserver( ClipboardObserver );
 
 		// The clipboard paste pipeline.
 
-		this.listenTo( editingView, 'clipboardInput', ( evt, data ) => {
+		this.listenTo( viewDocument, 'clipboardInput', ( evt, data ) => {
 			// Pasting and dropping is disabled when editor is read-only.
 			// See: https://github.com/ckeditor/ckeditor5-clipboard/issues/26.
 			if ( editor.isReadOnly ) {
@@ -153,12 +154,13 @@ export default class Clipboard extends Plugin {
 
 			this.fire( 'inputTransformation', { content } );
 
-			editingView.scrollToTheSelection();
+			view.scrollToTheSelection();
 		}, { priority: 'low' } );
 
 		this.listenTo( this, 'inputTransformation', ( evt, data ) => {
 			if ( !data.content.isEmpty ) {
 				const dataController = this.editor.data;
+				const model = this.editor.model;
 
 				// Convert the pasted content to a model document fragment.
 				// Conversion is contextual, but in this case we need an "all allowed" context and for that
@@ -169,9 +171,7 @@ export default class Clipboard extends Plugin {
 					return;
 				}
 
-				doc.enqueueChanges( () => {
-					dataController.insertContent( modelFragment, doc.selection );
-				} );
+				model.insertContent( modelFragment, modelDocument.selection );
 			}
 		}, { priority: 'low' } );
 
@@ -179,15 +179,16 @@ export default class Clipboard extends Plugin {
 
 		function onCopyCut( evt, data ) {
 			const dataTransfer = data.dataTransfer;
-			const content = editor.data.toView( editor.data.getSelectedContent( doc.selection ) );
 
 			data.preventDefault();
 
-			editingView.fire( 'clipboardOutput', { dataTransfer, content, method: evt.name } );
+			const content = editor.data.toView( editor.model.getSelectedContent( modelDocument.selection ) );
+
+			viewDocument.fire( 'clipboardOutput', { dataTransfer, content, method: evt.name } );
 		}
 
-		this.listenTo( editingView, 'copy', onCopyCut, { priority: 'low' } );
-		this.listenTo( editingView, 'cut', ( evt, data ) => {
+		this.listenTo( viewDocument, 'copy', onCopyCut, { priority: 'low' } );
+		this.listenTo( viewDocument, 'cut', ( evt, data ) => {
 			// Cutting is disabled when editor is read-only.
 			// See: https://github.com/ckeditor/ckeditor5-clipboard/issues/26.
 			if ( editor.isReadOnly ) {
@@ -197,16 +198,14 @@ export default class Clipboard extends Plugin {
 			}
 		}, { priority: 'low' } );
 
-		this.listenTo( editingView, 'clipboardOutput', ( evt, data ) => {
+		this.listenTo( viewDocument, 'clipboardOutput', ( evt, data ) => {
 			if ( !data.content.isEmpty ) {
 				data.dataTransfer.setData( 'text/html', this._htmlDataProcessor.toData( data.content ) );
 				data.dataTransfer.setData( 'text/plain', viewToPlainText( data.content ) );
 			}
 
 			if ( data.method == 'cut' ) {
-				doc.enqueueChanges( () => {
-					editor.data.deleteContent( doc.selection, doc.batch() );
-				} );
+				editor.model.deleteContent( modelDocument.selection );
 			}
 		}, { priority: 'low' } );
 	}

+ 20 - 18
packages/ckeditor5-clipboard/src/clipboardobserver.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
@@ -14,25 +14,27 @@ import DataTransfer from './datatransfer';
  * {@link module:engine/view/document~Document#event:paste Paste} event observer.
  *
  * Note that this observer is not available by default. To make it available it needs to be added to
- * {@link module:engine/view/document~Document} by the {@link module:engine/view/document~Document#addObserver} method.
+ * {@link module:engine/view/document~Document} by the {@link module:engine/view/view~View#addObserver} method.
  *
  * @extends module:engine/view/observer/domeventobserver~DomEventObserver
  */
 export default class ClipboardObserver extends DomEventObserver {
-	constructor( doc ) {
-		super( doc );
+	constructor( view ) {
+		super( view );
+
+		const viewDocument = this.document;
 
 		this.domEventType = [ 'paste', 'copy', 'cut', 'drop', 'dragover' ];
 
-		this.listenTo( doc, 'paste', handleInput, { priority: 'low' } );
-		this.listenTo( doc, 'drop', handleInput, { priority: 'low' } );
+		this.listenTo( viewDocument, 'paste', handleInput, { priority: 'low' } );
+		this.listenTo( viewDocument, 'drop', handleInput, { priority: 'low' } );
 
 		function handleInput( evt, data ) {
 			data.preventDefault();
 
-			const targetRanges = data.dropRange ? [ data.dropRange ] : Array.from( doc.selection.getRanges() );
+			const targetRanges = data.dropRange ? [ data.dropRange ] : Array.from( viewDocument.selection.getRanges() );
 
-			doc.fire( 'clipboardInput', {
+			viewDocument.fire( 'clipboardInput', {
 				dataTransfer: data.dataTransfer,
 				targetRanges
 			} );
@@ -45,14 +47,14 @@ export default class ClipboardObserver extends DomEventObserver {
 		};
 
 		if ( domEvent.type == 'drop' ) {
-			evtData.dropRange = getDropViewRange( this.document, domEvent );
+			evtData.dropRange = getDropViewRange( this.view, domEvent );
 		}
 
 		this.fire( domEvent.type, domEvent, evtData );
 	}
 }
 
-function getDropViewRange( doc, domEvent ) {
+function getDropViewRange( view, domEvent ) {
 	const domDoc = domEvent.target.ownerDocument;
 	const x = domEvent.clientX;
 	const y = domEvent.clientY;
@@ -70,9 +72,9 @@ function getDropViewRange( doc, domEvent ) {
 	}
 
 	if ( domRange ) {
-		return doc.domConverter.domRangeToView( domRange );
+		return view.domConverter.domRangeToView( domRange );
 	} else {
-		return doc.selection.getFirstRange();
+		return view.document.selection.getFirstRange();
 	}
 }
 
@@ -84,7 +86,7 @@ function getDropViewRange( doc, domEvent ) {
  * and inserted into the editor.
  *
  * Note that this event is not available by default. To make it available {@link module:clipboard/clipboardobserver~ClipboardObserver}
- * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/document~Document#addObserver} method.
+ * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/view~View#addObserver} method.
  * It's done by the {@link module:clipboard/clipboard~Clipboard} feature. If it's not loaded, it must be done manually.
  *
  * @see module:clipboard/clipboardobserver~ClipboardObserver
@@ -104,7 +106,7 @@ function getDropViewRange( doc, domEvent ) {
  * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
  *
  * Note that this event is not available by default. To make it available {@link module:clipboard/clipboardobserver~ClipboardObserver}
- * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/document~Document#addObserver} method.
+ * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/view~View#addObserver} method.
  * It's done by the {@link module:clipboard/clipboard~Clipboard} feature. If it's not loaded, it must be done manually.
  *
  * @see module:engine/view/document~Document#event:clipboardInput
@@ -118,7 +120,7 @@ function getDropViewRange( doc, domEvent ) {
  * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
  *
  * Note that this event is not available by default. To make it available {@link module:clipboard/clipboardobserver~ClipboardObserver}
- * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/document~Document#addObserver} method.
+ * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/view~View#addObserver} method.
  * It's done by the {@link module:clipboard/clipboard~Clipboard} feature. If it's not loaded, it must be done manually.
  *
  * @see module:engine/view/document~Document#event:clipboardInput
@@ -133,7 +135,7 @@ function getDropViewRange( doc, domEvent ) {
  * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
  *
  * Note that this event is not available by default. To make it available {@link module:clipboard/clipboardobserver~ClipboardObserver}
- * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/document~Document#addObserver} method.
+ * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/view~View#addObserver} method.
  * It's done by the {@link module:clipboard/clipboard~Clipboard} feature. If it's not loaded, it must be done manually.
  *
  * @see module:engine/view/document~Document#event:clipboardInput
@@ -147,7 +149,7 @@ function getDropViewRange( doc, domEvent ) {
  * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
  *
  * Note that this event is not available by default. To make it available {@link module:clipboard/clipboardobserver~ClipboardObserver}
- * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/document~Document#addObserver} method.
+ * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/view~View#addObserver} method.
  * It's done by the {@link module:clipboard/clipboard~Clipboard} feature. If it's not loaded, it must be done manually.
  *
  * @see module:clipboard/clipboardobserver~ClipboardObserver
@@ -161,7 +163,7 @@ function getDropViewRange( doc, domEvent ) {
  * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
  *
  * Note that this event is not available by default. To make it available {@link module:clipboard/clipboardobserver~ClipboardObserver}
- * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/document~Document#addObserver} method.
+ * needs to be added to {@link module:engine/view/document~Document} by the {@link module:engine/view/view~View#addObserver} method.
  * It's done by the {@link module:clipboard/clipboard~Clipboard} feature. If it's not loaded, it must be done manually.
  *
  * @see module:clipboard/clipboardobserver~ClipboardObserver

+ 1 - 1
packages/ckeditor5-clipboard/src/datatransfer.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 1 - 1
packages/ckeditor5-clipboard/src/utils/normalizeclipboarddata.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 1 - 1
packages/ckeditor5-clipboard/src/utils/plaintexttohtml.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 1 - 1
packages/ckeditor5-clipboard/src/utils/viewtoplaintext.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 59 - 53
packages/ckeditor5-clipboard/tests/clipboard.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
@@ -23,7 +23,7 @@ import ViewDocumentFragment from '@ckeditor/ckeditor5-engine/src/view/documentfr
 import ViewText from '@ckeditor/ckeditor5-engine/src/view/text';
 
 describe( 'Clipboard feature', () => {
-	let editor, editingView, clipboardPlugin, scrollSpy;
+	let editor, view, viewDocument, clipboardPlugin, scrollSpy;
 
 	beforeEach( () => {
 		return VirtualTestEditor
@@ -32,18 +32,19 @@ describe( 'Clipboard feature', () => {
 			} )
 			.then( newEditor => {
 				editor = newEditor;
-				editingView = editor.editing.view;
+				view = editor.editing.view;
+				viewDocument = editor.editing.view.document;
 				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' );
+				scrollSpy = sinon.stub( view, 'scrollToTheSelection' );
 			} );
 	} );
 
 	describe( 'constructor()', () => {
 		it( 'registers ClipboardObserver', () => {
-			expect( editingView.getObserver( ClipboardObserver ) ).to.be.instanceOf( ClipboardObserver );
+			expect( view.getObserver( ClipboardObserver ) ).to.be.instanceOf( ClipboardObserver );
 		} );
 	} );
 
@@ -53,14 +54,14 @@ describe( 'Clipboard feature', () => {
 				const dataTransferMock = createDataTransfer( { 'text/html': '<p>x</p>', 'text/plain': 'y' } );
 				const preventDefaultSpy = sinon.spy();
 
-				editingView.on( 'clipboardInput', ( evt, data ) => {
+				viewDocument.on( 'clipboardInput', ( evt, data ) => {
 					expect( preventDefaultSpy.calledOnce ).to.be.true;
 					expect( data.dataTransfer ).to.equal( dataTransferMock );
 
 					done();
 				} );
 
-				editingView.fire( 'paste', {
+				viewDocument.fire( 'paste', {
 					dataTransfer: dataTransferMock,
 					preventDefault: preventDefaultSpy
 				} );
@@ -77,7 +78,7 @@ describe( 'Clipboard feature', () => {
 					done();
 				} );
 
-				editingView.fire( 'paste', {
+				viewDocument.fire( 'paste', {
 					dataTransfer: dataTransferMock,
 					preventDefault: preventDefaultSpy
 				} );
@@ -89,14 +90,14 @@ describe( 'Clipboard feature', () => {
 				const dataTransferMock = createDataTransfer( { 'text/plain': 'x\n\ny  z' } );
 				const preventDefaultSpy = sinon.spy();
 
-				editingView.on( 'clipboardInput', ( evt, data ) => {
+				viewDocument.on( 'clipboardInput', ( evt, data ) => {
 					expect( preventDefaultSpy.calledOnce ).to.be.true;
 					expect( data.dataTransfer ).to.equal( dataTransferMock );
 
 					done();
 				} );
 
-				editingView.fire( 'paste', {
+				viewDocument.fire( 'paste', {
 					dataTransfer: dataTransferMock,
 					preventDefault: preventDefaultSpy
 				} );
@@ -113,7 +114,7 @@ describe( 'Clipboard feature', () => {
 					done();
 				} );
 
-				editingView.fire( 'paste', {
+				viewDocument.fire( 'paste', {
 					dataTransfer: dataTransferMock,
 					preventDefault: preventDefaultSpy
 				} );
@@ -125,7 +126,7 @@ describe( 'Clipboard feature', () => {
 			const preventDefaultSpy = sinon.spy();
 			const editorViewCalled = sinon.spy();
 
-			editingView.on( 'clipboardInput', ( evt, data ) => {
+			viewDocument.on( 'clipboardInput', ( evt, data ) => {
 				expect( preventDefaultSpy.calledOnce ).to.be.true;
 
 				expect( data.dataTransfer ).to.equal( dataTransferMock );
@@ -142,7 +143,7 @@ describe( 'Clipboard feature', () => {
 				done();
 			} );
 
-			editingView.fire( 'paste', {
+			viewDocument.fire( 'paste', {
 				dataTransfer: dataTransferMock,
 				preventDefault: preventDefaultSpy
 			} );
@@ -152,13 +153,13 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': 'x' } );
 			const spy = sinon.spy();
 
-			editingView.on( 'paste', evt => {
+			viewDocument.on( 'paste', evt => {
 				evt.stop();
 			} );
 
-			editingView.on( 'clipboardInput', spy );
+			viewDocument.on( 'clipboardInput', spy );
 
-			editingView.fire( 'paste', {
+			viewDocument.fire( 'paste', {
 				dataTransfer: dataTransferMock,
 				preventDefault() {}
 			} );
@@ -168,9 +169,9 @@ describe( 'Clipboard feature', () => {
 
 		it( 'inserts content to the editor', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': '<p>x</p>', 'text/plain': 'y' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
-			editingView.fire( 'paste', {
+			viewDocument.fire( 'paste', {
 				dataTransfer: dataTransferMock,
 				preventDefault() {}
 			} );
@@ -181,11 +182,11 @@ describe( 'Clipboard feature', () => {
 
 		it( 'does not insert content when editor is read-only', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': '<p>x</p>', 'text/plain': 'y' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
 			editor.isReadOnly = true;
 
-			editingView.fire( 'paste', {
+			viewDocument.fire( 'paste', {
 				dataTransfer: dataTransferMock,
 				preventDefault() {}
 			} );
@@ -197,9 +198,9 @@ describe( 'Clipboard feature', () => {
 			// Whole content is invalid. Even though there is "view" content, the "model" content would be empty.
 			// Do not insert content in this case.
 			const dataTransferMock = createDataTransfer( { 'text/html': '<unknownTag></unknownTag>', 'text/plain': '' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
-			editingView.fire( 'paste', {
+			viewDocument.fire( 'paste', {
 				dataTransfer: dataTransferMock,
 				preventDefault() {}
 			} );
@@ -211,9 +212,9 @@ describe( 'Clipboard feature', () => {
 			// It's enough if we check this here with a text node and paragraph because if the conversion was made
 			// in a normal root, then text or paragraph wouldn't be allowed here.
 			const dataTransferMock = createDataTransfer( { 'text/html': 'x<p>y</p>', 'text/plain': 'z' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
-			editingView.fire( 'paste', {
+			viewDocument.fire( 'paste', {
 				dataTransfer: dataTransferMock,
 				preventDefault() {}
 			} );
@@ -224,9 +225,9 @@ describe( 'Clipboard feature', () => {
 
 		it( 'does nothing when pasted content is empty', () => {
 			const dataTransferMock = createDataTransfer( { 'text/plain': '' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
-			editingView.fire( 'clipboardInput', {
+			viewDocument.fire( 'clipboardInput', {
 				dataTransfer: dataTransferMock,
 				content: new ViewDocumentFragment()
 			} );
@@ -240,7 +241,7 @@ describe( 'Clipboard feature', () => {
 
 			clipboardPlugin.on( 'inputTransformation', inputTransformationSpy );
 
-			editingView.fire( 'clipboardInput', {
+			viewDocument.fire( 'clipboardInput', {
 				dataTransfer: dataTransferMock,
 				content: new ViewDocumentFragment()
 			} );
@@ -251,13 +252,13 @@ describe( 'Clipboard feature', () => {
 
 		it( 'uses low priority observer for the clipboardInput event', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': 'x' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
-			editingView.on( 'clipboardInput', evt => {
+			viewDocument.on( 'clipboardInput', evt => {
 				evt.stop();
 			} );
 
-			editingView.fire( 'paste', {
+			viewDocument.fire( 'paste', {
 				dataTransfer: dataTransferMock,
 				preventDefault() {}
 			} );
@@ -279,9 +280,9 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer();
 			const preventDefaultSpy = sinon.spy();
 
-			setModelData( editor.document, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
+			setModelData( editor.model, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
 
-			editingView.on( 'clipboardOutput', ( evt, data ) => {
+			viewDocument.on( 'clipboardOutput', ( evt, data ) => {
 				expect( preventDefaultSpy.calledOnce ).to.be.true;
 				expect( data.method ).to.equal( 'copy' );
 
@@ -293,7 +294,7 @@ describe( 'Clipboard feature', () => {
 				done();
 			} );
 
-			editingView.fire( 'copy', {
+			viewDocument.fire( 'copy', {
 				dataTransfer: dataTransferMock,
 				preventDefault: preventDefaultSpy
 			} );
@@ -303,15 +304,15 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer();
 			const preventDefaultSpy = sinon.spy();
 
-			setModelData( editor.document, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
+			setModelData( editor.model, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
 
-			editingView.on( 'clipboardOutput', ( evt, data ) => {
+			viewDocument.on( 'clipboardOutput', ( evt, data ) => {
 				expect( data.method ).to.equal( 'cut' );
 
 				done();
 			} );
 
-			editingView.fire( 'cut', {
+			viewDocument.fire( 'cut', {
 				dataTransfer: dataTransferMock,
 				preventDefault: preventDefaultSpy
 			} );
@@ -322,12 +323,12 @@ describe( 'Clipboard feature', () => {
 			const preventDefaultSpy = sinon.spy();
 			const spy = sinon.spy();
 
-			setModelData( editor.document, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
+			setModelData( editor.model, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
 			editor.isReadOnly = true;
 
-			editingView.on( 'clipboardOutput', spy );
+			viewDocument.on( 'clipboardOutput', spy );
 
-			editingView.fire( 'cut', {
+			viewDocument.fire( 'cut', {
 				dataTransfer: dataTransferMock,
 				preventDefault: preventDefaultSpy
 			} );
@@ -340,13 +341,13 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer();
 			const spy = sinon.spy();
 
-			editingView.on( 'copy', evt => {
+			viewDocument.on( 'copy', evt => {
 				evt.stop();
 			} );
 
-			editingView.on( 'clipboardOutput', spy );
+			viewDocument.on( 'clipboardOutput', spy );
 
-			editingView.fire( 'copy', {
+			viewDocument.fire( 'copy', {
 				dataTransfer: dataTransferMock,
 				preventDefault() {}
 			} );
@@ -395,7 +396,7 @@ describe( 'Clipboard feature', () => {
 					'<figcaption>caption</figcaption>' +
 				'</figure>';
 
-			editingView.fire( 'clipboardOutput', {
+			viewDocument.fire( 'clipboardOutput', {
 				dataTransfer: dataTransferMock,
 				content: parseView( input ),
 				method: 'copy'
@@ -442,7 +443,7 @@ describe( 'Clipboard feature', () => {
 				'image foo\n' +
 				'caption';
 
-			editingView.fire( 'clipboardOutput', {
+			viewDocument.fire( 'clipboardOutput', {
 				dataTransfer: dataTransferMock,
 				content: parseView( input ),
 				method: 'copy'
@@ -454,7 +455,7 @@ describe( 'Clipboard feature', () => {
 		it( 'does not set clipboard HTML data if content is empty', () => {
 			const dataTransferMock = createDataTransfer();
 
-			editingView.fire( 'clipboardOutput', {
+			viewDocument.fire( 'clipboardOutput', {
 				dataTransfer: dataTransferMock,
 				content: new ViewDocumentFragment(),
 				method: 'copy'
@@ -466,25 +467,30 @@ describe( 'Clipboard feature', () => {
 		it( 'deletes selected content in case of cut', () => {
 			const dataTransferMock = createDataTransfer();
 
-			setModelData( editor.document, '<paragraph>f[o</paragraph><paragraph>x]o</paragraph>' );
+			setModelData( editor.model, '<paragraph>f[o</paragraph><paragraph>x]o</paragraph>' );
 
-			editingView.fire( 'clipboardOutput', {
-				dataTransfer: dataTransferMock,
-				content: new ViewDocumentFragment(),
-				method: 'cut'
+			// Change block is only to get writer instance.
+			// Writer should not be passed along this event.
+			editor.model.change( writer => {
+				viewDocument.fire( 'clipboardOutput', {
+					dataTransfer: dataTransferMock,
+					content: new ViewDocumentFragment(),
+					method: 'cut',
+					writer
+				} );
 			} );
 
-			expect( getModelData( editor.document ) ).to.equal( '<paragraph>f[]o</paragraph>' );
+			expect( getModelData( editor.model ) ).to.equal( '<paragraph>f[]o</paragraph>' );
 		} );
 
 		it( 'uses low priority observer for the clipboardOutput event', () => {
 			const dataTransferMock = createDataTransfer();
 
-			editingView.on( 'clipboardOutput', evt => {
+			viewDocument.on( 'clipboardOutput', evt => {
 				evt.stop();
 			} );
 
-			editingView.fire( 'copy', {
+			viewDocument.fire( 'copy', {
 				dataTransfer: dataTransferMock,
 				content: new ViewDocumentFragment( [ new ViewText( 'abc' ) ] ),
 				preventDefault() {}

+ 16 - 13
packages/ckeditor5-clipboard/tests/clipboardobserver.js

@@ -1,35 +1,38 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
 /* globals document */
 
 import ClipboardObserver from '../src/clipboardobserver';
-import Document from '@ckeditor/ckeditor5-engine/src/view/document';
-import Element from '@ckeditor/ckeditor5-engine/src/view/element';
+import View from '@ckeditor/ckeditor5-engine/src/view/view';
+import Writer from '@ckeditor/ckeditor5-engine/src/view/writer';
 import Range from '@ckeditor/ckeditor5-engine/src/view/range';
 import Position from '@ckeditor/ckeditor5-engine/src/view/position';
 import DataTransfer from '../src/datatransfer';
+import createViewRoot from '@ckeditor/ckeditor5-engine/tests/view/_utils/createroot';
 
 describe( 'ClipboardObserver', () => {
-	let doc, observer, root, el, range, eventSpy, preventDefaultSpy;
+	let view, doc, writer, observer, root, el, range, eventSpy, preventDefaultSpy;
 
 	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'div' );
+		view = new View();
+		doc = view.document;
+		writer = new Writer( doc );
+		root = createViewRoot( doc );
 
 		// Create view and DOM structures.
-		el = new Element( 'p' );
-		root.appendChildren( el );
-		doc.domConverter.viewToDom( root, document, { withChildren: true, bind: true } );
+		el = writer.createContainerElement( 'p' );
+		writer.insert( Position.createAt( root ), el );
+		view.domConverter.viewToDom( root, document, { withChildren: true, bind: true } );
 
-		doc.selection.setCollapsedAt( el );
+		doc.selection._setTo( el, 0 );
 		range = new Range( new Position( root, 1 ) );
 		// Just making sure that the following tests will check anything.
 		expect( range.isEqual( doc.selection.getFirstRange() ) ).to.be.false;
 
-		observer = doc.addObserver( ClipboardObserver );
+		observer = view.addObserver( ClipboardObserver );
 
 		eventSpy = sinon.spy();
 		preventDefaultSpy = sinon.spy();
@@ -117,7 +120,7 @@ describe( 'ClipboardObserver', () => {
 		it( 'should be fired with the right event data – dropRange (when document.caretRangeFromPoint present)', () => {
 			let caretRangeFromPointCalledWith;
 
-			const domRange = doc.domConverter.viewRangeToDom( range );
+			const domRange = view.domConverter.viewRangeToDom( range );
 			const dataTransfer = mockDomDataTransfer();
 			const targetElement = mockDomTargetElement( {
 				caretRangeFromPoint( x, y ) {
@@ -147,7 +150,7 @@ describe( 'ClipboardObserver', () => {
 		} );
 
 		it( 'should be fired with the right event data – dropRange (when evt.rangeParent|Offset present)', () => {
-			const domRange = doc.domConverter.viewRangeToDom( range );
+			const domRange = view.domConverter.viewRangeToDom( range );
 			const dataTransfer = mockDomDataTransfer();
 			const targetElement = mockDomTargetElement( {
 				createRange() {

+ 1 - 1
packages/ckeditor5-clipboard/tests/datatransfer.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 8 - 7
packages/ckeditor5-clipboard/tests/manual/copycut.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
@@ -13,22 +13,23 @@ import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-u
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [ ArticlePluginSet ],
-		toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
+		toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
 	} )
 	.then( editor => {
 		window.editor = editor;
+		const viewDocument = editor.editing.view.document;
 		const clipboard = editor.plugins.get( 'Clipboard' );
 
-		editor.editing.view.on( 'paste', ( evt, data ) => {
+		viewDocument.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' } );
+		viewDocument.on( 'paste', onViewEvent );
+		viewDocument.on( 'copy', onViewEvent, { priority: 'lowest' } );
+		viewDocument.on( 'cut', onViewEvent, { priority: 'lowest' } );
 
 		clipboard.on( 'inputTransformation', onPipelineEvent );
-		editor.editing.view.on( 'clipboardOutput', ( evt, data ) => {
+		viewDocument.on( 'clipboardOutput', ( evt, data ) => {
 			console.clear();
 			onPipelineEvent( evt, data );
 		} );

+ 8 - 11
packages/ckeditor5-clipboard/tests/manual/dropping.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
@@ -7,22 +7,19 @@
 
 import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
-
-import Text from '@ckeditor/ckeditor5-engine/src/model/text';
-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: [ ArticlePluginSet ],
-		toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
+		toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
 	} )
 	.then( editor => {
 		window.editor = editor;
+		const viewDocument = editor.editing.view.document;
 		// const clipboard = editor.plugins.get( 'Clipboard' );
 
-		editor.editing.view.on( 'drop', ( evt, data ) => {
+		viewDocument.on( 'drop', ( evt, data ) => {
 			console.clear();
 
 			console.log( '----- drop -----' );
@@ -33,10 +30,10 @@ ClassicEditor
 			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 );
+			editor.model.change( writer => {
+				const dropRange = editor.editing.mapper.toModelRange( data.dropRange );
+				writer.insert( writer.createText( '@' ), dropRange.start );
+				writer.setSelection( dropRange );
 			} );
 		} );
 

+ 3 - 3
packages/ckeditor5-clipboard/tests/manual/pasting.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
@@ -13,13 +13,13 @@ import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-u
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [ ArticlePluginSet ],
-		toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'undo', 'redo' ]
+		toolbar: [ 'heading', '|', '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 ) => {
+		editor.editing.view.document.on( 'paste', ( evt, data ) => {
 			console.clear();
 
 			console.log( '----- paste -----' );

+ 22 - 29
packages/ckeditor5-clipboard/tests/pasting-integration.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 
@@ -34,11 +34,11 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, 'x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y' );
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
 							'<$text linkHref="x">link</$text> y[]' +
@@ -53,11 +53,11 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, '<p>x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y</p>' );
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
 							'<$text linkHref="x">link</$text> y[]' +
@@ -72,11 +72,11 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, '<div>x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y</div>' );
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
 							'<$text linkHref="x">link</$text> y[]' +
@@ -91,26 +91,19 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, BlockQuote, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, '<blockquote>x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y</blockquote>' );
 
-					expect( getData( editor.document ) ).to.equal(
-						'<blockQuote><paragraph>x bold italic link y[]</paragraph></blockQuote>'
+					expect( getData( editor.model ) ).to.equal(
+						'<blockQuote>' +
+							'<paragraph>' +
+								'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
+								'<$text linkHref="x">link</$text> y[]' +
+							'</paragraph>' +
+						'</blockQuote>'
 					);
 
-					// The expected result would be this:
-					//
-					// '<blockQuote>' +
-					// 	'<paragraph>' +
-					// 		'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
-					// 		'<$text linkHref="x">link</$text> y[]' +
-					// 	'</paragraph>' +
-					// '</blockQuote>'
-					//
-					// See https://github.com/ckeditor/ckeditor5/issues/477#issuecomment-310428963.
-					// Although, this may be a deeper problem with ckeditor5-paragraph's wildcard conversion.
-
 					return editor.destroy();
 				} );
 		} );
@@ -122,7 +115,7 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>x[]y</paragraph>' );
+					setData( editor.model, '<paragraph>x[]y</paragraph>' );
 
 					pasteHtml( editor,
 						'<meta charset=\'utf-8\'>' +
@@ -133,7 +126,7 @@ describe( 'Pasting – integration', () => {
 						'<span style="color: rgb(0, 0, 0); font-family: Times;">.</span>'
 					);
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'xThis is the ' +
 							'<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
@@ -150,7 +143,7 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>x[]y</paragraph>' );
+					setData( editor.model, '<paragraph>x[]y</paragraph>' );
 
 					/* eslint-disable max-len */
 					pasteHtml( editor,
@@ -162,7 +155,7 @@ describe( 'Pasting – integration', () => {
 					);
 					/* eslint-enable max-len */
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'xThis is the ' +
 							'<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
@@ -178,7 +171,7 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>x[]y</paragraph>' );
+					setData( editor.model, '<paragraph>x[]y</paragraph>' );
 
 					// Note, when copying the HTML from Firefox's console you'll see only normal spaces,
 					// but when you check it later in the model it's still an nbsp.
@@ -186,7 +179,7 @@ describe( 'Pasting – integration', () => {
 						'This is the <a href="url">third developer preview</a> of <strong>CKEditor\u00a05</strong>.'
 					);
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'xThis is the ' +
 							'<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
@@ -201,7 +194,7 @@ describe( 'Pasting – integration', () => {
 } );
 
 function pasteHtml( editor, html ) {
-	editor.editing.view.fire( 'paste', {
+	editor.editing.view.document.fire( 'paste', {
 		dataTransfer: createDataTransfer( { 'text/html': html } ),
 		preventDefault() {}
 	} );

+ 1 - 1
packages/ckeditor5-clipboard/tests/utils/normalizeclipboarddata.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 1 - 1
packages/ckeditor5-clipboard/tests/utils/plaintexttohtml.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */
 

+ 1 - 1
packages/ckeditor5-clipboard/tests/utils/viewtoplaintext.js

@@ -1,5 +1,5 @@
 /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md.
  */