@ckeditor/ckeditor5-fullscreen 45.1.0-alpha.4 → 45.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-fullscreen",
3
- "version": "45.1.0-alpha.4",
3
+ "version": "45.1.0-alpha.6",
4
4
  "description": "Fullscreen mode feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,13 +13,13 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "45.1.0-alpha.4",
17
- "@ckeditor/ckeditor5-editor-classic": "45.1.0-alpha.4",
18
- "@ckeditor/ckeditor5-editor-decoupled": "45.1.0-alpha.4",
19
- "@ckeditor/ckeditor5-icons": "45.1.0-alpha.4",
20
- "@ckeditor/ckeditor5-ui": "45.1.0-alpha.4",
21
- "@ckeditor/ckeditor5-utils": "45.1.0-alpha.4",
22
- "ckeditor5": "45.1.0-alpha.4"
16
+ "@ckeditor/ckeditor5-core": "45.1.0-alpha.6",
17
+ "@ckeditor/ckeditor5-editor-classic": "45.1.0-alpha.6",
18
+ "@ckeditor/ckeditor5-editor-decoupled": "45.1.0-alpha.6",
19
+ "@ckeditor/ckeditor5-icons": "45.1.0-alpha.6",
20
+ "@ckeditor/ckeditor5-ui": "45.1.0-alpha.6",
21
+ "@ckeditor/ckeditor5-utils": "45.1.0-alpha.6",
22
+ "ckeditor5": "45.1.0-alpha.6"
23
23
  },
24
24
  "author": "CKSource (http://cksource.com/)",
25
25
  "license": "SEE LICENSE IN LICENSE.md",
