aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/htmlwriter
diff options
context:
space:
mode:
Diffstat (limited to 'sources/plugins/htmlwriter')
-rw-r--r--sources/plugins/htmlwriter/plugin.js360
-rw-r--r--sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.flabin0 -> 85504 bytes
-rw-r--r--sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.swfbin0 -> 15571 bytes
-rw-r--r--sources/plugins/htmlwriter/samples/assets/outputforflash/swfobject.js5
-rw-r--r--sources/plugins/htmlwriter/samples/outputforflash.html283
-rw-r--r--sources/plugins/htmlwriter/samples/outputhtml.html224
6 files changed, 872 insertions, 0 deletions
diff --git a/sources/plugins/htmlwriter/plugin.js b/sources/plugins/htmlwriter/plugin.js
new file mode 100644
index 0000000..b6d2716
--- /dev/null
+++ b/sources/plugins/htmlwriter/plugin.js
@@ -0,0 +1,360 @@
1/**
2 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5
6CKEDITOR.plugins.add( 'htmlwriter', {
7 init: function( editor ) {
8 var writer = new CKEDITOR.htmlWriter();
9
10 writer.forceSimpleAmpersand = editor.config.forceSimpleAmpersand;
11 writer.indentationChars = editor.config.dataIndentationChars || '\t';
12
13 // Overwrite default basicWriter initialized in hmtlDataProcessor constructor.
14 editor.dataProcessor.writer = writer;
15 }
16} );
17
18/**
19 * The class used to write HTML data.
20 *
21 * var writer = new CKEDITOR.htmlWriter();
22 * writer.openTag( 'p' );
23 * writer.attribute( 'class', 'MyClass' );
24 * writer.openTagClose( 'p' );
25 * writer.text( 'Hello' );
26 * writer.closeTag( 'p' );
27 * alert( writer.getHtml() ); // '<p class="MyClass">Hello</p>'
28 *
29 * @class
30 * @extends CKEDITOR.htmlParser.basicWriter
31 */
32CKEDITOR.htmlWriter = CKEDITOR.tools.createClass( {
33 base: CKEDITOR.htmlParser.basicWriter,
34
35 /**
36 * Creates an `htmlWriter` class instance.
37 *
38 * @constructor
39 */
40 $: function() {
41 // Call the base contructor.
42 this.base();
43
44 /**
45 * The characters to be used for each indentation step.
46 *
47 * // Use tab for indentation.
48 * editorInstance.dataProcessor.writer.indentationChars = '\t';
49 */
50 this.indentationChars = '\t';
51
52 /**
53 * The characters to be used to close "self-closing" elements, like `<br>` or `<img>`.
54 *
55 * // Use HTML4 notation for self-closing elements.
56 * editorInstance.dataProcessor.writer.selfClosingEnd = '>';
57 */
58 this.selfClosingEnd = ' />';
59
60 /**
61 * The characters to be used for line breaks.
62 *
63 * // Use CRLF for line breaks.
64 * editorInstance.dataProcessor.writer.lineBreakChars = '\r\n';
65 */
66 this.lineBreakChars = '\n';
67
68 this.sortAttributes = 1;
69
70 this._.indent = 0;
71 this._.indentation = '';
72 // Indicate preformatted block context status. (#5789)
73 this._.inPre = 0;
74 this._.rules = {};
75
76 var dtd = CKEDITOR.dtd;
77
78 for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) ) {
79 this.setRules( e, {
80 indent: !dtd[ e ][ '#' ],
81 breakBeforeOpen: 1,
82 breakBeforeClose: !dtd[ e ][ '#' ],
83 breakAfterClose: 1,
84 needsSpace: ( e in dtd.$block ) && !( e in { li: 1, dt: 1, dd: 1 } )
85 } );
86 }
87
88 this.setRules( 'br', { breakAfterOpen: 1 } );
89
90 this.setRules( 'title', {
91 indent: 0,
92 breakAfterOpen: 0
93 } );
94
95 this.setRules( 'style', {
96 indent: 0,
97 breakBeforeClose: 1
98 } );
99
100 this.setRules( 'pre', {
101 breakAfterOpen: 1, // Keep line break after the opening tag
102 indent: 0 // Disable indentation on <pre>.
103 } );
104 },
105
106 proto: {
107 /**
108 * Writes the tag opening part for an opener tag.
109 *
110 * // Writes '<p'.
111 * writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } );
112 *
113 * @param {String} tagName The element name for this tag.
114 * @param {Object} attributes The attributes defined for this tag. The
115 * attributes could be used to inspect the tag.
116 */
117 openTag: function( tagName ) {
118 var rules = this._.rules[ tagName ];
119
120 if ( this._.afterCloser && rules && rules.needsSpace && this._.needsSpace )
121 this._.output.push( '\n' );
122
123 if ( this._.indent )
124 this.indentation();
125 // Do not break if indenting.
126 else if ( rules && rules.breakBeforeOpen ) {
127 this.lineBreak();
128 this.indentation();
129 }
130
131 this._.output.push( '<', tagName );
132
133 this._.afterCloser = 0;
134 },
135
136 /**
137 * Writes the tag closing part for an opener tag.
138 *
139 * // Writes '>'.
140 * writer.openTagClose( 'p', false );
141 *
142 * // Writes ' />'.
143 * writer.openTagClose( 'br', true );
144 *
145 * @param {String} tagName The element name for this tag.
146 * @param {Boolean} isSelfClose Indicates that this is a self-closing tag,
147 * like `<br>` or `<img>`.
148 */
149 openTagClose: function( tagName, isSelfClose ) {
150 var rules = this._.rules[ tagName ];
151
152 if ( isSelfClose ) {
153 this._.output.push( this.selfClosingEnd );
154
155 if ( rules && rules.breakAfterClose )
156 this._.needsSpace = rules.needsSpace;
157 } else {
158 this._.output.push( '>' );
159
160 if ( rules && rules.indent )
161 this._.indentation += this.indentationChars;
162 }
163
164 if ( rules && rules.breakAfterOpen )
165 this.lineBreak();
166 tagName == 'pre' && ( this._.inPre = 1 );
167 },
168
169 /**
170 * Writes an attribute. This function should be called after opening the
171 * tag with {@link #openTagClose}.
172 *
173 * // Writes ' class="MyClass"'.
174 * writer.attribute( 'class', 'MyClass' );
175 *
176 * @param {String} attName The attribute name.
177 * @param {String} attValue The attribute value.
178 */
179 attribute: function( attName, attValue ) {
180
181 if ( typeof attValue == 'string' ) {
182 this.forceSimpleAmpersand && ( attValue = attValue.replace( /&amp;/g, '&' ) );
183 // Browsers don't always escape special character in attribute values. (#4683, #4719).
184 attValue = CKEDITOR.tools.htmlEncodeAttr( attValue );
185 }
186
187 this._.output.push( ' ', attName, '="', attValue, '"' );
188 },
189
190 /**
191 * Writes a closer tag.
192 *
193 * // Writes '</p>'.
194 * writer.closeTag( 'p' );
195 *
196 * @param {String} tagName The element name for this tag.
197 */
198 closeTag: function( tagName ) {
199 var rules = this._.rules[ tagName ];
200
201 if ( rules && rules.indent )
202 this._.indentation = this._.indentation.substr( this.indentationChars.length );
203
204 if ( this._.indent )
205 this.indentation();
206 // Do not break if indenting.
207 else if ( rules && rules.breakBeforeClose ) {
208 this.lineBreak();
209 this.indentation();
210 }
211
212 this._.output.push( '</', tagName, '>' );
213 tagName == 'pre' && ( this._.inPre = 0 );
214
215 if ( rules && rules.breakAfterClose ) {
216 this.lineBreak();
217 this._.needsSpace = rules.needsSpace;
218 }
219
220 this._.afterCloser = 1;
221 },
222
223 /**
224 * Writes text.
225 *
226 * // Writes 'Hello Word'.
227 * writer.text( 'Hello Word' );
228 *
229 * @param {String} text The text value
230 */
231 text: function( text ) {
232 if ( this._.indent ) {
233 this.indentation();
234 !this._.inPre && ( text = CKEDITOR.tools.ltrim( text ) );
235 }
236
237 this._.output.push( text );
238 },
239
240 /**
241 * Writes a comment.
242 *
243 * // Writes "<!-- My comment -->".
244 * writer.comment( ' My comment ' );
245 *
246 * @param {String} comment The comment text.
247 */
248 comment: function( comment ) {
249 if ( this._.indent )
250 this.indentation();
251
252 this._.output.push( '<!--', comment, '-->' );
253 },
254
255 /**
256 * Writes a line break. It uses the {@link #lineBreakChars} property for it.
257 *
258 * // Writes '\n' (e.g.).
259 * writer.lineBreak();
260 */
261 lineBreak: function() {
262 if ( !this._.inPre && this._.output.length > 0 )
263 this._.output.push( this.lineBreakChars );
264 this._.indent = 1;
265 },
266
267 /**
268 * Writes the current indentation character. It uses the {@link #indentationChars}
269 * property, repeating it for the current indentation steps.
270 *
271 * // Writes '\t' (e.g.).
272 * writer.indentation();
273 */
274 indentation: function() {
275 if ( !this._.inPre && this._.indentation )
276 this._.output.push( this._.indentation );
277 this._.indent = 0;
278 },
279
280 /**
281 * Empties the current output buffer. It also brings back the default
282 * values of the writer flags.
283 *
284 * writer.reset();
285 */
286 reset: function() {
287 this._.output = [];
288 this._.indent = 0;
289 this._.indentation = '';
290 this._.afterCloser = 0;
291 this._.inPre = 0;
292 this._.needsSpace = 0;
293 },
294
295 /**
296 * Sets formatting rules for a given element. Possible rules are:
297 *
298 * * `indent` &ndash; indent the element content.
299 * * `breakBeforeOpen` &ndash; break line before the opener tag for this element.
300 * * `breakAfterOpen` &ndash; break line after the opener tag for this element.
301 * * `breakBeforeClose` &ndash; break line before the closer tag for this element.
302 * * `breakAfterClose` &ndash; break line after the closer tag for this element.
303 *
304 * All rules default to `false`. Each function call overrides rules that are
305 * already present, leaving the undefined ones untouched.
306 *
307 * By default, all elements available in the {@link CKEDITOR.dtd#$block},
308 * {@link CKEDITOR.dtd#$listItem}, and {@link CKEDITOR.dtd#$tableContent}
309 * lists have all the above rules set to `true`. Additionaly, the `<br>`
310 * element has the `breakAfterOpen` rule set to `true`.
311 *
312 * // Break line before and after "img" tags.
313 * writer.setRules( 'img', {
314 * breakBeforeOpen: true
315 * breakAfterOpen: true
316 * } );
317 *
318 * // Reset the rules for the "h1" tag.
319 * writer.setRules( 'h1', {} );
320 *
321 * @param {String} tagName The name of the element for which the rules are set.
322 * @param {Object} rules An object containing the element rules.
323 */
324 setRules: function( tagName, rules ) {
325 var currentRules = this._.rules[ tagName ];
326
327 if ( currentRules )
328 CKEDITOR.tools.extend( currentRules, rules, true );
329 else
330 this._.rules[ tagName ] = rules;
331 }
332 }
333} );
334
335/**
336 * Whether to force using `'&'` instead of `'&amp;'` in element attributes
337 * values. It is not recommended to change this setting for compliance with the
338 * W3C XHTML 1.0 standards ([C.12, XHTML 1.0](http://www.w3.org/TR/xhtml1/#C_12)).
339 *
340 * // Use `'&'` instead of `'&amp;'`
341 * CKEDITOR.config.forceSimpleAmpersand = true;
342 *
343 * @cfg {Boolean} [forceSimpleAmpersand=false]
344 * @member CKEDITOR.config
345 */
346
347/**
348 * The characters to be used for indenting HTML output produced by the editor.
349 * Using characters different from `' '` (space) and `'\t'` (tab) is not recommended
350 * as it will mess the code.
351 *
352 * // No indentation.
353 * CKEDITOR.config.dataIndentationChars = '';
354 *
355 * // Use two spaces for indentation.
356 * CKEDITOR.config.dataIndentationChars = ' ';
357 *
358 * @cfg {String} [dataIndentationChars='\t']
359 * @member CKEDITOR.config
360 */
diff --git a/sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.fla b/sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.fla
new file mode 100644
index 0000000..27e68cc
--- /dev/null
+++ b/sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.fla
Binary files differ
diff --git a/sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.swf b/sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.swf
new file mode 100644
index 0000000..dbe17b6
--- /dev/null
+++ b/sources/plugins/htmlwriter/samples/assets/outputforflash/outputforflash.swf
Binary files differ
diff --git a/sources/plugins/htmlwriter/samples/assets/outputforflash/swfobject.js b/sources/plugins/htmlwriter/samples/assets/outputforflash/swfobject.js
new file mode 100644
index 0000000..90cdcc9
--- /dev/null
+++ b/sources/plugins/htmlwriter/samples/assets/outputforflash/swfobject.js
@@ -0,0 +1,5 @@
1
2/* SWFObject v2.2 <http://code.google.com/p/swfobject/>
3 is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
4*/
5var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
diff --git a/sources/plugins/htmlwriter/samples/outputforflash.html b/sources/plugins/htmlwriter/samples/outputforflash.html
new file mode 100644
index 0000000..f72616d
--- /dev/null
+++ b/sources/plugins/htmlwriter/samples/outputforflash.html
@@ -0,0 +1,283 @@
1<!DOCTYPE html>
2<!--
3Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
4For licensing, see LICENSE.md or http://ckeditor.com/license
5-->
6<html>
7<head>
8 <meta charset="utf-8">
9 <title>Output for Flash &mdash; CKEditor Sample</title>
10 <script src="../../../ckeditor.js"></script>
11 <script src="../../../samples/old/sample.js"></script>
12 <script src="assets/outputforflash/swfobject.js"></script>
13 <link href="../../../samples/old/sample.css" rel="stylesheet">
14 <meta name="ckeditor-sample-required-plugins" content="sourcearea">
15 <meta name="ckeditor-sample-name" content="Output for Flash">
16 <meta name="ckeditor-sample-group" content="Advanced Samples">
17 <meta name="ckeditor-sample-description" content="Configuring CKEditor to produce HTML code that can be used with Adobe Flash.">
18 <style>
19
20 .alert
21 {
22 background: #ffa84c;
23 padding: 10px 15px;
24 font-weight: bold;
25 display: block;
26 margin-bottom: 20px;
27 }
28
29 </style>
30</head>
31<body>
32 <h1 class="samples">
33 <a href="../../../samples/old/index.html">CKEditor Samples</a> &raquo; Producing Flash Compliant HTML Output
34 </h1>
35 <div class="warning deprecated">
36 This sample is not maintained anymore. Check out the <a href="http://sdk.ckeditor.com/">brand new samples in CKEditor SDK</a>.
37 </div>
38 <div class="description">
39 <p>
40 This sample shows how to configure CKEditor to output
41 HTML code that can be used with
42 <a class="samples" href="http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00000922.html">
43 Adobe Flash</a>.
44 The code will contain a subset of standard HTML elements like <code>&lt;b&gt;</code>,
45 <code>&lt;i&gt;</code>, and <code>&lt;p&gt;</code> as well as HTML attributes.
46 </p>
47 <p>
48 To add a CKEditor instance outputting Flash compliant HTML code, load the editor using a standard
49 JavaScript call, and define CKEditor features to use HTML elements and attributes.
50 </p>
51 <p>
52 For details on how to create this setup check the source code of this sample page.
53 </p>
54 </div>
55 <p>
56 To see how it works, create some content in the editing area of CKEditor on the left
57 and send it to the Flash object on the right side of the page by using the
58 <strong>Send to Flash</strong> button.
59 </p>
60 <table style="width: 100%; border-spacing: 0; border-collapse:collapse;">
61 <tr>
62 <td style="width: 100%">
63 <textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;&lt;b&gt;&lt;font size=&quot;18&quot; style=&quot;font-size:18px;&quot;&gt;Flash and HTML&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;It is possible to have &lt;a href=&quot;http://ckeditor.com&quot;&gt;CKEditor&lt;/a&gt; creating content that will be later loaded inside &lt;b&gt;Flash&lt;/b&gt; objects and animations.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Flash has a few limitations when dealing with HTML:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;It has limited support on tags.&lt;/li&gt;&lt;li&gt;There is no margin between block elements, like paragraphs.&lt;/li&gt;&lt;/ul&gt;</textarea>
64 <script>
65
66 if ( document.location.protocol == 'file:' )
67 alert( 'Warning: This samples does not work when loaded from local filesystem' +
68 'due to security restrictions implemented in Flash.' +
69 '\n\nPlease load the sample from a web server instead.' );
70
71 var editor = CKEDITOR.replace( 'editor1', {
72 /*
73 * Ensure that htmlwriter plugin, which is required for this sample, is loaded.
74 */
75 extraPlugins: 'htmlwriter',
76
77 height: 290,
78 width: '100%',
79 toolbar: [
80 [ 'Source', '-', 'Bold', 'Italic', 'Underline', '-', 'BulletedList', '-', 'Link', 'Unlink' ],
81 [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ],
82 '/',
83 [ 'Font', 'FontSize' ],
84 [ 'TextColor', '-', 'About' ]
85 ],
86
87 /*
88 * Style sheet for the contents
89 */
90 contentsCss: 'body {color:#000; background-color#FFF; font-family: Arial; font-size:80%;} p, ol, ul {margin-top: 0px; margin-bottom: 0px;}',
91
92 /*
93 * Quirks doctype
94 */
95 docType: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
96
97 /*
98 * Core styles.
99 */
100 coreStyles_bold: { element: 'b' },
101 coreStyles_italic: { element: 'i' },
102 coreStyles_underline: { element: 'u' },
103
104 /*
105 * Font face.
106 */
107
108 // Define the way font elements will be applied to the document. The "font"
109 // element will be used.
110 font_style: {
111 element: 'font',
112 attributes: { 'face': '#(family)' }
113 },
114
115 /*
116 * Font sizes.
117 */
118
119 // The CSS part of the font sizes isn't used by Flash, it is there to get the
120 // font rendered correctly in CKEditor.
121 fontSize_sizes: '8px/8;9px/9;10px/10;11px/11;12px/12;14px/14;16px/16;18px/18;20px/20;22px/22;24px/24;26px/26;28px/28;36px/36;48px/48;72px/72',
122 fontSize_style: {
123 element: 'font',
124 attributes: { 'size': '#(size)' },
125 styles: { 'font-size': '#(size)px' }
126 } ,
127
128 /*
129 * Font colors.
130 */
131 colorButton_enableMore: true,
132
133 colorButton_foreStyle: {
134 element: 'font',
135 attributes: { 'color': '#(color)' }
136 },
137
138 colorButton_backStyle: {
139 element: 'font',
140 styles: { 'background-color': '#(color)' }
141 },
142
143 on: { 'instanceReady': configureFlashOutput }
144 });
145
146 /*
147 * Adjust the behavior of the dataProcessor to match the
148 * requirements of Flash
149 */
150 function configureFlashOutput( ev ) {
151 var editor = ev.editor,
152 dataProcessor = editor.dataProcessor,
153 htmlFilter = dataProcessor && dataProcessor.htmlFilter;
154
155 // Out self closing tags the HTML4 way, like <br>.
156 dataProcessor.writer.selfClosingEnd = '>';
157
158 // Make output formatting match Flash expectations
159 var dtd = CKEDITOR.dtd;
160 for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) ) {
161 dataProcessor.writer.setRules( e, {
162 indent: false,
163 breakBeforeOpen: false,
164 breakAfterOpen: false,
165 breakBeforeClose: false,
166 breakAfterClose: false
167 });
168 }
169 dataProcessor.writer.setRules( 'br', {
170 indent: false,
171 breakBeforeOpen: false,
172 breakAfterOpen: false,
173 breakBeforeClose: false,
174 breakAfterClose: false
175 });
176
177 // Output properties as attributes, not styles.
178 htmlFilter.addRules( {
179 elements: {
180 $: function( element ) {
181 var style, match, width, height, align;
182
183 // Output dimensions of images as width and height
184 if ( element.name == 'img' ) {
185 style = element.attributes.style;
186
187 if ( style ) {
188 // Get the width from the style.
189 match = ( /(?:^|\s)width\s*:\s*(\d+)px/i ).exec( style );
190 width = match && match[1];
191
192 // Get the height from the style.
193 match = ( /(?:^|\s)height\s*:\s*(\d+)px/i ).exec( style );
194 height = match && match[1];
195
196 if ( width ) {
197 element.attributes.style = element.attributes.style.replace( /(?:^|\s)width\s*:\s*(\d+)px;?/i , '' );
198 element.attributes.width = width;
199 }
200
201 if ( height ) {
202 element.attributes.style = element.attributes.style.replace( /(?:^|\s)height\s*:\s*(\d+)px;?/i , '' );
203 element.attributes.height = height;
204 }
205 }
206 }
207
208 // Output alignment of paragraphs using align
209 if ( element.name == 'p' ) {
210 style = element.attributes.style;
211
212 if ( style ) {
213 // Get the align from the style.
214 match = ( /(?:^|\s)text-align\s*:\s*(\w*);?/i ).exec( style );
215 align = match && match[1];
216
217 if ( align ) {
218 element.attributes.style = element.attributes.style.replace( /(?:^|\s)text-align\s*:\s*(\w*);?/i , '' );
219 element.attributes.align = align;
220 }
221 }
222 }
223
224 if ( element.attributes.style === '' )
225 delete element.attributes.style;
226
227 return element;
228 }
229 }
230 });
231 }
232
233 function sendToFlash() {
234 var html = CKEDITOR.instances.editor1.getData() ;
235
236 // Quick fix for link color.
237 html = html.replace( /<a /g, '<font color="#0000FF"><u><a ' )
238 html = html.replace( /<\/a>/g, '</a></u></font>' )
239
240 var flash = document.getElementById( 'ckFlashContainer' ) ;
241 flash.setData( html ) ;
242 }
243
244 CKEDITOR.domReady( function() {
245 if ( !swfobject.hasFlashPlayerVersion( '8' ) ) {
246 CKEDITOR.dom.element.createFromHtml( '<span class="alert">' +
247 'At least Adobe Flash Player 8 is required to run this sample. ' +
248 'You can download it from <a href="http://get.adobe.com/flashplayer">Adobe\'s website</a>.' +
249 '</span>' ).insertBefore( editor.element );
250 }
251
252 swfobject.embedSWF(
253 'assets/outputforflash/outputforflash.swf',
254 'ckFlashContainer',
255 '550',
256 '400',
257 '8',
258 { wmode: 'transparent' }
259 );
260 });
261
262 </script>
263 <p>
264 <input type="button" value="Send to Flash" onclick="sendToFlash();">
265 </p>
266 </td>
267 <td style="vertical-align: top; padding-left: 20px">
268 <div id="ckFlashContainer"></div>
269 </td>
270 </tr>
271 </table>
272 <div id="footer">
273 <hr>
274 <p>
275 CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
276 </p>
277 <p id="copy">
278 Copyright &copy; 2003-2017, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
279 Knabben. All rights reserved.
280 </p>
281 </div>
282</body>
283</html>
diff --git a/sources/plugins/htmlwriter/samples/outputhtml.html b/sources/plugins/htmlwriter/samples/outputhtml.html
new file mode 100644
index 0000000..a433025
--- /dev/null
+++ b/sources/plugins/htmlwriter/samples/outputhtml.html
@@ -0,0 +1,224 @@
1<!DOCTYPE html>
2<!--
3Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
4For licensing, see LICENSE.md or http://ckeditor.com/license
5-->
6<html>
7<head>
8 <meta charset="utf-8">
9 <title>HTML Compliant Output &mdash; CKEditor Sample</title>
10 <script src="../../../ckeditor.js"></script>
11 <script src="../../../samples/old/sample.js"></script>
12 <link href="../../../samples/old/sample.css" rel="stylesheet">
13 <meta name="ckeditor-sample-required-plugins" content="sourcearea">
14 <meta name="ckeditor-sample-name" content="Output HTML">
15 <meta name="ckeditor-sample-group" content="Advanced Samples">
16 <meta name="ckeditor-sample-description" content="Configuring CKEditor to produce legacy HTML 4 code.">
17</head>
18<body>
19 <h1 class="samples">
20 <a href="../../../samples/old/index.html">CKEditor Samples</a> &raquo; Producing HTML Compliant Output
21 </h1>
22 <div class="warning deprecated">
23 This sample is not maintained anymore. Check out the <a href="http://sdk.ckeditor.com/">brand new samples in CKEditor SDK</a>.
24 </div>
25 <div class="description">
26 <p>
27 This sample shows how to configure CKEditor to output valid
28 <a class="samples" href="http://www.w3.org/TR/html401/">HTML 4.01</a> code.
29 Traditional HTML elements like <code>&lt;b&gt;</code>,
30 <code>&lt;i&gt;</code>, and <code>&lt;font&gt;</code> are used in place of
31 <code>&lt;strong&gt;</code>, <code>&lt;em&gt;</code>, and CSS styles.
32 </p>
33 <p>
34 To add a CKEditor instance outputting legacy HTML 4.01 code, load the editor using a standard
35 JavaScript call, and define CKEditor features to use the HTML compliant elements and attributes.
36 </p>
37 <p>
38 A snippet of the configuration code can be seen below; check the source of this page for
39 full definition:
40 </p>
41<pre class="samples">
42CKEDITOR.replace( '<em>textarea_id</em>', {
43 coreStyles_bold: { element: 'b' },
44 coreStyles_italic: { element: 'i' },
45
46 fontSize_style: {
47 element: 'font',
48 attributes: { 'size': '#(size)' }
49 }
50
51 ...
52});</pre>
53 </div>
54 <form action="../../../samples/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">&lt;p&gt;This is some &lt;b&gt;sample text&lt;/b&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
60 <script>
61
62 CKEDITOR.replace( 'editor1', {
63 /*
64 * Ensure that htmlwriter plugin, which is required for this sample, is loaded.
65 */
66 extraPlugins: 'htmlwriter',
67
68 /*
69 * Style sheet for the contents
70 */
71 contentsCss: 'body {color:#000; background-color#:FFF;}',
72
73 /*
74 * Simple HTML5 doctype
75 */
76 docType: '<!DOCTYPE HTML>',
77
78 /*
79 * Allowed content rules which beside limiting allowed HTML
80 * will also take care of transforming styles to attributes
81 * (currently only for img - see transformation rules defined below).
82 *
83 * Read more: http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter
84 */
85 allowedContent:
86 'h1 h2 h3 p pre[align]; ' +
87 'blockquote code kbd samp var del ins cite q b i u strike ul ol li hr table tbody tr td th caption; ' +
88 'img[!src,alt,align,width,height]; font[!face]; font[!family]; font[!color]; font[!size]; font{!background-color}; a[!href]; a[!name]',
89
90 /*
91 * Core styles.
92 */
93 coreStyles_bold: { element: 'b' },
94 coreStyles_italic: { element: 'i' },
95 coreStyles_underline: { element: 'u' },
96 coreStyles_strike: { element: 'strike' },
97
98 /*
99 * Font face.
100 */
101
102 // Define the way font elements will be applied to the document.
103 // The "font" element will be used.
104 font_style: {
105 element: 'font',
106 attributes: { 'face': '#(family)' }
107 },
108
109 /*
110 * Font sizes.
111 */
112 fontSize_sizes: 'xx-small/1;x-small/2;small/3;medium/4;large/5;x-large/6;xx-large/7',
113 fontSize_style: {
114 element: 'font',
115 attributes: { 'size': '#(size)' }
116 },
117
118 /*
119 * Font colors.
120 */
121
122 colorButton_foreStyle: {
123 element: 'font',
124 attributes: { 'color': '#(color)' }
125 },
126
127 colorButton_backStyle: {
128 element: 'font',
129 styles: { 'background-color': '#(color)' }
130 },
131
132 /*
133 * Styles combo.
134 */
135 stylesSet: [
136 { name: 'Computer Code', element: 'code' },
137 { name: 'Keyboard Phrase', element: 'kbd' },
138 { name: 'Sample Text', element: 'samp' },
139 { name: 'Variable', element: 'var' },
140 { name: 'Deleted Text', element: 'del' },
141 { name: 'Inserted Text', element: 'ins' },
142 { name: 'Cited Work', element: 'cite' },
143 { name: 'Inline Quotation', element: 'q' }
144 ],
145
146 on: {
147 pluginsLoaded: configureTransformations,
148 loaded: configureHtmlWriter
149 }
150 });
151
152 /*
153 * Add missing content transformations.
154 */
155 function configureTransformations( evt ) {
156 var editor = evt.editor;
157
158 editor.dataProcessor.htmlFilter.addRules( {
159 attributes: {
160 style: function( value, element ) {
161 // Return #RGB for background and border colors
162 return CKEDITOR.tools.convertRgbToHex( value );
163 }
164 }
165 } );
166
167 // Default automatic content transformations do not yet take care of
168 // align attributes on blocks, so we need to add our own transformation rules.
169 function alignToAttribute( element ) {
170 if ( element.styles[ 'text-align' ] ) {
171 element.attributes.align = element.styles[ 'text-align' ];
172 delete element.styles[ 'text-align' ];
173 }
174 }
175 editor.filter.addTransformations( [
176 [ { element: 'p', right: alignToAttribute } ],
177 [ { element: 'h1', right: alignToAttribute } ],
178 [ { element: 'h2', right: alignToAttribute } ],
179 [ { element: 'h3', right: alignToAttribute } ],
180 [ { element: 'pre', right: alignToAttribute } ]
181 ] );
182 }
183
184 /*
185 * Adjust the behavior of htmlWriter to make it output HTML like FCKeditor.
186 */
187 function configureHtmlWriter( evt ) {
188 var editor = evt.editor,
189 dataProcessor = editor.dataProcessor;
190
191 // Out self closing tags the HTML4 way, like <br>.
192 dataProcessor.writer.selfClosingEnd = '>';
193
194 // Make output formatting behave similar to FCKeditor.
195 var dtd = CKEDITOR.dtd;
196 for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) ) {
197 dataProcessor.writer.setRules( e, {
198 indent: true,
199 breakBeforeOpen: true,
200 breakAfterOpen: false,
201 breakBeforeClose: !dtd[ e ][ '#' ],
202 breakAfterClose: true
203 });
204 }
205 }
206
207 </script>
208 </p>
209 <p>
210 <input type="submit" value="Submit">
211 </p>
212 </form>
213 <div id="footer">
214 <hr>
215 <p>
216 CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
217 </p>
218 <p id="copy">
219 Copyright &copy; 2003-2017, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
220 Knabben. All rights reserved.
221 </p>
222 </div>
223</body>
224</html>