Skip to content

Commit a5b9bb3

Browse files
committed
Merge branch 'release/v1.5.2'
2 parents 865696f + 62c2b25 commit a5b9bb3

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.5.2
4+
### Fixed
5+
- Fixed bug where expanding collapsed blocks wasn't working properly
6+
37
## 1.5.1
48
### Added
59
- Added proper title and icon for settings (#19)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logseq-plugin-jump-to-block",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"main": "dist/index.html",
55
"logseq": {
66
"id": "logseq-plugin-jump-to-block",

src/components/App.tsx

+19-15
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ const selectionHandler = async (
5252
return;
5353
}
5454
if (expand) {
55-
await Promise.all(
56-
R.dropLast(1, item.path as PathItem[])
57-
.filter((pathItem) => pathItem.collapsed)
58-
.map(({ uuid }) => logseq.Editor.setBlockCollapsed(uuid, false))
59-
);
55+
const collapsedItems = (item.path as PathItem[])
56+
.filter((pathItem) => pathItem.collapsed);
57+
for (const item of collapsedItems) {
58+
await logseq.Editor.setBlockCollapsed(item.uuid, false);
59+
}
6060
}
61-
if (item) scrollTo(item.id as string);
61+
scrollTo(item.id as string);
6262
};
6363

6464

@@ -67,7 +67,8 @@ const makeCommands = (
6767
mode: ModeOption,
6868
maxDepth = Infinity
6969
) => {
70-
const items: Command[] = [];
70+
const entries: Command[] = [];
71+
7172
const recurse = (
7273
block: BlockEntity,
7374
depth: number,
@@ -109,25 +110,28 @@ const makeCommands = (
109110
color: 'transparent',
110111
path: path,
111112
};
112-
items.push(cmd);
113+
entries.push(cmd);
114+
113115
const children = block.children || [];
114116
if (children.length) {
117+
const parentPathItem: PathItem = {
118+
uuid: block.uuid,
119+
collapsed: block['collapsed?'],
120+
};
115121
(children as BlockEntity[]).forEach(
116-
(block) => recurse(
117-
block,
122+
(child) => recurse(
123+
child,
118124
depth + 1,
119-
[...path, {
120-
uuid: block.uuid,
121-
collapsed: block['collapsed?'],
122-
}]
125+
[...path, parentPathItem]
123126
)
124127
);
125128
}
126129
};
130+
127131
blocks.forEach(
128132
(block) => recurse(block, 0, [])
129133
);
130-
return items;
134+
return entries;
131135
};
132136

133137

src/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import type { InitalSelectionOption, ModeOption } from './types';
22

33
export const initialSelectionDefault: InitalSelectionOption = 'Nothing';
44
export const defaultMaxDepth = 3;
5-
export const modeDefault: ModeOption = 'Headings-only';
5+
export const modeDefault: ModeOption = 'Default';
66

77
export const headingRegex = /^#{1,6} (.*)/gi;

0 commit comments

Comments
 (0)