Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addStorage('wordpressRebuildPostData', (storage) => {
const controller = new SaveController()
const elementsStorage = getStorage('elements')
const settingsStorage = getStorage('settings')
const wordpressBackendWorkspace = getStorage('wordpressBackendWorkspace')
const documentManager = getService('document')
const modernAssetsStorage = getService('modernAssetsStorage')
storage.on('save', (id, options, source = '') => {
storage.state('status').set({ status: 'saving' }, source)
settingsStorage.state('status').set({ status: 'ready' })
const documentData = documentManager.all()
// check this
storage.trigger('wordpress:beforeSave', {
pageElements: documentData
})
options = Object.assign({}, {
elements: documentData
}, options)
valueChangeHandler (fieldKey, value) {
const storage = getStorage('fieldOptions')
const options = {
fieldKey: fieldKey,
fieldType: this.props.fieldType,
id: this.props.elementAccessPoint.id
}
storage.trigger('fieldOptionsChange', options)
let newState = lodash.defaultsDeep({}, this.state)
newState.devices[ newState.currentDevice ][ fieldKey ] = value
this.updateValue(newState, fieldKey)
}
addStorage('migration', (storage) => {
const cook = getService('cook')
const utils = getService('utils')
const elementsStorage = getStorage('elements')
storage.on('migrateContent', (contentData) => {
window.setTimeout(() => {
if (!contentData._migrated) {
const textElement = cook.get({ tag: 'textBlock', output: utils.wpAutoP(contentData.content, '__VCVID__') })
if (textElement) {
elementsStorage.trigger('add', textElement.toJS())
}
} else {
let elements = storage.state('elements').get()
let elementsArray = []
for (let key in elements) {
if (elements.hasOwnProperty(key)) {
elementsArray.push(elements[ key ])
}
}
addStorage('workspace', (storage) => {
const elementsStorage = getStorage('elements')
const documentManager = getService('document')
const cook = getService('cook')
const isElementOneRelation = (parent) => {
let children = cook.getContainerChildren(parent.tag)
if (children.length === 1) {
return children[ 0 ].tag
}
return false
}
storage.on('add', (id, tag, options) => {
let element = false
if (id) {
element = documentManager.get(id)
}
if (element) {
let oneTag = isElementOneRelation(element)
addStorage('history', (storage) => {
const elementsStorage = getStorage('elements')
const workspaceStorage = getStorage('workspace')
const elementsTimeMachine = new TimeMachine('layout')
const documentService = getService('document')
let inited = false
let lockedReason = ''
const checkUndoRedo = () => {
storage.state('canRedo').set(inited && elementsTimeMachine.canRedo())
storage.state('canUndo').set(inited && elementsTimeMachine.canUndo())
}
const updateElementsStorage = () => {
elementsStorage.trigger('updateAll', elementsTimeMachine.get())
}
storage.on('undo', () => {
if (!inited) {
return
}
componentWillUnmount () {
if (this.errorTimeout) {
window.clearTimeout(this.errorTimeout)
this.errorTimeout = 0
}
getStorage('hubTemplates').state('templates').ignoreChange(this.handleTemplateStorageStateChange)
}
componentDidMount () {
getStorage('hubTemplates').state('templates').onChange(this.handleTemplateStorageStateChange)
}
import React from 'react'
import Logo from '../../../../resources/components/navbar/logo/logo'
import PlusControl from '../../../../resources/components/navbar/controls/plusControl'
import PlusTeaserControl from '../../../../resources/components/navbar/controls/plusTeaserControl'
import AddTemplateControl from '../../../../resources/components/navbar/controls/addTemplateControl'
import TreeViewControl from '../../../../resources/components/navbar/controls/treeViewControl'
import UndoRedoControl from '../../../../resources/components/navbar/controls/undoRedoControl'
import SettingsButtonControl from '../../../../resources/components/navbar/controls/settingsButtonControl'
import Navbar from '../../../../resources/components/navbar/navbar'
import {getStorage} from 'vc-cake'
const workspaceStorage = getStorage('workspace')
const contentEndState = workspaceStorage.state('contentEnd')
export default class NavbarContainer extends React.Component {
constructor (props) {
super(props)
this.state = {
locked: false
}
this.updateLockedState = this.updateLockedState.bind(this)
}
componentDidMount () {
contentEndState.onChange(this.updateLockedState)
}
componentWillUnmount () {
contentEndState.ignoreChange(this.updateLockedState)
}
addStorage('history', (storage) => {
const elementsStorage = getStorage('elements')
const workspaceStorage = getStorage('workspace')
const elementsTimeMachine = new TimeMachine('layout')
const documentService = getService('document')
let inited = false
let lockedReason = ''
const checkUndoRedo = () => {
storage.state('canRedo').set(inited && elementsTimeMachine.canRedo())
storage.state('canUndo').set(inited && elementsTimeMachine.canUndo())
}
const updateElementsStorage = () => {
elementsStorage.trigger('updateAll', elementsTimeMachine.get())
}
storage.on('undo', () => {
if (!inited) {
return
}
elementsTimeMachine.undo()
import React from 'react'
import { setData, getStorage, env } from 'vc-cake'
const settingsStorage = getStorage('settings')
const workspaceStorage = getStorage('workspace')
const workspaceIFrame = workspaceStorage.state('iframe')
export default class TemplateSettings extends React.Component {
constructor (props) {
super(props)
let templateStorageData = settingsStorage.state('pageTemplate').get()
let templateData = window.VCV_PAGE_TEMPLATES ? window.VCV_PAGE_TEMPLATES() : {}
let currentTemplate = templateStorageData || templateData.current || 'default'
this.state = {
current: currentTemplate,
all: templateData.all || []
}
setData('ui:settings:pageTemplate', currentTemplate)
this.updateTemplate = this.updateTemplate.bind(this)
this.getTemplateOptions = this.getTemplateOptions.bind(this)
}