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

fix: pass previewUrlCallback function to the global scope #270

Merged
merged 2 commits into from
Jul 23, 2021
Merged
Changes from all commits
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
7 changes: 6 additions & 1 deletion src/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const useWidget = (
locale,
localeTranslations,
localePluralize,
previewUrlCallback,
...options
},
uploadcare
Expand All @@ -67,6 +68,9 @@ const useWidget = (
if (localeTranslations) {
window.UPLOADCARE_LOCALE_TRANSLATIONS = localeTranslations
}
if (previewUrlCallback) {
window.UPLOADCARE_PREVIEW_URL_CALLBACK = previewUrlCallback
}

uploadcare.plugin((internal) => {
internal.locale.rebuild({
Expand All @@ -80,8 +84,9 @@ const useWidget = (
if (locale) delete window.UPLOADCARE_LOCALE
if (localePluralize) delete window.UPLOADCARE_LOCALE_PLURALIZE
if (localeTranslations) delete window.UPLOADCARE_LOCALE_TRANSLATIONS
if (previewUrlCallback) delete window.UPLOADCARE_PREVIEW_URL_CALLBACK
}
}, [locale, localeTranslations, localePluralize])
}, [locale, localeTranslations, localePluralize, previewUrlCallback])

useEffect(() => {
widget.current = uploadcare.Widget(input.current)
Expand Down