xhtmlstyle.html 6.8 KB

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