mirror of
https://github.com/NicolasConstant/sengi
synced 2025-02-09 00:18:44 +01:00
add content copy, fix #280
This commit is contained in:
parent
6a7d389b55
commit
c14009692f
@ -11,6 +11,9 @@
|
||||
<ng-template contextMenuItem (execute)="copyStatusLink()" *ngIf="statusWrapper">
|
||||
Copy link to status
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="copyAllData()" *ngIf="statusWrapper">
|
||||
Copy all data
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem divider="true" *ngIf="statusWrapper"></ng-template>
|
||||
<ng-template contextMenuItem (execute)="mentionAccount()" *ngIf="!isOwnerSelected">
|
||||
Mention @{{ this.username }}
|
||||
|
@ -75,7 +75,7 @@ export class StatusUserContextMenuComponent implements OnInit, OnDestroy {
|
||||
|
||||
private checkStatus(accounts: AccountInfo[]): void {
|
||||
const selectedAccount = accounts.find(x => x.isSelected);
|
||||
|
||||
|
||||
this.isOwnerSelected = selectedAccount.username.toLowerCase() === this.displayedStatus.account.username.toLowerCase()
|
||||
&& selectedAccount.instance.toLowerCase() === this.displayedStatus.account.url.replace('https://', '').split('/')[0].toLowerCase();
|
||||
}
|
||||
@ -118,6 +118,33 @@ export class StatusUserContextMenuComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
|
||||
copyAllData(): boolean {
|
||||
const newLine = String.fromCharCode(13, 10);
|
||||
|
||||
let selBox = document.createElement('textarea');
|
||||
selBox.style.position = 'fixed';
|
||||
selBox.style.left = '0';
|
||||
selBox.style.top = '0';
|
||||
selBox.style.opacity = '0';
|
||||
selBox.value = `${this.displayedStatus.url}${newLine}${newLine}${this.displayedStatus.content}${newLine}${newLine}`;
|
||||
|
||||
let parser = new DOMParser();
|
||||
var dom = parser.parseFromString(this.displayedStatus.content, 'text/html')
|
||||
selBox.value += `${dom.body.textContent}${newLine}${newLine}`;
|
||||
|
||||
for (const att of this.displayedStatus.media_attachments) {
|
||||
selBox.value += `${att.url}${newLine}${newLine}`;
|
||||
}
|
||||
|
||||
document.body.appendChild(selBox);
|
||||
selBox.focus();
|
||||
selBox.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(selBox);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
mentionAccount(): boolean {
|
||||
this.navigationService.replyToUser(this.fullHandle, false);
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user