Change the div being used to create code mirror to a textarea-- just make sure to escape the content! Update tests accordingly.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
</ul>
|
||||
|
||||
<div class="row">
|
||||
<textarea class="tiny-mce">${data}</textarea>
|
||||
<div name="" class="edit-box">${data}</div>
|
||||
<textarea class="tiny-mce">${data | h}</textarea>
|
||||
<textarea name="" class="edit-box">${data | h}</textarea>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
<section class="html-edit">
|
||||
<textarea class="tiny-mce">dummy content</textarea>
|
||||
<div name="" class="edit-box"><problem>
|
||||
<p></p>
|
||||
<multiplechoiceresponse>
|
||||
<pre><problem>
|
||||
<p></p></pre>
|
||||
<div><foo>bar</foo></div></div>
|
||||
<textarea class="tiny-mce">dummy</textarea>
|
||||
<!--
|
||||
The text passed in is the escaped version of
|
||||
<problem>
|
||||
<p></p>
|
||||
<multiplechoiceresponse>
|
||||
<pre><problem>
|
||||
<p></p></pre>
|
||||
<div><foo>bar</foo></div>
|
||||
-->
|
||||
<textarea name="" class="edit-box">&lt;problem>
|
||||
&lt;p>&lt;/p>
|
||||
&lt;multiplechoiceresponse>
|
||||
<pre>&lt;problem>
|
||||
&lt;p>&lt;/p></pre>
|
||||
<div><foo>bar</foo></div></textarea>
|
||||
</section>
|
||||
@@ -5,6 +5,6 @@
|
||||
</ul>
|
||||
<div class="row">
|
||||
<textarea class="tiny-mce">dummy text</textarea>
|
||||
<div name="" class="edit-box">Advanced Editor Text</div>
|
||||
<textarea name="" class="edit-box">Advanced Editor Text</textarea>
|
||||
</div>
|
||||
</section>
|
||||
@@ -13,12 +13,12 @@ describe 'HTMLEditingDescriptor', ->
|
||||
spyOn(@descriptor, 'getVisualEditor').andCallFake () ->
|
||||
visualEditorStub
|
||||
data = @descriptor.save().data
|
||||
expect(data).toEqual("""<problem>
|
||||
<p></p>
|
||||
<multiplechoiceresponse>
|
||||
<pre><problem>
|
||||
<p></p></pre>
|
||||
<div><foo>bar</foo></div>""")
|
||||
expect(data).toEqual("""<problem>
|
||||
<p></p>
|
||||
<multiplechoiceresponse>
|
||||
<pre><problem>
|
||||
<p></p></pre>
|
||||
<div><foo>bar</foo></div>""")
|
||||
describe 'Saves HTML', ->
|
||||
beforeEach ->
|
||||
loadFixtures 'html-edit.html'
|
||||
@@ -52,7 +52,7 @@ describe 'HTMLEditingDescriptor', ->
|
||||
beforeEach ->
|
||||
loadFixtures 'html-edit.html'
|
||||
@descriptor = new HTMLEditingDescriptor($('.html-edit'))
|
||||
it 'Populates from Advanced Editor if Advanced Editor is dirty', ->
|
||||
it 'Populates from Visual Editor if Advanced Visual is dirty', ->
|
||||
expect(@descriptor.showingVisualEditor).toEqual(true)
|
||||
visualEditorStub =
|
||||
isDirty: () -> true
|
||||
@@ -60,7 +60,7 @@ describe 'HTMLEditingDescriptor', ->
|
||||
@descriptor.showAdvancedEditor(visualEditorStub)
|
||||
expect(@descriptor.showingVisualEditor).toEqual(false)
|
||||
expect(@descriptor.advanced_editor.getValue()).toEqual('from visual editor')
|
||||
it 'Does not populate from Advanced Editor if Advanced Editor is not dirty', ->
|
||||
it 'Does not populate from Visual Editor if Visual Editor is not dirty', ->
|
||||
expect(@descriptor.showingVisualEditor).toEqual(true)
|
||||
visualEditorStub =
|
||||
isDirty: () -> false
|
||||
|
||||
@@ -3,13 +3,12 @@ class @HTMLEditingDescriptor
|
||||
|
||||
constructor: (element) ->
|
||||
@element = element;
|
||||
text = $(".edit-box", @element)[0];
|
||||
replace_func = (elt) -> text.parentNode.replaceChild(elt, text)
|
||||
@advanced_editor = CodeMirror(replace_func, {
|
||||
value: text.innerHTML
|
||||
|
||||
@advanced_editor = CodeMirror.fromTextArea($(".edit-box", @element)[0], {
|
||||
mode: "text/html"
|
||||
lineNumbers: true
|
||||
lineWrapping: true})
|
||||
lineWrapping: true
|
||||
})
|
||||
|
||||
$(@advanced_editor.getWrapperElement()).addClass(HTMLEditingDescriptor.isInactiveClass)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user