diff --git a/src/operations/moveTo.ts b/src/operations/moveTo.ts index 180f40a..735d836 100644 --- a/src/operations/moveTo.ts +++ b/src/operations/moveTo.ts @@ -4,8 +4,9 @@ import { getSettings } from '@/common/funcs'; export default () => { const keyBindings = getSettings('keyBindings'); - const handler = async ({ uuid }) => { + const openMoveBlockWindow = async ({ uuid }) => { const targetStore = useTargetStore(); + if (uuid) { targetStore.setFallbackUUID(uuid); } @@ -24,8 +25,27 @@ export default () => { binding: keyBindings.moveBlock, }, }, - handler + openMoveBlockWindow ); - logseq.Editor.registerSlashCommand(`Move Block`, handler); - logseq.Editor.registerBlockContextMenuItem(`Move Block`, handler); + logseq.Editor.registerSlashCommand(`Move Block`, openMoveBlockWindow); + logseq.Editor.registerBlockContextMenuItem(`Move Block`, openMoveBlockWindow); + // Register icon ui + logseq.provideModel({ + async openMoveBlock() { + const block = await logseq.Editor.getCurrentBlock(); + if (!block || !block.uuid) { + logseq.UI.showMsg('Need to select one block at least!', 'warning'); + return; + } + await openMoveBlockWindow({ uuid: block.uuid }); + }, + }); + logseq.App.registerUIItem('pagebar', { + key: 'logseq-move-block', + template: ` + + + + `, + }); };