File: htmlwriter.js

package info (click to toggle)
ckeditor 4.16.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 258,804 kB
  • sloc: javascript: 239,590; sh: 184; makefile: 64; python: 37; php: 15; xml: 5
file content (94 lines) | stat: -rw-r--r-- 2,365 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* bender-tags: editor */
/* bender-ckeditor-plugins: wysiwygarea, htmlwriter */

bender.test( {
	'test extra line break': function() {
		var data = '<div>Text <strong>inline</strong> Text <p>paragraph</p></div>';

		bender.editorBot.create( {
			name: 'basic1',
			formattedOutput: true,

			config: {
				allowedContent: true,

				on: {
					instanceReady: function( evt ) {
						evt.editor.dataProcessor.writer.setRules( 'p', {
							indent: true,
							breakBeforeOpen: true,
							breakAfterOpen: true,
							breakBeforeClose: true,
							breakAfterClose: true
						} );

						evt.editor.dataProcessor.writer.setRules( 'div', {
							indent: true,
							breakBeforeOpen: false,
							breakAfterOpen: true,
							breakBeforeClose: false,
							breakAfterClose: true
						} );
					}
				}
			}
		}, function( bot ) {
			bot.setData( data, function() {
				var afterFormat = bot.getData( false, false );

				// Trigger getData a second time to reveal bug.
				assert.areSame( afterFormat, bot.getData( false, false ) );
			} );
		} );
	},

	// (#965)
	'test config.forceSimpleAmpersand works in HTML element attributes': function() {
		var data = '<p><a href="http://www.blah.com?foo=1&bar=2">Test link</a></p>';

		bender.editorBot.create( {
			name: 'forceSimpleAmpersand',
			formattedOutput: true,
			config: {
				extraAllowedContent: 'a[href]',
				forceSimpleAmpersand: true
			}
		}, function( bot ) {
			bot.editor.dataProcessor.writer.setRules( 'p', {
				indent: false,
				breakAfterClose: false
			} );

			bot.setData( data, function() {
				assert.areSame( data, bot.getData( false, false ) );
			} );
		} );
	},

	// (#3795)
	'test dataIndentationChars with empty character': function() {
		// We are testing against indentation, not new line character. Preserve new lines for smoother comparison.
		var data = '<ol>\n<li>One</li>\n<li>Two</li>\n<li>Three</li>\n</ol>\n';

		bender.editorBot.create( {
			name: 'dataIndentationChars',
			formattedOutput: true,
			config: {
				allowedContent: true,
				dataIndentationChars: ''
			}
		}, function( bot ) {
			bot.editor.dataProcessor.writer.setRules( 'ol', {
				indent: true
			} );

			bot.editor.dataProcessor.writer.setRules( 'li', {
				indent: true
			} );

			bot.setData( data, function() {
				assert.areSame( data, bot.getData( false, false ) );
			} );
		} );
	}
} );