How to use substance - 10 common examples

To help you get started, we’ve selected a few substance 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 archivist / archivist / packages / store / user / UserStore.js View on Github external
createUser(userData) {
    // Generate a userId if not provided
    if (!userData.userId) {
      userData.userId = uuid()
    }

    if (isUndefined(userData.name)) {
      userData.name = ''
    }

    return this.userExists(userData.userId).bind(this)
      .then(function(exists) {
        if (exists) {
          throw new Err('UserStore.CreateError', {
            message: 'User already exists.'
          })
        }

        return this._createUser(userData)
      }.bind(this))
github archivist / archivist / packages / store / user / UserStore.js View on Github external
_createUser(userData) {
    // at some point we should make this more secure
    let loginKey = userData.loginKey || uuid()

    let record = {
      userId: userData.userId,
      name: userData.name,
      email: userData.email,
      created: new Date(),
      loginKey: loginKey,
      password: userData.password,
      access: userData.access,
      super: userData.super
    }

    return new Promise(function(resolve, reject) {
      this.db.users.insert(record, function(err, user) {
        if (err) {
          return reject(new Err('UserStore.CreateError', {
github substance / texture / src / dar / PersistedDocumentArchive.js View on Github external
addAsset (file) {
    let assetId = uuid()
    let [name, ext] = _getNameAndExtension(file.name)
    let filePath = this._getUniqueFileName(name, ext)
    // TODO: this is not ready for collab
    this._manifestSession.transaction(tx => {
      let assetNode = tx.create({
        type: 'asset',
        id: assetId,
        path: filePath,
        assetType: file.type
      })
      documentHelpers.append(tx, ['dar', 'assets'], assetNode.id)
    })
    this.buffer.addBlob(assetId, {
      id: assetId,
      path: filePath,
      blob: file
github stencila / mini / test / engine / TestCell.js View on Github external
constructor(exprStr) {
    super()

    this.id = uuid()
    this.source = exprStr
    this.expr = null
    this.error = null

    this.updateExpression(exprStr)
  }
github substance / texture / src / PersistedDocumentArchive.js View on Github external
createFile(file) {
    let assetId
    let fileExtension = last(file.name.split('.'))
    let filePath = `${uuid()}.${fileExtension}`
    this._sessions.manifest.transaction(tx => {
      let assets = tx.find('assets')
      let asset = tx.createElement('asset').attr({
        path: filePath,
        type: file.type
      })
      assetId = asset.id
      assets.appendChild(asset)
    })

    this.buffer.addBlob(assetId, file)
    this._pendingFiles[filePath] = URL.createObjectURL(file)
    return filePath
  }
github archivist / archivist / packages / store / session / SessionStore.js View on Github external
createSession(session) {
    let sessionToken = session.sessionToken || uuid()

    let newSession = {
      sessionToken: sessionToken,
      created: new Date(),
      userId: session.userId
    }

    return new Promise(function(resolve, reject) {
      this.db.sessions.insert(newSession, function(err, session) {
        if (err) {
          return reject(new Err('SessionStore.CreateError', {
            cause: err
          }))
        }

        resolve(session)
github archivist / archivist / packages / engine / auth / AuthEngine.js View on Github external
_updateLoginKey(user) {
    let userStore = this.userStore
    let newLoginKey = uuid()
    return userStore.updateUser(user.userId, {loginKey: newLoginKey})
  }
github substance / texture / src / kit / app / AbstractAppState.js View on Github external
constructor () {
    this.id = uuid()
    this.values = new Map()
    this.dirty = {}
    this.updates = {}
  }
github substance / document / src / model.js View on Github external
function Model( data ) {
  Substance.EventEmitter.call(this);

  this.properties = Substance.extend({}, this.getDefaultProperties(), data);
  this.properties.type = this.constructor.static.name;
  this.properties.id = this.properties.id || Substance.uuid(this.properties.type);
}

substance

Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).

MIT
Latest version published 4 years ago

Package Health Score

54 / 100
Full package analysis

Popular substance functions