summaryrefslogtreecommitdiff
path: root/_source/plugins/split
diff options
context:
space:
mode:
authorLester Caine <lsces@lsces.co.uk>2010-07-29 20:31:06 +0100
committerLester Caine <lsces@lsces.co.uk>2010-07-29 20:31:06 +0100
commit1a293c5c57779b3750b561b5fe295aff33b3ebf9 (patch)
tree254fc36fc473e7d60b88324d550ce95f94e18cca /_source/plugins/split
parent33c69a19cc35f82336bce6020b15e33152ff8763 (diff)
downloadckeditor-1a293c5c57779b3750b561b5fe295aff33b3ebf9.tar.gz
ckeditor-1a293c5c57779b3750b561b5fe295aff33b3ebf9.tar.bz2
ckeditor-1a293c5c57779b3750b561b5fe295aff33b3ebf9.zip
ync with version 3.3.1 of CKEditor
Diffstat (limited to '_source/plugins/split')
-rw-r--r--_source/plugins/split/images/split.gifbin0 -> 54 bytes
-rw-r--r--_source/plugins/split/plugin.js107
2 files changed, 107 insertions, 0 deletions
diff --git a/_source/plugins/split/images/split.gif b/_source/plugins/split/images/split.gif
new file mode 100644
index 0000000..8d1cffd
--- /dev/null
+++ b/_source/plugins/split/images/split.gif
Binary files differ
diff --git a/_source/plugins/split/plugin.js b/_source/plugins/split/plugin.js
new file mode 100644
index 0000000..99acbb1
--- /dev/null
+++ b/_source/plugins/split/plugin.js
@@ -0,0 +1,107 @@
+/*
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @file Content Split Marker
+ */
+
+// Register a plugin named "split".
+CKEDITOR.plugins.add( 'split',
+{
+ init : function( editor )
+ {
+ // Register the command.
+ editor.addCommand( 'split', CKEDITOR.plugins.splitCmd );
+
+ // Register the toolbar button.
+ editor.ui.addButton( 'Split',
+ {
+ label : editor.lang.split,
+ command : 'split'
+ });
+
+ // Add the style that renders our placeholder.
+ editor.addCss(
+ 'img.cke_split' +
+ '{' +
+ 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/split.gif' ) + ');' +
+ 'background-position: center center;' +
+ 'background-repeat: no-repeat;' +
+ 'clear: both;' +
+ 'display: block;' +
+ 'float: none;' +
+ 'width:100%;_width:99.9%;' +
+ 'border-top: #999999 1px dotted;' +
+ 'border-bottom: #999999 1px dotted;' +
+ 'height: 5px;' +
+ 'page-break-after: always;' +
+
+ '}' );
+ },
+
+ afterInit : function( editor )
+ {
+ // Register a filter to displaying placeholders after mode change.
+
+ var dataProcessor = editor.dataProcessor,
+ dataFilter = dataProcessor && dataProcessor.dataFilter;
+
+ if ( dataFilter )
+ {
+ dataFilter.addRules(
+ {
+ elements :
+ {
+ div : function( element )
+ {
+ var attributes = element.attributes,
+ style = attributes && attributes.style,
+ child = style && element.children.length == 1 && element.children[ 0 ],
+ childStyle = child && ( child.name == 'span' ) && child.attributes.style;
+
+ if ( childStyle && ( /page-break-after\s*:\s*always/i ).test( style ) && ( /display\s*:\s*none/i ).test( childStyle ) )
+ return editor.createFakeParserElement( element, 'cke_split', 'div' );
+ }
+ }
+ });
+ }
+ },
+
+ requires : [ 'fakeobjects' ]
+});
+
+CKEDITOR.plugins.splitCmd =
+{
+ exec : function( editor )
+ {
+ // Create the element that represents a print break.
+ var breakObject = CKEDITOR.dom.element.createFromHtml( '<div style="page-break-after: always;"><span style="display: none;">&nbsp;</span></div>...split...' );
+
+ // Creates the fake image used for this element.
+ breakObject = editor.createFakeElement( breakObject, 'cke_split', 'div' );
+
+ var ranges = editor.getSelection().getRanges();
+
+ editor.fire( 'saveSnapshot' );
+
+ for ( var range, i = 0 ; i < ranges.length ; i++ )
+ {
+ range = ranges[ i ];
+
+ if ( i > 0 )
+ breakObject = breakObject.clone( true );
+
+ range.splitBlock( 'p' );
+ range.insertNode( breakObject );
+ if ( i == ranges.length - 1 )
+ {
+ range.moveToPosition( breakObject, CKEDITOR.POSITION_AFTER_END );
+ range.select();
+ }
+ }
+
+ editor.fire( 'saveSnapshot' );
+ }
+};