How to use the @jupyterlab/codeeditor.CodeEditor.defaultConfig function in @jupyterlab/codeeditor

To help you get started, we’ve selected a few @jupyterlab/codeeditor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / packages / fileeditor-extension / src / index.ts View on Github external
Object.keys(config).forEach((key: keyof CodeEditor.IConfig) => {
      config[key] =
        cached[key] === null || cached[key] === undefined
          ? CodeEditor.defaultConfig[key]
          : cached[key];
    });
    // Trigger a refresh of the rendered commands
github jupyterlab / jupyterlab / packages / fileeditor-extension / src / commands.ts View on Github external
export function updateSettings(
    settings: ISettingRegistry.ISettings,
    commands: CommandRegistry
  ): void {
    config = {
      ...CodeEditor.defaultConfig,
      ...(settings.get('editorConfig').composite as JSONObject)
    };

    // Trigger a refresh of the rendered commands
    commands.notifyCommandChanged();
  }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / fileeditor-extension / src / index.ts View on Github external
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 };

  // Handle state restoration.
  if (restorer) {
    restorer.restore(tracker, {
      command: 'docmanager:open',
      args: widget => ({ path: widget.context.path, factory: FACTORY }),
      name: widget => widget.context.path
    });
  }

  /**
   * Update the setting values.
   */
  function updateSettings(settings: ISettingRegistry.ISettings): void {
    config = {
      ...CodeEditor.defaultConfig,
github jupyterlab / jupyterlab / packages / fileeditor-extension / src / index.ts View on Github external
function updateSettings(settings: ISettingRegistry.ISettings): void {
    config = {
      ...CodeEditor.defaultConfig,
      ...(settings.get('editorConfig').composite as JSONObject)
    };

    // Trigger a refresh of the rendered commands
    app.commands.notifyCommandChanged();
  }
github jupyterlab / jupyterlab / tests / test-cells / src / widget.spec.ts View on Github external
it('shoule accept a custom editorConfig', () => {
        const editorConfig: Partial = {
          insertSpaces: false,
          matchBrackets: false
        };
        const widget = new Cell({
          editorConfig,
          model,
          contentFactory
        }).initializeState();
        expect(widget.editor.getOption('insertSpaces')).toEqual(false);
        expect(widget.editor.getOption('matchBrackets')).toEqual(false);
        expect(widget.editor.getOption('lineNumbers')).toEqual(
          CodeEditor.defaultConfig.lineNumbers
        );
      });
    });
github jupyterlab / jupyterlab / packages / codemirror / src / editor.ts View on Github external
*/
    styleSelectedText: boolean;

    /**
     * Defines the mouse cursor appearance when hovering over the selection.
     * It can be set to a string, like "pointer", or to true,
     * in which case the "default" (arrow) cursor will be used.
     */
    selectionPointer: boolean | string;
  }

  /**
   * The default configuration options for an editor.
   */
  export let defaultConfig: Required = {
    ...CodeEditor.defaultConfig,
    mode: 'null',
    theme: 'jupyter',
    smartIndent: true,
    electricChars: true,
    keyMap: 'default',
    extraKeys: null,
    gutters: [],
    fixedGutter: true,
    showCursorWhenSelecting: false,
    coverGutterNextToScrollbar: false,
    dragDrop: true,
    lineSeparator: null,
    scrollbarStyle: 'native',
    lineWiseCopyCut: true,
    scrollPastEnd: false,
    styleActiveLine: false,
github jupyterlab / jupyterlab / packages / fileeditor-extension / src / index.ts View on Github external
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([
github jupyterlab / jupyterlab / packages / notebook / src / widget.ts View on Github external
*/
    readonly raw: Partial;
  }

  /**
   * Default configuration options for cell editors.
   */
  export const defaultEditorConfig: IEditorConfig = {
    code: {
      ...CodeEditor.defaultConfig,
      lineWrap: 'off',
      matchBrackets: true,
      autoClosingBrackets: true
    },
    markdown: {
      ...CodeEditor.defaultConfig,
      lineWrap: 'on',
      matchBrackets: false,
      autoClosingBrackets: false
    },
    raw: {
      ...CodeEditor.defaultConfig,
      lineWrap: 'on',
      matchBrackets: false,
      autoClosingBrackets: false
    }
  };

  /**
   * A config object for the notebook widget
   */
  export interface INotebookConfig {
github jupyterlab / jupyterlab / packages / codemirror / src / editor.ts View on Github external
*/
    scrollbarStyle?: string;

    /**
     * When enabled, which is the default, doing copy or cut when there is no
     * selection will copy or cut the whole lines that have cursors on them.
     */
    lineWiseCopyCut?: boolean;
  }

  /**
   * The default configuration options for an editor.
   */
  export
  let defaultConfig: IConfig = {
    ...CodeEditor.defaultConfig,
    mode: 'null',
    theme: 'jupyter',
    smartIndent: true,
    electricChars: true,
    keyMap: 'default',
    extraKeys: null,
    gutters: Object.freeze([]),
    fixedGutter: true,
    showCursorWhenSelecting: false,
    coverGutterNextToScrollbar: false,
    dragDrop: true,
    lineSeparator: null,
    scrollbarStyle: 'native',
    lineWiseCopyCut: true,
  };
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / notebook / src / widget.ts View on Github external
*/
  export const defaultEditorConfig: IEditorConfig = {
    code: {
      ...CodeEditor.defaultConfig,
      lineWrap: 'off',
      matchBrackets: true,
      autoClosingBrackets: true
    },
    markdown: {
      ...CodeEditor.defaultConfig,
      lineWrap: 'on',
      matchBrackets: false,
      autoClosingBrackets: false
    },
    raw: {
      ...CodeEditor.defaultConfig,
      lineWrap: 'on',
      matchBrackets: false,
      autoClosingBrackets: false
    }
  };

  /**
   * A config object for the notebook widget
   */
  export interface INotebookConfig {
    /**
     * Enable scrolling past the last cell
     */
    scrollPastEnd: boolean;
  }
  /**