Add audience and thema data to catalogue. Also: nicer cover view.
[redakcja.git] / src / redakcja / static / js / wiki / wikiapi.js
index 53b2a9d..1bf6ebb 100644 (file)
 
                    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;
         /*
          * 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
          */