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
9ec3a2da
Commit
9ec3a2da
authored
Mar 17, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove CodeMirror tabbed editor.
parent
9ac94fc4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
71 deletions
+15
-71
cms/templates/widgets/html-edit.html
+0
-6
common/lib/xmodule/xmodule/js/src/html/edit.coffee
+15
-65
No files found.
cms/templates/widgets/html-edit.html
View file @
9ec3a2da
...
@@ -2,14 +2,8 @@
...
@@ -2,14 +2,8 @@
<div
class=
"wrapper-comp-editor"
id=
"editor-tab"
data-base-asset-url=
"${base_asset_url}"
>
<div
class=
"wrapper-comp-editor"
id=
"editor-tab"
data-base-asset-url=
"${base_asset_url}"
>
<section
class=
"html-editor editor"
>
<section
class=
"html-editor editor"
>
<ul
class=
"editor-tabs"
>
<li><a
href=
"#"
class=
"visual-tab tab current"
data-tab=
"visual"
>
${_("Visual")}
</a></li>
<li><a
href=
"#"
class=
"html-tab tab"
data-tab=
"advanced"
>
${_("HTML")}
</a></li>
</ul>
<div
class=
"row"
>
<div
class=
"row"
>
<textarea
class=
"tiny-mce"
>
${data | h}
</textarea>
<textarea
class=
"tiny-mce"
>
${data | h}
</textarea>
<textarea
name=
""
class=
"edit-box"
>
${data | h}
</textarea>
</div>
</div>
</section>
</section>
</div>
</div>
...
...
common/lib/xmodule/xmodule/js/src/html/edit.coffee
View file @
9ec3a2da
...
@@ -7,15 +7,6 @@ class @HTMLEditingDescriptor
...
@@ -7,15 +7,6 @@ class @HTMLEditingDescriptor
if
@
base_asset_url
==
undefined
if
@
base_asset_url
==
undefined
@
base_asset_url
=
null
@
base_asset_url
=
null
@
advanced_editor
=
CodeMirror
.
fromTextArea
(
$
(
".edit-box"
,
@
element
)[
0
],
{
mode
:
"text/html"
lineNumbers
:
true
lineWrapping
:
true
})
@
$advancedEditorWrapper
=
$
(
@
advanced_editor
.
getWrapperElement
())
@
$advancedEditorWrapper
.
addClass
(
HTMLEditingDescriptor
.
isInactiveClass
)
# This is a workaround for the fact that tinyMCE's baseURL property is not getting correctly set on AWS
# This is a workaround for the fact that tinyMCE's baseURL property is not getting correctly set on AWS
# instances (like sandbox). It is not necessary to explicitly set baseURL when running locally.
# instances (like sandbox). It is not necessary to explicitly set baseURL when running locally.
tinyMCE
.
baseURL
=
"
#{
baseUrl
}
/js/vendor/tiny_mce"
tinyMCE
.
baseURL
=
"
#{
baseUrl
}
/js/vendor/tiny_mce"
...
@@ -23,7 +14,7 @@ class @HTMLEditingDescriptor
...
@@ -23,7 +14,7 @@ class @HTMLEditingDescriptor
# tinyMCE incorrectly decides that the suffix should be "", which means it fails to load files.
# tinyMCE incorrectly decides that the suffix should be "", which means it fails to load files.
tinyMCE
.
suffix
=
".min"
tinyMCE
.
suffix
=
".min"
@
tiny_mce_textarea
=
$
(
".tiny-mce"
,
@
element
).
tinymce
({
@
tiny_mce_textarea
=
$
(
".tiny-mce"
,
@
element
).
tinymce
({
script_url
:
"
#{
baseUrl
}
/js/vendor/tiny_mce/tiny
_
mce.min.js"
,
script_url
:
"
#{
baseUrl
}
/js/vendor/tiny_mce/tinymce.min.js"
,
theme
:
"modern"
,
theme
:
"modern"
,
skin
:
'studio-tmce4'
,
skin
:
'studio-tmce4'
,
schema
:
"html5"
,
schema
:
"html5"
,
...
@@ -48,8 +39,7 @@ class @HTMLEditingDescriptor
...
@@ -48,8 +39,7 @@ class @HTMLEditingDescriptor
},
},
# We may want to add "styleselect" when we collect all styles used throughout the LMS
# We may want to add "styleselect" when we collect all styles used throughout the LMS
# Can have a single toolbar by just specifying "toolbar". Splitting for now so all are visible.
# Can have a single toolbar by just specifying "toolbar". Splitting for now so all are visible.
toolbar1
:
"formatselect | fontselect | bold italic underline forecolor | bullist numlist outdent indent"
,
toolbar
:
"formatselect | fontselect | bold italic underline forecolor | bullist numlist outdent indent | link unlink image | blockquote wrapAsCode | code"
,
toolbar2
:
"link unlink image | blockquote wrapAsCode code"
,
# TODO: i18n
# TODO: i18n
block_formats
:
"Paragraph=p;Preformatted=pre;Heading 1=h1;Heading 2=h2;Heading 3=h3"
,
block_formats
:
"Paragraph=p;Preformatted=pre;Heading 1=h1;Heading 2=h2;Heading 3=h3"
,
width
:
'100%'
,
width
:
'100%'
,
...
@@ -62,14 +52,6 @@ class @HTMLEditingDescriptor
...
@@ -62,14 +52,6 @@ class @HTMLEditingDescriptor
init_instance_callback
:
@
initInstanceCallback
init_instance_callback
:
@
initInstanceCallback
})
})
@
showingVisualEditor
=
true
# Doing these find operations within onSwitchEditor leads to sporadic failures on Chrome (version 20 and older).
$element
=
$
(
element
)
@
$htmlTab
=
$element
.
find
(
'.html-tab'
)
@
$visualTab
=
$element
.
find
(
'.visual-tab'
)
@
element
.
on
(
'click'
,
'.editor-tabs .tab'
,
@
onSwitchEditor
)
setupTinyMCE
:
(
ed
)
=>
setupTinyMCE
:
(
ed
)
=>
ed
.
addButton
(
'wrapAsCode'
,
{
ed
.
addButton
(
'wrapAsCode'
,
{
title
:
'Code'
,
title
:
'Code'
,
...
@@ -84,6 +66,8 @@ class @HTMLEditingDescriptor
...
@@ -84,6 +66,8 @@ class @HTMLEditingDescriptor
@
visualEditor
=
ed
@
visualEditor
=
ed
ed
.
on
(
'change'
,
@
changeHandler
)
ed
.
on
(
'change'
,
@
changeHandler
)
ed
.
on
(
'ShowCodeMirror'
,
@
showCodeEditor
)
ed
.
on
(
'SaveCodeMirror'
,
@
saveCodeEditor
)
# Intended to run after the "image" plugin is used so that static urls are set
# Intended to run after the "image" plugin is used so that static urls are set
# correctly in the Visual editor immediately after command use.
# correctly in the Visual editor immediately after command use.
...
@@ -91,59 +75,27 @@ class @HTMLEditingDescriptor
...
@@ -91,59 +75,27 @@ class @HTMLEditingDescriptor
# The fact that we have to listen to all change events and act on an event actually fired
# The fact that we have to listen to all change events and act on an event actually fired
# from undo (which is where the "level" comes from) is extremely ugly. However, plugins
# from undo (which is where the "level" comes from) is extremely ugly. However, plugins
# don't fire any events in TinyMCE version 4 that I can hook into (in particular, not ExecCommand).
# don't fire any events in TinyMCE version 4 that I can hook into (in particular, not ExecCommand).
debugger
if
e
.
level
and
e
.
level
.
content
and
e
.
level
.
content
.
match
(
/<img src="\/static\//
)
if
e
.
level
and
e
.
level
.
content
and
e
.
level
.
content
.
match
(
/<img src="\/static\//
)
content
=
rewriteStaticLinks
(
e
.
target
.
getContent
(),
'/static/'
,
@
base_asset_url
)
content
=
rewriteStaticLinks
(
e
.
target
.
getContent
(),
'/static/'
,
@
base_asset_url
)
e
.
target
.
setContent
(
content
)
e
.
target
.
setContent
(
content
)
onSwitchEditor
:
(
e
)
=>
showCodeEditor
:
(
codeEditor
)
=>
e
.
preventDefault
();
# Called with the CodeMirror Editor is displayed to convert links to show satic prefix.
content
=
rewriteStaticLinks
(
codeEditor
.
getValue
(),
@
base_asset_url
,
'/static/'
)
$currentTarget
=
$
(
e
.
currentTarget
)
codeEditor
.
setValue
(
content
)
if
not
$currentTarget
.
hasClass
(
'current'
)
$currentTarget
.
addClass
(
'current'
)
# Initializing $mceToolbar if undefined.
saveCodeEditor
:
(
codeEditor
)
=>
if
not
@
$mceToolbar
?
# Called when the CodeMirror Editor is saved to convert links back to the full form.
@
$mceToolbar
=
$
(
@
element
).
find
(
'table.mceToolbar'
)
content
=
rewriteStaticLinks
(
codeEditor
.
getValue
(),
'/static/'
,
@
base_asset_url
)
@
$mceToolbar
.
toggleClass
(
HTMLEditingDescriptor
.
isInactiveClass
)
codeEditor
.
setValue
(
content
)
@
$advancedEditorWrapper
.
toggleClass
(
HTMLEditingDescriptor
.
isInactiveClass
)
visualEditor
=
@
getVisualEditor
()
if
$currentTarget
.
data
(
'tab'
)
is
'visual'
@
$htmlTab
.
removeClass
(
'current'
)
@
showVisualEditor
(
visualEditor
)
else
@
$visualTab
.
removeClass
(
'current'
)
@
showAdvancedEditor
(
visualEditor
)
# Show the Advanced (codemirror) Editor. Pulled out as a helper method for unit testing.
showAdvancedEditor
:
(
visualEditor
)
->
if
visualEditor
.
isDirty
()
content
=
rewriteStaticLinks
(
visualEditor
.
getContent
({
no_events
:
1
}),
@
base_asset_url
,
'/static/'
)
@
advanced_editor
.
setValue
(
content
)
@
advanced_editor
.
setCursor
(
0
)
@
advanced_editor
.
refresh
()
@
advanced_editor
.
focus
()
@
showingVisualEditor
=
false
# Show the Visual (tinyMCE) Editor. Pulled out as a helper method for unit testing.
showVisualEditor
:
(
visualEditor
)
->
# In order for isDirty() to return true ONLY if edits have been made after setting the text,
# both the startContent must be sync'ed up and the dirty flag set to false.
content
=
rewriteStaticLinks
(
@
advanced_editor
.
getValue
(),
'/static/'
,
@
base_asset_url
)
visualEditor
.
setContent
(
content
)
visualEditor
.
startContent
=
visualEditor
.
getContent
({
format
:
'raw'
})
@
focusVisualEditor
(
visualEditor
)
@
showingVisualEditor
=
true
initInstanceCallback
:
(
visualEditor
)
=>
initInstanceCallback
:
(
visualEditor
)
=>
visualEditor
.
setContent
(
rewriteStaticLinks
(
@
advanced_editor
.
getValue
(
),
'/static/'
,
@
base_asset_url
))
visualEditor
.
setContent
(
rewriteStaticLinks
(
visualEditor
.
getContent
({
no_events
:
1
}
),
'/static/'
,
@
base_asset_url
))
@
focusVisualEditor
(
visualEditor
)
@
focusVisualEditor
(
visualEditor
)
focusVisualEditor
:
(
visualEditor
)
=>
focusVisualEditor
:
(
visualEditor
)
=>
visualEditor
.
focus
()
visualEditor
.
focus
()
if
not
@
$mceToolbar
?
@
$mceToolbar
=
$
(
@
element
).
find
(
'table.mceToolbar'
)
getVisualEditor
:
()
->
getVisualEditor
:
()
->
###
###
...
@@ -155,9 +107,7 @@ class @HTMLEditingDescriptor
...
@@ -155,9 +107,7 @@ class @HTMLEditingDescriptor
return
@
visualEditor
return
@
visualEditor
save
:
->
save
:
->
@
element
.
off
(
'click'
,
'.editor-tabs .tab'
,
@
onSwitchEditor
)
text
=
@
advanced_editor
.
getValue
()
visualEditor
=
@
getVisualEditor
()
visualEditor
=
@
getVisualEditor
()
if
@
showingVisualEditor
and
visualEditor
.
isDirty
()
if
visualEditor
.
isDirty
()
text
=
rewriteStaticLinks
(
visualEditor
.
getContent
({
no_events
:
1
}),
@
base_asset_url
,
'/static/'
)
text
=
rewriteStaticLinks
(
visualEditor
.
getContent
({
no_events
:
1
}),
@
base_asset_url
,
'/static/'
)
data
:
text
data
:
text
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