codemirror-rails 5.10 → 5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +15 -12
  4. data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +1 -1
  5. data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +2 -2
  6. data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +32 -11
  7. data/vendor/assets/javascripts/codemirror/modes/clike.js +1 -3
  8. data/vendor/assets/javascripts/codemirror/modes/clojure.js +8 -3
  9. data/vendor/assets/javascripts/codemirror/modes/css.js +14 -13
  10. data/vendor/assets/javascripts/codemirror/modes/django.js +3 -4
  11. data/vendor/assets/javascripts/codemirror/modes/haskell-literate.js +43 -0
  12. data/vendor/assets/javascripts/codemirror/modes/jade.js +3 -3
  13. data/vendor/assets/javascripts/codemirror/modes/javascript.js +15 -4
  14. data/vendor/assets/javascripts/codemirror/modes/jsx.js +147 -0
  15. data/vendor/assets/javascripts/codemirror/modes/julia.js +143 -78
  16. data/vendor/assets/javascripts/codemirror/modes/markdown.js +1 -1
  17. data/vendor/assets/javascripts/codemirror/modes/nginx.js +1 -1
  18. data/vendor/assets/javascripts/codemirror/modes/ruby.js +1 -1
  19. data/vendor/assets/javascripts/codemirror/modes/swift.js +42 -3
  20. data/vendor/assets/javascripts/codemirror/modes/xml.js +78 -69
  21. data/vendor/assets/javascripts/codemirror/modes/yaml-frontmatter.js +1 -1
  22. data/vendor/assets/stylesheets/codemirror/modes/tiki.css +1 -1
  23. data/vendor/assets/stylesheets/codemirror/themes/mbo.css +1 -1
  24. data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -0
  25. metadata +3 -1
@@ -235,7 +235,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
235
235
  }
236
236
 
237
237
  function local(stream, state) {
238
- if (stream.sol() && state.fencedChars && stream.match(state.fencedChars, false)) {
238
+ if (state.fencedChars && stream.match(state.fencedChars, false)) {
239
239
  state.localMode = state.localState = null;
240
240
  state.f = state.block = leavingLocal;
241
241
  return null;
@@ -173,6 +173,6 @@ CodeMirror.defineMode("nginx", function(config) {
173
173
  };
174
174
  });
175
175
 
176
- CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf");
176
+ CodeMirror.defineMIME("text/x-nginx-conf", "nginx");
177
177
 
178
178
  });
@@ -275,7 +275,7 @@ CodeMirror.defineMode("ruby", function(config) {
275
275
  (state.continuedLine ? config.indentUnit : 0);
276
276
  },
277
277
 
278
- electricChars: "}de", // enD and rescuE
278
+ electricInput: /^\s*(?:end|rescue|\})$/,
279
279
  lineComment: "#"
280
280
  };
281
281
  });
@@ -34,13 +34,13 @@
34
34
  "private","extension"])
35
35
  var operators = "+-/*%=|&<>#"
36
36
  var punc = ";,.(){}[]"
37
- var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/
38
37
  var number = /^-?(?:(?:[\d_]+\.[_\d]*|\.[_\d]+|0o[0-7_\.]+|0b[01_\.]+)(?:e-?[\d_]+)?|0x[\d_a-f\.]+(?:p-?[\d_]+)?)/i
39
38
  var identifier = /^[_A-Za-z$][_A-Za-z$0-9]*/
40
39
  var property = /^[@\.][_A-Za-z$][_A-Za-z$0-9]*/
41
40
  var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\//
42
41
 
43
42
  function tokenBase(stream, state, prev) {
43
+ if (stream.sol()) state.indented = stream.indentation()
44
44
  if (stream.eatSpace()) return null
45
45
 
46
46
  var ch = stream.peek()
@@ -60,7 +60,8 @@
60
60
  return "operator"
61
61
  }
62
62
  if (punc.indexOf(ch) > -1) {
63
- stream.match(delimiters)
63
+ stream.next()
64
+ stream.match("..")
64
65
  return "punctuation"
65
66
  }
66
67
  if (ch == '"' || ch == "'") {
@@ -136,14 +137,35 @@
136
137
  return "comment"
137
138
  }
138
139
 
