Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getPublicImage (filename) {
let { metaAssetsPath } = this.props
if (!filename) {
return ''
}
const isDynamic = env('VCV_JS_FT_DYNAMIC_FIELDS')
if (isDynamic && filename.match(blockRegexp)) {
let blockInfo = filename.split(blockRegexp)
let blockAtts = JSON.parse(blockInfo[ 4 ])
filename = getDynamicFieldsData({
blockAtts: blockAtts
})
return filename
}
return filename.match('^(https?:)?\\/\\/?') ? filename : metaAssetsPath + filename
}
constructor (props) {
super(props)
this.handleDynamicFieldOpen = this.handleDynamicFieldOpen.bind(this)
this.handleDynamicFieldClose = this.handleDynamicFieldClose.bind(this)
this.handleDynamicFieldChange = this.handleDynamicFieldChange.bind(this)
this.onLoadPostFields = this.onLoadPostFields.bind(this)
this.open = this.open.bind(this)
this.hide = this.hide.bind(this)
const isDynamic = env('VCV_JS_FT_DYNAMIC_FIELDS') && this.props.options && this.props.options.dynamicField
let state = {
isDynamic: isDynamic,
dynamicFieldOpened: false,
isWindowOpen: false,
blockInfo: false
}
if (isDynamic) {
let newState = this.getStateFromValue(this.props.value)
state = { ...state, ...newState }
if (state.blockInfo && state.blockInfo.blockAtts && state.blockInfo.blockAtts.sourceId) {
window.setTimeout(() => {
settingsStorage.trigger('loadDynamicPost', state.blockInfo.blockAtts.sourceId, this.onLoadPostFields, (error) => {
console.warn('Error loading dynamic post info', error)
this.onLoadPostFields(state.blockInfo.blockAtts.sourceId, {}, {})
}, true)
constructor (props) {
super(props)
this.handleChangeSourceId = this.handleChangeSourceId.bind(this)
this.handleDynamicFieldOpen = this.handleDynamicFieldOpen.bind(this)
this.handleDynamicFieldClose = this.handleDynamicFieldClose.bind(this)
this.handleDynamicFieldChange = this.handleDynamicFieldChange.bind(this)
this.handleAutocompleteToggle = this.handleAutocompleteToggle.bind(this)
this.onLoadPostFields = this.onLoadPostFields.bind(this)
const isDynamic = env('VCV_JS_FT_DYNAMIC_FIELDS') && this.props.options && this.props.options.dynamicField && !(this.props.editFormOptions && this.props.editFormOptions.nestedAttr)
let state = {
isDynamic: isDynamic,
dynamicFieldOpened: false
}
if (isDynamic) {
let newState = this.getStateFromValue(this.props.value)
window.setTimeout(() => {
settingsStorage.trigger('loadDynamicPost', state.sourceId, this.onLoadPostFields, function (error) {
console.warn('Error loading dynamic post info', error)
this.onLoadPostFields(this.state.sourceId, {}, {})
})
}, 1)
state = { ...state, ...newState }
}
this.state = state
getTemplateControlProps (template) {
template = Object.assign({}, template)
if (
(env('VCV_FT_TEMPLATE_DATA_ASYNC') && this.state.showLoading === template.id) ||
(this.state.removing && template.id === this.state.showSpinner)
) {
template.spinner = true
}
return {
key: 'vcv-element-control-' + template.id,
applyTemplate: this.handleApplyTemplate,
removeTemplate: this.handleRemoveTemplate,
...template
}
}
getValue (settings, data, key, ignoreGetter = false) {
if ((env('EXISTING_ELEMENT_ATTR_FIX') && settings.access === 'protected') || (typeof data[ key ] === 'undefined' && typeof settings.value !== 'undefined')) {
data[ key ] = settings.value
}
return this.getter && ignoreGetter !== true ? this.getter(data, key, settings) : this.getRawValue(data, key)
}