Skip to content

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

fix: editor toolbar is not sticky

thecodrr6f26c58048b9
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 7f37c198e..120025fae 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -150,81 +150,73 @@ function Editor({ noteId, nonce }) {
</Flex>
) : null}
<Toolbar />
- <FlexScrollContainer>
+ <FlexScrollContainer className="editorScroll">
+ <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="editorScroll"
- flexDirection="column"
- overflow="hidden"
- overflowY="auto"
+ className="editor"
+ sx={{
+ alignSelf: [
+ "stretch",
+ isFocusMode ? "center" : "stretch",
+ "center",
+ ],
+ }}
+ maxWidth={isFocusMode ? "min(100%,850px)" : "935px"}
+ width="100%"
+ px={[2, 2, 35]}
+ mt={[2, 2, 25]}
>
- <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)" : "935px"}
- width="100%"
- px={[2, 2, 35]}
- 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></p>") 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>
+ <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></p>") 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>
</FlexScrollContainer>
{arePropertiesVisible && <Properties noteId={noteId} />}
diff --git a/apps/web/src/components/editor/toolbar.js b/apps/web/src/components/editor/toolbar.js
index a9ffec8b4..562c0b34b 100644
--- a/apps/web/src/components/editor/toolbar.js
+++ b/apps/web/src/components/editor/toolbar.js
@@ -35,6 +35,7 @@ function Toolbar(props) {
useEffect(() => {
const editorScroll = document.querySelector(".editorScroll");
+ if (!editorScroll) return;
function onScroll(e) {
const headerOffset = document.querySelector(".editorTitle").scrollHeight;
diff --git a/apps/web/src/components/scroll-container/index.js b/apps/web/src/components/scroll-container/index.js
index 73c5ffcca..b54a7a757 100644
--- a/apps/web/src/components/scroll-container/index.js
+++ b/apps/web/src/components/scroll-container/index.js
@@ -28,7 +28,7 @@ const ScrollContainer = ({ children, style, forwardedRef, ...props }) => {
};
export default ScrollContainer;
-export function FlexScrollContainer({ children, style, ...props }) {
+export function FlexScrollContainer({ children, className, ...props }) {
return (
<Scrollbars
{...props}
@@ -44,6 +44,7 @@ export function FlexScrollContainer({ children, style, ...props }) {
renderView={({ style, ...props }) => (
<Box
{...props}
+ className={className}
style={{
overflow: "scroll",
position: "relative",