Skip to content

Commit

Permalink
wip: optimize history
Browse files Browse the repository at this point in the history
  • Loading branch information
vipzhicheng committed Mar 20, 2023
1 parent a603911 commit b8a7a02
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/operations/moveTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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: `
<a class="button" data-on-click="openMoveBlock" title="Open move block window">
<i class="ti ti-corner-up-right" style=""></i>
</a>
`,
});
};

0 comments on commit b8a7a02

Please sign in to comment.