From 2ec0fd44960ed8e9e759f644fd31da212c836863 Mon Sep 17 00:00:00 2001 From: Fovway Date: Mon, 3 Nov 2025 22:25:09 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=20NoteItem=20=D0=B4=D0=BB=D1=8F=20=D1=83=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D1=88=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D1=81=D0=BA=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BE=D0=BF=D1=8B=D1=82=D0=B0=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE=D0=BA.=20?= =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D1=84=D0=BB?= =?UTF-8?q?=D0=B0=D0=B3=20=D0=B4=D0=BB=D1=8F=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=BA=D1=83=D1=80=D1=81=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D0=B5=D1=86=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=B2?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B5=20=D0=B2=20=D1=80=D0=B5=D0=B6=D0=B8?= =?UTF-8?q?=D0=BC=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F.=20=D0=A3=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D1=8B=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20=D0=B2=20useEffect=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B2=D1=8B=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B8=D0=B7=D0=B2=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev-dist/sw.js | 2 +- src/components/notes/NoteItem.tsx | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dev-dist/sw.js b/dev-dist/sw.js index 9adc105..fbcb384 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -85,7 +85,7 @@ define(['./workbox-8cfb3eb5'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.8irmmrfvp3g" + "revision": "0.cbp336fi3v8" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/src/components/notes/NoteItem.tsx b/src/components/notes/NoteItem.tsx index 01fedb5..6d04046 100644 --- a/src/components/notes/NoteItem.tsx +++ b/src/components/notes/NoteItem.tsx @@ -59,6 +59,7 @@ export const NoteItem: React.FC = ({ const imageInputRef = useRef(null); const fileInputRef = useRef(null); const textNoteRef = useRef(null); + const shouldSetCursorToEndRef = useRef(false); const searchQuery = useAppSelector((state) => state.notes.searchQuery); const isPreviewMode = useAppSelector((state) => state.ui.isPreviewMode); const aiEnabled = useAppSelector((state) => state.profile.aiEnabled); @@ -77,6 +78,7 @@ export const NoteItem: React.FC = ({ setShowFloatingToolbar(false); setActiveFormats({ bold: false, italic: false, strikethrough: false }); setLocalPreviewMode(false); + shouldSetCursorToEndRef.current = true; // Устанавливаем флаг для установки курсора в конец }; const toggleLocalPreviewMode = () => { @@ -760,15 +762,20 @@ export const NoteItem: React.FC = ({ useEffect(() => { if (isEditing && editTextareaRef.current && !localPreviewMode) { setTimeout(() => { - editTextareaRef.current?.focus(); - // Устанавливаем курсор в конец текста const textarea = editTextareaRef.current; if (textarea) { - textarea.setSelectionRange(editContent.length, editContent.length); + textarea.focus(); + // Устанавливаем курсор в конец текста только при первом входе в режим редактирования + if (shouldSetCursorToEndRef.current) { + // Используем актуальное значение из textarea, а не из состояния + const contentLength = textarea.value.length; + textarea.setSelectionRange(contentLength, contentLength); + shouldSetCursorToEndRef.current = false; // Сбрасываем флаг после установки + } } }, 100); } - }, [isEditing, localPreviewMode, editContent]); + }, [isEditing, localPreviewMode]); // Убрали все зависимости от editContent // Отслеживание выделения текста useEffect(() => {