Merge pull request #68 from bakuzan/master

Protect against leaf not existing when obsidian first starts up.
This commit is contained in:
Luke Leppan 2023-01-24 21:02:16 +02:00 committed by GitHub
commit 07cdeffa31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,7 +72,7 @@ export default class BetterWordCount extends Plugin {
giveEditorPlugin(leaf: WorkspaceLeaf): void { giveEditorPlugin(leaf: WorkspaceLeaf): void {
//@ts-expect-error, not typed //@ts-expect-error, not typed
const editor = leaf.view.editor; const editor = leaf?.view?.editor;
if (editor) { if (editor) {
const editorView = editor.cm as EditorView; const editorView = editor.cm as EditorView;
const editorPlug = editorView.plugin(editorPlugin); const editorPlug = editorView.plugin(editorPlugin);