Kaynağa Gözat

Cleanup, use px unit for width.

Piotrek Koszuliński 6 yıl önce
ebeveyn
işleme
858a933b72

+ 10 - 7
packages/ckeditor5-widget/src/resizecontext.js

@@ -1,3 +1,12 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module widget/resizecontext
+ */
+
 import View from '@ckeditor/ckeditor5-ui/src/view';
 import {
 	getAbsoluteBoundaryPoint
@@ -8,12 +17,6 @@ import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
-/**
- * @module widget/resizecontext
- */
-
-const WIDTH_ATTRIBUTE_NAME = 'width';
-
 /**
  * Stores the internal state of a single resizable object.
  *
@@ -195,7 +198,7 @@ export default class ResizeContext {
 		this.redraw();
 
 		editor.model.change( writer => {
-			writer.setAttribute( WIDTH_ATTRIBUTE_NAME, newWidth, modelEntry );
+			writer.setAttribute( 'width', newWidth + 'px', modelEntry );
 		} );
 
 		this._cleanupContext();

+ 4 - 11
packages/ckeditor5-widget/src/widgetresizer.js

@@ -14,8 +14,6 @@ import DomEmitterMixin from '@ckeditor/ckeditor5-utils/src/dom/emittermixin';
 import global from '@ckeditor/ckeditor5-utils/src/dom/global';
 import { throttle } from 'lodash-es';
 
-const WIDTH_ATTRIBUTE_NAME = 'width';
-
 /**
  * Widget resize feature plugin.
  *
@@ -33,12 +31,13 @@ export default class WidgetResizer extends Plugin {
 		this.contexts = [];
 		this.activeContext = null;
 
-		this._registerSchema();
-
 		const mouseObserverHost = global.window.document;
-
 		const THROTTLE_THRESHOLD = 16; // 16ms = ~60fps
 
+		this.editor.model.schema.setAttributeProperties( 'width', {
+			isFormatting: true
+		} );
+
 		this._observers = {
 			mouseMove: Object.create( DomEmitterMixin ),
 			mouseDownUp: Object.create( DomEmitterMixin ),
@@ -174,12 +173,6 @@ export default class WidgetResizer extends Plugin {
 		return this._getContextByWrapper( getAncestors( domResizeHandler )
 			.filter( element => element.classList.contains( 'ck-widget__resizer-wrapper' ) )[ 0 ] );
 	}
-
-	_registerSchema() {
-		this.editor.model.schema.setAttributeProperties( WIDTH_ATTRIBUTE_NAME, {
-			isFormatting: true
-		} );
-	}
 }
 
 /**