You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
645 B
JavaScript

class ImageWidget extends BaseWidget {
$el;
#path;
constructor(data, renderer) {
super(data, renderer);
this.makeLayout({
type: 'div',
name: 'el',
html: waiter(),
});
this.update(data);
}
update(data) {
super.update(data);
if ('value' in data) this.#path = data.value;
if ('action' in data || 'value' in data) {
this.addFile(this.#path, 'url', file => {
this.$el.innerHTML = `<img style="width:100%" src="${file}">`;
});
}
}
}
Renderer.register('image', ImageWidget);