Skip to content

Commit

Permalink
feat: update layout of translate dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Jun 13, 2023
1 parent 3a0f8f6 commit 08863e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/components/Menu/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,15 @@ 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.trim().length ? selectedText : this.$editor.view.state.doc.textContent
this.displayTranslate = selectedText ?? ''
},
hideTranslate() {
this.displayTranslate = false
Expand Down
7 changes: 6 additions & 1 deletion src/components/Modal/Translate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
input-id="fromLanguage"
:placeholder="t('text', 'Select language')"
:options="fromLanguages"
:disabled="disableFromLanguage"
:append-to-body="false" />
</div>
<textarea v-model="input" />
<textarea ref="input"
v-model="input"
autofocus="true"
@focus="disableFromLanguage = false" />
</div>
<div class="col">
<div class="language-selector">
Expand Down Expand Up @@ -103,6 +107,7 @@ export default {
canDetect: loadState('text', 'translation_can_detect'),
loading: false,
error: null,
disableFromLanguage: true,
}
},
computed: {
Expand Down

0 comments on commit 08863e6

Please sign in to comment.