wlxml: metadata wip - adding/removing/editing, undo, cloning support
[fnpeditor.git] / src / smartxml / core.js
index 10d058f..4d3c2c1 100644 (file)
@@ -99,6 +99,8 @@ var elementNodeTransformations = {
         if(this.sameNode(this.document.root)) {
             this.document._defineDocumentProperties(node._$);
         }
         if(this.sameNode(this.document.root)) {
             this.document._defineDocumentProperties(node._$);
         }
+
+        /* TODO: This invalidates old references to this node. Caching instances on nodes would fix this. */
         this._$.replaceWith(node._$);
         this._setNativeNode(node._$[0]);
         this._$.append(myContents);
         this._$.replaceWith(node._$);
         this._setNativeNode(node._$[0]);
         this._$.append(myContents);
@@ -186,9 +188,15 @@ var elementNodeTransformations = {
 };
 
 var textNodeTransformations = {
 };
 
 var textNodeTransformations = {
-    setText: function(text) {
-        this.nativeNode.data = text;
-        this.triggerTextChangeEvent();
+    setText: {
+        impl: function(t, text) {
+            t.oldText = this.getText();
+            this.nativeNode.data = text;
+            this.triggerTextChangeEvent();
+        },
+        undo: function(t) {
+            this.setText(t.oldText);
+        }
     },
 
     appendText: function(text) {
     },
 
     appendText: function(text) {