Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options.forEach(option => {
const toolbarFactory = option.toolbarFactory
? (w: MimeDocument) => option.toolbarFactory!(w.content.renderer)
: undefined;
let factory = new MimeDocumentFactory({
renderTimeout: item.renderTimeout,
dataType: item.dataType,
rendermime,
modelName: option.modelName,
name: option.name,
primaryFileType: registry.getFileType(option.primaryFileType),
fileTypes: option.fileTypes,
defaultFor: option.defaultFor,
defaultRendered: option.defaultRendered,
toolbarFactory
});
registry.addWidgetFactory(factory);
factory.widgetCreated.connect((sender, widget) => {
Private.factoryNameProperty.set(widget, factory.name);
// Notify the widget tracker if restore data needs to update.
function activate(app: JupyterLab, restorer: ILayoutRestorer, rendermime: IRenderMimeRegistry) {
const primaryFileType = app.docRegistry.getFileType('markdown');
const factory = new MimeDocumentFactory({
name: FACTORY,
primaryFileType,
fileTypes: ['markdown'],
rendermime
});
const { commands } = app;
const namespace = 'rendered-markdown';
const tracker = new InstanceTracker>({ namespace });
app.docRegistry.addWidgetFactory(factory);
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
activate: (app: JupyterLab, restorer: ILayoutRestorer) => {
// Add the mime renderer.
if (item.rank !== undefined) {
app.rendermime.addFactory(
item.rendererFactory, item.rank
);
} else {
app.rendermime.addFactory(item.rendererFactory);
}
// Handle the widget factory.
if (!item.documentWidgetFactoryOptions) {
return;
}
let factory = new MimeDocumentFactory({
mimeType: item.mimeType,
renderTimeout: item.renderTimeout,
dataType: item.dataType,
rendermime: app.rendermime,
...item.documentWidgetFactoryOptions,
});
app.docRegistry.addWidgetFactory(factory);
const factoryName = factory.name;
const namespace = `${factoryName}-renderer`;
const tracker = new InstanceTracker({ namespace });
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: factoryName }),
options.forEach(option => {
const toolbarFactory = option.toolbarFactory
? (w: MimeDocument) => option.toolbarFactory(w.content.renderer)
: undefined;
let factory = new MimeDocumentFactory({
renderTimeout: item.renderTimeout,
dataType: item.dataType,
rendermime,
modelName: option.modelName,
name: option.name,
primaryFileType: registry.getFileType(option.primaryFileType),
fileTypes: option.fileTypes,
defaultFor: option.defaultFor,
defaultRendered: option.defaultRendered,
toolbarFactory
});
registry.addWidgetFactory(factory);
factory.widgetCreated.connect((sender, widget) => {
Private.factoryNameProperty.set(widget, factory.name);
// Notify the instance tracker if restore data needs to update.
function activate(app: JupyterLab, restorer: ILayoutRestorer) {
const factory = new MimeDocumentFactory({
name: FACTORY,
fileExtensions: ['.md'],
mimeType: 'text/markdown',
rendermime: app.rendermime
});
app.docRegistry.addWidgetFactory(factory);
const { commands } = app;
const namespace = 'rendered-markdown';
const tracker = new InstanceTracker({ namespace });
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
it('should require a context parameter', () => {
const widgetFactory = new MimeDocumentFactory({
name: 'markdown',
fileTypes: ['markdown'],
rendermime: RENDERMIME,
primaryFileType: DocumentRegistry.defaultTextFileType
});
expect(widgetFactory.createNew(dContext)).to.be.an.instanceof(
MimeDocument
);
});
});
it('should require a context parameter', () => {
const widgetFactory = new MimeDocumentFactory({
name: 'markdown',
fileTypes: ['markdown'],
rendermime: RENDERMIME,
primaryFileType: DocumentRegistry.defaultTextFileType
});
expect(widgetFactory.createNew(dContext)).to.be.an.instanceof(
MimeDocument
);
});
});
it('should require a context parameter', () => {
let widgetFactory = new MimeDocumentFactory({
name: 'markdown',
fileExtensions: ['.md'],
rendermime: RENDERMIME,
mimeType: 'text/markdown'
});
expect(widgetFactory.createNew(context)).to.be.a(MimeDocument);
});
safe: false,
mimeTypes: [MIME_TYPE],
createRenderer: options => new RenderedVDOM(options, context)
},
0
);
});
app.docRegistry.addFileType({
name: 'vdom',
mimeTypes: [MIME_TYPE],
extensions: ['.vdom', '.vdom.json'],
iconClass: CSS_ICON_CLASS
});
const factory = new MimeDocumentFactory({
renderTimeout: 1000,
dataType: 'json',
rendermime,
name: FACTORY_NAME,
primaryFileType: app.docRegistry.getFileType('vdom'),
fileTypes: ['vdom', 'json'],
defaultFor: ['vdom']
});
factory.widgetCreated.connect((sender, widget) => {
widget.context.pathChanged.connect(() => {
void tracker.save(widget);
});
void tracker.add(widget);
});