8
0
Просмотр исходного кода

Internal: Fixed a case where resize shadow would remain unaffected by image's max-width CSS rule.

Marek Lewandowski 6 лет назад
Родитель
Сommit
cdb25fd98e

+ 8 - 1
packages/ckeditor5-widget/src/resizertopbound.js

@@ -122,7 +122,14 @@ export default class ResizerCentral {
 
 		if ( resizeUsingImage ) {
 			resizeHost.style.width = `${ drawnSize.x }px`;
-			resizeHost.style.height = `${ drawnSize.y }px`;
+			// resizeHost.style.height = `${ drawnSize.y }px`;
+
+			const latestRect = resizeHost.getBoundingClientRect();
+
+			// Refresh values based on real image. Real image might be limited by max-width, and thus fetching it
+			// here will reflect this limitation on resizer shadow later on.
+			drawnSize.x = latestRect.width;
+			drawnSize.y = latestRect.height;
 		} else {
 			const invertedPosition = this.context._invertPosition( context.referenceHandlerPosition );
 

+ 1 - 1
packages/ckeditor5-widget/src/widgetresizer.js

@@ -70,7 +70,7 @@ export default class WidgetResizer extends Plugin {
 		};
 
 		this.editor.editing.view.document.on( 'layoutChanged', () => {
-			// This works around the issue witn undo.
+			// This works around the issue with undo.
 			for ( const context of this.contexts ) {
 				// This check is needed, as there were cases when widget was not yet initialized but layoutChanged happened.
 				if ( context.domResizeWrapper && context.domResizeWrapper.parentElement ) {