Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor(editor): cleanup autohide mechanism
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Jan 2, 2024
commit 9b53bc6f6fa3bbfc8221da4a15ac871a15069ef3
20 changes: 0 additions & 20 deletions src/components/Menu/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
:aria-label="t('text', 'Editor actions')"
:class="{
'text-menubar--ready': isReady,
'text-menubar--show': isVisible,
'text-menubar--hide': isHidden,
'text-menubar--is-workspace': $isRichWorkspace
}">
Expand Down Expand Up @@ -84,7 +83,6 @@
<script>
import { NcActionSeparator, NcActionButton } from '@nextcloud/vue'
import { loadState } from '@nextcloud/initial-state'
import debounce from 'debounce'
import { useResizeObserver } from '@vueuse/core'

import ActionFormattingHelp from './ActionFormattingHelp.vue'
Expand Down Expand Up @@ -148,7 +146,6 @@ export default {
displayHelp: false,
displayTranslate: false,
isReady: false,
isVisible: this.$editor.isFocused,
canTranslate: loadState('text', 'translation_languages', []).length > 0,
resize: null,
iconsLimit: 4,
Expand Down Expand Up @@ -178,26 +175,13 @@ export default {
mounted() {
this.resize = useResizeObserver(this.$refs.menubar, this.onResize)

this.$onFocusChange = () => {
this.isVisible = this.$editor.isFocused
}
this.$onBlurChange = debounce(() => {
this.isVisible = this.$editor.isFocused
}, 3000) // 3s

this.$editor.on('focus', this.$onFocusChange)
this.$editor.on('blur', this.$onBlurChange)

this.$nextTick(() => {
this.isReady = true
this.$emit('update:loaded', true)
})
},
beforeDestroy() {
this.resize?.stop()

this.$editor.off('focus', this.$onFocusChange)
this.$editor.off('blur', this.$onBlurChange)
},
methods: {
onResize(entries) {
Expand Down Expand Up @@ -283,10 +267,6 @@ export default {
&.text-menubar--hide {
opacity: 0;
transition: visibility 0.2s 0.4s, opacity 0.2s 0.4s;
&.text-menubar--show {
visibility: visible;
opacity: 1;
}
}
.text-menubar__entries {
display: flex;
Expand Down