xhtmlstyle.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.md or http://ckeditor.com/license
  5. -->
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>XHTML Compliant Output &mdash; CKEditor Sample</title>
  10. <meta name="ckeditor-sample-required-plugins" content="sourcearea">
  11. <script src="../../ckeditor.js"></script>
  12. <script src="sample.js"></script>
  13. <link href="sample.css" rel="stylesheet">
  14. </head>
  15. <body>
  16. <h1 class="samples">
  17. <a href="index.html">CKEditor Samples</a> &raquo; Producing XHTML Compliant Output
  18. </h1>
  19. <div class="warning deprecated">
  20. This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/basicstyles.html">brand new version in CKEditor SDK</a>.
  21. </div>
  22. <div class="description">
  23. <p>
  24. This sample shows how to configure CKEditor to output valid
  25. <a class="samples" href="http://www.w3.org/TR/xhtml11/">XHTML 1.1</a> code.
  26. Deprecated elements (<code>&lt;font&gt;</code>, <code>&lt;u&gt;</code>) or attributes
  27. (<code>size</code>, <code>face</code>) will be replaced with XHTML compliant code.
  28. </p>
  29. <p>
  30. To add a CKEditor instance outputting valid XHTML code, load the editor using a standard
  31. JavaScript call and define CKEditor features to use the XHTML compliant elements and styles.
  32. </p>
  33. <p>
  34. A snippet of the configuration code can be seen below; check the source of this page for
  35. full definition:
  36. </p>
  37. <pre class="samples">
  38. CKEDITOR.replace( '<em>textarea_id</em>', {
  39. contentsCss: 'assets/outputxhtml.css',
  40. coreStyles_bold: {
  41. element: 'span',
  42. attributes: { 'class': 'Bold' }
  43. },
  44. coreStyles_italic: {
  45. element: 'span',
  46. attributes: { 'class': 'Italic' }
  47. },
  48. ...
  49. });</pre>
  50. </div>
  51. <form action="sample_posteddata.php" method="post">
  52. <p>
  53. <label for="editor1">
  54. Editor 1:
  55. </label>
  56. <textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;span class="Bold"&gt;sample text&lt;/span&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  57. <script>
  58. CKEDITOR.replace( 'editor1', {
  59. /*
  60. * Style sheet for the contents
  61. */
  62. contentsCss: 'assets/outputxhtml/outputxhtml.css',
  63. /*
  64. * Special allowed content rules for spans used by
  65. * font face, size, and color buttons.
  66. *
  67. * Note: all rules have been written separately so
  68. * it was possible to specify required classes.
  69. */
  70. extraAllowedContent: 'span(!FontColor1);span(!FontColor2);span(!FontColor3);' +
  71. 'span(!FontColor1BG);span(!FontColor2BG);span(!FontColor3BG);' +
  72. 'span(!FontComic);span(!FontCourier);span(!FontTimes);' +
  73. 'span(!FontSmaller);span(!FontLarger);span(!FontSmall);span(!FontBig);span(!FontDouble)',
  74. /*
  75. * Core styles.
  76. */
  77. coreStyles_bold: {
  78. element: 'span',
  79. attributes: { 'class': 'Bold' }
  80. },
  81. coreStyles_italic: {
  82. element: 'span',
  83. attributes: { 'class': 'Italic' }
  84. },
  85. coreStyles_underline: {
  86. element: 'span',
  87. attributes: { 'class': 'Underline' }
  88. },
  89. coreStyles_strike: {
  90. element: 'span',
  91. attributes: { 'class': 'StrikeThrough' },
  92. overrides: 'strike'
  93. },
  94. coreStyles_subscript: {
  95. element: 'span',
  96. attributes: { 'class': 'Subscript' },
  97. overrides: 'sub'
  98. },
  99. coreStyles_superscript: {
  100. element: 'span',
  101. attributes: { 'class': 'Superscript' },
  102. overrides: 'sup'
  103. },
  104. /*
  105. * Font face.
  106. */
  107. // List of fonts available in the toolbar combo. Each font definition is
  108. // separated by a semi-colon (;). We are using class names here, so each font
  109. // is defined by {Combo Label}/{Class Name}.
  110. font_names: 'Comic Sans MS/FontComic;Courier New/FontCourier;Times New Roman/FontTimes',
  111. // Define the way font elements will be applied to the document. The "span"
  112. // element will be used. When a font is selected, the font name defined in the
  113. // above list is passed to this definition with the name "Font", being it
  114. // injected in the "class" attribute.
  115. // We must also instruct the editor to replace span elements that are used to
  116. // set the font (Overrides).
  117. font_style: {
  118. element: 'span',
  119. attributes: { 'class': '#(family)' },
  120. overrides: [
  121. {
  122. element: 'span',
  123. attributes: {
  124. 'class': /^Font(?:Comic|Courier|Times)$/
  125. }
  126. }
  127. ]
  128. },
  129. /*
  130. * Font sizes.
  131. */
  132. fontSize_sizes: 'Smaller/FontSmaller;Larger/FontLarger;8pt/FontSmall;14pt/FontBig;Double Size/FontDouble',
  133. fontSize_style: {
  134. element: 'span',
  135. attributes: { 'class': '#(size)' },
  136. overrides: [
  137. {
  138. element: 'span',
  139. attributes: {
  140. 'class': /^Font(?:Smaller|Larger|Small|Big|Double)$/
  141. }
  142. }
  143. ]
  144. } ,
  145. /*
  146. * Font colors.
  147. */
  148. colorButton_enableMore: false,
  149. colorButton_colors: 'FontColor1/FF9900,FontColor2/0066CC,FontColor3/F00',
  150. colorButton_foreStyle: {
  151. element: 'span',
  152. attributes: { 'class': '#(color)' },
  153. overrides: [
  154. {
  155. element: 'span',
  156. attributes: {
  157. 'class': /^FontColor(?:1|2|3)$/
  158. }
  159. }
  160. ]
  161. },
  162. colorButton_backStyle: {
  163. element: 'span',
  164. attributes: { 'class': '#(color)BG' },
  165. overrides: [
  166. {
  167. element: 'span',
  168. attributes: {
  169. 'class': /^FontColor(?:1|2|3)BG$/
  170. }
  171. }
  172. ]
  173. },
  174. /*
  175. * Indentation.
  176. */
  177. indentClasses: [ 'Indent1', 'Indent2', 'Indent3' ],
  178. /*
  179. * Paragraph justification.
  180. */
  181. justifyClasses: [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull' ],
  182. /*
  183. * Styles combo.
  184. */
  185. stylesSet: [
  186. { name: 'Strong Emphasis', element: 'strong' },
  187. { name: 'Emphasis', element: 'em' },
  188. { name: 'Computer Code', element: 'code' },
  189. { name: 'Keyboard Phrase', element: 'kbd' },
  190. { name: 'Sample Text', element: 'samp' },
  191. { name: 'Variable', element: 'var' },
  192. { name: 'Deleted Text', element: 'del' },
  193. { name: 'Inserted Text', element: 'ins' },
  194. { name: 'Cited Work', element: 'cite' },
  195. { name: 'Inline Quotation', element: 'q' }
  196. ]
  197. });
  198. </script>
  199. </p>
  200. <p>
  201. <input type="submit" value="Submit">
  202. </p>
  203. </form>
  204. <div id="footer">
  205. <hr>
  206. <p>
  207. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  208. </p>
  209. <p id="copy">
  210. Copyright &copy; 2003-2015, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  211. Knabben. All rights reserved.
  212. </p>
  213. </div>
  214. </body>
  215. </html>