Adding Copy function

This commit is contained in:
Fabian 2019-06-03 18:20:35 +02:00
parent ffe1dd6f9f
commit d46223c96a
1 changed files with 14 additions and 1 deletions

View File

@ -84,7 +84,7 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
}
const deleteNote = async () => {
Notes.delete(note._id).then(() => {
this.vault.deleteNote(note._id).then(() => {
Notifications.sendSuccess("Deleted")
this.rawNotes = this.rawNotes.filter(e => e._id !== note._id);
this.setState({ notes: this.state.notes.filter(e => e._id !== note._id) });
@ -93,6 +93,18 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
})
}
const copyNote = async () => {
this.vault.getNote(note._id).then(note => {
const el = document.createElement('textarea');
el.value = note.__value;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
Notifications.sendSuccess("Copied");
})
}
let share;
if ((window.navigator as any).share) {
share = <button class="uk-button" onClick={shareNote}>
@ -103,6 +115,7 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
let context = <ContextMenu event={evt} >
{share}
<button class="uk-button" onClick={deleteNote}>delete</button>
<button class="uk-button" onClick={copyNote}>copy</button>
</ContextMenu>
this.setState({ context });