Browse Source

undo for textEditor.js; bug fixed with close textEditor

Michael 10 years ago
parent
commit
669dcefa60
2 changed files with 21 additions and 6 deletions
  1. 1 1
      src/allplatforms/classes/History.js
  2. 20 5
      src/allplatforms/classes/TextEditor.js

+ 1 - 1
src/allplatforms/classes/History.js

@@ -92,7 +92,7 @@ console.log('start', this.get('stack'))
                     this.get('stack').splice(this.get('stackPointer'));
                 }
 
-                if(this.get('stack').length > 30){
+                if(this.get('stack').length > 40){
                     this.get('stack').splice(0, 1);
                     this.set({ stackPointer: (this.get('stackPointer') - 1) });
                 }

+ 20 - 5
src/allplatforms/classes/TextEditor.js

@@ -51,6 +51,13 @@ SC.loadPackage({ 'TextEditor': {
 
                 SuperGlue.get('selection').do('clearAll');
 
+                (function(elementNode){
+                    var textContent = elementNode.innerHTML;
+                    SuperGlue.get('history').do('actionHasStarted', function(){
+                        elementNode.innerHTML = textContent;
+                    })
+                }).call(this, this.get('originalElementNode'));
+
                 // Prepare textEditor's div
                 /*
                 textEditor.setAttribute('id', 'sg-editing-textEditor');
@@ -123,16 +130,16 @@ SC.loadPackage({ 'TextEditor': {
 
 
                 textEditorContainer.addEventListener('mouseup', function(evt){
+                    
+                    self.do('closeTextEditor');
+
                     evt.stopPropagation();
-                }, false);
+                }, true);
 
                 textEditorContainer.addEventListener('mousedown', function(evt){
-
-                    self.do('closeTextEditor');
-
                     evt.stopPropagation();
 
-                }, false);
+                }, true);
 
 
                 document.body.insertBefore(
@@ -322,6 +329,14 @@ SC.loadPackage({ 'TextEditor': {
                 });
 
 
+                (function(elementNode){
+                    var textContent = elementNode.innerHTML;
+                    SuperGlue.get('history').do('actionHasSucceeded', function(){
+                        elementNode.innerHTML = textContent;
+                    })
+                }).call(this, this.get('originalElementNode'));
+
+
             }
         },