From 5099f0261ac9b0aa5a34bbe7a6718cf25a8b1e28 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 22 Mar 2023 14:45:10 +0100 Subject: [PATCH 1/5] removed unused file --- .releaserc.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .releaserc.json diff --git a/.releaserc.json b/.releaserc.json deleted file mode 100644 index 8048e97..0000000 --- a/.releaserc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "npmPublish": false -} From 1776c0bfffb0cfabfdd5eca449b0f1531d709a15 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Thu, 23 Mar 2023 12:41:34 +0100 Subject: [PATCH 2/5] expand in parallel --- src/components/App.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 441f216..f0b6d7d 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -33,9 +33,11 @@ const selectionHandler = async ( return; } if (expand) { - for (const pathItem of item.path as PathItem[]) { - await logseq.Editor.setBlockCollapsed(pathItem.uuid, false); - } + await Promise.all( + (item.path as PathItem[]) + .filter((pathItem) => pathItem.collapsed) + .map(({ uuid }) => logseq.Editor.setBlockCollapsed(uuid, false)) + ); } if (item) scrollTo(item.id as string); }; From e599c0b35c6d80384347d7b50ef4474307abda3d Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Thu, 23 Mar 2023 13:58:27 +0100 Subject: [PATCH 3/5] fix: don't expand the actual block --- package-lock.json | 34 ++++++++++++++++++++++++++++++---- package.json | 2 ++ src/components/App.tsx | 3 ++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 45f89a4..2d203a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,23 @@ { - "name": "logseq-plugin-go-to-symbol", - "version": "0.1.0", + "name": "logseq-plugin-jump-to-block", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "logseq-plugin-go-to-symbol", - "version": "0.1.0", + "name": "logseq-plugin-jump-to-block", + "version": "1.0.1", "dependencies": { "@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", @@ -970,6 +972,15 @@ "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", "dev": true }, + "node_modules/@types/ramda": { + "version": "0.28.23", + "resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.28.23.tgz", + "integrity": "sha512-9TYWiwkew+mCMsL7jZ+kkzy6QXn8PL5/SKmBPmjgUlTpkokZWTBr+OhiIUDztpAEbslWyt24NNfEmZUBFmnXig==", + "dev": true, + "dependencies": { + "ts-toolbelt": "^6.15.1" + } + }, "node_modules/@types/react": { "version": "18.0.28", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.28.tgz", @@ -3589,6 +3600,15 @@ } ] }, + "node_modules/ramda": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz", + "integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ramda" + } + }, "node_modules/react": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", @@ -4099,6 +4119,12 @@ "node": ">=8.0" } }, + "node_modules/ts-toolbelt": { + "version": "6.15.5", + "resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz", + "integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==", + "dev": true + }, "node_modules/tslib": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", diff --git a/package.json b/package.json index 4c36495..11d9ba9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/App.tsx b/src/components/App.tsx index f0b6d7d..59bbb8d 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -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'; @@ -34,7 +35,7 @@ const selectionHandler = async ( } if (expand) { await Promise.all( - (item.path as PathItem[]) + R.dropLast(1, item.path as PathItem[]) .filter((pathItem) => pathItem.collapsed) .map(({ uuid }) => logseq.Editor.setBlockCollapsed(uuid, false)) ); From 26aff5ea7e6a9209b0fc647071c64473bab64ce3 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Thu, 23 Mar 2023 14:01:39 +0100 Subject: [PATCH 4/5] more logging --- src/components/App.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 59bbb8d..37a66c4 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -19,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); }; @@ -31,7 +31,7 @@ const selectionHandler = async ( expand: boolean, ) => { if (!item) { - return; + return console.info('nothing selected'); } if (expand) { await Promise.all( From df3643636ad6bdbff2406e85d2908f2f8c085457 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Thu, 23 Mar 2023 14:02:12 +0100 Subject: [PATCH 5/5] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 11d9ba9..0729811 100644 --- a/package.json +++ b/package.json @@ -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"