zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
4.22k stars 231 forks source link

FR: Make spellcheck in excalidraw plugin follow the obsidian chosen/default spellcheck settings, or add option to disable spellcheck/red-underline in excalidraw plugin #2108

Open froggyfunkin opened 3 days ago

froggyfunkin commented 3 days ago

Is your feature request related to a problem? Please describe.

Problem: Excalidraw plugin in Obsidian currently doesn't follow Obsidian's spellcheck settings. Instead, turned on by default with no way of turning it off. This makes typos, intentional made-up-on-the-spot words/phrases, code lines/syntaxes, etc, get frustratingly repeatedly red-underlined mid-typing and editing, very visually disrupting the freeflow of thoughts and ideas when in chaotic/flow-like thought-capturing/pouring mode. Against the very essence of intuitive "write drunk, edit sober" approach for extension-of-self tools like Excalidraw and Obsidian, which is (imo) the best way to use those tools too.

image

Other user having the same problem when making a UML diagram: image

Describe the solution you'd like

Proposed solutions:

  1. Ideal: Make Excalidraw plugin follow native Obsidian spellcheck setting. This way the spellchecking in Excalidraw will behave/toggled the way user already set in Obsidian, and the Obsidian native toggle spellcheck hotkey would also work when used in Excalidraw plugin too when in the whiteboard screen, making the workflow even smoother and uninterrupted.

  2. Alternatives:

    • Adding a separate option/toggle to disable/enable spellcheck in Excalidraw plugin, along with the hotkey too if possible.
    • Visually hiding the red-underlines (by making it colorless or white-color same as the whiteboard's color), though not ideal, would also probably work.

Real-life usage scenarios

Real-life usage scenario example:

  1. Got a fleeting idea in the middle of working on something else
  2. Hit hotkey to launch Obsidian (achieved with another plugin for global hotkey)
  3. Hit hotkey to create new drawing in Excalidraw in Obsidian
  4. Writing drunk: Freely and uninterruptedly just pour out my chaotic thoughts, and moving textboxes, and drawing arrows, etc without being visually bombarded/interrupted mid-typing with red squiggly lines on my made-up words/phrases.
  5. Editing sober (optional):
    • If I feel like it, then hit native Obsidian hotkey (that i'm already familiar with) to toggle spellcheck on.
    • Notice all my typos, fix it, proofreading.
    • Noticing all my new made-up words/phrases, rewrite it better or just let it be or add it to dictionary, or even develop it into a new note further developing that new semantical/lexical concept.
  6. Hit hotkey to rename the Excalidraw drawing file properly
  7. Hit hotkey to close the file
  8. Hit hotkey to close Obsidian
  9. Continue working on something else.

Describe alternatives you've considered

No response

Additional context

Additional contexts, infos, etc

Things i've tried but didn't work to disable the spellcheck of Excalidraw in Obsidian:

My current workaround for it:

Additional observations that might be related: Observation

Hypothesis

image image (1) image (2)

Thank you in advance That's probably about all, sorry it's long and quite messy, my first time making a github account then opening an issue, tried to follow the requirements. Also, again thank you so much for creating this plugin in the first place and even continuously maintaining and updating it, am probably already the thousandth or millionth user relying on it everyday saying that lmao, seriously wouldn't be able to have developed a deeper understanding of myself, visually thinking, world-modelling/system-making, etc this far or fast if not for Excalidraw and Obsidian, and this plugin is in the smack-dab middle of it enabling that on steroid.

zsviczian commented 3 days ago

following Obsidian plugin settings is likely a stretch too far. I will add an option to allow you to disable spellcheck for the Excalidraw plugin. Not more.

froggyfunkin commented 3 days ago

Thank youu! πŸ™

zsviczian commented 3 days ago

Here's a DYI you can apply today. Let me know how it works.

https://github.com/user-attachments/assets/1148fee6-454c-4962-bee9-9ee6670376fd

the script you need:

if(window.electron) {
  const alignElectronSpellcheckWithObsidianSettings = () => {
    const session = window.electron.remote.getCurrentWebContents().session;
    session.setSpellCheckerEnabled(app.vault.config.spellcheck);
    if(app.vault.config.spellcheck) {
      session.setSpellCheckerLanguages(navigator.languages);
    }
  };

  const body = document.body;
  const observer = new MutationObserver((mutationsList, observer) => {
    for (let mutation of mutationsList) {
      if (mutation.type === 'childList') {
        mutation.removedNodes.forEach(node => {
          if (node.classList && node.classList.contains('modal-container')) {
            alignElectronSpellcheckWithObsidianSettings();
          }
        });
      }
    }
  });
  const config = { childList: true };
  observer.observe(body, config);
  alignElectronSpellcheckWithObsidianSettings();
}
froggyfunkin commented 3 days ago

Hiya sorry for the late reply, it works! πŸ˜€ And the Obsidian native toggle spellcheck hotkey also works too on it, this is the ideal solution haha, thank you so much!

I'm not familiar with Electron in Obsidian, or coding/programming in general unfortunately, so don't know how to help/contribute with the limitations yet, apology πŸ™. Here's a little info I found on internet/Obsidian forum that might be related/useful if at all(?): https://forum.obsidian.md/t/dutch-language-support/30955/13

But on mine, for the default English language it works perfectly, including the hotkey working! Thank you again.