From e7bdf51e0aed8528d017e553f638f8e6ae77b75e Mon Sep 17 00:00:00 2001 From: leijun Date: Tue, 22 Aug 2023 09:57:46 +0800 Subject: [PATCH] fix: Syntax error --- main.ts | 4 ++-- manifest.json | 4 ++-- src/utils/FileUtils.ts | 2 +- src/utils/ObsidianUtils.ts | 34 +++++++++++++++++----------------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/main.ts b/main.ts index 9e1894f..fda123f 100644 --- a/main.ts +++ b/main.ts @@ -104,7 +104,7 @@ export default class ExcelPlugin extends Plugin { if (location === "md-properties") { location = "new-tab"; } - var leaf: WorkspaceLeaf; + var leaf: WorkspaceLeaf | null = null; if (location === "popout-window") { leaf = app.workspace.openPopoutLeaf(); } @@ -121,7 +121,7 @@ export default class ExcelPlugin extends Plugin { } } - leaf.openFile( + leaf?.openFile( excelFile, !subpath || subpath === "" ? { active } diff --git a/manifest.json b/manifest.json index 06b818e..cb56007 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { - "id": "com.ljcoder.obsidian-excel", + "id": "obsidian-excel", "name": "Excel", - "version": "1.0.0", + "version": "1.0.1", "minAppVersion": "0.15.0", "description": "This is a Excel plugin for Obsidian.", "author": "ljcoder", diff --git a/src/utils/FileUtils.ts b/src/utils/FileUtils.ts index bbc8213..9b3bc9e 100644 --- a/src/utils/FileUtils.ts +++ b/src/utils/FileUtils.ts @@ -77,7 +77,7 @@ export function getNewUniqueFilepath( folderpath: string, ): string { let fname = normalizePath(`${folderpath}/${filename}`); - let file: TAbstractFile = vault.getAbstractFileByPath(fname); + let file: TAbstractFile | null = vault.getAbstractFileByPath(fname); let i = 0; const extension = filename.endsWith(".xlsx.md") ? ".xlsx.md" diff --git a/src/utils/ObsidianUtils.ts b/src/utils/ObsidianUtils.ts index e01da81..7281b3c 100644 --- a/src/utils/ObsidianUtils.ts +++ b/src/utils/ObsidianUtils.ts @@ -51,7 +51,7 @@ export const getNewOrAdjacentLeaf = ( const getMostRecentOrAvailableLeafInMainWorkspace = ( inDifferentTabGroup?: boolean - ): WorkspaceLeaf => { + ): WorkspaceLeaf | null => { let mainLeaf = app.workspace.getMostRecentLeaf(); if ( mainLeaf && @@ -86,22 +86,22 @@ export const getNewOrAdjacentLeaf = ( return ml ?? app.workspace.createLeafBySplit(leaf); //app.workspace.getLeaf(true); } - //3 - if (leafLoc === "hover") { - const leaves = new Set(); - app.workspace.iterateAllLeaves((l) => { - //@ts-ignore - if ( - l !== leaf && - leaf.containerEl.parentElement === l.containerEl.parentElement - ) - leaves.add(l); - }); - if (leaves.size === 0) { - return plugin.app.workspace.createLeafBySplit(leaf); - } - return Array.from(leaves)[0]; - } + // //3 + // if (leafLoc === "hover") { + // const leaves = new Set(); + // app.workspace.iterateAllLeaves((l) => { + // //@ts-ignore + // if ( + // l !== leaf && + // leaf.containerEl.parentElement === l.containerEl.parentElement + // ) + // leaves.add(l); + // }); + // if (leaves.size === 0) { + // return plugin.app.workspace.createLeafBySplit(leaf); + // } + // return Array.from(leaves)[0]; + // } //4 if (leafLoc === "popout") {