Skip to content

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

fix: scroll jumps in editor

thecodrr89cdaff48805
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index e595ea9e0..dc4b5c971 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -88,9 +88,9 @@ function Editor(props) {
onScroll={(e) => {
const title = document.querySelector(".editorTitle");
const headerOffset = title.scrollHeight;
- const hideOffset = headerOffset + 60;
+ const hideOffset = headerOffset + 60 + 40;
const { editor } = editorRef.current;
- if (e.target.scrollTop > hideOffset && !editor.isToolbarSticky) {
+ if (e.target.scrollTop >= hideOffset && !editor.isToolbarSticky) {
editor.pauseScrollIntoView = true;
const toolbar = document.querySelector(".tox-editor-header");
toolbar.style.position = "fixed";
@@ -99,7 +99,7 @@ function Editor(props) {
toolbar.style.width = `${title.clientWidth}px`;
editor.isToolbarSticky = true;
} else if (
- e.target.scrollTop <= hideOffset &&
+ e.target.scrollTop < hideOffset - 20 &&
editor.isToolbarSticky
) {
editor.pauseScrollIntoView = true;
@@ -135,7 +135,6 @@ function Editor(props) {
onFocus={() => toggleProperties(false)}
onSave={saveSession}
onChange={(content) => {
- console.log("CHANGING CONTENT", content);
if (!content.length) content = "<p><br></pr>";
setSession((state) => {
state.session.content = {
diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.js
index 25d90c59f..bdaee42fb 100644
--- a/apps/web/src/components/editor/tinymce.js
+++ b/apps/web/src/components/editor/tinymce.js
@@ -177,13 +177,19 @@ function TinyMCE(props) {
},
setup: (editor) => {
editor.on("ScrollIntoView", (e) => {
+ e.preventDefault();
if (editor.pauseScrollIntoView) {
- e.preventDefault();
editor.pauseScrollIntoView = false;
+ } else {
+ e.elm.scrollIntoView({
+ behavior: "smooth",
+ block: "nearest",
+ });
}
});
},
browser_spellcheck: true,
+ autoresize_bottom_margin: 100,
}}
// onBeforeExecCommand={async (command) => {
// if (