@ckeditor/ckeditor5-editor-classic
Advanced tools
Comparing version 10.0.1 to 11.0.0
Changelog | ||
========= | ||
## [11.0.0](https://github.com/ckeditor/ckeditor5-editor-classic/compare/v10.0.1...v11.0.0) (2018-07-18) | ||
### Features | ||
* Editor can now be created with initial data passed to the `create()` method. Closes [#72](https://github.com/ckeditor/ckeditor5-editor-classic/issues/72). ([09cebc6](https://github.com/ckeditor/ckeditor5-editor-classic/commit/09cebc6)) | ||
### Other changes | ||
* Used the `EditorUI` as a parent class for the `ClassicEditorUI` (see [ckeditor/ckeditor5-core#130](https://github.com/ckeditor/ckeditor5-core/issues/130)). ([ae98cfd](https://github.com/ckeditor/ckeditor5-editor-classic/commit/ae98cfd)) | ||
### BREAKING CHANGES | ||
* The `ClassicEditor#element` property was renamed to `ClassicEditor#sourceElement` and `ClassicEditor#updateElement()` method to `ClassicEditor#updateSourceElement()`. See [ckeditor/ckeditor5-core#64](https://github.com/ckeditor/ckeditor5-core/issues/64). | ||
## [10.0.1](https://github.com/ckeditor/ckeditor5-editor-classic/compare/v10.0.0...v10.0.1) (2018-06-21) | ||
@@ -5,0 +20,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-editor-classic", | ||
"version": "10.0.1", | ||
"version": "11.0.0", | ||
"description": "Classic editor implementation for CKEditor 5.", | ||
@@ -12,15 +12,15 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^10.1.0", | ||
"@ckeditor/ckeditor5-engine": "^10.1.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^10.1.0", | ||
"@ckeditor/ckeditor5-ui": "^10.1.0", | ||
"@ckeditor/ckeditor5-utils": "^10.1.0" | ||
"@ckeditor/ckeditor5-core": "^11.0.0", | ||
"@ckeditor/ckeditor5-engine": "^10.2.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^11.0.0", | ||
"@ckeditor/ckeditor5-ui": "^11.0.0", | ||
"@ckeditor/ckeditor5-utils": "^10.2.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^10.0.1", | ||
"@ckeditor/ckeditor5-enter": "^10.1.0", | ||
"@ckeditor/ckeditor5-heading": "^10.0.1", | ||
"@ckeditor/ckeditor5-paragraph": "^10.0.1", | ||
"@ckeditor/ckeditor5-typing": "^10.0.1", | ||
"@ckeditor/ckeditor5-undo": "^10.0.1", | ||
"@ckeditor/ckeditor5-basic-styles": "^10.0.2", | ||
"@ckeditor/ckeditor5-enter": "^10.1.1", | ||
"@ckeditor/ckeditor5-heading": "^10.0.2", | ||
"@ckeditor/ckeditor5-paragraph": "^10.0.2", | ||
"@ckeditor/ckeditor5-typing": "^11.0.0", | ||
"@ckeditor/ckeditor5-undo": "^10.0.2", | ||
"eslint": "^4.15.0", | ||
@@ -32,3 +32,3 @@ "eslint-config-ckeditor5": "^1.0.7", | ||
"engines": { | ||
"node": ">=6.0.0", | ||
"node": ">=6.9.0", | ||
"npm": ">=3.0.0" | ||
@@ -35,0 +35,0 @@ }, |
@@ -20,2 +20,3 @@ /** | ||
import mix from '@ckeditor/ckeditor5-utils/src/mix'; | ||
import isElement from '@ckeditor/ckeditor5-utils/src/lib/lodash/isElement'; | ||
@@ -57,11 +58,16 @@ /** | ||
* @protected | ||
* @param {HTMLElement} element The DOM element that will be the source for the created editor. | ||
* The data will be loaded from it and loaded back to it once the editor is destroyed. | ||
* @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor | ||
* or the editor's initial data. For more information see | ||
* {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}. | ||
* @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration. | ||
*/ | ||
constructor( element, config ) { | ||
constructor( sourceElementOrData, config ) { | ||
super( config ); | ||
if ( isElement( sourceElementOrData ) ) { | ||
this.sourceElement = sourceElementOrData; | ||
} | ||
/** | ||
* The element replacer instance used to hide the editor element. | ||
* The element replacer instance used to hide the editor's source element. | ||
* | ||
@@ -73,4 +79,2 @@ * @protected | ||
this.element = element; | ||
this.data.processor = new HtmlDataProcessor(); | ||
@@ -86,5 +90,12 @@ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get element() { | ||
return this.ui.view.element; | ||
} | ||
/** | ||
* Destroys the editor instance, releasing all resources used by it. | ||
* | ||
* Updates the original editor element with the data. | ||
* Updates the editor's source element with the data. | ||
* | ||
@@ -94,3 +105,6 @@ * @returns {Promise} | ||
destroy() { | ||
this.updateElement(); | ||
if ( this.sourceElement ) { | ||
this.updateSourceElement(); | ||
} | ||
this._elementReplacer.restore(); | ||
@@ -105,3 +119,3 @@ this.ui.destroy(); | ||
* | ||
* Creating instance when using {@glink builds/index CKEditor build}: | ||
* Creating an instance when using a {@glink builds/index CKEditor build}: | ||
* | ||
@@ -117,3 +131,3 @@ * ClassicEditor | ||
* | ||
* Creating instance when using CKEditor from source (make sure to specify the list of plugins to load and the toolbar): | ||
* Creating an instance when using CKEditor from source (make sure to specify the list of plugins to load and the toolbar): | ||
* | ||
@@ -138,4 +152,39 @@ * import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
* | ||
* @param {HTMLElement} element The DOM element that will be the source for the created editor. | ||
* The data will be loaded from it and loaded back to it once the editor is destroyed. | ||
* Creating an instance when using initial data instead of a DOM element: | ||
* | ||
* import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
* import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; | ||
* import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; | ||
* import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; | ||
* import ... | ||
* | ||
* ClassicEditor | ||
* .create( '<p>Hello world!</p>' ) | ||
* .then( editor => { | ||
* console.log( 'Editor was initialized', editor ); | ||
* | ||
* // Initial data was provided so `editor.element` needs to be added manually to the DOM. | ||
* document.body.appendChild( editor.element ); | ||
* } ) | ||
* .catch( err => { | ||
* console.error( err.stack ); | ||
* } ); | ||
* | ||
* @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor | ||
* or the editor's initial data. | ||
* | ||
* If a source element is passed, then its contents will be automatically | ||
* {@link module:editor-classic/classiceditor~ClassicEditor#setData loaded} to the editor on startup | ||
* and the {@link module:core/editor/editorwithui~EditorWithUI#element editor element} will replace the passed element in the DOM | ||
* (the original one will be hidden and the editor will be injected next to it). | ||
* | ||
* Moreover, the data will be set back to the source element once the editor is destroyed and | ||
* (if the element is a `<textarea>`) when a form in which this element is contained is submitted (which ensures | ||
* automatic integration with native web forms). | ||
* | ||
* If the data is passed, a detached editor will be created. It means that you need to insert it into the DOM manually | ||
* (by accessing the {@link module:editor-classic/classiceditor~ClassicEditor#element `editor.element`} property). | ||
* | ||
* See the examples above to learn more. | ||
* | ||
* @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration. | ||
@@ -145,5 +194,5 @@ * @returns {Promise} A promise resolved once the editor is ready. | ||
*/ | ||
static create( element, config ) { | ||
static create( sourceElementOrData, config ) { | ||
return new Promise( resolve => { | ||
const editor = new this( element, config ); | ||
const editor = new this( sourceElementOrData, config ); | ||
@@ -154,8 +203,17 @@ resolve( | ||
.then( () => { | ||
editor._elementReplacer.replace( element, editor.ui.view.element ); | ||
if ( isElement( sourceElementOrData ) ) { | ||
editor._elementReplacer.replace( sourceElementOrData, editor.element ); | ||
} | ||
editor.fire( 'uiReady' ); | ||
} ) | ||
.then( () => editor.editing.view.attachDomRoot( editor.ui.view.editableElement ) ) | ||
.then( () => editor.data.init( getDataFromElement( element ) ) ) | ||
.then( () => { | ||
const initialData = isElement( sourceElementOrData ) ? | ||
getDataFromElement( sourceElementOrData ) : | ||
sourceElementOrData; | ||
return editor.data.init( initialData ); | ||
} ) | ||
.then( () => { | ||
editor.fire( 'dataReady' ); | ||
@@ -162,0 +220,0 @@ editor.fire( 'ready' ); |
@@ -10,4 +10,3 @@ /** | ||
import ComponentFactory from '@ckeditor/ckeditor5-ui/src/componentfactory'; | ||
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker'; | ||
import EditorUI from '@ckeditor/ckeditor5-core/src/editor/editorui'; | ||
import enableToolbarKeyboardFocus from '@ckeditor/ckeditor5-ui/src/toolbar/enabletoolbarkeyboardfocus'; | ||
@@ -19,33 +18,12 @@ import normalizeToolbarConfig from '@ckeditor/ckeditor5-ui/src/toolbar/normalizetoolbarconfig'; | ||
* | ||
* @implements module:core/editor/editorui~EditorUI | ||
* @extends module:core/editor/editorui~EditorUI | ||
*/ | ||
export default class ClassicEditorUI { | ||
export default class ClassicEditorUI extends EditorUI { | ||
/** | ||
* Creates an instance of the editor UI class. | ||
* | ||
* @param {module:core/editor/editor~Editor} editor The editor instance. | ||
* @param {module:ui/editorui/editoruiview~EditorUIView} view The view of the UI. | ||
* @inheritDoc | ||
*/ | ||
constructor( editor, view ) { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.editor = editor; | ||
super( editor, view ); | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.view = view; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.componentFactory = new ComponentFactory( editor ); | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.focusTracker = new FocusTracker(); | ||
/** | ||
* A normalized `config.toolbar` object. | ||
@@ -93,9 +71,2 @@ * | ||
} | ||
/** | ||
* Destroys the UI. | ||
*/ | ||
destroy() { | ||
this.view.destroy(); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23885
338
+ Added@ckeditor/ckeditor5-core@11.1.0(transitive)
+ Added@ckeditor/ckeditor5-engine@12.0.0(transitive)
+ Added@ckeditor/ckeditor5-theme-lark@11.1.012.0.0(transitive)
+ Added@ckeditor/ckeditor5-ui@11.2.0(transitive)
+ Added@ckeditor/ckeditor5-utils@11.1.0(transitive)
+ Addedlodash-es@4.17.21(transitive)
- Removed@ckeditor/ckeditor5-core@10.1.0(transitive)
- Removed@ckeditor/ckeditor5-theme-lark@10.1.0(transitive)
- Removed@ckeditor/ckeditor5-ui@10.1.0(transitive)