MCPcopy Create free account
hub / github.com/Make-md/makemd / patchWorkspaceForFlow

Function patchWorkspaceForFlow

src/basics/flow/patchWorkspaceForFlow.ts:8–88  ·  view source on GitHub ↗
(plugin: MakeBasicsPlugin)

Source from the content-addressed store, hash-verified

6
7
8export const patchWorkspaceForFlow = (plugin: MakeBasicsPlugin) => {
9 let layoutChanging = false;
10 const uninstaller = around(Workspace.prototype, {
11
12
13 changeLayout(old) {
14 return async function (workspace: unknown) {
15 layoutChanging = true;
16 try {
17 // Don't consider hover popovers part of the workspace while it's changing
18 await old.call(this, workspace);
19 } finally {
20 layoutChanging = false;
21 }
22 };
23 },
24
25 getLeaf(old) {
26 //Patch get leaf to always return root leaf if leaf is a flow block
27 return function (newLeaf?: PaneType | boolean) {
28
29 let leaf: WorkspaceLeaf = old.call(this, newLeaf);
30
31
32 if (leaf.isFlowBlock) {
33 const currentLeafId = leaf.id;
34 let foundLeaf = false;
35 plugin.app.workspace.iterateLeaves((_leaf) => {
36 if (_leaf.flowEditors && !foundLeaf) {
37 _leaf.flowEditors.forEach((f) => {
38 f.leaves().forEach((l: any) => {
39 if (l.id == currentLeafId) {
40 foundLeaf = true;
41 leaf = _leaf;
42 return;
43 }
44 });
45
46 });
47 }
48 return;
49 }, plugin.app.workspace["rootSplit"]!);
50 }
51
52 return leaf;
53 };
54 },
55
56
57 setActiveLeaf(old) {
58 return function setActiveLeaf(leaf, params) {
59 if (leaf.view.getViewType() == 'markdown') {
60 this.activeEditor = leaf.view;
61 if (leaf.view.file) {
62
63 }
64 }
65 return old.call(this, leaf, params);

Callers 1

loadBasicsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected