Sfoglia il codice sorgente

remove codemirror find and replace, edit menu findReplacers

Andrew Schlaepfer 6 anni fa
parent
commit
0e188bb47f

+ 0 - 24
packages/codemirror-extension/src/index.ts

@@ -42,8 +42,6 @@ namespace CommandIDs {
 
   export const find = 'codemirror:find';
 
-  export const findAndReplace = 'codemirror:find-and-replace';
-
   export const goToLine = 'codemirror:go-to-line';
 }
 
@@ -284,19 +282,6 @@ function activateEditorCommands(
     isEnabled
   });
 
-  commands.addCommand(CommandIDs.findAndReplace, {
-    label: 'Find and Replace...',
-    execute: () => {
-      let widget = tracker.currentWidget;
-      if (!widget) {
-        return;
-      }
-      let editor = widget.content.editor as CodeMirrorEditor;
-      editor.execCommand('replace');
-    },
-    isEnabled
-  });
-
   commands.addCommand(CommandIDs.goToLine, {
     label: 'Go to Line...',
     execute: () => {
@@ -395,15 +380,6 @@ function activateEditorCommands(
     // Add the syntax highlighting submenu to the `View` menu.
     mainMenu.viewMenu.addGroup([{ type: 'submenu', submenu: modeMenu }], 40);
 
-    // Add find-replace capabilities to the edit menu.
-    mainMenu.editMenu.findReplacers.add({
-      tracker,
-      findAndReplace: (widget: IDocumentWidget<FileEditor>) => {
-        let editor = widget.content.editor as CodeMirrorEditor;
-        editor.execCommand('replace');
-      }
-    } as IEditMenu.IFindReplacer<IDocumentWidget<FileEditor>>);
-
     // Add go to line capabilities to the edit menu.
     mainMenu.editMenu.goToLiners.add({
       tracker,

+ 0 - 16
packages/mainmenu-extension/src/index.ts

@@ -51,8 +51,6 @@ export namespace CommandIDs {
 
   export const find = 'editmenu:find';
 
-  export const findAndReplace = 'editmenu:find-and-replace';
-
   export const goToLine = 'editmenu:go-to-line';
 
   export const openFile = 'filemenu:open';
@@ -280,20 +278,6 @@ export function createEditMenu(app: JupyterFrontEnd, menu: EditMenu): void {
     10
   );
 
-  // Add the find-replace command to the Edit menu.
-  commands.addCommand(CommandIDs.findAndReplace, {
-    label: 'Find and Replace…',
-    isEnabled: Private.delegateEnabled(
-      app,
-      menu.findReplacers,
-      'findAndReplace'
-    ),
-    execute: Private.delegateExecute(app, menu.findReplacers, 'findAndReplace')
-  });
-  menu.addGroup(
-    [{ command: CommandIDs.find }, { command: CommandIDs.findAndReplace }],
-    200
-  );
   commands.addCommand(CommandIDs.goToLine, {
     label: 'Go to Line…',
     isEnabled: Private.delegateEnabled(app, menu.goToLiners, 'goToLine'),

+ 0 - 23
packages/mainmenu/src/edit.ts

@@ -19,11 +19,6 @@ export interface IEditMenu extends IJupyterLabMenu {
    */
   readonly clearers: Set<IEditMenu.IClearer<Widget>>;
 
-  /**
-   * A set storing IFindReplacers for the Edit menu.
-   */
-  readonly findReplacers: Set<IEditMenu.IFindReplacer<Widget>>;
-
   /**
    * A set storing IGoToLiners for the Edit menu.
    */
@@ -45,8 +40,6 @@ export class EditMenu extends JupyterLabMenu implements IEditMenu {
 
     this.clearers = new Set<IEditMenu.IClearer<Widget>>();
 
-    this.findReplacers = new Set<IEditMenu.IFindReplacer<Widget>>();
-
     this.goToLiners = new Set<IEditMenu.IGoToLiner<Widget>>();
   }
 
@@ -60,11 +53,6 @@ export class EditMenu extends JupyterLabMenu implements IEditMenu {
    */
   readonly clearers: Set<IEditMenu.IClearer<Widget>>;
 
-  /**
-   * A set storing IFindReplacers for the Edit menu.
-   */
-  readonly findReplacers: Set<IEditMenu.IFindReplacer<Widget>>;
-
   /**
    * A set storing IGoToLiners for the Edit menu.
    */
@@ -76,7 +64,6 @@ export class EditMenu extends JupyterLabMenu implements IEditMenu {
   dispose(): void {
     this.undoers.clear();
     this.clearers.clear();
-    this.findReplacers.clear();
     super.dispose();
   }
 }
@@ -125,16 +112,6 @@ export namespace IEditMenu {
     clearAll?: (widget: T) => void;
   }
 
-  /**
-   * Interface for an activity that uses Find/Find+Replace.
-   */
-  export interface IFindReplacer<T extends Widget> extends IMenuExtender<T> {
-    /**
-     * Execute a find/replace command for the activity.
-     */
-    findAndReplace?: (widget: T) => void;
-  }
-
   /**
    * Interface for an activity that uses Go to Line.
    */

+ 0 - 15
tests/test-mainmenu/src/edit.spec.ts

@@ -90,20 +90,5 @@ describe('@jupyterlab/mainmenu', () => {
         expect(wodget.state).to.equal('clearAll');
       });
     });
-
-    describe('#findReplacers', () => {
-      it('should allow setting of an IFindReplacer', () => {
-        const finder: IEditMenu.IFindReplacer<Wodget> = {
-          tracker,
-          findAndReplace: widget => {
-            widget.state = 'findAndReplace';
-            return;
-          }
-        };
-        menu.findReplacers.add(finder);
-        void delegateExecute(wodget, menu.findReplacers, 'findAndReplace');
-        expect(wodget.state).to.equal('findAndReplace');
-      });
-    });
   });
 });