Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve the diff / original values of a CodeMirror merge.js

I am trying to retrieve both the original (may be modified as I am allowing it) as well as the data I am comparing to (which might also be modified).

The documentation doesn't explain how to do it, there is references to origLeft and origRight, but they seem to not work properly - one is NULL (left) and the other doesn't appear to contain the modified data.

Here is the code I am using:

<div id=editor></div>

<script>
var original = 'Original text';
var compareTo = 'Modified text';

hilight= true;
var target = document.getElementById("editor");

dv = CodeMirror.MergeView(target, {
    value: original ,
    origLeft: null,
    orig: compareTo ,
    lineNumbers: true,
    mode: "text/html",
    highlightDifferences: hilight,
    lineWrapping : true,
  });
</script>

I tried doing dv.getValue(), dv.leftOriginal(), dv.rightOriginal(), etc. no luck

Your help is appreciated

like image 774
Noam Rathaus Avatar asked Nov 19 '13 09:11

Noam Rathaus


1 Answers

I think dv.rightOriginal().getValue() and dv.editor().getValue() (for the edited content) are what you are looking for. (These methods, leftOriginal, rightOriginal, and editor, return CodeMirror instances.)

like image 188
Marijn Avatar answered Nov 03 '22 11:11

Marijn