- Timestamp:
- 2021-11-11T15:22:25+13:00 (2 years ago)
- Location:
- main/trunk/model-interfaces-dev/atea/macron-restoration/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/DirectInput.vue
r35726 r35728 8 8 <span v-if="errorState" class="error-text">Something went wrong! Please try modifying your input text.</span> 9 9 10 <!-- eslint-disable-next-line vue/require-v-for-key --> 11 <span v-for="word in validRestored" :class="{ 'highlight': word.macronised && this.showMacronisedWords }">{{ word.w }} </span> 10 <span class="preserveWhitespace" v-html="formattedRestored" /> 12 11 </div> 13 12 14 13 <div class="flex"> 15 <input type="checkbox" id="i-preserve-existing-macrons" v-model="preserveExistingMacrons" />14 <input type="checkbox" id="i-preserve-existing-macrons" v-model="preserveExistingMacrons" @input="startMacronisationWait" /> 16 15 <label for="i-preserve-existing-macrons">{{ translations.get('DirectInput_PreserveExistingMacrons') }}</label> 17 16 </div> … … 20 19 <input type="checkbox" id="i-show-macronised-words" v-model="showMacronisedWords" /> 21 20 <label for="i-show-macronised-words">{{ translations.get('DirectInput_ShowMacronisedWords') }}</label> 21 </div> 22 23 <div class="flex right-column"> 24 <input type="checkbox" id="i-show-macronised-words" v-model="normaliseLinebreaks" /> 25 <label for="i-show-macronised-words">{{ translations.get('DirectInput_NormaliseLinebreaks') }}</label> 22 26 </div> 23 27 … … 33 37 } 34 38 39 .preserveWhitespace { 40 white-space: pre-line; 41 } 42 35 43 .input-area { 36 resize: none;44 resize: vertical; 37 45 min-height: 4em; 38 overflow: hidden;39 46 } 40 47 … … 72 79 preserveExistingMacrons: true, 73 80 showMacronisedWords: false, 74 transcribeTimeout: null, 75 waitingOnTranscribe: false, 76 errorState: false 81 macroniseWaitTimeout: null, 82 waitingToMacronise: false, 83 errorState: false, 84 normaliseLinebreaks: false 77 85 } 78 86 }, 79 87 computed: { 80 88 canDownload() { 81 return this.restored !== null && !this.waiting OnTranscribe;89 return this.restored !== null && !this.waitingToMacronise; 82 90 }, 83 91 input: { … … 87 95 set(newValue) { 88 96 this.$store.commit("setDirectInput", newValue); 97 this.startMacronisationWait(); 89 98 } 90 99 }, … … 97 106 } 98 107 }, 99 validRestored() { 100 return this.restored.filter(w => w.w !== ""); 108 formattedRestored() { 109 let restored = ""; 110 111 for (const word of this.restored) { 112 if (word.w) { 113 if (word[0] !== "-") { 114 restored += " "; 115 } 116 117 if (word.macronised && this.showMacronisedWords) { 118 restored += `<mark class="highlight">${word.w}</mark>`; 119 } 120 else { 121 restored += word.w; 122 } 123 } 124 125 if (word.linebreak) { 126 restored += this.normaliseLinebreak(word.linebreak); 127 } 128 } 129 130 return restored; 101 131 }, 102 132 ...mapState({ 103 133 translations: state => state.translations 104 134 }) 105 },106 watch: {107 input() {108 this.waitingOnTranscribe = true;109 110 if (this.transcribeTimeout !== null) {111 clearTimeout(this.transcribeTimeout);112 }113 114 this.transcribeTimeout = setTimeout(this.updateMacronisedText, 1000);115 }116 135 }, 117 136 methods: { … … 124 143 event.target.height = event.target.scrollHeight; 125 144 }, 145 startMacronisationWait() { 146 if (this.input === null || this.input === "") { 147 return; 148 } 149 150 this.waitingToMacronise = true; 151 152 if (this.macroniseWaitTimeout !== null) { 153 clearTimeout(this.macroniseWaitTimeout); 154 } 155 156 this.macroniseWaitTimeout = setTimeout(this.updateMacronisedText, 1000); 157 }, 126 158 async updateMacronisedText() { 127 159 this.errorState = false; … … 129 161 try { 130 162 this.restored = await macroniser.directMacronisation(this.input, this.preserveExistingMacrons); 131 this.waiting OnTranscribe = false;163 this.waitingToMacronise = false; 132 164 } 133 165 catch (ex) { … … 139 171 const blob = new Blob([ this.restored ], { type: "text/plain;charset=utf-8" }); 140 172 saveAs(blob, "restored.txt"); 173 }, 174 /** 175 * Normalises a linebreak. 176 * @param {String} linebreak The linebreak sequence. 177 */ 178 normaliseLinebreak(linebreak) { 179 if (!this.normaliseLinebreaks) { 180 return linebreak; 181 } 182 183 const rCount = linebreak.split("\r").length - 1; 184 const nCount = linebreak.split("\n").length - 1; 185 186 if (rCount > 1) { 187 if (nCount > 0) { 188 return "\r\n\r\n"; 189 } 190 191 return "\r\r"; 192 } 193 else if (nCount > 1) { 194 return "\n\n"; 195 } 196 197 return linebreak; 141 198 } 142 199 } -
main/trunk/model-interfaces-dev/atea/macron-restoration/src/styles/_material.scss
r35723 r35728 32 32 // Default theme 33 33 @extend .theme-primary; 34 } 35 36 /* Scrollbar replacement */ 37 38 ::-webkit-scrollbar { 39 width: 8px; 40 height: 8px; 41 } 42 43 ::-webkit-scrollbar-track { 44 background: #f1f1f1; 45 } 46 47 ::-webkit-scrollbar-thumb { 48 background: #CCC; 49 border-radius: 3px; 50 51 transition-duration: var(--transition-duration); 52 53 &:hover { 54 background: #666; 55 height: 8px; 56 width: 8px; 57 } 34 58 } 35 59 … … 114 138 display: flex; 115 139 flex-wrap: wrap; 140 align-content: flex-start; 141 align-items: flex-start; 116 142 117 143 border-radius: var(--border-radius); … … 123 149 @extend .text-container; 124 150 151 align-items: center; 125 152 overflow-x: auto; 126 153 overflow-y: hidden; … … 140 167 font-size: 1em; 141 168 142 transition -duration:var(--transition-duration);169 transition: border var(--transition-duration); 143 170 144 171 &:hover { … … 416 443 } 417 444 418 /* Scrollbar replacement */419 420 ::-webkit-scrollbar {421 width: 6px;422 height: 6px;423 }424 425 ::-webkit-scrollbar-track {426 background: #f1f1f1;427 }428 429 ::-webkit-scrollbar-thumb {430 background: #CCC;431 border-radius: 3px;432 433 transition-duration: var(--transition-duration);434 435 &:hover {436 background: #666;437 height: 8px;438 width: 8px;439 }440 }441 442 445 /* === Start Theme Definitions === */ 443 446
Note:
See TracChangeset
for help on using the changeset viewer.