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,
consoleTracker: IConsoleTracker,
editorServices: IEditorServices,
browserFactory: IFileBrowserFactory,
settingRegistry: ISettingRegistry,
palette: ICommandPalette | null,
launcher: ILauncher | null,
menu: IMainMenu | null,
restorer: ILayoutRestorer | null
): IEditorTracker {
const id = plugin.id;
const namespace = 'editor';
const factory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: FACTORY,
fileTypes: ['markdown', '*'], // Explicitly add the markdown fileType so
defaultFor: ['markdown', '*'] // it outranks the defaultRendered viewer.
}
});
const { commands, restored, shell } = app;
const tracker = new InstanceTracker>({
namespace
});
const isEnabled = () =>
tracker.currentWidget !== null &&
tracker.currentWidget === shell.currentWidget;
let config: CodeEditor.IConfig = { ...CodeEditor.defaultConfig };
function activate(
app: JupyterFrontEnd,
consoleTracker: IConsoleTracker,
editorServices: IEditorServices,
browserFactory: IFileBrowserFactory,
settingRegistry: ISettingRegistry,
palette: ICommandPalette | null,
launcher: ILauncher | null,
menu: IMainMenu | null,
restorer: ILayoutRestorer | null
): IEditorTracker {
const id = plugin.id;
const namespace = 'editor';
const factory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: FACTORY,
fileTypes: ['markdown', '*'], // Explicitly add the markdown fileType so
defaultFor: ['markdown', '*'] // it outranks the defaultRendered viewer.
}
});
const { commands, restored, shell } = app;
const tracker = new WidgetTracker>({
namespace
});
const isEnabled = () =>
tracker.currentWidget !== null &&
tracker.currentWidget === shell.currentWidget;
let config: CodeEditor.IConfig = { ...CodeEditor.defaultConfig };
function activate(
app: JupyterFrontEnd,
consoleTracker: IConsoleTracker,
editorServices: IEditorServices,
browserFactory: IFileBrowserFactory,
settingRegistry: ISettingRegistry,
palette: ICommandPalette | null,
launcher: ILauncher | null,
menu: IMainMenu | null,
restorer: ILayoutRestorer | null
): IEditorTracker {
const id = plugin.id;
const namespace = 'editor';
const factory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: FACTORY,
fileTypes: ['markdown', '*'], // Explicitly add the markdown fileType so
defaultFor: ['markdown', '*'] // it outranks the defaultRendered viewer.
}
});
const { commands, restored, shell } = app;
const tracker = new InstanceTracker>({
namespace
});
const isEnabled = () =>
tracker.currentWidget !== null &&
tracker.currentWidget === shell.currentWidget;
let config = { ...CodeEditor.defaultConfig };
insertSpaces: false,
size: 4,
name: 'Indent with Tab'
};
menu.addItem({ command, args });
for (let size of [1, 2, 4, 8]) {
let args: JSONObject = {
insertSpaces: true,
size,
name: `Spaces: ${size} `
};
menu.addItem({ command, args });
}
// Create the status item.
const item = new TabSpaceStatus({ menu });
// Keep a reference to the code editor config from the settings system.
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
const cached = settings.get('editorConfig').composite as Partial<
CodeEditor.IConfig
>;
const config: CodeEditor.IConfig = {
...CodeEditor.defaultConfig,
...cached
};
item.model!.config = config;
};
void Promise.all([
settingRegistry.load('@jupyterlab/fileeditor-extension:plugin'),
app.restored
]).then(([settings]) => {
insertSpaces: false,
size: 4,
name: 'Indent with Tab'
};
menu.addItem({ command, args });
for (let size of [1, 2, 4, 8]) {
let args: JSONObject = {
insertSpaces: true,
size,
name: `Spaces: ${size} `
};
menu.addItem({ command, args });
}
// Create the status item.
const item = new TabSpaceStatus({ menu });
// Keep a reference to the code editor config from the settings system.
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
item.model!.config = {
...CodeEditor.defaultConfig,
...(settings.get('editorConfig').composite as JSONObject)
};
};
void Promise.all([
settingRegistry.load('@jupyterlab/fileeditor-extension:plugin'),
app.restored
]).then(([settings]) => {
updateSettings(settings);
settings.changed.connect(updateSettings);
});
insertSpaces: false,
size: 4,
name: 'Indent with Tab'
};
menu.addItem({ command, args });
for (let size of [1, 2, 4, 8]) {
let args: JSONObject = {
insertSpaces: true,
size,
name: `Spaces: ${size} `
};
menu.addItem({ command, args });
}
// Create the status item.
const item = new TabSpaceStatus({ menu });
// Keep a reference to the code editor config from the settings system.
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
item.model!.config = {
...CodeEditor.defaultConfig,
...(settings.get('editorConfig').composite as JSONObject)
};
};
void Promise.all([
settingRegistry.load('@jupyterlab/fileeditor-extension:plugin'),
app.restored
]).then(([settings]) => {
updateSettings(settings);
settings.changed.connect(updateSettings);
});
describe('FileEditorFactory', () => {
const widgetFactory = new FileEditorFactory({
editorServices: {
factoryService,
mimeTypeService
},
factoryOptions: {
name: 'editor',
fileTypes: ['*'],
defaultFor: ['*']
}
});
describe('#constructor()', () => {
it('should create an FileEditorFactory', () => {
expect(widgetFactory).to.be.an.instanceof(FileEditorFactory);
});
});
describe('FileEditorFactory', () => {
const widgetFactory = new FileEditorFactory({
editorServices: {
factoryService,
mimeTypeService
},
factoryOptions: {
name: 'editor',
fileTypes: ['*'],
defaultFor: ['*']
}
});
describe('#constructor()', () => {
it('should create an FileEditorFactory', () => {
expect(widgetFactory).to.be.an.instanceof(FileEditorFactory);
});
});
beforeEach(() => {
const path = UUID.uuid4() + '.py';
context = new Context({ manager, factory: modelFactory, path });
widget = new FileEditorCodeWrapper({
factory: options => factoryService.newDocumentEditor(options),
mimeTypeService,
context
});
});
beforeEach(() => {
const path = UUID.uuid4() + '.py';
context = new Context({ manager, factory: modelFactory, path });
widget = new FileEditorCodeWrapper({
factory: options => factoryService.newDocumentEditor(options),
mimeTypeService,
context
});
});