Skip to content

Commit

Permalink
release: 0.4.5 (fix quick preview not working for aliases)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Dec 7, 2023
1 parent b200cd2 commit 2379c7e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "quick-preview",
"name": "Quick Preview",
"version": "0.4.4",
"version": "0.4.5",
"minAppVersion": "1.3.5",
"description": "Quickly preview a suggestion before selecting it in link suggestions & quick swicher.",
"author": "Ryota Ushio",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-quick-preview",
"version": "0.4.4",
"version": "0.4.5",
"description": "An Obsidian.md plugin to quickly preview a suggestion before selecting it in link suggestions & quick swicher.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
18 changes: 11 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ export default class EnhancedLinkSuggestionsPlugin extends Plugin {
this.app.workspace.onLayoutReady(() => {
this.patchSetSelectedItem();
const itemNormalizer = (item: BuiltInSuggestItem | QuickSwitcherItem): SuggestItem => {
if (item.type !== "block") return item as SuggestItem;
return {
type: "block",
file: item.file,
line: item.node.position.start.line,
};
}
if (item.type === "alias") {
return { type: "file", file: item.file };
} else if (item.type === "block") {
return {
type: "block",
file: item.file,
line: item.node.position.start.line,
};
}
return item;
};
// @ts-ignore
this.patchSuggester(this.getBuiltInSuggest().constructor, itemNormalizer);
this.patchSuggester(this.app.internalPlugins.getPluginById('switcher').instance.QuickSwitcherModal, itemNormalizer);
Expand Down
6 changes: 5 additions & 1 deletion src/typings/suggest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PopoverManager } from "popoverManager";


export type SuggestItem = FileInfo | HeadingInfo | BlockInfo;
export type BuiltInSuggestItem = FileLinkInfo | HeadingLinkInfo | BlockLinkInfo;
export type BuiltInSuggestItem = FileLinkInfo | AliasLinkInfo | HeadingLinkInfo | BlockLinkInfo;
export type BuiltInSuggest = EditorSuggest<BuiltInSuggestItem> & { manager: PopoverManager<BuiltInSuggestItem> };
export type Suggester<T> = PopoverSuggest<T> | SuggestModal<T>;
export type PatchedSuggester<T> = Suggester<T> & { manager: PopoverManager<T> };
Expand Down Expand Up @@ -42,6 +42,10 @@ export interface FileLinkInfo extends LinkInfo {
type: "file";
}

export interface AliasLinkInfo extends LinkInfo {
type: "alias";
}

export interface HeadingLinkInfo extends LinkInfo {
type: "heading";
heading: string;
Expand Down

0 comments on commit 2379c7e

Please sign in to comment.