
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
vin-content-editable
Advanced tools
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
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.
contenteditable=true
with angular forms.npm install --save vin-content-editable.
For Angular 10 use version 2.0.x
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 { }
vinContentEditable
directive for angular forms and matContentEditableInput
for material form field on the target HTML element.<div vinContentEditable [formControl]="fc"></div>
<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>
fc = new FormControl('form control', Validators.required);
constructor() { }
ngOnInit() {
this.fc.valueChanges.subscribe(val => {
console.log({ val })
});
}
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.
You can use innerText
or innerHTML
to get value from with vinContentEditable
directive. E.g.
vinContentEditable="innerHTML"
Here is the Demo
FAQs
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
We found that vin-content-editable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.