Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function initializeMarked(): void {
if (markedInitialized) {
return;
}
markedInitialized = true;
marked.setOptions({
gfm: true,
sanitize: false,
tables: true,
// breaks: true; We can't use GFM breaks as it causes problems with tables
langPrefix: `cm-s-${CodeMirrorEditor.defaultConfig.theme} language-`,
highlight: (code, lang, callback) => {
if (!lang) {
// no language, no highlight
if (callback) {
callback(null, code);
return;
} else {
return code;
}
}
Mode.ensure(lang).then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
callback(null, code);
return;
function initializeMarked(): void {
if (markedInitialized) {
return;
}
markedInitialized = true;
marked.setOptions({
gfm: true,
sanitize: false,
tables: true,
// breaks: true; We can't use GFM breaks as it causes problems with tables
langPrefix: `cm-s-${CodeMirrorEditor.defaultConfig.theme} language-`,
highlight: (code, lang, callback) => {
let cb = (err: Error | null, code: string) => {
if (callback) {
callback(err, code);
}
return code;
};
if (!lang) {
// no language, no highlight
return cb(null, code);
}
Mode.ensure(lang)
.then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
function initializeMarked(): void {
if (markedInitialized) {
return;
}
markedInitialized = true;
marked.setOptions({
gfm: true,
sanitize: false,
tables: true,
// breaks: true; We can't use GFM breaks as it causes problems with tables
langPrefix: `cm-s-${CodeMirrorEditor.defaultConfig.theme} language-`,
highlight: (code, lang, callback) => {
let cb = (err: Error | null, code: string) => {
if (callback) {
callback(err, code);
}
return code;
};
if (!lang) {
// no language, no highlight
return cb(null, code);
}
Mode.ensure(lang)
.then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
function initializeMarked(): void {
if (markedInitialized) {
return;
}
markedInitialized = true;
marked.setOptions({
gfm: true,
sanitize: false,
tables: true,
// breaks: true; We can't use GFM breaks as it causes problems with tables
langPrefix: `cm-s-${CodeMirrorEditor.defaultConfig.theme} language-`,
highlight: (code, lang, callback) => {
let cb = (err: Error | null, code: string) => {
if (callback) {
callback(err, code);
}
return code;
};
if (!lang) {
// no language, no highlight
return cb(null, code);
}
Mode.ensure(lang)
.then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
function activateEditorCommands(
app: JupyterFrontEnd,
tracker: IEditorTracker,
settingRegistry: ISettingRegistry,
mainMenu: IMainMenu | null
): void {
const { commands, restored } = app;
let {
theme,
keyMap,
scrollPastEnd,
styleActiveLine,
styleSelectedText,
selectionPointer
} = CodeMirrorEditor.defaultConfig;
/**
* Update the setting values.
*/
async function updateSettings(
settings: ISettingRegistry.ISettings
): Promise {
keyMap = (settings.get('keyMap').composite as string | null) || keyMap;
// Lazy loading of vim mode
if (keyMap === 'vim') {
// @ts-ignore
await import('codemirror/keymap/vim.js');
}
theme = (settings.get('theme').composite as string | null) || theme;
function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMenu: IMainMenu, palette: ICommandPalette, state: IStateDB, settingRegistry: ISettingRegistry): void {
const { commands, restored } = app;
const { id } = commandsPlugin;
let { theme, keyMap } = CodeMirrorEditor.defaultConfig;
/**
* Update the setting values.
*/
function updateSettings(settings: ISettingRegistry.ISettings): void {
keyMap = settings.get('keyMap').composite as string | null || keyMap;
theme = settings.get('theme').composite as string | null || theme;
}
/**
* Update the settings of the current tracker instances.
*/
function updateTracker(): void {
tracker.forEach(widget => {
if (widget.editor instanceof CodeMirrorEditor) {
let cm = widget.editor.editor;
function activateEditorCommands(
app: JupyterFrontEnd,
tracker: IEditorTracker,
settingRegistry: ISettingRegistry,
mainMenu: IMainMenu | null
): void {
const { commands, restored } = app;
let {
theme,
keyMap,
scrollPastEnd,
styleActiveLine,
styleSelectedText,
selectionPointer
} = CodeMirrorEditor.defaultConfig;
/**
* Update the setting values.
*/
function updateSettings(settings: ISettingRegistry.ISettings): void {
keyMap = (settings.get('keyMap').composite as string | null) || keyMap;
theme = (settings.get('theme').composite as string | null) || theme;
scrollPastEnd = settings.get('scrollPastEnd').composite as boolean | null;
styleActiveLine =
(settings.get('styleActiveLine').composite as
| boolean
| CodeMirror.StyleActiveLine) || styleActiveLine;
styleSelectedText =
(settings.get('styleSelectedText').composite as boolean) ||
styleSelectedText;
selectionPointer =