Przeglądaj źródła

Merge branch 'master' into t/ckeditor5/1151

Aleksander Nowodzinski 6 lat temu
rodzic
commit
e383614da0

+ 1 - 3
packages/ckeditor5-core/.travis.yml

@@ -28,6 +28,4 @@ after_script:
 - ckeditor5-dev-tests-notify-travis-status
 - ckeditor5-dev-tests-notify-travis-status
 env:
 env:
   global:
   global:
-  - secure: uJiLhULzhBDdkuQrYW7k7H4l4HizyfCdnV9ORe2HXyNnWFnFfAhc2vD1FQ5182ldQXtUQMX51gM/YL5r1Sa2IO3EW/j0gyuznqYvM8KX4lU1hXUAap1ZHW7Zb/leVQfU76IH688rkGcpr2SwCG6/LglqunozwhyePuxBzH23whSrf5dGXjswnMUAjouavtm+YybPZY81uj181aFY7nbcWOCUkx7FGaIg5WqG27kkYuUCVDw977hlwSevL6K1AF1OMtfHTAt4NR2oRKtpcRsrBlVNFFCraVa+3E1DN/kcEMaNDFJ4737Zta6jK9irGdfOwvtt1t4Og2fWKtUNCix2Almjiu0t58miuHhZenB4xRm4kpnc5nzfu0x/Ur4R95OHbKMf/6Zvvd/2v4bHe0iFihZXB8qiXvqZwqVyXCH2pWzj+tFztwpvyfj+Z1k4LIuo3shbG9GlK8mSl0OfL9WdSR/g09NBRg1aJtEKsJreensTEO9esJ5dD7JksKo6VsESSAztN4v5xuavtPM+yT2g2vFWpwyY0/6/yxR8hlIo0//24t8be9Lm+G3k1f++Jc6ea8aFYUPF+O6kdZgqD0g2LoAp5e28CjXkMDoq/0l+Ab0obpaMjZlyEZ+S8X+8+kyICpyADmLTWP/Mwmik8ixzABgBz0903w4aExOl8mEi9ws=
-  - secure: tVEuv/7HAhriDudbEP0+30DvPV04pI3XoW3ibHDVdI7qhjtNH4AnYcqJOtI25wZTYr8hUquqkFNM7nl4sSoPPHEgdLL/c9U1bLkmTfQD4l+e6OPL8V2D9qStnSvswDMevtoCAVep+yKU7tDwL+ppNZeC9SX4xigo8MMC0qKhgx/q2CWIOlDVURFbFeEss+RI6nn1nxO+1kyyiZ1O0hyh5Xkn2u9h5ihV3SAeAHfZyvKvhyii74jSjHBHiapKkwUr4WSUkmKwuaqA2OppZXiDf5ah5nbjh1kX8u90jN+1yFH0Aor+M1Qdejs8A5sg9spOU2L0OXlw1wiLj0gzrGEQH6wbTR2T8nyIYYpivnuPUh19WK6FCABCbH3baxJwpZdYrd87Oi2EAPDS8obpNc/fZEj5XrZBVIf8Tk9wvaDrB4JSsyjp8U8G5eKVrY++sRdCTGxpP1W9LJlkVSTW8weX1FWWo6OWnZGo7+Q6xd63wVZ7/dc0TU/h9Ck9ekTeOAU2/to71EnPZzU4Ydv5R/BK1VK0PUIIThosFIvd7UwrnVzmgndovIAfas+XhxgpJCWN+9pXPA46OfFNyYl8naiLdJqCOpl40tWNCE6T8rC60seTUSrDJwGEForCfr3eu2fkl0x5syc7eOimHHECBIGk4dE3TwwIg2kf6PUHMIT433M=
-  - secure: luFopu3v12G0Rn1nCriEa9TeKsghtiDezeFBCQ7pWxlpSDZKjt07x6Sd10h6xR6ixotHFSkiZX+Zsbsu6MAI2PjP1v49PIQkJFm0gyAxC2adVCn9KVf5Q/ag1/gF8Rn9L0MdjG/netiu5vOqTfHnASF953fibc/q53HQpIaKL/8cizipz0L0V8sT6lgCKna+K2OFLQ8wb/RZ6FwmrM+35KzuyxUdcXKUcPmGen6i3cJGeyB5TT2wPe7JYs4mYNuhREI0XzuPR8TsU37KYsl0sR8UTYClUoGVp/abbyHwTxuxlHnW/E1sYArmaFi84Y7bOhLD3P9VR+Ts9imYp38oLgF35FnynkOfL2BZnXzx25eUQXbDb9y6lq1J73ECTt3Iw+G13Y3YmLVGfNRdEq12CgD/V/BqgAkltYCo6AgWWyTPnToI636NqL1c+a4ruVfp6qt082BS+SpduiNIu+x/0OlMPqe+TbEBCxAd7jDN6sfhYAiCUMfUcTAFO4O/drodcyGsqAz6rPtmzDHMfX1sAUsBY9Q0jIhP/8fA+zf4br47Q37Gg8ilCw7sZ4QF+83wi4Z7poIl2U0EG3qhCyj0/V/I/mtJ/2A1ZHzO997NNrT61mqCO2tBFWBgZKrm62NWFItTIk1L7ZnUiUj+tZEyaD8HX0YMam2LJYlLo4BVWOU=
+  - secure: TEv7Uuc8Xcd+AaR8W+s7qt/synWT60kR8/8QNiqBmdFDYC3LNdoI48V8vh8rIbdtYk1u6Ur+6pBLDC1+gMyA6+oAY5SVKdiep7JgJUkYEygCtr4chyiatbZezuKmWs9GxJ8awhZGeFuKNt/jwyVxMqYHDQ1t0Mb4+AyYB60h6o0Mx8IQ4rnmVmcCe45NZNe24a2a2ao5IX3Y3INrdXKBZ780mfDQrCWRa404MZ3ZoVdVeKoEkX3OiuKnsiCDIcKu89IVLRW7mq1kw84G8npDNbddU8sGtS6RdfSZ61M1jp1yHNXi/2/tLQyE0N8UF3bYHy9GzqKC6D4VGLLykGgv+yd95y0arwMMdi2gfrg3nE2Zehu/kuTRwMSBMwkhScZAhixYOjX/AFGd7EAmt4/wfBrNNCs29lCiOUpR7wC1ZSNCMbVxkNlAoI1J/2MoBKALqLdBfYGcH1XwfIwx/w62dqiE/zlnDYgdBursnpa0sGXMau1xAA+5ud+oHwmKTkMjKeszQC5YaWLS+qtTX/y2TnePvbzO8yTJrLDt+8tVAWsbUrWe9Uk+zuLNFxhNVmBbaQD3hhkRIm/ElCQROIA7tGRRyksuG63m1GBWZU6tIeiK6fitdXpgb+UpIru+Qc0p48XAz68zdslJg/4N3wcFuacNNdVqA3ZWd2Rsp8LO7t4=

