Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async drawImage(args: any[], buffers: any) {
const [serializedImage, x, y, width, height] = args;
const image = await unpack_models(serializedImage, this.widget_manager);
if (image instanceof CanvasModel || image instanceof MultiCanvasModel) {
this._drawImage(image.canvas, x, y, width, height);
return;
}
if (image.get('_model_name') == 'ImageModel') {
// Create the image manually instead of creating an ImageView
let url: string;
const format = image.get('format');
const value = image.get('value');
if (format !== 'url') {
const blob = new Blob([value], {type: `image/${format}`});
url = URL.createObjectURL(blob);
} else {
url = (new TextDecoder('utf-8')).decode(value.buffer);
private async _add(payload: any): Promise {
const { serializedWidget, area, args, id } = payload;
const model = await unpack_models(serializedWidget, this.widget_manager);
const view = await this.widget_manager.create_view(model, {});
const title = await unpack_models(model.get('title'), this.widget_manager);
const pWidget = view.pWidget;
pWidget.id = id ?? DOMUtils.createDomID();
MessageLoop.installMessageHook(pWidget, (handler: any, msg: Message) => {
switch (msg.type) {
case 'close-request': {
const widgets = this.get('_widgets').slice();
ArrayExt.removeAllWhere(widgets, (w: any) => w.id === handler.id);
this.set('_widgets', widgets);
this.save_changes();
break;
}
}
private async _add(payload: any): Promise {
const { serializedWidget, area, args, id } = payload;
const model = await unpack_models(serializedWidget, this.widget_manager);
const view = await this.widget_manager.create_view(model, {});
const title = await unpack_models(model.get('title'), this.widget_manager);
const pWidget = view.pWidget;
pWidget.id = id ?? DOMUtils.createDomID();
MessageLoop.installMessageHook(pWidget, (handler: any, msg: Message) => {
switch (msg.type) {
case 'close-request': {
const widgets = this.get('_widgets').slice();
ArrayExt.removeAllWhere(widgets, (w: any) => w.id === handler.id);
this.set('_widgets', widgets);
this.save_changes();
break;
}
}
return true;
});