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() {
if (this.capabilities.isFirefox) {
// execCommand("undo") is no not supported in Firefox so we insert old text at range
this._insertAt(
this.lastSelectionRange.x,
this.lastSelectionRange.y,
this.initialValue
);
// we also need to calculate the length diffrence between the old and new text
const lengthDifference =
this.selectedText.length - this.initialValue.length;
const end = this.lastSelectionRange.y - lengthDifference;
this._insertAt(this.lastSelectionRange.x, end, this.initialValue);
} else {
document.execCommand("undo", false, null);
}