Skip to content

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

feat: double tap on end container to insert a new paragraph at end

thecodrrde17a06a9c0d
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index 961d79027..64e13fc7e 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -4,15 +4,9 @@ import {
PortalProvider,
Toolbar,
usePermissionHandler,
- useTiptap
+ useTiptap,
} from "notesnook-editor";
-import {
- useEffect,
- useLayoutEffect,
- useReducer,
- useRef,
- useState
-} from "react";
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { useEditorController } from "../hooks/useEditorController";
import { useSettings } from "../hooks/useSettings";
import { useEditorThemeStore } from "../state/theme";
@@ -33,7 +27,7 @@ const Tiptap = () => {
global.noToolbar ||
settings.noToolbar ||
global.readonly ||
- settings.readonly
+ settings.readonly,
});
const contentRef = useRef<HTMLDivElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
@@ -42,14 +36,14 @@ const Tiptap = () => {
//todo
accent: "green",
scale: 1,
- theme: theme?.night ? "dark" : "light"
+ theme: theme?.night ? "dark" : "light",
});
const editorTheme = useTheme({
//todo
accent: "green",
scale: 1,
- theme: theme?.night ? "dark" : "light"
+ theme: theme?.night ? "dark" : "light",
});
editorTheme.space = [0, 10, 12, 20];
@@ -61,37 +55,37 @@ const Tiptap = () => {
...toolbarTheme.buttons.menuitem,
height: "50px",
paddingX: "20px",
- borderBottomWidth: 0
+ borderBottomWidth: 0,
};
toolbarTheme.iconSizes = {
big: 20,
medium: 18,
- small: 18
+ small: 18,
};
toolbarTheme.fontSizes = {
...toolbarTheme.fontSizes,
subBody: "0.8rem",
- body: "0.9rem"
+ body: "0.9rem",
};
toolbarTheme.radii = {
...toolbarTheme.radii,
- small: 5
+ small: 5,
};
toolbarTheme.buttons.menuitem = {
...toolbarTheme.buttons.menuitem,
px: 5,
- height: "45px"
+ height: "45px",
};
usePermissionHandler({
claims: {
- premium: settings.premium
+ premium: settings.premium,
},
onPermissionDenied: () => {
post(EventTypes.pro);
- }
+ },
});
const editor = useTiptap(
{
@@ -113,10 +107,10 @@ const Tiptap = () => {
element: !layout ? undefined : contentRef.current || undefined,
editable: !initialProps.readonly,
editorProps: {
- editable: () => !initialProps.readonly
+ editable: () => !initialProps.readonly,
},
content: global.editorController?.content?.current,
- isMobile: true
+ isMobile: true,
},
[layout, initialProps.readonly, tick]
);
@@ -141,7 +135,7 @@ const Tiptap = () => {
flex: 1,
flexDirection: "column",
maxWidth: "100vw",
- marginBottom: "5px"
+ marginBottom: "5px",
}}
>
<Header
@@ -159,7 +153,7 @@ const Tiptap = () => {
height: "100%",
flexGrow: 1,
flexShrink: 1,
- display: "flex"
+ display: "flex",
}}
>
{initialProps.noHeader ? null : (
@@ -179,8 +173,22 @@ const Tiptap = () => {
padding: 12,
paddingTop: 0,
color: theme?.pri,
- flex: 1
+ flex: 1,
+ }}
+ />
+ <div
+ onDoubleClick={() => {
+ const lastPosition = globalThis.editor?.state.doc.content.size;
+ if (!lastPosition) return;
+ globalThis.editor
+ ?.chain()
+ .focus()
+ .insertContentAt(lastPosition - 1, "<p></p>", {
+ updateSelection: true,
+ })
+ .run();
}}
+ style={{ flexShrink: 0, height: 150, width: "100%" }}
/>
</div>