Kaynağa Gözat

Internal: Initial resizer API mocks.

Marek Lewandowski 6 yıl önce
ebeveyn
işleme
fdad8c85ed

+ 10 - 0
packages/ckeditor5-widget/src/utils.js

@@ -108,6 +108,10 @@ export function toWidget( element, writer, options = {} ) {
 		addSelectionHandler( element, writer );
 	}
 
+	if ( options.features ) {
+		addWidgetFeatures( element, writer, options.features );
+	}
+
 	setHighlightHandling(
 		element,
 		writer,
@@ -379,3 +383,9 @@ function addSelectionHandler( widgetElement, writer ) {
 	writer.insert( writer.createPositionAt( widgetElement, 0 ), selectionHandler );
 	writer.addClass( [ 'ck-widget_with-selection-handler' ], widgetElement );
 }
+
+function addWidgetFeatures( element, writer, features ) {
+	for ( const currentFeature of features ) {
+		currentFeature.apply( element, writer );
+	}
+}

+ 16 - 0
packages/ckeditor5-widget/src/widgetfeature.js

@@ -0,0 +1,16 @@
+/**
+ * @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/widget
+ */
+
+/**
+ * The base class for widget features. This type provides a common API for reusable features of widgets.
+ */
+export default class WidgetFeature {
+	apply() {
+	}
+}

+ 27 - 0
packages/ckeditor5-widget/src/widgetresizefeature.js

@@ -0,0 +1,27 @@
+/**
+ * @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/widget
+ */
+
+import WidgetFeature from './widgetfeature';
+
+export const WIDGET_RESIZE_ATTRIBUTE_NAME = 'resizer';
+
+/**
+ * The base class for widget features. This type provides a common API for reusable features of widgets.
+ */
+export default class WidgetResizeFeature extends WidgetFeature {
+	apply( widget, writer ) {
+		super.apply( widget, writer );
+
+		// writer.setCustomProperty( WIDGET_RESIZE_ATTRIBUTE_NAME, true, widget );
+		writer.setAttribute( WIDGET_RESIZE_ATTRIBUTE_NAME, true, widget );
+
+		// widget.setAttribute( WIDGET_RESIZE_ATTRIBUTE_NAME );
+		// aaa
+	}
+}