1.0.30 • Published 4 years ago

ng-simple-markdown-editor v1.0.30

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

npm version Build Status Known Vulnerabilities

ng-simple-markdown-editor

A simple markdown editor component for Angular 2 and up.

Demo

Stackblitz

Dependencies

Install

Using npm

npm install ng-simple-markdown-editor

Import to your module

import { NgSimpleMarkdownEditorModule } from 'ng-simple-markdown-editor';

@NgModule({
  imports: [
    NgSimpleMarkdownEditorModule, // <-- import the library into your module
  ],
})
export class AppModule {}

Usage

Using the editor

<ng-simple-markdown-editor name="markdown" [(ngModel)]="markdown" (files)="upload($event)" (mentionSearchTerm)="search($event)"></ng-simple-markdown-editor>

Using the markdown viewer

<iframe ngSimpleMarkdownViewer [markdown]="markdown" (ready)="ready()" (mentions)="mentions($event)" (tags)="tags($event)" (taskLists)="taskLists($event)"></iframe>

Using the markdown text preview pipe

<div>{{ markdown | ngSimpleMarkdownTextPreview }}</div>

Using the markdown service

import { NgSimpleMarkdownEditorService } from 'ng-simple-markdown-editor';

@Component({
  ...
})
export class DemoComponent {

  public constructor(private ngSimpleMarkdownEditorService: NgSimpleMarkdownEditorService) {}

  public parseMarkdown(markdown: string): string {
    return this.ngSimpleMarkdownEditorService.parse(markdown);
  }

}

Configuration

NgSimpleMarkdownEditorComponent

TypeNameDataTypeDefault ValueDescription
Inputheightstring'400px'Define the total height of the editor element including the toolbar
InputhistoryStepsnumber10Define the number of history saved, 0 for disable
InputmentionConfigsMentionConfig[][]Define mention configs
Inputplaceholderstring''Define the placeholder of the editor
InputresizebooleantrueWhether allow user to resize this editor
OutputfilesFile[]NilEmit when files are dropped / pasted into the editor
OutputmentionSearchTermstringNilEmit when user type mention search term

NgSimpleMarkdownViewerDirective

TypeNameDataTypeDefault ValueDescription
InputmarkdownstringundefinedDefine the input markdown
InputstylesstringundefinedDefine the additional css styles
InputgetTagUrl(tag: string) => stringundefinedDefine the function for the link of #tag
OutputmentionsstringNilEmit the mention when clicked, which is username
OutputmentionWithIds string, string NilEmit the mention when clicked, the first string is userId, the second is username
OutputreadybooleanNilEmit when markdown content has loaded
OutputtagsstringNilEmit the tag string when clicked
OutputtaskListsstringNilEmit the updated markdown when clicked task list checkbox

For the mentions, the accepted formats are @(userId|user.name) or @user.name.

MentionConfig\<T>

NameDataTypeDescription
dataObservable<T[]>Array of data entries feed into mention menu
templateTemplateRefTemplate for render mention menu entry
transform(item: T) => stringTransform function used before inserting content to editor
triggerstringCharacter for trigger mention menu

MentionsSearchTerm

NameDataTypeDescription
termstringUser input search term
triggerstringTrigger character
1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.7.13

4 years ago

0.7.12

4 years ago

0.7.10

4 years ago

0.7.9

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago