Skip to content

Commit

Permalink
Merge branch 'release/v1.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
freder committed Apr 26, 2023
2 parents 865696f + 62c2b25 commit a5b9bb3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.5.2
### Fixed
- Fixed bug where expanding collapsed blocks wasn't working properly

## 1.5.1
### Added
- Added proper title and icon for settings (#19)
Expand Down
2 changes: 1 addition & 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.5.1",
"version": "1.5.2",
"main": "dist/index.html",
"logseq": {
"id": "logseq-plugin-jump-to-block",
Expand Down
34 changes: 19 additions & 15 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ 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 = (item.path as PathItem[])
.filter((pathItem) => pathItem.collapsed);
for (const item of collapsedItems) {
await logseq.Editor.setBlockCollapsed(item.uuid, false);
}
}
if (item) scrollTo(item.id as string);
scrollTo(item.id as string);
};


Expand All @@ -67,7 +67,8 @@ const makeCommands = (
mode: ModeOption,
maxDepth = Infinity
) => {
const items: Command[] = [];
const entries: Command[] = [];

const recurse = (
block: BlockEntity,
depth: number,
Expand Down Expand Up @@ -109,25 +110,28 @@ const makeCommands = (
color: 'transparent',
path: path,
};
items.push(cmd);
entries.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, [])
);
return items;
return entries;
};


Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit a5b9bb3

Please sign in to comment.