diff --git a/web/client.ts b/web/client.ts index 195dd556..912c9958 100644 --- a/web/client.ts +++ b/web/client.ts @@ -197,7 +197,7 @@ export class Client implements ConfigContainer { this.ui.render(this.parent); this.editorView = new EditorView({ - state: createEditorState(this, "", "", false), + state: createEditorState(this, "", "", true), parent: document.getElementById("sb-editor")!, }); @@ -499,6 +499,10 @@ export class Client implements ConfigContainer { await this.navigate({ page: lastPage }); } } + setTimeout(() => { + console.log("Focusing editor"); + this.focus(); + }, 100); } async initSpace(): Promise { @@ -861,7 +865,6 @@ export class Client implements ConfigContainer { rebuildEditorState() { const editorView = this.editorView; - console.log("Rebuilding editor state"); if (this.currentPage) { editorView.setState( diff --git a/web/editor_state.ts b/web/editor_state.ts index 835bd06d..e65783e6 100644 --- a/web/editor_state.ts +++ b/web/editor_state.ts @@ -80,7 +80,7 @@ export function createEditorState( ...client.ui.viewState.uiOptions.vimMode ? [vim({ status: true })] : [], ], [ - ...readOnly || client.ui.viewState.uiOptions.forcedROMode + ...(readOnly || client.ui.viewState.uiOptions.forcedROMode) ? [EditorView.editable.of(false)] : [], ], diff --git a/web/editor_ui.tsx b/web/editor_ui.tsx index ebaab326..30a24bef 100644 --- a/web/editor_ui.tsx +++ b/web/editor_ui.tsx @@ -38,6 +38,7 @@ export class MainUI { return; } console.log("Delegated keydown", ev, "to editor"); + client.focus(); if (runScopeHandlers(client.editorView, ev, "editor")) { ev.preventDefault(); }