|
|
@@ -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,27 +7,30 @@
|
|
|
* @module editor-classic/classiceditor
|
|
|
*/
|
|
|
|
|
|
-import StandardEditor from '@ckeditor/ckeditor5-core/src/editor/standardeditor';
|
|
|
+import Editor from '@ckeditor/ckeditor5-core/src/editor/editor';
|
|
|
+import DataApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/dataapimixin';
|
|
|
+import ElementApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/elementapimixin';
|
|
|
+import attachToForm from '@ckeditor/ckeditor5-core/src/editor/utils/attachtoform';
|
|
|
import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
|
|
|
import ClassicEditorUI from './classiceditorui';
|
|
|
import ClassicEditorUIView from './classiceditoruiview';
|
|
|
import ElementReplacer from '@ckeditor/ckeditor5-utils/src/elementreplacer';
|
|
|
-
|
|
|
-import '../theme/theme.scss';
|
|
|
+import getDataFromElement from '@ckeditor/ckeditor5-utils/src/dom/getdatafromelement';
|
|
|
+import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
|
|
|
|
|
/**
|
|
|
- * The {@glink builds/guides/overview#Classic-editor classic editor} implementation.
|
|
|
+ * The {@glink builds/guides/overview#classic-editor classic editor} implementation.
|
|
|
* It uses an inline editable and a sticky toolbar, all enclosed in a boxed UI.
|
|
|
* See the {@glink examples/builds/classic-editor demo}.
|
|
|
*
|
|
|
* In order to create a classic editor instance, use the static
|
|
|
- * {@link module:editor-classic/classiceditor~ClassicEditor#create `ClassicEditor.create()`} method.
|
|
|
+ * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`} method.
|
|
|
*
|
|
|
* # Classic editor and classic build
|
|
|
*
|
|
|
* The classic editor can be used directly from source (if you installed the
|
|
|
* [`@ckeditor/ckeditor5-editor-classic`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-classic) package)
|
|
|
- * but it is also available in the {@glink builds/guides/overview#Classic-editor classic build}.
|
|
|
+ * but it is also available in the {@glink builds/guides/overview#classic-editor classic build}.
|
|
|
*
|
|
|
* {@glink builds/guides/overview Builds} are ready-to-use editors with plugins bundled in. When using the editor from
|
|
|
* source you need to take care of loading all plugins by yourself
|
|
|
@@ -35,16 +38,19 @@ import '../theme/theme.scss';
|
|
|
* Using the editor from source gives much better flexibility and allows easier customization.
|
|
|
*
|
|
|
* Read more about initializing the editor from source or as a build in
|
|
|
- * {@link module:editor-classic/classiceditor~ClassicEditor#create `ClassicEditor.create()`}.
|
|
|
+ * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
|
|
|
*
|
|
|
- * @extends module:core/editor/standardeditor~StandardEditor
|
|
|
+ * @mixes module:core/editor/utils/dataapimixin~DataApiMixin
|
|
|
+ * @mixes module:core/editor/utils/elementapimixin~ElementApiMixin
|
|
|
+ * @implements module:core/editor/editorwithui~EditorWithUI
|
|
|
+ * @extends module:core/editor/editor~Editor
|
|
|
*/
|
|
|
-export default class ClassicEditor extends StandardEditor {
|
|
|
+export default class ClassicEditor extends Editor {
|
|
|
/**
|
|
|
* Creates an instance of the classic editor.
|
|
|
*
|
|
|
* **Note:** do not use the constructor to create editor instances. Use the static
|
|
|
- * {@link module:editor-classic/classiceditor~ClassicEditor#create `ClassicEditor.create()`} method instead.
|
|
|
+ * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`} method instead.
|
|
|
*
|
|
|
* @protected
|
|
|
* @param {HTMLElement} element The DOM element that will be the source for the created editor.
|
|
|
@@ -52,11 +58,7 @@ export default class ClassicEditor extends StandardEditor {
|
|
|
* @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration.
|
|
|
*/
|
|
|
constructor( element, config ) {
|
|
|
- super( element, config );
|
|
|
-
|
|
|
- this.document.createRoot();
|
|
|
- this.data.processor = new HtmlDataProcessor();
|
|
|
- this.ui = new ClassicEditorUI( this, new ClassicEditorUIView( this.locale ) );
|
|
|
+ super( config );
|
|
|
|
|
|
/**
|
|
|
* The element replacer instance used to hide the editor element.
|
|
|
@@ -65,6 +67,16 @@ export default class ClassicEditor extends StandardEditor {
|
|
|
* @member {module:utils/elementreplacer~ElementReplacer}
|
|
|
*/
|
|
|
this._elementReplacer = new ElementReplacer();
|
|
|
+
|
|
|
+ this.element = element;
|
|
|
+
|
|
|
+ this.data.processor = new HtmlDataProcessor();
|
|
|
+
|
|
|
+ this.model.document.createRoot();
|
|
|
+
|
|
|
+ this.ui = new ClassicEditorUI( this, new ClassicEditorUIView( this.locale ) );
|
|
|
+
|
|
|
+ attachToForm( this );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -75,7 +87,7 @@ export default class ClassicEditor extends StandardEditor {
|
|
|
* @returns {Promise}
|
|
|
*/
|
|
|
destroy() {
|
|
|
- this.updateEditorElement();
|
|
|
+ this.updateElement();
|
|
|
this._elementReplacer.restore();
|
|
|
this.ui.destroy();
|
|
|
|
|
|
@@ -134,7 +146,7 @@ export default class ClassicEditor extends StandardEditor {
|
|
|
editor.fire( 'uiReady' );
|
|
|
} )
|
|
|
.then( () => editor.editing.view.attachDomRoot( editor.ui.view.editableElement ) )
|
|
|
- .then( () => editor.loadDataFromEditorElement() )
|
|
|
+ .then( () => editor.data.init( getDataFromElement( element ) ) )
|
|
|
.then( () => {
|
|
|
editor.fire( 'dataReady' );
|
|
|
editor.fire( 'ready' );
|
|
|
@@ -144,3 +156,6 @@ export default class ClassicEditor extends StandardEditor {
|
|
|
} );
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+mix( ClassicEditor, DataApiMixin );
|
|
|
+mix( ClassicEditor, ElementApiMixin );
|