fix(editor): restore Windows emoji input

This commit is contained in:
johnnyjoygh 2026-07-27 22:05:16 +08:00
parent 2036c1ffc1
commit b4fefa94d7
2 changed files with 20 additions and 0 deletions

View file

@ -80,6 +80,12 @@ export function buildEditorExtensions({
markdown({ extensions: [GFM] }),
...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" }),
placeholderCompartment.of(cmPlaceholder(placeholder)),
EditorView.domEventHandlers({
paste: (event) => {

View file

@ -43,6 +43,20 @@ describe("Editor", () => {
expect(onChange).toHaveBeenCalledWith("hello");
});
it("keeps native autocorrection enabled for Windows text services", () => {
const props = {
className: "x",
initialContent: "",
placeholder: "memo",
onContentChange: vi.fn(),
onFiles: vi.fn(),
onSubmit: vi.fn(),
};
const { container } = render(<Editor {...props} />);
expect(container.querySelector(".cm-content")).toHaveAttribute("autocorrect", "on");
});
it("reconfigures the placeholder when its translation changes", () => {
const props = {
className: "x",