X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/28866d0f2520b7515f3c06e9b61bcce4f44d53b1..54612c196135c939a7d17d51b81b1357f6eac9c3:/src/redakcja/static/js/wiki/wikiapi.js diff --git a/src/redakcja/static/js/wiki/wikiapi.js b/src/redakcja/static/js/wiki/wikiapi.js index 426c7f62..1bf6ebb1 100644 --- a/src/redakcja/static/js/wiki/wikiapi.js +++ b/src/redakcja/static/js/wiki/wikiapi.js @@ -121,18 +121,6 @@ this.galleryStart = parseInt($("*[data-key='gallery-start']", meta).text()); this.fullUri = $("*[data-key='full-uri']", meta).text(); - var diff = $("*[data-key='diff']", meta).text(); - if (diff) { - diff = diff.split(','); - if (diff.length == 2 && diff[0] < diff[1]) - this.diff = diff; - else if (diff.length == 1) { - diff = parseInt(diff); - if (diff != NaN) - this.diff = [diff - 1, diff]; - } - } - this.galleryImages = []; this.text = null; this.has_local_changes = false; @@ -162,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; @@ -300,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 */