Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

#134 - fix to breaking changes introduced in Obsidian 1.5.4 (they did an internal refactoring of File Explorer, the fix follows the refactoring accordingly) #138

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/click-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getClickHandler = (plugin: ALxFolderNote) => {
getFileItemInnerTitleEl(item).contains(evt.target as Node)
) ||
// ignore file being renamed
item.fileExplorer.fileBeingRenamed === item.file
item.view.fileBeingRenamed === item.file
)
return false;

Expand Down Expand Up @@ -64,8 +64,8 @@ export const pressHandler = (
item: FolderItem,
_evt: LongPressEvent,
): boolean => {
if (!item || item.fileExplorer.fileBeingRenamed === item.file) return false;
if (!item || item.view.fileBeingRenamed === item.file) return false;
const folder = item.file;
item.fileExplorer.folderNoteUtils?.folderFocus.toggleFocusFolder(folder);
item.view.folderNoteUtils?.folderFocus.toggleFocusFolder(folder);
return true;
};
7 changes: 4 additions & 3 deletions src/fe-handler/folder-focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ export default class FolderFocus extends FEHandler_Base {
// @ts-ignore
this.plugin.app.nextFrame(() => {
// @ts-ignore
this.fileExplorer.dom.infinityScroll.computeSync();
this.fileExplorer.tree.infinityScroll.compute();
// @ts-ignore
this.fileExplorer.dom.infinityScroll.scrollIntoView(item);
this.fileExplorer.tree.infinityScroll.scrollIntoView(item);
});
}
this.fileExplorer.dom.navFileContainerEl.toggleClass(focusModeCls, !!item);
console.log('§2§')
this.fileExplorer.navFileContainerEl.toggleClass(focusModeCls, !!item);
}
toggleFocusFolder(folder: TFolder | null) {
const folderItem = folder
Expand Down
2 changes: 1 addition & 1 deletion src/fe-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const PatchFileExplorer = (plugin: ALxFolderNote) => {
const self = this;
next.call(self);
self.folderNoteUtils = getFileExplorerHandlers(plugin, self);
AddLongPressEvt(plugin, self.dom.navFileContainerEl);
AddLongPressEvt(plugin, self.navFileContainerEl);
self.containerEl.on(
"auxclick",
".nav-folder",
Expand Down
8 changes: 4 additions & 4 deletions src/typings/obsidian-ex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ declare module "obsidian" {
getViewType(): string;
getDisplayText(): string;
onClose(): Promise<void>;
dom: {
tree: {
infinityScroll: HTMLDivElement;
navFileContainerEl: HTMLDivElement;
};
navFileContainerEl: HTMLDivElement;
onOpen(): Promise<void>;
onFileClick(evt: MouseEvent, navEl: HTMLDivElement): void;
handleFileClick(evt: MouseEvent, item: AFItem): boolean;
Expand Down Expand Up @@ -48,7 +48,7 @@ declare module "obsidian" {
class FileItem {
el: HTMLDivElement;
file: TFile;
fileExplorer: FileExplorerView;
view: FileExplorerView; // Starting from Obsidian 1.5.4 the .fileExplorer field was renamed to .view
info: any;
/**
* @deprecated After Obsidian 1.2.0, use `selfEl` instead.
Expand All @@ -64,7 +64,7 @@ declare module "obsidian" {

class FolderItem {
el: HTMLDivElement;
fileExplorer: FileExplorerView;
view: FileExplorerView; // Starting from Obsidian 1.5.4 the .fileExplorer field was renamed to .view
info: any;
/**
* @deprecated After Obsidian 1.2.0, use `selfEl` instead.
Expand Down