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.

231 lines
6.7 KiB

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