diff --git a/packages/web/editor.tsx b/packages/web/editor.tsx index 735a41a..c995c76 100644 --- a/packages/web/editor.tsx +++ b/packages/web/editor.tsx @@ -439,7 +439,7 @@ export class Editor { this.createEditorState(this.currentPage, editorView.state.sliceDoc()) ); if (editorView.contentDOM) { - editorView.contentDOM.spellcheck = true; + this.tweakEditorDOM(editorView.contentDOM); } this.restoreState(this.currentPage); @@ -508,7 +508,7 @@ export class Editor { let editorState = this.createEditorState(pageName, doc.text); editorView.setState(editorState); if (editorView.contentDOM) { - editorView.contentDOM.spellcheck = true; + this.tweakEditorDOM(editorView.contentDOM); } this.restoreState(pageName); this.space.watchPage(pageName); @@ -521,6 +521,12 @@ export class Editor { await this.eventHook.dispatchEvent("editor:pageSwitched"); } + tweakEditorDOM(contentDOM: HTMLElement) { + contentDOM.spellcheck = true; + contentDOM.setAttribute("autocorrect", "on"); + contentDOM.setAttribute("autocapitalize", "on"); + } + private restoreState(pageName: string) { let pageState = this.openPages.get(pageName); const editorView = this.editorView!; diff --git a/packages/web/syscalls/editor.ts b/packages/web/syscalls/editor.ts index 00e6afd..7990a54 100644 --- a/packages/web/syscalls/editor.ts +++ b/packages/web/syscalls/editor.ts @@ -54,7 +54,10 @@ export function editorSyscalls(editor: Editor): SysCallMapping { await editor.reloadPage(); }, "editor.openUrl": async (ctx, url: string) => { - window.open(url, "_blank")!.focus(); + let win = window.open(url, "_blank"); + if (win) { + win.focus(); + } }, "editor.flashNotification": (ctx, message: string) => { editor.flashNotification(message);