Files
baserow/web-frontend/modules/builder/mixins/element.js
Peter EvansandJeremie Pardou 5a62c876e4 fix: align custom code in builder Preview with the editor on shared hostnames (#6881)
* fix: restrict editor-written code in the builder editor and on the editor hostname

* fix: simplify builder author code restrictions by hostname

* refactor: remove redundant backend custom code hostname checks

* refactor: unify builder HTML element rendering restrictions

* refactor: clarify builder web frontend hostname terminology

* fix: distinguish untrusted builder content in preview notices

* refactor: remove unused backend preview security setting

* docs: shorten builder code restriction changelog

* fix: restrict iframe cookie access across frontend ports

* refactor: share web frontend hostname matching

* fix: preserve protected HTML interactions and bound iframe height

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-26 17:20:44 +00:00

97 lines
3.0 KiB
JavaScript

import { resolveColor } from '@baserow/modules/core/utils/colors'
import applicationContextMixin from '@baserow/modules/builder/mixins/applicationContext'
import resolveFormulaMixin from '@baserow/modules/builder/mixins/resolveFormula'
import { ThemeConfigBlockType } from '@baserow/modules/builder/themeConfigBlockTypes'
export default {
inject: ['workspace', 'builder', 'currentPage', 'elementPage', 'mode'],
mixins: [applicationContextMixin, resolveFormulaMixin],
props: {
element: {
type: Object,
required: true,
},
},
computed: {
workflowActionsInProgress() {
const workflowActions = this.$store.getters[
'builderWorkflowAction/getElementWorkflowActions'
](this.elementPage, this.element.id)
const dispatchedById = this.elementType.uniqueElementId({
element: this.element,
applicationContext: this.applicationContext,
})
return workflowActions.some((workflowAction) =>
this.$store.getters['builderWorkflowAction/getDispatching'](
workflowAction,
dispatchedById
)
)
},
elementType() {
return this.$registry.get('element', this.element.type)
},
isEditMode() {
return this.mode === 'editing'
},
/**
* Restrict author code according to the hostname serving this page.
*/
isAuthorCodeRestricted() {
return this.$isAuthorCodeRestricted()
},
/**
* The editor's hint for an element that holds author code. Preview only
* shows such an element in full when it doesn't restrict that code.
*/
authorCodeEditorHint() {
return this.$previewRestrictsAuthorCode()
? this.$t('iframeElementForm.editorEmbedHintPublished')
: this.$t('iframeElementForm.editorEmbedHint')
},
elementIsInError() {
return this.elementType.isInError(this.element, this.applicationContext)
},
themeConfigBlocks() {
return this.$registry.getOrderedList('themeConfigBlock')
},
colorVariables() {
return ThemeConfigBlockType.getAllColorVariables(
this.themeConfigBlocks,
this.builder.theme
)
},
},
methods: {
async fireEvent(event) {
if (this.mode !== 'editing') {
if (this.workflowActionsInProgress) {
return false
}
const workflowActions = this.$store.getters[
'builderWorkflowAction/getElementWorkflowActions'
](this.elementPage, this.element.id).filter(
({ event: eventName }) => eventName === event.name
)
await event.fire({
workflowActions,
resolveFormula: this.resolveFormula,
applicationContext: this.applicationContext,
})
}
},
getStyleOverride(key, colorVariables = null) {
return ThemeConfigBlockType.getAllStyles(
this.themeConfigBlocks,
this.element.styles?.[key] || {},
colorVariables || this.colorVariables,
this.builder.theme
)
},
resolveColor,
},
}