fix(editor): enable native mobile text assistance (#6248)
This commit is contained in:
parent
80832c0ad1
commit
2c7cf91aac
2 changed files with 15 additions and 8 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue