File: brmode.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 (50 lines) | stat: -rw-r--r-- 1,721 bytes parent folder | download | duplicates (4)
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
/* bender-tags: editor */
/* bender-ckeditor-plugins: entities,enterkey */

( function() {
	bender.editor = {
		config: {
			enterMode: CKEDITOR.ENTER_BR,
			allowedContent: true
		}
	};

	bender.test( {
		doTest: function( input, expected, msg ) {
			var ed = this.editor;
			bender.tools.setHtmlWithSelection( ed,  input );
			ed.execCommand( 'enter' );
			var output = bender.tools.getHtmlWithSelection( ed );
			expected.exec ?
				assert.isMatching( expected, output, msg ) :
				assert.areSame( expected, output, msg );
		},

		'test enter mode br': function() {
			this.doTest( '<p>foo^bar</p>', '<p>foo<br />^bar</p>', 'in block' );
			this.doTest( '<ul><li>foo^</li></ul>', '<ul><li>foo</li><li>^&nbsp;</li></ul>', 'end of list item' );
			this.doTest( '<h1>foo^</h1>bar', CKEDITOR.env.ie && CKEDITOR.env.version < 9 ? '<h1>foo^</h1><br />bar' : '<h1>foo</h1>^<br />bar', 'end of heading' );
			this.doTest( '<h1 dir="rtl">foo^</h1>', '<h1 dir="rtl">foo</h1><div dir="rtl">^&nbsp;</div>', 'end of heading (with direction)' );
			this.doTest( '<pre>foo^bar</pre>', /^<pre>foo(\r\n|\r|\n|<br \/>)\^bar<\/pre>$/, 'in pre' );
		}

		/*
		// Commented out until we decide whether we want to block enter key completely and how.
		'test blocked if active filter does not allow br': function() {
			var filter = new CKEDITOR.filter( 'p' );
			this.editor.setActiveFilter( filter );

			try {
				this.doTest( '<p>foo^bar</p>', '<p>foo^bar</p>', 'br is blocked' );
			} catch ( e ) {
				throw e;
			} finally {
				// Always reset filter - even if previous test failed.
				this.editor.setActiveFilter( null );
			}

			this.doTest( '<p>foo^bar</p>', '<p>foo<br />^bar</p>', 'br is not blocked' );
		}
		*/
	} );
} )();