hyde_admin 0.0.1 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +3 -0
  3. data/.idea/hyde_admin.iml +2 -0
  4. data/.idea/vcs.xml +6 -0
  5. data/CHANGELOG.md +35 -0
  6. data/README.md +23 -0
  7. data/TODO.md +3 -0
  8. data/bin/admin_views/admin_layout.html.erb +204 -108
  9. data/bin/admin_views/configuration.erb +13 -0
  10. data/bin/admin_views/dashboard.erb +1 -1
  11. data/bin/admin_views/editor_html.erb +24 -0
  12. data/bin/admin_views/editor_js.erb +120 -0
  13. data/bin/admin_views/files/edit.erb +30 -0
  14. data/bin/admin_views/files/listing.erb +111 -0
  15. data/bin/admin_views/partials/image_element.html.erb +4 -0
  16. data/bin/admin_views/partials/images_page.html.erb +8 -0
  17. data/bin/admin_views/posts/edit.erb +158 -0
  18. data/bin/admin_views/posts/listing.erb +37 -0
  19. data/bin/admin_views/upload_image_form.erb +45 -0
  20. data/bin/fslightbox/fslightbox.js +1 -0
  21. data/bin/hyde_admin +3 -0
  22. data/bin/hyde_admin.ru +306 -56
  23. data/bin/hyde_admin.yml +12 -5
  24. data/bin/hyde_assets/hyde_admin.css +37 -0
  25. data/bin/hyde_assets/hyde_admin.js +24 -0
  26. data/bin/i18n/en.yml +77 -1
  27. data/bin/i18n/fr.yml +77 -1
  28. data/bin/lib/codemirror.css +349 -0
  29. data/bin/lib/codemirror.js +9833 -0
  30. data/bin/mode/css/css.js +864 -0
  31. data/bin/mode/css/gss.html +104 -0
  32. data/bin/mode/css/gss_test.js +17 -0
  33. data/bin/mode/css/index.html +81 -0
  34. data/bin/mode/css/less.html +152 -0
  35. data/bin/mode/css/less_test.js +54 -0
  36. data/bin/mode/css/scss.html +158 -0
  37. data/bin/mode/css/scss_test.js +110 -0
  38. data/bin/mode/css/test.js +217 -0
  39. data/bin/mode/htmlembedded/htmlembedded.js +37 -0
  40. data/bin/mode/htmlembedded/index.html +60 -0
  41. data/bin/mode/htmlmixed/htmlmixed.js +153 -0
  42. data/bin/mode/htmlmixed/index.html +100 -0
  43. data/bin/mode/javascript/index.html +118 -0
  44. data/bin/mode/javascript/javascript.js +959 -0
  45. data/bin/mode/javascript/json-ld.html +72 -0
  46. data/bin/mode/javascript/test.js +521 -0
  47. data/bin/mode/javascript/typescript.html +62 -0
  48. data/bin/mode/markdown/index.html +418 -0
  49. data/bin/mode/markdown/markdown.js +886 -0
  50. data/bin/mode/markdown/test.js +1319 -0
  51. data/bin/mode/ruby/index.html +183 -0
  52. data/bin/mode/ruby/ruby.js +303 -0
  53. data/bin/mode/ruby/test.js +23 -0
  54. data/bin/mode/sass/index.html +68 -0
  55. data/bin/mode/sass/sass.js +459 -0
  56. data/bin/mode/sass/test.js +122 -0
  57. data/bin/mode/spreadsheet/index.html +42 -0
  58. data/bin/mode/spreadsheet/spreadsheet.js +112 -0
  59. data/bin/mode/xml/index.html +61 -0
  60. data/bin/mode/xml/test.js +51 -0
  61. data/bin/mode/xml/xml.js +417 -0
  62. data/bin/mode/yaml/index.html +80 -0
  63. data/bin/mode/yaml/yaml.js +120 -0
  64. data/bin/mode/yaml-frontmatter/index.html +121 -0
  65. data/bin/mode/yaml-frontmatter/yaml-frontmatter.js +72 -0
  66. data/hyde_admin.gemspec +7 -1
  67. data/lib/hyde_admin/version.rb +1 -1
  68. metadata +131 -7
  69. data/bin/admin_views/edit.erb +0 -57
  70. data/bin/admin_views/listing.erb +0 -32
  71. data/bin/hyde_admin.sh +0 -3
@@ -0,0 +1,72 @@
1
+ <!doctype html>
2
+
3
+ <title>CodeMirror: JSON-LD mode</title>
4
+ <meta charset="utf-8"/>
5
+ <link rel=stylesheet href="../../doc/docs.css">
6
+
7
+ <link rel="stylesheet" href="../../lib/codemirror.css">
8
+ <script src="../../lib/codemirror.js"></script>
9
+ <script src="../../addon/edit/matchbrackets.js"></script>
10
+ <script src="../../addon/comment/continuecomment.js"></script>
11
+ <script src="../../addon/comment/comment.js"></script>
12
+ <script src="javascript.js"></script>
13
+ <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14
+ <div id="nav">
15
+ <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>
16
+
17
+ <ul>
18
+ <li><a href="../../index.html">Home</a>
19
+ <li><a href="../../doc/manual.html">Manual</a>
20
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
21
+ </ul>
22
+ <ul>
23
+ <li><a href="../index.html">Language modes</a>
24
+ <li><a class=active href="#">JSON-LD</a>
25
+ </ul>
26
+ </div>
27
+
28
+ <article>
29
+ <h2>JSON-LD mode</h2>
30
+
31
+
32
+ <div><textarea id="code" name="code">
33
+ {
34
+ "@context": {
35
+ "name": "http://schema.org/name",
36
+ "description": "http://schema.org/description",
37
+ "image": {
38
+ "@id": "http://schema.org/image",
39
+ "@type": "@id"
40
+ },
41
+ "geo": "http://schema.org/geo",
42
+ "latitude": {
43
+ "@id": "http://schema.org/latitude",
44
+ "@type": "xsd:float"
45
+ },
46
+ "longitude": {
47
+ "@id": "http://schema.org/longitude",
48
+ "@type": "xsd:float"
49
+ },
50
+ "xsd": "http://www.w3.org/2001/XMLSchema#"
51
+ },
52
+ "name": "The Empire State Building",
53
+ "description": "The Empire State Building is a 102-story landmark in New York City.",
54
+ "image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
55
+ "geo": {
56
+ "latitude": "40.75",
57
+ "longitude": "73.98"
58
+ }
59
+ }
60
+ </textarea></div>
61
+
62
+ <script>
63
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
64
+ matchBrackets: true,
65
+ autoCloseBrackets: true,
66
+ mode: "application/ld+json",
67
+ lineWrapping: true
68
+ });
69
+ </script>
70
+
71
+ <p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
72
+ </article>
@@ -0,0 +1,521 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: https://codemirror.net/LICENSE
3
+
4
+ (function() {
5
+ var mode = CodeMirror.getMode({indentUnit: 2}, "javascript");
6
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
7
+
8
+ MT("locals",
9
+ "[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
10
+
11
+ MT("comma-and-binop",
12
+ "[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");
13
+
14
+ MT("destructuring",
15
+ "([keyword function]([def a], [[[def b], [def c] ]]) {",
16
+ " [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);",
17
+ " [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
18
+ "})();");
19
+
20
+ MT("destructure_trailing_comma",
21
+ "[keyword let] {[def a], [def b],} [operator =] [variable foo];",
22
+ "[keyword let] [def c];"); // Parser still in good state?
23
+
24
+ MT("class_body",
25
+ "[keyword class] [def Foo] {",
26
+ " [property constructor]() {}",
27
+ " [property sayName]() {",
28
+ " [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",
29
+ " }",
30
+ "}");
31
+
32
+ MT("class",
33
+ "[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
34
+ " [keyword get] [property prop]() { [keyword return] [number 24]; }",
35
+ " [property constructor]([def x], [def y]) {",
36
+ " [keyword super]([string 'something']);",
37
+ " [keyword this].[property x] [operator =] [variable-2 x];",
38
+ " }",
39
+ "}");
40
+
41
+ MT("anonymous_class_expression",
42
+ "[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {",
43
+ " [property add]([def a], [def b]) {}",
44
+ "};");
45
+
46
+ MT("named_class_expression",
47
+ "[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {",
48
+ " [property sub]([def a], [def b]) {}",
49
+ "};");
50
+
51
+ MT("class_async_method",
52
+ "[keyword class] [def Foo] {",
53
+ " [property sayName1]() {}",
54
+ " [keyword async] [property sayName2]() {}",
55
+ "}");
56
+
57
+ MT("import",
58
+ "[keyword function] [def foo]() {",
59
+ " [keyword import] [def $] [keyword from] [string 'jquery'];",
60
+ " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
61
+ "}");
62
+
63
+ MT("import_trailing_comma",
64
+ "[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']")
65
+
66
+ MT("import_dynamic",
67
+ "[keyword import]([string 'baz']).[property then]")
68
+
69
+ MT("import_dynamic",
70
+ "[keyword const] [def t] [operator =] [keyword import]([string 'baz']).[property then]")
71
+
72
+ MT("const",
73
+ "[keyword function] [def f]() {",
74
+ " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
75
+ "}");
76
+
77
+ MT("for/of",
78
+ "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}");
79
+
80
+ MT("for await",
81
+ "[keyword for] [keyword await]([keyword let] [def of] [keyword of] [variable something]) {}");
82
+
83
+ MT("generator",
84
+ "[keyword function*] [def repeat]([def n]) {",
85
+ " [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
86
+ " [keyword yield] [variable-2 i];",
87
+ "}");
88
+
89
+ MT("let_scoping",
90
+ "[keyword function] [def scoped]([def n]) {",
91
+ " { [keyword var] [def i]; } [variable-2 i];",
92
+ " { [keyword let] [def j]; [variable-2 j]; } [variable j];",
93
+ " [keyword if] ([atom true]) { [keyword const] [def k]; [variable-2 k]; } [variable k];",
94
+ "}");
95
+
96
+ MT("switch_scoping",
97
+ "[keyword switch] ([variable x]) {",
98
+ " [keyword default]:",
99
+ " [keyword let] [def j];",
100
+ " [keyword return] [variable-2 j]",
101
+ "}",
102
+ "[variable j];")
103
+
104
+ MT("leaving_scope",
105
+ "[keyword function] [def a]() {",
106
+ " {",
107
+ " [keyword const] [def x] [operator =] [number 1]",
108
+ " [keyword if] ([atom true]) {",
109
+ " [keyword let] [def y] [operator =] [number 2]",
110
+ " [keyword var] [def z] [operator =] [number 3]",
111
+ " [variable console].[property log]([variable-2 x], [variable-2 y], [variable-2 z])",
112
+ " }",
113
+ " [variable console].[property log]([variable-2 x], [variable y], [variable-2 z])",
114
+ " }",
115
+ " [variable console].[property log]([variable x], [variable y], [variable-2 z])",
116
+ "}")
117
+
118
+ MT("quotedStringAddition",
119
+ "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
120
+
121
+ MT("quotedFatArrow",
122
+ "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
123
+
124
+ MT("fatArrow",
125
+ "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
126
+ "[variable a];", // No longer in scope
127
+ "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
128
+ "[variable c];");
129
+
130
+ MT("fatArrow_stringDefault",
131
+ "([def a], [def b] [operator =] [string 'x\\'y']) [operator =>] [variable-2 a] [operator +] [variable-2 b]")
132
+
133
+ MT("spread",
134
+ "[keyword function] [def f]([def a], [meta ...][def b]) {",
135
+ " [variable something]([variable-2 a], [meta ...][variable-2 b]);",
136
+ "}");
137
+
138
+ MT("quasi",
139
+ "[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
140
+
141
+ MT("quasi_no_function",
142
+ "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
143
+
144
+ MT("indent_statement",
145
+ "[keyword var] [def x] [operator =] [number 10]",
146
+ "[variable x] [operator +=] [variable y] [operator +]",
147
+ " [atom Infinity]",
148
+ "[keyword debugger];");
149
+
150
+ MT("indent_if",
151
+ "[keyword if] ([number 1])",
152
+ " [keyword break];",
153
+ "[keyword else] [keyword if] ([number 2])",
154
+ " [keyword continue];",
155
+ "[keyword else]",
156
+ " [number 10];",
157
+ "[keyword if] ([number 1]) {",
158
+ " [keyword break];",
159
+ "} [keyword else] [keyword if] ([number 2]) {",
160
+ " [keyword continue];",
161
+ "} [keyword else] {",
162
+ " [number 10];",
163
+ "}");
164
+
165
+ MT("indent_for",
166
+ "[keyword for] ([keyword var] [def i] [operator =] [number 0];",
167
+ " [variable-2 i] [operator <] [number 100];",
168
+ " [variable-2 i][operator ++])",
169
+ " [variable doSomething]([variable-2 i]);",
170
+ "[keyword debugger];");
171
+
172
+ MT("indent_c_style",
173
+ "[keyword function] [def foo]()",
174
+ "{",
175
+ " [keyword debugger];",
176
+ "}");
177
+
178
+ MT("indent_else",
179
+ "[keyword for] (;;)",
180
+ " [keyword if] ([variable foo])",
181
+ " [keyword if] ([variable bar])",
182
+ " [number 1];",
183
+ " [keyword else]",
184
+ " [number 2];",
185
+ " [keyword else]",
186
+ " [number 3];");
187
+
188
+ MT("indent_funarg",
189
+ "[variable foo]([number 10000],",
190
+ " [keyword function]([def a]) {",
191
+ " [keyword debugger];",
192
+ "};");
193
+
194
+ MT("indent_below_if",
195
+ "[keyword for] (;;)",
196
+ " [keyword if] ([variable foo])",
197
+ " [number 1];",
198
+ "[number 2];");
199
+
200
+ MT("indent_semicolonless_if",
201
+ "[keyword function] [def foo]() {",
202
+ " [keyword if] ([variable x])",
203
+ " [variable foo]()",
204
+ "}")
205
+
206
+ MT("indent_semicolonless_if_with_statement",
207
+ "[keyword function] [def foo]() {",
208
+ " [keyword if] ([variable x])",
209
+ " [variable foo]()",
210
+ " [variable bar]()",
211
+ "}")
212
+
213
+ MT("multilinestring",
214
+ "[keyword var] [def x] [operator =] [string 'foo\\]",
215
+ "[string bar'];");
216
+
217
+ MT("scary_regexp",
218
+ "[string-2 /foo[[/]]bar/];");
219
+
220
+ MT("indent_strange_array",
221
+ "[keyword var] [def x] [operator =] [[",
222
+ " [number 1],,",
223
+ " [number 2],",
224
+ "]];",
225
+ "[number 10];");
226
+
227
+ MT("param_default",
228
+ "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
229
+ " [keyword return] [variable-2 x];",
230
+ "}");
231
+
232
+ MT(
233
+ "param_destructuring",
234
+ "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
235
+ " [keyword return] [variable-2 x];",
236
+ "}");
237
+
238
+ MT("new_target",
239
+ "[keyword function] [def F]([def target]) {",
240
+ " [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
241
+ " [keyword return] [keyword new]",
242
+ " .[keyword target];",
243
+ " }",
244
+ "}");
245
+
246
+ MT("async",
247
+ "[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
248
+
249
+ MT("async_assignment",
250
+ "[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };");
251
+
252
+ MT("async_object",
253
+ "[keyword let] [def obj] [operator =] { [property async]: [atom false] };");
254
+
255
+ // async be highlighted as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173
256
+ MT("async_object_function",
257
+ "[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };");
258
+
259
+ MT("async_object_properties",
260
+ "[keyword let] [def obj] [operator =] {",
261
+ " [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
262
+ " [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
263
+ " [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },",
264
+ "};");
265
+
266
+ MT("async_arrow",
267
+ "[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };");
268
+
269
+ MT("async_jquery",
270
+ "[variable $].[property ajax]({",
271
+ " [property url]: [variable url],",
272
+ " [property async]: [atom true],",
273
+ " [property method]: [string 'GET']",
274
+ "});");
275
+
276
+ MT("async_variable",
277
+ "[keyword const] [def async] [operator =] {[property a]: [number 1]};",
278
+ "[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];")
279
+
280
+ MT("bigint", "[number 1n] [operator +] [number 0x1afn] [operator +] [number 0o064n] [operator +] [number 0b100n];")
281
+
282
+ MT("async_comment",
283
+ "[keyword async] [comment /**/] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
284
+
285
+ MT("indent_switch",
286
+ "[keyword switch] ([variable x]) {",
287
+ " [keyword default]:",
288
+ " [keyword return] [number 2]",
289
+ "}")
290
+
291
+ MT("regexp_corner_case",
292
+ "[operator +]{} [operator /] [atom undefined];",
293
+ "[[[meta ...][string-2 /\\//] ]];",
294
+ "[keyword void] [string-2 /\\//];",
295
+ "[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);",
296
+ "[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];",
297
+ "[string-2 `${][variable async][operator ++][string-2 }//`];",
298
+ "[string-2 `${]{} [operator /] [string-2 /\\//}`];")
299
+
300
+ MT("return_eol",
301
+ "[keyword return]",
302
+ "{} [string-2 /5/]")
303
+
304
+ MT("numeric separator",
305
+ "[number 123_456];",
306
+ "[number 0xdead_c0de];",
307
+ "[number 0o123_456];",
308
+ "[number 0b1101_1101];",
309
+ "[number .123_456e0_1];",
310
+ "[number 1E+123_456];",
311
+ "[number 12_34_56n];")
312
+
313
+ MT("underscore property",
314
+ "[variable something].[property _property];",
315
+ "[variable something].[property _123];",
316
+ "[variable something].[property _for];",
317
+ "[variable _for];",
318
+ "[variable _123];")
319
+
320
+ MT("private properties",
321
+ "[keyword class] [def C] {",
322
+ " [property #x] [operator =] [number 2];",
323
+ " [property #read]() {",
324
+ " [keyword return] [keyword this].[property #x]",
325
+ " }",
326
+ "}")
327
+
328
+ var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
329
+ function TS(name) {
330
+ test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
331
+ }
332
+
333
+ TS("typescript_extend_type",
334
+ "[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}")
335
+
336
+ TS("typescript_arrow_type",
337
+ "[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]")
338
+
339
+ TS("typescript_class",
340
+ "[keyword class] [def Foo] {",
341
+ " [keyword public] [keyword static] [property main]() {}",
342
+ " [keyword private] [property _foo]: [type string];",
343
+ "}")
344
+
345
+ TS("typescript_literal_types",
346
+ "[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];",
347
+ "[keyword interface] [def MyAttributes] {",
348
+ " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
349
+ " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
350
+ "}",
351
+ "[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {",
352
+ " [property rawAttributes]: [type MyAttributes];",
353
+ " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
354
+ " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
355
+ "}")
356
+
357
+ TS("typescript_extend_operators",
358
+ "[keyword export] [keyword interface] [def UserModel] [keyword extends]",
359
+ " [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {",
360
+ " [property findById]: (",
361
+ " [variable userId]: [type number]",
362
+ " ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];",
363
+ " [property updateById]: (",
364
+ " [variable userId]: [type number],",
365
+ " [variable isActive]: [type boolean]",
366
+ " ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];",
367
+ " }")
368
+
369
+ TS("typescript_interface_with_const",
370
+ "[keyword const] [def hello]: {",
371
+ " [property prop1][operator ?]: [type string];",
372
+ " [property prop2][operator ?]: [type string];",
373
+ "} [operator =] {};")
374
+
375
+ TS("typescript_double_extend",
376
+ "[keyword export] [keyword interface] [def UserAttributes] {",
377
+ " [property id][operator ?]: [type number];",
378
+ " [property createdAt][operator ?]: [type Date];",
379
+ "}",
380
+ "[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {",
381
+ " [property id]: [type number];",
382
+ " [property createdAt]: [type Date];",
383
+ "}");
384
+
385
+ TS("typescript_index_signature",
386
+ "[keyword interface] [def A] {",
387
+ " [[ [variable prop]: [type string] ]]: [type any];",
388
+ " [property prop1]: [type any];",
389
+ "}");
390
+
391
+ TS("typescript_generic_class",
392
+ "[keyword class] [def Foo][operator <][type T][operator >] {",
393
+ " [property bar]() {}",
394
+ " [property foo](): [type Foo] {}",
395
+ "}")
396
+
397
+ TS("typescript_type_when_keyword",
398
+ "[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];",
399
+ "[keyword type] [type Flags] [operator =] {",
400
+ " [property p1]: [type string];",
401
+ " [property p2]: [type boolean];",
402
+ "};")
403
+
404
+ TS("typescript_type_when_not_keyword",
405
+ "[keyword class] [def HasType] {",
406
+ " [property type]: [type string];",
407
+ " [property constructor]([def type]: [type string]) {",
408
+ " [keyword this].[property type] [operator =] [variable-2 type];",
409
+ " }",
410
+ " [property setType]({ [def type] }: { [property type]: [type string]; }) {",
411
+ " [keyword this].[property type] [operator =] [variable-2 type];",
412
+ " }",
413
+ "}")
414
+
415
+ TS("typescript_function_generics",
416
+ "[keyword function] [def a]() {}",
417
+ "[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}",
418
+ "[keyword function] [def c]() {}")
419
+
420
+ TS("typescript_complex_return_type",
421
+ "[keyword function] [def A]() {",
422
+ " [keyword return] [keyword this].[property property];",
423
+ "}",
424
+ "[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {",
425
+ " [keyword return] [keyword this].[property property];",
426
+ "}")
427
+
428
+ TS("typescript_complex_type_casting",
429
+ "[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };")
430
+
431
+ TS("typescript_keyof",
432
+ "[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {",
433
+ " [keyword return]")
434
+
435
+ TS("typescript_new_typeargs",
436
+ "[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])")
437
+
438
+ TS("modifiers",
439
+ "[keyword class] [def Foo] {",
440
+ " [keyword public] [keyword abstract] [property bar]() {}",
441
+ " [property constructor]([keyword readonly] [keyword private] [def x]) {}",
442
+ "}")
443
+
444
+ TS("arrow prop",
445
+ "({[property a]: [def p] [operator =>] [variable-2 p]})")
446
+
447
+ TS("generic in function call",
448
+ "[keyword this].[property a][operator <][type Type][operator >]([variable foo]);",
449
+ "[keyword this].[property a][operator <][variable Type][operator >][variable foo];")
450
+
451
+ TS("type guard",
452
+ "[keyword class] [def Appler] {",
453
+ " [keyword static] [property assertApple]([def fruit]: [type Fruit]): [variable-2 fruit] [keyword is] [type Apple] {",
454
+ " [keyword if] ([operator !]([variable-2 fruit] [keyword instanceof] [variable Apple]))",
455
+ " [keyword throw] [keyword new] [variable Error]();",
456
+ " }",
457
+ "}")
458
+
459
+ TS("type as variable",
460
+ "[variable type] [operator =] [variable x] [keyword as] [type Bar];");
461
+
462
+ TS("enum body",
463
+ "[keyword export] [keyword const] [keyword enum] [def CodeInspectionResultType] {",
464
+ " [def ERROR] [operator =] [string 'problem_type_error'],",
465
+ " [def WARNING] [operator =] [string 'problem_type_warning'],",
466
+ " [def META],",
467
+ "}")
468
+
469
+ TS("parenthesized type",
470
+ "[keyword class] [def Foo] {",
471
+ " [property x] [operator =] [keyword new] [variable A][operator <][type B], [type string][operator |](() [operator =>] [type void])[operator >]();",
472
+ " [keyword private] [property bar]();",
473
+ "}")
474
+
475
+ TS("abstract class",
476
+ "[keyword export] [keyword abstract] [keyword class] [def Foo] {}")
477
+
478
+ TS("interface without semicolons",
479
+ "[keyword interface] [def Foo] {",
480
+ " [property greet]([def x]: [type int]): [type blah]",
481
+ " [property bar]: [type void]",
482
+ "}")
483
+
484
+ var jsonld_mode = CodeMirror.getMode(
485
+ {indentUnit: 2},
486
+ {name: "javascript", jsonld: true}
487
+ );
488
+ function LD(name) {
489
+ test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1));
490
+ }
491
+
492
+ LD("json_ld_keywords",
493
+ '{',
494
+ ' [meta "@context"]: {',
495
+ ' [meta "@base"]: [string "http://example.com"],',
496
+ ' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],',
497
+ ' [property "likesFlavor"]: {',
498
+ ' [meta "@container"]: [meta "@list"]',
499
+ ' [meta "@reverse"]: [string "@beFavoriteOf"]',
500
+ ' },',
501
+ ' [property "nick"]: { [meta "@container"]: [meta "@set"] },',
502
+ ' [property "nick"]: { [meta "@container"]: [meta "@index"] }',
503
+ ' },',
504
+ ' [meta "@graph"]: [[ {',
505
+ ' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],',
506
+ ' [property "name"]: [string "John Lennon"],',
507
+ ' [property "modified"]: {',
508
+ ' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],',
509
+ ' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]',
510
+ ' }',
511
+ ' } ]]',
512
+ '}');
513
+
514
+ LD("json_ld_fake",
515
+ '{',
516
+ ' [property "@fake"]: [string "@fake"],',
517
+ ' [property "@contextual"]: [string "@identifier"],',
518
+ ' [property "user@domain.com"]: [string "@graphical"],',
519
+ ' [property "@ID"]: [string "@@ID"]',
520
+ '}');
521
+ })();
@@ -0,0 +1,62 @@
1
+ <!doctype html>
2
+
3
+ <title>CodeMirror: TypeScript mode</title>
4
+ <meta charset="utf-8"/>
5
+ <link rel=stylesheet href="../../doc/docs.css">
6
+
7
+ <link rel="stylesheet" href="../../lib/codemirror.css">
8
+ <script src="../../lib/codemirror.js"></script>
9
+ <script src="../../addon/edit/matchbrackets.js"></script>
10
+ <script src="javascript.js"></script>
11
+ <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12
+ <div id=nav>
13
+ <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
14
+
15
+ <ul>
16
+ <li><a href="../../index.html">Home</a>
17
+ <li><a href="../../doc/manual.html">Manual</a>
18
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
19
+ </ul>
20
+ <ul>
21
+ <li><a href="../index.html">Language modes</a>
22
+ <li><a class=active href="#">TypeScript</a>
23
+ </ul>
24
+ </div>
25
+
26
+ <article>
27
+ <h2>TypeScript mode</h2>
28
+
29
+
30
+ <div><textarea id="code" name="code">
31
+ class Greeter {
32
+ greeting: string;
33
+ constructor (message: string) {
34
+ this.greeting = message;
35
+ }
36
+ greet() {
37
+ return "Hello, " + this.greeting;
38
+ }
39
+ }
40
+
41
+ var greeter = new Greeter("world");
42
+
43
+ var button = document.createElement('button')
44
+ button.innerText = "Say Hello"
45
+ button.onclick = function() {
46
+ alert(greeter.greet())
47
+ }
48
+
49
+ document.body.appendChild(button)
50
+
51
+ </textarea></div>
52
+
53
+ <script>
54
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
55
+ lineNumbers: true,
56
+ matchBrackets: true,
57
+ mode: "text/typescript"
58
+ });
59
+ </script>
60
+
61
+ <p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
62
+ </article>