|
41 | 41 | :share-token="shareToken" |
42 | 42 | :mime="file.mimetype" |
43 | 43 | :autofocus="autofocus" |
| 44 | + :autohide="autohide" |
44 | 45 | active |
45 | | - autohide |
46 | 46 | rich-workspace |
47 | 47 | @ready="ready=true" |
48 | | - @focus="focus=true" |
49 | | - @blur="unfocus" |
| 48 | + @focus="onFocus" |
| 49 | + @blur="onBlur" |
50 | 50 | @error="reset" /> |
51 | 51 | </div> |
52 | 52 | </template> |
@@ -78,6 +78,7 @@ export default { |
78 | 78 | loaded: false, |
79 | 79 | ready: false, |
80 | 80 | autofocus: false, |
| 81 | + autohide: true, |
81 | 82 | darkTheme: OCA.Accessibility && OCA.Accessibility.theme === 'dark', |
82 | 83 | enabled: OCA.Text.RichWorkspaceEnabled, |
83 | 84 | } |
@@ -109,14 +110,23 @@ export default { |
109 | 110 | } |
110 | 111 | subscribe('Text::showRichWorkspace', this.showRichWorkspace) |
111 | 112 | subscribe('Text::hideRichWorkspace', this.hideRichWorkspace) |
| 113 | +
|
| 114 | + this.listenKeydownEvents() |
| 115 | +
|
112 | 116 | }, |
113 | 117 | beforeDestroy() { |
114 | 118 | unsubscribe('Text::showRichWorkspace', this.showRichWorkspace) |
115 | 119 | unsubscribe('Text::hideRichWorkspace', this.hideRichWorkspace) |
| 120 | +
|
| 121 | + this.unlistenKeydownEvents() |
116 | 122 | }, |
117 | 123 | methods: { |
118 | | - unfocus() { |
119 | | - // setTimeout(() => this.focus = false, 2000) |
| 124 | + onBlur() { |
| 125 | + this.listenKeydownEvents() |
| 126 | + }, |
| 127 | + onFocus() { |
| 128 | + this.focus = true |
| 129 | + this.unlistenKeydownEvents() |
120 | 130 | }, |
121 | 131 | reset() { |
122 | 132 | this.file = null |
@@ -185,6 +195,30 @@ export default { |
185 | 195 | hideRichWorkspace() { |
186 | 196 | this.enabled = false |
187 | 197 | }, |
| 198 | + listenKeydownEvents() { |
| 199 | + window.addEventListener('keydown', this.onKeydown) |
| 200 | + }, |
| 201 | + unlistenKeydownEvents() { |
| 202 | + clearInterval(this.$_timeoutAutohide) |
| 203 | +
|
| 204 | + window.removeEventListener('keydown', this.onKeydown) |
| 205 | + }, |
| 206 | + onTimeoutAutohide() { |
| 207 | + this.autohide = true |
| 208 | + }, |
| 209 | + onKeydown(e) { |
| 210 | + if (e.key !== 'Tab') { |
| 211 | + return |
| 212 | + } |
| 213 | +
|
| 214 | + // remove previous timeout |
| 215 | + clearInterval(this.$_timeoutAutohide) |
| 216 | +
|
| 217 | + this.autohide = false |
| 218 | +
|
| 219 | + // schedule to normal behaviour |
| 220 | + this.$_timeoutAutohide = setTimeout(this.onTimeoutAutohide, 7000) // 7s |
| 221 | + }, |
188 | 222 | }, |
189 | 223 | } |
190 | 224 | </script> |
|
0 commit comments