You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

351 lines
11 KiB

7 months ago
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/5/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. dialog: { attrs: { open: null } },
  99. dl: s,
  100. dt: s,
  101. em: s,
  102. embed: { attrs: { src: null, type: null, width: null, height: null } },
  103. eventsource: { attrs: { src: null } },
  104. fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } },
  105. figcaption: s,
  106. figure: s,
  107. font: s,
  108. footer: s,
  109. form: {
  110. attrs: {
  111. action: null, name: null,
  112. "accept-charset": charsets,
  113. autocomplete: ["on", "off"],
  114. enctype: encs,
  115. method: methods,
  116. novalidate: ["", "novalidate"],
  117. target: targets
  118. }
  119. },
  120. frame: s,
  121. frameset: s,
  122. h1: s, h2: s, h3: s, h4: s, h5: s, h6: s,
  123. head: {
  124. attrs: {},
  125. children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
  126. },
  127. header: s,
  128. hgroup: s,
  129. hr: s,
  130. html: {
  131. attrs: { manifest: null },
  132. children: ["head", "body"]
  133. },
  134. i: s,
  135. iframe: {
  136. attrs: {
  137. src: null, srcdoc: null, name: null, width: null, height: null,
  138. sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
  139. seamless: ["", "seamless"]
  140. }
  141. },
  142. img: {
  143. attrs: {
  144. alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
  145. crossorigin: ["anonymous", "use-credentials"]
  146. }
  147. },
  148. input: {
  149. attrs: {
  150. alt: null, dirname: null, form: null, formaction: null,
  151. height: null, list: null, max: null, maxlength: null, min: null,
  152. name: null, pattern: null, placeholder: null, size: null, src: null,
  153. step: null, value: null, width: null,
  154. accept: ["audio/*", "video/*", "image/*"],
  155. autocomplete: ["on", "off"],
  156. autofocus: ["", "autofocus"],
  157. checked: ["", "checked"],
  158. disabled: ["", "disabled"],
  159. formenctype: encs,
  160. formmethod: methods,
  161. formnovalidate: ["", "novalidate"],
  162. formtarget: targets,
  163. multiple: ["", "multiple"],
  164. readonly: ["", "readonly"],
  165. required: ["", "required"],
  166. type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
  167. "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
  168. "file", "submit", "image", "reset", "button"]
  169. }
  170. },
  171. ins: { attrs: { cite: null, datetime: null } },
  172. kbd: s,
  173. keygen: {
  174. attrs: {
  175. challenge: null, form: null, name: null,
  176. autofocus: ["", "autofocus"],
  177. disabled: ["", "disabled"],
  178. keytype: ["RSA"]
  179. }
  180. },
  181. label: { attrs: { "for": null, form: null } },
  182. legend: s,
  183. li: { attrs: { value: null } },
  184. link: {
  185. attrs: {
  186. href: null, type: null,
  187. hreflang: langs,
  188. media: media,
  189. sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
  190. }
  191. },
  192. map: { attrs: { name: null } },
  193. mark: s,
  194. menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
  195. meta: {
  196. attrs: {
  197. content: null,
  198. charset: charsets,
  199. name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
  200. "http-equiv": ["content-language", "content-type", "default-style", "refresh"]
  201. }
  202. },
  203. meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
  204. nav: s,
  205. noframes: s,
  206. noscript: s,
  207. object: {
  208. attrs: {
  209. data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
  210. typemustmatch: ["", "typemustmatch"]
  211. }
  212. },
  213. ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } },
  214. optgroup: { attrs: { disabled: ["", "disabled"], label: null } },
  215. option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } },
  216. output: { attrs: { "for": null, form: null, name: null } },
  217. p: s,
  218. param: { attrs: { name: null, value: null } },
  219. pre: s,
  220. progress: { attrs: { value: null, max: null } },
  221. q: { attrs: { cite: null } },
  222. rp: s,
  223. rt: s,
  224. ruby: s,
  225. s: s,
  226. samp: s,
  227. script: {
  228. attrs: {
  229. type: ["text/javascript"],
  230. src: null,
  231. async: ["", "async"],
  232. defer: ["", "defer"],
  233. charset: charsets
  234. }
  235. },
  236. section: s,
  237. select: {
  238. attrs: {
  239. form: null, name: null, size: null,
  240. autofocus: ["", "autofocus"],
  241. disabled: ["", "disabled"],
  242. multiple: ["", "multiple"]
  243. }
  244. },
  245. small: s,
  246. source: { attrs: { src: null, type: null, media: null } },
  247. span: s,
  248. strike: s,
  249. strong: s,
  250. style: {
  251. attrs: {
  252. type: ["text/css"],
  253. media: media,
  254. scoped: null
  255. }
  256. },
  257. sub: s,
  258. summary: s,
  259. sup: s,
  260. table: s,
  261. tbody: s,
  262. td: { attrs: { colspan: null, rowspan: null, headers: null } },
  263. textarea: {
  264. attrs: {
  265. dirname: null, form: null, maxlength: null, name: null, placeholder: null,
  266. rows: null, cols: null,
  267. autofocus: ["", "autofocus"],
  268. disabled: ["", "disabled"],
  269. readonly: ["", "readonly"],
  270. required: ["", "required"],
  271. wrap: ["soft", "hard"]
  272. }
  273. },
  274. tfoot: s,
  275. th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
  276. thead: s,
  277. time: { attrs: { datetime: null } },
  278. title: s,
  279. tr: s,
  280. track: {
  281. attrs: {
  282. src: null, label: null, "default": null,
  283. kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
  284. srclang: langs
  285. }
  286. },
  287. tt: s,
  288. u: s,
  289. ul: s,
  290. "var": s,
  291. video: {
  292. attrs: {
  293. src: null, poster: null, width: null, height: null,
  294. crossorigin: ["anonymous", "use-credentials"],
  295. preload: ["auto", "metadata", "none"],
  296. autoplay: ["", "autoplay"],
  297. mediagroup: ["movie"],
  298. muted: ["", "muted"],
  299. controls: ["", "controls"]
  300. }
  301. },
  302. wbr: s
  303. };
  304. var globalAttrs = {
  305. 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"],
  306. "class": null,
  307. contenteditable: ["true", "false"],
  308. contextmenu: null,
  309. dir: ["ltr", "rtl", "auto"],
  310. draggable: ["true", "false", "auto"],
  311. dropzone: ["copy", "move", "link", "string:", "file:"],
  312. hidden: ["hidden"],
  313. id: null,
  314. inert: ["inert"],
  315. itemid: null,
  316. itemprop: null,
  317. itemref: null,
  318. itemscope: ["itemscope"],
  319. itemtype: null,
  320. lang: ["en", "es"],
  321. spellcheck: ["true", "false"],
  322. autocorrect: ["true", "false"],
  323. autocapitalize: ["true", "false"],
  324. style: null,
  325. tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
  326. title: null,
  327. translate: ["yes", "no"],
  328. onclick: null,
  329. rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"]
  330. };
  331. function populate(obj) {
  332. for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr))
  333. obj.attrs[attr] = globalAttrs[attr];
  334. }
  335. populate(s);
  336. for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s)
  337. populate(data[tag]);
  338. CodeMirror.htmlSchema = data;
  339. function htmlHint(cm, options) {
  340. var local = {schemaInfo: data};
  341. if (options) for (var opt in options) local[opt] = options[opt];
  342. return CodeMirror.hint.xml(cm, local);
  343. }
  344. CodeMirror.registerHelper("hint", "html", htmlHint);
  345. });