@ckeditor/ckeditor5-editor-balloon
Advanced tools
Comparing version 10.0.1 to 11.0.0
Changelog | ||
========= | ||
## [11.0.0](https://github.com/ckeditor/ckeditor5-editor-balloon/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 [#18](https://github.com/ckeditor/ckeditor5-editor-balloon/issues/18). ([48c265c](https://github.com/ckeditor/ckeditor5-editor-balloon/commit/48c265c)) | ||
### Other changes | ||
* Used the `EditorUI` as a parent class for the `BalloonEditorUI` (see [ckeditor/ckeditor5-core#130](https://github.com/ckeditor/ckeditor5-core/issues/130)). ([03af1c0](https://github.com/ckeditor/ckeditor5-editor-balloon/commit/03af1c0)) | ||
### BREAKING CHANGES | ||
* The `BalloonEditor#element` property was renamed to `BalloonEditor#sourceElement` and `BalloonEditor#updateElement()` method to `BalloonEditor#updateSourceElement()`. See [ckeditor/ckeditor5-core#64](https://github.com/ckeditor/ckeditor5-core/issues/64). | ||
## [10.0.1](https://github.com/ckeditor/ckeditor5-editor-balloon/compare/v10.0.0...v10.0.1) (2018-06-21) | ||
@@ -5,0 +20,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-editor-balloon", | ||
"version": "10.0.1", | ||
"version": "11.0.0", | ||
"description": "Balloon editor implementation for CKEditor 5.", | ||
@@ -12,12 +12,12 @@ "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-essentials": "^10.1.0", | ||
"@ckeditor/ckeditor5-paragraph": "^10.0.1", | ||
"@ckeditor/ckeditor5-basic-styles": "^10.0.2", | ||
"@ckeditor/ckeditor5-essentials": "^10.1.1", | ||
"@ckeditor/ckeditor5-paragraph": "^10.0.2", | ||
"eslint": "^4.15.0", | ||
@@ -29,3 +29,3 @@ "eslint-config-ckeditor5": "^1.0.7", | ||
"engines": { | ||
"node": ">=6.0.0", | ||
"node": ">=6.9.0", | ||
"npm": ">=3.0.0" | ||
@@ -32,0 +32,0 @@ }, |
@@ -21,2 +21,3 @@ /** | ||
import mix from '@ckeditor/ckeditor5-utils/src/mix'; | ||
import isElement from '@ckeditor/ckeditor5-utils/src/lib/lodash/isElement'; | ||
@@ -58,10 +59,13 @@ /** | ||
* @protected | ||
* @param {HTMLElement} element The DOM element that will be the source for the created editor | ||
* (on which the editor will be initialized). | ||
* @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor | ||
* (on which the editor will be initialized) or initial data for the editor. For more information see | ||
* {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}. | ||
* @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration. | ||
*/ | ||
constructor( element, config ) { | ||
constructor( sourceElementOrData, config ) { | ||
super( config ); | ||
this.element = element; | ||
if ( isElement( sourceElementOrData ) ) { | ||
this.sourceElement = sourceElementOrData; | ||
} | ||
@@ -75,3 +79,3 @@ this.config.get( 'plugins' ).push( BalloonToolbar ); | ||
this.ui = new BalloonEditorUI( this, new BalloonEditorUIView( this.locale, element ) ); | ||
this.ui = new BalloonEditorUI( this, new BalloonEditorUIView( this.locale, this.sourceElement ) ); | ||
@@ -82,2 +86,9 @@ attachToForm( this ); | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get element() { | ||
return this.ui.view.editable.element; | ||
} | ||
/** | ||
* Destroys the editor instance, releasing all resources used by it. | ||
@@ -97,3 +108,7 @@ * | ||
return super.destroy() | ||
.then( () => setDataInElement( this.element, data ) ); | ||
.then( () => { | ||
if ( this.sourceElement ) { | ||
setDataInElement( this.sourceElement, data ); | ||
} | ||
} ); | ||
} | ||
@@ -104,3 +119,3 @@ | ||
* | ||
* Creating instance when using {@glink builds/index CKEditor build}: | ||
* Creating an instance when using a {@glink builds/index CKEditor build}: | ||
* | ||
@@ -116,3 +131,3 @@ * BalloonEditor | ||
* | ||
* 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): | ||
* | ||
@@ -137,4 +152,34 @@ * import BalloonEditor from '@ckeditor/ckeditor5-editor-balloon/src/ballooneditor'; | ||
* | ||
* @param {HTMLElement} element The DOM element that will be the source for the created editor | ||
* (on which the editor will be initialized). | ||
* Creating an instance when using initial data instead of a DOM element: | ||
* | ||
* import BalloonEditor from '@ckeditor/ckeditor5-editor-balloon/src/ballooneditor'; | ||
* 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 ... | ||
* | ||
* BalloonEditor | ||
* .create( '<p>Hello world!</p>', { | ||
* plugins: [ Essentials, Bold, Italic, ... ], | ||
* toolbar: [ 'bold', 'italic', ... ] | ||
* } ) | ||
* .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 | ||
* (on which the editor will be initialized) or initial data for the editor. | ||
* | ||
* If a source element is passed, then its contents will be automatically | ||
* {@link module:editor-balloon/ballooneditor~BalloonEditor#setData loaded} to the editor on startup and the element | ||
* itself will be used as the editor's editable element. | ||
* | ||
* If data is provided, then `editor.element` will be created automatically and needs to be added | ||
* to the DOM manually. | ||
* @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration. | ||
@@ -144,5 +189,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 ); | ||
@@ -155,4 +200,10 @@ resolve( | ||
} ) | ||
.then( () => editor.data.init( getDataFromElement( element ) ) ) | ||
.then( () => { | ||
const initialData = isElement( sourceElementOrData ) ? | ||
getDataFromElement( sourceElementOrData ) : | ||
sourceElementOrData; | ||
return editor.data.init( initialData ); | ||
} ) | ||
.then( () => { | ||
editor.fire( 'dataReady' ); | ||
@@ -159,0 +210,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'; | ||
@@ -18,34 +17,6 @@ | ||
* | ||
* @implements module:core/editor/editorui~EditorUI | ||
* @extends module:core/editor/editorui~EditorUI | ||
*/ | ||
export default class BalloonEditorUI { | ||
export default class BalloonEditorUI extends EditorUI { | ||
/** | ||
* Creates an instance of the balloon 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. | ||
*/ | ||
constructor( editor, view ) { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.editor = editor; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.view = view; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.componentFactory = new ComponentFactory( editor ); | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.focusTracker = new FocusTracker(); | ||
} | ||
/** | ||
* Initializes the UI. | ||
@@ -85,9 +56,2 @@ */ | ||
} | ||
/** | ||
* Destroys the UI. | ||
*/ | ||
destroy() { | ||
this.view.destroy(); | ||
} | ||
} |
@@ -23,2 +23,4 @@ /** | ||
* @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor#locale} instance. | ||
* @param {HTMLElement} [editableElement] The editable element. If not specified, it will be automatically created by | ||
* {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used. | ||
*/ | ||
@@ -25,0 +27,0 @@ constructor( locale, editableElement ) { |
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
19485
278
+ 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)