@ckeditor/ckeditor5-ckbox 0.0.0-nightly-20240531.0 → 0.0.0-nightly-20240602.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.
@@ -11,7 +11,14 @@
11
11
  */
12
12
  import { Plugin } from 'ckeditor5/src/core.js';
13
13
  /**
14
- * The CKBoxUI plugin. It introduces the `'ckbox'` toolbar button.
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.
15
22
  */
16
23
  export default class CKBoxUI extends Plugin {
17
24
  /**
@@ -23,7 +30,27 @@ export default class CKBoxUI extends Plugin {
23
30
  */
24
31
  afterInit(): void;
25
32
  /**
26
- * Creates a button for CKBox command to use either in toolbar or in menu bar.
33
+ * Creates the base for various kinds of the button component provided by this feature.
27
34
  */
28
35
  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;
29
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-ckbox",
3
- "version": "0.0.0-nightly-20240531.0",
3
+ "version": "0.0.0-nightly-20240602.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-20240531.0",
16
+ "ckeditor5": "0.0.0-nightly-20240602.0",
17
17
  "blurhash": "2.0.5",
18
18
  "lodash-es": "4.17.21"
19
19
  },
package/src/ckboxui.d.ts CHANGED
@@ -7,7 +7,14 @@
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
9
  /**
10
- * The CKBoxUI plugin. It introduces the `'ckbox'` toolbar button.
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.
11
18
  */
12
19
  export default class CKBoxUI extends Plugin {
13
20
  /**
@@ -19,7 +26,27 @@ export default class CKBoxUI extends Plugin {
19
26
  */
20
27
  afterInit(): void;
21
28
  /**
22
- * Creates a button for CKBox command to use either in toolbar or in menu bar.
29
+ * Creates the base for various kinds of the button component provided by this feature.
23
30
  */
24
31
  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;
25
52
  }
package/src/ckboxui.js CHANGED
@@ -8,7 +8,14 @@
8
8
  import { icons, Plugin } from 'ckeditor5/src/core.js';
9
9
  import { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
10
10
  /**
11
- * The CKBoxUI plugin. It introduces the `'ckbox'` toolbar button.
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.
12
19
  */
13
20
  export default class CKBoxUI extends Plugin {
14
21
  /**
@@ -27,44 +34,20 @@ export default class CKBoxUI extends Plugin {
27
34
  if (!editor.commands.get('ckbox')) {
28
35
  return;
29
36
  }
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));
37
+ editor.ui.componentFactory.add('ckbox', () => this._createFileToolbarButton());
38
+ editor.ui.componentFactory.add('menuBar:ckbox', () => this._createFileMenuBarButton());
38
39
  if (editor.plugins.has('ImageInsertUI')) {
39
- const imageInsertUI = editor.plugins.get('ImageInsertUI');
40
- imageInsertUI.registerIntegration({
40
+ editor.plugins.get('ImageInsertUI').registerIntegration({
41
41
  name: 'assetManager',
42
42
  observable: () => editor.commands.get('ckbox'),
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
- }
43
+ buttonViewCreator: () => this._createImageToolbarButton(),
44
+ formViewCreator: () => this._createImageDropdownButton(),
45
+ menuBarButtonViewCreator: isOnly => this._createImageMenuBarButton(isOnly ? 'insertOnly' : 'insertNested')
63
46
  });
64
47
  }
65
48
  }
66
49
  /**
67
- * Creates a button for CKBox command to use either in toolbar or in menu bar.
50
+ * Creates the base for various kinds of the button component provided by this feature.
68
51
  */
69
52
  _createButton(ButtonClass) {
70
53
  const editor = this.editor;
@@ -72,14 +55,77 @@ export default class CKBoxUI extends Plugin {
72
55
  const view = new ButtonClass(locale);
73
56
  const command = editor.commands.get('ckbox');
74
57
  const t = locale.t;
75
- view.set({
76
- label: t('Open file manager'),
77
- icon: icons.browseFiles
78
- });
79
58
  view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
80
59
  view.on('execute', () => {
81
60
  editor.execute('ckbox');
82
61
  });
83
62
  return view;
84
63
  }
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
+ }
85
131
  }