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

Move toTableWidget() util to converters/downcast.js and remove it from public API.

Maciej Gołaszewski 5 лет назад
Родитель
Сommit
fd0817c627

+ 15 - 2
packages/ckeditor5-table/src/converters/downcast.js

@@ -8,8 +8,7 @@
  */
  */
 
 
 import TableWalker from './../tablewalker';
 import TableWalker from './../tablewalker';
-import { toWidgetEditable } from '@ckeditor/ckeditor5-widget/src/utils';
-import { toTableWidget } from '../utils/common';
+import { toWidget, toWidgetEditable } from '@ckeditor/ckeditor5-widget/src/utils';
 
 
 /**
 /**
  * Model table element to view table element conversion helper.
  * Model table element to view table element conversion helper.
@@ -312,6 +311,20 @@ export function downcastRemoveRow() {
 	}, { priority: 'higher' } );
 	}, { priority: 'higher' } );
 }
 }
 
 
+// Converts a given {@link module:engine/view/element~Element} to a table widget:
+// * Adds a {@link module:engine/view/element~Element#_setCustomProperty custom property} allowing to recognize the table widget element.
+// * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
+//
+// @param {module:engine/view/element~Element} viewElement
+// @param {module:engine/view/downcastwriter~DowncastWriter} writer An instance of the view writer.
+// @param {String} label The element's label. It will be concatenated with the table `alt` attribute if one is present.
+// @returns {module:engine/view/element~Element}
+function toTableWidget( viewElement, writer ) {
+	writer.setCustomProperty( 'table', true, viewElement );
+
+	return toWidget( viewElement, writer, { hasSelectionHandle: true } );
+}
+
 // Renames an existing table cell in the view to a given element name.
 // Renames an existing table cell in the view to a given element name.
 //
 //
 // **Note** This method will not do anything if a view table cell has not been converted yet.
 // **Note** This method will not do anything if a view table cell has not been converted yet.

+ 1 - 17
packages/ckeditor5-table/src/utils/common.js

@@ -7,26 +7,10 @@
  * @module table/utils/common
  * @module table/utils/common
  */
  */
 
 
-import { isWidget, toWidget } from '@ckeditor/ckeditor5-widget/src/utils';
+import { isWidget } from '@ckeditor/ckeditor5-widget/src/utils';
 import { createEmptyTableCell, findAncestor, updateNumericAttribute } from '../commands/utils';
 import { createEmptyTableCell, findAncestor, updateNumericAttribute } from '../commands/utils';
 import TableWalker from '../tablewalker';
 import TableWalker from '../tablewalker';
 
 
-/**
- * Converts a given {@link module:engine/view/element~Element} to a table widget:
- * * Adds a {@link module:engine/view/element~Element#_setCustomProperty custom property} allowing to recognize the table widget element.
- * * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
- *
- * @param {module:engine/view/element~Element} viewElement
- * @param {module:engine/view/downcastwriter~DowncastWriter} writer An instance of the view writer.
- * @param {String} label The element's label. It will be concatenated with the table `alt` attribute if one is present.
- * @returns {module:engine/view/element~Element}
- */
-export function toTableWidget( viewElement, writer ) {
-	writer.setCustomProperty( 'table', true, viewElement );
-
-	return toWidget( viewElement, writer, { hasSelectionHandle: true } );
-}
-
 // Checks if a given view element is a table widget.
 // Checks if a given view element is a table widget.
 //
 //
 // @param {module:engine/view/element~Element} viewElement
 // @param {module:engine/view/element~Element} viewElement