1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Lexical: Added button icon system

With a bunch of default icons
This commit is contained in:
Dan Brown
2024-06-19 20:00:29 +01:00
parent e2409a5fab
commit 13d970c7ce
34 changed files with 99 additions and 16 deletions

View File

@ -4,6 +4,7 @@ import {el} from "../../helpers";
export interface EditorBasicButtonDefinition {
label: string;
icon?: string|undefined;
}
export interface EditorButtonDefinition extends EditorBasicButtonDefinition {
@ -21,10 +22,19 @@ export class EditorButton extends EditorUiElement {
}
protected buildDOM(): HTMLButtonElement {
const label = this.getLabel();
let child: string|HTMLElement = label;
if (this.definition.icon) {
child = el('span', {class: 'editor-button-icon'});
child.innerHTML = this.definition.icon;
}
const button = el('button', {
type: 'button',
class: 'editor-button',
}, [this.getLabel()]) as HTMLButtonElement;
title: this.definition.icon ? label : null,
}, [child]) as HTMLButtonElement;
button.addEventListener('click', this.onClick.bind(this));