CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-external-editor

Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT

79

1.05x
Overview
Eval results
Files

task.mdevals/scenario-3/

Note Draft Editor

A helper that opens the user's default text editor with prefilled content so the final note comes from a real editing session.

Capabilities

Opens editor with template

  • When given a title and optional body, it writes a header line # <title> followed by the body (if provided) to a temporary file, opens the external editor, and returns exactly what the user saved. @test

Detects empty saves

  • If the user saves the file empty or only whitespace, it returns an empty string and reports that nothing was edited. @test

Tracks changes vs initial text

  • If the saved content differs from the initial template aside from trailing newlines, it reports wasEdited as true; otherwise it is false. @test

Implementation

@generates

API

export interface DraftResult {
  content: string;
  wasEdited: boolean;
}

export function openNoteDraft(title: string, body?: string): DraftResult;

Dependencies { .dependencies }

external-editor { .dependency }

Uses the user's default external text editor to synchronously edit the prefilled content.

Install with Tessl CLI

npx tessl i tessl/npm-external-editor

tile.json