How to use the vc-cake.getStorage function in vc-cake

To help you get started, we’ve selected a few vc-cake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VisualComposer / builder / public / editor / stores / wordpressRebuildPostData / wordpressRebuildPostDataStorage.js View on Github external
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)
github VisualComposer / builder / public / sources / attributes / attribute.js View on Github external
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)
  }
github VisualComposer / builder / public / editor / stores / migrationStorage.js View on Github external
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 ])
          }
        }
github VisualComposer / builder / public / editor / stores / workspaceStorage.js View on Github external
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)
github VisualComposer / builder / public / editor / stores / history / historyStorage.js View on Github external
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
    }
github VisualComposer / builder / public / components / panels / addTemplate / addTemplatePanel.js View on Github external
componentWillUnmount () {
    if (this.errorTimeout) {
      window.clearTimeout(this.errorTimeout)
      this.errorTimeout = 0
    }
    getStorage('hubTemplates').state('templates').ignoreChange(this.handleTemplateStorageStateChange)
  }
github VisualComposer / builder / public / components / panels / addTemplate / addTemplatePanel.js View on Github external
componentDidMount () {
    getStorage('hubTemplates').state('templates').onChange(this.handleTemplateStorageStateChange)
  }
github VisualComposer / builder / public / editor / modules / wordpressUpdateWorkspace / containers / navbarContainer.js View on Github external
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)
  }
github VisualComposer / builder / public / editor / stores / history / historyStorage.js View on Github external
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()
github VisualComposer / builder / public / components / panels / settings / lib / pageSettings / settings / deprecated / template.js View on Github external
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)
  }

vc-cake

Modular approach for javascript based projects from WPBakery

ISC
Latest version published 12 months ago

Package Health Score

56 / 100
Full package analysis