@ckeditor/ckeditor5-editor-classic
Advanced tools
Comparing version 0.7.1 to 0.7.2
Changelog | ||
========= | ||
## [0.7.2](https://github.com/ckeditor/ckeditor5-editor-classic/compare/v0.7.1...v0.7.2) (2017-04-05) | ||
### Bug fixes | ||
* It should be possible to use `ClassicEditor.create()` in its child classes. Closes [#53](https://github.com/ckeditor/ckeditor5-editor-classic/issues/53). ([95798ba](https://github.com/ckeditor/ckeditor5-editor-classic/commit/95798ba)) | ||
### Other changes | ||
* Code refactoring to share API with `ckeditor5-editor-inline`. Closes [#48](https://github.com/ckeditor/ckeditor5-editor-classic/issues/48). ([2bb1e4e](https://github.com/ckeditor/ckeditor5-editor-classic/commit/2bb1e4e)) | ||
## [0.7.1](https://github.com/ckeditor/ckeditor5-editor-classic/compare/v0.7.0...v0.7.1) (2017-03-06) | ||
@@ -5,0 +16,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-editor-classic", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Classic Editor for CKEditor 5.", | ||
"keywords": [], | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^0.7.0", | ||
"@ckeditor/ckeditor5-engine": "^0.8.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^0.6.1", | ||
"@ckeditor/ckeditor5-ui": "^0.7.1", | ||
"@ckeditor/ckeditor5-utils": "^0.8.0" | ||
"@ckeditor/ckeditor5-core": "^0.8.0", | ||
"@ckeditor/ckeditor5-engine": "^0.9.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^0.7.0", | ||
"@ckeditor/ckeditor5-ui": "^0.8.0", | ||
"@ckeditor/ckeditor5-utils": "^0.9.0" | ||
}, | ||
@@ -16,7 +16,7 @@ "devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^0.7.1", | ||
"@ckeditor/ckeditor5-enter": "^0.8.0", | ||
"@ckeditor/ckeditor5-heading": "^0.8.0", | ||
"@ckeditor/ckeditor5-paragraph": "^0.6.1", | ||
"@ckeditor/ckeditor5-undo": "^0.7.1", | ||
"@ckeditor/ckeditor5-typing": "^0.8.0", | ||
"@ckeditor/ckeditor5-enter": "^0.9.0", | ||
"@ckeditor/ckeditor5-heading": "^0.9.0", | ||
"@ckeditor/ckeditor5-paragraph": "^0.7.0", | ||
"@ckeditor/ckeditor5-undo": "^0.8.0", | ||
"@ckeditor/ckeditor5-typing": "^0.9.0", | ||
"gulp": "^3.9.0", | ||
@@ -23,0 +23,0 @@ "guppy-pre-commit": "^0.4.0" |
@@ -84,3 +84,3 @@ /** | ||
return new Promise( ( resolve ) => { | ||
const editor = new ClassicEditor( element, config ); | ||
const editor = new this( element, config ); | ||
@@ -87,0 +87,0 @@ resolve( |
@@ -12,5 +12,8 @@ /** | ||
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker'; | ||
import enableToolbarKeyboardFocus from '@ckeditor/ckeditor5-ui/src/toolbar/enabletoolbarkeyboardfocus'; | ||
/** | ||
* The classic editor UI class. | ||
* | ||
* @implements module:core/editor/editorui~EditorUI | ||
*/ | ||
@@ -26,6 +29,3 @@ export default class ClassicEditorUI { | ||
/** | ||
* Editor that the UI belongs to. | ||
* | ||
* @readonly | ||
* @member {module:core/editor/editor~Editor} | ||
* @inheritDoc | ||
*/ | ||
@@ -35,6 +35,3 @@ this.editor = editor; | ||
/** | ||
* View of the ui. | ||
* | ||
* @readonly | ||
* @member {module:ui/editorui/editoruiview~EditorUIView} | ||
* @inheritDoc | ||
*/ | ||
@@ -44,6 +41,3 @@ this.view = view; | ||
/** | ||
* Instance of the {@link module:ui/componentfactory~ComponentFactory}. | ||
* | ||
* @readonly | ||
* @member {module:ui/componentfactory~ComponentFactory} | ||
* @inheritDoc | ||
*/ | ||
@@ -53,6 +47,3 @@ this.componentFactory = new ComponentFactory( editor ); | ||
/** | ||
* Keeps information about editor focus. | ||
* | ||
* @readonly | ||
* @member {module:utils/focustracker~FocusTracker} | ||
* @inheritDoc | ||
*/ | ||
@@ -87,33 +78,11 @@ this.focusTracker = new FocusTracker(); | ||
.then( () => { | ||
const toolbarConfig = editor.config.get( 'toolbar' ); | ||
const promises = []; | ||
if ( toolbarConfig ) { | ||
promises.push( this.view.toolbar.fillFromConfig( toolbarConfig, this.componentFactory ) ); | ||
} | ||
return Promise.all( promises ); | ||
return this.view.toolbar.fillFromConfig( editor.config.get( 'toolbar' ), this.componentFactory ); | ||
} ) | ||
.then( () => { | ||
const toolbarFocusTracker = this.view.toolbar.focusTracker; | ||
// Because toolbar items can get focus, the overall state of | ||
// the toolbar must also be tracked. | ||
this.focusTracker.add( this.view.toolbar.element ); | ||
// Focus the toolbar on the keystroke, if not already focused. | ||
editor.keystrokes.set( 'Alt+F10', ( data, cancel ) => { | ||
if ( this.focusTracker.isFocused && !toolbarFocusTracker.isFocused ) { | ||
this.view.toolbar.focus(); | ||
cancel(); | ||
} | ||
enableToolbarKeyboardFocus( { | ||
origin: editor.editing.view, | ||
originFocusTracker: this.focusTracker, | ||
originKeystrokeHandler: editor.keystrokes, | ||
toolbar: this.view.toolbar | ||
} ); | ||
// Blur the toolbar and bring the focus back to editable on the keystroke. | ||
this.view.toolbar.keystrokes.set( 'Esc', ( data, cancel ) => { | ||
if ( toolbarFocusTracker.isFocused ) { | ||
editor.editing.view.focus(); | ||
cancel(); | ||
} | ||
} ); | ||
} ); | ||
@@ -120,0 +89,0 @@ } |
@@ -90,2 +90,18 @@ /** | ||
} ); | ||
it( 'creates an instance of a ClassicEditor child class', () => { | ||
class CustomClassicEditor extends ClassicEditor {} | ||
return CustomClassicEditor.create( editorElement, { | ||
plugins: [ Paragraph, Bold ] | ||
} ) | ||
.then( newEditor => { | ||
editor = newEditor; | ||
expect( newEditor ).to.be.instanceof( CustomClassicEditor ); | ||
expect( newEditor ).to.be.instanceof( ClassicEditor ); | ||
expect( newEditor.getData() ).to.equal( '<p><strong>foo</strong> bar</p>' ); | ||
} ); | ||
} ); | ||
} ); | ||
@@ -92,0 +108,0 @@ |
@@ -16,4 +16,4 @@ /** | ||
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker'; | ||
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; | ||
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; | ||
@@ -143,66 +143,24 @@ import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils'; | ||
it( 'fills view.toolbar#items with editor config', () => { | ||
const spy = testUtils.sinon.spy( view.toolbar, 'fillFromConfig' ); | ||
return ui.init().then( () => { | ||
expect( view.toolbar.items ).to.have.length( 2 ); | ||
expect( view.toolbar.items.get( 0 ).name ).to.equal( 'foo' ); | ||
expect( view.toolbar.items.get( 1 ).name ).to.equal( 'bar' ); | ||
sinon.assert.calledWithExactly( spy, editor.config.get( 'toolbar' ), ui.componentFactory ); | ||
} ); | ||
} ); | ||
describe( 'activates keyboard navigation for the toolbar', () => { | ||
it( 'Alt+F10: focus the first focusable toolbar item', () => { | ||
return ui.init().then( () => { | ||
const spy = sinon.spy( view.toolbar, 'focus' ); | ||
const toolbarFocusTracker = view.toolbar.focusTracker; | ||
const keyEvtData = { | ||
keyCode: keyCodes.f10, | ||
altKey: true, | ||
preventDefault: sinon.spy(), | ||
stopPropagation: sinon.spy() | ||
}; | ||
it( 'initializes keyboard navigation between view#toolbar and view#editable', () => { | ||
const spy = testUtils.sinon.spy( view.toolbar, 'focus' ); | ||
toolbarFocusTracker.isFocused = false; | ||
ui.focusTracker.isFocused = false; | ||
return ui.init().then( () => { | ||
ui.focusTracker.isFocused = true; | ||
ui.view.toolbar.focusTracker.isFocused = false; | ||
editor.keystrokes.press( keyEvtData ); | ||
sinon.assert.notCalled( spy ); | ||
toolbarFocusTracker.isFocused = true; | ||
ui.focusTracker.isFocused = true; | ||
editor.keystrokes.press( keyEvtData ); | ||
sinon.assert.notCalled( spy ); | ||
toolbarFocusTracker.isFocused = false; | ||
ui.focusTracker.isFocused = true; | ||
editor.keystrokes.press( keyEvtData ); | ||
sinon.assert.calledOnce( spy ); | ||
sinon.assert.calledOnce( keyEvtData.preventDefault ); | ||
sinon.assert.calledOnce( keyEvtData.stopPropagation ); | ||
editor.keystrokes.press( { | ||
keyCode: keyCodes.f10, | ||
altKey: true, | ||
preventDefault: sinon.spy(), | ||
stopPropagation: sinon.spy() | ||
} ); | ||
} ); | ||
it( 'esc: re–foucus editable when toolbar is focused', () => { | ||
return ui.init().then( () => { | ||
const spy = sinon.spy( editor.editing.view, 'focus' ); | ||
const toolbarFocusTracker = view.toolbar.focusTracker; | ||
const keyEvtData = { keyCode: keyCodes.esc, | ||
preventDefault: sinon.spy(), | ||
stopPropagation: sinon.spy() | ||
}; | ||
toolbarFocusTracker.isFocused = false; | ||
ui.view.toolbar.keystrokes.press( keyEvtData ); | ||
sinon.assert.notCalled( spy ); | ||
toolbarFocusTracker.isFocused = true; | ||
ui.view.toolbar.keystrokes.press( keyEvtData ); | ||
sinon.assert.calledOnce( spy ); | ||
sinon.assert.calledOnce( keyEvtData.preventDefault ); | ||
sinon.assert.calledOnce( keyEvtData.stopPropagation ); | ||
} ); | ||
sinon.assert.calledOnce( spy ); | ||
} ); | ||
@@ -209,0 +167,0 @@ } ); |
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
33297
655
+ Added@ckeditor/ckeditor5-core@0.8.1(transitive)
+ Added@ckeditor/ckeditor5-engine@0.10.00.9.0(transitive)
+ Added@ckeditor/ckeditor5-theme-lark@0.7.0(transitive)
+ Added@ckeditor/ckeditor5-ui@0.8.0(transitive)
+ Added@ckeditor/ckeditor5-utils@0.9.1(transitive)
- Removed@ckeditor/ckeditor5-core@0.7.0(transitive)
- Removed@ckeditor/ckeditor5-engine@0.8.0(transitive)
- Removed@ckeditor/ckeditor5-theme-lark@0.6.1(transitive)
- Removed@ckeditor/ckeditor5-ui@0.7.1(transitive)
- Removed@ckeditor/ckeditor5-utils@0.8.0(transitive)