@@ -165,7 +165,7 @@ export default class AbstractEditorHandler {
165
165
  */
166
166
  private _restoreDocumentOutlineDefaultContainer;
167
167
  /**
168
- * Stores the current state of the annotations UIs to restore it when leaving fullscreen mode.
168
+ * Stores the current state of the annotations UIs to restore it when leaving fullscreen mode and switches the UI to the wide sidebar.
169
169
  */
170
170
  private _overrideAnnotationsUIs;
171
171
  /**
@@ -412,18 +412,13 @@ export default class AbstractEditorHandler {
412
412
  documentOutlineUI.view.documentOutlineContainer = documentOutlineUI.view.element;
413
413
  }
414
414
  /**
415
- * Stores the current state of the annotations UIs to restore it when leaving fullscreen mode.
415
+ * Stores the current state of the annotations UIs to restore it when leaving fullscreen mode and switches the UI to the wide sidebar.
416
416
  */
417
417
  // Code coverage is provided in the commercial package repository as integration unit tests.
418
418
  /* istanbul ignore next -- @preserve */
419
419
  _overrideAnnotationsUIs() {
420
420
  const annotationsUIs = this._editor.plugins.get('AnnotationsUIs');
421
421
  this._annotationsUIsData = new Map(annotationsUIs.uisData);
422
- // Switch to the wide sidebar.
423
- const sidebarPlugin = this._editor.plugins.get('Sidebar');
424
- if (!sidebarPlugin.container) {
425
- sidebarPlugin.setContainer(this.getWrapper().querySelector('[data-ck-fullscreen="right-sidebar"]'));
426
- }
427
422
  const annotationsFilters = new Map();
428
423
  for (const [uiName, data] of [...this._annotationsUIsData]) {
429
424
  // Default filter is `() => true`. Only store filters that are different.
@@ -432,20 +427,43 @@ export default class AbstractEditorHandler {
432
427
  }
433
428
  }
434
429
  annotationsUIs.deactivateAll();
435
- // Check if someone has a filter defined for `wideSidebar`. If so, retrieve and apply it in fullscreen. Do not show any other UI.
436
- if (annotationsFilters.has('wideSidebar')) {
437
- annotationsUIs.activate('wideSidebar', annotationsFilters.get('wideSidebar'));
438
- }
439
- // If no filter is defined for `wideSidebar`, read the filters for the active display(s) mode and apply them.
440
- // It's possible there are filters for both `narrowSidebar` and `inline` modes, so display annotations that match any of them.
441
- else if (annotationsFilters.size) {
442
- annotationsUIs.activate('wideSidebar', (annotation) => [...annotationsFilters.values()].some(filter => filter(annotation)));
443
- }
444
- // If no filters are defined for the active display mode(s), simply display all annotations in the wide sidebar.
430
+ const sidebarPlugin = this._editor.plugins.get('Sidebar');
431
+ // There are two scenarios to consider: if wide sidebar is already used and when it's not.
432
+ // If sidebar container is not set (e.g. in case of inline annotations), we need to:
433
+ // 1. Set the sidebar container in the sidebar plugin.
434
+ // 2. Activate the wide sidebar UI.
435
+ // 3. Move the sidebar element to the fullscreen mode.
436
+ if (!sidebarPlugin.container) {
437
+ sidebarPlugin.setContainer(this.getWrapper().querySelector('[data-ck-fullscreen="right-sidebar"]'));
438
+ switchToWideSidebar();
439
+ this.moveToFullscreen(sidebarPlugin.container.firstElementChild, 'right-sidebar');
440
+ }
441
+ // If sidebar was already used:
442
+ // 1. Switch to the wide sidebar UI (it's possibly switch back but we deactivated all UIs before).
443
+ // 2. Move the sidebar element to the fullscreen mode.
444
+ // 3. Set the sidebar container in the sidebar plugin.
445
+ // If we set the container before moving the sidebar, we lose the reference to the original sidebar container and it won't be
446
+ // moved back to the correct position after leaving fullscreen.
445
447
  else {
446
- annotationsUIs.switchTo('wideSidebar');
448
+ switchToWideSidebar();
449
+ this.moveToFullscreen(sidebarPlugin.container.firstElementChild, 'right-sidebar');
450
+ sidebarPlugin.setContainer(this.getWrapper().querySelector('[data-ck-fullscreen="right-sidebar"]'));
451
+ }
452
+ function switchToWideSidebar() {
453
+ // First, check if someone has a filter defined for `wideSidebar`. If so, retrieve and apply it in fullscreen.
454
+ if (annotationsFilters.has('wideSidebar')) {
455
+ annotationsUIs.activate('wideSidebar', annotationsFilters.get('wideSidebar'));
456
+ }
457
+ // If no filter is defined for `wideSidebar`, read the filters for the active display(s) mode and apply them on wide sidebar.
458
+ // It's possible there are filters for both `narrowSidebar` and `inline` modes, so display annotations that match any of them.
459
+ else if (annotationsFilters.size) {
460
+ annotationsUIs.activate('wideSidebar', (annotation) => [...annotationsFilters.values()].some(filter => filter(annotation)));
461
+ }
462
+ // If no filters are defined for the active display mode(s), simply display all annotations in the wide sidebar.
463
+ else {
464
+ annotationsUIs.switchTo('wideSidebar');
465
+ }
447
466
  }
448
- this.moveToFullscreen(sidebarPlugin.container.firstElementChild, 'right-sidebar');
449
467
  }
450
468
  /**
451
469
  * Restores the saved state of the annotations UIs.
@@ -453,6 +471,12 @@ export default class AbstractEditorHandler {
453
471
  // Code coverage is provided in the commercial package repository as integration unit tests.
454
472
  /* istanbul ignore next -- @preserve */
455
473
  _restoreAnnotationsUIs() {
474
+ const sidebarPlugin = this._editor.plugins.get('Sidebar');
475
+ const sidebarContainer = sidebarPlugin.context.config.get('sidebar.container');
476
+ // If sidebar container was set initially, restore it to the original value from config.
477
+ if (sidebarContainer) {
478
+ sidebarPlugin.setContainer(sidebarContainer);
479
+ }
456
480
  const annotationsUIs = this._editor.plugins.get('AnnotationsUIs');
457
481
  annotationsUIs.deactivateAll();
458
482
  for (const [uiName, data] of [...this._annotationsUIsData]) {