Skip to content

Commit

Permalink
Merge pull request #1626 from RodriSanchez1/feature/repeatLastSentenc…
Browse files Browse the repository at this point in the history
…eWithRedo

Feature - Repeat last spoken sentence with redo
  • Loading branch information
martinbedouret authored Dec 8, 2023
2 parents 4786e14 + 53f2d2e commit e431d12
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/components/Board/Output/Output.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ export class OutputContainer extends Component {
translatedOutput: []
};

componentDidMount() {
document.addEventListener('keydown', this.handleRepeatLastSpokenSentence);
}
componentWillUnmount() {
document.removeEventListener(
'keydown',
this.handleRepeatLastSpokenSentence
);
}

outputReducer(accumulator, currentValue) {
const actionValue =
currentValue.action &&
Expand Down Expand Up @@ -219,6 +229,22 @@ export class OutputContainer extends Component {
this.spliceOutput(index);
};

handleRepeatLastSpokenSentence = event => {
const Z_KEY_CODE = 90;
const Y_KEY_CODE = 89;
if (
(event.ctrlKey && event.shiftKey && event.keyCode === Z_KEY_CODE) ||
(event.ctrlKey && event.keyCode === Y_KEY_CODE)
) {
const { output } = this.props;
const lastSpokenSymbol = output.findLast(
(element, index) => element.label && index !== output.length - 1
);
const text = lastSpokenSymbol ? lastSpokenSymbol.label : '';
this.speakOutput(text);
}
};

handleOutputClick = event => {
const targetEl = event.target;
const targetElLow = targetEl.tagName.toLowerCase();
Expand Down
4 changes: 4 additions & 0 deletions src/components/Board/Symbol/Symbol.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
padding: 0.2em 0.9em 0.2em 0.9em;
}

.liveInput .MuiInputBase-input::-webkit-scrollbar {
display: none;
}

.Symbol textarea {
align-self: flex-start;
font-weight: 700;
Expand Down

0 comments on commit e431d12

Please sign in to comment.