Skip to content

Commit f9e1ccd

Browse files
committed
Code tidy up with new apis
1 parent 14f61a5 commit f9e1ccd

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ much, feel free to throw some coins in my hat via
6666
[GitHub Sponsors](https://github.com/sponsors/deathau)
6767

6868
# Version History
69+
## 0.1.2
70+
- Added elixir mode (thanks to James Dalton)
71+
6972
## 0.1.1
7073
- Apply codemirror theme to latex math also
7174

main.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default class CMSyntaxHighlightPlugin extends Plugin {
132132

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

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

156156
refreshLeaves = () => {
157-
// iterate through all markdown leaves
158-
this.app.workspace.getLeavesOfType("markdown").forEach(leaf => {
159-
if (leaf.view instanceof MarkdownView && leaf.view.sourceMode && leaf.view.sourceMode.cmEditor) {
160-
// re-set the editor mode to refresh the syntax highlighting
161-
leaf.view.sourceMode.cmEditor.setOption("mode", leaf.view.sourceMode.cmEditor.getOption("mode"));
162-
}
163-
})
157+
// re-set the editor mode to refresh the syntax highlighting
158+
this.app.workspace.iterateCodeMirrors(cm => cm.setOption("mode", cm.getOption("mode")))
164159
}
165160
}

manifest.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"id": "cm-editor-syntax-highlight-obsidian",
33
"name": "Editor Syntax Highlight",
44
"author": "death_au",
5+
"authorUrl": "https://github.com/deathau",
56
"description": "Show syntax highlighing in code blocks the editor",
67
"isDesktopOnly": false,
7-
"version": "0.1.1"
8+
"version": "0.1.1",
9+
"minAppVersion": "0.10.0"
810
}

versions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"0.1.2": "0.10.0",
3+
"0.1.1": "0.9.7"
4+
}

0 commit comments

Comments
 (0)