cloud file, folder operations

This commit is contained in:
SPRINX0\prochazka
2025-05-28 10:46:35 +02:00
parent 741b942dea
commit 7b50a19b2c
9 changed files with 150 additions and 41 deletions

View File

@@ -15,16 +15,31 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
const tabs = get(openedTabs);
const tabid = editor.activator.tabid;
const data = editor.getData();
const { savedFile, savedFilePath, savedFolder } = tabs.find(x => x.tabid == tabid).props || {};
const { savedFile, savedFilePath, savedFolder, savedCloudFolderId, savedCloudContentId } =
tabs.find(x => x.tabid == tabid).props || {};
const handleSave = async () => {
if (savedFile) {
await apiCall('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
if (savedCloudFolderId && savedCloudContentId) {
const resp = await apiCall('cloud/save-file', {
folid: savedCloudFolderId,
fileName: savedFile,
data,
contentFolder: folder,
format,
cntid: savedCloudContentId,
});
if (resp.cntid) {
markTabSaved(tabid);
}
} else {
if (savedFile) {
await apiCall('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
}
if (savedFilePath) {
await apiCall('files/save-as', { filePath: savedFilePath, data, format });
}
markTabSaved(tabid);
}
if (savedFilePath) {
await apiCall('files/save-as', { filePath: savedFilePath, data, format });
}
markTabSaved(tabid);
};
const onSave = (title, newProps) => {
@@ -60,6 +75,8 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
savedFile: null,
savedFolder: null,
savedFilePath: file,
savedCloudFolderId: null,
savedCloudContentId: null,
});
}
} else if ((savedFile || savedFilePath) && saveMode == 'save') {
@@ -73,6 +90,8 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
name: savedFile || 'newFile',
filePath: savedFilePath,
onSave,
folid: savedCloudFolderId,
// cntid: savedCloudContentId,
});
}
}