Fix undo on text editor.

This commit is contained in:
Paulo Gustavo Veiga 2023-02-03 04:00:12 -08:00
parent 36f435099d
commit 44a6c19912
2 changed files with 9 additions and 7 deletions

View File

@ -36,24 +36,24 @@ describe('Node manager', () => {
it('undo changes', () => {
cy.get('body').type('{enter}').type('Mind Mapping rocks!!').type('{enter}');
cy.focusTopicByText('Mind Mapping rocks!!');
cy.triggerUndo();
cy.focusTopicById(36);
cy.matchImageSnapshot('undoChange');
});
it('redo changes', () => {
cy.get('body').type('{enter}').type('Mind Mapping rocks!!').type('{enter}');
cy.triggerUndo();
cy.focusTopicById(36);
cy.focusTopicByText('Mind Mapping rocks!!');
cy.triggerUndo();
cy.triggerRedo();
cy.focusTopicById(36);
cy.focusTopicByText('Mind Mapping rocks!!');
cy.matchImageSnapshot('redoChange');
});
it('Save changes', () => {
it('save changes', () => {
cy.get('body').type('{ctrl}s');
cy.matchImageSnapshot('saveChagesShortcut');
});

View File

@ -70,8 +70,6 @@ class EditorComponent extends Events {
switch (event.code) {
case 'Escape':
// Revert to previous text ...
this._topic.setText(this._oldText);
this.resize();
this.close(false);
break;
case 'Enter': {
@ -253,6 +251,8 @@ class EditorComponent extends Events {
}
close(update: boolean): void {
this._topic.setText(this._oldText);
if (update) {
this.updateModel();
}
@ -261,6 +261,8 @@ class EditorComponent extends Events {
// Restore topoc share visibility ...
this._topic.getOrBuildTextShape().setVisibility(true);
this.resize();
}
}