From a2d7f36f13a26675147911b901c4bea4cfa80f6c Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 26 Apr 2023 19:51:31 +0200 Subject: [PATCH 1/7] clean up --- src/components/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 349f07c..e50efa3 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -58,7 +58,7 @@ const selectionHandler = async ( .map(({ uuid }) => logseq.Editor.setBlockCollapsed(uuid, false)) ); } - if (item) scrollTo(item.id as string); + scrollTo(item.id as string); }; From 6cb3fa6cbaf06345a919e8f93139dab4aeee6ee2 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 26 Apr 2023 19:55:19 +0200 Subject: [PATCH 2/7] fixed default mode --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 4f55fd9..6425da0 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -2,6 +2,6 @@ import type { InitalSelectionOption, ModeOption } from './types'; export const initialSelectionDefault: InitalSelectionOption = 'Nothing'; export const defaultMaxDepth = 3; -export const modeDefault: ModeOption = 'Headings-only'; +export const modeDefault: ModeOption = 'Default'; export const headingRegex = /^#{1,6} (.*)/gi; From 1348c8f046bb824105b2064e9478820d4667408d Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 26 Apr 2023 20:03:18 +0200 Subject: [PATCH 3/7] expand sequentially --- 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 e50efa3..f2e3515 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -52,11 +52,11 @@ const selectionHandler = async ( return; } if (expand) { - await Promise.all( - R.dropLast(1, item.path as PathItem[]) - .filter((pathItem) => pathItem.collapsed) - .map(({ uuid }) => logseq.Editor.setBlockCollapsed(uuid, false)) - ); + const collapsedItems = R.dropLast(1, item.path as PathItem[]) + .filter((pathItem) => pathItem.collapsed); + for (const item of collapsedItems) { + await logseq.Editor.setBlockCollapsed(item.uuid, false); + } } scrollTo(item.id as string); }; From b73b769f21127cb83d12ac81fe1dd3311f5277c6 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 26 Apr 2023 20:22:38 +0200 Subject: [PATCH 4/7] fix --- src/components/App.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index f2e3515..91a0e28 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -52,7 +52,7 @@ const selectionHandler = async ( return; } if (expand) { - const collapsedItems = R.dropLast(1, item.path as PathItem[]) + const collapsedItems = (item.path as PathItem[]) .filter((pathItem) => pathItem.collapsed); for (const item of collapsedItems) { await logseq.Editor.setBlockCollapsed(item.uuid, false); @@ -68,6 +68,7 @@ const makeCommands = ( maxDepth = Infinity ) => { const items: Command[] = []; + const recurse = ( block: BlockEntity, depth: number, @@ -110,20 +111,23 @@ const makeCommands = ( path: path, }; items.push(cmd); + const children = block.children || []; if (children.length) { + const parentPathItem: PathItem = { + uuid: block.uuid, + collapsed: block['collapsed?'], + }; (children as BlockEntity[]).forEach( - (block) => recurse( - block, + (child) => recurse( + child, depth + 1, - [...path, { - uuid: block.uuid, - collapsed: block['collapsed?'], - }] + [...path, parentPathItem] ) ); } }; + blocks.forEach( (block) => recurse(block, 0, []) ); From 36b6bd8a4f553869d49b18b66a93ffbf36920c69 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 26 Apr 2023 20:25:19 +0200 Subject: [PATCH 5/7] renamed variable --- src/components/App.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 91a0e28..9ba5953 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -67,7 +67,7 @@ const makeCommands = ( mode: ModeOption, maxDepth = Infinity ) => { - const items: Command[] = []; + const entries: Command[] = []; const recurse = ( block: BlockEntity, @@ -110,7 +110,7 @@ const makeCommands = ( color: 'transparent', path: path, }; - items.push(cmd); + entries.push(cmd); const children = block.children || []; if (children.length) { @@ -131,7 +131,7 @@ const makeCommands = ( blocks.forEach( (block) => recurse(block, 0, []) ); - return items; + return entries; }; From 7426874fe2919c5b40711ee768068e35fa6cf645 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 26 Apr 2023 20:29:35 +0200 Subject: [PATCH 6/7] updated changelog --- changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.md b/changelog.md index 38f4aab..524ef0d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 1.x.x +### Fixed +- Fixed bug where expanding collapsed blocks wasn't working properly + ## 1.5.1 ### Added - Added proper title and icon for settings (#19) From 62c2b25102298a3a78accfb9e8d6ffebbde0c7e8 Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Wed, 26 Apr 2023 20:30:07 +0200 Subject: [PATCH 7/7] version bump --- changelog.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 524ef0d..3e2f0ac 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # Changelog -## 1.x.x +## 1.5.2 ### Fixed - Fixed bug where expanding collapsed blocks wasn't working properly diff --git a/package.json b/package.json index 91e1c53..3408569 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "logseq-plugin-jump-to-block", - "version": "1.5.1", + "version": "1.5.2", "main": "dist/index.html", "logseq": { "id": "logseq-plugin-jump-to-block",