mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Fix editor file handling and add UI improvements
Enable empty code files, normalize paths, mark currentFile as reactive, and convert editor styles to SCSS
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
let editorElement: HTMLDivElement;
|
||||
|
||||
export function openFile(code: string, path: string) {
|
||||
if (!code || path.endsWith('/')) return;
|
||||
if (path.endsWith('/')) return;
|
||||
const uri = monaco.Uri.parse(path);
|
||||
const model = monaco.editor.getModel(uri) ?? monaco.editor.createModel(code, null, uri);
|
||||
model.setValue(code);
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
<div class="editor" role="presentation" bind:this={editorElement}></div>
|
||||
|
||||
<style>
|
||||
<style lang="scss">
|
||||
.editor {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -17,7 +17,7 @@ class Studio {
|
||||
terminals = new SvelteMap<symbol, Synapse>();
|
||||
activeTerminal = $state(this.mainTerminalId);
|
||||
filesystem: SvelteSet<string> = $state(new SvelteSet());
|
||||
currentFile: string | null = null;
|
||||
currentFile: string | null = $state(null);
|
||||
openFiles: SvelteSet<string> = $state(new SvelteSet());
|
||||
synapse: Synapse;
|
||||
editor: monaco.editor.IStandaloneCodeEditor;
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
let mainRef: HTMLElement;
|
||||
|
||||
studio.synapse.addEventListener('syncWorkDir', ({ message }) => {
|
||||
if (studio.streaming) return;
|
||||
if (studio.streaming === false) return;
|
||||
const { path, content, event } = message.data as SyncWorkDirData;
|
||||
if (event !== 'add' && event !== 'change') return;
|
||||
studio.currentFile = path;
|
||||
instance?.openFile(content, path);
|
||||
const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
|
||||
studio.currentFile = normalizedPath;
|
||||
instance?.openFile(content, normalizedPath);
|
||||
});
|
||||
|
||||
async function openFile(path: string) {
|
||||
|
||||
Reference in New Issue
Block a user