From e008de88e6a006a414d55f261101cdc9e9985043 Mon Sep 17 00:00:00 2001 From: cahrens Date: Mon, 7 Apr 2014 21:51:57 -0400 Subject: [PATCH] Fix source editor for the case of no CodeMirror editor. In the HTML component, there is no longer a tabbed CodeMirror Editor. STUD-1516. --- cms/templates/widgets/source-edit.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cms/templates/widgets/source-edit.html b/cms/templates/widgets/source-edit.html index fbd7e3f0bc..6681fcd997 100644 --- a/cms/templates/widgets/source-edit.html +++ b/cms/templates/widgets/source-edit.html @@ -123,7 +123,16 @@ require(["jquery", "jquery.leanModal", "codemirror/stex"], function($) { if (xml.length == 0) { alert('Conversion failed! error:' + data.message); } else { - el.closest('.component').find('.CodeMirror-wrap')[0].CodeMirror.setValue(xml); + // If a parent CodeMirror editor is open (LaTeX problem being edited), set the text + // there. Otherwise, set the text in the active TinyMCE Editor for the case + // of an HTML component being edited. + var parentCodemirrorEditor = el.closest('.component').find('.CodeMirror-wrap'); + if (parentCodemirrorEditor.length > 0) { + parentCodemirrorEditor[0].CodeMirror.setValue(xml); + } + else if (window.tinyMCE !== undefined && window.tinyMCE.activeEditor !== undefined) { + window.tinyMCE.activeEditor.setContent(xml); + } save_hls(el); } },