+ 7 - 0
packages/ckeditor5-core/CHANGELOG.md

@@ -1,6 +1,13 @@
 Changelog
 Changelog
 =========
 =========
 
 
+## [12.1.1](https://github.com/ckeditor/ckeditor5-core/compare/v12.1.0...v12.1.1) (2019-06-05)
+
+### Other changes
+
+* Updated translations. ([ed6bd3c](https://github.com/ckeditor/ckeditor5-core/commit/ed6bd3c)) 
+
+
 ## [12.1.0](https://github.com/ckeditor/ckeditor5-core/compare/v12.0.0...v12.1.0) (2019-04-10)
 ## [12.1.0](https://github.com/ckeditor/ckeditor5-core/compare/v12.0.0...v12.1.0) (2019-04-10)
 
 
 ### Features
 ### Features

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

@@ -4,7 +4,6 @@ CKEditor 5 core editor architecture
 [![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)
 [![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-core.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-core)
 [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-core.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-core)
 [![Build Status](https://travis-ci.org/ckeditor/ckeditor5-core.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-core)
 [![Build Status](https://travis-ci.org/ckeditor/ckeditor5-core.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-core)
-[![BrowserStack Status](https://automate.browserstack.com/automate/badge.svg?badge_key=d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)](https://automate.browserstack.com/public-build/d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)
 [![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-core/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-core?branch=master)
 [![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-core/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-core?branch=master)
 <br>
 <br>
 [![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-core/status.svg)](https://david-dm.org/ckeditor/ckeditor5-core)
 [![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-core/status.svg)](https://david-dm.org/ckeditor/ckeditor5-core)
@@ -20,4 +19,4 @@ Additionally, see the [`@ckeditor/ckeditor5-core` package](https://ckeditor.com/
 
 
 ## License
 ## License
 
 
-Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file.
+Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file or [https://ckeditor.com/legal/ckeditor-oss-license](https://ckeditor.com/legal/ckeditor-oss-license).

+ 25 - 0
packages/ckeditor5-core/lang/translations/lt.po

@@ -0,0 +1,25 @@
+# Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+#
+#                                     !!! IMPORTANT !!!
+#
+#         Before you edit this file, please keep in mind that contributing to the project
+#                translations is possible ONLY via the Transifex online service.
+#
+#         To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
+#
+#                   To learn more, check out the official contributor's guide:
+#     https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
+#
+msgid ""
+msgstr ""
+"Language-Team: Lithuanian (https://www.transifex.com/ckeditor/teams/11143/lt/)\n"
+"Language: lt\n"
+"Plural-Forms: nplurals=4; plural=(n % 10 == 1 && (n % 100 > 19 || n % 100 < 11) ? 0 : (n % 10 >= 2 && n % 10 <=9) && (n % 100 > 19 || n % 100 < 11) ? 1 : n % 1 != 0 ? 2: 3);\n"
+
+msgctxt "Label for the Save button."
+msgid "Save"
+msgstr "Išsaugoti"
+
+msgctxt "Label for the Cancel button."
+msgid "Cancel"
+msgstr "Atšaukti"

+ 16 - 16
packages/ckeditor5-core/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "@ckeditor/ckeditor5-core",
   "name": "@ckeditor/ckeditor5-core",
-  "version": "12.1.0",
+  "version": "12.1.1",
   "description": "The core architecture of CKEditor 5 – the best browser-based rich text editor.",
   "description": "The core architecture of CKEditor 5 – the best browser-based rich text editor.",
   "keywords": [
   "keywords": [
     "ckeditor5-lib",
     "ckeditor5-lib",
@@ -21,24 +21,24 @@
     "framework"
     "framework"
   ],
   ],
   "dependencies": {
   "dependencies": {
-    "@ckeditor/ckeditor5-engine": "^13.1.0",
-    "@ckeditor/ckeditor5-utils": "^12.1.0",
+    "@ckeditor/ckeditor5-engine": "^13.1.1",
+    "@ckeditor/ckeditor5-utils": "^12.1.1",
     "lodash-es": "^4.17.10"
     "lodash-es": "^4.17.10"
   },
   },
   "devDependencies": {
   "devDependencies": {
-    "@ckeditor/ckeditor5-autoformat": "^11.0.1",
-    "@ckeditor/ckeditor5-basic-styles": "^11.1.0",
-    "@ckeditor/ckeditor5-block-quote": "^11.0.1",
-    "@ckeditor/ckeditor5-editor-classic": "^12.1.0",
-    "@ckeditor/ckeditor5-essentials": "^11.0.1",
-    "@ckeditor/ckeditor5-heading": "^11.0.1",
-    "@ckeditor/ckeditor5-image": "^13.0.1",
-    "@ckeditor/ckeditor5-link": "^11.0.1",
-    "@ckeditor/ckeditor5-list": "^12.0.1",
-    "@ckeditor/ckeditor5-media-embed": "^11.1.0",
-    "@ckeditor/ckeditor5-paragraph": "^11.0.1",
-    "@ckeditor/ckeditor5-table": "^12.0.1",
-    "@ckeditor/ckeditor5-ui": "^12.1.0",
+    "@ckeditor/ckeditor5-autoformat": "^11.0.2",
+    "@ckeditor/ckeditor5-basic-styles": "^11.1.1",
+    "@ckeditor/ckeditor5-block-quote": "^11.1.0",
+    "@ckeditor/ckeditor5-editor-classic": "^12.1.1",
+    "@ckeditor/ckeditor5-essentials": "^11.0.2",
+    "@ckeditor/ckeditor5-heading": "^11.0.2",
+    "@ckeditor/ckeditor5-image": "^13.1.0",
+    "@ckeditor/ckeditor5-link": "^11.0.2",
+    "@ckeditor/ckeditor5-list": "^12.0.2",
+    "@ckeditor/ckeditor5-media-embed": "^11.1.1",
+    "@ckeditor/ckeditor5-paragraph": "^11.0.2",
+    "@ckeditor/ckeditor5-table": "^13.0.0",
+    "@ckeditor/ckeditor5-ui": "^13.0.0",
     "eslint": "^5.5.0",
     "eslint": "^5.5.0",
     "eslint-config-ckeditor5": "^1.0.11",
     "eslint-config-ckeditor5": "^1.0.11",
     "husky": "^1.3.1",
     "husky": "^1.3.1",

+ 16 - 0
packages/ckeditor5-core/src/editor/editor.js

@@ -312,6 +312,22 @@ mix( Editor, ObservableMixin );
  * @event destroy
  * @event destroy
  */
  */
 
 
+/**
+ * This error is thrown when a user tries to use a `<textarea>` element to create a non-classic editor in it.
+ *
+ * Textarea element represents a plain-text and cannot be used as a editable root element with included CKEditor5.
+ * Content of an editor should be nicely present to the user and show him how it's going to looks like. Textarea element
+ * doesn't support such behavior.
+ *
+ * Only {@glink builds/guides/overview#classic-editor Classic Editor} has implemented a special system, which
+ * **replace** DOM element and load data from it
+ * ({@link module:editor-classic/classiceditor~ClassicEditor.create more information}). All other editors
+ * use an existing element, load data from it and make this element editable. Details about behaviour of each editor
+ * might be found in an associated description of a `create` method of each editor.
+ *
+ * @error editor-wrong-element
+ */
+
 /**
 /**
  * An array of plugins built into this editor class.
  * An array of plugins built into this editor class.
  * It is used in CKEditor 5 builds to provide a list of plugins which are later automatically initialized
  * It is used in CKEditor 5 builds to provide a list of plugins which are later automatically initialized

+ 4 - 4
packages/ckeditor5-core/src/editor/editorconfig.jsdoc

@@ -33,10 +33,10 @@
 /**
 /**
  * The initial editor data to be used instead of the provided element's HTML content.
  * The initial editor data to be used instead of the provided element's HTML content.
  *
  *
- *      ClassicEditor
- *          .create( document.querySelector( '#editor' ), {
- *              initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
- *          } )
+ *		ClassicEditor
+ *			.create( document.querySelector( '#editor' ), {
+ *				initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
+ *			} )
  *			.then( ... )
  *			.then( ... )
  *			.catch( ... );
  *			.catch( ... );
  *
  *

+ 58 - 4
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -10,6 +10,7 @@ import ClassicTestEditor from '../../tests/_utils/classictesteditor';
 
 
 import Plugin from '../../src/plugin';
 import Plugin from '../../src/plugin';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import EditorUI from '../../src/editor/editorui';
 import EditorUI from '../../src/editor/editorui';
 import BoxedEditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/boxed/boxededitoruiview';
 import BoxedEditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/boxed/boxededitoruiview';
@@ -21,6 +22,7 @@ import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 
 
 import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import testUtils from '../../tests/_utils/utils';
 import testUtils from '../../tests/_utils/utils';
+import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
 
 describe( 'ClassicTestEditor', () => {
 describe( 'ClassicTestEditor', () => {
 	let editorElement;
 	let editorElement;
@@ -32,13 +34,17 @@ describe( 'ClassicTestEditor', () => {
 		document.body.appendChild( editorElement );
 		document.body.appendChild( editorElement );
 	} );
 	} );
 
 
+	afterEach( () => {
+		editorElement.remove();
+	} );
+
 	describe( 'constructor()', () => {
 	describe( 'constructor()', () => {
 		it( 'creates an instance of editor', () => {
 		it( 'creates an instance of editor', () => {
 			const editor = new ClassicTestEditor( editorElement, { foo: 1 } );
 			const editor = new ClassicTestEditor( editorElement, { foo: 1 } );
 
 
 			expect( editor ).to.be.instanceof( Editor );
 			expect( editor ).to.be.instanceof( Editor );
 			expect( editor.config.get( 'foo' ) ).to.equal( 1 );
 			expect( editor.config.get( 'foo' ) ).to.equal( 1 );
-			expect( editor.element ).to.equal( editorElement );
+			expect( editor.sourceElement ).to.equal( editorElement );
 			expect( editor.ui ).to.be.instanceOf( EditorUI );
 			expect( editor.ui ).to.be.instanceOf( EditorUI );
 			expect( editor.ui.view ).to.be.instanceOf( BoxedEditorUIView );
 			expect( editor.ui.view ).to.be.instanceOf( BoxedEditorUIView );
 			expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
 			expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
@@ -82,7 +88,7 @@ describe( 'ClassicTestEditor', () => {
 					expect( editor ).to.be.instanceof( ClassicTestEditor );
 					expect( editor ).to.be.instanceof( ClassicTestEditor );
 
 
 					expect( editor.config.get( 'foo' ) ).to.equal( 1 );
 					expect( editor.config.get( 'foo' ) ).to.equal( 1 );
-					expect( editor ).to.have.property( 'element', editorElement );
+					expect( editor.sourceElement ).to.equal( editorElement );
 				} );
 				} );
 		} );
 		} );
 
 
@@ -175,6 +181,54 @@ describe( 'ClassicTestEditor', () => {
 					return editor.destroy();
 					return editor.destroy();
 				} );
 				} );
 		} );
 		} );
+
+		it( 'initializes the data controller with `config.initialData` if this option is provided', () => {
+			return ClassicTestEditor.create( editorElement, { initialData: '<p>foo</p>', plugins: [ Paragraph ] } )
+				.then( editor => {
+					expect( editor.getData() ).to.equal( '<p>foo</p>' );
+
+					return editor.destroy();
+				} );
+		} );
+
+		it( 'initializes the data controller with an empty string if the `config.initialData` is not provided', () => {
+			return ClassicTestEditor.create( editorElement )
+				.then( editor => {
+					expect( editor.getData() ).to.equal( '' );
+
+					return editor.destroy();
+				} );
+		} );
+
+		it( 'initializes the data controller with the data from the source element', () => {
+			editorElement.innerHTML = '<p>foo</p>';
+
+			return ClassicTestEditor.create( editorElement, { plugins: [ Paragraph ] } )
+				.then( editor => {
+					expect( editor.getData() ).to.equal( '<p>foo</p>' );
+
+					return editor.destroy();
+				} );
+		} );
+
+		it( 'initializes the data controller with the data from the first argument if it is a string', () => {
+			return ClassicTestEditor.create( '<p>foo</p>', { plugins: [ Paragraph ] } )
+				.then( editor => {
+					expect( editor.getData() ).to.equal( '<p>foo</p>' );
+
+					return editor.destroy();
+				} );
+		} );
+
+		it( 'throws when the data is passed from as the first argument and as a `config.initialData` at the same time', () => {
+			return ClassicTestEditor.create( '<p>foo</p>', { initialData: '<p>bar</p>' } )
+				.then( () => {
+					throw new Error( 'It should throw an error' );
+				}, err => {
+					expect( err.message ).to.match( /^editor-create-initial-data:/ );
+					expect( err ).to.be.instanceOf( CKEditorError );
+				} );
+		} );
 	} );
 	} );
 
 
 	describe( 'destroy()', () => {
 	describe( 'destroy()', () => {
@@ -195,11 +249,11 @@ describe( 'ClassicTestEditor', () => {
 		it( 'restores the editor element', () => {
 		it( 'restores the editor element', () => {
 			return ClassicTestEditor.create( editorElement, { foo: 1 } )
 			return ClassicTestEditor.create( editorElement, { foo: 1 } )
 				.then( editor => {
 				.then( editor => {
-					expect( editor.element.style.display ).to.equal( 'none' );
+					expect( editor.sourceElement.style.display ).to.equal( 'none' );
 
 
 					return editor.destroy()
 					return editor.destroy()
 						.then( () => {
 						.then( () => {
-							expect( editor.element.style.display ).to.equal( '' );
+							expect( editor.sourceElement.style.display ).to.equal( '' );
 						} );
 						} );
 				} );
 				} );
 		} );
 		} );

+ 17 - 0
packages/ckeditor5-core/tests/_utils-tests/virtualtesteditor.js

@@ -9,6 +9,7 @@ import VirtualTestEditor from '../../tests/_utils/virtualtesteditor';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import DataApiMixin from '../../src/editor/utils/dataapimixin';
 import DataApiMixin from '../../src/editor/utils/dataapimixin';
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import testUtils from '../../tests/_utils/utils';
 import testUtils from '../../tests/_utils/utils';
 
 
@@ -34,4 +35,20 @@ describe( 'VirtualTestEditor', () => {
 			expect( testUtils.isMixed( VirtualTestEditor, DataApiMixin ) ).to.true;
 			expect( testUtils.isMixed( VirtualTestEditor, DataApiMixin ) ).to.true;
 		} );
 		} );
 	} );
 	} );
+
+	describe( 'static create()', () => {
+		it( 'initializes the data controller with the `config.initialData`', () => {
+			return VirtualTestEditor.create( { initialData: '<p>foo</p>', plugins: [ Paragraph ] } )
+				.then( editor => {
+					expect( editor.getData() ).to.equal( '<p>foo</p>' );
+				} );
+		} );
+
+		it( 'initializes the data controller with an empty string if the `config.initialData` is not provided', () => {
+			return VirtualTestEditor.create()
+				.then( editor => {
+					expect( editor.getData() ).to.equal( '' );
+				} );
+		} );
+	} );
 } );
 } );

+ 43 - 15
packages/ckeditor5-core/tests/_utils/classictesteditor.js

@@ -13,6 +13,8 @@ import ElementReplacer from '@ckeditor/ckeditor5-utils/src/elementreplacer';
 import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
 import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
 import getDataFromElement from '@ckeditor/ckeditor5-utils/src/dom/getdatafromelement';
 import getDataFromElement from '@ckeditor/ckeditor5-utils/src/dom/getdatafromelement';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
+import { isElement } from 'lodash-es';
+import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
 
 /**
 /**
  * A simplified classic editor. Useful for testing features.
  * A simplified classic editor. Useful for testing features.
@@ -24,51 +26,66 @@ export default class ClassicTestEditor extends Editor {
 	/**
 	/**
 	 * @inheritDoc
 	 * @inheritDoc
 	 */
 	 */
-	constructor( element, config ) {
+	constructor( sourceElementOrData, config ) {
 		super( config );
 		super( config );
 
 
-		// The element on which the editor has been initialized.
-		this.element = element;
+		if ( isElement( sourceElementOrData ) ) {
+			this.sourceElement = sourceElementOrData;
+		}
 
 
 		// Use the HTML data processor in this editor.
 		// Use the HTML data processor in this editor.
 		this.data.processor = new HtmlDataProcessor();
 		this.data.processor = new HtmlDataProcessor();
 
 
+		// Create the ("main") root element of the model tree.
+		this.model.document.createRoot();
+
 		this.ui = new ClassicTestEditorUI( this, new BoxedEditorUIView( this.locale ) );
 		this.ui = new ClassicTestEditorUI( this, new BoxedEditorUIView( this.locale ) );
 
 
 		// Expose properties normally exposed by the ClassicEditorUI.
 		// Expose properties normally exposed by the ClassicEditorUI.
 		this.ui.view.editable = new InlineEditableUIView( this.ui.view.locale, this.editing.view );
 		this.ui.view.editable = new InlineEditableUIView( this.ui.view.locale, this.editing.view );
-
-		// Create the ("main") root element of the model tree.
-		this.model.document.createRoot();
 	}
 	}
 
 
 	/**
 	/**
 	 * @inheritDoc
 	 * @inheritDoc
 	 */
 	 */
 	destroy() {
 	destroy() {
+		if ( this.sourceElement ) {
+			this.updateSourceElement();
+		}
+
 		this.ui.destroy();
 		this.ui.destroy();
 
 
 		return super.destroy();
 		return super.destroy();
 	}
 	}
 
 
 	/**
 	/**
-	 * @inheritDoc
+	 * @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor
+	 * or the editor's initial data.
+	 * @param {module:core/editor/editorconfig~EditorConfig} [config] The editor configuration.
+	 * @returns {Promise} A promise resolved once the editor is ready. The promise resolves with the created editor instance.
 	 */
 	 */
-	static create( element, config ) {
+	static create( sourceElementOrData, config = {} ) {
 		return new Promise( resolve => {
 		return new Promise( resolve => {
-			const editor = new this( element, config );
+			const editor = new this( sourceElementOrData, config );
 
 
 			resolve(
 			resolve(
 				editor.initPlugins()
 				editor.initPlugins()
 					// Simulate EditorUI.init() (e.g. like in ClassicEditorUI). The ui#view
 					// Simulate EditorUI.init() (e.g. like in ClassicEditorUI). The ui#view
 					// should be rendered after plugins are initialized.
 					// should be rendered after plugins are initialized.
-					.then( () => editor.ui.init( element ) )
+					.then( () => editor.ui.init( isElement( sourceElementOrData ) ? sourceElementOrData : null ) )
 					.then( () => editor.editing.view.attachDomRoot( editor.ui.getEditableElement() ) )
 					.then( () => editor.editing.view.attachDomRoot( editor.ui.getEditableElement() ) )
-					.then( () => editor.data.init( getDataFromElement( element ) ) )
 					.then( () => {
 					.then( () => {
-						editor.state = 'ready';
-						editor.fire( 'ready' );
+						if ( !isElement( sourceElementOrData ) && config.initialData ) {
+							// Documented in core/editor/editorconfig.jsdoc.
+							throw new CKEditorError(
+								'editor-create-initial-data: ' +
+								'The config.initialData option cannot be used together with initial data passed in Editor.create().'
+							);
+						}
+
+						editor.data.init( config.initialData || getInitialData( sourceElementOrData ) );
 					} )
 					} )
+					.then( () => editor.fire( 'ready' ) )
 					.then( () => editor )
 					.then( () => editor )
 			);
 			);
 		} );
 		} );
@@ -104,7 +121,12 @@ class ClassicTestEditorUI extends EditorUI {
 		return this._view;
 		return this._view;
 	}
 	}
 
 
-	init( element ) {
+	/**
+	 * Initializes the UI.
+	 *
+	 * @param {HTMLElement|null} replacementElement The DOM element that will be the source for the created editor.
+	 */
+	init( replacementElement ) {
 		const view = this.view;
 		const view = this.view;
 		const editable = view.editable;
 		const editable = view.editable;
 		const editingView = this.editor.editing.view;
 		const editingView = this.editor.editing.view;
@@ -118,7 +140,9 @@ class ClassicTestEditorUI extends EditorUI {
 
 
 		this._editableElements.set( 'main', view.editable.element );
 		this._editableElements.set( 'main', view.editable.element );
 
 
-		this._elementReplacer.replace( element, view.element );
+		if ( replacementElement ) {
+			this._elementReplacer.replace( replacementElement, view.element );
+		}
 
 
 		this.fire( 'ready' );
 		this.fire( 'ready' );
 	}
 	}
@@ -137,3 +161,7 @@ class ClassicTestEditorUI extends EditorUI {
 
 
 mix( ClassicTestEditor, DataApiMixin );
 mix( ClassicTestEditor, DataApiMixin );
 mix( ClassicTestEditor, ElementApiMixin );
 mix( ClassicTestEditor, ElementApiMixin );
+
+function getInitialData( sourceElementOrData ) {
+	return isElement( sourceElementOrData ) ? getDataFromElement( sourceElementOrData ) : sourceElementOrData;
+}

+ 2 - 1
packages/ckeditor5-core/tests/_utils/memory.js

@@ -30,7 +30,8 @@ const GARBAGE_COLLECTOR_TIMEOUT = 500;
  * @param {Function} callback Callback with test suit body
  * @param {Function} callback Callback with test suit body
  */
  */
 export function describeMemoryUsage( callback ) {
 export function describeMemoryUsage( callback ) {
-	describe( 'memory usage', () => {
+	// Skip all memory tests due to https://github.com/ckeditor/ckeditor5/issues/1731.
+	describe.skip( 'memory usage', () => {
 		skipIfNoGarbageCollector();
 		skipIfNoGarbageCollector();
 
 
 		beforeEach( createEditorElement );
 		beforeEach( createEditorElement );

+ 10 - 10
packages/ckeditor5-core/tests/_utils/utils.js

@@ -49,19 +49,19 @@ const utils = {
 	 *
 	 *
 	 * Usage:
 	 * Usage:
 	 *
 	 *
-	 *      it( 'test', () => {
-	 *          // Test bootstrapping...
+	 *		it( 'test', () => {
+	 *			// Test bootstrapping...
 	 *
 	 *
-	 *          const assertEdge = () => {
-	 *              // expect();
-	 *          };
+	 *			const assertEdge = () => {
+	 *				// expect();
+	 *			};
 	 *
 	 *
-	 *          const assertAll = () => {
-	 *              // expect();
-	 *          };
+	 *			const assertAll = () => {
+	 *				// expect();
+	 *			};
 	 *
 	 *
-	 *          testUtils.checkAssertions( assertEdge, assertAll );
-	 *      } );
+	 *			testUtils.checkAssertions( assertEdge, assertAll );
+	 *		} );
 	 *
 	 *
 	 * @param {...Function} assertions Functions that will be executed.
 	 * @param {...Function} assertions Functions that will be executed.
 	 */
 	 */

+ 3 - 1
packages/ckeditor5-core/tests/_utils/virtualtesteditor.js

@@ -27,13 +27,15 @@ export default class VirtualTestEditor extends Editor {
 		this.model.document.createRoot();
 		this.model.document.createRoot();
 	}
 	}
 
 
-	static create( config ) {
+	static create( config = {} ) {
 		return new Promise( resolve => {
 		return new Promise( resolve => {
 			const editor = new this( config );
 			const editor = new this( config );
 
 
 			resolve(
 			resolve(
 				editor.initPlugins()
 				editor.initPlugins()
 					.then( () => {
 					.then( () => {
+						editor.data.init( config.initialData || '' );
+
 						// Fire `data#ready` event manually as `data#init()` method is not used.
 						// Fire `data#ready` event manually as `data#init()` method is not used.
 						editor.data.fire( 'ready' );
 						editor.data.fire( 'ready' );
 						editor.fire( 'ready' );
 						editor.fire( 'ready' );

+ 20 - 18
packages/ckeditor5-core/tests/plugin.js

@@ -6,33 +6,35 @@
 import Plugin from '../src/plugin';
 import Plugin from '../src/plugin';
 import Editor from '../src/editor/editor';
 import Editor from '../src/editor/editor';
 
 
-let editor;
+describe( 'Plugin', () => {
+	let editor;
 
 
-before( () => {
-	editor = new Editor();
-} );
-
-describe( 'constructor()', () => {
-	it( 'should set the `editor` property', () => {
-		const plugin = new Plugin( editor );
-
-		expect( plugin ).to.have.property( 'editor' ).to.equal( editor );
+	beforeEach( () => {
+		editor = new Editor();
 	} );
 	} );
 
 
-	describe( 'destroy()', () => {
-		it( 'should be defined', () => {
+	describe( 'constructor()', () => {
+		it( 'should set the `editor` property', () => {
 			const plugin = new Plugin( editor );
 			const plugin = new Plugin( editor );
 
 
-			expect( plugin.destroy ).to.be.a( 'function' );
+			expect( plugin ).to.have.property( 'editor' ).to.equal( editor );
 		} );
 		} );
 
 
-		it( 'should stop listening', () => {
-			const plugin = new Plugin( editor );
-			const stopListeningSpy = sinon.spy( plugin, 'stopListening' );
+		describe( 'destroy()', () => {
+			it( 'should be defined', () => {
+				const plugin = new Plugin( editor );
+
+				expect( plugin.destroy ).to.be.a( 'function' );
+			} );
+
+			it( 'should stop listening', () => {
+				const plugin = new Plugin( editor );
+				const stopListeningSpy = sinon.spy( plugin, 'stopListening' );
 
 
-			plugin.destroy();
+				plugin.destroy();
 
 
-			expect( stopListeningSpy.calledOnce ).to.equal( true );
+				expect( stopListeningSpy.calledOnce ).to.equal( true );
+			} );
 		} );
 		} );
 	} );
 	} );
 } );
 } );