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>"}action: openpath: <relative path to the file>Optional: focusTop
By default Demo Time will try to focus the top of the editor when opening a file. Use the optional boolean focusTop to explicitly control this behaviour. When set to true the editor will focus the top of the file; when set to false it will preserve the editor’s default reveal behaviour.
{ "action": "open", "path": "README.md", "focusTop": true}action: openpath: README.mdfocusTop: trueCreate 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 (optional)"}action: createpath: <relative path to the file>content: <content of the file> # optionalcontentPath: <relative path to the file> # optionalThe 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"}action: saveRename 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)"}action: renamepath: <relative path to the file>dest: <new name/path of the file>overwrite: <true/false> # optional, default is falseMove 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)"}action: movepath: <relative path to the file>dest: <new name/path of the file>overwrite: <true/false> # optional, default is falseCopy 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)"}action: copypath: <relative path to the file>dest: <new name/path of the file>overwrite: <true/false> # optional, default is falseDelete 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>"}action: deleteFilepath: <relative path to the file>Close file
To close a the currently opened file in the editor, use the close action.
{ "action": "close"}action: closeClose all files
To close all opened files in the editor, use the closeAll action.
{ "action": "closeAll"}action: closeAll