@ckeditor/ckeditor5-ckbox 0.0.0-nightly-20240602.0 → 0.0.0-nightly-20240604.0

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.
@@ -36,14 +36,6 @@ export default class CKBoxImageEditCommand extends Command {
36
36
  * A wrapper function to prepare mount options. Ensures that at most one preparation is in-flight.
37
37
  */
38
38
  private _prepareOptions;
39
- /**
40
- * CKBox's onClose function runs before the final cleanup, potentially causing
41
- * page layout changes after it finishes. To address this, we use a setTimeout hack
42
- * to ensure that floating elements on the page maintain their correct position.
43
- *
44
- * See: https://github.com/ckeditor/ckeditor5/issues/16153.
45
- */
46
- private _updateUiDelayed;
47
39
  /**
48
40
  * @inheritDoc
49
41
  */
@@ -11,14 +11,7 @@
11
11
  */
12
12
  import { Plugin } from 'ckeditor5/src/core.js';
13
13
  /**
14
- * Introduces UI components for the `CKBox` plugin.
15
- *
16
- * The plugin introduces two UI components to the {@link module:ui/componentfactory~ComponentFactory UI component factory}:
17
- *
18
- * * the `'ckbox'` toolbar button,
19
- * * the `'menuBar:ckbox'` menu bar component, which is by default added to the `'Insert'` menu.
20
- *
21
- * It also integrates with the `insertImage` toolbar component and `menuBar:insertImage` menu component.
14
+ * The CKBoxUI plugin. It introduces the `'ckbox'` toolbar button.
22
15
  */
23
16
  export default class CKBoxUI extends Plugin {
24
17
  /**
@@ -30,27 +23,7 @@ export default class CKBoxUI extends Plugin {
30
23
  */
31
24
  afterInit(): void;
32
25
  /**
33
- * Creates the base for various kinds of the button component provided by this feature.
26
+ * Creates a button for CKBox command to use either in toolbar or in menu bar.
34
27
  */
35
28
  private _createButton;
36
- /**
37
- * Creates a simple toolbar button for files management, with an icon and a tooltip.
38
- */
39
- private _createFileToolbarButton;
40
- /**
41
- * Creates a simple toolbar button for images management, with an icon and a tooltip.
42
- */
43
- private _createImageToolbarButton;
44
- /**
45
- * Creates a button for images management for the dropdown view, with an icon, text and no tooltip.
46
- */
47
- private _createImageDropdownButton;
48
- /**
49
- * Creates a button for files management for the menu bar.
50
- */
51
- private _createFileMenuBarButton;
52
- /**
53
- * Creates a button for images management for the menu bar.
54
- */
55
- private _createImageMenuBarButton;
56
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-ckbox",
3
- "version": "0.0.0-nightly-20240602.0",
3
+ "version": "0.0.0-nightly-20240604.0",
4
4
  "description": "CKBox integration for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,7 +13,7 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "ckeditor5": "0.0.0-nightly-20240602.0",
16
+ "ckeditor5": "0.0.0-nightly-20240604.0",
17
17
  "blurhash": "2.0.5",
18
18
  "lodash-es": "4.17.21"
19
19
  },
@@ -32,14 +32,6 @@ export default class CKBoxImageEditCommand extends Command {
32
32
  * A wrapper function to prepare mount options. Ensures that at most one preparation is in-flight.
33
33
  */
34
34
  private _prepareOptions;
35
- /**
36
- * CKBox's onClose function runs before the final cleanup, potentially causing
37
- * page layout changes after it finishes. To address this, we use a setTimeout hack
38
- * to ensure that floating elements on the page maintain their correct position.
39
- *
40
- * See: https://github.com/ckeditor/ckeditor5/issues/16153.
41
- */
42
- private _updateUiDelayed;
43
35
  /**
44
36
  * @inheritDoc
45
37
  */
@@ -7,7 +7,7 @@
7
7
  * @module ckbox/ckboximageedit/ckboximageeditcommand
8
8
  */
9
9
  import { Command, PendingActions } from 'ckeditor5/src/core.js';
10
- import { CKEditorError, abortableDebounce, createElement, retry, delay } from 'ckeditor5/src/utils.js';
10
+ import { CKEditorError, abortableDebounce, createElement, retry } from 'ckeditor5/src/utils.js';
11
11
  import { Notification } from 'ckeditor5/src/ui.js';
12
12
  import { isEqual } from 'lodash-es';
13
13
  import { sendHttpRequest } from '../utils.js';
@@ -33,14 +33,6 @@ export default class CKBoxImageEditCommand extends Command {
33
33
  * The states of image processing in progress.
34
34
  */
35
35
  this._processInProgress = new Set();
36
- /**
37
- * CKBox's onClose function runs before the final cleanup, potentially causing
38
- * page layout changes after it finishes. To address this, we use a setTimeout hack
39
- * to ensure that floating elements on the page maintain their correct position.
40
- *
41
- * See: https://github.com/ckeditor/ckeditor5/issues/16153.
42
- */
43
- this._updateUiDelayed = delay(() => this.editor.ui.update(), 0);
44
36
  this.value = false;
45
37
  this._canEdit = createEditabilityChecker(editor.config.get('ckbox.allowExternalImagesEditing'));
46
38
  this._prepareOptions = abortableDebounce((signal, state) => this._prepareOptionsAbortable(signal, state));
@@ -91,7 +83,6 @@ export default class CKBoxImageEditCommand extends Command {
91
83
  destroy() {
92
84
  this._handleImageEditorClose();
93
85
  this._prepareOptions.abort();
94
- this._updateUiDelayed.cancel();
95
86
  for (const state of this._processInProgress.values()) {
96
87
  state.controller.abort();
97
88
  }
@@ -179,7 +170,6 @@ export default class CKBoxImageEditCommand extends Command {
179
170
  this._wrapper.remove();
180
171
  this._wrapper = null;
181
172
  this.editor.editing.view.focus();
182
- this._updateUiDelayed();
183
173
  this.refresh();
184
174
  }
185
175
  /**
package/src/ckboxui.d.ts CHANGED
@@ -7,14 +7,7 @@
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
9
  /**
10
- * Introduces UI components for the `CKBox` plugin.
11
- *
12
- * The plugin introduces two UI components to the {@link module:ui/componentfactory~ComponentFactory UI component factory}:
13
- *
14
- * * the `'ckbox'` toolbar button,
15
- * * the `'menuBar:ckbox'` menu bar component, which is by default added to the `'Insert'` menu.
16
- *
17
- * It also integrates with the `insertImage` toolbar component and `menuBar:insertImage` menu component.
10
+ * The CKBoxUI plugin. It introduces the `'ckbox'` toolbar button.
18
11
  */
19
12
  export default class CKBoxUI extends Plugin {
20
13
  /**
@@ -26,27 +19,7 @@ export default class CKBoxUI extends Plugin {
26
19
  */
27
20
  afterInit(): void;
28
21
  /**
29
- * Creates the base for various kinds of the button component provided by this feature.
22
+ * Creates a button for CKBox command to use either in toolbar or in menu bar.
30
23
  */
31
24
  private _createButton;
32
- /**
33
- * Creates a simple toolbar button for files management, with an icon and a tooltip.
34
- */
35
- private _createFileToolbarButton;
36
- /**
37
- * Creates a simple toolbar button for images management, with an icon and a tooltip.
38
- */
39
- private _createImageToolbarButton;
40
- /**
41
- * Creates a button for images management for the dropdown view, with an icon, text and no tooltip.
42
- */
43
- private _createImageDropdownButton;
44
- /**
45
- * Creates a button for files management for the menu bar.
46
- */
47
- private _createFileMenuBarButton;
48
- /**
49
- * Creates a button for images management for the menu bar.
50
- */
51
- private _createImageMenuBarButton;
52
25
  }
package/src/ckboxui.js CHANGED
@@ -8,14 +8,7 @@
8
8
  import { icons, Plugin } from 'ckeditor5/src/core.js';
9
9
  import { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
10
10
  /**
11
- * Introduces UI components for the `CKBox` plugin.
12
- *
13
- * The plugin introduces two UI components to the {@link module:ui/componentfactory~ComponentFactory UI component factory}:
14
- *
15
- * * the `'ckbox'` toolbar button,
16
- * * the `'menuBar:ckbox'` menu bar component, which is by default added to the `'Insert'` menu.
17
- *
18
- * It also integrates with the `insertImage` toolbar component and `menuBar:insertImage` menu component.
11
+ * The CKBoxUI plugin. It introduces the `'ckbox'` toolbar button.
19
12
  */
20
13
  export default class CKBoxUI extends Plugin {
21
14
  /**
@@ -34,20 +27,44 @@ export default class CKBoxUI extends Plugin {
34
27
  if (!editor.commands.get('ckbox')) {
35
28
  return;
36
29
  }
37
- editor.ui.componentFactory.add('ckbox', () => this._createFileToolbarButton());
38
- editor.ui.componentFactory.add('menuBar:ckbox', () => this._createFileMenuBarButton());
30
+ const t = editor.t;
31
+ const componentFactory = editor.ui.componentFactory;
32
+ componentFactory.add('ckbox', () => {
33
+ const button = this._createButton(ButtonView);
34
+ button.tooltip = true;
35
+ return button;
36
+ });
37
+ componentFactory.add('menuBar:ckbox', () => this._createButton(MenuBarMenuListItemButtonView));
39
38
  if (editor.plugins.has('ImageInsertUI')) {
40
- editor.plugins.get('ImageInsertUI').registerIntegration({
39
+ const imageInsertUI = editor.plugins.get('ImageInsertUI');
40
+ imageInsertUI.registerIntegration({
41
41
  name: 'assetManager',
42
42
  observable: () => editor.commands.get('ckbox'),
43
- buttonViewCreator: () => this._createImageToolbarButton(),
44
- formViewCreator: () => this._createImageDropdownButton(),
45
- menuBarButtonViewCreator: isOnly => this._createImageMenuBarButton(isOnly ? 'insertOnly' : 'insertNested')
43
+ buttonViewCreator: () => {
44
+ const button = this.editor.ui.componentFactory.create('ckbox');
45
+ button.icon = icons.imageAssetManager;
46
+ button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ?
47
+ t('Replace image with file manager') :
48
+ t('Insert image with file manager'));
49
+ return button;
50
+ },
51
+ formViewCreator: () => {
52
+ const button = this.editor.ui.componentFactory.create('ckbox');
53
+ button.icon = icons.imageAssetManager;
54
+ button.withText = true;
55
+ button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ?
56
+ t('Replace with file manager') :
57
+ t('Insert with file manager'));
58
+ button.on('execute', () => {
59
+ imageInsertUI.dropdownView.isOpen = false;
60
+ });
61
+ return button;
62
+ }
46
63
  });
47
64
  }
48
65
  }
49
66
  /**
50
- * Creates the base for various kinds of the button component provided by this feature.
67
+ * Creates a button for CKBox command to use either in toolbar or in menu bar.
51
68
  */
52
69
  _createButton(ButtonClass) {
53
70
  const editor = this.editor;
@@ -55,77 +72,14 @@ export default class CKBoxUI extends Plugin {
55
72
  const view = new ButtonClass(locale);
56
73
  const command = editor.commands.get('ckbox');
57
74
  const t = locale.t;
75
+ view.set({
76
+ label: t('Open file manager'),
77
+ icon: icons.browseFiles
78
+ });
58
79
  view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
59
80
  view.on('execute', () => {
60
81
  editor.execute('ckbox');
61
82
  });
62
83
  return view;
63
84
  }
64
- /**
65
- * Creates a simple toolbar button for files management, with an icon and a tooltip.
66
- */
67
- _createFileToolbarButton() {
68
- const t = this.editor.locale.t;
69
- const button = this._createButton(ButtonView);
70
- button.icon = icons.browseFiles;
71
- button.label = t('Open file manager');
72
- button.tooltip = true;
73
- return button;
74
- }
75
- /**
76
- * Creates a simple toolbar button for images management, with an icon and a tooltip.
77
- */
78
- _createImageToolbarButton() {
79
- const t = this.editor.locale.t;
80
- const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
81
- const button = this._createButton(ButtonView);
82
- button.icon = icons.imageAssetManager;
83
- button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace image with file manager') : t('Insert image with file manager'));
84
- button.tooltip = true;
85
- return button;
86
- }
87
- /**
88
- * Creates a button for images management for the dropdown view, with an icon, text and no tooltip.
89
- */
90
- _createImageDropdownButton() {
91
- const t = this.editor.locale.t;
92
- const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
93
- const button = this._createButton(ButtonView);
94
- button.icon = icons.imageAssetManager;
95
- button.withText = true;
96
- button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace with file manager') : t('Insert with file manager'));
97
- button.on('execute', () => {
98
- imageInsertUI.dropdownView.isOpen = false;
99
- });
100
- return button;
101
- }
102
- /**
103
- * Creates a button for files management for the menu bar.
104
- */
105
- _createFileMenuBarButton() {
106
- const t = this.editor.locale.t;
107
- const button = this._createButton(MenuBarMenuListItemButtonView);
108
- button.icon = icons.browseFiles;
109
- button.withText = true;
110
- button.label = t('File');
111
- return button;
112
- }
113
- /**
114
- * Creates a button for images management for the menu bar.
115
- */
116
- _createImageMenuBarButton(type) {
117
- const t = this.editor.locale.t;
118
- const button = this._createButton(MenuBarMenuListItemButtonView);
119
- button.icon = icons.imageAssetManager;
120
- button.withText = true;
121
- switch (type) {
122
- case 'insertOnly':
123
- button.label = t('Image');
124
- break;
125
- case 'insertNested':
126
- button.label = t('With file manager');
127
- break;
128
- }
129
- return button;
130
- }
131
85
  }