sourcePane.js
function (newPaneOptions) {
    var newInstance = newPaneOptions.newInstance
    if (!newInstance) {
      let uri = newPaneOptions.newBase
      if (uri.endsWith('/')) {
        uri = uri.slice(0, -1)
        newPaneOptions.newBase = uri
      }
      newInstance = kb.sym(uri)
      newPaneOptions.newInstance = newInstance
    }

    var contentType = mime.lookup(newInstance.uri)
    if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) {
      let msg = 'A new text file has to have an file extension like .txt .ttl etc.'
      alert(msg)
      throw new Error(msg)
    }

    return new Promise(function (resolve, reject) {
      kb.fetcher.webOperation('PUT', newInstance.uri, {data: '\n', contentType: contentType})
        .then(function (response) {
          console.log('New text file created: ' + newInstance.uri)
          newPaneOptions.newInstance = newInstance
          resolve(newPaneOptions)
        }, err => {
          alert('Cant make new file: ' + err)
          reject(err)
        })
    })
  }
function (newPaneOptions) {
    var newInstance = newPaneOptions.newInstance
    if (!newInstance) {
      let uri = newPaneOptions.newBase
      if (uri.endsWith('/')) {
        uri = uri.slice(0, -1)
        newPaneOptions.newBase = uri
      }
      newInstance = kb.sym(uri)
      newPaneOptions.newInstance = newInstance
    }

    var contentType = mime.lookup(newInstance.uri)
    if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) {
      let msg = 'A new text file has to have an file extension like .txt .ttl etc.'
      alert(msg)
      throw new Error(msg)
    }

    return new Promise(function (resolve, reject) {
      kb.fetcher.webOperation('PUT', newInstance.uri, {data: '\n', contentType: contentType})
        .then(function (response) {
          console.log('New text file created: ' + newInstance.uri)
          newPaneOptions.newInstance = newInstance
          resolve(newPaneOptions)
        }, err => {
          alert('Cant make new file: ' + err)
          reject(err)
        })
    })
  }
function ( newPaneOptions ) { var newInstance = newPaneOptions . newInstance if ( ! newInstance ) { let uri = newPaneOptions . newBase if ( uri . endsWith ( '/' ) ) { uri = uri . slice ( 0 , - 1 ) newPaneOptions . newBase = uri } newInstance = kb . sym ( uri ) newPaneOptions . newInstance = newInstance } var contentType = mime . lookup ( newInstance . uri ) if ( ! contentType || ! ( contentType . startsWith ( 'text' ) || contentType . includes ( 'xml' ) ) ) { let msg = 'A new text file has to have an file extension like .txt .ttl etc.' alert ( msg ) throw new Error ( msg ) } return new Promise ( function ( resolve , reject ) { kb . fetcher . webOperation ( 'PUT' , newInstance . uri , { data : '\n' , contentType : contentType } ) . then ( function ( response ) { console . log ( 'New text file created: ' + newInstance . uri ) newPaneOptions . newInstance = newInstance resolve ( newPaneOptions ) } , err => { alert ( 'Cant make new file: ' + err ) reject ( err ) } ) } ) }
Create a new text file in a Solid system,
Create a new text file in a Solid system