mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-22 19:25:18 -04:00
Update CodeMirror to 5.13.5
This commit is contained in:
parent
edc3a31dfd
commit
8bf516263c
84 changed files with 2837 additions and 504 deletions
47
public/vendor/codemirror/mode/swift/swift.js
vendored
47
public/vendor/codemirror/mode/swift/swift.js
vendored
|
@ -34,13 +34,13 @@
|
|||
"private","extension"])
|
||||
var operators = "+-/*%=|&<>#"
|
||||
var punc = ";,.(){}[]"
|
||||
var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/
|
||||
var number = /^-?(?:(?:[\d_]+\.[_\d]*|\.[_\d]+|0o[0-7_\.]+|0b[01_\.]+)(?:e-?[\d_]+)?|0x[\d_a-f\.]+(?:p-?[\d_]+)?)/i
|
||||
var identifier = /^[_A-Za-z$][_A-Za-z$0-9]*/
|
||||
var property = /^[@\.][_A-Za-z$][_A-Za-z$0-9]*/
|
||||
var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\//
|
||||
|
||||
function tokenBase(stream, state, prev) {
|
||||
if (stream.sol()) state.indented = stream.indentation()
|
||||
if (stream.eatSpace()) return null
|
||||
|
||||
var ch = stream.peek()
|
||||
|
@ -60,7 +60,8 @@
|
|||
return "operator"
|
||||
}
|
||||
if (punc.indexOf(ch) > -1) {
|
||||
stream.match(delimiters)
|
||||
stream.next()
|
||||
stream.match("..")
|
||||
return "punctuation"
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
|
@ -136,14 +137,35 @@
|
|||
return "comment"
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("swift", function() {
|
||||
function Context(prev, align, indented) {
|
||||
this.prev = prev
|
||||
this.align = align
|
||||
this.indented = indented
|
||||
}
|
||||
|
||||
function pushContext(state, stream) {
|
||||
var align = stream.match(/^\s*($|\/[\/\*])/, false) ? null : stream.column() + 1
|
||||
state.context = new Context(state.context, align, state.indented)
|
||||
}
|
||||
|
||||
function popContext(state) {
|
||||
if (state.context) {
|
||||
state.indented = state.context.indented
|
||||
state.context = state.context.prev
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("swift", function(config) {
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
prev: null,
|
||||
context: null,
|
||||
indented: 0,
|
||||
tokenize: []
|
||||
}
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var prev = state.prev
|
||||
state.prev = null
|
||||
|
@ -151,8 +173,25 @@
|
|||
var style = tokenize(stream, state, prev)
|
||||
if (!style || style == "comment") state.prev = prev
|
||||
else if (!state.prev) state.prev = style
|
||||
|
||||
if (style == "punctuation") {
|
||||
var bracket = /[\(\[\{]|([\]\)\}])/.exec(stream.current())
|
||||
if (bracket) (bracket[1] ? popContext : pushContext)(state, stream)
|
||||
}
|
||||
|
||||
return style
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var cx = state.context
|
||||
if (!cx) return 0
|
||||
var closing = /^[\]\}\)]/.test(textAfter)
|
||||
if (cx.align != null) return cx.align - (closing ? 1 : 0)
|
||||
return cx.indented + (closing ? 0 : config.indentUnit)
|
||||
},
|
||||
|
||||
electricInput: /^\s*[\)\}\]]$/,
|
||||
|
||||
lineComment: "//",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/"
|
||||
|
@ -160,4 +199,4 @@
|
|||
})
|
||||
|
||||
CodeMirror.defineMIME("text/x-swift","swift")
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue