From 5ce9833923bcd23880bcc7f682ef6657b16a18f9 Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Thu, 14 Nov 2024 09:37:20 -0800 Subject: [PATCH] fix console error when switching between reading/editing modes --- src/main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.js b/src/main.js index bc67760..45040cc 100644 --- a/src/main.js +++ b/src/main.js @@ -228,9 +228,9 @@ class RichFootPlugin extends Plugin { // Remove any existing Rich Foot if the file is now excluded const content = view.contentEl; let container; - if (view.getMode() === 'preview') { + if ((view.getMode?.() ?? view.mode) === 'preview') { container = content.querySelector('.markdown-preview-section'); - } else if (view.getMode() === 'source' || view.getMode() === 'live') { + } else if ((view.getMode?.() ?? view.mode) === 'source' || (view.getMode?.() ?? view.mode) === 'live') { container = content.querySelector('.cm-sizer'); } if (container) { @@ -242,9 +242,9 @@ class RichFootPlugin extends Plugin { const content = view.contentEl; let container; - if (view.getMode() === 'preview') { + if ((view.getMode?.() ?? view.mode) === 'preview') { container = content.querySelector('.markdown-preview-section'); - } else if (view.getMode() === 'source' || view.getMode() === 'live') { + } else if ((view.getMode?.() ?? view.mode) === 'source' || (view.getMode?.() ?? view.mode) === 'live') { container = content.querySelector('.cm-sizer'); } @@ -259,7 +259,7 @@ class RichFootPlugin extends Plugin { const richFoot = this.createRichFoot(file); // Append the Rich Foot to the container - if (view.getMode() === 'source' || view.getMode() === 'live') { + if ((view.getMode?.() ?? view.mode) === 'source' || (view.getMode?.() ?? view.mode) === 'live') { container.appendChild(richFoot); } else { container.appendChild(richFoot); @@ -689,7 +689,7 @@ class RichFootSettingTab extends PluginSettingTab { this.plugin.settings.borderRadius = DEFAULT_SETTINGS.borderRadius; await this.plugin.saveSettings(); this.plugin.updateRichFoot(); - // Update just THIS setting's slider value + // Update just the slider value const slider = button.buttonEl.parentElement.parentElement.querySelector('input[type="range"]'); if (slider) slider.value = DEFAULT_SETTINGS.borderRadius; }));