hjg
2024-10-30 8cf23534166c07e711aac2a25911ada317ba01f0
提交 | 用户 | 时间
58d006 1 <!DOCTYPE html>
A 2 <!--
3 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
4 For licensing, see LICENSE.html or http://ckeditor.com/license
5 -->
6 <html>
7 <head>
8     <title>XHTML Compliant Output &mdash; CKEditor Sample</title>
9     <meta charset="utf-8">
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
38     coreStyles_bold: {
39         element: 'span',
40         attributes: { 'class': 'Bold' }
41     },
42     coreStyles_italic: {
43         element: 'span',
44         attributes: { 'class': 'Italic' }
45     },
46
47     ...
48 });</pre>
49     </div>
50     <form action="sample_posteddata.php" method="post">
51         <p>
52             <label for="editor1">
53                 Editor 1:
54             </label>
55             <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>
56             <script>
57
58                 CKEDITOR.replace( 'editor1', {
59                     /*
60                      * Style sheet for the contents
61                      */
62                     contentsCss: 'assets/outputxhtml/outputxhtml.css',
63
64                     /*
65                      * Core styles.
66                      */
67                     coreStyles_bold: {
68                         element: 'span',
69                         attributes: { 'class': 'Bold' }
70                     },
71                     coreStyles_italic: {
72                         element: 'span',
73                         attributes: { 'class': 'Italic' }
74                     },
75                     coreStyles_underline: {
76                         element: 'span',
77                         attributes: { 'class': 'Underline' }
78                     },
79                     coreStyles_strike: {
80                         element: 'span',
81                         attributes: { 'class': 'StrikeThrough' },
82                         overrides: 'strike'
83                     },
84                     coreStyles_subscript: {
85                         element: 'span',
86                         attributes: { 'class': 'Subscript' },
87                         overrides: 'sub'
88                     },
89                     coreStyles_superscript: {
90                         element: 'span',
91                         attributes: { 'class': 'Superscript' },
92                         overrides: 'sup'
93                     },
94
95                     /*
96                      * Font face.
97                      */
98
99                     // List of fonts available in the toolbar combo. Each font definition is
100                     // separated by a semi-colon (;). We are using class names here, so each font
101                     // is defined by {Combo Label}/{Class Name}.
102                     font_names: 'Comic Sans MS/FontComic;Courier New/FontCourier;Times New Roman/FontTimes',
103
104                     // Define the way font elements will be applied to the document. The "span"
105                     // element will be used. When a font is selected, the font name defined in the
106                     // above list is passed to this definition with the name "Font", being it
107                     // injected in the "class" attribute.
108                     // We must also instruct the editor to replace span elements that are used to
109                     // set the font (Overrides).
110                     font_style: {
111                         element: 'span',
112                         attributes: { 'class': '#(family)' },
113                         overrides: [
114                             {
115                                 element: 'span',
116                                 attributes: {
117                                     'class': /^Font(?:Comic|Courier|Times)$/
118                                 }
119                             }
120                         ]
121                     },
122
123                     /*
124                      * Font sizes.
125                      */
126                     fontSize_sizes: 'Smaller/FontSmaller;Larger/FontLarger;8pt/FontSmall;14pt/FontBig;Double Size/FontDouble',
127                     fontSize_style: {
128                         element: 'span',
129                         attributes: { 'class': '#(size)' },
130                         overrides: [
131                             {
132                                 element: 'span',
133                                 attributes: {
134                                     'class': /^Font(?:Smaller|Larger|Small|Big|Double)$/
135                                 }
136                             }
137                         ]
138                     } ,
139
140                     /*
141                      * Font colors.
142                      */
143                     colorButton_enableMore: false,
144
145                     colorButton_colors: 'FontColor1/FF9900,FontColor2/0066CC,FontColor3/F00',
146                     colorButton_foreStyle: {
147                         element: 'span',
148                         attributes: { 'class': '#(color)' },
149                         overrides: [
150                             {
151                                 element: 'span',
152                                 attributes: {
153                                     'class': /^FontColor(?:1|2|3)$/
154                                 }
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                     /*
173                      * Indentation.
174                      */
175                     indentClasses: [ 'Indent1', 'Indent2', 'Indent3' ],
176
177                     /*
178                      * Paragraph justification.
179                      */
180                     justifyClasses: [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull' ],
181
182                     /*
183                      * Styles combo.
184                      */
185                     stylesSet: [
186                         { name: 'Strong Emphasis', element: 'strong' },
187                         { name: 'Emphasis', element: 'em' },
188
189                         { name: 'Computer Code', element: 'code' },
190                         { name: 'Keyboard Phrase', element: 'kbd' },
191                         { name: 'Sample Text', element: 'samp' },
192                         { name: 'Variable', element: 'var' },
193
194                         { name: 'Deleted Text', element: 'del' },
195                         { name: 'Inserted Text', element: 'ins' },
196
197                         { name: 'Cited Work', element: 'cite' },
198                         { name: 'Inline Quotation', element: 'q' }
199                     ]
200                 });
201
202             </script>
203         </p>
204         <p>
205             <input type="submit" value="Submit">
206         </p>
207     </form>
208     <div id="footer">
209         <hr>
210         <p>
211             CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
212         </p>
213         <p id="copy">
214             Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
215             Knabben. All rights reserved.
216         </p>
217     </div>
218 </body>
219 </html>