diff --git a/src/Editor.tsx b/src/Editor.tsx index dc0022d..e794d38 100644 --- a/src/Editor.tsx +++ b/src/Editor.tsx @@ -288,10 +288,10 @@ export default function Editor({ settings }: { settings: t.UserSettings }) { { dispatch(librarySlice.actions.setActiveTextIndex(-1)); - }} */ + }} onSubmit={(title) => { dispatch( librarySlice.actions.setTitle({ diff --git a/src/components/ContentEditable.tsx b/src/components/ContentEditable.tsx index 114b5e7..80f9a77 100644 --- a/src/components/ContentEditable.tsx +++ b/src/components/ContentEditable.tsx @@ -12,7 +12,7 @@ export default function ContentEditable({ onClick = () => {}, }) { const [content, setContent] = React.useState(value); - + const [edited, setEdited] = React.useState(false); const handleChange = (evt) => { const value = evt.target.innerHTML.replace(/
| /g, " ").trim(); setContent(value); @@ -42,32 +42,48 @@ export default function ContentEditable({ }, [div.current]); const onKeyDown = (evt) => { - if ((evt.metaKey && evt.code === "KeyS") || evt.key === "Enter") { + if ( + (evt.metaKey && evt.code === "KeyS") || + evt.key === "Enter" || + evt.key === "Tab" + ) { if (document.activeElement === div.current) { evt.preventDefault(); + setEdited(false); console.warn("submitting", content); onSubmit(content); if (nextFocus) { nextFocus(); } } + } else { + setEdited(true); } }; return ( -
- {value} -
+ <> +
+
+ {value} +
+ {edited && ( + + Enter to save + + )} +
+ ); }