Changeset 35521 for main/trunk


Ignore:
Timestamp:
2021-09-29T14:51:57+13:00 (3 years ago)
Author:
cstephen
Message:

Improve new word insertion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/TranscriptionItemEditor.vue

    r35517 r35521  
    2020    </div>
    2121
    22     <!-- <word-timing-selector class="word-timing-selector" :surroundingWords="surroundingWords" :word="selectedWord" /> -->
     22    <word-timing-selector class="word-timing-selector" :surroundingWords="surroundingWords" :word="selectedWord" />
    2323
    2424    <div class="editor-controls">
     
    8787import AudioPlayback from "../js/AudioPlaybackModule"
    8888import AudioTimeBar from "./AudioTimeBar.vue"
    89 // import WordTimingSelector from "./WordTimingSelector.vue"
     89import WordTimingSelector from "./WordTimingSelector.vue"
    9090import Util, { log } from "../js/Util";
    9191
     
    121121    name: "TranscriptionItemEditor",
    122122    components: {
    123         AudioTimeBar//,
    124         // WordTimingSelector
     123        AudioTimeBar,
     124        WordTimingSelector
    125125    },
    126126    props: {
     
    215215
    216216            if (insertionEvents.includes(event.inputType)) {
    217                 if (event.data === " ") {
    218                     // Only insert if the current word isn't blank, to prevent 'jumping jacks' as the duplicate empty boxes are removed
    219                     if (word.word !== "") {
     217                const inputIndex = this.$refs[word.id].selectionStart;
     218
     219                if (event.data === " ") { // ONLY whitespace entered. Split or add new word
     220                    let newWord;
     221
     222                    if (inputIndex === 0) {
     223                        const newEndTime = word.startTime + (word.endTime - word.startTime) / 2;
     224                        newWord = new Word("", word.startTime, newEndTime);
     225
     226                        this.words.splice(index, 0, newWord);
     227                        word.startTime = newEndTime;
     228                    }
     229                    else if (inputIndex === word.word.length) {
    220230                        const newStartTime = word.startTime + ((word.endTime - word.startTime) / 2);
    221                         const newWord = new Word("", newStartTime, word.endTime);
     231                        newWord = new Word("", newStartTime, word.endTime);
     232
    222233                        this.words.splice(index + 1, 0, newWord);
    223 
    224                         // We have to give the element some time to be mounted before we can focus it
    225                         setTimeout(() => this.$refs[newWord.id].focus(), 50);
     234                        word.endTime = newStartTime;
    226235                    }
     236                    else {
     237                        // Split down middle
     238                    }
    227239
    228240                    event.preventDefault();
     241                    setTimeout(() => this.$refs[newWord.id].focus(), 50); // Give the element time to be mounted before focusing
     242                }
     243                else if (event.data.includes(" ")) {
     244                    // Split input
    229245                }
    230246            }
Note: See TracChangeset for help on using the changeset viewer.