diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index 136786531..0f0349654 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -195,9 +195,8 @@ const Tiptap = ({ settings }: { settings: Settings }) => {
ref={containerRef}
style={{
overflowY: "scroll",
- flexDirection: "column",
height: "100%",
- display: "flex"
+ display: "block"
}}
>
{settings.noHeader ? null : (
diff --git a/packages/editor-mobile/src/components/styles.module.css b/packages/editor-mobile/src/components/styles.module.css
index 9a39d79ee..0e065c16d 100644
--- a/packages/editor-mobile/src/components/styles.module.css
+++ b/packages/editor-mobile/src/components/styles.module.css
@@ -19,6 +19,10 @@
.titleBar::placeholder {
color: var(--nn_primary_placeholder);
}
+.titleBar {
+ resize: none;
+ outline: none;
+}
.container {
-ms-overflow-style: none;
diff --git a/packages/editor-mobile/src/components/title.tsx b/packages/editor-mobile/src/components/title.tsx
index cb4c789af..a3cf52c38 100644
--- a/packages/editor-mobile/src/components/title.tsx
+++ b/packages/editor-mobile/src/components/title.tsx
@@ -18,7 +18,7 @@ along with this program. If not, see .
*/
import { getFontById } from "@notesnook/editor";
-import React, { RefObject, useEffect, useRef } from "react";
+import React, { RefObject, useCallback, useEffect, useRef } from "react";
import { EditorController } from "../hooks/useEditorController";
import styles from "./styles.module.css";
function Title({
@@ -34,46 +34,98 @@ function Title({
readonly: boolean;
fontFamily: string;
}) {
- const titleRef = useRef(null);
+ const titleRef = useRef(null);
+ const titleSizeDiv = useRef(null);
const emitUpdate = useRef(true);
global.editorTitle = titleRef;
+ const resizeTextarea = useCallback(() => {
+ if (!titleSizeDiv.current || !titleRef.current) return;
+ titleSizeDiv.current.innerText = titleRef.current.value;
+ titleRef.current.style.height = `${titleSizeDiv.current.clientHeight}px`;
+ titleSizeDiv.current.style.width = `${titleRef.current.clientWidth}px`;
+ }, []);
+
useEffect(() => {
if (titleRef.current) {
emitUpdate.current = false;
titleRef.current.value = title;
+ resizeTextarea();
emitUpdate.current = true;
}
- }, [title]);
+
+ window.addEventListener("resize", resizeTextarea);
+ return () => {
+ window.removeEventListener("resize", resizeTextarea);
+ };
+ }, [resizeTextarea, title]);
return (
- {
- if (!emitUpdate.current) return;
- controller.current?.titleChange(event.target.value);
- }}
- placeholder={titlePlaceholder}
- />
+ <>
+
+