Przeglądaj źródła

Imported 2 positions from MT to BalloonPanelView.defaultPositions. Fixed broken MT.

Aleksander Nowodzinski 8 lat temu
rodzic
commit
c36b658f3b

+ 12 - 0
packages/ckeditor5-ui/src/panel/balloon/balloonpanelview.js

@@ -460,5 +460,17 @@ BalloonPanelView.defaultPositions = {
 		top: targetRect.bottom + BalloonPanelView.arrowVerticalOffset,
 		left: targetRect.left - balloonRect.width / 2,
 		name: 'arrow_s'
+	} ),
+
+	southArrowNorth: ( targetRect, balloonRect ) => ( {
+		top: targetRect.bottom + BalloonPanelView.arrowVerticalOffset,
+		left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
+		name: 'arrow_s'
+	} ),
+
+	northArrowSouth: ( targetRect, balloonRect ) => ( {
+		top: targetRect.top - balloonRect.height - BalloonPanelView.arrowVerticalOffset,
+		left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
+		name: 'arrow_n'
 	} )
 };

+ 3 - 26
packages/ckeditor5-ui/tests/manual/imagetoolbar/imagetoolbar.js

@@ -19,31 +19,6 @@ import Template from '../../../src/template';
 import ToolbarView from '../../../src/toolbar/toolbarview';
 import BalloonPanelView from '../../../src/panel/balloon/balloonpanelview';
 
-const arrowVOffset = BalloonPanelView.arrowVerticalOffset;
-const positions = {
-	//          [text range]
-	//                ^
-	//       +-----------------+
-	//       |     Balloon     |
-	//       +-----------------+
-	south: ( targetRect, balloonRect ) => ( {
-		top: targetRect.bottom + arrowVOffset,
-		left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
-		name: 's'
-	} ),
-
-	//	+-----------------+
-	//	|     Balloon     |
-	//	+-----------------+
-	//	        V
-	//	   [text range]
-	north: ( targetRect, balloonRect ) => ( {
-		top: targetRect.top - balloonRect.height - arrowVOffset,
-		left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
-		name: 'n'
-	} )
-};
-
 ClassicEditor.create( document.querySelector( '#editor' ), {
 	plugins: [ Enter, Typing, Paragraph, Undo, Bold, Italic, Image ],
 	toolbar: [ 'bold', 'italic', 'undo', 'redo' ]
@@ -111,9 +86,11 @@ function createImageToolbar( editor ) {
 		} );
 
 		function attachToolbar() {
+			const defaultPositions = BalloonPanelView.defaultPositions;
+
 			panel.attachTo( {
 				target: editingView.domConverter.viewRangeToDom( editingView.selection.getFirstRange() ),
-				positions: [ positions.north, positions.south ]
+				positions: [ defaultPositions.northArrowSouth, defaultPositions.southArrowNorth ]
 			} );
 		}
 	} );

+ 16 - 0
packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

@@ -721,6 +721,22 @@ describe( 'BalloonPanelView', () => {
 				name: 'arrow_s'
 			} );
 		} );
+
+		it( 'southArrowNorth', () => {
+			expect( positions.southArrowNorth( targetRect, balloonRect ) ).to.deep.equal( {
+				top: 215,
+				left: 125,
+				name: 'arrow_s'
+			} );
+		} );
+
+		it( 'northArrowSouth', () => {
+			expect( positions.northArrowSouth( targetRect, balloonRect ) ).to.deep.equal( {
+				top: 35,
+				left: 125,
+				name: 'arrow_n'
+			} );
+		} );
 	} );
 } );