FIX: Revert length issue (#556)
This commit is contained in:
parent
830cc26075
commit
fc6b937df7
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue