Beginner documentation:

Listening to editor right-click menu

Listening to the user opening the right-click menu in the editor can be done using

this.registerEvent(
    this.app.workspace.on("editor-menu", (menu, editor, view) => {
        console.log('User opened the editor menu');
        menu.addItem((item) => {
            item
                .setTitle("Add to-do item")
                .onClick(async () => {
                    new Notice(view.file?.path ?? "test");
                });
        });
    })
);

Accept user input using modals

Modals documentation

Reading and writing files

File system access through Node.js fs seems to be blocked as running the following code

import { writeFileSync } from "fs";

function writeFile() {
    writeFileSync("dummy-file-name.txt", "random data");
}

will result in Uncaught Error: EROFS: read-only file system, open 'dummy-file-name.txt'.

Instead of directly working with the file system, you are supposed to work through the Vault or the FileSystemAdapter.