CommandLink alias syntax
This commit is contained in:
@@ -35,6 +35,29 @@ export class LinkWidget extends WidgetType {
|
||||
}
|
||||
}
|
||||
|
||||
export class ButtonWidget extends WidgetType {
|
||||
constructor(
|
||||
readonly text: string,
|
||||
readonly title: string,
|
||||
readonly cssClass: string,
|
||||
readonly callback: (e: MouseEvent) => void,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
toDOM(): HTMLElement {
|
||||
const anchor = document.createElement("button");
|
||||
anchor.className = this.cssClass;
|
||||
anchor.textContent = this.text;
|
||||
anchor.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.callback(e);
|
||||
});
|
||||
anchor.setAttribute("title", this.title);
|
||||
return anchor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two ranges overlap
|
||||
* Based on the visual diagram on https://stackoverflow.com/a/25369187
|
||||
|
||||
Reference in New Issue
Block a user