Browse Source

Improved positioning for cell and table properties balloons.

Aleksander Nowodzinski 5 years ago
parent
commit
4a8c95f2cd

+ 1 - 1
packages/ckeditor5-table/src/tablecellproperties/tablecellpropertiesui.js

@@ -136,7 +136,7 @@ export default class TableCellPropertiesUI extends Plugin {
 			if ( !getTableWidgetAncestor( viewDocument.selection ) ) {
 				this._hideView();
 			} else if ( this._isViewVisible ) {
-				repositionContextualBalloon( editor );
+				repositionContextualBalloon( editor, 'cell' );
 			}
 		} );
 

+ 1 - 1
packages/ckeditor5-table/src/tableproperties/tablepropertiesui.js

@@ -138,7 +138,7 @@ export default class TablePropertiesUI extends Plugin {
 			if ( !getTableWidgetAncestor( viewDocument.selection ) ) {
 				this._hideView();
 			} else if ( this._isViewVisible ) {
-				repositionContextualBalloon( editor );
+				repositionContextualBalloon( editor, 'table' );
 			}
 		} );
 

+ 10 - 2
packages/ckeditor5-table/src/ui/utils.js

@@ -30,12 +30,20 @@ const BALLOON_POSITIONS = [
  * with respect to the table in the editor content, if one is selected.
  *
  * @param {module:core/editor/editor~Editor} editor The editor instance.
+ * @param {String} target Either "cell" or "table". Determines the the target the ballon will
+ * be attached to.
  */
-export function repositionContextualBalloon( editor ) {
+export function repositionContextualBalloon( editor, target ) {
 	const balloon = editor.plugins.get( 'ContextualBalloon' );
 
 	if ( getTableWidgetAncestor( editor.editing.view.document.selection ) ) {
-		const position = getBalloonCellPositionData( editor );
+		let position;
+
+		if ( target === 'cell' ) {
+			position = getBalloonCellPositionData( editor );
+		} else {
+			position = getBalloonTablePositionData( editor );
+		}
 
 		balloon.updatePosition( position );
 	}