I am unable to figure out how to set the lineSeperator to \r\n for the MergeView docs
any examples or suggestions?
I am unable to figure out how to set the lineSeperator to \r\n for the MergeView docs
any examples or suggestions?
You should be able to just pass the lineSeparator
option to to the MergeView
constructor.
Thanks -
I tried that and it accepted the option but it caused more harm than good.
I guess I should explain what is happening at this point.
We have an xml editor that is CodeMirror in MergeView mode.
On IE it works fine but on Chrome it is stripping line endings when I save the edited file. I was assuming this was due to the default setting as described in documentation.
After trying your suggestion and adding
lineSeperator: “\r\n” , to the options list during construction - the IE version won’t even finish init and the chrome version now shows one continuous line instead of multi line view.
Here is my code:
<script type="text/javascript">
var value, orig2, dv, panes = 2, highlight = true, collapse = false;
function initUI() {
if (value == null) return;
var target = document.getElementById("view");
target.innerHTML = "";
CodeMirror.orig
dv = CodeMirror.MergeView(target,
{value: value,
origLeft: null,
origRight: orig2,
orig: value,
lineNumbers: true,
mode: "text/xml",
highlightDifferences: highlight,
connect: 'align',
collapseIdentical: collapse
});
if (dv.leftOriginal())
dv.leftOriginal().setSize(null, 500);
dv.editor().setSize(null, 500);
if (dv.rightOriginal())
dv.rightOriginal().setSize(null, 500);
dv.wrap.style.height = "500px";
}
function toggleDifferences() {
dv.setShowDifferences(highlight = !highlight);
}
window.onload = function () {
value = document.getElementById("ContentPlaceHolder1_FileText").innerText;
orig2 = document.getElementById("ContentPlaceHolder1_OriginalFileText").innerText;
initUI();
let d = document.createElement("div"); d.style.cssText = "width: 50px; margin: 7px; height: 14px"; dv.editor().addLineWidget(57, d)
var lineError = document.getElementById("ContentPlaceHolder1_LineError").value;
var charError = document.getElementById("ContentPlaceHolder1_CharError").value;
if (lineError) {
dv.editor().scrollIntoView({ line: lineError, char: charError });
}
};
function saveButtonClick() {
document.getElementById("ContentPlaceHolder1_FileText").innerText = dv.edit.doc.getValue();
}
</script>
No, I don’t think that is related to the editor line separator setting. The library will give you a string with \n
line separators by default. If those are getting stripped out that’s happening in some other part of your pipeline.