Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Fetch the initial state of the settings.
settingRegistry
.load(plugin.id)
.then((settings: ISettingRegistry.ISettings) => {
settings.changed.connect(() => {
updateSettings(settings);
});
updateSettings(settings);
})
.catch((reason: Error) => {
console.error(reason.message);
});
// Register the MarkdownViewer factory.
const factory = new MarkdownViewerFactory({
rendermime,
name: FACTORY,
primaryFileType: docRegistry.getFileType('markdown'),
fileTypes: ['markdown'],
defaultRendered: ['markdown']
});
factory.widgetCreated.connect((sender, widget) => {
// Notify the instance tracker if restore data needs to update.
widget.context.pathChanged.connect(() => {
void tracker.save(widget);
});
// Handle the settings of new widgets.
updateWidget(widget.content);
void tracker.add(widget);
});
docRegistry.addWidgetFactory(factory);
it('should require a context parameter', () => {
let widgetFactory = new MarkdownViewerFactory({
name: 'markdown',
fileExtensions: ['.md'],
rendermime: RENDERMIME
});
expect(widgetFactory.createNew(context)).to.be.a(MarkdownViewer);
});