timhor/obsidian-editor-shortcuts

Can't contribute to this plugin: git clone dev version doesn't work

Closed this issue · 1 comments

Hello! First of all, thank you for this great plugin. Using these functions in my vimrc provides an even further vim-like writing experience.

I'm currently trying to extend this plugin's functionality by creating two functions: deletePrevChar and deleteNextChar.

deletePrevChar would simply delete the character to the left of the cursor (equivalent to the keyboard key Backspace). <ctrl-h> is mapped as backspace in Insert mode in vim. I tried remapping in .obsidian.vimrc but it doesn't work due to CodeMirror limitation, hence I'm trying to achieve the same result with this seemingly unnecessary function. By creating these functions I could do the following in my .obsidian.vimrc:

exmap deletePrevChar obcommand obsidian-editor-shortcuts:deletePrevChar
imap <C-h> :deletePrevChar

(deleteNextChar is just for the symmetry (I won't personally use it)).

The problem is that I can't develop this plugin.

Steps to reproduce:

  1. Uninstall the release version in Obsidian
  2. cd /home/user/Obsidian/Obsidian-vault/.obsidian/plugins
  3. Make sure the above dir doesn't contain the dir obsidian-editor-shortcuts
  4. git clone https://github.com/timhor/obsidian-editor-shortcuts.git
  5. cd obsidian-editor-shortcuts
  6. Switch to the specified Node version: nvm use
  7. Install dependencies: yarn install
  8. Run the extension: yarn start
  9. Restart Obsidian
  10. Enable the plugin in Obsidian
  11. Trigger a shortcut
  12. Open console to see the following:
Command failed to execute:  obsidian-editor-shortcuts:goToPrevChar
app.js:1 TypeError: cm.operation is not a function
    at withMultipleSelections (eval at <anonymous> (app.js:1), <anonymous>:108:8)
    at Object.editorCallback (eval at <anonymous> (app.js:1), <anonymous>:587:35)
    at Object.e.mobileOnly.xb.isMobile.e.checkCallback (app.js:1)
    at Mz (app.js:1)
    at e.executeCommandById (app.js:1)
    at e.onTrigger (app.js:1)
    at e.handleKey (app.js:1)
    at t.e.handleKey (app.js:1)
    at t.handleKey (app.js:1)
    at e.onKeyEvent (app.js:1)

screenshot-2022-04-24-10-33-37

Any idea as to why Obsidian wouldn't recognize the development version? The file size of main.js emitted from yarn run is also different from the released version.

Any help is much appreciated. Thank you!

Just had a look, and it's due to the discrepancy between CodeMirror 5 and 6 APIs. For multi-cursor support, this plugin assumes it's using the legacy editor (which you can toggle in the Editor settings).

image

I'll need to make some sweeping changes to make it work properly with Live Preview at some point. In the meantime, I've pushed an update that should unblock you: 741bcea.

As for the file size difference, that's because the released version is generated using yarn build.