fix: Syntax error

This commit is contained in:
leijun 2023-08-22 09:57:46 +08:00
parent 6a33e1604b
commit e7bdf51e0a
4 changed files with 22 additions and 22 deletions

View file

@ -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 }

View file

@ -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",

View file

@ -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"

View file

@ -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<WorkspaceLeaf>();
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<WorkspaceLeaf>();
// 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") {