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