Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jupyterlab/docmanager-extension

Package Overview
Dependencies
Maintainers
16
Versions
390
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyterlab/docmanager-extension - npm Package Compare versions

Comparing version 1.1.0-alpha.2 to 1.1.0-rc.0

69

lib/index.js
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { some, map, each } from '@phosphor/algorithm';
import { Widget } from '@phosphor/widgets';
import { ILabShell, ILabStatus } from '@jupyterlab/application';

@@ -11,2 +9,5 @@ import { showDialog, showErrorMessage, Dialog, ICommandPalette } from '@jupyterlab/apputils';

import { IStatusBar } from '@jupyterlab/statusbar';
import { each, map, some, toArray } from '@phosphor/algorithm';
import { JSONExt } from '@phosphor/coreutils';
import { Widget } from '@phosphor/widgets';
/**

@@ -75,2 +76,3 @@ * The command IDs used by the document manager plugin.

const onSettingsUpdated = (settings) => {
// Handle whether to autosave
const autosave = settings.get('autosave').composite;

@@ -80,4 +82,29 @@ docManager.autosave =

app.commands.notifyCommandChanged(CommandIDs.toggleAutosave);
// Handle autosave interval
const autosaveInterval = settings.get('autosaveInterval').composite;
docManager.autosaveInterval = autosaveInterval || 120;
// Handle default widget factory overrides.
const defaultViewers = settings.get('defaultViewers').composite;
const overrides = {};
// Filter the defaultViewers and file types for existing ones.
Object.keys(defaultViewers).forEach(ft => {
if (!registry.getFileType(ft)) {
console.warn(`File Type ${ft} not found`);
return;
}
if (!registry.getWidgetFactory(defaultViewers[ft])) {
console.warn(`Document viewer ${defaultViewers[ft]} not found`);
}
overrides[ft] = defaultViewers[ft];
});
// Set the default factory overrides. If not provided, this has the
// effect of unsetting any previous overrides.
each(registry.fileTypes(), ft => {
try {
registry.setDefaultWidgetFactory(ft.name, overrides[ft.name]);
}
catch (_a) {
console.warn(`Failed to set default viewer ${overrides[ft.name]} for file type ${ft.name}`);
}
});
};

@@ -93,2 +120,40 @@ // Fetch the initial state of the settings.

});
// Register a fetch transformer for the settings registry,
// allowing us to dynamically populate a help string with the
// available document viewers and file types for the default
// viewer overrides.
settingRegistry.transform(pluginId, {
fetch: plugin => {
// Get the available file types.
const fileTypes = toArray(registry.fileTypes())
.map(ft => ft.name)
.join(' \n');
// Get the available widget factories.
const factories = toArray(registry.widgetFactories())
.map(f => f.name)
.join(' \n');
// Generate the help string.
const description = `Overrides for the default viewers for file types.
Specify a mapping from file type name to document viewer name, for example:
defaultViewers: {
markdown: "Markdown Preview"
}
If you specify non-existent file types or viewers, or if a viewer cannot
open a given file type, the override will not function.
Available viewers:
${factories}
Available file types:
${fileTypes}`;
const schema = JSONExt.deepCopy(plugin.schema);
schema.properties.defaultViewers.description = description;
return Object.assign({}, plugin, { schema });
}
});
// If the document registry gains or loses a factory or file type,
// regenerate the settings description with the available options.
registry.changed.connect(() => settingRegistry.reload(pluginId));
return docManager;

@@ -95,0 +160,0 @@ }

21

package.json
{
"name": "@jupyterlab/docmanager-extension",
"version": "1.1.0-alpha.2",
"version": "1.1.0-rc.0",
"description": "JupyterLab - Document Manager Extension",

@@ -39,11 +39,12 @@ "homepage": "https://github.com/jupyterlab/jupyterlab",

"dependencies": {
"@jupyterlab/application": "^1.1.0-alpha.2",
"@jupyterlab/apputils": "^1.1.0-alpha.2",
"@jupyterlab/coreutils": "^3.1.0-alpha.2",
"@jupyterlab/docmanager": "^1.1.0-alpha.2",
"@jupyterlab/docregistry": "^1.1.0-alpha.2",
"@jupyterlab/mainmenu": "^1.1.0-alpha.2",
"@jupyterlab/services": "^4.1.0-alpha.2",
"@jupyterlab/statusbar": "^1.1.0-alpha.2",
"@jupyterlab/application": "^1.1.0-rc.0",
"@jupyterlab/apputils": "^1.1.0-rc.0",
"@jupyterlab/coreutils": "^3.1.0-rc.0",
"@jupyterlab/docmanager": "^1.1.0-rc.0",
"@jupyterlab/docregistry": "^1.1.0-rc.0",
"@jupyterlab/mainmenu": "^1.1.0-rc.0",
"@jupyterlab/services": "^4.1.0-rc.0",
"@jupyterlab/statusbar": "^1.1.0-rc.0",
"@phosphor/algorithm": "^1.1.3",
"@phosphor/coreutils": "^1.3.1",
"@phosphor/disposable": "^1.2.0",

@@ -64,3 +65,3 @@ "@phosphor/widgets": "^1.8.0"

},
"gitHead": "4a56efd6860d2a54301eea426b8d9eb2fdc170b0"
"gitHead": "eeaaf8976f4d54ad03bd2c53c424a13514d78e8d"
}

@@ -6,2 +6,3 @@ {

"jupyter.lab.setting-icon-label": "Document Manager",
"jupyter.lab.transform": true,
"jupyter.lab.shortcuts": [

@@ -31,2 +32,12 @@ {

"default": 120
},
"defaultViewers": {
"type": "object",
"title": "Default Viewers",
"default": {},
"description": "Overrides for the default viewers for file types",
"properties": {},
"additionalProperties": {
"type": "string"
}
}

@@ -33,0 +44,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc