From 8e25311ddd9955ae3abc5ec1045213a2c5a57f68 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 | 100 ++++++++++++++++++++++++----- 2 files changed, 90 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..a2018dc3eca 100644 --- a/src/components/Modal/Translate.vue +++ b/src/components/Modal/Translate.vue @@ -20,26 +20,44 @@ -->