Question

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

Was it helpful?

Solution

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.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top