import { RTEListItemBlock } from '../../dto/blocks/list-item-block';
import { RTETextBlock } from '../../public-api';
import { VegaRTEExtension } from '../extension.abstract';
import { InsertTokenNodeStrategy } from './insert-token-node-strategy';
import { SpanToTokenNodeStrategy } from './span-to-token-node-strategy';
import { RTETokenNode } from './token-node';
import { RTETokenNodeRenderer } from './token-node-renderer';
import { RTETokenToolbarButtonRenderer } from './token-toolbar-button-renderer';
const spanToTokenNodeStrategy = new SpanToTokenNodeStrategy();
/**
 * Vega Rich Text Editor Token Extension
 */
export class VegaRTETokenExtension extends VegaRTEExtension {
  constructor(tokenList = []) {
    super();
    this.tokenRenderer = new RTETokenNodeRenderer();
    this.registerNode('token', RTETokenNode);
    this.registerRenderer('token', this.tokenRenderer);
    this.tokenToolbarButtonRenderer = new RTETokenToolbarButtonRenderer(tokenList);
    this.registerToolbarButtonRenderer('token', this.tokenToolbarButtonRenderer);
    this.registerElementToNodeDTOClassStrategy(spanToTokenNodeStrategy);
  }
}
(() => {
  const insertTokenNodeStrategy = new InsertTokenNodeStrategy();
  VegaRTEExtension.registerActionHandleStrategy(RTETextBlock.name, 'INSERT_TOKEN_NODE', insertTokenNodeStrategy);
  VegaRTEExtension.registerActionHandleStrategy(RTEListItemBlock.name, 'INSERT_TOKEN_NODE', insertTokenNodeStrategy);
})();
