Skip to content

Commit

Permalink
fix: adjust event handlers in referencePickerModal.js
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <[email protected]>
  • Loading branch information
raimund-schluessler committed Dec 20, 2023
1 parent fd871aa commit f65ab1c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/components/NcRichText/NcReferencePicker/referencePickerModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createApp } from 'vue'
* @return {Promise<unknown>}
*/
export async function getLinkWithPicker(providerId = null, isInsideViewer = undefined) {
console.debug('test')
return await new Promise((resolve, reject) => {
const modalId = 'referencePickerModal'
const modalElement = document.createElement('div')
Expand All @@ -24,16 +25,19 @@ export async function getLinkWithPicker(providerId = null, isInsideViewer = unde
const view = createApp(NcReferencePickerModal, {
initialProvider,
isInsideViewer,
}).mount(modalElement)

// TODO adjust this for vue3
view.$on('cancel', () => {
view.$destroy()
reject(new Error('User cancellation'))
})
view.$on('submit', (link) => {
view.$destroy()
resolve(link)
onCancel() {
destroyView()
reject(new Error('User cancellation'))
},
onSubmit(link) {
destroyView()
resolve(link)
},
})
view.mount(modalElement)

const destroyView = () => {
view.unmount()
}
})
}

0 comments on commit f65ab1c

Please sign in to comment.