Sha256: d7762ff181bd2c43f7a941d9fea93de6c67ec55d2edc97244baf6df6cedc807d

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

(function() {
  CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
    var pos = cm.getCursor(), token = cm.getTokenAt(pos);
    var space;
    if (token.className == "string") {
      var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end});
      var listStart = /\*|\d+\./, listContinue;
      if (token.string.search(listStart) == 0) {
        var reg = /^[\W]*(\d+)\./g;
        var matches = reg.exec(full);
        if(matches)
          listContinue = (parseInt(matches[1]) + 1) + ".  ";
        else
          listContinue = "*   ";
        space = full.slice(0, token.start);
        if (!/^\s*$/.test(space)) {
          space = "";
          for (var i = 0; i < token.start; ++i) space += " ";
        }
      }
    }

    if (space != null)
      cm.replaceSelection("\n" + space + listContinue, "end");
    else
      cm.execCommand("newlineAndIndent");
  };
})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glebtv-ckeditor-4.0.1 vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/continuelist.js