mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
web: use default note title from settings
This commit is contained in:
committed by
Abdullah Atta
parent
7f5d5fcb82
commit
58ba453f57
@@ -43,22 +43,29 @@ function TitleBox(props: TitleBoxProps) {
|
||||
return isMobile || isTablet ? 1.625 : 2.625;
|
||||
}, [isMobile, isTablet]);
|
||||
|
||||
const updateFontSize = useCallback(() => {
|
||||
if (!inputRef.current) return;
|
||||
const fontSize = textLengthToFontSize(
|
||||
inputRef.current.value.length,
|
||||
MAX_FONT_SIZE
|
||||
);
|
||||
inputRef.current.style.fontSize = `${fontSize}em`;
|
||||
}, [MAX_FONT_SIZE]);
|
||||
const updateFontSize = useCallback(
|
||||
(length) => {
|
||||
if (!inputRef.current) return;
|
||||
const fontSize = textLengthToFontSize(length, MAX_FONT_SIZE);
|
||||
inputRef.current.style.fontSize = `${fontSize}em`;
|
||||
},
|
||||
[MAX_FONT_SIZE]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
inputRef.current.placeholder = "Note title";
|
||||
inputRef.current.value = title;
|
||||
updateFontSize();
|
||||
updateFontSize(title.length);
|
||||
}
|
||||
}, [id, updateFontSize]);
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current && inputRef.current.value !== title) {
|
||||
inputRef.current.placeholder = title || "Note title";
|
||||
}
|
||||
}, [title]);
|
||||
|
||||
return (
|
||||
<Input
|
||||
ref={inputRef}
|
||||
@@ -77,7 +84,7 @@ function TitleBox(props: TitleBoxProps) {
|
||||
onChange={(e) => {
|
||||
const { sessionId, id } = store.get().session;
|
||||
debouncedOnTitleChange(sessionId, id, e.target.value);
|
||||
updateFontSize();
|
||||
updateFontSize(e.target.value.length);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -88,7 +95,6 @@ export default React.memo(TitleBox, (prevProps, nextProps) => {
|
||||
});
|
||||
|
||||
function onTitleChange(noteId: string, title: string) {
|
||||
if (!title) return;
|
||||
store.get().setTitle(noteId, title);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user