A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: focus editor with tap & create nodes
ammarahm-edb549f39e1a29
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsxindex e5bd71c15..317b71c95 100644--- a/packages/editor-mobile/src/components/editor.tsx+++ b/packages/editor-mobile/src/components/editor.tsx@@ -106,6 +106,58 @@ const Tiptap = ({useLayoutEffect(() => {setLayout(true);}, []);++ const onClickEmptyArea: React.MouseEventHandler<HTMLDivElement> = useCallback(+ (event) => {+ const y = event.nativeEvent.pageY;+ const x = event.nativeEvent.pageX;+ const element = document.elementFromPoint(x, y);+ if (!element) return;+ if (element.id === "statusbar" || element.id === "header") {+ const firstChild = globalThis.editor?.state.doc.firstChild;+ const isParagraph = firstChild?.type.name === "paragraph";+ const isFirstChildEmpty =+ !firstChild?.textContent || firstChild?.textContent?.length === 0;+ if (isParagraph && isFirstChildEmpty) {+ globalThis.editor?.commands.focus();+ return;+ }+ globalThis.editor+ ?.chain()+ .insertContentAt(0, "<p></p>", {+ updateSelection: true+ })+ .run();+ setTimeout(() => {+ globalThis.editor?.commands.focus();+ }, 1);+ }+ },+ []+ );++ const onClickBottomArea = useCallback(() => {+ const docSize = globalThis.editor?.state.doc.content.size;+ if (!docSize) return;+ const lastChild = globalThis.editor?.state.doc.lastChild;+ const isParagraph = lastChild?.type.name === "paragraph";+ const isLastChildEmpty =+ !lastChild?.textContent || lastChild?.textContent?.length === 0;+ if (isParagraph && isLastChildEmpty) {+ globalThis.editor?.commands.focus();+ return;+ }+ globalThis.editor+ ?.chain()+ .insertContentAt(docSize - 1, "<p></p>", {+ updateSelection: true+ })+ .run();+ setTimeout(() => {+ globalThis.editor?.commands.focus();+ }, 1);+ }, []);+return (<><div@@ -116,6 +168,8 @@ const Tiptap = ({maxWidth: "100vw",marginBottom: "5px"}}+ id="editorroot"+ onDoubleClick={onClickEmptyArea}><HeaderhasRedo={_editor?.can().redo() || false}@@ -130,8 +184,6 @@ const Tiptap = ({overflowY: "scroll",flexDirection: "column",height: "100%",- flexGrow: 1,- flexShrink: 1,display: "flex"}}>@@ -154,23 +206,11 @@ const Tiptap = ({/><div- onDoubleClick={() => {- const lastPosition = globalThis.editor?.state.doc.content.size;- if (!lastPosition) return;- globalThis.editor- ?.chain()- .insertContentAt(lastPosition - 1, "<p></p>", {- updateSelection: true- })- .run();- setTimeout(() => {- globalThis.editor?.commands.focus();- }, 1);- }}+ onClick={onClickBottomArea}style={{- flexShrink: 0,- height: 150,- width: "100%"+ flexGrow: 1,+ width: "100%",+ minHeight: 250}}/></div>@@ -198,7 +238,6 @@ const ContentDiv = memo(style={{padding: 12,paddingTop: props.padding,- flex: 1,color: theme.pri,marginTop: -12,caretColor: theme.accentdiff --git a/packages/editor-mobile/src/components/header.tsx b/packages/editor-mobile/src/components/header.tsxindex 7ace6a757..b53a3f8a6 100644--- a/packages/editor-mobile/src/components/header.tsx+++ b/packages/editor-mobile/src/components/header.tsx@@ -77,6 +77,7 @@ export default function Header({position: "sticky",width: "100vw"}}+>{noHeader ? null : (<div@@ -89,6 +90,7 @@ export default function Header({height: 50,alignItems: "center"}}+ id='header'>{settings.deviceMode !== "mobile" && !settings.fullscreen ? (<div />diff --git a/packages/editor-mobile/src/components/statusbar.tsx b/packages/editor-mobile/src/components/statusbar.tsxindex 9e6bdc505..91c2b8f7b 100644--- a/packages/editor-mobile/src/components/statusbar.tsx+++ b/packages/editor-mobile/src/components/statusbar.tsx@@ -83,13 +83,15 @@ function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {};}, [onScroll, container]);- const paragraphStyle = {+ const paragraphStyle:React.CSSProperties = {marginTop: 0,marginBottom: 0,fontSize: "12px",color: "var(--nn_icon)",marginRight: 8,- paddingBottom: 0+ paddingBottom: 0,+ userSelect:"none",+ pointerEvents:"none"};return (@@ -107,6 +109,7 @@ function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {paddingTop: 2,paddingBottom: 2}}+ id="statusbar"><p style={paragraphStyle}>{words}</p><p style={paragraphStyle}>{status.date}</p>