Skip to content

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

feat: use custom scroll everywhere

thecodrrb165724ef0e9
diff --git a/apps/web/package.json b/apps/web/package.json
index 5e62dc629..7d10acfc3 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -52,7 +52,7 @@
"rebass": "^4.0.7",
"streamablefs": "file:packages/streamablefs",
"timeago.js": "^4.0.2",
- "tinymce": "^5.10.0",
+ "tinymce": "^5.10.2",
"uzip": "^0.20201231.0",
"web-streams-polyfill": "^3.1.1",
"wouter": "^2.7.3",
diff --git a/apps/web/src/components/dialogs/confirm.js b/apps/web/src/components/dialogs/confirm.js
index c412d8860..3f47ccb7b 100644
--- a/apps/web/src/components/dialogs/confirm.js
+++ b/apps/web/src/components/dialogs/confirm.js
@@ -8,7 +8,6 @@ function Confirm(props) {
isOpen={true}
title={props.title}
icon={props.icon}
- scrollable
description={props.subtitle}
onClose={props.onNo}
positiveButton={{
diff --git a/apps/web/src/components/dialogs/dialog.js b/apps/web/src/components/dialogs/dialog.js
index 1f3dcf478..ca1c29bd1 100644
--- a/apps/web/src/components/dialogs/dialog.js
+++ b/apps/web/src/components/dialogs/dialog.js
@@ -2,6 +2,7 @@ import { Flex, Text, Button as RebassButton } from "rebass";
import * as Icon from "../icons";
import Modal from "react-modal";
import { useTheme } from "emotion-theming";
+import { FlexScrollContainer } from "../scroll-container";
Modal.setAppElement("#root");
function Dialog(props) {
@@ -37,6 +38,7 @@ function Dialog(props) {
right: 0,
bottom: 0,
display: "flex",
+ flexDirection: "column",
justifyContent: "center",
backgroundColor: undefined,
padding: 0,
@@ -57,8 +59,9 @@ function Dialog(props) {
height={["100%", "auto", "auto"]}
bg="background"
alignSelf={"center"}
- overflowY={props.scrollable ? "auto" : "hidden"}
+ overflowY={"hidden"}
sx={{
+ justifyContent: "stretch",
position: "relative",
overflow: "hidden",
boxShadow: "4px 5px 18px 2px #00000038",
@@ -98,8 +101,8 @@ function Dialog(props) {
</Text>
)}
</Flex>
- <Flex flexDirection="column" my={1} mx={4}>
- {props.children}
+ <Flex variant="columnFill" sx={{ overflowY: "hidden" }} my={1} mx={4}>
+ <FlexScrollContainer>{props.children}</FlexScrollContainer>
</Flex>
{(props.positiveButton || props.negativeButton) && (
<Flex
diff --git a/apps/web/src/components/dialogs/exportdialog.js b/apps/web/src/components/dialogs/exportdialog.js
index 52cb07954..0a85d74ac 100644
--- a/apps/web/src/components/dialogs/exportdialog.js
+++ b/apps/web/src/components/dialogs/exportdialog.js
@@ -44,7 +44,6 @@ function ExportDialog(props) {
icon={props.icon}
description="You can export your notes as Markdown, HTML, PDF or Text."
onClose={props.onClose}
- scrollable
negativeButton={{
onClick: props.onClose,
text: "Cancel",
diff --git a/apps/web/src/components/dialogs/featuredialog.js b/apps/web/src/components/dialogs/featuredialog.js
index bf8beaaef..3e3b65ec6 100644
--- a/apps/web/src/components/dialogs/featuredialog.js
+++ b/apps/web/src/components/dialogs/featuredialog.js
@@ -109,7 +109,6 @@ function FeatureDialog(props) {
<Dialog
isOpen={true}
title={feature.title}
- scrollable
description={feature.subtitle}
buttonsAlignment="center"
positiveButton={{
diff --git a/apps/web/src/components/dialogs/issuedialog.js b/apps/web/src/components/dialogs/issuedialog.js
index 6a5ccde32..08af2a74a 100644
--- a/apps/web/src/components/dialogs/issuedialog.js
+++ b/apps/web/src/components/dialogs/issuedialog.js
@@ -46,7 +46,6 @@ function IssueDialog(props) {
<Dialog
isOpen={true}
title={"Report an issue"}
- scrollable
description={
"Let us know if you are facing an issue. We'll do our best to sort it out for you."
}
diff --git a/apps/web/src/components/dialogs/move-note-dialog.js b/apps/web/src/components/dialogs/move-note-dialog.js
index 00a7e7599..9975b356a 100644
--- a/apps/web/src/components/dialogs/move-note-dialog.js
+++ b/apps/web/src/components/dialogs/move-note-dialog.js
@@ -1,5 +1,5 @@
import React from "react";
-import { Flex, Box, Text } from "rebass";
+import { Flex, Text } from "rebass";
import * as Icon from "../icons";
import { db } from "../../common/db";
import Dialog from "./dialog";
@@ -86,7 +86,7 @@ class MoveDialog extends React.Component {
onClick: props.onClose,
}}
>
- <Flex flexDirection="column" sx={{ overflowY: "hidden" }}>
+ <Flex flexDirection="column" flex={1} sx={{ overflowY: "hidden" }}>
<Field
inputRef={(ref) => (this.inputRef = ref)}
data-test-id="mnd-new-notebook-title"
@@ -105,14 +105,12 @@ class MoveDialog extends React.Component {
if (e.key === "Enter") await this.addNotebook(e.target);
}}
/>
- <Box
+ <Flex
mt={1}
+ variant="columnFill"
sx={{
borderRadius: "default",
- borderWidth: 1,
- borderStyle: "solid",
- borderColor: "border",
- overflowY: "auto",
+ border: "1px solid var(--border)",
}}
>
{notebooks.map((notebook, index) => (
@@ -197,7 +195,7 @@ class MoveDialog extends React.Component {
</Flex>
</Flex>
))}
- </Box>
+ </Flex>
</Flex>
</Dialog>
);
diff --git a/apps/web/src/components/dialogs/reminder-dialog.js b/apps/web/src/components/dialogs/reminder-dialog.js
index 4d12aa011..783367d80 100644
--- a/apps/web/src/components/dialogs/reminder-dialog.js
+++ b/apps/web/src/components/dialogs/reminder-dialog.js
@@ -81,7 +81,6 @@ function ReminderDialog(props) {
title={reminder.title}
onClose={props.onClose}
showClose
- scrollable
description={reminder.description}
alignment="center"
positiveButton={{
diff --git a/apps/web/src/components/dialogs/sessionexpireddialog.js b/apps/web/src/components/dialogs/sessionexpireddialog.js
index e597fc574..5a2ed9e23 100644
--- a/apps/web/src/components/dialogs/sessionexpireddialog.js
+++ b/apps/web/src/components/dialogs/sessionexpireddialog.js
@@ -57,7 +57,6 @@ function SessionExpiredDialog(props) {
</Flex>
}
icon={Icon.Login}
- scrollable
negativeButton={{
text: "Sign out",
disabled: isLoggingIn,
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 6a9b0ddcb..066338b8a 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -20,6 +20,7 @@ import EditorLoading from "./loading";
import { db } from "../../common/db";
import { AppEventManager, AppEvents } from "../../common";
import debounce from "just-debounce-it";
+import { FlexScrollContainer } from "../scroll-container";
const ReactMCE = React.lazy(() => import("./tinymce"));
@@ -136,81 +137,83 @@ function Editor({ noteId, nonce }) {
</Flex>
) : null}
<Toolbar />
- <Flex
- variant="columnFill"
- className="editorScroll"
- flexDirection="column"
- overflow="hidden"
- overflowY="auto"
- >
- <Flex
- id="editorToolbar"
- sx={{
- bg: "background",
- position: "sticky",
- top: 0,
- zIndex: 2,
- borderBottom: "1px solid",
- borderBottomColor: "border",
- justifyContent: "center",
- alignItems: "center",
- minHeight: "39px",
- }}
- />
+ <FlexScrollContainer>
<Flex
variant="columnFill"
- className="editor"
- sx={{
- alignSelf: [
- "stretch",
- isFocusMode ? "center" : "stretch",
- "center",
- ],
- }}
- maxWidth={isFocusMode ? "min(100%,850px)" : "900px"}
- width="100%"
- mx={[2, 2, 0]}
- mt={[2, 2, 25]}
+ className="editorScroll"
+ flexDirection="column"
+ overflow="hidden"
+ overflowY="auto"
>
- <Header />
-
- {isSessionReady && (
- <Suspense fallback={<div />}>
- {contentType === "tiny" ? (
- <>
- <ReactMCE
- editorRef={editorRef}
- onFocus={() => toggleProperties(false)}
- onSave={saveSession}
- sessionId={sessionId}
- onChange={(content, editor) => {
- if (!content || content === "<p><br></pr>") return;
-
- editorstore.get().setSessionContent({
- type: "tiny",
- data: content,
- });
-
- debouncedUpdateWordCount(editor);
- }}
- changeInterval={100}
- onInit={(editor) => {
- if (sessionId && editorstore.get().session.contentId) {
- setContent();
- } else if (nonce) clearContent();
-
- setTimeout(() => {
- setIsEditorLoading(false);
- // a short delay to make sure toolbar has rendered.
- }, 100);
- }}
- />
- </>
- ) : null}
- </Suspense>
- )}
+ <Flex
+ id="editorToolbar"
+ sx={{
+ bg: "background",
+ position: "sticky",
+ top: 0,
+ zIndex: 2,
+ borderBottom: "1px solid",
+ borderBottomColor: "border",
+ justifyContent: "center",
+ alignItems: "center",
+ minHeight: "39px",
+ }}
+ />
+ <Flex
+ variant="columnFill"
+ className="editor"
+ sx={{
+ alignSelf: [
+ "stretch",
+ isFocusMode ? "center" : "stretch",
+ "center",
+ ],
+ }}
+ maxWidth={isFocusMode ? "min(100%,850px)" : "900px"}
+ width="100%"
+ mx={[2, 2, 0]}
+ mt={[2, 2, 25]}
+ >
+ <Header />
+
+ {isSessionReady && (
+ <Suspense fallback={<div />}>
+ {contentType === "tiny" ? (
+ <>
+ <ReactMCE
+ editorRef={editorRef}
+ onFocus={() => toggleProperties(false)}
+ onSave={saveSession}
+ sessionId={sessionId}
+ onChange={(content, editor) => {
+ if (!content || content === "<p><br></pr>") return;
+
+ editorstore.get().setSessionContent({
+ type: "tiny",
+ data: content,
+ });
+
+ debouncedUpdateWordCount(editor);
+ }}
+ changeInterval={100}
+ onInit={(editor) => {
+ if (sessionId && editorstore.get().session.contentId) {
+ setContent();
+ } else if (nonce) clearContent();
+
+ setTimeout(() => {
+ setIsEditorLoading(false);
+ // a short delay to make sure toolbar has rendered.
+ }, 100);
+ }}
+ />
+ </>
+ ) : null}
+ </Suspense>
+ )}
+ </Flex>
</Flex>
- </Flex>
+ </FlexScrollContainer>
{arePropertiesVisible && <Properties noteId={noteId} />}
</Flex>
);
diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.js
index 1c2feac2e..5d706c369 100644
--- a/apps/web/src/components/editor/tinymce.js
+++ b/apps/web/src/components/editor/tinymce.js
@@ -2,7 +2,7 @@ import React, { useEffect } from "react";
import "./editor.css";
import "@streetwritersco/tinymce-plugins/codeblock/styles.css";
import "@streetwritersco/tinymce-plugins/collapsibleheaders/styles.css";
-import "tinymce/tinymce.js";
+import "tinymce/tinymce";
// eslint-disable-next-line import/no-webpack-loader-syntax
import "file-loader?name=static/js/icons/default/icons.js&esModule=false!tinymce/icons/default/icons.min.js";
// eslint-disable-next-line import/no-webpack-loader-syntax
@@ -258,7 +258,8 @@ function TinyMCE(props) {
editor.on("ScrollIntoView", onScrollIntoView);
editor.on("tap", onTap);
editor.on(changeEvents, onEditorChange);
- editor.on("remove", () => {
+ editor.once("remove", () => {
+ console.log("removing");
editor.off("ScrollIntoView", onScrollIntoView);
editor.off("tap", onTap);
editor.off(changeEvents, onEditorChange);
diff --git a/apps/web/src/components/scroll-container/index.js b/apps/web/src/components/scroll-container/index.js
index 765977693..73c5ffcca 100644
--- a/apps/web/src/components/scroll-container/index.js
+++ b/apps/web/src/components/scroll-container/index.js
@@ -1,5 +1,5 @@
import React from "react";
-import { Box, Text } from "rebass";
+import { Box } from "rebass";
import { Scrollbars } from "rc-scrollbars";
const ScrollContainer = ({ children, style, forwardedRef, ...props }) => {
@@ -28,6 +28,49 @@ const ScrollContainer = ({ children, style, forwardedRef, ...props }) => {
};
export default ScrollContainer;
+export function FlexScrollContainer({ children, style, ...props }) {
+ return (
+ <Scrollbars
+ {...props}
+ autoHide
+ style={{
+ overflowY: "hidden",
+ height: "auto",
+ width: "auto",
+ display: "flex",
+ flexDirection: "column",
+ flex: "1 1 auto",
+ }}
+ renderView={({ style, ...props }) => (
+ <Box
+ {...props}
+ style={{
+ overflow: "scroll",
+ position: "relative",
+ flex: "1 1 auto",
+ }}
+ sx={{
+ scrollbarWidth: "none",
+ "::-webkit-scrollbar": { width: 0, height: 0 },
+ msOverflowStyle: "none",
+ }}
+ />
+ )}
+ renderThumbVertical={({ style, ...props }) => (
+ <Box
+ {...props}
+ style={{
+ ...style,
+ backgroundColor: "var(--bgSecondaryText)",
+ }}
+ />
+ )}
+ >
+ {children}
+ </Scrollbars>
+ );
+}
+
export const CustomScrollbarsVirtualList = React.forwardRef((props, ref) => {
return (
<ScrollContainer {...props} forwardedRef={(sRef) => (ref.current = sRef)} />