Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix(editor): enable native mobile text assistance (#6248)

boojack2c7cf91aac7c
diff --git a/web/src/components/MemoEditor/Editor/extensions.ts b/web/src/components/MemoEditor/Editor/extensions.ts
index e3077d53f..82869e55d 100644
--- a/web/src/components/MemoEditor/Editor/extensions.ts
+++ b/web/src/components/MemoEditor/Editor/extensions.ts
@@ -81,12 +81,16 @@ export function buildEditorExtensions({
markdown({ extensions: memoMarkdownExtensions }),
...memoEditorTheme,
EditorView.lineWrapping,
- // CodeMirror defaults to autocorrect="off" because it is primarily a code
- // editor. Memos is a prose editor, and leaving that default in place also
- // routes Windows TSF input (including the Win+. emoji picker) through
- // Chrome's autocorrect-suppression path, which has dropped committed text.
- // Restore the browser default used by the textarea editor before v0.30.
- EditorView.contentAttributes.of({ autocorrect: "on" }),
+ // CodeMirror disables native text assistance because it is primarily a code
+ // editor. Memos is a prose editor, so restore the browser behavior used by
+ // the textarea editor before v0.30. Autocorrect also keeps Windows TSF input
+ // out of Chrome's autocorrect-suppression path, which has dropped committed
+ // text from the emoji picker.
+ EditorView.contentAttributes.of({
+ autocorrect: "on",
+ autocapitalize: "on",
+ spellcheck: "true",
+ }),
placeholderCompartment.of(cmPlaceholder(placeholder)),
EditorView.domEventHandlers({
paste: (event, view) => {
diff --git a/web/tests/editor.test.tsx b/web/tests/editor.test.tsx
index 3ad852951..0015fab4b 100644
--- a/web/tests/editor.test.tsx
+++ b/web/tests/editor.test.tsx
@@ -105,7 +105,7 @@ describe("Editor", () => {
expect(onChange).not.toHaveBeenCalledWith("server value");
});
- it("keeps native autocorrection enabled for Windows text services", () => {
+ it("enables native text assistance for prose input", () => {
const props = {
className: "x",
initialContent: "",
@@ -116,7 +116,10 @@ describe("Editor", () => {
};
const { container } = render(<Editor {...props} />);
- expect(container.querySelector(".cm-content")).toHaveAttribute("autocorrect", "on");
+ const content = container.querySelector(".cm-content");
+ expect(content).toHaveAttribute("autocorrect", "on");
+ expect(content).toHaveAttribute("autocapitalize", "on");
+ expect(content).toHaveAttribute("spellcheck", "true");
});
it("reconfigures the placeholder when its translation changes", () => {