mirror of
https://github.com/quorafind/Obsidian-Float-Search.git
synced 2026-07-22 07:30:25 +00:00
fix: undo tab would open search view
This commit is contained in:
parent
3e577d6a0e
commit
f1ea991fe0
6 changed files with 153 additions and 72 deletions
|
|
@ -15,6 +15,7 @@ esbuild.build({
|
|||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
minify: prod,
|
||||
entryPoints: ['src/floatSearchIndex.ts'],
|
||||
bundle: true,
|
||||
external: [
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "float-search",
|
||||
"name": "Floating Search",
|
||||
"version": "3.3.3",
|
||||
"version": "3.3.4",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "You can use search view in modal/leaf/popout window now.",
|
||||
"author": "Boninall",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "float-search",
|
||||
"version": "3.3.3",
|
||||
"version": "3.3.4",
|
||||
"description": "You can use search view in modal/leaf/popout window now.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {
|
|||
Modal, OpenViewState,
|
||||
Plugin, SearchView,
|
||||
TAbstractFile,
|
||||
TFile,
|
||||
TFile, ViewState,
|
||||
Workspace,
|
||||
WorkspaceContainer, WorkspaceItem,
|
||||
WorkspaceLeaf
|
||||
|
|
@ -164,6 +164,15 @@ export default class FloatSearchPlugin extends Plugin {
|
|||
return function (event: MouseEvent, leaf: WorkspaceLeaf) {
|
||||
return old.call(this, event, leaf);
|
||||
};
|
||||
},
|
||||
pushUndoHistory(old: any) {
|
||||
return function (leaf: WorkspaceLeaf, id: string, ...args: any[]) {
|
||||
const viewState = leaf.getViewState();
|
||||
if (viewState.type === "search") {
|
||||
return;
|
||||
}
|
||||
return old.call(this, leaf, id, ...args);
|
||||
};
|
||||
}
|
||||
});
|
||||
this.register(uninstaller);
|
||||
|
|
@ -238,7 +247,18 @@ export default class FloatSearchPlugin extends Plugin {
|
|||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
},
|
||||
// setViewState(old) {
|
||||
// return function (viewState: ViewState, eState?: any) {
|
||||
// const result = old.call(this, viewState, eState);
|
||||
// console.log(viewState);
|
||||
// if (isEmebeddedLeaf(this)) {
|
||||
// console.log("hello", viewState);
|
||||
// console.log(this.app.undoHistory);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
@ -610,7 +630,7 @@ class FloatSearchModal extends Modal {
|
|||
case "g":
|
||||
if (this.fileLeaf && e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
app.workspace.setActiveLeaf(this.fileLeaf, {
|
||||
this.plugin.app.workspace.setActiveLeaf(this.fileLeaf, {
|
||||
focus: true,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
59
src/types/types-obsidian.d.ts
vendored
59
src/types/types-obsidian.d.ts
vendored
|
|
@ -18,6 +18,7 @@ interface InternalPlugins {
|
|||
"page-preview": InternalPlugin;
|
||||
graph: GraphPlugin;
|
||||
}
|
||||
|
||||
interface OpenViewState {
|
||||
eState?: EphemeralState;
|
||||
state?: { mode: string };
|
||||
|
|
@ -26,16 +27,22 @@ interface OpenViewState {
|
|||
|
||||
declare class QuickSwitcherModal extends SuggestModal<TFile> {
|
||||
getSuggestions(query: string): TFile[] | Promise<TFile[]>;
|
||||
|
||||
renderSuggestion(value: TFile, el: HTMLElement): unknown;
|
||||
|
||||
onChooseSuggestion(item: TFile, evt: MouseEvent | KeyboardEvent): unknown;
|
||||
}
|
||||
|
||||
interface InternalPlugin {
|
||||
disable(): void;
|
||||
|
||||
enable(): void;
|
||||
|
||||
enabled: boolean;
|
||||
_loaded: boolean;
|
||||
instance: { name: string; id: string };
|
||||
}
|
||||
|
||||
interface GraphPlugin extends InternalPlugin {
|
||||
views: { localgraph: (leaf: WorkspaceLeaf) => GraphView };
|
||||
}
|
||||
|
|
@ -44,6 +51,7 @@ interface GraphView extends View {
|
|||
engine: typeof Object;
|
||||
renderer: { worker: { terminate(): void } };
|
||||
}
|
||||
|
||||
interface QuickSwitcherPlugin extends InternalPlugin {
|
||||
instance: {
|
||||
name: string;
|
||||
|
|
@ -56,6 +64,7 @@ declare global {
|
|||
const i18next: {
|
||||
t(id: string): string;
|
||||
};
|
||||
|
||||
interface Window {
|
||||
activeWindow: Window;
|
||||
activeDocument: Document;
|
||||
|
|
@ -87,52 +96,75 @@ declare module "obsidian" {
|
|||
};
|
||||
dom: { appContainerEl: HTMLElement };
|
||||
viewRegistry: ViewRegistry;
|
||||
|
||||
openWithDefaultApp(path: string): void;
|
||||
}
|
||||
|
||||
interface ViewRegistry {
|
||||
typeByExtension: Record<string, string>; // file extensions to view types
|
||||
viewByType: Record<string, (leaf: WorkspaceLeaf) => View>; // file extensions to view types
|
||||
}
|
||||
|
||||
interface CalendarPlugin {
|
||||
view: View;
|
||||
}
|
||||
|
||||
interface WorkspaceParent {
|
||||
insertChild(index: number, child: WorkspaceItem, resize?: boolean): void;
|
||||
|
||||
replaceChild(index: number, child: WorkspaceItem, resize?: boolean): void;
|
||||
|
||||
removeChild(leaf: WorkspaceLeaf, resize?: boolean): void;
|
||||
|
||||
containerEl: HTMLElement;
|
||||
children: any;
|
||||
}
|
||||
|
||||
interface MarkdownEditView {
|
||||
editorEl: HTMLElement;
|
||||
}
|
||||
|
||||
class MarkdownPreviewRendererStatic extends MarkdownPreviewRenderer {
|
||||
static registerDomEvents(el: HTMLElement, handlerInstance: unknown, cb: (el: HTMLElement) => unknown): void;
|
||||
}
|
||||
|
||||
interface WorkspaceLeaf {
|
||||
openLinkText(linkText: string, path: string, state?: unknown): Promise<void>;
|
||||
|
||||
updateHeader(): void;
|
||||
|
||||
containerEl: HTMLDivElement;
|
||||
working: boolean;
|
||||
parentSplit: WorkspaceParent;
|
||||
activeTime: number;
|
||||
}
|
||||
|
||||
interface Workspace {
|
||||
recordHistory(leaf: WorkspaceLeaf, pushHistory: boolean): void;
|
||||
|
||||
iterateLeaves(callback: (item: WorkspaceLeaf) => boolean | void, item: WorkspaceItem | WorkspaceItem[]): boolean;
|
||||
|
||||
iterateLeaves(item: WorkspaceItem | WorkspaceItem[], callback: (item: WorkspaceLeaf) => boolean | void): boolean;
|
||||
|
||||
getDropLocation(event: MouseEvent): {
|
||||
target: WorkspaceItem;
|
||||
sidedock: boolean;
|
||||
};
|
||||
|
||||
recursiveGetTarget(event: MouseEvent, parent: WorkspaceParent): WorkspaceItem;
|
||||
|
||||
recordMostRecentOpenedFile(file: TFile): void;
|
||||
|
||||
onDragLeaf(event: MouseEvent, leaf: WorkspaceLeaf): void;
|
||||
|
||||
onLayoutChange(): void; // tell Obsidian leaves have been added/removed/etc.
|
||||
activeLeafEvents(): void;
|
||||
|
||||
floatingSplit: any;
|
||||
|
||||
pushUndoHistory(leaf: WorkspaceLeaf, id: string, e: any): void;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
getClickableTokenAt(pos: EditorPosition): {
|
||||
text: string;
|
||||
|
|
@ -141,25 +173,38 @@ declare module "obsidian" {
|
|||
end: EditorPosition;
|
||||
};
|
||||
}
|
||||
|
||||
interface View {
|
||||
iconEl: HTMLElement;
|
||||
file: TFile;
|
||||
|
||||
setMode(mode: MarkdownSubView): Promise<void>;
|
||||
|
||||
followLinkUnderCursor(newLeaf: boolean): void;
|
||||
|
||||
modes: Record<string, MarkdownSubView>;
|
||||
|
||||
getMode(): string;
|
||||
|
||||
headerEl: HTMLElement;
|
||||
contentEl: HTMLElement;
|
||||
}
|
||||
|
||||
interface SearchView extends View {
|
||||
onKeyArrowRightInFocus(e: KeyboardEvent): void;
|
||||
|
||||
onKeyArrowLeftInFocus(e: KeyboardEvent): void;
|
||||
|
||||
onKeyArrowUpInFocus(e: KeyboardEvent): void;
|
||||
|
||||
onKeyArrowDownInFocus(e: KeyboardEvent): void;
|
||||
|
||||
onKeyEnterInFocus(e: KeyboardEvent): void;
|
||||
|
||||
onKeyShowMoreBefore(e: KeyboardEvent): void;
|
||||
|
||||
onKeyShowMoreAfter(e: KeyboardEvent): void;
|
||||
|
||||
dom: any;
|
||||
searchComponent: SearchComponent;
|
||||
headerDom: any;
|
||||
|
|
@ -173,21 +218,25 @@ declare module "obsidian" {
|
|||
interface FileManager {
|
||||
createNewMarkdownFile(folder: TFolder, fileName: string): Promise<TFile>;
|
||||
}
|
||||
|
||||
enum PopoverState {
|
||||
Showing,
|
||||
Shown,
|
||||
Hiding,
|
||||
Hidden,
|
||||
}
|
||||
|
||||
interface Menu {
|
||||
items: MenuItem[];
|
||||
dom: HTMLElement;
|
||||
hideCallback: () => unknown;
|
||||
}
|
||||
|
||||
interface MenuItem {
|
||||
iconEl: HTMLElement;
|
||||
dom: HTMLElement;
|
||||
}
|
||||
|
||||
interface EphemeralState {
|
||||
focus?: boolean;
|
||||
subpath?: string;
|
||||
|
|
@ -196,22 +245,32 @@ declare module "obsidian" {
|
|||
endLoc?: Loc;
|
||||
scroll?: number;
|
||||
}
|
||||
|
||||
interface HoverParent {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
interface HoverPopover {
|
||||
parent: EmbeddedViewParent | null;
|
||||
targetEl: HTMLElement;
|
||||
hoverEl: HTMLElement;
|
||||
|
||||
position(pos?: MousePos): void;
|
||||
|
||||
hide(): void;
|
||||
|
||||
show(): void;
|
||||
|
||||
shouldShowSelf(): boolean;
|
||||
|
||||
timer: number;
|
||||
waitTime: number;
|
||||
|
||||
shouldShow(): boolean;
|
||||
|
||||
transition(): void;
|
||||
}
|
||||
|
||||
interface MousePos {
|
||||
x: number;
|
||||
y: number;
|
||||
|
|
|
|||
|
|
@ -16,5 +16,6 @@
|
|||
"3.3.0": "0.15.0",
|
||||
"3.3.1": "0.15.0",
|
||||
"3.3.2": "0.15.0",
|
||||
"3.3.3": "0.15.0"
|
||||
"3.3.3": "0.15.0",
|
||||
"3.3.4": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue