import { VegaRTEExtensionRenderer } from '../../base-extension-renderer';
import { isNonNullable } from '../../../../../types/type-guard';
export const TABLE_CAPTION_PLACEHOLDER_TEXT = 'Enter table caption';
/**
 * Renderer for the optional table caption node.
 */
export class RTETableCaptionRenderer extends VegaRTEExtensionRenderer {
  /**
   * @inheritDoc
   */
  doRender(h, renderData) {
    return h('caption', {
      'key': renderData.id,
      'ref': this.useRef(renderData),
      'style': renderData.getStyles(),
      'class': [renderData.getClasses(), renderData.isNotEmpty() ? null : 'showPlaceholder']
        .filter(isNonNullable)
        .join(' '),
      'data-placeholder': TABLE_CAPTION_PLACEHOLDER_TEXT,
    });
  }
}
