Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ShGKme committed Dec 1, 2023
1 parent 5cc6c04 commit 23fdbae
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/components/NcRichContenteditable/NcRichContenteditable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ export default {
aria-multiline="true"
class="rich-contenteditable__input"
role="textbox"
:aria-controls="isTributeOpen ? 'tribute-id' : undefined"
:aria-activedescendant="isTributeOpen && activedescendant ? activedescendant : undefined"
v-on="listeners"
@input="onInput"
@compositionstart="isComposing = true"
Expand All @@ -233,7 +235,9 @@ export default {
@keydown.enter.exact="onEnter"
@keydown.ctrl.enter.exact.stop.prevent="onCtrlEnter"
@paste="onPaste"
@keyup.stop.prevent.capture="onKeyUp" />
@keyup.stop.prevent.capture="onKeyUp"
@tribute-active-true="isTributeOpen = true"
@tribute-active-false="isTributeOpen = false" />
</template>

<script>
Expand Down Expand Up @@ -341,6 +345,7 @@ export default {
data() {
return {
isTributeOpen: false,
textSmiles: [],
tribute: null,
autocompleteOptions: {
Expand Down Expand Up @@ -375,7 +380,7 @@ export default {
return item.original
}
return `<span class="tribute-container-emoji__item__emoji">${item.original.native}</span> :${item.original.short_name}`
return `<span id="${Math.random().toString(32).substring(3, 10)}"><span class="tribute-container-emoji__item__emoji">${item.original.native}</span> :${item.original.short_name}</span>`
},
// Hide if no results
noMatchTemplate: () => t('No emoji found'),
Expand Down Expand Up @@ -435,6 +440,8 @@ export default {
// Is in text composition session in IME
isComposing: false,
activedescendant: null,
}
},
Expand Down Expand Up @@ -514,6 +521,22 @@ export default {
},
watch: {
isTributeOpen(isOpen) {
const wrapper = this.menuContainer.querySelector('.tribute-container-emoji')
if (isOpen && wrapper) {
wrapper.id = 'tribute-id'
// window.addEventListener('keydown', (event) => {
// console.log('keypress', wrapper, wrapper.querySelector('.highlight [id]'))

Check failure on line 529 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {

Check failure on line 530 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// this.activedescendant = wrapper.querySelector('.highlight [id]').id

Check failure on line 531 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// }

Check failure on line 532 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// })
// wrapper.addEventListener('mousemove', (event) => {
// console.log('mousemove', wrapper, wrapper.querySelector('.highlight [id]'))

Check failure on line 535 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// this.activedescendant = wrapper.querySelector('.highlight [id]').id

Check failure on line 536 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// })
}
},
/**
* If the parent value change, we compare the plain text rendering
* If it's different, we render everything and update the main content
Expand Down Expand Up @@ -796,6 +819,26 @@ export default {
onKeyUp(event) {
// prevent tribute from opening on keyup
event.stopImmediatePropagation()
if (this.isTributeOpen) {
const wrapper = this.menuContainer.querySelector('.tribute-container-emoji')
this.activedescendant = wrapper.querySelector('.highlight [id]').id
}
// console.log(wrapper)
// if (isOpen) {
// wrapper.id = 'tribute-id'

Check failure on line 830 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// window.addEventListener('keydown', (event) => {

Check failure on line 831 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// console.log('keypress', wrapper, wrapper.querySelector('.highlight [id]'))

Check failure on line 832 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {

Check failure on line 833 in src/components/NcRichContenteditable/NcRichContenteditable.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected tab character
// this.activedescendant = wrapper.querySelector('.highlight [id]').id
// }
// })
// wrapper.addEventListener('mousemove', (event) => {
// console.log('mousemove', wrapper, wrapper.querySelector('.highlight [id]'))
// this.activedescendant = wrapper.querySelector('.highlight [id]').id
// })
// }
},
},
}
Expand Down

0 comments on commit 23fdbae

Please sign in to comment.