Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function activate(
app: JupyterFrontEnd,
palette: ICommandPalette | null,
restorer: ILayoutRestorer | null
): IImageTracker {
const namespace = 'image-widget';
const factory = new ImageViewerFactory({
name: FACTORY,
modelName: 'base64',
fileTypes: FILE_TYPES,
defaultFor: FILE_TYPES,
readOnly: true
});
const tracker = new WidgetTracker>({
namespace
});
if (restorer) {
// Handle state restoration.
void restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
function activate(
app: JupyterFrontEnd,
palette: ICommandPalette | null,
restorer: ILayoutRestorer | null
): IImageTracker {
const namespace = 'image-widget';
const factory = new ImageViewerFactory({
name: FACTORY,
modelName: 'base64',
fileTypes: FILE_TYPES,
defaultFor: FILE_TYPES,
readOnly: true
});
const tracker = new InstanceTracker>({
namespace
});
if (restorer) {
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
it('should create an image document widget', () => {
const factory = new ImageViewerFactory({
name: 'Image',
modelName: 'base64',
fileTypes: ['png'],
defaultFor: ['png']
});
const context = createFileContext(IMAGE.path);
const d = factory.createNew(context);
expect(d).to.be.an.instanceof(DocumentWidget);
expect(d.content).to.be.an.instanceof(ImageViewer);
});
});
it('should create an image document widget', () => {
const factory = new ImageViewerFactory({
name: 'Image',
modelName: 'base64',
fileTypes: ['png'],
defaultFor: ['png']
});
const context = createFileContext(IMAGE.path);
const d = factory.createNew(context);
expect(d).to.be.an.instanceof(DocumentWidget);
expect(d.content).to.be.an.instanceof(ImageViewer);
});
});