ryjjin / Obsidian-shortcuts-extender

Plugin for Obsidian: Use shortcuts for input special symbols and changing level of headings without language switching
69 stars 6 forks source link

added live preview fixes #14

Closed that0n3guy closed 2 years ago

that0n3guy commented 2 years ago

Here is a start.

Current issues with this: image

I posted about it here: https://discordapp.com/channels/686053708261228577/840286264964022302/915289531656339517 (no reply yet)

If I remove this.shortcutHeader0(); from one of the other shortcut headers like shortcutHeader2() then the shortcut will add the appropriate number of ## to the line. It just appears to be something funky about shortcutHeader0.

that0n3guy commented 2 years ago

Based on https://discordapp.com/channels/686053708261228577/840286264964022302/915298126598909972 I got headers working. ctrl-0 ctrl1-6 for example. I also tested out alt-... it worked.

Selecting multiple lines and hitting ctrl-1 does not work... but I'm not sure it ever did.

claremacrae commented 2 years ago

Huge thanks for working on this!

If I remove this.shortcutHeader0(); from one of the other shortcut headers like shortcutHeader2() then the shortcut will add the appropriate number of ## to the line. It just appears to be something funky about shortcutHeader0.

Just to note... I see that shortcutHeader0 is also the implementation of the command "clearing of text formatting" command - so I do think that it also needs to be ported, and after that, it should be possible to retain the call to it in the level 1 to level 6 functions:

  this.addCommand({
      id: "heading-0",
      name: "clearing of text formatting",
      callback: () => this.shortcutHeader0(),
      hotkeys: [
        {
          modifiers: ["Ctrl"],
          key: "0",
        },
      ],
    });
  }
that0n3guy commented 2 years ago

The issue (from my discord link above) was that replaceRange wants a string rather than array. see this fix: https://github.com/ryjjin/Obsidian-shortcuts-extender/pull/14/commits/449e74897bc94d56218c3296fef469b0b5607734

It works now and someone needs to do more testing on it.

ryjjin commented 2 years ago

Hey! Thanks for your support. Most likely, I myself would not have coped with it (or at least it would have taken a whole carriage of time).

Everything works for me too, checked on Windows and Mac.