import { VegaRTEExtensionRenderer } from '../../base-extension-renderer';
import styles from './function-block-styles.css';
/**
 * Renderer for Function Block
 */
export class RTEFunctionBlockRenderer extends VegaRTEExtensionRenderer {
  /**
   * @inheritDoc
   */
  doRender(createElement, renderData) {
    return createElement('div', {
      key: renderData.id,
      class: this.getElementClassName(renderData),
      ref: this.useRef(renderData),
    });
  }
  /**
   * Defines the function block styles to be injected into the RTE scope.
   *
   * @returns {string} - The styles as a string.
   */
  injectRTEScopeStyles() {
    return styles;
  }
  /**
   * Gets the class name for the function block element.
   *
   * @param {RTEFunctionBlock} block - The function block.
   * @returns {string} The class name for the function block element.
   */
  getElementClassName(block) {
    let classes = block.getClasses();
    if (classes.indexOf('statement') < 0) {
      classes = 'statement ' + classes;
    }
    return classes.trim();
  }
}
