8
0
Quellcode durchsuchen

Added: Initial 'insertTable' button.

Maciej Gołaszewski vor 7 Jahren
Ursprung
Commit
41e8032999

+ 1 - 1
packages/ckeditor5-table/src/inserttablecommand.js

@@ -4,7 +4,7 @@
  */
 
 /**
- * @module table/tablecommand
+ * @module table/inserttablecommand
  */
 
 import Command from '@ckeditor/ckeditor5-core/src/command';

+ 23 - 0
packages/ckeditor5-table/src/tableui.js

@@ -8,6 +8,29 @@
  */
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
+
+import icon from '@ckeditor/ckeditor5-core/theme/icons/object-center.svg';
 
 export default class TableUI extends Plugin {
+	init() {
+		const editor = this.editor;
+
+		editor.ui.componentFactory.add( 'insertTable', locale => {
+			const buttonView = new ButtonView( locale );
+
+			buttonView.set( {
+				label: 'Insert table',
+				icon,
+				tooltip: true
+			} );
+
+			buttonView.on( 'execute', () => {
+				editor.execute( 'insertTable' );
+				editor.editing.view.focus();
+			} );
+
+			return buttonView;
+		} );
+	}
 }

+ 1 - 1
packages/ckeditor5-table/tests/manual/table.js

@@ -13,7 +13,7 @@ ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [ ArticlePluginSet, Table ],
 		toolbar: [
-			'headings', '|', 'bold', 'italic', 'undo', 'redo'
+			'headings', '|', 'insertTable', '|', 'bold', 'italic', 'undo', 'redo'
 		]
 	} )
 	.then( editor => {