1 import {el} from "../../../helpers";
2 import {EditorUiStateUpdate, EditorContainerUiElement} from "../core";
3 import {EditorButton} from "../buttons";
4 import {handleDropdown} from "../helpers/dropdowns";
6 export class EditorFormatMenu extends EditorContainerUiElement {
7 buildDOM(): HTMLElement {
8 const childElements: HTMLElement[] = this.getChildren().map(child => child.getDOMElement());
9 const menu = el('div', {
10 class: 'editor-format-menu-dropdown editor-dropdown-menu editor-menu-list',
14 const toggle = el('button', {
15 class: 'editor-format-menu-toggle editor-button',
17 }, [this.trans('Formats')]);
19 const wrapper = el('div', {
20 class: 'editor-format-menu editor-dropdown-menu-container',
23 handleDropdown(toggle, menu);
28 updateState(state: EditorUiStateUpdate) {
29 super.updateState(state);
31 for (const child of this.children) {
32 if (child instanceof EditorButton && child.isActive()) {
33 this.updateToggleLabel(child.getLabel());
38 this.updateToggleLabel(this.trans('Formats'));
41 protected updateToggleLabel(text: string): void {
42 const button = this.getDOMElement().querySelector('button');
44 button.innerText = text;