@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 +4 -4
- package/src/undoui.d.ts +5 -1
- package/src/undoui.js +31 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-undo",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
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-
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-
|
|
18
|
-
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-
|
|
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
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.
|
|
30
|
-
this.
|
|
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
|
-
|
|
40
|
+
_addButtonsToFactory(name, label, keystroke, Icon) {
|
|
41
41
|
const editor = this.editor;
|
|
42
|
-
editor.ui.componentFactory.add(name,
|
|
43
|
-
const
|
|
44
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
}
|