basic text editor
This commit is contained in:
@@ -5,12 +5,17 @@ import DirectoryListContextMenu from '~/components/DirectoryListContextMenu.vue'
|
||||
import RenameEntryDialog from '~/components/actions/RenameEntryDialog.vue';
|
||||
import { fetchFile, getWarrenDirectory, warrenRm } from '~/lib/api/warrens';
|
||||
import type { DirectoryEntry } from '~/shared/types';
|
||||
import { useImageViewer, useTextEditor } from '~/stores/viewers';
|
||||
|
||||
definePageMeta({
|
||||
middleware: ['authenticated'],
|
||||
});
|
||||
|
||||
const warrenStore = useWarrenStore();
|
||||
|
||||
const imageViewer = useImageViewer();
|
||||
const textEditor = useTextEditor();
|
||||
|
||||
const loadingIndicator = useLoadingIndicator();
|
||||
const uploadStore = useUploadStore();
|
||||
const warrenPath = computed(() => useWarrenPath());
|
||||
@@ -105,10 +110,32 @@ async function onEntryClicked(entry: DirectoryEntry, event: MouseEvent) {
|
||||
warrenStore.current.path,
|
||||
entry.name
|
||||
);
|
||||
|
||||
if (result.success) {
|
||||
const url = URL.createObjectURL(result.data);
|
||||
warrenStore.imageViewer.src = url;
|
||||
imageViewer.open(url);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.mimeType.startsWith('text/')) {
|
||||
const result = await fetchFile(
|
||||
warrenStore.current.warrenId,
|
||||
warrenStore.current.path,
|
||||
entry.name
|
||||
);
|
||||
|
||||
if (result.success) {
|
||||
textEditor.open(
|
||||
warrenStore.current.warrenId,
|
||||
warrenStore.current.path,
|
||||
entry,
|
||||
result.data
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user