diff --git a/src/qml/Component/Timeline/MessageDelegate.qml b/src/qml/Component/Timeline/MessageDelegate.qml index 44db5ec30..0542b6335 100644 --- a/src/qml/Component/Timeline/MessageDelegate.qml +++ b/src/qml/Component/Timeline/MessageDelegate.qml @@ -28,6 +28,14 @@ TimelineContainer { Layout.fillWidth: true messageId: model.eventId visible: currentRoom.chatBoxEditId === model.eventId + onVisibleChanged: { + if (visible) { + editChatDocumentHandler.document = textDocument + editChatDocumentHandler.cursorPosition = cursorPosition + editChatDocumentHandler.selectionStart = selectionStart + editChatDocumentHandler.selectionEnd = selectionEnd + } + } } LinkPreviewDelegate { Layout.fillWidth: true diff --git a/src/qml/Component/Timeline/MessageEditComponent.qml b/src/qml/Component/Timeline/MessageEditComponent.qml index d583b6701..f69c30c18 100644 --- a/src/qml/Component/Timeline/MessageEditComponent.qml +++ b/src/qml/Component/Timeline/MessageEditComponent.qml @@ -124,16 +124,6 @@ QQC2.TextArea { } } - ChatDocumentHandler { - id: documentHandler - isEdit: true - document: root.textDocument - cursorPosition: root.cursorPosition - selectionStart: root.selectionStart - selectionEnd: root.selectionEnd - room: currentRoom // We don't care about saving for edits so this is OK. - } - TextMetrics { id: editTextMetrics text: root.text diff --git a/src/qml/Page/RoomPage.qml b/src/qml/Page/RoomPage.qml index 9060ee55a..9274d0b06 100644 --- a/src/qml/Page/RoomPage.qml +++ b/src/qml/Page/RoomPage.qml @@ -26,6 +26,11 @@ Kirigami.ScrollablePage { /// cancel implementation. property bool disableCancelShortcut: false + property var editChatDocumentHandler: ChatDocumentHandler { + isEdit: true + room: currentRoom // We don't care about saving for edits so this is OK. + } + title: currentRoom.displayName KeyNavigation.left: pageStack.get(0)