Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
b1f4d28e
Commit
b1f4d28e
authored
Mar 19, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for style block being maintained.
parent
d73f65c3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
10 deletions
+57
-10
cms/djangoapps/contentstore/features/common.py
+4
-3
cms/djangoapps/contentstore/features/html-editor.feature
+15
-2
cms/djangoapps/contentstore/features/html-editor.py
+32
-5
common/lib/xmodule/xmodule/js/src/html/edit.coffee
+6
-0
No files found.
cms/djangoapps/contentstore/features/common.py
View file @
b1f4d28e
...
@@ -318,15 +318,16 @@ def i_am_shown_a_notification(step):
...
@@ -318,15 +318,16 @@ def i_am_shown_a_notification(step):
assert
world
.
is_css_present
(
'.wrapper-prompt'
)
assert
world
.
is_css_present
(
'.wrapper-prompt'
)
def
type_in_codemirror
(
index
,
text
):
def
type_in_codemirror
(
index
,
text
,
find_prefix
=
"$"
):
script
=
"""
script
=
"""
var cm =
$('div.CodeMirror:eq({
})').get(0).CodeMirror;
var cm =
{find_prefix}('div.CodeMirror:eq({index
})').get(0).CodeMirror;
cm.getInputField().focus();
cm.getInputField().focus();
cm.setValue(arguments[0]);
cm.setValue(arguments[0]);
cm.getInputField().blur();"""
.
format
(
index
)
cm.getInputField().blur();"""
.
format
(
index
=
index
,
find_prefix
=
find_prefix
)
world
.
browser
.
driver
.
execute_script
(
script
,
str
(
text
))
world
.
browser
.
driver
.
execute_script
(
script
,
str
(
text
))
world
.
wait_for_ajax_complete
()
world
.
wait_for_ajax_complete
()
def
get_codemirror_value
(
index
=
0
):
def
get_codemirror_value
(
index
=
0
):
return
world
.
browser
.
driver
.
execute_script
(
"""
return
world
.
browser
.
driver
.
execute_script
(
"""
return $('div.CodeMirror:eq({})').get(0).CodeMirror.getValue();
return $('div.CodeMirror:eq({})').get(0).CodeMirror.getValue();
...
...
cms/djangoapps/contentstore/features/html-editor.feature
View file @
b1f4d28e
...
@@ -24,4 +24,17 @@ Feature: CMS.HTML Editor
...
@@ -24,4 +24,17 @@ Feature: CMS.HTML Editor
Given
I have created a Blank HTML Page
Given
I have created a Blank HTML Page
When
I edit the page
When
I edit the page
And
I add an image with a static link via the Image Plugin Icon
And
I add an image with a static link via the Image Plugin Icon
Then
the image static link is rewritten to translate the path
Then
the image static link is rewritten to translate the path
\ No newline at end of file
Scenario
:
TinyMCE and CodeMirror preserve style tags
Given
I have created a Blank HTML Page
When
I edit the page
And type "<p class='title'>pages</p><style><!-- .title { color
:
red;
}
--></style>"
in
the
code
editor
and
press
OK
And
I save the page
Then the page has text
:
"""
<p class="title">pages</p>
<style><!--
.title { color: red; }
--></style>
"""
\ No newline at end of file
cms/djangoapps/contentstore/features/html-editor.py
View file @
b1f4d28e
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
# pylint: disable=C0111
# pylint: disable=C0111
from
lettuce
import
world
,
step
from
lettuce
import
world
,
step
from
nose.tools
import
assert_in
# pylint: disable=no-name-in-module
from
nose.tools
import
assert_in
,
assert_equal
# pylint: disable=no-name-in-module
from
common
import
type_in_codemirror
@step
(
'I have created a Blank HTML Page$'
)
@step
(
'I have created a Blank HTML Page$'
)
...
@@ -38,18 +39,44 @@ def i_click_on_edit_icon(step):
...
@@ -38,18 +39,44 @@ def i_click_on_edit_icon(step):
@step
(
'I add an image with a static link via the Image Plugin Icon$'
)
@step
(
'I add an image with a static link via the Image Plugin Icon$'
)
def
i_click_on_image_plugin_icon
(
step
):
def
i_click_on_image_plugin_icon
(
step
):
# Click on image plugin button
use_plugin
(
world
.
css_click
(
'.mce-i-image'
)
'.mce-i-image'
,
lambda
:
world
.
css_fill
(
'.mce-textbox'
,
'/static/image.jpg'
,
0
)
)
@step
(
'type "(.*)" in the code editor and press OK$'
)
def
type_in_codemirror_plugin
(
step
,
text
):
use_plugin
(
'.mce-i-code'
,
lambda
:
type_in_codemirror
(
0
,
text
,
"$('iframe').contents().find"
)
)
def
use_plugin
(
button_class
,
action
):
# Click on plugin button
world
.
css_click
(
button_class
)
# Wait for the editing window to open.
# Wait for the editing window to open.
world
.
wait_for_visible
(
'.mce-window'
)
world
.
wait_for_visible
(
'.mce-window'
)
# Fill in the first field (source).
# Trigger the action
world
.
css_fill
(
'.mce-textbox'
,
'/static/image.jpg'
,
0
)
action
()
# Click OK
# Click OK
world
.
css_click
(
'.mce-primary'
)
world
.
css_click
(
'.mce-primary'
)
@step
(
'I save the page$'
)
def
i_click_on_save
(
step
):
world
.
save_component
(
step
)
@step
(
'the page has text:'
)
def
check_page_text
(
step
):
assert_equal
(
step
.
multiline
,
world
.
css_find
(
'.xmodule_HtmlModule'
)
.
html
.
strip
())
@step
(
'the image static link is rewritten to translate the path$'
)
@step
(
'the image static link is rewritten to translate the path$'
)
def
image_static_link_is_rewritten
(
step
):
def
image_static_link_is_rewritten
(
step
):
# Find the TinyMCE iframe within the main window
# Find the TinyMCE iframe within the main window
...
...
common/lib/xmodule/xmodule/js/src/html/edit.coffee
View file @
b1f4d28e
...
@@ -46,6 +46,12 @@ class @HTMLEditingDescriptor
...
@@ -46,6 +46,12 @@ class @HTMLEditingDescriptor
height
:
'400px'
,
height
:
'400px'
,
menubar
:
false
,
menubar
:
false
,
statusbar
:
false
,
statusbar
:
false
,
# Necessary to avoid stripping of style tags.
valid_children
:
"+body[style]"
,
# Prevent TinyMCE from adding extra <p> </p> in code.
forced_root_block
:
""
,
force_br_newlines
:
true
,
force_p_newlines
:
false
,
setup
:
@
setupTinyMCE
,
setup
:
@
setupTinyMCE
,
# Cannot get access to tinyMCE Editor instance (for focusing) until after it is rendered.
# Cannot get access to tinyMCE Editor instance (for focusing) until after it is rendered.
# The tinyMCE callback passes in the editor as a paramter.
# The tinyMCE callback passes in the editor as a paramter.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment