@ckeditor/ckeditor5-undo 0.0.0-nightly-20240401.0 → 0.0.0-nightly-20240403.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-undo",
3
- "version": "0.0.0-nightly-20240401.0",
3
+ "version": "0.0.0-nightly-20240403.0",
4
4
  "description": "Undo feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,9 +13,9 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "0.0.0-nightly-20240401.0",
17
- "@ckeditor/ckeditor5-engine": "0.0.0-nightly-20240401.0",
18
- "@ckeditor/ckeditor5-ui": "0.0.0-nightly-20240401.0"
16
+ "@ckeditor/ckeditor5-core": "0.0.0-nightly-20240403.0",
17
+ "@ckeditor/ckeditor5-engine": "0.0.0-nightly-20240403.0",
18
+ "@ckeditor/ckeditor5-ui": "0.0.0-nightly-20240403.0"
19
19
  },
20
20
  "author": "CKSource (http://cksource.com/)",
21
21
  "license": "GPL-2.0-or-later",
package/src/undoui.d.ts CHANGED
@@ -26,5 +26,9 @@ export default class UndoUI extends Plugin {
26
26
  * @param keystroke Command keystroke.
27
27
  * @param Icon Source of the icon.
28
28
  */
29
- private _addButton;
29
+ private _addButtonsToFactory;
30
+ /**
31
+ * TODO
32
+ */
33
+ private _createButton;
30
34
  }
package/src/undoui.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * @module undo/undoui
7
7
  */
8
8
  import { icons, Plugin } from '@ckeditor/ckeditor5-core';
9
- import { ButtonView } from '@ckeditor/ckeditor5-ui';
9
+ import { ButtonView, MenuBarMenuListItemButtonView } from '@ckeditor/ckeditor5-ui';
10
10
  /**
11
11
  * The undo UI feature. It introduces the `'undo'` and `'redo'` buttons to the editor.
12
12
  */
@@ -26,8 +26,8 @@ export default class UndoUI extends Plugin {
26
26
  const t = editor.t;
27
27
  const localizedUndoIcon = locale.uiLanguageDirection == 'ltr' ? icons.undo : icons.redo;
28
28
  const localizedRedoIcon = locale.uiLanguageDirection == 'ltr' ? icons.redo : icons.undo;
29
- this._addButton('undo', t('Undo'), 'CTRL+Z', localizedUndoIcon);
30
- this._addButton('redo', t('Redo'), 'CTRL+Y', localizedRedoIcon);
29
+ this._addButtonsToFactory('undo', t('Undo'), 'CTRL+Z', localizedUndoIcon);
30
+ this._addButtonsToFactory('redo', t('Redo'), 'CTRL+Y', localizedRedoIcon);
31
31
  }
32
32
  /**
33
33
  * Creates a button for the specified command.
@@ -37,23 +37,37 @@ export default class UndoUI extends Plugin {
37
37
  * @param keystroke Command keystroke.
38
38
  * @param Icon Source of the icon.
39
39
  */
40
- _addButton(name, label, keystroke, Icon) {
40
+ _addButtonsToFactory(name, label, keystroke, Icon) {
41
41
  const editor = this.editor;
42
- editor.ui.componentFactory.add(name, locale => {
43
- const command = editor.commands.get(name);
44
- const view = new ButtonView(locale);
45
- view.set({
46
- label,
47
- icon: Icon,
48
- keystroke,
42
+ editor.ui.componentFactory.add(name, () => {
43
+ const buttonView = this._createButton(ButtonView, name, label, keystroke, Icon);
44
+ buttonView.set({
49
45
  tooltip: true
50
46
  });
51
- view.bind('isEnabled').to(command, 'isEnabled');
52
- this.listenTo(view, 'execute', () => {
53
- editor.execute(name);
54
- editor.editing.view.focus();
55
- });
56
- return view;
47
+ return buttonView;
48
+ });
49
+ editor.ui.componentFactory.add('menuBar:' + name, () => {
50
+ return this._createButton(MenuBarMenuListItemButtonView, name, label, keystroke, Icon);
51
+ });
52
+ }
53
+ /**
54
+ * TODO
55
+ */
56
+ _createButton(ButtonClass, name, label, keystroke, Icon) {
57
+ const editor = this.editor;
58
+ const locale = editor.locale;
59
+ const command = editor.commands.get(name);
60
+ const view = new ButtonClass(locale);
61
+ view.set({
62
+ label,
63
+ icon: Icon,
64
+ keystroke
65
+ });
66
+ view.bind('isEnabled').to(command, 'isEnabled');
67
+ this.listenTo(view, 'execute', () => {
68
+ editor.execute(name);
69
+ editor.editing.view.focus();
57
70
  });
71
+ return view;
58
72
  }
59
73
  }