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.
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>", "overwrite": "<true/false> (optional - default is false)"}
Move file
To move a file in the editor, use the move
action. The move
action takes a file path
and a dest
argument.
{ "action": "move", "path": "<relative path to the file>", "dest": "<new name/path of the file>", "overwrite": "<true/false> (optional - default is false)"}
Copy file
To copy a file in the editor, use the copy
action. The copy
action takes a file path
and a dest
argument.
{ "action": "copy", "path": "<relative path to the file>", "dest": "<new name/path of the file>", "overwrite": "<true/false> (optional - default is false)"}
Delete file
To delete a file in the editor, use the deleteFile
action. The deleteFile
action takes a file path
as an argument.
{ "action": "deleteFile", "path": "<relative path to the file>"}
Close file
To close a the currently opened file in the editor, use the close
action.
{ "action": "close"}
Close all files
To close all opened files in the editor, use the closeAll
action.
{ "action": "closeAll"}