mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
23 lines
633 B
TypeScript
23 lines
633 B
TypeScript
|
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService';
|
||
|
import NavService from '@joplin/lib/services/NavService';
|
||
|
|
||
|
export const declaration: CommandDeclaration = {
|
||
|
name: 'scrollToHash',
|
||
|
};
|
||
|
|
||
|
export const runtime = (): CommandRuntime => {
|
||
|
return {
|
||
|
execute: async (context: CommandContext, hash: string) => {
|
||
|
const selectedNoteIds = context.state.selectedNoteIds;
|
||
|
if (selectedNoteIds.length === 0) {
|
||
|
throw new Error('Unable to scroll to hash -- no note open.');
|
||
|
}
|
||
|
|
||
|
await NavService.go('Note', {
|
||
|
noteId: selectedNoteIds[0],
|
||
|
noteHash: hash,
|
||
|
});
|
||
|
},
|
||
|
};
|
||
|
};
|