X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/573b9004c7bc2a6a2b29335155b4ff55d142c6b6..341a4c1fd9b83f0289856986200fa5dd602047c9:/src/redakcja/static/js/wiki/wikiapi.js?ds=sidebyside

diff --git a/src/redakcja/static/js/wiki/wikiapi.js b/src/redakcja/static/js/wiki/wikiapi.js
index 53b2a9da..1bf6ebb1 100644
--- a/src/redakcja/static/js/wiki/wikiapi.js
+++ b/src/redakcja/static/js/wiki/wikiapi.js
@@ -150,6 +150,7 @@
 
 		    if (self.text === null || self.revision !== data.revision) {
 		        self.text = data.text;
+                        $.wiki.undo.push(data.text);
 		        self.revision = data.revision;
 		        self.gallery = data.gallery;
 		        changed = true;
@@ -288,12 +289,32 @@
         /*
          * Set document's text
          */
-        setText(text) {
+        setText(text, silent=false) {
             if (text == this.text) return;
+            if (!silent) {
+                $.wiki.undo.push(text);
+            }
             this.text = text;
             this.has_local_changes = true;
         }
 
+        undo() {
+            let ctx = $.wiki.exitContext();
+            this.setText(
+                $.wiki.undo.undo(),
+                true
+            );
+            $.wiki.enterContext(ctx);
+        }
+        redo() {
+            let ctx = $.wiki.exitContext();
+            this.setText(
+                $.wiki.undo.redo(),
+                true
+            );
+            $.wiki.enterContext(ctx);
+        }
+
         /*
          * Save text back to the server
          */