Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: auto hide properties when editor container is focused

thecodrrea42a67d76b6
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 21bce2e30..5be34f2de 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -9,6 +9,7 @@ import { useStore, SESSION_STATES } from "../../stores/editor-store";
import { timeConverter } from "../../utils/time";
import { countWords } from "../../utils/string";
import { useTheme } from "emotion-theming";
+import { useStore as useAppStore } from "../../stores/app-store";
const TextSeperator = () => {
const theme = useTheme();
@@ -30,6 +31,7 @@ function Editor() {
const setSession = useStore(store => store.setSession);
const saveSession = useStore(store => store.saveSession);
const reopenLastSession = useStore(store => store.reopenLastSession);
+ const hideProperties = useAppStore(store => store.hideProperties);
useEffect(() => {
// move the toolbar outside (easiest way)
@@ -45,7 +47,13 @@ function Editor() {
}, [reopenLastSession]);
return (
- <Flex width={["0%", "0%", "100%"]} sx={{ position: "relative" }}>
+ <Flex
+ width={["0%", "0%", "100%"]}
+ sx={{ position: "relative" }}
+ onFocus={() => {
+ hideProperties();
+ }}
+ >
<Flex className="editor" flex="1 1 auto" flexDirection="column">
<TitleBox
shouldFocus={sessionState === SESSION_STATES.new}
diff --git a/apps/web/src/components/editor/react-quill.js b/apps/web/src/components/editor/react-quill.js
index c52d19f03..b1234ec07 100644
--- a/apps/web/src/components/editor/react-quill.js
+++ b/apps/web/src/components/editor/react-quill.js
@@ -3,7 +3,6 @@ import Quill from "quill";
import "quill/dist/quill.snow.css";
import MarkdownShortcuts from "./modules/markdown";
import MagicUrl from "quill-magic-url";
-import { store as useAppStore } from "../../stores/app-store";
Quill.register("modules/markdownShortcuts", MarkdownShortcuts);
Quill.register("modules/magicUrl", MagicUrl);
@@ -106,15 +105,8 @@ export default class ReactQuill extends Component {
if (source === "api") return;
this.props.onChange(this.quill);
};
+
render() {
- return (
- <pre
- id="quill"
- onFocus={() => {
- //hideProperties();
- useAppStore.getState().hideProperties();
- }}
- />
- );
+ return <pre id="quill" />;
}
}