dtd.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or http://ckeditor.com/license
  4. */
  5. /**
  6. * @fileOverview Defines the {@link CKEDITOR.dtd} object, which holds the DTD
  7. * mapping for XHTML 1.0 Transitional. This file was automatically
  8. * generated from the file: xhtml1-transitional.dtd.
  9. */
  10. /**
  11. * Holds and object representation of the HTML DTD to be used by the
  12. * editor in its internal operations.
  13. *
  14. * Each element in the DTD is represented by a property in this object. Each
  15. * property contains the list of elements that can be contained by the element.
  16. * Text is represented by the `#` property.
  17. *
  18. * Several special grouping properties are also available. Their names start
  19. * with the `$` character.
  20. *
  21. * // Check if <div> can be contained in a <p> element.
  22. * alert( !!CKEDITOR.dtd[ 'p' ][ 'div' ] ); // false
  23. *
  24. * // Check if <p> can be contained in a <div> element.
  25. * alert( !!CKEDITOR.dtd[ 'div' ][ 'p' ] ); // true
  26. *
  27. * // Check if <p> is a block element.
  28. * alert( !!CKEDITOR.dtd.$block[ 'p' ] ); // true
  29. *
  30. * @class CKEDITOR.dtd
  31. * @singleton
  32. */
  33. CKEDITOR.dtd = ( function() {
  34. 'use strict';
  35. var X = CKEDITOR.tools.extend,
  36. // Subtraction rest of sets, from the first set.
  37. Y = function( source, removed ) {
  38. var substracted = CKEDITOR.tools.clone( source );
  39. for ( var i = 1; i < arguments.length; i++ ) {
  40. removed = arguments[ i ];
  41. for ( var name in removed )
  42. delete substracted[ name ];
  43. }
  44. return substracted;
  45. };
  46. // Phrasing elements.
  47. // P = { a: 1, em: 1, strong: 1, small: 1, abbr: 1, dfn: 1, i: 1, b: 1, s: 1,
  48. // u: 1, code: 1, 'var': 1, samp: 1, kbd: 1, sup: 1, sub: 1, q: 1, cite: 1,
  49. // span: 1, bdo: 1, bdi: 1, br: 1, wbr: 1, ins: 1, del: 1, img: 1, embed: 1,
  50. // object: 1, iframe: 1, map: 1, area: 1, script: 1, noscript: 1, ruby: 1,
  51. // video: 1, audio: 1, input: 1, textarea: 1, select: 1, button: 1, label: 1,
  52. // output: 1, keygen: 1, progress: 1, command: 1, canvas: 1, time: 1,
  53. // meter: 1, detalist: 1 },
  54. // Flow elements.
  55. // F = { a: 1, p: 1, hr: 1, pre: 1, ul: 1, ol: 1, dl: 1, div: 1, h1: 1, h2: 1,
  56. // h3: 1, h4: 1, h5: 1, h6: 1, hgroup: 1, address: 1, blockquote: 1, ins: 1,
  57. // del: 1, object: 1, map: 1, noscript: 1, section: 1, nav: 1, article: 1,
  58. // aside: 1, header: 1, footer: 1, video: 1, audio: 1, figure: 1, table: 1,
  59. // form: 1, fieldset: 1, menu: 1, canvas: 1, details:1 },
  60. // Text can be everywhere.
  61. // X( P, T );
  62. // Flow elements set consists of phrasing elements set.
  63. // X( F, P );
  64. var P = {}, F = {},
  65. // Intersection of flow elements set and phrasing elements set.
  66. PF = {
  67. a: 1, abbr: 1, area: 1, audio: 1, b: 1, bdi: 1, bdo: 1, br: 1, button: 1, canvas: 1, cite: 1,
  68. code: 1, command: 1, datalist: 1, del: 1, dfn: 1, em: 1, embed: 1, i: 1, iframe: 1, img: 1,
  69. input: 1, ins: 1, kbd: 1, keygen: 1, label: 1, map: 1, mark: 1, meter: 1, noscript: 1, object: 1,
  70. output: 1, progress: 1, q: 1, ruby: 1, s: 1, samp: 1, script: 1, select: 1, small: 1, span: 1,
  71. strong: 1, sub: 1, sup: 1, textarea: 1, time: 1, u: 1, 'var': 1, video: 1, wbr: 1
  72. },
  73. // F - PF (Flow Only).
  74. FO = {
  75. address: 1, article: 1, aside: 1, blockquote: 1, details: 1, div: 1, dl: 1, fieldset: 1,
  76. figure: 1, footer: 1, form: 1, h1: 1, h2: 1, h3: 1, h4: 1, h5: 1, h6: 1, header: 1, hgroup: 1,
  77. hr: 1, main: 1, menu: 1, nav: 1, ol: 1, p: 1, pre: 1, section: 1, table: 1, ul: 1
  78. },
  79. // Metadata elements.
  80. M = { command: 1, link: 1, meta: 1, noscript: 1, script: 1, style: 1 },
  81. // Empty.
  82. E = {},
  83. // Text.
  84. T = { '#': 1 },
  85. // Deprecated phrasing elements.
  86. DP = { acronym: 1, applet: 1, basefont: 1, big: 1, font: 1, isindex: 1, strike: 1, style: 1, tt: 1 }, // TODO remove "style".
  87. // Deprecated flow only elements.
  88. DFO = { center: 1, dir: 1, noframes: 1 };
  89. // Phrasing elements := PF + T + DP
  90. X( P, PF, T, DP );
  91. // Flow elements := FO + P + DFO
  92. X( F, FO, P, DFO );
  93. var dtd = {
  94. a: Y( P, { a: 1, button: 1 } ), // Treat as normal inline element (not a transparent one).
  95. abbr: P,
  96. address: F,
  97. area: E,
  98. article: F,
  99. aside: F,
  100. audio: X( { source: 1, track: 1 }, F ),
  101. b: P,
  102. base: E,
  103. bdi: P,
  104. bdo: P,
  105. blockquote: F,
  106. body: F,
  107. br: E,
  108. button: Y( P, { a: 1, button: 1 } ),
  109. canvas: P, // Treat as normal inline element (not a transparent one).
  110. caption: F,
  111. cite: P,
  112. code: P,
  113. col: E,
  114. colgroup: { col: 1 },
  115. command: E,
  116. datalist: X( { option: 1 }, P ),
  117. dd: F,
  118. del: P, // Treat as normal inline element (not a transparent one).
  119. details: X( { summary: 1 }, F ),
  120. dfn: P,
  121. div: F,
  122. dl: { dt: 1, dd: 1 },
  123. dt: F,
  124. em: P,
  125. embed: E,
  126. fieldset: X( { legend: 1 }, F ),
  127. figcaption: F,
  128. figure: X( { figcaption: 1 }, F ),
  129. footer: F,
  130. form: F,
  131. h1: P,
  132. h2: P,
  133. h3: P,
  134. h4: P,
  135. h5: P,
  136. h6: P,
  137. head: X( { title: 1, base: 1 }, M ),
  138. header: F,
  139. hgroup: { h1: 1, h2: 1, h3: 1, h4: 1, h5: 1, h6: 1 },
  140. hr: E,
  141. html: X( { head: 1, body: 1 }, F, M ), // Head and body are optional...
  142. i: P,
  143. iframe: T,
  144. img: E,
  145. input: E,
  146. ins: P, // Treat as normal inline element (not a transparent one).
  147. kbd: P,
  148. keygen: E,
  149. label: P,
  150. legend: P,
  151. li: F,
  152. link: E,
  153. // Can't be a descendant of article, aside, footer, header, nav, but we don't need this
  154. // complication. As well as checking if it's used only once.
  155. main: F,
  156. map: F,
  157. mark: P, // Treat as normal inline element (not a transparent one).
  158. menu: X( { li: 1 }, F ),
  159. meta: E,
  160. meter: Y( P, { meter: 1 } ),
  161. nav: F,
  162. noscript: X( { link: 1, meta: 1, style: 1 }, P ), // Treat as normal inline element (not a transparent one).
  163. object: X( { param: 1 }, P ), // Treat as normal inline element (not a transparent one).
  164. ol: { li: 1 },
  165. optgroup: { option: 1 },
  166. option: T,
  167. output: P,
  168. p: P,
  169. param: E,
  170. pre: P,
  171. progress: Y( P, { progress: 1 } ),
  172. q: P,
  173. rp: P,
  174. rt: P,
  175. ruby: X( { rp: 1, rt: 1 }, P ),
  176. s: P,
  177. samp: P,
  178. script: T,
  179. section: F,
  180. select: { optgroup: 1, option: 1 },
  181. small: P,
  182. source: E,
  183. span: P,
  184. strong: P,
  185. style: T,
  186. sub: P,
  187. summary: P,
  188. sup: P,
  189. table: { caption: 1, colgroup: 1, thead: 1, tfoot: 1, tbody: 1, tr: 1 },
  190. tbody: { tr: 1 },
  191. td: F,
  192. textarea: T,
  193. tfoot: { tr: 1 },
  194. th: F,
  195. thead: { tr: 1 },
  196. time: Y( P, { time: 1 } ),
  197. title: T,
  198. tr: { th: 1, td: 1 },
  199. track: E,
  200. u: P,
  201. ul: { li: 1 },
  202. 'var': P,
  203. video: X( { source: 1, track: 1 }, F ),
  204. wbr: E,
  205. // Deprecated tags.
  206. acronym: P,
  207. applet: X( { param: 1 }, F ),
  208. basefont: E,
  209. big: P,
  210. center: F,
  211. dialog: E,
  212. dir: { li: 1 },
  213. font: P,
  214. isindex: E,
  215. noframes: F,
  216. strike: P,
  217. tt: P
  218. };
  219. X( dtd, {
  220. /**
  221. * List of block elements, like `<p>` or `<div>`.
  222. */
  223. $block: X( { audio: 1, dd: 1, dt: 1, figcaption: 1, li: 1, video: 1 }, FO, DFO ),
  224. /**
  225. * List of elements that contain other blocks, in which block-level operations should be limited,
  226. * this property is not intended to be checked directly, use {@link CKEDITOR.dom.elementPath#blockLimit} instead.
  227. *
  228. * Some examples of editor behaviors that are impacted by block limits:
  229. *
  230. * * Enter key never split a block-limit element;
  231. * * Style application is constraint by the block limit of the current selection.
  232. * * Pasted html will be inserted into the block limit of the current selection.
  233. *
  234. * **Note:** As an exception `<li>` is not considered as a block limit, as it's generally used as a text block.
  235. */
  236. $blockLimit: {
  237. article: 1, aside: 1, audio: 1, body: 1, caption: 1, details: 1, dir: 1, div: 1, dl: 1,
  238. fieldset: 1, figcaption: 1, figure: 1, footer: 1, form: 1, header: 1, hgroup: 1, main: 1, menu: 1, nav: 1,
  239. ol: 1, section: 1, table: 1, td: 1, th: 1, tr: 1, ul: 1, video: 1
  240. },
  241. /**
  242. * List of elements that contain character data.
  243. */
  244. $cdata: { script: 1, style: 1 },
  245. /**
  246. * List of elements that are accepted as inline editing hosts.
  247. */
  248. $editable: {
  249. address: 1, article: 1, aside: 1, blockquote: 1, body: 1, details: 1, div: 1, fieldset: 1,
  250. figcaption: 1, footer: 1, form: 1, h1: 1, h2: 1, h3: 1, h4: 1, h5: 1, h6: 1, header: 1, hgroup: 1,
  251. main: 1, nav: 1, p: 1, pre: 1, section: 1
  252. },
  253. /**
  254. * List of empty (self-closing) elements, like `<br>` or `<img>`.
  255. */
  256. $empty: {
  257. area: 1, base: 1, basefont: 1, br: 1, col: 1, command: 1, dialog: 1, embed: 1, hr: 1, img: 1,
  258. input: 1, isindex: 1, keygen: 1, link: 1, meta: 1, param: 1, source: 1, track: 1, wbr: 1
  259. },
  260. /**
  261. * List of inline (`<span>` like) elements.
  262. */
  263. $inline: P,
  264. /**
  265. * List of list root elements.
  266. */
  267. $list: { dl: 1, ol: 1, ul: 1 },
  268. /**
  269. * List of list item elements, like `<li>` or `<dd>`.
  270. */
  271. $listItem: { dd: 1, dt: 1, li: 1 },
  272. /**
  273. * List of elements which may live outside body.
  274. */
  275. $nonBodyContent: X( { body: 1, head: 1, html: 1 }, dtd.head ),
  276. /**
  277. * Elements that accept text nodes, but are not possible to edit into the browser.
  278. */
  279. $nonEditable: {
  280. applet: 1, audio: 1, button: 1, embed: 1, iframe: 1, map: 1, object: 1, option: 1,
  281. param: 1, script: 1, textarea: 1, video: 1
  282. },
  283. /**
  284. * Elements that are considered objects, therefore selected as a whole in the editor.
  285. */
  286. $object: {
  287. applet: 1, audio: 1, button: 1, hr: 1, iframe: 1, img: 1, input: 1, object: 1, select: 1,
  288. table: 1, textarea: 1, video: 1
  289. },
  290. /**
  291. * List of elements that can be ignored if empty, like `<b>` or `<span>`.
  292. */
  293. $removeEmpty: {
  294. abbr: 1, acronym: 1, b: 1, bdi: 1, bdo: 1, big: 1, cite: 1, code: 1, del: 1, dfn: 1,
  295. em: 1, font: 1, i: 1, ins: 1, label: 1, kbd: 1, mark: 1, meter: 1, output: 1, q: 1, ruby: 1, s: 1,
  296. samp: 1, small: 1, span: 1, strike: 1, strong: 1, sub: 1, sup: 1, time: 1, tt: 1, u: 1, 'var': 1
  297. },
  298. /**
  299. * List of elements that have tabindex set to zero by default.
  300. */
  301. $tabIndex: { a: 1, area: 1, button: 1, input: 1, object: 1, select: 1, textarea: 1 },
  302. /**
  303. * List of elements used inside the `<table>` element, like `<tbody>` or `<td>`.
  304. */
  305. $tableContent: { caption: 1, col: 1, colgroup: 1, tbody: 1, td: 1, tfoot: 1, th: 1, thead: 1, tr: 1 },
  306. /**
  307. * List of "transparent" elements. See [W3C's definition of "transparent" element](http://dev.w3.org/html5/markup/terminology.html#transparent).
  308. */
  309. $transparent: { a: 1, audio: 1, canvas: 1, del: 1, ins: 1, map: 1, noscript: 1, object: 1, video: 1 },
  310. /**
  311. * List of elements that are not to exist standalone that must live under it's parent element.
  312. */
  313. $intermediate: {
  314. caption: 1, colgroup: 1, dd: 1, dt: 1, figcaption: 1, legend: 1, li: 1, optgroup: 1,
  315. option: 1, rp: 1, rt: 1, summary: 1, tbody: 1, td: 1, tfoot: 1, th: 1, thead: 1, tr: 1
  316. }
  317. } );
  318. return dtd;
  319. } )();
  320. // PACKAGER_RENAME( CKEDITOR.dtd )