mirror of
https://github.com/meld-cp/obsidian-build.git
synced 2026-07-22 07:30:25 +00:00
add reading view codeblock hiding
This commit is contained in:
parent
03e713f8ee
commit
b6539ed902
2 changed files with 19 additions and 0 deletions
15
src/main.ts
15
src/main.ts
|
|
@ -16,6 +16,19 @@ export default class MeldBuildPlugin extends Plugin {
|
|||
settings: MeldBuildPluginSettings;
|
||||
|
||||
|
||||
private async codeblockProcessor(el: HTMLElement, ctx: MarkdownPostProcessorContext): Promise<void> {
|
||||
const els = el.querySelector('.language-js');
|
||||
|
||||
if ( els == null ){
|
||||
return;
|
||||
}
|
||||
|
||||
if ( els.getText().contains( '//@hide_when_reading' ) ){
|
||||
console.debug('Hiding element',{el});
|
||||
el.hide();
|
||||
}
|
||||
}
|
||||
|
||||
async onload() {
|
||||
|
||||
await this.loadSettings();
|
||||
|
|
@ -29,6 +42,7 @@ export default class MeldBuildPlugin extends Plugin {
|
|||
( source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext ) => this.processToolbarRender( source, el, ctx )
|
||||
);
|
||||
|
||||
this.registerMarkdownPostProcessor( this.codeblockProcessor );
|
||||
|
||||
this.addCommand({
|
||||
id: 'run',
|
||||
|
|
@ -195,3 +209,4 @@ class ToolbarButton{
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,3 +5,7 @@
|
|||
grid-auto-flow: column;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.markdown-reading-view .block-language-meld-build-toolbar{
|
||||
padding:0.5em 0;
|
||||
}
|
||||
Loading…
Reference in a new issue