Auto-resize iframes, fix custom code, fix create form initial properties
This commit is contained in:
@@ -111,13 +111,6 @@ const loadForm = async (setup=false) => {
|
||||
// Adapt page to form: colors, custom code etc
|
||||
handleDarkMode(form.value.dark_mode)
|
||||
handleTransparentMode(form.value.transparent_background)
|
||||
|
||||
if (process.server) return
|
||||
if (form.value.custom_code) {
|
||||
const scriptEl = document.createRange().createContextualFragment(form.value.custom_code)
|
||||
document.head.append(scriptEl)
|
||||
}
|
||||
if (!isIframe) focusOnFirstFormElement()
|
||||
}
|
||||
|
||||
await loadForm(true)
|
||||
@@ -127,6 +120,14 @@ onMounted(() => {
|
||||
if (form.value) {
|
||||
handleDarkMode(form.value?.dark_mode)
|
||||
handleTransparentMode(form.value?.transparent_background)
|
||||
|
||||
if (process.client) {
|
||||
if (form.value.custom_code) {
|
||||
const scriptEl = document.createRange().createContextualFragment(form.value.custom_code)
|
||||
document.head.append(scriptEl)
|
||||
}
|
||||
if (!isIframe) focusOnFirstFormElement()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -165,6 +166,9 @@ useHead({
|
||||
return titleChunk
|
||||
}
|
||||
return titleChunk ? `${titleChunk} - OpnForm` : 'OpnForm';
|
||||
}
|
||||
},
|
||||
... form.value.custom_code ? {
|
||||
script: [ { src: '/widgets/iframeResizer.contentWindow.min.js' } ]
|
||||
} : {}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -75,7 +75,7 @@ onMounted(() => {
|
||||
is_pro: false
|
||||
}])
|
||||
|
||||
form.value = initForm()
|
||||
form.value = initForm({}, true)
|
||||
if (route.query.template !== undefined && route.query.template) {
|
||||
const template = templatesStore.getByKey(route.query.template)
|
||||
if (template && template.structure) {
|
||||
|
||||
@@ -92,7 +92,7 @@ onMounted(() => {
|
||||
formStore.loadAll(workspace.value.id)
|
||||
}
|
||||
|
||||
form.value = initForm({workspace_id: workspace.value?.id})
|
||||
form.value = initForm({workspace_id: workspace.value?.id}, true)
|
||||
formInitialHash.value = hash(JSON.stringify(form.value.data()))
|
||||
if (route.query.template !== undefined && route.query.template) {
|
||||
const template = templatesStore.getByKey(route.query.template)
|
||||
|
||||
Reference in New Issue
Block a user