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

vin-content-editable

v2.0.0

Published

By default angular forms only support HTML input element. If someone in their project has to use an element with `contenteditable=true`, in that case they do not any choice except write code for checking validation and other form state like touched or pri

Downloads

16

Readme

vinContentEditable

By default angular forms only support HTML input element. If someone in their project has to use an element with contenteditable=true, in that case they do not any choice except write code for checking validation and other form state like touched or pristien etc, by themselves, which is very error prone.

To overcome this issue, I have created this package vinContentEditable. This package has two directives.

  1. vinContentEditable: used for adding support for contenteditable=true with angular forms.
  2. matContentEditableInput: used for adding support for angular material form field.

Installation

npm install --save vin-content-editable.

For Angular 10 use version 2.0.x

Usage

  1. Import VinContentEditableModule in the component module where we want to use generict toggle.
  import { VinContentEditableModule } from 'vin-content-editable';

  @NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    VinContentEditableModule,
    FormsModule,
    ReactiveFormsModule,
  ],
  providers: [],
  bootstrap: [AppComponent],

})
export class AppModule { }
  1. Use vinContentEditable directive for angular forms and matContentEditableInput for material form field on the target HTML element.
<div vinContentEditable [formControl]="fc"></div>

For angular material form field

<mat-form-field>
  <div vinContentEditable [formControl]="fc" matContentEditableInput placeholder="content editable"></div>
  <mat-error *ngIf="fc.touched && fc.invalid">{{matceErr()}}</mat-error>
  <mat-hint>content editable field</mat-hint>
</mat-form-field>
  1. Here is the type script file code
  fc = new FormControl('form control', Validators.required);

  constructor() { }

  ngOnInit() {
    this.fc.valueChanges.subscribe(val => {
      console.log({ val })
    });
  }
  1. This is optional. In case of angular material there are very good changes that you design might break. To overcome this issue add below style to global style sheet or in the current componet with ::ng-deep.
.mat-form-field-infix {
    [contenteditable]:first-child {
      margin: 0px;
      outline: 0px;
      min-height: 1.125em;
      line-height: 1.125em;
      display: inline-block;
    }
  }

or if you are using scss, you can import style from @import 'vin-content-editable/mat-content-editable-styles'; and run mixin mat-content-editable-styles after your angular material styles.

Thats all you have to do.

If you find any issue please feel free to raise it on github.

Tip

You can use innerText or innerHTML to get value from with vinContentEditable directive. E.g.

vinContentEditable="innerHTML"

Example

Here is the Demo

Please have a look on these also

  1. NgGenericRadio
  2. NgGenericToggle