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

Function patchWorkspaceLeafForFlow

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

Source from the content-addressed store, hash-verified

87 plugin.plugin.register(uninstaller);
88};
89export const patchWorkspaceLeafForFlow = (plugin: MakeBasicsPlugin) => {
90 plugin.plugin.register(
91 around(WorkspaceLeaf.prototype, {
92 getRoot(old) {
93 return function () {
94 const top = old.call(this);
95 return top.getRoot === this.getRoot ? top : top.getRoot();
96 };
97 },
98 setViewState(old) {
99 return async function (viewState: ViewState, eState?: unknown) {
100 const result = await old.call(this, viewState, eState);
101 try {
102 if (this.flowEditors) {
103 for (const he of this.flowEditors) {
104 he.hide();
105 }
106 }
107 this.flowEditors = [];
108 } catch { }
109 return result;
110 };
111 },
112 setEphemeralState(old) {
113 return function (state: EphemeralState) {
114 old.call(this, state);
115 if (state.focus && this.view?.getViewType() === "empty") {
116 // Force empty (no-file) view to have focus so dialogs don't reset active pane
117 this.view.contentEl.tabIndex = -1;
118 this.view.contentEl.focus();
119 }
120 };
121 },
122 })
123 );
124 plugin.plugin.register(
125 around(WorkspaceItem.prototype, {
126 getContainer(old) {
127 return function () {
128 if (!old) return; // 0.14.x doesn't have this
129 if (!this.parentSplit || this instanceof WorkspaceContainer)
130 return old.call(this);
131 return this.parentSplit.getContainer();
132 };
133 },
134 })
135 );
136};

Callers 1

loadBasicsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected