Skip to content

Commit

Permalink
Merge branch 'release/v1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
freder committed Mar 23, 2023
2 parents dbbb1e2 + df36436 commit b5ae679
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
3 changes: 0 additions & 3 deletions .releaserc.json

This file was deleted.

34 changes: 30 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-plugin-jump-to-block",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist/index.html",
"logseq": {
"id": "logseq-plugin-jump-to-block"
Expand All @@ -16,11 +16,13 @@
"@logseq/libs": "^0.0.14",
"lodash": "^4.17.21",
"markdown-to-txt": "^2.0.1",
"ramda": "^0.28.0",
"react": "^18.2.0",
"react-command-palette": "^0.22.1",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/ramda": "^0.28.23",
"@types/react": "^18.0.28",
"@types/react-command-palette": "^0.18.1",
"@types/react-dom": "^18.0.11",
Expand Down
19 changes: 11 additions & 8 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { BlockEntity } from '@logseq/libs/dist/LSPlugin.user';
import React, { useEffect, useState } from 'react';
import CommandPalette, { Command } from 'react-command-palette';
import markdownToTxt from 'markdown-to-txt';
import * as R from 'ramda';

// @ts-ignore
import theme from '../../node_modules/react-command-palette/dist/themes/sublime-theme';
Expand All @@ -18,10 +19,10 @@ type PathItem = {

const scrollTo = async (blockUuid: string) => {
const page = await logseq.Editor.getCurrentPage();
if (!page) { return; }
logseq.Editor.scrollToBlockInPage(
page.name, blockUuid
);
if (!page) {
return console.error('failed to get current page');
}
logseq.Editor.scrollToBlockInPage(page.name, blockUuid);
};


Expand All @@ -30,12 +31,14 @@ const selectionHandler = async (
expand: boolean,
) => {
if (!item) {
return;
return console.info('nothing selected');
}
if (expand) {
for (const pathItem of item.path as PathItem[]) {
await logseq.Editor.setBlockCollapsed(pathItem.uuid, false);
}
await Promise.all(
R.dropLast(1, item.path as PathItem[])
.filter((pathItem) => pathItem.collapsed)
.map(({ uuid }) => logseq.Editor.setBlockCollapsed(uuid, false))
);
}
if (item) scrollTo(item.id as string);
};
Expand Down

0 comments on commit b5ae679

Please sign in to comment.