|
@@ -38,12 +38,13 @@ import {
|
|
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
|
|
|
|
import {
|
|
|
- markdownIcon,
|
|
|
- textEditorIcon,
|
|
|
- undoIcon,
|
|
|
cutIcon,
|
|
|
copyIcon,
|
|
|
- pasteIcon
|
|
|
+ markdownIcon,
|
|
|
+ pasteIcon,
|
|
|
+ redoIcon,
|
|
|
+ textEditorIcon,
|
|
|
+ undoIcon
|
|
|
} from '@jupyterlab/ui-components';
|
|
|
|
|
|
import { CommandRegistry } from '@lumino/commands';
|
|
@@ -84,6 +85,8 @@ export namespace CommandIDs {
|
|
|
|
|
|
export const undo = 'fileeditor:undo';
|
|
|
|
|
|
+ export const redo = 'fileeditor:redo';
|
|
|
+
|
|
|
export const cut = 'fileeditor:cut';
|
|
|
|
|
|
export const copy = 'fileeditor:copy';
|
|
@@ -218,6 +221,8 @@ export namespace Commands {
|
|
|
|
|
|
addUndoCommand(commands, tracker, isEnabled);
|
|
|
|
|
|
+ addRedoCommand(commands, tracker, isEnabled);
|
|
|
+
|
|
|
addCutCommand(commands, tracker, isEnabled);
|
|
|
|
|
|
addCopyCommand(commands, tracker, isEnabled);
|
|
@@ -613,6 +618,42 @@ export namespace Commands {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Add redo command
|
|
|
+ */
|
|
|
+ export function addRedoCommand(
|
|
|
+ commands: CommandRegistry,
|
|
|
+ tracker: WidgetTracker<IDocumentWidget<FileEditor>>,
|
|
|
+ isEnabled: () => boolean
|
|
|
+ ) {
|
|
|
+ commands.addCommand(CommandIDs.redo, {
|
|
|
+ execute: () => {
|
|
|
+ const widget = tracker.currentWidget?.content;
|
|
|
+
|
|
|
+ if (!widget) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ widget.editor.redo();
|
|
|
+ },
|
|
|
+ isEnabled: () => {
|
|
|
+ if (!isEnabled()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ const widget = tracker.currentWidget?.content;
|
|
|
+
|
|
|
+ if (!widget) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // TODO: Enable based if any undo events are stored
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ icon: redoIcon.bindprops({ stylesheet: 'menuItem' }),
|
|
|
+ label: 'Redo'
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Add cut command
|
|
|
*/
|
|
@@ -1155,6 +1196,7 @@ export namespace Commands {
|
|
|
addCreateConsoleToContextMenu(app);
|
|
|
addMarkdownPreviewToContextMenu(app);
|
|
|
addUndoCommandToContextMenu(app);
|
|
|
+ addRedoCommandToContextMenu(app);
|
|
|
addCutCommandToContextMenu(app);
|
|
|
addCopyCommandToContextMenu(app);
|
|
|
addPasteCommandToContextMenu(app);
|
|
@@ -1192,6 +1234,17 @@ export namespace Commands {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Add a Redo item to the File Editor context menu
|
|
|
+ */
|
|
|
+ export function addRedoCommandToContextMenu(app: JupyterFrontEnd) {
|
|
|
+ app.contextMenu.addItem({
|
|
|
+ command: CommandIDs.redo,
|
|
|
+ selector: '.jp-FileEditor',
|
|
|
+ rank: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Add a Cut item to the File Editor context menu
|
|
|
*/
|