Skip to content

Commit 09d965d

Browse files
committed
feat(tab): Extract tab fn.
1 parent b996768 commit 09d965d

File tree

3 files changed

+11
-43
lines changed

3 files changed

+11
-43
lines changed

src/html-generation/html-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class HTMLGenerator {
4747
await StatsView.activateStatsView(plugin);
4848
const view = StatsView.getStatsView(plugin);
4949
await AssetHandler.updateAssetCache(view);
50-
await MarkdownRenderer.beginBatch();
50+
await MarkdownRenderer.beginBatch(plugin);
5151
return view;
5252
}
5353

src/html-generation/markdown-renderer.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/* eslint-disable @typescript-eslint/no-namespace */
2-
import { MarkdownView, Notice, WorkspaceLeaf } from "obsidian";
2+
import { MarkdownView, Notice, WorkspaceLeaf, PaneType, SplitDirection, App } from "obsidian";
3+
import { clipboard} from 'electron';
34
import { InvioSettingTab } from "src/settings";
45
import { Utils } from "src/utils/utils";
56
import { ExportFile } from "./export-file";
67
import { AssetHandler } from "./asset-handler";
7-
import { TabManager } from "src/utils/tab-manager";
8-
const { clipboard } = require('electron')
98
import { RenderLog } from "./render-log";
109
import { StatsView } from "src/statsView";
11-
10+
import type InvioPlugin from "../main"; // unavoidable
1211

1312
export namespace MarkdownRenderer
1413
{
@@ -155,14 +154,19 @@ export namespace MarkdownRenderer
155154
element.textContent = element.value;
156155
});
157156
}
157+
158+
function newTab(app: App, navType: PaneType | boolean, splitDirection: SplitDirection = 'vertical'): WorkspaceLeaf {
159+
let leaf = navType === 'split' ? app.workspace.getLeaf(navType, splitDirection) : app.workspace.getLeaf(navType);
160+
return leaf;
161+
}
158162

159-
export async function beginBatch()
163+
export async function beginBatch(plugin: InvioPlugin)
160164
{
161165
problemLog = "";
162166
errorInBatch = false;
163167
cancelled = false;
164168

165-
renderLeaf = TabManager.openNewTab("window", "vertical");
169+
renderLeaf = newTab(plugin.app, "window", "vertical");
166170
// @ts-ignore
167171
const parentFound = await Utils.waitUntil(() => renderLeaf && renderLeaf.parent, 2000, 10);
168172
if (!parentFound)

src/utils/tab-manager.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)