html-hint.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. (function(mod) {
  4. if (typeof exports == "object" && typeof module == "object") // CommonJS
  5. mod(require("../../lib/codemirror"), require("./xml-hint"));
  6. else if (typeof define == "function" && define.amd) // AMD
  7. define(["../../lib/codemirror", "./xml-hint"], mod);
  8. else // Plain browser env
  9. mod(CodeMirror);
  10. })(function(CodeMirror) {
  11. "use strict";
  12. 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(" ");
  13. var targets = ["_blank", "_self", "_top", "_parent"];
  14. var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
  15. var methods = ["get", "post", "put", "delete"];
  16. var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
  17. var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech",
  18. "3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait",
  19. "orientation:landscape", "device-height: [X]", "device-width: [X]"];
  20. var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags
  21. var data = {
  22. a: {
  23. attrs: {
  24. href: null, ping: null, type: null,
  25. media: media,
  26. target: targets,
  27. hreflang: langs
  28. }
  29. },
  30. abbr: s,
  31. acronym: s,
  32. address: s,
  33. applet: s,
  34. area: {
  35. attrs: {
  36. alt: null, coords: null, href: null, target: null, ping: null,
  37. media: media, hreflang: langs, type: null,
  38. shape: ["default", "rect", "circle", "poly"]
  39. }
  40. },
  41. article: s,
  42. aside: s,
  43. audio: {
  44. attrs: {
  45. src: null, mediagroup: null,
  46. crossorigin: ["anonymous", "use-credentials"],
  47. preload: ["none", "metadata", "auto"],
  48. autoplay: ["", "autoplay"],
  49. loop: ["", "loop"],
  50. controls: ["", "controls"]
  51. }
  52. },
  53. b: s,
  54. base: { attrs: { href: null, target: targets } },
  55. basefont: s,
  56. bdi: s,
  57. bdo: s,
  58. big: s,
  59. blockquote: { attrs: { cite: null } },
  60. body: s,
  61. br: s,
  62. button: {
  63. attrs: {
  64. form: null, formaction: null, name: null, value: null,
  65. autofocus: ["", "autofocus"],
  66. disabled: ["", "autofocus"],
  67. formenctype: encs,
  68. formmethod: methods,
  69. formnovalidate: ["", "novalidate"],
  70. formtarget: targets,
  71. type: ["submit", "reset", "button"]
  72. }
  73. },
  74. canvas: { attrs: { width: null, height: null } },
  75. caption: s,
  76. center: s,
  77. cite: s,
  78. code: s,
  79. col: { attrs: { span: null } },
  80. colgroup: { attrs: { span: null } },
  81. command: {
  82. attrs: {
  83. type: ["command", "checkbox", "radio"],
  84. label: null, icon: null, radiogroup: null, command: null, title: null,
  85. disabled: ["", "disabled"],
  86. checked: ["", "checked"]
  87. }
  88. },
  89. data: { attrs: { value: null } },
  90. datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } },
  91. datalist: { attrs: { data: null } },
  92. dd: s,
  93. del: { attrs: { cite: null, datetime: null } },
  94. details: { attrs: { open: ["", "open"] } },
  95. dfn: s,
  96. dir: s,
  97. div: s,
  98. dl: s,
  99. dt: s,
  100. em: s,
  101. embed: { attrs: { src: null, type: null, width: null, height: null } },
  102. eventsource: { attrs: { src: null } },
  103. fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } },
  104. figcaption: s,
  105. figure: s,
  106. font: s,
  107. footer: s,
  108. form: {
  109. attrs: {
  110. action: null, name: null,
  111. "accept-charset": charsets,
  112. autocomplete: ["on", "off"],
  113. enctype: encs,
  114. method: methods,
  115. novalidate: ["", "novalidate"],
  116. target: targets
  117. }
  118. },
  119. frame: s,
  120. frameset: s,
  121. h1: s, h2: s, h3: s, h4: s, h5: s, h6: s,
  122. head: {
  123. attrs: {},
  124. children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
  125. },
  126. header: s,
  127. hgroup: s,
  128. hr: s,
  129. html: {
  130. attrs: { manifest: null },
  131. children: ["head", "body"]
  132. },
  133. i: s,
  134. iframe: {
  135. attrs: {
  136. src: null, srcdoc: null, name: null, width: null, height: null,
  137. sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
  138. seamless: ["", "seamless"]
  139. }
  140. },
  141. img: {
  142. attrs: {
  143. alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
  144. crossorigin: ["anonymous", "use-credentials"]
  145. }
  146. },
  147. input: {
  148. attrs: {
  149. alt: null, dirname: null, form: null, formaction: null,
  150. height: null, list: null, max: null, maxlength: null, min: null,
  151. name: null, pattern: null, placeholder: null, size: null, src: null,
  152. step: null, value: null, width: null,
  153. accept: ["audio/*", "video/*", "image/*"],
  154. autocomplete: ["on", "off"],
  155. autofocus: ["", "autofocus"],
  156. checked: ["", "checked"],
  157. disabled: ["", "disabled"],
  158. formenctype: encs,
  159. formmethod: methods,
  160. formnovalidate: ["", "novalidate"],
  161. formtarget: targets,
  162. multiple: ["", "multiple"],
  163. readonly: ["", "readonly"],
  164. required: ["", "required"],
  165. type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
  166. "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
  167. "file", "submit", "image", "reset", "button"]
  168. }
  169. },
  170. ins: { attrs: { cite: null, datetime: null } },
  171. kbd: s,
  172. keygen: {
  173. attrs: {
  174. challenge: null, form: null, name: null,
  175. autofocus: ["", "autofocus"],
  176. disabled: ["", "disabled"],
  177. keytype: ["RSA"]
  178. }
  179. },
  180. label: { attrs: { "for": null, form: null } },
  181. legend: s,
  182. li: { attrs: { value: null } },
  183. link: {
  184. attrs: {
  185. href: null, type: null,
  186. hreflang: langs,
  187. media: media,
  188. sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
  189. }
  190. },
  191. map: { attrs: { name: null } },
  192. mark: s,
  193. menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
  194. meta: {
  195. attrs: {
  196. content: null,
  197. charset: charsets,
  198. name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
  199. "http-equiv": ["content-language", "content-type", "default-style", "refresh"]
  200. }
  201. },
  202. meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
  203. nav: s,
  204. noframes: s,
  205. noscript: s,
  206. object: {
  207. attrs: {
  208. data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
  209. typemustmatch: ["", "typemustmatch"]
  210. }
  211. },
  212. ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } },
  213. optgroup: { attrs: { disabled: ["", "disabled"], label: null } },
  214. option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } },
  215. output: { attrs: { "for": null, form: null, name: null } },
  216. p: s,
  217. param: { attrs: { name: null, value: null } },
  218. pre: s,
  219. progress: { attrs: { value: null, max: null } },
  220. q: { attrs: { cite: null } },
  221. rp: s,
  222. rt: s,
  223. ruby: s,
  224. s: s,
  225. samp: s,
  226. script: {
  227. attrs: {
  228. type: ["text/javascript"],
  229. src: null,
  230. async: ["", "async"],
  231. defer: ["", "defer"],
  232. charset: charsets
  233. }
  234. },
  235. section: s,
  236. select: {
  237. attrs: {
  238. form: null, name: null, size: null,
  239. autofocus: ["", "autofocus"],
  240. disabled: ["", "disabled"],
  241. multiple: ["", "multiple"]
  242. }
  243. },
  244. small: s,
  245. source: { attrs: { src: null, type: null, media: null } },
  246. span: s,
  247. strike: s,
  248. strong: s,
  249. style: {
  250. attrs: {
  251. type: ["text/css"],
  252. media: media,
  253. scoped: null
  254. }
  255. },
  256. sub: s,
  257. summary: s,
  258. sup: s,
  259. table: s,
  260. tbody: s,
  261. td: { attrs: { colspan: null, rowspan: null, headers: null } },
  262. textarea: {
  263. attrs: {
  264. dirname: null, form: null, maxlength: null, name: null, placeholder: null,
  265. rows: null, cols: null,
  266. autofocus: ["", "autofocus"],
  267. disabled: ["", "disabled"],
  268. readonly: ["", "readonly"],
  269. required: ["", "required"],
  270. wrap: ["soft", "hard"]
  271. }
  272. },
  273. tfoot: s,
  274. th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
  275. thead: s,
  276. time: { attrs: { datetime: null } },
  277. title: s,
  278. tr: s,
  279. track: {
  280. attrs: {
  281. src: null, label: null, "default": null,
  282. kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
  283. srclang: langs
  284. }
  285. },
  286. tt: s,
  287. u: s,
  288. ul: s,
  289. "var": s,
  290. video: {
  291. attrs: {
  292. src: null, poster: null, width: null, height: null,
  293. crossorigin: ["anonymous", "use-credentials"],
  294. preload: ["auto", "metadata", "none"],
  295. autoplay: ["", "autoplay"],
  296. mediagroup: ["movie"],
  297. muted: ["", "muted"],
  298. controls: ["", "controls"]
  299. }
  300. },
  301. wbr: s
  302. };
  303. var globalAttrs = {
  304. 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"],
  305. "class": null,
  306. contenteditable: ["true", "false"],
  307. contextmenu: null,
  308. dir: ["ltr", "rtl", "auto"],
  309. draggable: ["true", "false", "auto"],
  310. dropzone: ["copy", "move", "link", "string:", "file:"],
  311. hidden: ["hidden"],
  312. id: null,
  313. inert: ["inert"],
  314. itemid: null,
  315. itemprop: null,
  316. itemref: null,
  317. itemscope: ["itemscope"],
  318. itemtype: null,
  319. lang: ["en", "es"],
  320. spellcheck: ["true", "false"],
  321. style: null,
  322. tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
  323. title: null,
  324. translate: ["yes", "no"],
  325. onclick: null,
  326. rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"]
  327. };
  328. function populate(obj) {
  329. for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr))
  330. obj.attrs[attr] = globalAttrs[attr];
  331. }
  332. populate(s);
  333. for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s)
  334. populate(data[tag]);
  335. CodeMirror.htmlSchema = data;
  336. function htmlHint(cm, options) {
  337. var local = {schemaInfo: data};
  338. if (options) for (var opt in options) local[opt] = options[opt];
  339. return CodeMirror.hint.xml(cm, local);
  340. }
  341. CodeMirror.registerHelper("hint", "html", htmlHint);
  342. });