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

@covalent/code-editor

Package Overview
Dependencies
Maintainers
4
Versions
279
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@covalent/code-editor

Teradata Text and Code Editor built on Covalent and Angular Material

  • 2.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
670
decreased by-51.69%
Maintainers
4
Weekly downloads
 
Created
Source

Covalent-Code-Editor is a Text and Code Editor built on Covalent, Monaco Editor and Angular Material

Build Status npm version npm Join the chat at https://gitter.im/Teradata/covalent Dependency Status

Covalent is a reusable UI platform from Teradata for building web applications with common standards and tooling. It is based on Angular 2 and Material Design.

Covalent-Code-Editor is an Angular Component for text and code editing based on Covalent and Monaco Editor. The component can run in both Electron and Web Browsers.

Demo: https://teradata.github.io/covalent/#/components/code-editor

Covalent Github Repo: https://github.com/Teradata/covalent

Covalent Electron Github Repo: https://github.com/Teradata/covalent-electron

Monaco Editor Repo: https://github.com/Microsoft/monaco-editor


Information

Setup

  • Install Module
npm install @covalent/code-editor
  • Important: Add the glob to assets in angular.json (to make monaco-editor javascript available to the app)
{
  "apps": [
    {
      "assets": [
        {
          "glob": "**/*",
          "input": "node_modules/@covalent/code-editor/assets/monaco",
          "output": "/assets/monaco"
        }
      ],
  • Add the following tag to html file
<td-code-editor style="height: 200px" theme="vs" flex language="sql"></td-code-editor>
  • Import the covalent-editor component into app.module.ts
import { CovalentCodeEditorModule } from '@covalent/code-editor';
...

imports: [
    CovalentCodeEditorModule,

...

td-code-editor

td-code-editor element generates a monaco editor for inline code editing

API Summary

Events

The component has 3 events:
NameDescription
editorInitializedEmitted when Editor is finished initializing. Event passes a reference to the actual editor instance that can be used to call additional operations outside of the Angular component. See usage example below.
onEditorConfigurationChangedEmitted when configuration of the Editor changes
onEditorLanguageChangedEmitted when the language of the Editor changes

Properties

The component has 6 properties:
NameTypeDescription
value?stringValue of Code in Editor
languagestringCode Language used in Editor
registerLanguagefunction()Registers a custom Language within the editor
editorStylestringAdditional Styling applied to Editor Container
themestringTheme used to style the Editor
automaticLayoutbooleanImplemented via setInterval that constantly probes for the container's size. Defaults to false.
editorOptionsObjectEditor Options Object of valid Configurations listed here: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditoroptions.html
layoutfunction()Instructs the editor to remeasure its container
isFullScreenbooleanIs the editor currently in Full Screen mode
fullScreenKeyBindingnumberSets the KeyCode for shortcutting to Fullscreen. Options listed see here: https://microsoft.github.io/monaco-editor/api/enums/monaco.keycode.html

Usage

Example for HTML usage:

<td-code-editor
        style="height: 200px"
        editorStyle="border:0;"
        flex
        theme="vs"
        language="sql"
        automaticLayout
        [editorOptions]="{readOnly:true, fontSize:20}"
        [(ngModel)]="model"
        (change)="callBackFunc()">
</td-code-editor>

Example of exposing editor instance

<td-code-editor
        [editorOptions]="editorOptions"
        [(ngModel)]="model"
        (editorInitialized)="onInit($event)">
</td-code-editor>
export class AppComponent {
  editorOptions = {theme: 'vs-dark', language: 'javascript'};
  model: string= 'function x() {\nconsole.log("Hello world!");\n}';
  column: number = 0;
  lineNumber: number = 0;

  async onEditorInitialized(editor: any): Promise<void> {
    let line: any = await editor.getPosition();

    this.column = line.column;
    this.lineNumber = line.lineNumber;
  }
}

Electron


Keywords

FAQs

Package last updated on 18 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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