add reading view codeblock hiding

This commit is contained in:
Cleon 2023-01-07 17:21:33 +13:00
parent 03e713f8ee
commit b6539ed902
2 changed files with 19 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -4,4 +4,8 @@
grid-row-gap: 1em;
grid-auto-flow: column;
justify-content: start;
}
.markdown-reading-view .block-language-meld-build-toolbar{
padding:0.5em 0;
}