Skip to content

Commit 58c3329

Browse files
feat: add clipboard in voicecapture
1 parent f3a8cc8 commit 58c3329

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/components/VoiceCapture.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default {
4141
type: String,
4242
default: 'fullscreen',
4343
},
44+
clipboard: {
45+
type: Boolean,
46+
default: false,
47+
},
4448
},
4549
emits: ['voiceTranscript', 'onStatus'],
4650
setup(props, { emit }) {
@@ -123,6 +127,16 @@ export default {
123127
translatedText.value = interimTranscript || finalTranscript.value;
124128
125129
if (finalTranscript.value) {
130+
if(props.clipboard) {
131+
navigator.clipboard.writeText(finalTranscript.value).then(
132+
() => {
133+
console.log('Text copied to clipboard');
134+
},
135+
(err) => {
136+
console.error('Could not copy text to clipboard', err);
137+
}
138+
);
139+
}
126140
emit('voiceTranscript', finalTranscript.value);
127141
deactivateVoice();
128142
}

0 commit comments

Comments
 (0)