@ckeditor/ckeditor5-ui
Advanced tools
Comparing version 0.0.0-nightly-20240712.0 to 0.0.0-nightly-20240713.0
@@ -113,2 +113,6 @@ /** | ||
/** | ||
* The last focused element to which focus should return on `Esc` press. | ||
*/ | ||
private _lastFocusedForeignElement; | ||
/** | ||
* Creates an instance of the editor UI class. | ||
@@ -250,2 +254,6 @@ * | ||
/** | ||
* Saves last focused element that doen not belong to editing view to restore focus on `Esc`. | ||
*/ | ||
private _saveLastFocusedForeignElement; | ||
/** | ||
* Returns definitions of toolbars that could potentially be focused, sorted by their importance for the user. | ||
@@ -252,0 +260,0 @@ * |
{ | ||
"name": "@ckeditor/ckeditor5-ui", | ||
"version": "0.0.0-nightly-20240712.0", | ||
"version": "0.0.0-nightly-20240713.0", | ||
"description": "The UI framework and standard UI library of CKEditor 5.", | ||
@@ -15,4 +15,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20240712.0", | ||
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-20240712.0", | ||
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20240713.0", | ||
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-20240713.0", | ||
"color-convert": "2.0.1", | ||
@@ -19,0 +19,0 @@ "color-parse": "1.4.2", |
@@ -109,2 +109,6 @@ /** | ||
/** | ||
* The last focused element to which focus should return on `Esc` press. | ||
*/ | ||
private _lastFocusedForeignElement; | ||
/** | ||
* Creates an instance of the editor UI class. | ||
@@ -246,2 +250,6 @@ * | ||
/** | ||
* Saves last focused element that doen not belong to editing view to restore focus on `Esc`. | ||
*/ | ||
private _saveLastFocusedForeignElement; | ||
/** | ||
* Returns definitions of toolbars that could potentially be focused, sorted by their importance for the user. | ||
@@ -248,0 +256,0 @@ * |
@@ -45,2 +45,6 @@ /** | ||
this._extraMenuBarElements = []; | ||
/** | ||
* The last focused element to which focus should return on `Esc` press. | ||
*/ | ||
this._lastFocusedForeignElement = null; | ||
const editingView = editor.editing.view; | ||
@@ -260,13 +264,26 @@ this.editor = editor; | ||
this.editor.keystrokes.set('Esc', (data, cancel) => { | ||
if (menuBarViewElement.contains(this.editor.ui.focusTracker.focusedElement)) { | ||
if (!menuBarViewElement.contains(this.editor.ui.focusTracker.focusedElement)) { | ||
return; | ||
} | ||
// Bring focus back to where it came from before focusing the toolbar: | ||
// If it came from outside the engine view (e.g. source editing), move it there. | ||
if (this._lastFocusedForeignElement) { | ||
this._lastFocusedForeignElement.focus(); | ||
this._lastFocusedForeignElement = null; | ||
} | ||
// Else just focus the view editing. | ||
else { | ||
this.editor.editing.view.focus(); | ||
cancel(); | ||
} | ||
cancel(); | ||
}); | ||
this.editor.keystrokes.set('Alt+F9', (data, cancel) => { | ||
if (!menuBarViewElement.contains(this.editor.ui.focusTracker.focusedElement)) { | ||
menuBarView.isFocusBorderEnabled = true; | ||
menuBarView.focus(); | ||
cancel(); | ||
// If menu bar is already focused do nothing. | ||
if (menuBarViewElement.contains(this.editor.ui.focusTracker.focusedElement)) { | ||
return; | ||
} | ||
this._saveLastFocusedForeignElement(); | ||
menuBarView.isFocusBorderEnabled = true; | ||
menuBarView.focus(); | ||
cancel(); | ||
}); | ||
@@ -321,14 +338,6 @@ } | ||
const editingView = editor.editing.view; | ||
let lastFocusedForeignElement; | ||
let candidateDefinitions; | ||
// Focus the next focusable toolbar on <kbd>Alt</kbd> + <kbd>F10</kbd>. | ||
editor.keystrokes.set('Alt+F10', (data, cancel) => { | ||
const focusedElement = this.focusTracker.focusedElement; | ||
// Focus moved out of a DOM element that | ||
// * is not a toolbar, | ||
// * does not belong to the editing view (e.g. source editing). | ||
if (Array.from(this._editableElementsMap.values()).includes(focusedElement) && | ||
!Array.from(editingView.domRoots.values()).includes(focusedElement)) { | ||
lastFocusedForeignElement = focusedElement; | ||
} | ||
this._saveLastFocusedForeignElement(); | ||
const currentFocusedToolbarDefinition = this._getCurrentFocusedToolbarDefinition(); | ||
@@ -371,5 +380,5 @@ // * When focusing a toolbar for the first time, set the array of definitions for successive presses of Alt+F10. | ||
// 1. If it came from outside the engine view (e.g. source editing), move it there. | ||
if (lastFocusedForeignElement) { | ||
lastFocusedForeignElement.focus(); | ||
lastFocusedForeignElement = null; | ||
if (this._lastFocusedForeignElement) { | ||
this._lastFocusedForeignElement.focus(); | ||
this._lastFocusedForeignElement = null; | ||
} | ||
@@ -391,2 +400,15 @@ // 2. There are two possibilities left: | ||
/** | ||
* Saves last focused element that doen not belong to editing view to restore focus on `Esc`. | ||
*/ | ||
_saveLastFocusedForeignElement() { | ||
const focusedElement = this.focusTracker.focusedElement; | ||
// Focus moved out of a DOM element that | ||
// * is not a toolbar, | ||
// * does not belong to the editing view (e.g. source editing). | ||
if (Array.from(this._editableElementsMap.values()).includes(focusedElement) && | ||
!Array.from(this.editor.editing.view.domRoots.values()).includes(focusedElement)) { | ||
this._lastFocusedForeignElement = focusedElement; | ||
} | ||
} | ||
/** | ||
* Returns definitions of toolbars that could potentially be focused, sorted by their importance for the user. | ||
@@ -393,0 +415,0 @@ * |
Sorry, the diff of this file is too big to display
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
6265575
60608
+ Added@ckeditor/ckeditor5-core@0.0.0-nightly-20240713.0(transitive)
+ Added@ckeditor/ckeditor5-engine@0.0.0-nightly-20240713.0(transitive)
+ Added@ckeditor/ckeditor5-utils@0.0.0-nightly-20240713.0(transitive)
+ Added@ckeditor/ckeditor5-watchdog@0.0.0-nightly-20240713.0(transitive)
- Removed@ckeditor/ckeditor5-core@0.0.0-nightly-20240712.0(transitive)
- Removed@ckeditor/ckeditor5-engine@0.0.0-nightly-20240712.0(transitive)
- Removed@ckeditor/ckeditor5-utils@0.0.0-nightly-20240712.0(transitive)
- Removed@ckeditor/ckeditor5-watchdog@0.0.0-nightly-20240712.0(transitive)