A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: overhaul ui
thecodrr3f60413d2f31
diff --git a/apps/web/package.json b/apps/web/package.jsonindex 3bf89d9fe..80b3e7d79 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -26,6 +26,7 @@"react-modal": "^3.11.2","react-qrcode-logo": "^2.2.1","react-scripts": "3.4.1",+ "react-textarea-autosize": "^8.3.0","react-virtualized-auto-sizer": "^1.0.2","react-window": "^1.8.5","rebass": "^4.0.7",diff --git a/apps/web/src/app.js b/apps/web/src/app.jsindex dbcc3816f..614229cee 100644--- a/apps/web/src/app.js+++ b/apps/web/src/app.js@@ -1,8 +1,7 @@-import React, { useEffect } from "react";+import React, { useEffect, useState } from "react";import "./app.css";import { Flex, Box } from "rebass";import ThemeProvider from "./components/theme-provider";-import { usePersistentState } from "./utils/hooks";import { useStore } from "./stores/app-store";import { useStore as useEditorStore } from "./stores/editor-store";import { useStore as useUserStore } from "./stores/user-store";@@ -19,9 +18,10 @@ import {shouldAddSignupReminder,} from "./common/reminders";import { EV } from "notes-core/common";+import useTablet from "./utils/use-tablet";function App() {- const [show, setShow] = usePersistentState("isContainerVisible", true);+ const [show, setShow] = useState(true);const refreshColors = useStore((store) => store.refreshColors);const isFocusMode = useStore((store) => store.isFocusMode);const addReminder = useStore((store) => store.addReminder);@@ -29,7 +29,9 @@ function App() {const initNotes = useNotesStore((store) => store.init);const openLastSession = useEditorStore((store) => store.openLastSession);const isEditorOpen = useStore((store) => store.isEditorOpen);+ const toggleSideMenu = useStore((store) => store.toggleSideMenu);const isMobile = useMobile();+ const isTablet = useTablet();const routeResult = useRoutes(routes);useEffect(@@ -63,10 +65,12 @@ function App() {}, [openLastSession]);useEffect(() => {- if (!isMobile) return;+ if (!isMobile && !isTablet) return;setShow(!isEditorOpen);- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [isEditorOpen, isMobile]);+ // if (isTablet) toggleSideMenu(!isEditorOpen);+ // if (!isEditorOpen && !isTablet && !isMobile) toggleSideMenu(true);+ // // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [isEditorOpen, isMobile, isTablet]);useEffect(() => {return () => {@@ -74,6 +78,11 @@ function App() {};}, []);+ useEffect(() => {+ toggleSideMenu(!isMobile);+ if (!isMobile && !isTablet) setShow(true);+ }, [isMobile, isTablet, toggleSideMenu]);+return (<ThemeProvider><Flex id="app" bg="background" height="100%">@@ -99,7 +108,7 @@ function App() {{routeResult}</Animated.Flex><Flex- width={[show ? 0 : "100%", "100%", "100%"]}+ width={[show ? 0 : "100%", show ? 0 : "100%", "100%"]}flexDirection="column"><Editor />diff --git a/apps/web/src/common/height-calculator.js b/apps/web/src/common/height-calculator.jsindex d93d389af..bcec503bc 100644--- a/apps/web/src/common/height-calculator.js+++ b/apps/web/src/common/height-calculator.js@@ -2,17 +2,19 @@ const SINGLE_LINE_HEIGHT = 1.3;const DEFAULT_FONT_SIZE = 16;const MAX_HEIGHTS = {- note: SINGLE_LINE_HEIGHT * 6 * DEFAULT_FONT_SIZE,+ note: SINGLE_LINE_HEIGHT * 7 * DEFAULT_FONT_SIZE,notebook: SINGLE_LINE_HEIGHT * 7 * DEFAULT_FONT_SIZE,generic: SINGLE_LINE_HEIGHT * 4 * DEFAULT_FONT_SIZE,};function getNoteHeight(item) {- const { title, headline } = item;+ const { notebook, headline } = item;let height = SINGLE_LINE_HEIGHT * 3;- if (title.length > 35) height += SINGLE_LINE_HEIGHT;+ //if (title.length > 35) height += SINGLE_LINE_HEIGHT;if (headline?.length > 0) height += SINGLE_LINE_HEIGHT;if (headline?.length > 40) height += SINGLE_LINE_HEIGHT;+ if (notebook) height += SINGLE_LINE_HEIGHT;+return height * DEFAULT_FONT_SIZE;}diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.jsindex 896e138c1..3c65eca9a 100644--- a/apps/web/src/common/index.js+++ b/apps/web/src/common/index.js@@ -3,6 +3,10 @@ import Database from "notes-core/api/";import SelectionOptions from "./selectionoptions";import EventSource from "eventsource";import { navigate } from "hookrouter";+import { store as editorStore } from "../stores/editor-store";+import { store as noteStore } from "../stores/note-store";+import { showAddNotebookDialog } from "../components/dialogs/addnotebookdialog";+import { showTopicDialog } from "../components/dialogs/topicdialog";export const db = new Database(StorageInterface, EventSource);db.host("http://localhost:4100");@@ -33,6 +37,15 @@ export const SELECTION_OPTIONS_MAP = {topics: SelectionOptions.TopicOptions,};+export const CREATE_BUTTON_MAP = {+ notes: {+ title: "Make a note",+ onClick: () => editorStore.newSession(noteStore.get().context),+ },+ notebooks: { title: "Create a notebook", onClick: showAddNotebookDialog },+ topics: { title: "Add a topic", onClick: showTopicDialog },+};+export const DEFAULT_CONTEXT = { colors: [], tags: [], notebook: {} };export function notesFromContext(context) {diff --git a/apps/web/src/components/button/index.js b/apps/web/src/components/button/index.jsindex fa0002025..f030108bb 100644--- a/apps/web/src/components/button/index.js+++ b/apps/web/src/components/button/index.js@@ -1,5 +1,5 @@import React from "react";-import { Flex, Text } from "rebass";+import { Flex } from "rebass";import { useTheme } from "emotion-theming";//TODO use normal button@@ -9,30 +9,32 @@ function Button(props) {<Flexdata-test-id={props.testId}bg="primary"- width={props.width}py={2}px={2}mx={2}- flexDirection="row"alignItems="center"+ display={["flex", "none", "none"]}sx={{- borderRadius: "default",+ position: "absolute",+ bottom: 2,+ right: 2,+ borderRadius: 50,marginBottom: 2,color: "static",fontFamily: "body",fontWeight: "body",+ boxShadow: `1px 1px 10px 0px ${theme.colors["primary"]}`,":hover": {cursor: "pointer",bg: theme.colors.primary + "dd",},- ...props.style,}}onClick={props.onClick}>{props.Icon && <props.Icon color="static" />}- <Text as="span" mx={1} fontSize={"body"} flex="1 1 auto">+ {/* <Text as="span" mx={1} fontSize={"body"} flex="1 1 auto">{props.content}- </Text>+ </Text> */}</Flex>);}diff --git a/apps/web/src/components/dialogs/add-notebook-dialog.js b/apps/web/src/components/dialogs/add-notebook-dialog.jsindex cd183a9ba..8c18999b2 100644--- a/apps/web/src/components/dialogs/add-notebook-dialog.js+++ b/apps/web/src/components/dialogs/add-notebook-dialog.js@@ -197,36 +197,6 @@ class AddNotebookDialog extends React.Component {}}-export function showEditNoteDialog(notebook) {- return showDialog((perform) => (- <AddNotebookDialog- isOpen={true}- notebook={notebook}- edit={true}- onDone={async (nb, deletedTopics) => {- // we remove the topics from notebook- // beforehand so we can add them manually, later- const topics = qclone(nb.topics);- delete nb.topics;-- // add the edited notebook to db- await store.add({ ...notebook, ...nb });-- // add or delete topics as required- const notebookTopics = db.notebooks.notebook(notebook.id).topics;- await notebookTopics.delete(...deletedTopics);- await notebookTopics.add(...topics);-- showToast("success", "Notebook edited successfully!");- perform(true);- }}- onClose={() => {- perform(false);- }}- />- ));-}-export default AddNotebookDialog;function TopicItem(props) {@@ -288,3 +258,51 @@ function TopicItem(props) {</Flex>);}++export function showEditNotebookDialog(notebook) {+ return showDialog((perform) => (+ <AddNotebookDialog+ isOpen={true}+ notebook={notebook}+ edit={true}+ onDone={async (nb, deletedTopics) => {+ // we remove the topics from notebook+ // beforehand so we can add them manually, later+ const topics = qclone(nb.topics);+ delete nb.topics;++ // add the edited notebook to db+ await store.add({ ...notebook, ...nb });++ // add or delete topics as required+ const notebookTopics = db.notebooks.notebook(notebook.id).topics;+ await notebookTopics.delete(...deletedTopics);+ await notebookTopics.add(...topics);++ showToast("success", "Notebook edited successfully!");+ perform(true);+ }}+ onClose={() => {+ perform(false);+ }}+ />+ ));+}++export function showAddNotebookDialog(notebook) {+ return showDialog((perform) => (+ <AddNotebookDialog+ isOpen={true}+ onDone={async (nb) => {+ // add the notebook to db+ await store.add({ ...notebook, ...nb });++ showToast("success", "Notebook added successfully!");+ perform(true);+ }}+ onClose={() => {+ perform(false);+ }}+ />+ ));+}diff --git a/apps/web/src/components/dialogs/recovery-key-dialog.js b/apps/web/src/components/dialogs/recovery-key-dialog.jsindex 8d72f8dab..18c57714b 100644--- a/apps/web/src/components/dialogs/recovery-key-dialog.js+++ b/apps/web/src/components/dialogs/recovery-key-dialog.js@@ -1,10 +1,6 @@import React, { useEffect, useState } from "react";import { Text, Flex, Button } from "rebass";import Dialog, { showDialog } from "./dialog";-import * as Icon from "../icons";-import { useStore as useUserStore } from "../../stores/user-store";-import { upgrade } from "../../common/upgrade";-import { showSignUpDialog } from "./signupdialog";import { db } from "../../common";import { QRCode } from "react-qrcode-logo";import Logo from "../../assets/notesnook-small.png";diff --git a/apps/web/src/components/editor/editor.css b/apps/web/src/components/editor/editor.cssindex b228d394b..3fbaa65a2 100644--- a/apps/web/src/components/editor/editor.css+++ b/apps/web/src/components/editor/editor.css@@ -1,11 +1,16 @@+.editorTitle:focus {+ border: none;+ outline: none;+}+.ql-editor {height: auto !important;- overflow-y: hidden !important;+ overflow: hidden !important;}.ql-container.ql-snow {border: none !important;- overflow-y: auto !important;+ overflow: hidden !important;}/*Quill Toolbar*/@@ -170,17 +175,12 @@ code {}.ql-editor {- font-size: 16px;+ font-size: 14px;color: var(--text) !important;padding: 10px !important;}-.ql-editor h1,-h2,-h3,-h4,-h5,-h6 {- font-family: "DM Serif Text", serif !important;- font-weight: 400 !important;+.ql-editor h1 h2 h3 h4 h5 h6 {+ font-family: "Poppins", monospace !important;+ font-weight: 600 !important;}diff --git a/apps/web/src/components/editor/footer.js b/apps/web/src/components/editor/footer.jsnew file mode 100644index 000000000..3898ea2eb--- /dev/null+++ b/apps/web/src/components/editor/footer.js@@ -0,0 +1,32 @@+import React from "react";+import "./editor.css";+import { Flex, Text } from "rebass";+import { useStore } from "../../stores/editor-store";+import { timeConverter } from "../../utils/time";++function Footer() {+ const dateEdited = useStore((store) => store.session.dateEdited);+ const id = useStore((store) => store.session.id);+ const totalWords = useStore((store) => store.session.totalWords);+ const isSaving = useStore((store) => store.session.isSaving);+ return (+ <Flex m={2} justifyContent="flex-end" alignItems="center">+ <Text fontSize={"subBody"} color="fontTertiary">+ {id ? totalWords + " words" : "-"}+ <TextSeperator />+ {timeConverter(dateEdited) || "-"}+ <TextSeperator />+ {id ? (isSaving ? "Saving" : "Saved") : "-"}+ </Text>+ </Flex>+ );+}+export default Footer;++const TextSeperator = () => {+ return (+ <Text as="span" mx={1}>+ •+ </Text>+ );+};diff --git a/apps/web/src/components/editor/header.js b/apps/web/src/components/editor/header.jsindex d6f957c20..aab7d0966 100644--- a/apps/web/src/components/editor/header.js+++ b/apps/web/src/components/editor/header.js@@ -1,108 +1,27 @@import React from "react";import "./editor.css";-import { Flex, Text } from "rebass";-import * as Icon from "../icons";-import { useStore as useAppStore } from "../../stores/app-store";+import { Flex } from "rebass";import TitleBox from "./title-box";import { useStore, SESSION_STATES } from "../../stores/editor-store";-import { timeConverter } from "../../utils/time";-import { showToast } from "../../utils/toast";--const TextSeperator = () => {- return (- <Text as="span" mx={1} mt={"-3px"} fontSize="20px">- •- </Text>- );-};function Header() {const title = useStore((store) => store.session.title);- const dateEdited = useStore((store) => store.session.dateEdited);- const id = useStore((store) => store.session.id);- const totalWords = useStore((store) => store.session.totalWords);- const isSaving = useStore((store) => store.session.isSaving);+const sessionState = useStore((store) => store.session.state);const setSession = useStore((store) => store.setSession);- const clearSession = useStore((store) => store.clearSession);- const isFocusMode = useAppStore((store) => store.isFocusMode);- const toggleFocusMode = useAppStore((store) => store.toggleFocusMode);- const toggleProperties = useStore((store) => store.toggleProperties);return (- <Flex>- <Flex flex="1 1 auto" flexDirection="column">- <Flex- justifyContent="center"- alignItems="center"- sx={{- paddingTop: [1, 2, 2],- paddingBottom: 0,- }}- >- <Icon.ChevronLeft- sx={{- display: ["block", "none", "none"],- }}- size={30}- onClick={() => {- clearSession();- showToast("success", "Note saved!");- }}- />- <TitleBox- shouldFocus={sessionState === SESSION_STATES.new}- title={title}- changeInterval={500}- setTitle={(title) =>- setSession((state) => {- state.session.title = title;- })- }- />- </Flex>- <Text- fontSize={"subBody"}- mx={2}- color="fontTertiary"- sx={{- display: "flex",- alignItems: "center",- }}- >- {timeConverter(dateEdited) || "-"}- <TextSeperator />- {id ? totalWords + " words" : "-"}- <TextSeperator />- {id ? (isSaving ? "Saving" : "Saved") : "-"}- </Text>- </Flex>- <Flex- sx={{- visibility: ["collapse", "visible", "visible"],- }}- alignItems="center"- pr={3}- onClick={() => {- toggleFocusMode();- }}- >- {isFocusMode ? (- <Icon.NormalMode size={30} />- ) : (- <Icon.FocusMode size={30} />- )}- </Flex>- {!isFocusMode && (- <Flex- alignItems="center"- onClick={() => toggleProperties()}- pr={3}- data-test-id="properties"- >- <Icon.Properties size={30} />- </Flex>- )}+ <Flex justifyContent="center">+ <TitleBox+ shouldFocus={sessionState === SESSION_STATES.new}+ title={title}+ changeInterval={500}+ setTitle={(title) =>+ setSession((state) => {+ state.session.title = title;+ })+ }+ /></Flex>);}diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.jsindex caa9984cb..4d59c42dd 100644--- a/apps/web/src/components/editor/index.js+++ b/apps/web/src/components/editor/index.js@@ -1,7 +1,7 @@import React, { useEffect, useRef } from "react";import "./editor.css";import ReactQuill from "./react-quill";-import { Flex } from "rebass";+import { Box, Flex } from "rebass";import Properties from "../properties";import {useStore,@@ -11,7 +11,6 @@ import {import { useStore as useAppStore } from "../../stores/app-store";import { useStore as useUserStore } from "../../stores/user-store";import Animated from "../animated";-import EditorMenu from "./editormenu";import Header from "./header";import { useHashParam } from "../../utils/useHashParam";import SplitEditor from "../spliteditor";@@ -19,6 +18,9 @@ import Unlock from "../unlock";import RouteContainer from "../route-container";import useMobile from "../../utils/use-mobile";import { SUBSCRIPTION_STATUS } from "../../common";+import Toolbar from "./toolbar";+import Footer from "./footer";+import ObservableArray from "../../utils/observablearray";function Editor() {const sessionState = useStore((store) => store.session.state);@@ -63,8 +65,20 @@ function Editor() {} = editorstore.get().session;const { quill } = quillRef.current;+ console.log(quill);quill.setContents(data, "init");- quill.history.clear();+ // quill.history.clear();+ quill.history.stack = {+ undo: new ObservableArray("undo"),+ redo: new ObservableArray("redo"),+ };++ const record = quill.history.record.bind(quill.history);+ quill.history.record = function (changeDelta, oldDelta) {+ record(changeDelta, oldDelta);+ quill.history.stack.redo = new ObservableArray("redo");+ };+if (!data || !data.length) return;const text = quill.getText();quill.setSelection(text.length, 0, "init");@@ -78,15 +92,12 @@ function Editor() {route={<Unlock noteId={unlock} />}/>);+if (diff) return <SplitEditor diffId={diff} />;return (- <Animated.Flex- width={["0%", "0%", "100%"]}- initial={{ width: "100%" }}- animate={{- width: isFocusMode ? "55%" : "100%",- }}- transition={{ duration: 0.5, ease: "easeIn" }}+ <Flex+ flexDirection="column"+ width={"100%"}sx={{position: "relative",alignSelf: isFocusMode ? "center" : "stretch",@@ -94,41 +105,64 @@ function Editor() {}}flex="1 1 auto">- <Flex variant="columnFill" className="editor">- <Header />- <Flex id="toolbar" />- <EditorMenu quill={quillRef.current?.quill} />- {contentType === "delta" && (- <ReactQuill- id="quill"- ref={quillRef}- refresh={sessionState === SESSION_STATES.new}- isSimple={!isLoggedin || (isLoggedin && !isTrial)}- onFocus={() => {- toggleProperties(false);- }}- placeholder="Type anything here"- container=".editor"- onSave={() => {- saveSession();- }}- changeInterval={500}- onWordCountChanged={updateWordCount}- onChange={() => {- const { quill } = quillRef.current;- const delta = quill.getContents().ops;- setSession((state) => {- state.session.content = {- type: "delta",- data: delta,- };- });- }}- />- )}+ <Toolbar quill={quillRef.current?.quill} />+ <Flex+ variant="columnFill"+ className="editorScroll"+ flexDirection="column"+ overflow="hidden"+ overflowY="auto"+ >+ <Animated.Flex+ variant="columnFill"+ className="editor"+ sx={{ mx: [0, 0, "20%"] }}+ animate={+ isFocusMode && {+ marginRight: "25%",+ marginLeft: "25%",+ }+ }+ transition={{ duration: 0.3, ease: "easeOut" }}+ mt={[0, 0, 50]}+ >+ <Header />+ <Box id="toolbar" />+ {/* <EditorMenu quill={quillRef.current?.quill} /> */}+ {contentType === "delta" && (+ <ReactQuill+ id="quill"+ ref={quillRef}+ refresh={sessionState === SESSION_STATES.new}+ isSimple={!isLoggedin || (isLoggedin && !isTrial)}+ onFocus={() => {+ toggleProperties(false);+ }}+ placeholder="Type anything here"+ container=".editor"+ scrollContainer=".editorScroll"+ onSave={() => {+ saveSession();+ }}+ changeInterval={500}+ onWordCountChanged={updateWordCount}+ onChange={() => {+ const { quill } = quillRef.current;+ const delta = quill.getContents().ops;+ setSession((state) => {+ state.session.content = {+ type: "delta",+ data: delta,+ };+ });+ }}+ />+ )}+ </Animated.Flex></Flex>+ <Footer /><Properties />- </Animated.Flex>+ </Flex>);}export default Editor;diff --git a/apps/web/src/components/editor/react-quill.js b/apps/web/src/components/editor/react-quill.jsindex 49b7548ee..93d8480c5 100644--- a/apps/web/src/components/editor/react-quill.js+++ b/apps/web/src/components/editor/react-quill.js@@ -39,7 +39,6 @@ const quillModules = {const simpleQuillModules = {toolbar: [- [{ header: 1 }, { header: 2 }],["bold", "italic", "underline", "strike", "blockquote"],[{ list: "ordered" },@@ -78,6 +77,7 @@ export default class ReactQuill extends Component {const {placeholder,container,+ scrollContainer,readOnly,initialContent,onChange,@@ -89,6 +89,7 @@ export default class ReactQuill extends Component {this.quill = new Quill("#" + id, {placeholder,bounds: container,+ scrollingContainer: scrollContainer,modules: modules || (isSimple ? simpleQuillModules : quillModules),theme: "snow",readOnly,@@ -130,7 +131,7 @@ export default class ReactQuill extends Component {getWordCount() {let text = this.quill.getText();- return (text.match(/\b\S+\b/g) || []).length;+ return (text.split(/\b\S+\b/g) || []).length;}render() {diff --git a/apps/web/src/components/editor/titlebox.js b/apps/web/src/components/editor/titlebox.jsindex d06ad622c..1b0882031 100644--- a/apps/web/src/components/editor/titlebox.js+++ b/apps/web/src/components/editor/titlebox.js@@ -1,29 +1,12 @@import React, { useEffect, useRef } from "react";import "./editor.css";-import { Input } from "@rebass/forms";+import TextArea from "react-textarea-autosize";+import { useTheme } from "emotion-theming";-/* class TitleBox extends React.Component {- inputRef;- changeTimeout = 0;- state = { text: "" };- shouldComponentUpdate(nextProps) {- return nextProps.title !== this.props.title || nextProps.shouldFocus;- }-- componentDidUpdate() {- if (this.props.shouldFocus) {- this.inputRef.focus();- }- }-- render() {- const { setTitle, sx, changeInterval } = this.props;- }-} */-/* export default TitleBox; */var changeTimeout;function TitleBox(props) {- const { sx, title, setTitle, changeInterval, shouldFocus } = props;+ const theme = useTheme();+ const { title, setTitle, changeInterval, shouldFocus } = props;const inputRef = useRef();useEffect(() => {@@ -37,21 +20,24 @@ function TitleBox(props) {}, [shouldFocus]);return (- <Input+ <TextArearef={inputRef}autoFocus={shouldFocus}+ className="editorTitle"data-test-id="editor-title"- maxLength={120}placeholder="Untitled"- fontFamily="heading"- fontWeight="heading"- fontSize="heading"- color="text"- px={2}- sx={{- borderWidth: 0,- ":focus": { outline: "none" },- ...sx,+ maxLength={240}+ style={{+ backgroundColor: "transparent",+ fontFamily: theme.fonts["heading"],+ fontSize: 42,+ fontWeight: theme.fontWeights["heading"],+ resize: "none",+ paddingRight: theme.space[2],+ paddingLeft: theme.space[2],+ border: "none",+ color: theme.colors["text"],+ width: "100%",}}onChange={(e) => {clearTimeout(changeTimeout);diff --git a/apps/web/src/components/editor/toolbar.js b/apps/web/src/components/editor/toolbar.jsnew file mode 100644index 000000000..c60262697--- /dev/null+++ b/apps/web/src/components/editor/toolbar.js@@ -0,0 +1,104 @@+import React, { useEffect, useMemo, useState } from "react";+import "./editor.css";+import { Button, Flex, Text } from "rebass";+import * as Icon from "../icons";+import { useStore as useAppStore } from "../../stores/app-store";+import { useStore } from "../../stores/editor-store";+import { showToast } from "../../utils/toast";+import { EventManagers } from "../../utils/observablearray";++function Toolbar(props) {+ const { quill } = props;+ const sessionState = useStore((store) => store.session.state);+ const [undoable, setUndoable] = useState(false);+ const [redoable, setRedoable] = useState(false);+ const isFocusMode = useAppStore((store) => store.isFocusMode);+ const toggleFocusMode = useAppStore((store) => store.toggleFocusMode);+ const toggleProperties = useStore((store) => store.toggleProperties);+ const clearSession = useStore((store) => store.clearSession);++ useEffect(() => {+ if (!quill?.history) return;++ function updateState() {+ setUndoable(quill.history.stack.undo.length > 0);+ setRedoable(quill.history.stack.redo.length > 0);+ }++ EventManagers.redo.subscribeMulti(["pop", "push"], updateState);+ EventManagers.undo.subscribeMulti(["pop", "push"], updateState);++ return () => {+ EventManagers.undo.unsubscribeAll();+ EventManagers.redo.unsubscribeAll();+ };+ }, [sessionState, quill]);++ const tools = useMemo(+ () => [+ {+ title: "Undo",+ icon: Icon.Undo,+ enabled: undoable,+ onClick: () => quill.history.undo(),+ },+ {+ title: "Redo",+ icon: Icon.Redo,+ enabled: redoable,+ onClick: () => quill.history.redo(),+ },+ {+ title: isFocusMode ? "Normal mode" : "Focus mode",+ icon: Icon.FocusMode,+ enabled: true,+ onClick: toggleFocusMode,+ },+ {+ title: "Properties",+ icon: Icon.Properties,+ enabled: true,+ onClick: toggleProperties,+ },+ ],+ [quill, redoable, undoable, toggleFocusMode, toggleProperties, isFocusMode]+ );++ return (+ <Flex m={2} justifyContent={["space-between", "space-between", "flex-end"]}>+ <Icon.ChevronLeft+ sx={{+ display: ["block", "block", "none"],+ }}+ size={30}+ onClick={() => {+ clearSession();+ showToast("success", "Note saved!");+ }}+ />+ <Flex justifyContent="flex-end">+ {tools.map((tool) => (+ <Button+ disabled={!tool.enabled}+ variant="tool"+ title={tool.title}+ key={tool.title}+ sx={{+ color: tool.enabled ? "text" : "disabled",+ cursor: tool.enabled ? "pointer" : "not-allowed",+ }}+ onClick={tool.onClick}+ >+ <Flex justifyContent="center" alignItems="center">+ <tool.icon size={18} color={tool.enabled ? "text" : "disabled"} />+ <Text display={["none", "none", "block"]} fontSize="body" ml={1}>+ {tool.title}+ </Text>+ </Flex>+ </Button>+ ))}+ </Flex>+ </Flex>+ );+}+export default Toolbar;diff --git a/apps/web/src/components/group-header/index.js b/apps/web/src/components/group-header/index.jsindex 0712811fc..471063adf 100644--- a/apps/web/src/components/group-header/index.js+++ b/apps/web/src/components/group-header/index.js@@ -3,9 +3,9 @@ import { Box, Text } from "rebass";function GroupHeader(props) {const { title } = props;- if (title === "Pinned") return null;+ if (!title) return null;return (- <Box height={22} mx={2} bg="background" py={0}>+ <Box my={2} bg="bgSecondary" px={2} py={1}><Text variant="heading" color="primary" fontSize="subtitle">{title}</Text>diff --git a/apps/web/src/components/icons/index.js b/apps/web/src/components/icons/index.jsindex f5f5ad16e..6f0e74409 100644--- a/apps/web/src/components/icons/index.js+++ b/apps/web/src/components/icons/index.js@@ -20,23 +20,26 @@ function Icon({ name, size = 24, color = "icon", stroke, rotate }) {function createIcon(name, rotate = false) {return function (props) {return (- <Animated.Box+ <Animated.Flex+ title={props.title}variant={props.variant}- height={(props.size || 24) + "px"}whileHover={{ scale: 1.1 }}transition={{ duration: 0.3, ease: "easeOut" }}animate={props.animation}onClick={props.onClick}data-test-id={props["data-test-id"]}sx={props.sx}+ justifyContent="center"+ alignItems="center"><Icon name={name} rotate={rotate} {...props} />- </Animated.Box>+ </Animated.Flex>);};}export const Plus = createIcon(Icons.mdiPlus);+export const Note = createIcon(Icons.mdiHomeOutline);export const Minus = createIcon(Icons.mdiMinus);export const Notebook = createIcon(Icons.mdiBookOutline);export const ArrowLeft = createIcon(Icons.mdiArrowLeft);@@ -85,7 +88,7 @@ export const Theme = createIcon(Icons.mdiThemeLightDark);export const Checkmark = createIcon(Icons.mdiCheck);export const CheckCircle = createIcon(Icons.mdiCheckCircle);-export const Properties = createIcon(Icons.mdiDotsHorizontal);+export const Properties = createIcon(Icons.mdiDotsVertical);// FORMATS@@ -106,3 +109,6 @@ export const Backup = createIcon(Icons.mdiBackupRestore);export const Buy = createIcon(Icons.mdiCurrencyUsdCircleOutline);export const Edit = createIcon(Icons.mdiPencil);++export const Undo = createIcon(Icons.mdiUndoVariant);+export const Redo = createIcon(Icons.mdiRedoVariant);diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.jsindex 84ac7841d..1a20851c2 100644--- a/apps/web/src/components/list-container/index.js+++ b/apps/web/src/components/list-container/index.js@@ -1,12 +1,10 @@import React, { useEffect, useMemo, useRef } from "react";import { Flex } from "rebass";import Button from "../button";-import Search from "../search";import * as Icon from "../icons";import { VariableSizeList as List } from "react-window";import AutoSizer from "react-virtualized-auto-sizer";import { useStore as useSelectionStore } from "../../stores/selection-store";-import ReminderBar from "../reminder-bar";import GroupHeader from "../group-header";import ListProfiles from "../../common/list-profiles";@@ -38,7 +36,7 @@ function ListContainer(props) {</Flex>) : (<>- <Flex variant="columnFill" mt={2} data-test-id="note-list">+ <Flex variant="columnFill" data-test-id="note-list">{props.children? props.children: props.items.length > 0 && (@@ -50,12 +48,8 @@ function ListContainer(props) {width={width}itemKey={(index) => {switch (index) {- case 0:- return "searchbar";- case 1:- return "reminderbar";default:- const item = props.items[index - 2];+ const item = props.items[index];return item.id || item.title;}}}@@ -63,36 +57,22 @@ function ListContainer(props) {estimatedItemSize={profile.estimatedItemHeight}itemSize={(index) => {switch (index) {- case 0:- return 45;- case 1:- return 85;default:- const item = props.items[index - 2];+ const item = props.items[index];if (item.type === "header") {- if (item.title === "Pinned") return 22;- else return 22;+ if (!item.title) return 0;+ return 50;} else {return profile.itemHeight(item);}}}}- itemCount={props.items.length + 2}+ itemCount={props.items.length}>{({ index, style }) => {switch (index) {- case 0:- return (- <Search- type={props.type}- query={props.query}- context={context}- />- );- case 1:- return <ReminderBar />;default:- const item = props.items[index - 2];+ const item = props.items[index];return (<div key={item.id} style={style}>{item.type === "header" ? (diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.jsindex 82c4eecff..560c00ab0 100644--- a/apps/web/src/components/list-item/index.js+++ b/apps/web/src/components/list-item/index.js@@ -84,7 +84,7 @@ function ListItem(props) {return (<Flex- bg={props.pinned || isSelected ? "shade" : "background"}+ bg={props.focused || isSelected ? "shade" : "background"}alignItems="center"onContextMenu={openContextMenu}p={2}@@ -96,37 +96,11 @@ function ListItem(props) {cursor: "pointer",position: "relative",":hover": {- borderBottomColor: "primary",+ backgroundColor: "shade",},}}data-test-id={`${props.item.type}-${props.index}`}>- {props.pinned && (- <Flex- variant="rowCenter"- bg="primary"- onClick={() => props.unpin && props.unpin()}- sx={{- position: "absolute",- top: -15,- right: 0,- borderRadius: 35,- width: 30,- height: 30,- boxShadow: "2px 1px 3px #00000066",- }}- mx={2}- >- <Box- bg="static"- sx={{- borderRadius: 5,- width: 5,- height: 5,- }}- />- </Flex>- )}<FlexflexDirection="column"onClick={() => {@@ -144,6 +118,7 @@ function ListItem(props) {},}}>+ {props.header}<Flex>{isSelectionMode && (<ItemSelector@@ -153,13 +128,13 @@ function ListItem(props) {)}<Textas="h3"- color={props.focused ? "primary" : "text"}+ color={props.bg ? props.bg : "text"}fontFamily={"heading"}fontSize="title"fontWeight={"bold"}sx={{lineHeight: "1.4em",- maxHeight: "2.8em", // 2 lines, i hope+ maxHeight: "1.4em", // 2 lines, i hopeoverflow: "hidden",textOverflow: "ellipsis",}}@@ -190,7 +165,7 @@ function ListItem(props) {variant="body"fontSize={11}color="fontTertiary"- sx={{ marginTop: 2 }}+ sx={{ marginTop: 1 }}>{props.info}</Text>diff --git a/apps/web/src/components/menu/index.js b/apps/web/src/components/menu/index.jsindex 0a1364e16..00fb611c8 100644--- a/apps/web/src/components/menu/index.js+++ b/apps/web/src/components/menu/index.js@@ -43,11 +43,12 @@ function Menu(props) {.join("").toLowerCase()}`}key={item.title}- onClick={(e) => {+ onClick={async (e) => {e.stopPropagation();if (props.closeMenu) {props.closeMenu();}+if (!item.component) {item.onClick(props.data);}@@ -72,7 +73,7 @@ function Menu(props) {{item.title}</Text>)}- {item.onlyPro && isTrial === undefined && (+ {item.onlyPro && !isTrial && (<TextfontSize="menu"bg="primary"diff --git a/apps/web/src/components/navigation-menu/index.js b/apps/web/src/components/navigation-menu/index.jsindex dc49fae14..c585424ed 100644--- a/apps/web/src/components/navigation-menu/index.js+++ b/apps/web/src/components/navigation-menu/index.js@@ -13,9 +13,10 @@ import { COLORS } from "../../common";import { showLogInDialog } from "../dialogs/logindialog";import { usePath } from "hookrouter";import useMobile from "../../utils/use-mobile";+import useTablet from "../../utils/use-tablet";const routes = [- { title: "Home", path: "/", icon: Icon.Home },+ { title: "Notes", path: "/", icon: Icon.Note },{title: "Notebooks",path: "/notebooks",@@ -53,34 +54,12 @@ function NavigationMenu(props) {const theme = useThemeStore((store) => store.theme);const toggleNightMode = useThemeStore((store) => store.toggleNightMode);const isMobile = useMobile();+ const isTablet = useTablet();useEffect(() => {setSelectedRoute(path);}, [path]);- useEffect(() => {- if (!isMobile) return;- const app = document.getElementById("app");-- let startX = 0;- app.ontouchstart = function (event) {- if (event.touches.length > 1) return;- startX = event.touches[0].pageX;- };-- app.ontouchmove = function (event) {- if (event.touches.length > 1) return;- let currentX = event.touches[0].pageX;- if (currentX - startX > 100) {- toggleSideMenu(true);- startX = currentX;- } else if (currentX - startX < -100) {- toggleSideMenu(false);- startX = currentX;- }- };- }, [toggleSideMenu, isMobile]);-return (<Animated.Flexid="navigationmenu"@@ -92,23 +71,24 @@ function NavigationMenu(props) {}}animate={{opacity: isFocusMode ? 0 : 1,- visibility: isFocusMode ? "hidden" : "visible",+ visibility: isFocusMode ? "collapse" : "visible",x: isMobile ? (isSideMenuOpen ? 0 : -500) : 0,- zIndex: isSideMenuOpen ? 999 : 1,}}transition={{ duration: 0.3, ease: "easeOut" }}sx={{borderRight: "1px solid",borderRightColor: "border",- minWidth: ["85%", 50, 50],- maxWidth: ["85%", 50, 50],+ minWidth: ["85%", isSideMenuOpen ? 150 : 0, isFocusMode ? 0 : 150],+ maxWidth: ["85%", isSideMenuOpen ? 150 : 0, isFocusMode ? 0 : 150],+ zIndex: !isSideMenuOpen ? -1 : isMobile ? 999 : isTablet ? 1 : 1,height: ["100%", "auto", "auto"],position: ["absolute", "relative", "relative"],}}- bg={"background"}+ bg={"bgSecondary"}px={0}>- {isSideMenuOpen &&+ {isMobile &&+ isSideMenuOpen &&ReactDOM.createPortal(<Flexsx={{@@ -143,7 +123,7 @@ function NavigationMenu(props) {}onClick={() => {setSelectedRoute(item.path);- if (selectedRoute === item.path)+ if (!isMobile && !isTablet && selectedRoute === item.path)return toggleNavigationContainer();toggleNavigationContainer(true);navigate(item.path);@@ -165,13 +145,13 @@ function NavigationMenu(props) {<Flex flexDirection="column">{theme === "light" ? (<NavigationItem- title="Enable dark mode"+ title="Dark mode"icon={Icon.DarkMode}onClick={toggleNightMode}/>) : (<NavigationItem- title="Enable light mode"+ title="Light mode"icon={Icon.LightMode}onClick={toggleNightMode}/>diff --git a/apps/web/src/components/navigation-menu/navigation-item.js b/apps/web/src/components/navigation-menu/navigation-item.jsindex 60905d869..912f9d29d 100644--- a/apps/web/src/components/navigation-menu/navigation-item.js+++ b/apps/web/src/components/navigation-menu/navigation-item.js@@ -1,38 +1,39 @@import React from "react";import { Flex, Button, Text } from "rebass";import { useStore as useAppStore } from "../../stores/app-store";+import useMobile from "../../utils/use-mobile";function NavigationItem(props) {const { icon: Icon, color, title, isLoading } = props;const toggleSideMenu = useAppStore((store) => store.toggleSideMenu);+ const isMobile = useMobile();return (<Buttondata-test-id={`navitem-${title.toLowerCase()}`}variant="icon"- py={3}+ py={2}label={title}title={title}onClick={() => {- toggleSideMenu(false);+ if (isMobile) toggleSideMenu(false);props.onClick();}}><Flex- justifyContent={["flex-start", "center", "center"]}+ justifyContent={"flex-start"}alignItems="center"- ml={[1, 0, 0]}sx={{ position: "relative" }}><Iconsize={18}- sx={{ mr: [1, 0, 0] }}+ sx={{ mr: 1 }}color={props.selected ? "primary" : color || "icon"}rotate={isLoading}/><Textvariant="body"- display={["flex", "none", "none"]}+ fontSize={12}color={props.selected ? "primary" : "text"}ml={1}>diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex bbc94c636..f7bb455d5 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -1,5 +1,5 @@-import React from "react";-import { Flex, Box, Text } from "rebass";+import React, { useMemo } from "react";+import { Flex, Text } from "rebass";import * as Icon from "../icons";import TimeAgo from "timeago-react";import ListItem from "../list-item";@@ -125,6 +125,11 @@ function Note(props) {const selectedNote = useStore((store) => store.selectedNote);const isOpened = selectedNote === note.id;const theme = useTheme();+ const color = useMemo(() => COLORS[note.colors[0]], [note.colors]);+ const notebook = useMemo(+ () => note.notebook && db.notebooks.notebook(note.notebook.id).data,+ [note.notebook]+ );return (<ListItem@@ -135,7 +140,23 @@ function Note(props) {body={note.headline}id={note.id}index={index}- unpin={pin.bind(this, note)}+ header={+ note.notebook && (+ <Flex+ alignSelf="flex-start"+ justifySelf="flex-start"+ alignContent="center"+ justifyContent="center"+ mb={1}+ >+ <Icon.Notebook size={12} color={color ? color : "primary"} />+ <Text variant="subBody" fontWeight="600" mt={"4px"} ml={"3px"}>+ {notebook.title}+ </Text>+ </Flex>+ )+ }+ bg={color}onClick={() => {if (note.conflicted) {setHashParam({ diff: note.id });@@ -146,7 +167,7 @@ function Note(props) {info={<Flex flex="1 1 auto" justifyContent="space-between"><Flex variant="rowCenter">- {note.colors.map((item, colorIndex) => (+ {/* {note.colors.map((item, colorIndex) => (<Boxkey={item}style={{@@ -159,7 +180,7 @@ function Note(props) {}}data-test-id={`note-${index}-colors-${item}`}/>- ))}+ ))} */}<TimeAgo datetime={note.dateCreated} />{note.locked && (<Icon.Lockdiff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.jsindex f5fe6abfc..9b8785e97 100644--- a/apps/web/src/components/notebook/index.js+++ b/apps/web/src/components/notebook/index.js@@ -2,7 +2,7 @@ import React from "react";import { Flex, Text } from "rebass";import ListItem from "../list-item";import { store } from "../../stores/notebook-store";-import { showEditNoteDialog } from "../dialogs/addnotebookdialog";+import { showEditNotebookDialog } from "../dialogs/addnotebookdialog";import { showDeleteConfirmation } from "../dialogs/confirm";import { showItemDeletedToast, showUnpinnedToast } from "../../common/toasts";const pin = async (notebook, index) => {@@ -18,7 +18,7 @@ function menuItems(notebook, index) {{title: "Edit",onClick: async () => {- if (await showEditNoteDialog(notebook)) store.refresh();+ if (await showEditNotebookDialog(notebook)) store.refresh();},},{diff --git a/apps/web/src/components/placeholders/index.js b/apps/web/src/components/placeholders/index.jsindex 2b7eef286..f542a40cd 100644--- a/apps/web/src/components/placeholders/index.js+++ b/apps/web/src/components/placeholders/index.js@@ -17,7 +17,7 @@ function Placeholder(props) {alignSelf="stretch"sx={{ position: "relative" }}>- <Image width={"100%"} height={"200px"} />+ <Image width={"100%"} height={"120px"} /></Flex></>);diff --git a/apps/web/src/components/reminder-bar/index.js b/apps/web/src/components/reminder-bar/index.jsindex e37067d66..347569d47 100644--- a/apps/web/src/components/reminder-bar/index.js+++ b/apps/web/src/components/reminder-bar/index.js@@ -29,7 +29,7 @@ function ReminderBar() {<Text variant="subBody" fontSize={10}>{reminder.action.text}</Text>- <Text variant="body" fontSize={12} color="primary">+ <Text variant="subBody" fontSize={10} color="primary">{reminder.title}</Text></Flex>diff --git a/apps/web/src/components/route-container/index.js b/apps/web/src/components/route-container/index.jsindex 77dcabd7a..2f7bf951b 100644--- a/apps/web/src/components/route-container/index.js+++ b/apps/web/src/components/route-container/index.js@@ -4,7 +4,9 @@ import { Box, Flex, Heading, Text } from "rebass";import * as Icon from "../icons";import { useStore } from "../../stores/app-store";import { useStore as useSelectionStore } from "../../stores/selection-store";-import { SELECTION_OPTIONS_MAP } from "../../common";+import { CREATE_BUTTON_MAP, SELECTION_OPTIONS_MAP } from "../../common";+import useMobile from "../../utils/use-mobile";+import { navigate } from "hookrouter";function RouteContainer(props) {const { type, route, canGoBack, title, subtitle, onlyBackButton } = props;@@ -19,11 +21,11 @@ function RouteContainer(props) {flex="1 1 auto"><Header+ type={type}canGoBack={canGoBack}title={title}subtitle={subtitle}onlyBackButton={onlyBackButton}- selectionOptions={SELECTION_OPTIONS_MAP[type]}/>{route}</Animated.Flex>@@ -33,15 +35,11 @@ function RouteContainer(props) {export default RouteContainer;function Header(props) {- const {- title,- subtitle,- canGoBack,- selectionOptions,- onlyBackButton,- } = props;-+ const { title, subtitle, canGoBack, onlyBackButton, type } = props;+ const createButtonData = CREATE_BUTTON_MAP[type];const toggleSideMenu = useStore((store) => store.toggleSideMenu);+ const isMobile = useMobile();+ const isSelectionMode = useSelectionStore((store) => store.isSelectionMode);if (!onlyBackButton && !title && !subtitle) return null;return (@@ -50,12 +48,10 @@ function Header(props) {<Flex alignItems="center" py={2}>{canGoBack || onlyBackButton ? (<Box- alignSelf="flex-start"- onClick={() => window.history.back()}- ml={-2}height={38}width={38}sx={{ flexShrink: 0 }}+ onClick={() => window.history.back()}><Icon.ChevronLeftsize={38}@@ -78,7 +74,41 @@ function Header(props) {{title}</Heading></Flex>- <SelectionOptions options={selectionOptions} />+ <SelectionOptions options={SELECTION_OPTIONS_MAP[type]} />+ {!isSelectionMode && (+ <Flex>+ {type !== "search" && (+ <Icon.Search+ size={24}+ sx={{ mr: 2 }}+ onClick={() => {+ navigate(+ `/search`,+ false,+ {+ type,+ },+ true+ );+ }}+ />+ )}++ {!isMobile && createButtonData && (+ <Icon.Plus+ color="primary"+ size={24}+ sx={{+ bg: "bgSecondary",+ borderRadius: "default",+ size: 28,+ }}+ title={createButtonData.title}+ onClick={createButtonData.onClick}+ />+ )}+ </Flex>+ )}</Flex>{subtitle && (<Text@@ -92,7 +122,6 @@ function Header(props) {{subtitle}</Text>)}- <SelectionBox /></Flex>);}@@ -112,39 +141,9 @@ function SelectionOptions(props) {mx={2}sx={{ cursor: "pointer" }}>- <option.icon />+ <option.icon size={20} /></Box>))}</Flex>);}--function SelectionBox() {- const toggleSelectionMode = useSelectionStore(- (store) => store.toggleSelectionMode- );- const selectAll = useSelectionStore((store) => store.selectAll);- const shouldSelectAll = useSelectionStore((store) => store.shouldSelectAll);- const isSelectionMode = useSelectionStore((store) => store.isSelectionMode);-- if (!isSelectionMode) return null;- return (- <Flex- alignItems="center"- mb={2}- sx={{ cursor: "pointer" }}- onClick={() => {- if (shouldSelectAll) {- toggleSelectionMode(false);- } else {- selectAll();- }- }}- >- {shouldSelectAll ? <Icon.Check /> : <Icon.CircleEmpty />}- <Text ml={1} variant="title" color="primary">- {shouldSelectAll ? "Unselect all" : "Select all"}- </Text>- </Flex>- );-}diff --git a/apps/web/src/components/search/index.js b/apps/web/src/components/search/index.jsindex 51451a918..e6e6da4dd 100644--- a/apps/web/src/components/search/index.js+++ b/apps/web/src/components/search/index.js@@ -3,15 +3,15 @@ import { Flex, Box } from "rebass";import { Input } from "@rebass/forms";import * as Icon from "../icons";import "./search.css";-import { navigate } from "hookrouter";-function Search(props) {- const { query, type, context } = props;+function SearchBox(props) {+ //const { query, type, context } = props;return (<Flexvariant="rowCenter"px={2}+ mb={2}sx={{position: "relative",}}@@ -19,19 +19,10 @@ function Search(props) {<Inputid="searchInput"name="search"- autoFocus={!!query}- defaultValue={query}+ bg="border"placeholder={`Type your query here`}onKeyDown={(e) => {- if (e.key === "Enter") {- let query = e.target.value;- navigate(- `/search`,- false,- { q: query, type, context: btoa(JSON.stringify(context)) },- true- );- }+ if (e.key === "Enter") props.onSearch(e.target.value);}}/><Box@@ -48,4 +39,4 @@ function Search(props) {</Flex>);}-export default Search;+export default SearchBox;diff --git a/apps/web/src/index.js b/apps/web/src/index.jsindex c655b72a6..8ed6fd044 100644--- a/apps/web/src/index.js+++ b/apps/web/src/index.js@@ -7,22 +7,28 @@ import "./index.css";import App from "./App";import * as serviceWorker from "./serviceWorker";import Modal from "react-modal";-import { db } from "./common";import { MotionConfig, AnimationFeature, GesturesFeature } from "framer-motion";+import Splash from "./views/splash";-db.init()- .catch(console.error)- .finally(() => {- Modal.setAppElement("#root");- ReactDOM.render(- <MotionConfig features={[AnimationFeature, GesturesFeature]}>- <App />- </MotionConfig>,- document.getElementById("root")- );+Modal.setAppElement("#root");+ReactDOM.render(+ <MotionConfig features={[AnimationFeature, GesturesFeature]}>+ <Splash+ onLoadingFinished={() => {+ ReactDOM.render(+ <MotionConfig features={[AnimationFeature, GesturesFeature]}>+ <App />+ </MotionConfig>,+ document.getElementById("root")+ );- // If you want your app to work offline and load faster, you can change- // unregister() to register() below. Note this comes with some pitfalls.- // Learn more about service workers: https://bit.ly/CRA-PWA- serviceWorker.unregister();- });+ // If you want your app to work offline and load faster, you can change+ // unregister() to register() below. Note this comes with some pitfalls.+ // Learn more about service workers: https://bit.ly/CRA-PWA+ serviceWorker.unregister();+ }}+ />+ </MotionConfig>,+ document.getElementById("root"),+ () => {}+);diff --git a/apps/web/src/navigation/routes.js b/apps/web/src/navigation/routes.jsindex 0853317c1..f82d263c0 100644--- a/apps/web/src/navigation/routes.js+++ b/apps/web/src/navigation/routes.js@@ -11,7 +11,7 @@ import Tags from "../views/tags";import Trash from "../views/trash";const routes = {- "/": () => <RouteContainer type="notes" title="Home" route={<Home />} />,+ "/": () => <RouteContainer type="notes" title="Notes" route={<Home />} />,"/notebooks*": () => <Notebooks />,"/favorites": () => (<RouteContainer@@ -38,7 +38,7 @@ const routes = {),"/settings": () => <RouteContainer title="Settings" route={<Settings />} />,"/search": () => (- <RouteContainer canGoBack title="Search" route={<Search />} />+ <RouteContainer type="search" canGoBack title="Search" route={<Search />} />),};diff --git a/apps/web/src/stores/app-store.js b/apps/web/src/stores/app-store.jsindex 4efa3021a..22251c172 100644--- a/apps/web/src/stores/app-store.js+++ b/apps/web/src/stores/app-store.js@@ -6,10 +6,11 @@ import { store as trashStore } from "./trash-store";import { store as editorStore } from "./editor-store";import { store as tagStore } from "./tag-store";import BaseStore from "./index";+import { isMobile } from "../utils/dimensions";class AppStore extends BaseStore {// default state- isSideMenuOpen = false;+ isSideMenuOpen = !isMobile();isFocusMode = false;isEditorOpen = false;colors = [];diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.jsindex 71ed131a8..d6ac0b02e 100644--- a/apps/web/src/stores/editor-store.js+++ b/apps/web/src/stores/editor-store.js@@ -4,7 +4,7 @@ import { store as appStore } from "./app-store";import { store as tagStore } from "./tag-store";import { db } from "../common";import BaseStore from ".";-import { isMobile } from "../utils/dimensions";+import { isMobile, isTablet } from "../utils/dimensions";import { getHashParam, setHashParam } from "../utils/useHashParam";const SESSION_STATES = { stale: "stale", new: "new", locked: "locked" };@@ -45,7 +45,7 @@ class EditorStore extends BaseStore {openLastSession = async () => {// Do not reopen last session on mobile- if (isMobile()) return;+ if (isMobile() && isTablet()) return;const id = localStorage.getItem("lastOpenedNote");if (id) {diff --git a/apps/web/src/theme/colorscheme/dark.js b/apps/web/src/theme/colorscheme/dark.jsindex baa126db4..b78fa5203 100644--- a/apps/web/src/theme/colorscheme/dark.js+++ b/apps/web/src/theme/colorscheme/dark.js@@ -16,6 +16,7 @@ class DarkColorSchemeFactory {overlay: "rgba(255, 255, 255, 0.5)",secondary: "black",icon: "#dbdbdb",+ disabled: "#5b5b5b",...new StaticColorSchemeFactory(accent),};}diff --git a/apps/web/src/theme/colorscheme/light.js b/apps/web/src/theme/colorscheme/light.jsindex 6ec517823..63dc9f534 100644--- a/apps/web/src/theme/colorscheme/light.js+++ b/apps/web/src/theme/colorscheme/light.js@@ -7,14 +7,15 @@ class LightColorSchemeFactory {primary: accent,background: "white",accent: "white",- bgSecondary: "#f0f0f0",+ bgSecondary: "#f7f7f7",border: "#f0f0f0",hover: "#e0e0e0",fontSecondary: "white",- text: "#000000",+ text: "#202124",overlay: "rgba(0, 0, 0, 0.1)",secondary: "white",icon: "#3b3b3b",+ disabled: "#9b9b9b",placeholder: hexToRGB("#000000", 0.6),...new StaticColorSchemeFactory(accent),};diff --git a/apps/web/src/theme/index.js b/apps/web/src/theme/index.jsindex 7252d1519..e1d16741e 100644--- a/apps/web/src/theme/index.js+++ b/apps/web/src/theme/index.js@@ -12,12 +12,12 @@ class ThemeFactory {construct(config) {return {breakpoints: ["480px", "1000px", "1000px"],- space: [0, 5, 10, 15, 20, 25, 30, 35] ,+ space: [0, 5, 10, 15, 20, 25, 30, 35],sizes: { full: "100%", half: "50%" },radii: { none: 0, default: 5 },colors: new ColorSchemeFactory(config.theme, config.accent),...new FontFactory(config.scale),- ...new VariantsFactory()+ ...new VariantsFactory(),};}}diff --git a/apps/web/src/theme/variants/button.js b/apps/web/src/theme/variants/button.jsindex d811091ee..8da4ddf89 100644--- a/apps/web/src/theme/variants/button.js+++ b/apps/web/src/theme/variants/button.js@@ -7,7 +7,7 @@ class ButtonFactory {tertiary: new Tertiary(),list: new List(),anchor: new Anchor(),- menu: new Menu(),+ tool: new Tool(),icon: new Icon(),};}@@ -109,16 +109,16 @@ class Icon {}}-class Menu {+class Tool {constructor() {return {variant: "buttons.default",color: "text",- fontSize: 14,- p: 2,- borderRadius: "none",+ p: 1,+ px: 2,+ borderRadius: "default",":hover": {- backgroundColor: "shade",+ backgroundColor: "bgSecondary",},};}diff --git a/apps/web/src/utils/dimensions.js b/apps/web/src/utils/dimensions.jsindex 2622a96cb..86430a7b2 100644--- a/apps/web/src/utils/dimensions.js+++ b/apps/web/src/utils/dimensions.js@@ -1,10 +1,19 @@function isMobile() {var match = window.matchMedia || window.msMatchMedia;if (match) {- var mq = match("(pointer:coarse)");+ var mq = match("(max-width: 480px)");return mq.matches;}return false;}-export { isMobile };+function isTablet() {+ var match = window.matchMedia || window.msMatchMedia;+ if (match) {+ var mq = match("(min-width: 480px) and (max-width: 1000px)");+ return mq.matches;+ }+ return false;+}++export { isMobile, isTablet };diff --git a/apps/web/src/utils/observablearray.js b/apps/web/src/utils/observablearray.jsnew file mode 100644index 000000000..13d9cb665--- /dev/null+++ b/apps/web/src/utils/observablearray.js@@ -0,0 +1,24 @@+import EventManager from "notes-core/utils/eventmanager";++export const EventManagers = {+ redo: new EventManager(),+ undo: new EventManager(),+};+export default class ObservableArray extends Array {+ constructor(type) {+ super();+ this.type = type;+ }++ pop = () => {+ const item = super.pop();+ EventManagers[this.type].publish("pop", this.length);+ return item;+ };++ push = (item) => {+ const n = super.push(item);+ EventManagers[this.type].publish("push", this.length);+ return n;+ };+}diff --git a/apps/web/src/utils/time.js b/apps/web/src/utils/time.jsindex 934c1a04f..d7bcd6f68 100644--- a/apps/web/src/utils/time.js+++ b/apps/web/src/utils/time.js@@ -1,13 +1,3 @@-const days = [- "Sunday",- "Monday",- "Tuesday",- "Wednesday",- "Thursday",- "Friday",- "Saturday"-];-const months = ["Jan","Feb",@@ -20,7 +10,7 @@ const months = ["Sep","Oct","Nov",- "Dec"+ "Dec",];export function timeConverter(timestamp, showSeconds = false) {@@ -28,7 +18,6 @@ export function timeConverter(timestamp, showSeconds = false) {var d = new Date(timestamp), // Convert the passed timestamp to millisecondsyyyy = d.getFullYear(),dd = ("0" + d.getDate()).slice(-2), // Add leading 0.- currentDay = d.getDay(),hh = d.getHours(),h = hh,min = ("0" + d.getMinutes()).slice(-2), // Add leading 0.@@ -48,8 +37,6 @@ export function timeConverter(timestamp, showSeconds = false) {// ie: 2013-02-18, 8:35 AMtime =- days[currentDay] +- " " +dd +" " +months[d.getMonth()] +diff --git a/apps/web/src/utils/use-tablet.js b/apps/web/src/utils/use-tablet.jsnew file mode 100644index 000000000..87302cd5e--- /dev/null+++ b/apps/web/src/utils/use-tablet.js@@ -0,0 +1,4 @@+import useMediaQuery from "./use-media-query";++export default () =>+ useMediaQuery("(min-width: 480px) and (max-width: 1000px)");diff --git a/apps/web/src/views/notebooks.js b/apps/web/src/views/notebooks.jsindex 0c33ff654..27ef16132 100644--- a/apps/web/src/views/notebooks.js+++ b/apps/web/src/views/notebooks.js@@ -1,5 +1,5 @@-import React, { useState, useEffect } from "react";-import AddNotebookDialog from "../components/dialogs/addnotebookdialog";+import React, { useEffect } from "react";+import { showAddNotebookDialog } from "../components/dialogs/addnotebookdialog";import ListContainer from "../components/list-container";import { useStore, store } from "../stores/notebook-store";import NotebooksPlaceholder from "../components/placeholders/notebooks-placeholder";@@ -51,10 +51,8 @@ function NotebooksContainer() {}function Notebooks() {- const [open, setOpen] = useState(false);useEffect(() => store.refresh(), []);const notebooks = useStore((state) => state.notebooks);- const add = useStore((state) => state.add);return (<>@@ -64,20 +62,7 @@ function Notebooks() {placeholder={NotebooksPlaceholder}button={{content: "Create a notebook",- onClick: async () => {- setOpen(true);- },- }}- />- <AddNotebookDialog- isOpen={open}- edit={false}- onDone={async (nb) => {- await add(nb);- setOpen(false);- }}- onClose={() => {- setOpen(false);+ onClick: showAddNotebookDialog,}}/></>diff --git a/apps/web/src/views/search.js b/apps/web/src/views/search.jsindex 3e58943b5..a4c12100c 100644--- a/apps/web/src/views/search.js+++ b/apps/web/src/views/search.js@@ -1,14 +1,15 @@-import React, { useEffect, useMemo, useState } from "react";+import React, { useState } from "react";import ListContainer from "../components/list-container";import SearchPlaceholder from "../components/placeholders/search-placeholder";import { useQueryParams } from "hookrouter";import { db, notesFromContext } from "../common";+import SearchBox from "../components/search";+import { useStore as useNoteStore } from "../stores/note-store";function typeToItems(type, context) {switch (type) {- case "home":- return ["notes", db.notes.all];case "notes":+ if (!context) return ["notes", db.notes.all];const notes = notesFromContext(context);return ["notes", notes];case "notebooks":@@ -28,32 +29,20 @@ function typeToItems(type, context) {function Search() {const [results, setResults] = useState([]);const [params] = useQueryParams();- const { q: query, type, context: ctx } = params;- const context = useMemo(() => {- try {- return ctx && JSON.parse(atob(ctx));- } catch (e) {- console.log(e);- }- }, [ctx]);-- useEffect(() => {- const [lookupType, items] = typeToItems(type, context);- if (lookupType === "notes") {- db.lookup[lookupType](items, query).then((results) => {- setResults(results);- });- } else {- setResults(db.lookup[lookupType](items, query));- }- }, [context, query, type]);+ const { type } = params;+ const context = useNoteStore((store) => store.context);return (<>+ <SearchBox+ onSearch={(query) => {+ const [lookupType, items] = typeToItems(type, context);+ setResults(db.lookup[lookupType](items, query));+ }}+ /><ListContainercontext={context}type={type}- query={query}items={results}placeholder={SearchPlaceholder}/>diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.jsindex d600f33e3..f4f6fc4e7 100644--- a/apps/web/src/views/settings.js+++ b/apps/web/src/views/settings.js@@ -8,7 +8,6 @@ import AccentItem from "../components/accent-item";import accents from "../theme/accents";import { showLogInDialog } from "../components/dialogs/logindialog";import { showLogoutConfirmation } from "../components/dialogs/confirm";-import { upgrade } from "../common/upgrade";import useSystemTheme from "../utils/use-system-theme";import download from "../utils/download";import { db, SUBSCRIPTION_STATUS } from "../common";diff --git a/apps/web/src/views/splash.js b/apps/web/src/views/splash.jsnew file mode 100644index 000000000..a2bdfe311--- /dev/null+++ b/apps/web/src/views/splash.js@@ -0,0 +1,83 @@+import React, { useEffect, useState } from "react";+import { Flex, Text } from "rebass";+import ThemeProvider from "../components/theme-provider";+import Animated from "../components/animated";+import { db } from "../common";+import { getRandom } from "../utils/random";++const loadingLines = [+ "Ejecting bumfuzzled notes",+ "Clearing up taradiddle vaccuums",+ "Lollygagging all parachutes",+ "Absquatulating the note engines",+ "Personalizing nincompoop notebooks",+];++function Splash(props) {+ const [loading, setLoading] = useState(true);+ const [animationEnded, setAnimationEnded] = useState(false);+ useEffect(() => {+ (async function () {+ try {+ await db.init();+ setLoading(false);+ } catch (e) {+ console.error(e);+ }+ })();+ }, []);++ useEffect(() => {+ if (!loading && animationEnded) props.onLoadingFinished();+ }, [loading, animationEnded, props]);++ return (+ <ThemeProvider>+ <Flex+ flexDirection="column"+ bg="bgSecondary"+ height="100%"+ justifyContent="center"+ alignItems="center"+ overflow="hidden"+ >+ <Flex+ sx={{+ fontSize: 62,+ color: "primary",+ fontWeight: "bold",+ fontFamily: "body",+ }}+ >+ <Animated.Text backgroundColor="bgPrimary" overflow={"hidden"} x={0}>+ Notes+ </Animated.Text>+ <Animated.Flex backgroundColor="" overflow={"hidden"}>+ <Animated.Text+ initial={{ x: -100 * 1.2 }}+ animate={{ x: 0 }}+ transition={{ ease: "easeOut", duration: 1 }}+ >+ nook+ </Animated.Text>+ </Animated.Flex>+ </Flex>+ <Flex overflow="hidden" width={300}>+ <Animated.Box+ height={5}+ initial={{ width: "0%" }}+ animate={{ width: "100%" }}+ transition={{ duration: 1 }}+ bg="primary"+ sx={{ borderRadius: "default" }}+ onAnimationComplete={() => setAnimationEnded(true)}+ />+ </Flex>+ <Text color="text" mt={2}>+ {loadingLines[getRandom(0, loadingLines.length)]}+ </Text>+ </Flex>+ </ThemeProvider>+ );+}+export default Splash;diff --git a/apps/web/yarn.lock b/apps/web/yarn.lockindex 8188779af..6455ac96d 100644--- a/apps/web/yarn.lock+++ b/apps/web/yarn.lock@@ -7971,11 +7971,6 @@ jsesc@~0.5.0:resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=-jshashes@^1.0.8:- version "1.0.8"- resolved "https://registry.yarnpkg.com/jshashes/-/jshashes-1.0.8.tgz#f60d837428383abf73ab022e1542e6614bd75514"- integrity sha512-btmQZ/w1rj8Lb6nEwvhjM7nBYoj54yaEFo2PWh3RkxZ8qNwuvOxvQYN/JxVuwoMmdIluL+XwYVJ+pEEZoSYybQ==-json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2:version "1.0.2"resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"@@ -8864,17 +8859,17 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg=="notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":- version "2.1.0"- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#b7d94074f19261cd0efc6c60c1720e82981b49a2"+ version "2.1.1"+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#9f80e6b94e45c56b30531d294bf415dfc057c347"dependencies:fast-sort "^2.0.1"fuzzysearch "^1.0.3"hypersearch "https://github.com/streetwriters/hypersearch"- jshashes "^1.0.8"no-internet "^1.5.2"qclone "^1.0.4"quill-delta-to-html "^0.12.0"quill-delta-to-markdown "https://github.com/streetwriters/quill-delta-to-markdown"+ spark-md5 "^3.0.1"transfun "^1.0.2"npm-run-path@^2.0.0:@@ -10759,6 +10754,15 @@ [email protected]:optionalDependencies:fsevents "2.1.2"+react-textarea-autosize@^8.3.0:+ version "8.3.0"+ resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.3.0.tgz#e6e2fd186d9f61bb80ac6e2dcb4c55504f93c2fa"+ integrity sha512-3GLWFAan2pbwBeoeNDoqGmSbrShORtgWfaWX0RJDivsUrpShh01saRM5RU/i4Zmf+whpBVEY5cA90Eq8Ub1N3w==+ dependencies:+ "@babel/runtime" "^7.10.2"+ use-composed-ref "^1.0.0"+ use-latest "^1.0.0"+react-virtualized-auto-sizer@^1.0.2:version "1.0.2"resolved "https://registry.yarnpkg.com/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.2.tgz#a61dd4f756458bbf63bd895a92379f9b70f803bd"@@ -11707,6 +11711,11 @@ source-map@^0.7.3:resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==+spark-md5@^3.0.1:+ version "3.0.1"+ resolved "https://registry.yarnpkg.com/spark-md5/-/spark-md5-3.0.1.tgz#83a0e255734f2ab4e5c466e5a2cfc9ba2aa2124d"+ integrity sha512-0tF3AGSD1ppQeuffsLDIOWlKUd3lS92tFxcsrh5Pe3ZphhnoK+oXIBTzOAThZCiuINZLvpiLH/1VS1/ANEJVig==+spawn-wrap@^2.0.0:version "2.0.0"resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-2.0.0.tgz#103685b8b8f9b79771318827aa78650a610d457e"@@ -12396,6 +12405,11 @@ tryer@^1.0.1:resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==+ts-essentials@^2.0.3:+ version "2.0.12"+ resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-2.0.12.tgz#c9303f3d74f75fa7528c3d49b80e089ab09d8745"+ integrity sha512-3IVX4nI6B5cc31/GFFE+i8ey/N2eA0CZDbo6n0yrz0zDX8ZJ8djmU1p+XRz7G3is0F3bB3pu2pAroFdAWQKU3w==+version "1.1.6"resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.6.tgz#389a24396d425a0d3162e96d2b4638900fdc289a"@@ -12629,6 +12643,25 @@ url@^0.11.0:punycode "1.3.2"querystring "0.2.0"+use-composed-ref@^1.0.0:+ version "1.1.0"+ resolved "https://registry.yarnpkg.com/use-composed-ref/-/use-composed-ref-1.1.0.tgz#9220e4e94a97b7b02d7d27eaeab0b37034438bbc"+ integrity sha512-my1lNHGWsSDAhhVAT4MKs6IjBUtG6ZG11uUqexPH9PptiIZDQOzaF4f5tEbJ2+7qvNbtXNBbU3SfmN+fXlWDhg==+ dependencies:+ ts-essentials "^2.0.3"++use-isomorphic-layout-effect@^1.0.0:+ version "1.1.0"+ resolved "https://registry.yarnpkg.com/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.0.tgz#4db2111e0d53ca694187ea5fd5cb2ba610286fe0"+ integrity sha512-kady5Z1O1qx5RitodCCKbpJSVEtECXYcnBnb5Q48Bz5V6gBmTu85ZcGdVwVFs8+DaOurNb/L5VdGHoQRMknghw==++use-latest@^1.0.0:+ version "1.2.0"+ resolved "https://registry.yarnpkg.com/use-latest/-/use-latest-1.2.0.tgz#a44f6572b8288e0972ec411bdd0840ada366f232"+ integrity sha512-d2TEuG6nSLKQLAfW3By8mKr8HurOlTkul0sOpxbClIv4SQ4iOd7BYr7VIzdbktUCnv7dua/60xzd8igMU6jmyw==+ dependencies:+ use-isomorphic-layout-effect "^1.0.0"+use@^3.1.0:version "3.1.1"resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"