From a7bbf77fd6f82db0b7a04724cfab4ba81008272a 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 | 103 ++++++++++++++++++++++++----- 2 files changed, 93 insertions(+), 18 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..197805148bc 100644 --- a/src/components/Modal/Translate.vue +++ b/src/components/Modal/Translate.vue @@ -20,26 +20,43 @@ -->