Skip to content

Commit

Permalink
移動時に書いていた内容を一時保存。
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanasu committed Oct 18, 2023
1 parent 6c886d8 commit 58c8d41
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/component/chat-input/chat-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class ChatInputComponent implements OnInit, OnDestroy {
get filterText(): string { return this._filterText };
set filterText(filterText: string) { this._filterText = filterText; this.filterTextChange.emit(filterText); }

@Output() moveToPalette = new EventEmitter();
@Output() moveToPalette = new EventEmitter<string>();

@Output() chat = new EventEmitter<{
text: string, gameType: string, sendFrom: string, sendTo: string,
Expand Down Expand Up @@ -358,7 +358,7 @@ export class ChatInputComponent implements OnInit, OnDestroy {
if (!this.textAreaElementRef) return;
if (this.textAreaElementRef.nativeElement.selectionStart != this.textAreaElementRef.nativeElement.selectionEnd) return;
if (this.textAreaElementRef.nativeElement.selectionStart === this.textAreaElementRef.nativeElement.value.length) {
this.moveToPalette.emit();
this.moveToPalette.emit(this.text);
e.preventDefault();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/component/chat-palette/chat-palette.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</label>
</div>
</form>
<chat-input [onlyCharacters]="true" [chatTabidentifier]="chatTabidentifier" (moveToPalette)="moveToPalette()"
<chat-input [onlyCharacters]="true" [chatTabidentifier]="chatTabidentifier" (moveToPalette)="moveToPalette($event)"
[(gameType)]="gameType" [(sendFrom)]="sendFrom" [(text)]="text" [(filterText)]="filterText" (chat)="sendChat($event)" #chatInput></chat-input>
<div *ngIf="isEdit" class="edit-info" style="display: flex">
<div style="width: calc(100% - 1.6em); text-align: center"><i class="material-icons" style="vertical-align: middle; font-size: 1.05rem">info_outline</i> チャットパレット編集中</div>
Expand Down
6 changes: 5 additions & 1 deletion src/app/component/chat-palette/chat-palette.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export class ChatPaletteComponent implements OnInit, OnDestroy {
if (!this.chatPletteElementRef.nativeElement) return;
const selectedPaletteIndex = this.chatPletteElementRef.nativeElement.selectedIndex;
if (selectedPaletteIndex <= 0) {
this.text = this._tempText;
this.chatInputComponent.textAreaElementRef.nativeElement.value = this._tempText;
this.chatInputComponent.textAreaElementRef.nativeElement.focus();
e.preventDefault();
}
Expand All @@ -145,7 +147,9 @@ export class ChatPaletteComponent implements OnInit, OnDestroy {
if (e) e.preventDefault();
}

moveToPalette() {
private _tempText: string;
moveToPalette(tempText: string) {
this._tempText = tempText;
if (!this.chatPletteElementRef.nativeElement) return;
if (this.chatPletteElementRef.nativeElement.options.length <= 0) return;
this.chatPletteElementRef.nativeElement.options[0].selected = true;
Expand Down

0 comments on commit 58c8d41

Please sign in to comment.