See Full API List
api.extURL()
RETURN: string
- The relative URL path to your extension.
let my_url = api.extURL();
console.log(my_url);
// http://domain.com/extensions/yourExtension/
api.extBasePath()
RETURN: string
- The absolute file path to your extension.
let my_path = api.extBasePath();
console.log(my_path);
// /Users/myAccount/path/to/bkdr/extensions/yourExtension/
api.currentDir()
RETURN: string
- The current directory within your file browsers in BKDR. Example, if you have a folder within your root directory called "subDir", and this was the active directory, then you would receive the following return:
let directory = api.currentDir();
console.log(directory);
// subDir
api.openedFiles()
RETURN: array
- An array of file objects.
let file_list = api.openedFiles();
console.log(file_list);
// Prints array of file objects
[
{
active: true,
code: "...",
createdDate: "2017-11-22 12:29:03",
filename: "index.htm",
filepath: "index.htm",
options: {
mode: "htmlmixed",
wrap: true
},
position: 1,
size: "11.36KB",
viewid: "index.htm",
},
{
active: false,
code: "...",
createdDate: "2017-12-01 16:53:23",
filename: "test.md",
filepath: "test.md",
options: {
mode: "markdown",
wrap: true
},
position: 2,
size: "273.00B",
viewid: "test.md",
}
]
api.getDirList( bool [Default: false] )
RETURN: array
- An array of file browser objects (not to be confused with file objects), in order of which they are found.
BOOL: You can pass true
or false
depending on whether you would like async or not. If true
, a promise will be returned, in which case you can access the array using .then
.
// Without async
let dir_list = api.getDirList();
console.log(dir_list);
// With async
let dir_list = api.getDirList(true);
dir_list.then((list) => {
console.log(list);
});
// Prints array of file browser objects
[
{
filename: "SubDir",
handler: "folder",
icon: "fa fa-folder",
isfolder: true,
lastmodified: "2017-12-13 15:08:14",
path: "SubDir",
permission: "0755",
size: "-",
sort: 1,
url: "SubDir"
},
{
filename: "index.htm",
handler: "file",
icon: "fa fa-code",
isfolder: false,
lastmodified: "2017-11-22 12:29:03",
path: "index.htm",
permission: "0644",
size: "11.36KB",
sort: 2,
url: "index.htm"
}
]
api.loadFile( file_browser_obj )
RETURN: bool
- If file is already opened, it will return false
. Meaning it did not open the file, hence it already exist. You can expect true
only if the file has not already been opened.
FILE BROWSER OBJECT: You can pass a file browser object from the array when using api.getDirList()
.
let load_file = api.loadFile(dir_list[1]);
if (load_file) {
console.log("You have opened a file");
} else {
console.log("File is already open");
}