html-hint.js 12 KB

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