-import {EditorUiContext, EditorUiElement, EditorUiStateUpdate} from "./base-elements";
+import {EditorUiContext, EditorUiElement, EditorUiStateUpdate} from "./core";
import {el} from "../../helpers";
+import {EditorButton} from "./buttons";
export class EditorContainerUiElement extends EditorUiElement {
protected children : EditorUiElement[];
}
setContext(context: EditorUiContext) {
+ super.setContext(context);
for (const child of this.getChildren()) {
child.setContext(context);
}
}, childElements);
const toggle = el('button', {
- class: 'editor-format-menu-toggle',
+ class: 'editor-format-menu-toggle editor-button',
type: 'button',
- }, ['Formats']);
+ }, [this.trans('Formats')]);
const wrapper = el('div', {
class: 'editor-format-menu editor-dropdown-menu-container',
return wrapper;
}
+
+ updateState(state: EditorUiStateUpdate) {
+ super.updateState(state);
+
+ for (const child of this.children) {
+ if (child instanceof EditorButton && child.isActive()) {
+ this.updateToggleLabel(child.getLabel());
+ return;
+ }
+ }
+
+ this.updateToggleLabel(this.trans('Formats'));
+ }
+
+ protected updateToggleLabel(text: string): void {
+ const button = this.getDOMElement().querySelector('button');
+ if (button) {
+ button.innerText = text;
+ }
+ }
}
\ No newline at end of file