html-hint.js 14 KB

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