1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

Desktop: Fix issue that was preventing editor context menu from being refreshed (#4303)

This commit is contained in:
Caleb John
2021-01-08 09:35:23 -07:00
committed by GitHub
parent 4a0fb124a7
commit c484c88715
18 changed files with 202 additions and 82 deletions

View File

@@ -1,6 +1,5 @@
import { useEffect } from 'react';
import { FormNote, ScrollOptionTypes } from './types';
import editorCommandDeclarations from '../commands/editorCommandDeclarations';
import CommandService, { CommandDeclaration, CommandRuntime, CommandContext } from '@joplin/lib/services/CommandService';
const time = require('@joplin/lib/time').default;
const { reg } = require('@joplin/lib/registry.js');
@@ -20,6 +19,7 @@ interface HookDependencies {
titleInputRef: any;
saveNoteAndWait: Function;
setFormNote: Function;
plugins: any;
}
function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any, setFormNote: Function): CommandRuntime {
@@ -61,10 +61,10 @@ function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any, s
}
export default function useWindowCommandHandler(dependencies: HookDependencies) {
const { setShowLocalSearch, noteSearchBarRef, editorRef, titleInputRef, setFormNote } = dependencies;
const { setShowLocalSearch, noteSearchBarRef, editorRef, titleInputRef, setFormNote, plugins } = dependencies;
useEffect(() => {
for (const declaration of editorCommandDeclarations) {
for (const declaration of CommandService.instance().editorCommandDeclarations()) {
CommandService.instance().registerRuntime(declaration.name, editorCommandRuntime(declaration, editorRef, setFormNote));
}
@@ -80,7 +80,7 @@ export default function useWindowCommandHandler(dependencies: HookDependencies)
}
return () => {
for (const declaration of editorCommandDeclarations) {
for (const declaration of CommandService.instance().editorCommandDeclarations()) {
CommandService.instance().unregisterRuntime(declaration.name);
}
@@ -88,5 +88,5 @@ export default function useWindowCommandHandler(dependencies: HookDependencies)
CommandService.instance().unregisterRuntime(command.declaration.name);
}
};
}, [editorRef, setShowLocalSearch, noteSearchBarRef, titleInputRef]);
}, [editorRef, setShowLocalSearch, noteSearchBarRef, titleInputRef, plugins]);
}