Skip to content

@jsvision/files / FileCommands

Variable: FileCommands

const FileCommands: object

Defined in: files/src/editor/commands.ts:19

The command names for the file operations, for wiring a menu or status bar to a file editor. Save behaviour lives on FileEditor (the base editor package is filesystem-free), so these names are defined here alongside it. Bind your File menu items to these and handle them in your app.

Type Declaration

new

readonly new: "new" = 'new'

Create a new untitled editor window.

open

readonly open: "open" = 'open'

Open an existing file.

save

readonly save: "save" = 'save'

Save the focused file editor.

saveAs

readonly saveAs: "saveAs" = 'saveAs'

Save the focused file editor under a new name (prompts for a path).

Example

ts
import { menuBar, subMenu, item } from '@jsvision/ui';
import { FileCommands } from '@jsvision/files';

const bar = menuBar([
  subMenu('~F~ile', [
    item('~N~ew', FileCommands.new),
    item('~O~pen', FileCommands.open),
    item('~S~ave', FileCommands.save),
    item('Save ~a~s', FileCommands.saveAs),
  ]),
]);