139
- CodeMirror.defineMode("swift", function() {
140
+ function Context(prev, align, indented) {
141
+ this.prev = prev
142
+ this.align = align
143
+ this.indented = indented
144
+ }
145
+
146
+ function pushContext(state, stream) {
147
+ var align = stream.match(/^\s*($|\/[\/\*])/, false) ? null : stream.column() + 1
148
+ state.context = new Context(state.context, align, state.indented)
149
+ }
150
+
151
+ function popContext(state) {
152
+ if (state.context) {
153
+ state.indented = state.context.indented
154
+ state.context = state.context.prev
155
+ }
156
+ }
157
+
158
+ CodeMirror.defineMode("swift", function(config) {
140
159
  return {
141
160
  startState: function() {
142
161
  return {
143
162
  prev: null,
163
+ context: null,
164
+ indented: 0,
144
165
  tokenize: []
145
166
  }
146
167
  },
168
+
147
169
  token: function(stream, state) {
148
170
  var prev = state.prev
149
171
  state.prev = null
@@ -151,8 +173,25 @@
151
173
  var style = tokenize(stream, state, prev)
152
174
  if (!style || style == "comment") state.prev = prev
153
175
  else if (!state.prev) state.prev = style
176
+
177
+ if (style == "punctuation") {
178
+ var bracket = /[\(\[\{]|([\]\)\}])/.exec(stream.current())
179
+ if (bracket) (bracket[1] ? popContext : pushContext)(state, stream)
180
+ }
181
+
154
182
  return style
155
183
  },
184
+
185
+ indent: function(state, textAfter) {
186
+ var cx = state.context
187
+ if (!cx) return 0
188
+ var closing = /^[\]\}\)]/.test(textAfter)
189
+ if (cx.align != null) return cx.align - (closing ? 1 : 0)
190
+ return cx.indented + (closing ? 0 : config.indentUnit)
191
+ },
192
+
193
+ electricInput: /^\s*[\)\}\]]$/,
194
+
156
195
  lineComment: "//",
157
196
  blockCommentStart: "/*",
158
197
  blockCommentEnd: "*/"
@@ -11,54 +11,56 @@
11
11
  })(function(CodeMirror) {
12
12
  "use strict";
13
13
 
14
- CodeMirror.defineMode("xml", function(config, parserConfig) {
15
- var indentUnit = config.indentUnit;
16
- var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
17
- var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
18
- if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
14
+ var htmlConfig = {
15
+ autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
16
+ 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
17
+ 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
18
+ 'track': true, 'wbr': true, 'menuitem': true},
19
+ implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
20
+ 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
21
+ 'th': true, 'tr': true},
22
+ contextGrabbers: {
23
+ 'dd': {'dd': true, 'dt': true},
24
+ 'dt': {'dd': true, 'dt': true},
25
+ 'li': {'li': true},
26
+ 'option': {'option': true, 'optgroup': true},
27
+ 'optgroup': {'optgroup': true},
28
+ 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
29
+ 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
30
+ 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
31
+ 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
32
+ 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
33
+ 'rp': {'rp': true, 'rt': true},
34
+ 'rt': {'rp': true, 'rt': true},
35
+ 'tbody': {'tbody': true, 'tfoot': true},
36
+ 'td': {'td': true, 'th': true},
37
+ 'tfoot': {'tbody': true},
38
+ 'th': {'td': true, 'th': true},
39
+ 'thead': {'tbody': true, 'tfoot': true},
40
+ 'tr': {'tr': true}
41
+ },
42
+ doNotIndent: {"pre": true},
43
+ allowUnquoted: true,
44
+ allowMissing: true,
45
+ caseFold: true
46
+ }
19
47
 
20
- var Kludges = parserConfig.htmlMode ? {
21
- autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
22
- 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
23
- 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
24
- 'track': true, 'wbr': true, 'menuitem': true},
25
- implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
26
- 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
27
- 'th': true, 'tr': true},
28
- contextGrabbers: {
29
- 'dd': {'dd': true, 'dt': true},
30
- 'dt': {'dd': true, 'dt': true},
31
- 'li': {'li': true},
32
- 'option': {'option': true, 'optgroup': true},
33
- 'optgroup': {'optgroup': true},
34
- 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
35
- 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
36
- 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
37
- 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
38
- 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
39
- 'rp': {'rp': true, 'rt': true},
40
- 'rt': {'rp': true, 'rt': true},
41
- 'tbody': {'tbody': true, 'tfoot': true},
42
- 'td': {'td': true, 'th': true},
43
- 'tfoot': {'tbody': true},
44
- 'th': {'td': true, 'th': true},
45
- 'thead': {'tbody': true, 'tfoot': true},
46
- 'tr': {'tr': true}
47
- },
48
- doNotIndent: {"pre": true},
49
- allowUnquoted: true,
50
- allowMissing: true,
51
- caseFold: true
52
- } : {
53
- autoSelfClosers: {},
54
- implicitlyClosed: {},
55
- contextGrabbers: {},
56
- doNotIndent: {},
57
- allowUnquoted: false,
58
- allowMissing: false,
59
- caseFold: false
60
- };
61
- var alignCDATA = parserConfig.alignCDATA;
48
+ var xmlConfig = {
49
+ autoSelfClosers: {},
50
+ implicitlyClosed: {},
51
+ contextGrabbers: {},
52
+ doNotIndent: {},
53
+ allowUnquoted: false,
54
+ allowMissing: false,
55
+ caseFold: false
56
+ }
57
+
58
+ CodeMirror.defineMode("xml", function(editorConf, config_) {
59
+ var indentUnit = editorConf.indentUnit
60
+ var config = {}
61
+ var defaults = config_.htmlMode ? htmlConfig : xmlConfig
62
+ for (var prop in defaults) config[prop] = defaults[prop]
63
+ for (var prop in config_) config[prop] = config_[prop]
62
64
 
63
65
  // Return variables for tokenizers
64
66
  var type, setStyle;
@@ -188,7 +190,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
188
190
  this.tagName = tagName;
189
191
  this.indent = state.indented;
190
192
  this.startOfLine = startOfLine;
191
- if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
193
+ if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
192
194
  this.noIndent = true;
193
195
  }
194
196
  function popContext(state) {
@@ -201,8 +203,8 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
201
203
  return;
202
204
  }
203
205
  parentTagName = state.context.tagName;
204
- if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
205
- !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
206
+ if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
207
+ !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
206
208
  return;
207
209
  }
