Skip to content

Commit

Permalink
#96 Focus on text area after undoing/redoing formatting in Comment Fo…
Browse files Browse the repository at this point in the history
…rmatting Helper

Close #96
  • Loading branch information
Rafael committed Nov 2, 2017
1 parent 11720fd commit 27166ae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Extension/esgst.js
Original file line number Diff line number Diff line change
Expand Up @@ -7648,12 +7648,17 @@ function loadFeatures() {
esgst.cfh.undo.classList.add(`esgst-faded`);
},
onClick: () => {
let end, value;
if (esgst.cfh.history.length) {
redoCfhFormatting(esgst.cfh.textArea, esgst.cfh.textArea.value);
esgst.cfh.textArea.value = esgst.cfh.history.pop();
value = esgst.cfh.history.pop();
end = esgst.cfh.textArea.selectionEnd - (esgst.cfh.textArea.value.length - value.length);
esgst.cfh.textArea.value = value;
esgst.cfh.textArea.setSelectionRange(end, end);
if (!esgst.cfh.history.length) {
esgst.cfh.undo.classList.add(`esgst-faded`);
}
esgst.cfh.textArea.focus();
}
}
}, {
Expand All @@ -7664,12 +7669,17 @@ function loadFeatures() {
esgst.cfh.redo.classList.add(`esgst-faded`);
},
onClick: () => {
let end, value;
if (esgst.cfh.backup.length) {
undoCfhFormatting(esgst.cfh.textArea, esgst.cfh.textArea.value);
esgst.cfh.textArea.value = esgst.cfh.backup.pop();
value = esgst.cfh.backup.pop();
end = esgst.cfh.textArea.selectionEnd + (value.length - esgst.cfh.textArea.value.length);
esgst.cfh.textArea.value = value;
esgst.cfh.textArea.setSelectionRange(end, end);
if (!esgst.cfh.backup.length) {
esgst.cfh.redo.classList.add(`esgst-faded`);
}
esgst.cfh.textArea.focus();
}
}
}
Expand Down

0 comments on commit 27166ae

Please sign in to comment.