Skip to content

Commit aa9f751

Browse files
authored
Merge pull request #3368 from mnaoumov/issue-3366
fix: register handlers before the layout is ready
2 parents 6785f99 + 84ff507 commit aa9f751

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/Obsidian/InlineRenderer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import { TaskLocation } from '../Task/TaskLocation';
2424
*/
2525
export class InlineRenderer {
2626
constructor({ plugin }: { plugin: Plugin }) {
27-
plugin.registerMarkdownPostProcessor(this._markdownPostProcessor.bind(this));
27+
plugin.registerMarkdownPostProcessor((el, ctx) => {
28+
plugin.app.workspace.onLayoutReady(() => {
29+
this.markdownPostProcessor(el, ctx);
30+
});
31+
});
2832
}
2933

3034
public markdownPostProcessor = this._markdownPostProcessor.bind(this);

src/Renderer/QueryRenderer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export class QueryRenderer {
3838
this.plugin = plugin;
3939
this.events = events;
4040

41-
plugin.registerMarkdownCodeBlockProcessor('tasks', this._addQueryRenderChild.bind(this));
41+
plugin.registerMarkdownCodeBlockProcessor('tasks', (source, el, ctx) => {
42+
plugin.app.workspace.onLayoutReady(() => {
43+
this.addQueryRenderChild(source, el, ctx);
44+
});
45+
});
4246
}
4347

4448
public addQueryRenderChild = this._addQueryRenderChild.bind(this);

src/main.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ export default class TasksPlugin extends Plugin {
6060
events,
6161
});
6262

63-
this.app.workspace.onLayoutReady(() => {
64-
// Only execute searches after Obsidian finishes loading.
65-
this.inlineRenderer = new InlineRenderer({ plugin: this });
66-
this.queryRenderer = new QueryRenderer({ plugin: this, events });
67-
});
63+
this.inlineRenderer = new InlineRenderer({ plugin: this });
64+
this.queryRenderer = new QueryRenderer({ plugin: this, events });
6865

6966
// Update types.json.
7067
this.setObsidianPropertiesTypes();

0 commit comments

Comments
 (0)