automatically focus when writing a new status
This commit is contained in:
parent
7aed4569e5
commit
328a87cef8
|
@ -3,10 +3,9 @@
|
||||||
|
|
||||||
<form (ngSubmit)="onSubmit()">
|
<form (ngSubmit)="onSubmit()">
|
||||||
<!-- <label>Please provide your account:</label> -->
|
<!-- <label>Please provide your account:</label> -->
|
||||||
<input [(ngModel)]="title" type="text" class="form-control form-control-sm" name="title" autocomplete="off"
|
<input [(ngModel)]="title" type="text" class="form-control form-control-sm" name="title" autocomplete="off" placeholder="Title (optional)" />
|
||||||
placeholder="Title (optional)" />
|
|
||||||
<!-- <textarea rows="4" cols="50"> -->
|
<!-- <textarea rows="4" cols="50"> -->
|
||||||
<textarea [(ngModel)]="status" name="status" class="form-control form-control-sm" style="min-width: 100%" rows="5" required placeholder="What's in your mind?" (keydown.control.enter)="onCtrlEnter()"></textarea>
|
<textarea #reply [(ngModel)]="status" name="status" class="form-control form-control-sm" style="min-width: 100%" rows="5" required placeholder="What's in your mind?" (keydown.control.enter)="onCtrlEnter()"></textarea>
|
||||||
|
|
||||||
<select class="form-control form-control-sm form-control--privacy" id="privacy" name="privacy" [(ngModel)]="selectedPrivacy">
|
<select class="form-control form-control-sm form-control--privacy" id="privacy" name="privacy" [(ngModel)]="selectedPrivacy">
|
||||||
<option *ngFor="let p of privacyList" [ngValue]="p">{{p}}</option>
|
<option *ngFor="let p of privacyList" [ngValue]="p">{{p}}</option>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input, ElementRef, ViewChild } from '@angular/core';
|
||||||
import { Store } from '@ngxs/store';
|
import { Store } from '@ngxs/store';
|
||||||
import { AccountInfo } from '../../../states/accounts.state';
|
import { AccountInfo } from '../../../states/accounts.state';
|
||||||
import { MastodonService, VisibilityEnum } from '../../../services/mastodon.service';
|
import { MastodonService, VisibilityEnum } from '../../../services/mastodon.service';
|
||||||
|
@ -13,6 +13,7 @@ import { FormsModule } from '@angular/forms';
|
||||||
export class AddNewStatusComponent implements OnInit {
|
export class AddNewStatusComponent implements OnInit {
|
||||||
@Input() title: string;
|
@Input() title: string;
|
||||||
@Input() status: string;
|
@Input() status: string;
|
||||||
|
@ViewChild('reply') replyElement: ElementRef;
|
||||||
|
|
||||||
selectedPrivacy = 'Public';
|
selectedPrivacy = 'Public';
|
||||||
privacyList: string[] = ['Public', 'Unlisted', 'Follows-only', 'DM'];
|
privacyList: string[] = ['Public', 'Unlisted', 'Follows-only', 'DM'];
|
||||||
|
@ -22,6 +23,9 @@ export class AddNewStatusComponent implements OnInit {
|
||||||
private readonly mastodonService: MastodonService) { }
|
private readonly mastodonService: MastodonService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.replyElement.nativeElement.focus();
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): boolean {
|
onSubmit(): boolean {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<form (ngSubmit)="onSubmit()">
|
<form (ngSubmit)="onSubmit()">
|
||||||
<textarea [(ngModel)]="status" name="status" class="form-control form-control-sm" rows="5" required placeholder="What's in your mind?" (keydown.control.enter)="onCtrlEnter()"></textarea>
|
<textarea #reply [(ngModel)]="status" name="status" class="form-control form-control-sm" rows="5" required placeholder="What's in your mind?" (keydown.control.enter)="onCtrlEnter()"></textarea>
|
||||||
|
|
||||||
<select class="form-control form-control-sm form-control--privacy" id="privacy" name="privacy" [(ngModel)]="selectedPrivacy">
|
<select class="form-control form-control-sm form-control--privacy" id="privacy" name="privacy" [(ngModel)]="selectedPrivacy">
|
||||||
<option *ngFor="let p of privacyList" [ngValue]="p">{{p}}</option>
|
<option *ngFor="let p of privacyList" [ngValue]="p">{{p}}</option>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter, ElementRef, ViewChild } from '@angular/core';
|
||||||
import { Store } from '@ngxs/store';
|
import { Store } from '@ngxs/store';
|
||||||
import { MastodonService, VisibilityEnum } from '../../../../services/mastodon.service';
|
import { MastodonService, VisibilityEnum } from '../../../../services/mastodon.service';
|
||||||
import { AccountInfo } from '../../../../states/accounts.state';
|
import { AccountInfo } from '../../../../states/accounts.state';
|
||||||
|
@ -14,6 +14,7 @@ export class ReplyToStatusComponent implements OnInit {
|
||||||
@Input() status: string = '';
|
@Input() status: string = '';
|
||||||
@Input() statusReplyingToWrapper: StatusWrapper;
|
@Input() statusReplyingToWrapper: StatusWrapper;
|
||||||
@Output() onClose = new EventEmitter();
|
@Output() onClose = new EventEmitter();
|
||||||
|
@ViewChild('reply') replyElement: ElementRef;
|
||||||
|
|
||||||
private statusReplyingTo: Status;
|
private statusReplyingTo: Status;
|
||||||
|
|
||||||
|
@ -31,6 +32,10 @@ export class ReplyToStatusComponent implements OnInit {
|
||||||
for (const mention of this.statusReplyingTo.mentions) {
|
for (const mention of this.statusReplyingTo.mentions) {
|
||||||
this.status += `@${mention.acct} `;
|
this.status += `@${mention.acct} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.replyElement.nativeElement.focus();
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): boolean {
|
onSubmit(): boolean {
|
||||||
|
@ -53,7 +58,7 @@ export class ReplyToStatusComponent implements OnInit {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let spoiler = this.statusReplyingTo.spoiler_text;
|
let spoiler = this.statusReplyingTo.spoiler_text;
|
||||||
|
|
||||||
for (const acc of selectedAccounts) {
|
for (const acc of selectedAccounts) {
|
||||||
this.mastodonService.postNewStatus(acc, this.status, visibility, spoiler, this.statusReplyingTo.id)
|
this.mastodonService.postNewStatus(acc, this.status, visibility, spoiler, this.statusReplyingTo.id)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, Input, Inject, LOCALE_ID } from "@angular/core";
|
import { Component, OnInit, Input, Inject, LOCALE_ID, ElementRef } from "@angular/core";
|
||||||
import { Status } from "../../../services/models/mastodon.interfaces";
|
import { Status } from "../../../services/models/mastodon.interfaces";
|
||||||
import { formatDate } from '@angular/common';
|
import { formatDate } from '@angular/common';
|
||||||
import { stateNameErrorMessage } from "@ngxs/store/src/decorators/state";
|
import { stateNameErrorMessage } from "@ngxs/store/src/decorators/state";
|
||||||
|
@ -45,7 +45,8 @@ export class StatusComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
constructor(@Inject(LOCALE_ID) private locale: string) { }
|
constructor(
|
||||||
|
@Inject(LOCALE_ID) private locale: string) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
@ -70,6 +71,7 @@ export class StatusComponent implements OnInit {
|
||||||
|
|
||||||
openReply(): boolean{
|
openReply(): boolean{
|
||||||
this.replyingToStatus = !this.replyingToStatus;
|
this.replyingToStatus = !this.replyingToStatus;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue