Fix text layer getting deselected after clicking out of Text tool interactive editing (#2144)

* properties panel remains active when user edits text layer

* Keep text layers selected after editing

* Update editor/src/messages/portfolio/document/document_message_handler.rs

* Delete Empty Text Layer on Escape or Right Click

* Fix: delete empty text layer on right click

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Sidharth-Singh10 2025-01-01 03:58:56 +05:30 committed by GitHub
parent 39a7b76ade
commit f225756655
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 48 additions and 16 deletions

View file

@ -300,7 +300,7 @@
export function triggerTextCommit() {
if (!textInput) return;
const textCleaned = textInputCleanup(textInput.innerText);
editor.handle.onChangeText(textCleaned);
editor.handle.onChangeText(textCleaned, false);
}
export async function displayEditableTextbox(displayEditableTextbox: DisplayEditableTextbox) {

View file

@ -172,7 +172,8 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
}
if (!inTextInput && !inContextMenu) {
if (textToolInteractiveInputElement) editor.handle.onChangeText(textInputCleanup(textToolInteractiveInputElement.innerText));
const isRightClick = e.button === 2;
if (textToolInteractiveInputElement) editor.handle.onChangeText(textInputCleanup(textToolInteractiveInputElement.innerText), isRightClick);
else viewportPointerInteractionOngoing = isTargetingCanvas instanceof Element;
}

View file

@ -433,8 +433,8 @@ impl EditorHandle {
/// A text box was committed
#[wasm_bindgen(js_name = onChangeText)]
pub fn on_change_text(&self, new_text: String) -> Result<(), JsValue> {
let message = TextToolMessage::TextChange { new_text };
pub fn on_change_text(&self, new_text: String, is_right_click: bool) -> Result<(), JsValue> {
let message = TextToolMessage::TextChange { new_text, is_right_click };
self.dispatch(message);
Ok(())