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.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
| 1. / 2. / ...
/*
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @file Plugin for creating Drupal teasers(fake object).
*/
CKEDITOR.plugins.add( 'cspb',
{
requires : [ 'fakeobjects', 'htmldataprocessor' ],
init : function( editor )
{
// Add the style that renders our fake objects.
editor.addCss(
'img.cke_pagebreak, img.cke_drupal_pagebreak,img.cke_drupal_break' +
'{' +
'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/pagebreak.gif' ) + ');' +
'background-position: center center;' +
'background-repeat: repeatx;' +
'display: inline;' +
'width: 100%;' +
'height: 5px;' +
'vertical-align: middle;' +
'border: #999999 1px dotted;' +
'}' );
editor.ui.addButton( 'cspb',
{
label : 'CS Seitenwechsel',
command : 'cspb',
icon : this.path + 'images/pagebreak.gif'
});
function insertComment( editor, text )
{
var ranges = editor.getSelection().getRanges(),
range = ranges[ 0 ],
bookmark;
range.splitBlock( 'p' );
bookmark = range.createBookmark();
var fakeComment = CKEDITOR.dom.element.createFromHtml( editor.dataProcessor.toHtml( '<!--' + text + '-->' ) );
range.insertNode( fakeComment );
range.moveToElementEditStart( fakeComment.getNext() );
range.select();
return fakeComment;
}
editor.addCommand( 'cspb',
{
exec : function( editor )
{
insertComment( editor, '[pagebreak]' );
}
} );
},
afterInit : function( editor )
{
var dataProcessor = editor.dataProcessor,
dataFilter = dataProcessor.dataFilter,
htmlFilter1 = dataProcessor.htmlFilter,
// Borrow the comment output filters to restore them.
commentFilters = htmlFilter1._.comment,
filter = commentFilters && ( commentFilters.filter || commentFilters[ 0 ] );
if ( dataProcessor && dataFilter )
// DataFilter for creating fake objects from HTML comment.
dataFilter.addRules(
{
comment : function( name, value )
{
var cdata = value;
// CData instance is received.
if ( value.value == '[pagebreak]' || value.value == '[pagebreak]<!-- ' )
{
var fakeElement;
// Is it actually a comment and match the desired pattern?
var displayName = '[pagebreak]';
var fakeWrapper = new CKEDITOR.htmlParser.element( '!--' + displayName + '<!-- --', {} );
fakeElement = editor.createFakeParserElement(
fakeWrapper,
'cke_pagebreak',
displayName,
false );
fakeElement.attributes.contenteditable = "false";
fakeElement.attributes[ 'title' ] = displayName;
if ( fakeElement )
{
delete value.name;
return fakeElement;
}
}
return value.value;
}
} );
// HtmlFilter rules for outputting fake comment.
function fakeCommentFilter( element )
{
delete element.name;
}
htmlFilter1.addRules(
{
elements :
{
'pagebreak': fakeCommentFilter
}
} );
}
} ); |