New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ngx-mat-markdown-text-editor

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-mat-markdown-text-editor

Angular markdown text editor based on Material Angular

latest
Source
npmnpm
Version
0.0.3
Version published
Weekly downloads
8
-20%
Maintainers
1
Weekly downloads
 
Created
Source

NgxMatMarkdownTextEditor

Angular markdown editor based on Angular material textarea. The goal of this library is to provide a markdown text editor which sweets the Angular Material Design.

  • Library location : projects/ngx-mat-markdown-text-editor directory of this repository.
  • Working example location : projects/demo directory of this repository.

Demo

  • Working example location : projects/demo directory of this repository.
  • Stackblitz

Installation

npm i ngx-mat-markdown-text-editor

API

import { NgxMatMarkdownTextEditorModule } from 'ngx-mat-markdown-text-editor'
selector: ngx-mat-markdown-text-editor

@Inputs()

InputTypeRequiredDescription
rowsnumberOptional
appearanceMatFormFieldAppearanceOptionalThe form-field appearance style.
matAutosizebooleanOptional, default: falseWhether autosizing is enabled or not
readonlybooleanOptional, default: falseWhether the element is readonly.
placeholderstringOptionalThe placeholder for this control.
matAutosizeMaxRowsnumberOptional
livePreviewEnabledbooleanOptional, default: falseWhether the live preview is enabled or not
hideLivePreviewButtonbooleanOptional, default: falseWhether preview toggle button is displayed or not

@Outputs()

OutputDescription
resetEmits when when the user resets a form.
changeEmits when the contents of the editor or selection have changed.
selectEmits when the current selection changes.
focusEmits when the editor receives focus.
touchedEmits when the user touches the editor.

Usage

  • Import the NgxMatMarkdownTextEditorModule in your app module.

import { NgxMatMarkdownTextEditorModule } from 'ngx-mat-markdown-text-editor'

import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material';
import { MatButtonModule } from '@angular/material/button'; 
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import {NgxMatMarkdownTextEditorModule} from 'ngx-mat-markdown-text-editor.module';

import { AppComponent } from './app.component'; 

@NgModule({
 declarations: [AppComponent],
 imports: [
   BrowserModule,
   BrowserAnimationsModule,
   FormsModule,
   ReactiveFormsModule,
   NgxMatMarkdownTextEditorModule,
   MatInputModule,
   MatButtonModule
 ],
 providers: [],
 bootstrap: [AppComponent]
})
export class AppModule {}
  • Use the editor (NgxMatMarkdownTextEditor) in your component.
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
@Component({
  selector: 'app-root',
  template: `
    <div class="container">
      <h3>NgxMatMarkdownTextEditor</h3>
      <form [formGroup]="formGroup" (ngSubmit)="submit()">
        <ngx-mat-markdown-text-editor formControlName="text" appearance="outline" matAutosize [livePreviewEnabled]="true"
                                      rows="5" (change)="change($event)"></ngx-mat-markdown-text-editor>
        <button mat-button type="submit" color="accent">Submit</button>
      </form>
    </div>
  `,
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {

  constructor() {}

  formGroup: FormGroup;

  ngOnInit() {
    this.formGroup = new FormGroup({ text: new FormControl('') });
  }

  submit(): void {
    console.log(this.formGroup.value)
  }

}

References

Build

Run ng build ngx-mat-markdown-text-editor to build the library. The build artifacts will be stored in the dist/ngx-mat-markdown-text-editor directory. Use the --prod flag for a production build.

Running unit tests

Run ng test ngx-mat-markdown-text-editor to execute the unit tests via Karma.

Credits

This project is based on ngx-markdown and inspired from ngx-markdown-editor.

Keywords

angular

FAQs

Package last updated on 27 Apr 2020

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