bb-inline-editor
Version:
Follow me [](https://twitter.com/carlillo) to be notified about new releases.
37 lines (31 loc) • 1.48 kB
text/typescript
import { Component, OnInit, Injector, ChangeDetectionStrategy } from "@angular/core";
import { InputBase } from "./input-base";
import { InlineTextareaConfig } from "../types/inline-configs";
export class InputTextareaComponent extends InputBase implements OnInit {
constructor(injector: Injector) {
super(injector);
this.isRegexTestable = true;
this.isLengthTestable = true;
}
public config: InlineTextareaConfig;
public onKeyPress(event: KeyboardEvent) {
super.onKeyPress(event);
if (event.charCode === 13 && this.isSaving(event)) {
this.save();
this.onEscape(event);
}
}
private isSaving(event: KeyboardEvent): boolean {
return (this.config.saveOnEnter && !event.shiftKey) || (!this.config.saveOnEnter && event.shiftKey);
}
}