Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting modal size when registering a custom picker component #3866

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -38,7 +38,7 @@

<script>
import NcReferencePicker from './NcReferencePicker.vue'
import { isCustomPickerElementRegistered } from './customPickerElements.js'
import { getCustomPickerElementSize, isCustomPickerElementRegistered } from './customPickerElements.js'
import NcButton from '../../NcButton/index.js'
import NcModal from '../../NcModal/index.js'
import { t } from '../../../l10n.js'
Expand Down Expand Up @@ -103,7 +103,7 @@ export default {
},
modalSize() {
return this.isProviderSelected && isCustomPickerElementRegistered(this.selectedProvider.id)
? 'large'
? (getCustomPickerElementSize(this.selectedProvider.id) ?? 'large')
: 'normal'
},
showModalTitle() {
Expand Down
Expand Up @@ -23,7 +23,15 @@ const isCustomPickerElementRegistered = (id) => {
return !!window._vue_richtext_custom_picker_elements[id]
}

const registerCustomPickerElement = (id, callback, onDestroy = (el) => {}) => {
const getCustomPickerElementSize = (id) => {
const size = window._vue_richtext_custom_picker_elements[id]?.size
if (['small', 'normal', 'large', 'full'].includes(size)) {
return size
}
return null
}

const registerCustomPickerElement = (id, callback, onDestroy = (el) => {}, size = 'large') => {
if (window._vue_richtext_custom_picker_elements[id]) {
console.error('Custom reference picker element for id ' + id + ' already registered')
return
Expand All @@ -33,6 +41,7 @@ const registerCustomPickerElement = (id, callback, onDestroy = (el) => {}) => {
id,
callback,
onDestroy,
size,
}
}

Expand Down Expand Up @@ -61,4 +70,5 @@ export {
renderCustomPickerElement,
destroyCustomPickerElement,
isCustomPickerElementRegistered,
getCustomPickerElementSize,
juliushaertl marked this conversation as resolved.
Show resolved Hide resolved
}