npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-infi-markdown

v1.0.2

Published

<p align="center"> <img width="80%" height="80%" src="https://raw.githubusercontent.com/gitsobek/npx-infi-markdown/master/logo.svg?sanitize=true"> </p> &nbsp;

Downloads

5

Readme

MIT PRs styled with prettier All Contributors

Simple and neat editor with an embedded preview. Create your own custom styles and transpile your written text into HTML. This library provides an injectable and configurable web-component which you can easily place anywhere in your application.

Table of Contents

Installation

Using npm:

npm install ngx-infi-markdown --save

Configuration

In order to start working with the editor you have to import NgxInfiMarkdown module in the root module:

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxInfiMarkdownModule } from 'ngx-infi-markdown';

@NgModule({
  declarations: [AppComponent],
  imports: [
    // ...,
    NgxInfiMarkdownModule
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

Place the markdown editor in your template:

<ngx-infi-markdown></ngx-infi-markdown>
<button (click)="getContent()">Submit post</button>

Inject NgxInfiMarkdownService into your component to interact with the editor and retrieve generated content:

import { NgxInfiMarkdownService } from 'ngx-infi-markdown';
 
export class AppComponent implements OnInit {
  constructor(private markdown: NgxInfiMarkdownService) {}
 
  ngOnInit() {}

  getContent(): void {
      const html = this.markdown.getHtml();
      // ..
  }
}

Methods

  • html$() returns observable of currently created content
  • getHtml() returns currently created content synchronously

Custom styles configuration

You can switch between default and custom styles by clicking the toggle button. This library provides a posibility to load your own custom styles in two ways:

  • pass the configuration object to the component:
<ngx-infi-markdown
    [styles]="articleStyles"
></ngx-infi-markdown>

In your class:

export class AppComponent {
  articleStyles = {
    primaryHeader: {
      textAlign: 'center',
      fontSize: '72px',
      fontWeight: 600,
    },
    secondaryHeader: {
      fontSize: '32px',
      fontWeight: 500,
    },
    tertiaryHeader: {
      fontFamily: ['Roboto', 'sans-serif'],
      fontSize: '26px',
      fontWeight: 400
    },
    quaternaryHeader: {
      fontSize: '22px',
    },
    orderedList: {
      // ...
    },
    unorderedList: {
      // ...
    },
    paragraph: {
      // ...
    },
    quote: {
      borderLeft: '1px solid #999',
      textAlign: 'left',
      // ...
    },
  };
}
  • pass a configuration object to all instances globally:
@NgModule({
  declarations: [AppComponent],
  imports: [
    NgxInfiMarkdownModule.forRoot({
      styles: {
        primaryHeader: {
          // ...
        },
        secondaryHeader: {
          // ...
        }
        // ...
    }),
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

You have to take few things into consideration when configuring your custom styles:

  1. Using global configuration method overrides component-level configuration in all instances of the editor.
  2. Every tag must be added in the configuration object. Available tags are listed below: primaryHeader, secondaryHeader, tertiaryHeader, quaternaryHeader, orderedList, unorderedList, paragraph, quote
  3. Every style property must be added in a camel case format.
  4. If you want to specify a font-family property for a particular tag, place the font names in an array: fontFamily: ['Roboto', 'sans-serif']

Store your changes

If you wish to store your changes on page leave or component destroy, then you have to pass the persistance storage configuration to the imported module.

NgxInfiMarkdownModule.forRoot({
    storageType: '<pass storage type>'
})

Available storages are as follows: | Name | Description | |:---------------:|:--------------------------:| | none | disables storage (default) | | localStorage | uses Local Storage | | sessionStorage | uses Session Storage |

Demo

The showcase of the library can be found under the following link.

Future plans

  • add bold, italic and underline tag
  • improve responsiveness of editor and preview
  • add IndexedDB as storage option

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind are welcome!