Commit | Line | Data |
---|---|---|
44f4c339 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
373d1232 | 2 | // Distributed under an MIT license: https://codemirror.net/LICENSE |
44f4c339 | 3 | |
837afb80 TD |
4 | (function(mod) { |
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
44f4c339 | 6 | mod(require("../../lib/codemirror"), require("./xml-hint")); |
837afb80 | 7 | else if (typeof define == "function" && define.amd) // AMD |
44f4c339 | 8 | define(["../../lib/codemirror", "./xml-hint"], mod); |
837afb80 TD |
9 | else // Plain browser env |
10 | mod(CodeMirror); | |
11 | })(function(CodeMirror) { | |
12 | "use strict"; | |
77b7b761 | 13 | |
837afb80 TD |
14 | var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "); |
15 | var targets = ["_blank", "_self", "_top", "_parent"]; | |
16 | var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"]; | |
17 | var methods = ["get", "post", "put", "delete"]; | |
18 | var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]; | |
19 | var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech", | |
20 | "3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait", | |
21 | "orientation:landscape", "device-height: [X]", "device-width: [X]"]; | |
22 | var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags | |
77b7b761 | 23 | |
837afb80 TD |
24 | var data = { |
25 | a: { | |
26 | attrs: { | |
27 | href: null, ping: null, type: null, | |
28 | media: media, | |
29 | target: targets, | |
30 | hreflang: langs | |
77b7b761 | 31 | } |
837afb80 TD |
32 | }, |
33 | abbr: s, | |
34 | acronym: s, | |
35 | address: s, | |
36 | applet: s, | |
37 | area: { | |
38 | attrs: { | |
39 | alt: null, coords: null, href: null, target: null, ping: null, | |
40 | media: media, hreflang: langs, type: null, | |
41 | shape: ["default", "rect", "circle", "poly"] | |
77b7b761 | 42 | } |
837afb80 TD |
43 | }, |
44 | article: s, | |
45 | aside: s, | |
46 | audio: { | |
47 | attrs: { | |
48 | src: null, mediagroup: null, | |
49 | crossorigin: ["anonymous", "use-credentials"], | |
50 | preload: ["none", "metadata", "auto"], | |
51 | autoplay: ["", "autoplay"], | |
52 | loop: ["", "loop"], | |
53 | controls: ["", "controls"] | |
77b7b761 | 54 | } |
837afb80 TD |
55 | }, |
56 | b: s, | |
57 | base: { attrs: { href: null, target: targets } }, | |
58 | basefont: s, | |
59 | bdi: s, | |
60 | bdo: s, | |
61 | big: s, | |
62 | blockquote: { attrs: { cite: null } }, | |
63 | body: s, | |
64 | br: s, | |
65 | button: { | |
66 | attrs: { | |
67 | form: null, formaction: null, name: null, value: null, | |
68 | autofocus: ["", "autofocus"], | |
69 | disabled: ["", "autofocus"], | |
70 | formenctype: encs, | |
71 | formmethod: methods, | |
72 | formnovalidate: ["", "novalidate"], | |
73 | formtarget: targets, | |
74 | type: ["submit", "reset", "button"] | |
75 | } | |
76 | }, | |
77 | canvas: { attrs: { width: null, height: null } }, | |
78 | caption: s, | |
79 | center: s, | |
80 | cite: s, | |
81 | code: s, | |
82 | col: { attrs: { span: null } }, | |
83 | colgroup: { attrs: { span: null } }, | |
84 | command: { | |
85 | attrs: { | |
86 | type: ["command", "checkbox", "radio"], | |
87 | label: null, icon: null, radiogroup: null, command: null, title: null, | |
88 | disabled: ["", "disabled"], | |
89 | checked: ["", "checked"] | |
90 | } | |
91 | }, | |
92 | data: { attrs: { value: null } }, | |
93 | datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } }, | |
94 | datalist: { attrs: { data: null } }, | |
95 | dd: s, | |
96 | del: { attrs: { cite: null, datetime: null } }, | |
97 | details: { attrs: { open: ["", "open"] } }, | |
98 | dfn: s, | |
99 | dir: s, | |
100 | div: s, | |
704cb1bf | 101 | dialog: { attrs: { open: null } }, |
837afb80 TD |
102 | dl: s, |
103 | dt: s, | |
104 | em: s, | |
105 | embed: { attrs: { src: null, type: null, width: null, height: null } }, | |
106 | eventsource: { attrs: { src: null } }, | |
107 | fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } }, | |
108 | figcaption: s, | |
109 | figure: s, | |
110 | font: s, | |
111 | footer: s, | |
112 | form: { | |
113 | attrs: { | |
114 | action: null, name: null, | |
115 | "accept-charset": charsets, | |
116 | autocomplete: ["on", "off"], | |
117 | enctype: encs, | |
118 | method: methods, | |
119 | novalidate: ["", "novalidate"], | |
120 | target: targets | |
121 | } | |
122 | }, | |
123 | frame: s, | |
124 | frameset: s, | |
125 | h1: s, h2: s, h3: s, h4: s, h5: s, h6: s, | |
126 | head: { | |
127 | attrs: {}, | |
128 | children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"] | |
129 | }, | |
130 | header: s, | |
131 | hgroup: s, | |
132 | hr: s, | |
133 | html: { | |
134 | attrs: { manifest: null }, | |
135 | children: ["head", "body"] | |
136 | }, | |
137 | i: s, | |
138 | iframe: { | |
139 | attrs: { | |
140 | src: null, srcdoc: null, name: null, width: null, height: null, | |
141 | sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"], | |
142 | seamless: ["", "seamless"] | |
143 | } | |
144 | }, | |
145 | img: { | |
146 | attrs: { | |
147 | alt: null, src: null, ismap: null, usemap: null, width: null, height: null, | |
148 | crossorigin: ["anonymous", "use-credentials"] | |
149 | } | |
150 | }, | |
151 | input: { | |
152 | attrs: { | |
153 | alt: null, dirname: null, form: null, formaction: null, | |
154 | height: null, list: null, max: null, maxlength: null, min: null, | |
155 | name: null, pattern: null, placeholder: null, size: null, src: null, | |
156 | step: null, value: null, width: null, | |
157 | accept: ["audio/*", "video/*", "image/*"], | |
158 | autocomplete: ["on", "off"], | |
159 | autofocus: ["", "autofocus"], | |
160 | checked: ["", "checked"], | |
161 | disabled: ["", "disabled"], | |
162 | formenctype: encs, | |
163 | formmethod: methods, | |
164 | formnovalidate: ["", "novalidate"], | |
165 | formtarget: targets, | |
166 | multiple: ["", "multiple"], | |
167 | readonly: ["", "readonly"], | |
168 | required: ["", "required"], | |
169 | type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month", | |
170 | "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", | |
171 | "file", "submit", "image", "reset", "button"] | |
172 | } | |
173 | }, | |
174 | ins: { attrs: { cite: null, datetime: null } }, | |
175 | kbd: s, | |
176 | keygen: { | |
177 | attrs: { | |
178 | challenge: null, form: null, name: null, | |
179 | autofocus: ["", "autofocus"], | |
180 | disabled: ["", "disabled"], | |
181 | keytype: ["RSA"] | |
182 | } | |
183 | }, | |
184 | label: { attrs: { "for": null, form: null } }, | |
185 | legend: s, | |
186 | li: { attrs: { value: null } }, | |
187 | link: { | |
188 | attrs: { | |
189 | href: null, type: null, | |
190 | hreflang: langs, | |
191 | media: media, | |
192 | sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"] | |
193 | } | |
194 | }, | |
195 | map: { attrs: { name: null } }, | |
196 | mark: s, | |
197 | menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } }, | |
198 | meta: { | |
199 | attrs: { | |
200 | content: null, | |
201 | charset: charsets, | |
202 | name: ["viewport", "application-name", "author", "description", "generator", "keywords"], | |
203 | "http-equiv": ["content-language", "content-type", "default-style", "refresh"] | |
204 | } | |
205 | }, | |
206 | meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } }, | |
207 | nav: s, | |
208 | noframes: s, | |
209 | noscript: s, | |
210 | object: { | |
211 | attrs: { | |
212 | data: null, type: null, name: null, usemap: null, form: null, width: null, height: null, | |
213 | typemustmatch: ["", "typemustmatch"] | |
214 | } | |
215 | }, | |
216 | ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } }, | |
217 | optgroup: { attrs: { disabled: ["", "disabled"], label: null } }, | |
218 | option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } }, | |
219 | output: { attrs: { "for": null, form: null, name: null } }, | |
220 | p: s, | |
221 | param: { attrs: { name: null, value: null } }, | |
222 | pre: s, | |
223 | progress: { attrs: { value: null, max: null } }, | |
224 | q: { attrs: { cite: null } }, | |
225 | rp: s, | |
226 | rt: s, | |
227 | ruby: s, | |
228 | s: s, | |
229 | samp: s, | |
230 | script: { | |
231 | attrs: { | |
232 | type: ["text/javascript"], | |
233 | src: null, | |
234 | async: ["", "async"], | |
235 | defer: ["", "defer"], | |
236 | charset: charsets | |
237 | } | |
238 | }, | |
239 | section: s, | |
240 | select: { | |
241 | attrs: { | |
242 | form: null, name: null, size: null, | |
243 | autofocus: ["", "autofocus"], | |
244 | disabled: ["", "disabled"], | |
245 | multiple: ["", "multiple"] | |
246 | } | |
247 | }, | |
248 | small: s, | |
249 | source: { attrs: { src: null, type: null, media: null } }, | |
250 | span: s, | |
251 | strike: s, | |
252 | strong: s, | |
253 | style: { | |
254 | attrs: { | |
255 | type: ["text/css"], | |
256 | media: media, | |
257 | scoped: null | |
258 | } | |
259 | }, | |
260 | sub: s, | |
261 | summary: s, | |
262 | sup: s, | |
263 | table: s, | |
264 | tbody: s, | |
265 | td: { attrs: { colspan: null, rowspan: null, headers: null } }, | |
266 | textarea: { | |
267 | attrs: { | |
268 | dirname: null, form: null, maxlength: null, name: null, placeholder: null, | |
269 | rows: null, cols: null, | |
270 | autofocus: ["", "autofocus"], | |
271 | disabled: ["", "disabled"], | |
272 | readonly: ["", "readonly"], | |
273 | required: ["", "required"], | |
274 | wrap: ["soft", "hard"] | |
275 | } | |
276 | }, | |
277 | tfoot: s, | |
278 | th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } }, | |
279 | thead: s, | |
280 | time: { attrs: { datetime: null } }, | |
281 | title: s, | |
282 | tr: s, | |
283 | track: { | |
284 | attrs: { | |
285 | src: null, label: null, "default": null, | |
286 | kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"], | |
287 | srclang: langs | |
288 | } | |
289 | }, | |
290 | tt: s, | |
291 | u: s, | |
292 | ul: s, | |
293 | "var": s, | |
294 | video: { | |
295 | attrs: { | |
296 | src: null, poster: null, width: null, height: null, | |
297 | crossorigin: ["anonymous", "use-credentials"], | |
298 | preload: ["auto", "metadata", "none"], | |
299 | autoplay: ["", "autoplay"], | |
300 | mediagroup: ["movie"], | |
301 | muted: ["", "muted"], | |
302 | controls: ["", "controls"] | |
303 | } | |
304 | }, | |
305 | wbr: s | |
77b7b761 TD |
306 | }; |
307 | ||
837afb80 TD |
308 | var globalAttrs = { |
309 | accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], | |
310 | "class": null, | |
311 | contenteditable: ["true", "false"], | |
312 | contextmenu: null, | |
313 | dir: ["ltr", "rtl", "auto"], | |
314 | draggable: ["true", "false", "auto"], | |
315 | dropzone: ["copy", "move", "link", "string:", "file:"], | |
316 | hidden: ["hidden"], | |
317 | id: null, | |
318 | inert: ["inert"], | |
319 | itemid: null, | |
320 | itemprop: null, | |
321 | itemref: null, | |
322 | itemscope: ["itemscope"], | |
323 | itemtype: null, | |
324 | lang: ["en", "es"], | |
325 | spellcheck: ["true", "false"], | |
373d1232 TD |
326 | autocorrect: ["true", "false"], |
327 | autocapitalize: ["true", "false"], | |
837afb80 TD |
328 | style: null, |
329 | tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], | |
330 | title: null, | |
331 | translate: ["yes", "no"], | |
332 | onclick: null, | |
333 | rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"] | |
334 | }; | |
335 | function populate(obj) { | |
336 | for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr)) | |
337 | obj.attrs[attr] = globalAttrs[attr]; | |
338 | } | |
77b7b761 | 339 | |
837afb80 TD |
340 | populate(s); |
341 | for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s) | |
342 | populate(data[tag]); | |
77b7b761 | 343 | |
837afb80 TD |
344 | CodeMirror.htmlSchema = data; |
345 | function htmlHint(cm, options) { | |
346 | var local = {schemaInfo: data}; | |
347 | if (options) for (var opt in options) local[opt] = options[opt]; | |
348 | return CodeMirror.hint.xml(cm, local); | |
349 | } | |
350 | CodeMirror.registerHelper("hint", "html", htmlHint); | |
351 | }); |