Add basic text editor

This commit is contained in:
Johannes Zellner
2023-02-26 23:34:31 +01:00
parent d7c3a6cec9
commit 1f16ca7e01
9 changed files with 551 additions and 29 deletions
+36
View File
@@ -0,0 +1,36 @@
import superagent from 'superagent';
import safe from 'safetydance';
export function createDirectoryModel(origin, accessToken, appId) {
return {
name: 'DirectoryModel',
async listFiles(path) {
const [error, result] = await safe(superagent.get(`${origin}/api/v1/apps/${appId}/files/${path}`).query({ access_token: accessToken }));
if (error) {
console.error('Failed to list files', error);
return [];
}
return result.body.entries;
},
async rename(oldPath, newPath) {
},
async getFile(path) {
const [error, result] = await safe(superagent.get(`${origin}/api/v1/apps/${appId}/files/${path}`).query({ access_token: accessToken }));
if (error) {
console.error('Failed to get file', error);
return null;
}
console.log(result.body);
return result.body;
}
};
}
export default {
createDirectoryModel
};