From d8e366db9f4cf843b7d5851a1ad8ae96ae20c7af Mon Sep 17 00:00:00 2001 From: Luka Trovic Date: Fri, 9 Jun 2023 17:55:39 +0200 Subject: [PATCH] feat: update layout of translate dialog Signed-off-by: Luka Trovic --- src/components/Menu/MenuBar.vue | 8 +- src/components/Modal/Translate.vue | 118 ++++++++++++++++++++++++----- 2 files changed, 106 insertions(+), 20 deletions(-) diff --git a/src/components/Menu/MenuBar.vue b/src/components/Menu/MenuBar.vue index c2052735839..a510a935747 100644 --- a/src/components/Menu/MenuBar.vue +++ b/src/components/Menu/MenuBar.vue @@ -247,7 +247,13 @@ export default { }, showTranslate() { const { from, to } = this.$editor.view.state.selection - const selectedText = this.$editor.view.state.doc.textBetween(from, to, ' ') + let selectedText = this.$editor.view.state.doc.textBetween(from, to, ' ') + + if (!selectedText.trim().length) { + this.$editor.commands.selectAll() + selectedText = this.$editor.view.state.doc.textContent + } + console.debug('translation click', this.$editor.view.state.selection, selectedText) this.displayTranslate = selectedText ?? '' }, diff --git a/src/components/Modal/Translate.vue b/src/components/Modal/Translate.vue index 47c11c9be08..3603c9b6857 100644 --- a/src/components/Modal/Translate.vue +++ b/src/components/Modal/Translate.vue @@ -20,26 +20,43 @@ -->