fix: auto close properties when editor is focused

This commit is contained in:
thecodrr
2020-09-13 11:44:36 +05:00
parent 9b54bc4356
commit 138f2e4b2c
3 changed files with 10 additions and 11 deletions

View File

@@ -17,8 +17,8 @@ function Editor() {
const sessionState = useStore((store) => store.session.state);
const setSession = useStore((store) => store.setSession);
const saveSession = useStore((store) => store.saveSession);
const toggleProperties = useStore((store) => store.toggleProperties);
const init = useStore((store) => store.init);
//const openSession = useStore((store) => store.openSession);
const isFocusMode = useAppStore((store) => store.isFocusMode);
const isTrial = useUserStore(
(store) => store.user.notesnook?.subscription?.isTrial
@@ -68,13 +68,7 @@ function Editor() {
}}
flex="1 1 auto"
>
<Flex
variant="columnFill"
className="editor"
onFocus={() => {
//hideProperties();
}}
>
<Flex variant="columnFill" className="editor">
<Header />
<Flex id="toolbar" />
<EditorMenu quill={quillRef.current && quillRef.current.quill} />
@@ -83,6 +77,9 @@ function Editor() {
ref={quillRef}
refresh={sessionState === SESSION_STATES.new}
isSimple={isLoggedin || !isTrial}
onFocus={() => {
toggleProperties(false);
}}
initialContent={delta}
placeholder="Type anything here"
container=".editor"

View File

@@ -115,6 +115,6 @@ export default class ReactQuill extends Component {
render() {
console.log("RERENDERING QUILL");
return <pre id={this.props.id} />;
return <pre onFocus={this.props.onFocus} id={this.props.id} />;
}
}

View File

@@ -190,9 +190,11 @@ class EditorStore extends BaseStore {
this._setTagOrColor("tag", tag);
};
toggleProperties = () => {
toggleProperties = (toggleState) => {
this.set(
(state) => (state.arePropertiesVisible = !state.arePropertiesVisible)
(state) =>
(state.arePropertiesVisible =
toggleState !== undefined ? toggleState : !state.arePropertiesVisible)
);
};