Skip to content

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

mobile: add scroll to top and bottom in editor

Ammar Ahmedd6e3f2761218
diff --git a/packages/editor-mobile/src/components/header.tsx b/packages/editor-mobile/src/components/header.tsx
index 152517586..221eca76f 100644
--- a/packages/editor-mobile/src/components/header.tsx
+++ b/packages/editor-mobile/src/components/header.tsx
@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { ControlledMenu, MenuItem as MenuItemInner } from "@szhsin/react-menu";
import ArrowBackIcon from "mdi-react/ArrowBackIcon";
+import ArrowTopIcon from "mdi-react/ArrowTopIcon";
+import ArrowDownIcon from "mdi-react/ArrowDownIcon";
import ArrowForwardIcon from "mdi-react/ArrowForwardIcon";
import ArrowULeftTopIcon from "mdi-react/ArrowULeftTopIcon";
import ArrowURightTopIcon from "mdi-react/ArrowURightTopIcon";
@@ -428,6 +430,30 @@ function Header({
tab.session?.noteId
);
break;
+ case "scroll-top":
+ {
+ const element = document.getElementById(
+ "editor-container-scroller"
+ );
+ element?.scrollTo({
+ top: 0,
+ left: 0,
+ behavior: "smooth"
+ });
+ }
+ break;
+ case "scroll-bottom":
+ {
+ const element = document.getElementById(
+ "editor-container-scroller"
+ );
+ element?.scrollTo({
+ top: element?.scrollHeight,
+ left: 0,
+ behavior: "smooth"
+ });
+ }
+ break;
case "properties":
post(
EditorEvents.properties,
@@ -590,6 +616,47 @@ function Header({
{strings.toc()}
</span>
</MenuItem>
+ <MenuItem
+ value="scroll-top"
+ style={{
+ display: "flex",
+ gap: 10,
+ alignItems: "center"
+ }}
+ >
+ <ArrowTopIcon
+ size={22 * settings.fontScale}
+ color="var(--nn_primary_icon)"
+ />
+ <span
+ style={{
+ color: "var(--nn_primary_paragraph)"
+ }}
+ >
+ {strings.scrollToTop()}
+ </span>
+ </MenuItem>
+
+ <MenuItem
+ value="scroll-bottom"
+ style={{
+ display: "flex",
+ gap: 10,
+ alignItems: "center"
+ }}
+ >
+ <ArrowDownIcon
+ size={22 * settings.fontScale}
+ color="var(--nn_primary_icon)"
+ />
+ <span
+ style={{
+ color: "var(--nn_primary_paragraph)"
+ }}
+ >
+ {strings.scrollToBottom()}
+ </span>
+ </MenuItem>
<MenuItem
value="properties"
style={{
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 13886bc7d..d0122476e 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -5301,6 +5301,14 @@ msgstr "Scan the QR code with your authenticator app"
msgid "School work"
msgstr "School work"
+#: src/strings.ts:2491
+msgid "Scroll to bottom"
+msgstr "Scroll to bottom"
+
+#: src/strings.ts:2490
+msgid "Scroll to top"
+msgstr "Scroll to top"
+
#: src/strings.ts:1509
#: src/strings.ts:1527
msgid "Search"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index e96a41c06..51e86dcff 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -5275,6 +5275,14 @@ msgstr ""
msgid "School work"
msgstr ""
+#: src/strings.ts:2491
+msgid "Scroll to bottom"
+msgstr ""
+
+#: src/strings.ts:2490
+msgid "Scroll to top"
+msgstr ""
+
#: src/strings.ts:1509
#: src/strings.ts:1527
msgid "Search"
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index e650d1503..70ce5cf77 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2486,5 +2486,7 @@ Use this if changes from other devices are not appearing on this device. This wi
unarchive: () => t`Unarchive`,
moveNotebookDesc: () =>
t`Select a notebook to move this notebook into, or unselect to move it to the root level.`,
- noNotebooksSelectedToMove: () => t`No notebooks selected to move`
+ noNotebooksSelectedToMove: () => t`No notebooks selected to move`,
+ scrollToTop: () => t`Scroll to top`,
+ scrollToBottom: () => t`Scroll to bottom`
};