Skip to content

File actions

File actions are used to open, create, or preview files in the editor.

Open file

To open a file in the editor, use the open action. The open action takes a file path as an argument.

{
"action": "open",
"path": "<relative path to the file>"
}

Create file

To create a new file in the editor, use the create action. The create action takes a file path as an argument and optionally a content or contentPath argument.

{
"action": "create",
"path": "<relative path to the file>",
"content": "<content of the file> (optional)",
"contentPath": "<relative path to the file in the .demo folder> (optional)"
}

The content argument is used to define th content of the file. It is best used when it is a single line of text.

When you want to create a file with a large content, you can use the contentPath argument. The contentPath argument is used to define the path to the file in the .demo folder. The content of the file will be read from the file in the .demo folder and used as the content of the file to be created.

Preview markdown file

To preview a markdown file in the editor, use the markdownPreview action. The markdownPreview action takes a file path as an argument.

{
"action": "markdownPreview",
"path": "<relative path to the file>"
}

Save current file

To save the current file in the editor, use the save action.

{
"action": "save"
}

Rename file

To rename a file in the editor, use the rename action. The rename action takes a file path and a dest argument.

{
"action": "rename",
"path": "<relative path to the file>",
"dest": "<new name/path of the file>"
}

Delete file

To delete a file in the editor, use the deleteFile action. The deleteFile action takes a file path as an argument.

{
"action": "delete",
"path": "<relative path to the file>"
}