hugo-commandbar/assets/commandbar/js/setHandler.js

32 lines
650 B
JavaScript

class SetEvent extends Event {
#option;
#newValue;
constructor(option, newValue) {
super("setOption")
this.#option = option;
this.#newValue = newValue;
}
get option() {
return this.#option;
}
get newValue() {
return this.#newValue;
}
}
export class SetOptionHandler {
get name() {
return "set";
}
execute(command, commandBar) {
for (const param of command.parameters) {
const setEvent = new SetEvent(param.name.valueOf(), param.value.valueOf());
commandBar.dispatchEvent(setEvent);
}
return true;
}
}