Skip to content

Commit

Permalink
Code tidy up with new apis
Browse files Browse the repository at this point in the history
  • Loading branch information
deathau committed Dec 29, 2020
1 parent 14f61a5 commit f9e1ccd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ much, feel free to throw some coins in my hat via
[GitHub Sponsors](https://github.com/sponsors/deathau)

# Version History
## 0.1.2
- Added elixir mode (thanks to James Dalton)

## 0.1.1
- Apply codemirror theme to latex math also

Expand Down
11 changes: 3 additions & 8 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class CMSyntaxHighlightPlugin extends Plugin {

async onload() {
// wait for layout to be ready to perform the rest
(this.app.workspace as any).layoutReady ? this.layoutReady() : this.app.workspace.on('layout-ready', this.layoutReady);
this.app.workspace.layoutReady ? this.layoutReady() : this.app.workspace.on('layout-ready', this.layoutReady);
}

layoutReady = () => {
Expand All @@ -154,12 +154,7 @@ export default class CMSyntaxHighlightPlugin extends Plugin {
}

refreshLeaves = () => {
// iterate through all markdown leaves
this.app.workspace.getLeavesOfType("markdown").forEach(leaf => {
if (leaf.view instanceof MarkdownView && leaf.view.sourceMode && leaf.view.sourceMode.cmEditor) {
// re-set the editor mode to refresh the syntax highlighting
leaf.view.sourceMode.cmEditor.setOption("mode", leaf.view.sourceMode.cmEditor.getOption("mode"));
}
})
// re-set the editor mode to refresh the syntax highlighting
this.app.workspace.iterateCodeMirrors(cm => cm.setOption("mode", cm.getOption("mode")))
}
}
4 changes: 3 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"id": "cm-editor-syntax-highlight-obsidian",
"name": "Editor Syntax Highlight",
"author": "death_au",
"authorUrl": "https://github.com/deathau",
"description": "Show syntax highlighing in code blocks the editor",
"isDesktopOnly": false,
"version": "0.1.1"
"version": "0.1.1",
"minAppVersion": "0.10.0"
}
4 changes: 4 additions & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"0.1.2": "0.10.0",
"0.1.1": "0.9.7"
}

0 comments on commit f9e1ccd

Please sign in to comment.