8
0

tablewidgettoolbar.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Copyright (c) 2016 - 2018, CKSource - Frederico Knabben. All rights reserved.
  3. */
  4. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  5. import { isTableWidgetSelected } from '@ckeditor/ckeditor5-table/src/utils';
  6. import WidgetToolbar from '@ckeditor/ckeditor5-widget/src/widgettoolbar';
  7. /**
  8. * The table widget toolbar class. It creates a table toolbar that shows up when the table widget is selected.
  9. *
  10. * The toolbar uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
  11. *
  12. * @extends module:core/plugin~Plugin
  13. */
  14. export default class TableWidgetToolbar extends Plugin {
  15. /**
  16. * @inheritDoc
  17. */
  18. static get requires() {
  19. return [ WidgetToolbar ];
  20. }
  21. /**
  22. * @inheritDoc
  23. */
  24. static get pluginName() {
  25. return 'TableWidgetToolbar';
  26. }
  27. /**
  28. * @inheritDoc
  29. */
  30. afterInit() {
  31. const editor = this.editor;
  32. const widgetToolbar = editor.plugins.get( 'WidgetToolbar' );
  33. widgetToolbar.add( 'tableWidget', {
  34. toolbarItems: editor.config.get( 'table.widgetToolbar' ) || [],
  35. isVisible: isTableWidgetSelected,
  36. } );
  37. }
  38. }