From 2379c7e5a907d2340d7bdef90302e4536c347718 Mon Sep 17 00:00:00 2001 From: RyotaUshio Date: Fri, 8 Dec 2023 04:21:18 +0900 Subject: [PATCH] release: 0.4.5 (fix quick preview not working for aliases) --- manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/main.ts | 18 +++++++++++------- src/typings/suggest.d.ts | 6 +++++- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/manifest.json b/manifest.json index da06222..8adf62b 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/package-lock.json b/package-lock.json index 5856684..606765d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-quick-preview", - "version": "0.4.4", + "version": "0.4.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-quick-preview", - "version": "0.4.4", + "version": "0.4.5", "license": "MIT", "dependencies": { "monkey-around": "^2.3.0" diff --git a/package.json b/package.json index 259cc8e..f032da9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main.ts b/src/main.ts index dad9367..d76f75d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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); diff --git a/src/typings/suggest.d.ts b/src/typings/suggest.d.ts index 492a7fe..a862d16 100644 --- a/src/typings/suggest.d.ts +++ b/src/typings/suggest.d.ts @@ -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 & { manager: PopoverManager }; export type Suggester = PopoverSuggest | SuggestModal; export type PatchedSuggester = Suggester & { manager: PopoverManager }; @@ -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;