Skip to content

Commit

Permalink
fix console error when switching between reading/editing modes
Browse files Browse the repository at this point in the history
  • Loading branch information
jparkerweb committed Nov 14, 2024
1 parent aaf0f03 commit 5ce9833
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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');
}

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}));
Expand Down

0 comments on commit 5ce9833

Please sign in to comment.