Skip to content

A script that might be of use #7

@fjueic

Description

@fjueic

Script to add scroll with buffer REST api /editor/scroll-into-view without building

Adding to Readme as a possible way might help others. But I would totally understand if you outright reject this idea.

I clone the Original REST api repo manually added the changes from Your fork
used diff to compare both main.js files and created a script to add the changes to the original file.

Why script?

In case of update of the original extension, I can just run the script again to add the changes.

I am still a newbie in neovim, I wonder if there is a way to conditionally add the changes to the original file using obsidian-bridge.nvim plugin.

#!/bin/bash

# This is a really bad way to do it.

echo -n "Enter the path of your Obsidian vault: "
read vault_path

vault_path+="/.obsidian/plugins/obsidian-local-rest-api/main.js"


sed -i 's/this.api.route("\/open\/(.*)").post(this.openPost.bind(this));/this.api.route("\/open\/(.*)").post(this.openPost.bind(this));\n    this.api.route("\/editor\/scroll-into-view").post(this.scrollEditorPositionIntoView.bind(this));/g' $vault_path

sed -i 's/certificateGet(req, res) {/scrollEditorPositionIntoView(req, res) {\n    return __async(this, null, function* () {\n      const { center, range } = req.body;\n      const activeView = this.app.workspace.getActiveViewOfType(import_obsidian.MarkdownView);\n      const editor = activeView.editor;\n      editor.scrollIntoView(range, center);\n      res.json();\n    });\n  }\n  certificateGet(req, res) {/g' $vault_path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions