Fixed jscommand and jsfile broken

This commit is contained in:
Erez Shermer 2022-07-20 08:59:40 +03:00
parent 08b0c5461a
commit bcc1e56935
4 changed files with 7 additions and 3 deletions

View file

@ -257,6 +257,10 @@ See [here](JsSnippets.md) for the full example, and please contribute your own!
## Changelog
### 0.7.1
Fixed `jscommand` and `jsfile` broken in the latest Obsidian update.
### 0.7.0
**IMPORTANT: this version drops support for the legacy (CM5) Obsidian editor.**

View file

@ -521,7 +521,7 @@ export default class VimrcPlugin extends Plugin {
if (jsCode[0] != '{' || jsCode[jsCode.length - 1] != '}')
throw new Error("Expected an argument which is JS code surrounded by curly brackets: {...}");
let currentSelections = this.currentSelection;
var chosenSelection = currentSelections[0];
var chosenSelection = currentSelections && currentSelections.length > 0 ? currentSelections[0] : null;
const command = Function('editor', 'view', 'selection', jsCode);
const view = this.getActiveView();
command(view.editor, view, chosenSelection);

View file

@ -1,7 +1,7 @@
{
"id": "obsidian-vimrc-support",
"name": "Vimrc Support",
"version": "0.7.0",
"version": "0.7.1",
"description": "Auto-load a startup file with Obsidian Vim commands.",
"minAppVersion": "0.15.3",
"author": "esm",

View file

@ -1,6 +1,6 @@
{
"name": "obsidian-vimrc-support",
"version": "0.7.0",
"version": "0.7.1",
"description": "Auto-load a startup file with Obsidian Vim commands.",
"main": "main.js",
"scripts": {