Skip to content

Commit

Permalink
immediately apply vim mode kinda but also not
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Jan 17, 2025
1 parent abf6d6a commit 7c2e0f5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
4 changes: 1 addition & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@
<!----------- CONFIRM DIALOG ----------->
<div class="dialog-container">
<dialog id="you-sure-dialog">
<h1>Are you sure?</h1>
<p>
Are you sure you want to
<span id="you-sure-action-description">do that</span>???
<span id="you-sure-action-description">Are you sure?</span>
</p>
<p>
<button id="you-sure-yes-button">Yes</button>
Expand Down
4 changes: 2 additions & 2 deletions src/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const yesButton = document.querySelector('#you-sure-yes-button');
const noButton = document.querySelector('#you-sure-no-button');
const actionDescriptionSpan = document.querySelector('#you-sure-action-description');

export async function nudelConfirm(actionDescription = 'do that') {
actionDescriptionSpan.textContent = actionDescription;
export async function nudelConfirm(message = 'Are you sure you want to do that???') {
actionDescriptionSpan.textContent = message;
youSureDialog.showModal();

return new Promise((resolve) => {
Expand Down
9 changes: 0 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Session } from '@flok-editor/session';
import { nudelAlert } from './alert.js';
import { nudelConfirm } from './confirm.js';
import { applySettingsToNudel, getSettings } from './settings.js';
import { PastaMirror } from './editor.js';
import { clearInlineErrors } from './error.js';
Expand Down Expand Up @@ -108,14 +107,6 @@ window.addEventListener('message', (event) => {
}
});

const mcPlantButton = document.querySelector('#mcplant-button');
mcPlantButton?.addEventListener('click', async () => {
const result = await nudelConfirm('eat a mcplant');
if (result) {
nudelAlert('You eat the McPlant. It tastes just like a real burger.');
}
});

session.initialize();
applySettingsToNudel();

Expand Down
8 changes: 6 additions & 2 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ export function applySettingsToNudel(settings = getSettings()) {
}
}

// TODO: fix vim mode i think i broke it sorry -todepond
if (appliedSettings && isSettingChanged('vimMode', { previous: appliedSettings, next: settings })) {
const pingPong = settings.vimMode ? 'enable' : 'disable';
nudelConfirm(`Do you want to refresh the page to ${pingPong} vim mode immediately?`);
}

pastamirror.updateExtensions(settings, appliedSettings);

appliedSettings = { ...settings };
Expand Down Expand Up @@ -238,6 +242,6 @@ function saveSettingsToLocalStorage(settings) {

const resetButton = document.querySelector('#settings-reset-button');
resetButton.addEventListener('click', async () => {
const response = await nudelConfirm();
const response = await nudelConfirm('Are you sure you want to reset your settings?');
if (response) setSettings(defaultSettings);
});

0 comments on commit 7c2e0f5

Please sign in to comment.