FIX: Revert length issue (#556)

This commit is contained in:
Keegan George 2024-04-04 10:28:17 -07:00 committed by GitHub
parent 830cc26075
commit fc6b937df7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -338,11 +338,11 @@ export default class AiHelperContextMenu extends Component {
undoAIAction() { undoAIAction() {
if (this.capabilities.isFirefox) { if (this.capabilities.isFirefox) {
// execCommand("undo") is no not supported in Firefox so we insert old text at range // execCommand("undo") is no not supported in Firefox so we insert old text at range
this._insertAt( // we also need to calculate the length diffrence between the old and new text
this.lastSelectionRange.x, const lengthDifference =
this.lastSelectionRange.y, this.selectedText.length - this.initialValue.length;
this.initialValue const end = this.lastSelectionRange.y - lengthDifference;
); this._insertAt(this.lastSelectionRange.x, end, this.initialValue);
} else { } else {
document.execCommand("undo", false, null); document.execCommand("undo", false, null);
} }