22 <div
33 class =" transcript d-flex"
44 v-bind:class =" [wrapTextPositionClass, (chromeless ? 'chromeless' : '')]"
5- v-bind:style =" {height, color, backgroundColor, fontFamily, fontSize, lineHeight, letterSpacing, textTransform, padding, textShadow}" >
5+ v-bind:style =" {height, color, backgroundColor, fontFamily, fontSize, lineHeight, letterSpacing, textTransform, padding, textShadow, cursor}"
6+ @click =" focusIfInTypingMode()" >
67 <link type =" text/css" rel =" stylesheet" :href =" 'https://fonts.googleapis.com/css?family=' + fontFamily" />
78 <span
89 v-bind:class =" textPositionClass"
910 class =" transcript-scroller"
1011 ref =" scroller" >
11- <span class =" transcript-scroller-child" >{{finalTranscript}} <span v-if =" interimTranscript" v-bind:style =" {color: interimColor}" >{{interimTranscript}}</span ></span >
12+ <span class =" transcript-scroller-child" >{{finalTranscript}} <span v-if =" interimTranscript" v-bind:style =" {color: interimColor}" >{{interimTranscript}}</span > < span v-show = " typingModeOn " contenteditable v-text = " transcriptTypedForDisplay " @input = " typedTranscriptDidChange() " ref = " typedTranscript " class = " transcriptTyped " >Hello world</ span > </span >
1213 </span >
1314 </div >
1415</template >
@@ -27,6 +28,7 @@ export default {
2728 data : function () {
2829 return {
2930 height: ' 100vh' ,
31+ transcriptTypedForDisplay: ' ' ,
3032 }
3133 },
3234 methods: {
@@ -37,6 +39,14 @@ export default {
3739 }
3840 });
3941 },
42+ typedTranscriptDidChange : function () {
43+ this .$store .commit (' captioner/SET_TRANSCRIPT_TYPED' , {transcriptTyped: this .$refs .typedTranscript .innerText })
44+ },
45+ focusIfInTypingMode : function () {
46+ if (this .typingModeOn ) {
47+ this .$refs .typedTranscript .focus ();
48+ }
49+ },
4050 },
4151 mounted : function () {
4252 this .scrollToBottom ();
@@ -54,6 +64,37 @@ export default {
5464 this .height = this .adjustAppHeight ();
5565 });
5666 },
67+ watch: {
68+ typingModeOn : function (on ) {
69+ if (on) {
70+ // Turned on. Copy the transcript over once.
71+ this .transcriptTypedForDisplay = this .typedTranscript ;
72+ this .$nextTick (() => {
73+ this .$refs .typedTranscript .focus ();
74+
75+ // Put caret at end
76+ if (typeof window .getSelection != " undefined"
77+ && typeof document .createRange != " undefined" ) {
78+ var range = document .createRange ();
79+ range .selectNodeContents (this .$refs .typedTranscript );
80+ range .collapse (false );
81+ var sel = window .getSelection ();
82+ sel .removeAllRanges ();
83+ sel .addRange (range);
84+ } else if (typeof document .body .createTextRange != " undefined" ) {
85+ var textRange = document .body .createTextRange ();
86+ textRange .moveToElementText (this .$refs .typedTranscript );
87+ textRange .collapse (false );
88+ textRange .select ();
89+ }
90+ });
91+ }
92+ else {
93+ // Turned off.
94+ this .transcriptTypedForDisplay = ' ' ;
95+ }
96+ },
97+ },
5798 computed: {
5899 // Appearance
59100 color () {
@@ -107,6 +148,12 @@ export default {
107148 return (this .$store .state .captioner .transcript .interim && this .$store .state .captioner .transcript .interim .length ? ' ' : ' ' )
108149 + this .$store .state .captioner .transcript .interim ;
109150 },
151+ typingModeOn () {
152+ return this .$store .state .captioner .typingModeOn ;
153+ },
154+ typedTranscript () {
155+ return this .$store .state .captioner .transcript .typed ;
156+ },
110157
111158 textPositionClass : function () {
112159 return {
@@ -130,6 +177,9 @@ export default {
130177 ' align-items-end' : [' bottom' ,' lowerThird' ].includes (this .$store .state .settings .appearance .text .alignment .vertical ),
131178 }
132179 },
180+ cursor : function () {
181+ return this .typingModeOn ? ' text' : ' default' ;
182+ },
133183 largerLayout : function () {
134184 return this .$store .state .settings .controls .layout .larger ;
135185 },
@@ -138,4 +188,10 @@ export default {
138188 </script >
139189
140190<style lang="css">
191+ .transcriptTyped {
192+ outline :none ;
193+ min-width :5px ;
194+ display :inline-block ;
195+ min-height :100px ;
196+ }
141197 </style >
0 commit comments