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

ng2-lazy-trumbowyg

v2.4.3

Published

Angular 2 Component for lazy loading of Trumbowyg wysiwyg editor

Downloads

122

Readme

ng2-lazy-trumbowyg

Angular 2 Component for async loading of Trumbowyg wysiwyg editor Only few users on your app use text editor. This module let Angular app load jQuery, Trumbowyg js files and css file only for the users who write something.

plunker example app

Demo app with SystemJS (github)

Demo app with Angular-CLI (github)

Install

npm install ng2-lazy-trumbowyg --save

Usage

import TrumbowygModule in app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {TrumbowygModule} from 'ng2-lazy-trumbowyg';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    // If you want default version (2.8.0) and don't need plug-in, include this line.
    //TrumbowygModule,  
    //emoji doesn't work yet due to its dependency. table plug-in and insertaudio don't have icons.
    TrumbowygModule.forRoot({plugins: ['colors', 'noembed', 'preformatted', 'pasteimage', 'upload'], version: '2.8.0'}) //Optional config : plug-ins and version
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

include in component template

import {Component, ChangeDetectionStrategy} from '@angular/core';
import {Subject} from "rxjs";

@Component({
  selector: 'app-root',
  template: `
    <h2>Angular 2 Trumbowyg Update with <strong>Observable</strong> Example </h2>
    <p>Updated only when update button clicked</p>
    <trumbowyg [initialContent]="initialContentOne"  
               [options]="options1"
               [update]="update$" 
               (savedContent)="contentOne=$event">
      
    </trumbowyg>
    <button (click)="togglePreview()">Toggle Preview(with update)</button>
    <button *ngIf="showPreview" (click)="update$.next()">Update</button>
    <h2>Preview Mode {{showPreview ? 'On':'Off'}} </h2>
    <div *ngIf="showPreview" [innerHTML]="contentOne"></div>
    
    <br><br><br>
    
    <h2>Angular 2 Trumbowyg <strong>Live Update</strong> Example</h2>
    <trumbowyg liveUpdate="true" 
               [initialContent]="initialContentTwo"
               [options]="options2"
               (savedContent)="contentTwo=$event">
      
    </trumbowyg>
    <div [innerHTML]="contentTwo"></div>
  `
})
export class AppComponent {
  public showPreview: boolean = false;
  public initialContentOne: string = `<h2>This is an initial title One.</h2><p>This is an initial content.</p><p><img src="https://angular.io/assets/images/logos/angular/angular.svg" alt=""><br></p><p><br></p>`
  public initialContentTwo: string = `<h2>This is an initial title Two.</h2><p>This is an initial content.</p><p><img src="https://angular.io/generated/images/marketing/home/loved-by-millions.svg" alt=""><br></p><p><br></p>`
  public contentOne: string;
  public contentTwo: string;
  public update$: Subject<any> = new Subject();
  public options1: any = {
    autogrow: true,
    removeformatPasted: true,
    semantic: false,
    btns: [['bold', 'italic'], ['link'],['foreColor', 'backColor'], ['preformatted'], ['noembed']],
    lang: 'fr'
  };

  public options2: any = {
    lang: 'ru'
  };

  togglePreview() {
    this.showPreview = !this.showPreview;
    if(this.showPreview) this.update$.next();
  }

  constructor() {

    //Initial content update.
    setTimeout(() => {
      this.initialContentOne = "<h1>Contents can be manually updated 2</h1>"
      this.update$.next(); // this is needed only when you use ChangeDetectionStrategy.OnPush strategy
    },2000);
  }
}

Example app

cd example

npm install

ng serve

Build

npm run build