208
210
  popContext(state);
@@ -233,7 +235,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
233
235
  if (type == "word") {
234
236
  var tagName = stream.current();
235
237
  if (state.context && state.context.tagName != tagName &&
236
- Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
238
+ config.implicitlyClosed.hasOwnProperty(state.context.tagName))
237
239
  popContext(state);
238
240
  if (state.context && state.context.tagName == tagName) {
239
241
  setStyle = "tag";
@@ -269,7 +271,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
269
271
  var tagName = state.tagName, tagStart = state.tagStart;
270
272
  state.tagName = state.tagStart = null;
271
273
  if (type == "selfcloseTag" ||
272
- Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
274
+ config.autoSelfClosers.hasOwnProperty(tagName)) {
273
275
  maybePopContext(state, tagName);
274
276
  } else {
275
277
  maybePopContext(state, tagName);
@@ -282,12 +284,12 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
282
284
  }
283
285
  function attrEqState(type, stream, state) {
284
286
  if (type == "equals") return attrValueState;
285
- if (!Kludges.allowMissing) setStyle = "error";
287
+ if (!config.allowMissing) setStyle = "error";
286
288
  return attrState(type, stream, state);
287
289
  }
288
290
  function attrValueState(type, stream, state) {
289
291
  if (type == "string") return attrContinuedState;
290
- if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
292
+ if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
291
293
  setStyle = "error";
292
294
  return attrState(type, stream, state);
293
295
  }
@@ -297,12 +299,14 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
297
299
  }
298
300
 
299
301
  return {
300
- startState: function() {
301
- return {tokenize: inText,
302
- state: baseState,
303
- indented: 0,
304
- tagName: null, tagStart: null,
305
- context: null};
302
+ startState: function(baseIndent) {
303
+ var state = {tokenize: inText,
304
+ state: baseState,
305
+ indented: baseIndent || 0,
306
+ tagName: null, tagStart: null,
307
+ context: null}
308
+ if (baseIndent != null) state.baseIndent = baseIndent
309
+ return state
306
310
  },
307
311
 
308
312
  token: function(stream, state) {
@@ -335,19 +339,19 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
335
339
  return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
336
340
  // Indent the starts of attribute names.
337
341
  if (state.tagName) {
338
- if (multilineTagIndentPastTag)
342
+ if (config.multilineTagIndentPastTag !== false)
339
343
  return state.tagStart + state.tagName.length + 2;
340
344
  else
341
- return state.tagStart + indentUnit * multilineTagIndentFactor;
345
+ return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
342
346
  }
343
- if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
347
+ if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
344
348
  var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
345
349
  if (tagAfter && tagAfter[1]) { // Closing tag spotted
346
350
  while (context) {
347
351
  if (context.tagName == tagAfter[2]) {
348
352
  context = context.prev;
349
353
  break;
350
- } else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
354
+ } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
351
355
  context = context.prev;
352
356
  } else {
353
357
  break;
@@ -355,25 +359,30 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
355
359
  }
356
360
  } else if (tagAfter) { // Opening tag spotted
357
361
  while (context) {
358
- var grabbers = Kludges.contextGrabbers[context.tagName];
362
+ var grabbers = config.contextGrabbers[context.tagName];
359
363
  if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
360
364
  context = context.prev;
361
365
  else
362
366
  break;
363
367
  }
364
368
  }
365
- while (context && !context.startOfLine)
369
+ while (context && context.prev && !context.startOfLine)
366
370
  context = context.prev;
367
371
  if (context) return context.indent + indentUnit;
368
- else return 0;
372
+ else return state.baseIndent || 0;
369
373
  },
370
374
 
371
375
  electricInput: /<\/[\s\w:]+>$/,
372
376
  blockCommentStart: "<!--",
373
377
  blockCommentEnd: "-->",
374
378
 
375
- configuration: parserConfig.htmlMode ? "html" : "xml",
376
- helperType: parserConfig.htmlMode ? "html" : "xml"
379
+ configuration: config.htmlMode ? "html" : "xml",
380
+ helperType: config.htmlMode ? "html" : "xml",
381
+
382
+ skipAttribute: function(state) {
383
+ if (state.state == attrValueState)
384
+ state.state = attrState
385
+ }
377
386
  };
378
387
  });
