tableborderstylecommand.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module table/tableproperties/commands/tableborderstylecommand
  7. */
  8. import TablePropertyCommand from './tablepropertycommand';
  9. import { getSingleValue } from '../../commands/utils';
  10. /**
  11. * The table style border command.
  12. *
  13. * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as
  14. * the `'tableBorderStyle'` editor command.
  15. *
  16. * To change the border style of the selected table, execute the command:
  17. *
  18. * editor.execute( 'tableBorderStyle', {
  19. * value: 'dashed'
  20. * } );
  21. *
  22. * @extends module:table/tableproperties/commands/tablepropertycommand~TablePropertyCommand
  23. */
  24. export default class TableBorderStyleCommand extends TablePropertyCommand {
  25. /**
  26. * Creates a new `TableBorderStyleCommand` instance.
  27. *
  28. * @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
  29. */
  30. constructor( editor ) {
  31. super( editor, 'borderStyle' );
  32. }
  33. /**
  34. * @inheritDoc
  35. */
  36. _getValue( table ) {
  37. if ( !table ) {
  38. return;
  39. }
  40. return getSingleValue( table.getAttribute( this.attributeName ) );
  41. }
  42. }