Dotclear


Ignore:
Timestamp:
12/11/17 15:59:17 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Update CodeMirror? from 5.25.1 to 5.32.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/js/codemirror/addon/edit/closebrackets.js

    r3532 r3617  
    2424    } 
    2525    if (val) { 
     26      ensureBound(getOption(val, "pairs")) 
    2627      cm.state.closeBrackets = val; 
    2728      cm.addKeyMap(keyMap); 
     
    3536  } 
    3637 
    37   var bind = defaults.pairs + "`"; 
    3838  var keyMap = {Backspace: handleBackspace, Enter: handleEnter}; 
    39   for (var i = 0; i < bind.length; i++) 
    40     keyMap["'" + bind.charAt(i) + "'"] = handler(bind.charAt(i)); 
     39  function ensureBound(chars) { 
     40    for (var i = 0; i < chars.length; i++) { 
     41      var ch = chars.charAt(i), key = "'" + ch + "'" 
     42      if (!keyMap[key]) keyMap[key] = handler(ch) 
     43    } 
     44  } 
     45  ensureBound(defaults.pairs + "`") 
    4146 
    4247  function handler(ch) { 
     
    8085    } 
    8186    cm.operation(function() { 
    82       cm.replaceSelection("\n\n", null); 
     87      var linesep = cm.lineSeparator() || "\n"; 
     88      cm.replaceSelection(linesep + linesep, null); 
    8389      cm.execCommand("goCharLeft"); 
    8490      ranges = cm.listSelections(); 
     
    128134        curType = "addFour"; 
    129135      } else if (identical) { 
    130         if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, ch)) curType = "both"; 
     136        var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) 
     137        if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; 
    131138        else return CodeMirror.Pass; 
    132139      } else if (opening && (cm.getLine(cur.line).length == cur.ch || 
     
    180187  } 
    181188 
    182   // Project the token type that will exists after the given char is 
    183   // typed, and use it to determine whether it would cause the start 
    184   // of a string token. 
    185   function enteringString(cm, pos, ch) { 
    186     var line = cm.getLine(pos.line); 
    187     var token = cm.getTokenAt(pos); 
    188     if (/\bstring2?\b/.test(token.type) || stringStartsAfter(cm, pos)) return false; 
    189     var stream = new CodeMirror.StringStream(line.slice(0, pos.ch) + ch + line.slice(pos.ch), 4); 
    190     stream.pos = stream.start = token.start; 
    191     for (;;) { 
    192       var type1 = cm.getMode().token(stream, token.state); 
    193       if (stream.pos >= pos.ch + 1) return /\bstring2?\b/.test(type1); 
    194       stream.start = stream.pos; 
    195     } 
    196   } 
    197  
    198189  function stringStartsAfter(cm, pos) { 
    199190    var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1)) 
    200     return /\bstring/.test(token.type) && token.start == pos.ch 
     191    return /\bstring/.test(token.type) && token.start == pos.ch && 
     192      (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos))) 
    201193  } 
    202194}); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map