379
388
 
@@ -40,7 +40,7 @@
40
40
  state.state = FRONTMATTER
41
41
  return yamlMode.token(stream, state.inner)
42
42
  } else {
43
- stream.state = BODY
43
+ state.state = BODY
44
44
  state.inner = CodeMirror.startState(innerMode)
45
45
  return innerMode.token(stream, state.inner)
46
46
  }
@@ -15,7 +15,7 @@
15
15
  }
16
16
 
17
17
  .cm-tw-box {
18
- border-top-width: 0px ! important;
18
+ border-top-width: 0px !important;
19
19
  border-style: solid;
20
20
  border-width: 1px;
21
21
  border-color: inherit;
@@ -33,5 +33,5 @@
33
33
  .cm-s-mbo span.cm-qualifier { color: #ffffec; }
34
34
 
35
35
  .cm-s-mbo .CodeMirror-activeline-background { background: #494b41; }
36
- .cm-s-mbo .CodeMirror-matchingbracket { color: #222 !important; }
36
+ .cm-s-mbo .CodeMirror-matchingbracket { color: #ffb928 !important; }
37
37
  .cm-s-mbo .CodeMirror-matchingtag { background: rgba(255, 255, 255, .37); }
@@ -16,6 +16,7 @@
16
16
 
17
17
  .cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute { color: #a6e22e; }
18
18
  .cm-s-monokai span.cm-keyword { color: #f92672; }
19
+ .cm-s-monokai span.cm-builtin { color: #66d9ef; }
19
20
  .cm-s-monokai span.cm-string { color: #e6db74; }
20
21
 
21
22
  .cm-s-monokai span.cm-variable { color: #f8f8f2; }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codemirror-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: '5.10'
4
+ version: '5.11'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Fixler
@@ -306,6 +306,7 @@ files:
306
306
  - vendor/assets/javascripts/codemirror/modes/groovy.js
307
307
  - vendor/assets/javascripts/codemirror/modes/haml.js
308
308
  - vendor/assets/javascripts/codemirror/modes/handlebars.js
309
+ - vendor/assets/javascripts/codemirror/modes/haskell-literate.js
309
310
  - vendor/assets/javascripts/codemirror/modes/haskell.js
310
311
  - vendor/assets/javascripts/codemirror/modes/haxe.js
311
312
  - vendor/assets/javascripts/codemirror/modes/htmlembedded.js
@@ -315,6 +316,7 @@ files:
315
316
  - vendor/assets/javascripts/codemirror/modes/jade.js
316
317
  - vendor/assets/javascripts/codemirror/modes/javascript.js
317
318
  - vendor/assets/javascripts/codemirror/modes/jinja2.js
319
+ - vendor/assets/javascripts/codemirror/modes/jsx.js
318
320
  - vendor/assets/javascripts/codemirror/modes/julia.js
319
321
  - vendor/assets/javascripts/codemirror/modes/livescript.js
320
322
  - vendor/assets/javascripts/codemirror/modes/lua.js