Changeset 35541


Ignore:
Timestamp:
2021-10-01T13:37:21+13:00 (3 years ago)
Author:
cstephen
Message:

Handle pasting of multiple words

File:
1 edited

Legend:

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

    r35538 r35541  
    1313            <li v-for="(word, index) in words" :key="word.id" class="word-container">
    1414                <input :size="word.word.length === 0 ? 1 : word.word.length" :ref="word.id"
    15                     class="editor-word" v-model="word.word" type="text" onpaste="return false;" :class="{ 'word-highlight-applied': word.shouldHighlight }"
     15                    class="editor-word" v-model="word.word" type="text" :class="{ 'word-highlight-applied': word.shouldHighlight }"
    1616                    @beforeinput="onEditorBeforeInput($event, index)" @focusout="onEditorFocusOut(index)" @focus="onEditorFocus(index)" />
    1717                <span>&nbsp;</span>
     
    299299                }
    300300                else if (event.data.includes(" ")) {
    301                     // TODO: Split input
     301                    let wordsToAdd = event.data.split(" ");
     302                    wordsToAdd = wordsToAdd.filter(w => w.trim().length > 0).map(w => w.trim());
     303                    const sharedTime = (word.endTime - word.startTime) / wordsToAdd.length;
     304
     305                    if (wordsToAdd.length === 0) {
     306                        return;
     307                    }
     308
     309                    word.endTime = word.startTime + sharedTime;
     310                    let newStartTime = word.endTime;
     311
     312                    for (let i = 0; i < wordsToAdd.length; i++) {
     313                        const newWord = new Word(wordsToAdd[i], newStartTime, newStartTime + sharedTime);
     314                        newStartTime += sharedTime;
     315
     316                        this.words.splice(index + i + 1, 0, newWord);
     317                    }
     318
     319                    event.preventDefault();
    302320                }
    303321            }
Note: See TracChangeset for help on using the changeset viewer.