@ckeditor/ckeditor5-core
Advanced tools
Comparing version 0.7.0 to 0.8.0
Changelog | ||
========= | ||
## [0.8.0](https://github.com/ckeditor/ckeditor5-core/compare/v0.7.0...v0.8.0) (2017-04-05) | ||
### Bug fixes | ||
* This time, we introduced support for `config.removePlugins` for real (we said that we did this in the previous release, but we didn't). Closes [#49](https://github.com/ckeditor/ckeditor5-core/issues/49). ([5834fed](https://github.com/ckeditor/ckeditor5-core/commit/5834fed)) | ||
### Features | ||
* Added support for building plugins and default configs into `Editor` classes. Closes [#67](https://github.com/ckeditor/ckeditor5-core/issues/67). ([a1fa64f](https://github.com/ckeditor/ckeditor5-core/commit/a1fa64f)) | ||
### Other changes | ||
* Updated translations. ([1296b03](https://github.com/ckeditor/ckeditor5-core/commit/1296b03)) | ||
## [0.7.0](https://github.com/ckeditor/ckeditor5-core/compare/v0.6.0...v0.7.0) (2017-03-06) | ||
@@ -5,0 +20,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-core", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "", | ||
"keywords": [], | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-engine": "^0.8.0", | ||
"@ckeditor/ckeditor5-utils": "^0.8.0" | ||
"@ckeditor/ckeditor5-engine": "^0.9.0", | ||
"@ckeditor/ckeditor5-utils": "^0.9.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-dev-lint": "^2.0.2", | ||
"@ckeditor/ckeditor5-ui": "^0.7.1", | ||
"@ckeditor/ckeditor5-ui": "^0.8.0", | ||
"gulp": "^3.9.0", | ||
@@ -14,0 +14,0 @@ "guppy-pre-commit": "^0.4.0" |
@@ -34,2 +34,4 @@ /** | ||
constructor( config ) { | ||
const availablePlugins = this.constructor.build && this.constructor.build.plugins; | ||
/** | ||
@@ -41,4 +43,6 @@ * Holds all configurations specific to this editor instance. | ||
*/ | ||
this.config = new Config( config ); | ||
this.config = new Config( config, this.constructor.build && this.constructor.build.config ); | ||
this.config.define( 'plugins', availablePlugins ); | ||
/** | ||
@@ -50,3 +54,3 @@ * The plugins loaded and in use by this editor instance. | ||
*/ | ||
this.plugins = new PluginCollection( this ); | ||
this.plugins = new PluginCollection( this, availablePlugins ); | ||
@@ -122,3 +126,6 @@ /** | ||
function loadPlugins() { | ||
return that.plugins.load( config.get( 'plugins' ) || [] ); | ||
const plugins = config.get( 'plugins' ) || []; | ||
const removePlugins = config.get( 'removePlugins' ) || []; | ||
return that.plugins.load( plugins, removePlugins ); | ||
} | ||
@@ -125,0 +132,0 @@ |
@@ -16,2 +16,3 @@ /** | ||
import BoxedEditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/boxed/boxededitoruiview'; | ||
import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview'; | ||
@@ -43,3 +44,3 @@ import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; | ||
it( 'creates model and view roots', () => { | ||
const editor = new ClassicTestEditor( { foo: 1 } ); | ||
const editor = new ClassicTestEditor( editorElement ); | ||
@@ -50,5 +51,14 @@ expect( editor.document.getRoot() ).to.have.property( 'name', '$root' ); | ||
} ); | ||
it( 'creates editable DOM', () => { | ||
const editor = new ClassicTestEditor( editorElement ); | ||
expect( editor.ui.view.editable ).to.be.instanceOf( InlineEditableUIView ); | ||
expect( editor.ui.view.editableElement.tagName ).to.equal( 'DIV' ); | ||
expect( editor.ui.view.editableElement ).to.equal( editor.ui.view.editable.element ); | ||
} ); | ||
} ); | ||
describe( 'create', () => { | ||
describe( 'create()', () => { | ||
it( 'creates an instance of editor', () => { | ||
@@ -106,9 +116,29 @@ return ClassicTestEditor.create( editorElement, { foo: 1 } ) | ||
} ) | ||
.then( () => { | ||
.then( editor => { | ||
expect( fired ).to.deep.equal( [ 'pluginsReady', 'uiReady', 'dataReady', 'ready' ] ); | ||
return editor.destroy(); | ||
} ); | ||
} ); | ||
it( 'inserts editor UI next to editor element', () => { | ||
return ClassicTestEditor.create( editorElement ) | ||
.then( editor => { | ||
expect( editor.ui.view.element.previousSibling ).to.equal( editorElement ); | ||
return editor.destroy(); | ||
} ); | ||
} ); | ||
it( 'attaches editable UI as view\'s DOM root', () => { | ||
return ClassicTestEditor.create( editorElement ) | ||
.then( editor => { | ||
expect( editor.editing.view.getDomRoot() ).to.equal( editor.ui.view.editable.element ); | ||
return editor.destroy(); | ||
} ); | ||
} ); | ||
} ); | ||
describe( 'destroy', () => { | ||
describe( 'destroy()', () => { | ||
it( 'destroys UI and calls super.destroy()', () => { | ||
@@ -127,3 +157,15 @@ return ClassicTestEditor.create( editorElement, { foo: 1 } ) | ||
} ); | ||
it( 'restores the editor element', () => { | ||
return ClassicTestEditor.create( editorElement, { foo: 1 } ) | ||
.then( editor => { | ||
expect( editor.element.style.display ).to.equal( 'none' ); | ||
return editor.destroy() | ||
.then( () => { | ||
expect( editor.element.style.display ).to.equal( '' ); | ||
} ); | ||
} ); | ||
} ); | ||
} ); | ||
} ); |
@@ -10,2 +10,4 @@ /** | ||
import BoxedEditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/boxed/boxededitoruiview'; | ||
import ElementReplacer from '@ckeditor/ckeditor5-utils/src/elementreplacer'; | ||
import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview'; | ||
@@ -30,2 +32,9 @@ /** | ||
this.ui = new ClassicTestEditorUI( this, new BoxedEditorUIView( this.locale ) ); | ||
// Expose properties normally exposed by the ClassicEditorUI. | ||
this.ui.view.editable = new InlineEditableUIView( this.ui.view.locale ); | ||
this.ui.view.main.add( this.ui.view.editable ); | ||
this.ui.view.editableElement = this.ui.view.editable.element; | ||
this._elementReplacer = new ElementReplacer(); | ||
} | ||
@@ -37,2 +46,4 @@ | ||
destroy() { | ||
this._elementReplacer.restore(); | ||
return this.ui.destroy() | ||
@@ -51,4 +62,6 @@ .then( () => super.destroy() ); | ||
editor.initPlugins() | ||
.then( () => editor._elementReplacer.replace( element, editor.ui.view.element ) ) | ||
.then( () => editor.ui.init() ) | ||
.then( () => editor.fire( 'uiReady' ) ) | ||
.then( () => editor.editing.view.attachDomRoot( editor.ui.view.editableElement ) ) | ||
.then( () => editor.loadDataFromEditorElement() ) | ||
@@ -55,0 +68,0 @@ .then( () => { |
@@ -19,2 +19,6 @@ /** | ||
} | ||
static get pluginName() { | ||
return 'A'; | ||
} | ||
} | ||
@@ -28,2 +32,6 @@ | ||
} | ||
static get pluginName() { | ||
return 'B'; | ||
} | ||
} | ||
@@ -38,2 +46,6 @@ | ||
static get pluginName() { | ||
return 'C'; | ||
} | ||
static get requires() { | ||
@@ -51,2 +63,6 @@ return [ PluginB ]; | ||
static get pluginName() { | ||
return 'D'; | ||
} | ||
static get requires() { | ||
@@ -58,2 +74,6 @@ return [ PluginC ]; | ||
describe( 'Editor', () => { | ||
afterEach( () => { | ||
delete Editor.build; | ||
} ); | ||
describe( 'constructor()', () => { | ||
@@ -69,2 +89,28 @@ it( 'should create a new editor instance', () => { | ||
} ); | ||
it( 'should extend an editor configuration using built in config', () => { | ||
Editor.build = { | ||
config: { | ||
foo: { | ||
a: 1, | ||
b: 2 | ||
} | ||
} | ||
}; | ||
const editor = new Editor( { | ||
bar: 'foo', | ||
foo: { | ||
c: 3 | ||
}, | ||
} ); | ||
expect( editor.config.get( 'foo' ) ).to.deep.equal( { | ||
a: 1, | ||
b: 2, | ||
c: 3 | ||
} ); | ||
expect( editor.config.get( 'bar' ) ).to.equal( 'foo' ); | ||
} ); | ||
} ); | ||
@@ -253,2 +299,158 @@ | ||
} ); | ||
it( 'should load plugins built in the Editor even if the passed config is empty', () => { | ||
Editor.build = { | ||
plugins: [ PluginA, PluginB, PluginC ] | ||
}; | ||
const editor = new Editor(); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 3 ); | ||
expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginB ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginC ) ).to.be.an.instanceof( Plugin ); | ||
} ); | ||
} ); | ||
it( 'should load plugins provided in the config and should ignore plugins built in the Editor', () => { | ||
Editor.build = { | ||
plugins: [ PluginA, PluginB, PluginC, PluginD ] | ||
}; | ||
const editor = new Editor( { | ||
plugins: [ | ||
'A' | ||
] | ||
} ); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 1 ); | ||
expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin ); | ||
} ); | ||
} ); | ||
it( 'should load plugins built in the Editor using their names', () => { | ||
class PrivatePlugin extends Plugin {} | ||
Editor.build = { | ||
plugins: [ PluginA, PluginB, PluginC, PluginD ] | ||
}; | ||
const editor = new Editor( { | ||
plugins: [ | ||
'A', | ||
'B', | ||
'C', | ||
PrivatePlugin | ||
] | ||
} ); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 4 ); | ||
expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginB ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginC ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PrivatePlugin ) ).to.be.an.instanceof( PrivatePlugin ); | ||
} ); | ||
} ); | ||
it( 'should load plugins inherited from the base Editor', () => { | ||
Editor.build = { | ||
plugins: [ PluginA, PluginB, PluginC, PluginD ] | ||
}; | ||
class CustomEditor extends Editor {} | ||
const editor = new CustomEditor( { | ||
plugins: [ | ||
'D' | ||
] | ||
} ); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 3 ); | ||
expect( editor.plugins.get( PluginB ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginC ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginD ) ).to.be.an.instanceof( Plugin ); | ||
} ); | ||
} ); | ||
it( 'should load plugins build into Editor\'s subclass', () => { | ||
class CustomEditor extends Editor {} | ||
CustomEditor.build = { | ||
plugins: [ PluginA, PluginB, PluginC, PluginD ] | ||
}; | ||
const editor = new CustomEditor( { | ||
plugins: [ | ||
'D' | ||
] | ||
} ); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 3 ); | ||
expect( editor.plugins.get( PluginB ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginC ) ).to.be.an.instanceof( Plugin ); | ||
expect( editor.plugins.get( PluginD ) ).to.be.an.instanceof( Plugin ); | ||
} ); | ||
} ); | ||
it( 'should not load plugins specified in the config as "removePlugins"', () => { | ||
const editor = new Editor( { | ||
plugins: [ PluginA, PluginD ], | ||
removePlugins: [ PluginD ] | ||
} ); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 1 ); | ||
expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin ); | ||
} ); | ||
} ); | ||
it( 'should not load plugins built in the Editor when "removePlugins" option is specified', () => { | ||
Editor.build = { | ||
plugins: [ PluginA, PluginD ] | ||
}; | ||
const editor = new Editor( { | ||
removePlugins: [ 'D' ] | ||
} ); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 1 ); | ||
expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin ); | ||
} ); | ||
} ); | ||
it( 'should not load plugins build into Editor\'s subclass when "removePlugins" option is specified', () => { | ||
class CustomEditor extends Editor {} | ||
CustomEditor.build = { | ||
plugins: [ PluginA, PluginD ] | ||
}; | ||
const editor = new CustomEditor( { | ||
removePlugins: [ 'D' ] | ||
} ); | ||
return editor.initPlugins() | ||
.then( () => { | ||
expect( getPlugins( editor ).length ).to.equal( 1 ); | ||
expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin ); | ||
} ); | ||
} ); | ||
} ); | ||
@@ -255,0 +457,0 @@ } ); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
156373
79
3061
+ Added@ckeditor/ckeditor5-engine@0.9.0(transitive)
+ Added@ckeditor/ckeditor5-utils@0.9.1(transitive)
- Removed@ckeditor/ckeditor5-engine@0.8.0(transitive)
- Removed@ckeditor/ckeditor5-utils@0.8.0(transitive)