-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Vernite/dev
Version 1.1.1
- Loading branch information
Showing
52 changed files
with
656 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...nents/textarea/textarea.component.spec.ts → ...-editor/markdown-editor.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...n/components/textarea/textarea.stories.ts → ...arkdown-editor/markdown-editor.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/app/_main/directives/textarea-autosize/textarea-autosize.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Directive, Input, HostBinding, Optional, OnInit } from '@angular/core'; | ||
import { NgControl, AbstractControl } from '@angular/forms'; | ||
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy'; | ||
import { startWith } from 'rxjs'; | ||
|
||
@UntilDestroy() | ||
@Directive({ | ||
selector: 'textarea[autosize]', | ||
}) | ||
export class TextareaAutosizeDirective implements OnInit { | ||
@HostBinding('rows') | ||
public rows!: number; | ||
|
||
@Input() | ||
public minRows: number = 1; | ||
|
||
@Input() | ||
public maxRows: number = 10; | ||
|
||
@HostBinding('style.max-height') | ||
public maxHeight: string = '400px'; | ||
|
||
private _control?: AbstractControl; | ||
|
||
constructor(@Optional() private ngControl: NgControl) {} | ||
|
||
ngOnInit() { | ||
console.log('ngOnInit', this.ngControl.control); | ||
if (this.ngControl.control) { | ||
return this.ngOnControlInit(); | ||
} | ||
|
||
const _setUpControl = (this.ngControl as any)._setUpControl; | ||
(this.ngControl as any)._setUpControl = (...args: any[]) => { | ||
const tmp = _setUpControl.apply(this.ngControl, ...args); | ||
|
||
this.ngOnControlInit(); | ||
return tmp; | ||
}; | ||
} | ||
|
||
ngOnControlInit() { | ||
this._control = this.ngControl.control!; | ||
this._control.valueChanges | ||
.pipe(startWith(null), untilDestroyed(this)) | ||
.subscribe(() => this.resize()); | ||
} | ||
|
||
private resize() { | ||
if (this._control?.value) { | ||
this.rows = Math.min( | ||
this.maxRows, | ||
Math.max(this.minRows, this._control.value.split('\n').length), | ||
); | ||
} else { | ||
this.rows = this.minRows; | ||
} | ||
} | ||
} |
Oops, something went wrong.