Sha256: 5c89a0d4b9f92b119e9faf0822dac9ef64ca0a4d216242d655274e078e5ad831

Contents?: true

Size: 1.09 KB

Versions: 32

Compression:

Stored size: 1.09 KB

Contents

!(function (angular) {
  'use strict';

  class AceSnippetManager {
    constructor() {
      this._context = 'pgsql';
      this._aceSnippetManager = ace.require('ace/snippets').snippetManager;
    }

    set context(c) {
      this._context = c;
    }

    get context() {
      return this._context;
    }

    add(name, content) {
      this._aceSnippetManager.register(this._parseSnippet(name, content), this._context);
    }

    remove(name, content) {
      this._aceSnippetManager.unregister(this._parseSnippet(name, content), this._context);
    }

    reset() {
      this._aceSnippetManager.snippetMap = {};
      this._aceSnippetManager.snippetNameMap = {};
    }

    // private method

    _parseSnippet(name, content) {
      let composed = 'snippet ' + name + ' \n\t ' + this._transformNewlines(content);
      return this._aceSnippetManager.parseSnippetFile(composed);
    }

    _transformNewlines(content) {
      return content.replace(/(\r\n|\n|\r)/gm, '\n\t');
    }
  }

  angular.module('alephServices.aceSnippetManager', []).service('AceSnippetManager', AceSnippetManager);
}(angular));

Version data entries

32 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.0.5 app/assets/javascripts/angular/services/snippet/ace_snippet_manager.js.es6
aleph_analytics-0.0.5 public/assets/angular/services/snippet/ace_snippet_manager.js-dbbba5d8ad5040042b469b294c4d7228.es6
aleph_analytics-0.0.4 app/assets/javascripts/angular/services/snippet/ace_snippet_manager.js.es6
aleph_analytics-0.0.4 public/assets/angular/services/snippet/ace_snippet_manager.js-dbbba5d8ad5040042b469b294c4d7228.es6
aleph_analytics-0.0.3 public/assets/angular/services/snippet/ace_snippet_manager.js-dbbba5d8ad5040042b469b294c4d7228.es6
aleph_analytics-0.0.3 app/assets/javascripts/angular/services/snippet/ace_snippet_manager.js.es6
aleph_analytics-0.0.2 public/assets/angular/services/snippet/ace_snippet_manager.js-dbbba5d8ad5040042b469b294c4d7228.es6
aleph_analytics-0.0.2 app/assets/javascripts/angular/services/snippet/ace_snippet_manager.js.es6
aleph_analytics-0.0.1.alpha app/assets/javascripts/angular/services/snippet/ace_snippet_manager.js.es6
aleph_analytics-0.0.1.alpha public/assets/angular/services/snippet/ace_snippet_manager.js-dbbba5d8ad5040042b469b294c4d7228.es6
aleph_analytics-0.0.0.alpha public/assets/angular/services/snippet/ace_snippet_manager.js-dbbba5d8ad5040042b469b294c4d7228.es6
aleph_analytics-0.0.0.alpha app/assets/javascripts/angular/services/snippet/ace_snippet_manager.js.es6