aboutsummaryrefslogtreecommitdiff
path: root/sources/core/editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'sources/core/editor.js')
-rw-r--r--sources/core/editor.js45
1 files changed, 43 insertions, 2 deletions
diff --git a/sources/core/editor.js b/sources/core/editor.js
index f29be63f..31188d24 100644
--- a/sources/core/editor.js
+++ b/sources/core/editor.js
@@ -1,5 +1,5 @@
1/** 1/**
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. 2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license 3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */ 4 */
5 5
@@ -654,6 +654,47 @@
654 return editor.blockless ? CKEDITOR.ENTER_BR : enterMode; 654 return editor.blockless ? CKEDITOR.ENTER_BR : enterMode;
655 } 655 }
656 656
657 // Create DocumentFragment from specified ranges. For now it handles only tables in Firefox
658 // and returns DocumentFragment from the 1. range for other cases. (#13884)
659 function createDocumentFragmentFromRanges( ranges, editable ) {
660 var docFragment = new CKEDITOR.dom.documentFragment(),
661 tableClone,
662 currentRow,
663 currentRowClone;
664
665 for ( var i = 0; i < ranges.length; i++ ) {
666 var range = ranges[ i ],
667 container = range.startContainer;
668
669 if ( container.getName && container.getName() == 'tr' ) {
670 if ( !tableClone ) {
671 tableClone = container.getAscendant( 'table' ).clone();
672 tableClone.append( container.getAscendant( 'tbody' ).clone() );
673 docFragment.append( tableClone );
674 tableClone = tableClone.findOne( 'tbody' );
675 }
676
677 if ( !( currentRow && currentRow.equals( container ) ) ) {
678 currentRow = container;
679 currentRowClone = container.clone();
680 tableClone.append( currentRowClone );
681 }
682
683 currentRowClone.append( range.cloneContents() );
684 } else {
685 // If there was something else copied with table,
686 // append it to DocumentFragment.
687 docFragment.append( range.cloneContents() );
688 }
689 }
690
691 if ( !tableClone ) {
692 return editable.getHtmlFromRange( ranges[ 0 ] );
693 }
694
695 return docFragment;
696 }
697
657 CKEDITOR.tools.extend( CKEDITOR.editor.prototype, { 698 CKEDITOR.tools.extend( CKEDITOR.editor.prototype, {
658 /** 699 /**
659 * Adds a command definition to the editor instance. Commands added with 700 * Adds a command definition to the editor instance. Commands added with
@@ -1133,7 +1174,7 @@
1133 return null; 1174 return null;
1134 } 1175 }
1135 1176
1136 var docFragment = editable.getHtmlFromRange( ranges[ 0 ] ); 1177 var docFragment = createDocumentFragmentFromRanges( ranges, editable );
1137 1178
1138 return toString ? docFragment.getHtml() : docFragment; 1179 return toString ? docFragment.getHtml() : docFragment;
1139 }, 1180 },