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
6af8ecef
Commit
6af8ecef
authored
Dec 02, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mitx_markdown => edx_markdown
parent
d1f3e3a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
40 deletions
+39
-40
common/static/js/vendor/CodeMirror/edx_markdown.js
+32
-32
lms/djangoapps/course_wiki/editors.py
+1
-1
lms/static/js/wiki/CodeMirror.init.js
+6
-7
No files found.
common/static/js/vendor/CodeMirror/
mit
x_markdown.js
→
common/static/js/vendor/CodeMirror/
ed
x_markdown.js
View file @
6af8ecef
...
...
@@ -9,7 +9,7 @@ var schematic_editor_width = 500;
$
(
function
(){
$
(
document
).
ready
(
function
()
{
//$("a[rel*=leanModal]").leanModal(); //TODO: Make this work with the new modal library. Try and integrate this with the "slices"
$
(
"body"
).
append
(
'
\
<div id="circuit_editor_modal" class="modal hide fade">
\
<div class="modal-body">
\
...
...
@@ -21,39 +21,39 @@ $(function(){
</button>
\
</div>
\
</div>'
);
//This is the editor that pops up as a modal
var
editorCircuit
=
$
(
"#schematic_editor"
).
get
(
0
);
//This is the circuit that they last clicked. The one being edited.
var
editingCircuit
=
null
;
//Notice we use live, because new circuits can be inserted
//Notice we use live, because new circuits can be inserted
$
(
".schematic_open"
).
live
(
"click"
,
function
()
{
//Find the new editingCircuit. Transfer its contents to the editorCircuit
editingCircuit
=
$
(
this
).
children
(
"input.schematic"
).
get
(
0
);
editingCircuit
.
schematic
.
update_value
();
var
circuit_so_far
=
$
(
editingCircuit
).
val
();
var
n
=
editorCircuit
.
schematic
.
components
.
length
;
for
(
var
i
=
0
;
i
<
n
;
i
++
)
editorCircuit
.
schematic
.
components
[
n
-
1
-
i
].
remove
();
editorCircuit
.
schematic
.
load_schematic
(
circuit_so_far
,
""
);
editorCircuit
.
schematic
.
zoomall
();
});
$
(
"#circuit_save_btn"
).
click
(
function
()
{
//Take the circuit from the editor and put it back into editingCircuit
//Take the circuit from the editor and put it back into editingCircuit
editorCircuit
.
schematic
.
update_value
();
var
saving_circuit
=
$
(
editorCircuit
).
val
();
var
n
=
editingCircuit
.
schematic
.
components
.
length
;
for
(
var
i
=
0
;
i
<
n
;
i
++
)
editingCircuit
.
schematic
.
components
[
n
-
1
-
i
].
remove
();
editingCircuit
.
schematic
.
load_schematic
(
saving_circuit
,
""
);
editingCircuit
.
schematic
.
zoomall
();
if
(
editingCircuit
.
codeMirrorLine
)
{
editingCircuit
.
codeMirrorLine
.
replace
(
0
,
null
,
"circuit-schematic:"
+
saving_circuit
);
}
...
...
@@ -62,7 +62,7 @@ $(function(){
});
CodeMirror
.
defineMode
(
"
mit
x_markdown"
,
function
(
cmCfg
,
modeCfg
)
{
CodeMirror
.
defineMode
(
"
ed
x_markdown"
,
function
(
cmCfg
,
modeCfg
)
{
var
htmlFound
=
CodeMirror
.
mimeModes
.
hasOwnProperty
(
"text/html"
);
var
htmlMode
=
CodeMirror
.
getMode
(
cmCfg
,
htmlFound
?
"text/html"
:
"text/plain"
);
...
...
@@ -109,7 +109,7 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
}
return
null
;
}
function
escapeHtml
(
unsafe
)
{
return
unsafe
.
replace
(
/&/g
,
"&"
)
...
...
@@ -118,16 +118,16 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
.
replace
(
/"/g
,
"""
)
.
replace
(
/'/g
,
"'"
);
}
var
circuit_formatter
=
{
creator
:
function
(
text
)
{
var
circuit_value
=
text
.
match
(
circuitRE
)[
1
]
circuit_value
=
escapeHtml
(
circuit_value
);
var
html
=
"<div style='display:block;line-height:0;' class='schematic_container'><a href='#circuit_editor_modal' data-toggle='modal' class='schematic_open' style='display:inline-block;'>"
+
var
html
=
"<div style='display:block;line-height:0;' class='schematic_container'><a href='#circuit_editor_modal' data-toggle='modal' class='schematic_open' style='display:inline-block;'>"
+
"<input type='hidden' parts='' value='"
+
circuit_value
+
"' width='"
+
schematic_width
+
"' height='"
+
schematic_height
+
"' analyses='' class='schematic ctrls'/></a></div>"
;
return
html
;
},
size
:
function
(
text
)
{
...
...
@@ -144,7 +144,7 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
schmInput
.
schematic
.
redraw_background
();
}
}
catch
(
err
)
{
console
.
log
(
"Error in
mit
x_markdown callback: "
+
err
);
console
.
log
(
"Error in
ed
x_markdown callback: "
+
err
);
}
}
...
...
@@ -174,7 +174,7 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
state
.
indentation
+=
match
[
0
].
length
;
return
list
;
}
return
switchInline
(
stream
,
state
,
state
.
inline
);
}
...
...
@@ -196,10 +196,10 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
// Inline
function
getType
(
state
)
{
var
styles
=
[];
if
(
state
.
strong
)
{
styles
.
push
(
state
.
em
?
emstrong
:
strong
);
}
else
if
(
state
.
em
)
{
styles
.
push
(
em
);
}
if
(
state
.
header
)
{
styles
.
push
(
header
);
}
if
(
state
.
quote
)
{
styles
.
push
(
quote
);
}
...
...
@@ -210,16 +210,16 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
if
(
stream
.
match
(
textRE
,
true
))
{
return
getType
(
state
);
}
return
undefined
;
return
undefined
;
}
function
inlineNormal
(
stream
,
state
)
{
var
style
=
state
.
text
(
stream
,
state
)
if
(
typeof
style
!==
'undefined'
)
return
style
;
var
ch
=
stream
.
next
();
if
(
ch
===
'
\
\'
) {
stream.next();
return getType(state);
...
...
@@ -241,12 +241,12 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
stream
.
backUp
(
1
);
return
switchBlock
(
stream
,
state
,
htmlBlock
);
}
if
(
ch
===
'<'
&&
stream
.
match
(
/^
\/\w
*
?
>/
))
{
state
.
md_inside
=
false
;
return
"tag"
;
}
var
t
=
getType
(
state
);
if
(
ch
===
'*'
||
ch
===
'_'
)
{
if
(
stream
.
eat
(
ch
))
{
...
...
@@ -254,7 +254,7 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
}
return
(
state
.
em
=
!
state
.
em
)
?
getType
(
state
)
:
t
;
}
return
getType
(
state
);
}
...
...
@@ -316,11 +316,11 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
startState: function() {
return {
f: blockNormal,
block: blockNormal,
htmlState: CodeMirror.startState(htmlMode),
indentation: 0,
inline: inlineNormal,
text: handleText,
em: false,
...
...
@@ -333,11 +333,11 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
copyState: function(s) {
return {
f: s.f,
block: s.block,
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
indentation: s.indentation,
inline: s.inline,
text: s.text,
em: s.em,
...
...
lms/djangoapps/course_wiki/editors.py
View file @
6af8ecef
...
...
@@ -57,7 +57,7 @@ class CodeMirror(BaseEditor):
}
js
=
(
"js/vendor/CodeMirror/codemirror.js"
,
"js/vendor/CodeMirror/xml.js"
,
"js/vendor/CodeMirror/
mit
x_markdown.js"
,
"js/vendor/CodeMirror/
ed
x_markdown.js"
,
"js/wiki/accessible.js"
,
"js/wiki/CodeMirror.init.js"
,
)
lms/static/js/wiki/CodeMirror.init.js
View file @
6af8ecef
$
(
document
).
ready
(
function
()
{
var
editor
=
CodeMirror
.
fromTextArea
(
document
.
getElementById
(
"id_content"
),
{
mode
:
'
mit
x_markdown'
,
mode
:
'
ed
x_markdown'
,
matchBrackets
:
true
,
theme
:
"default"
,
lineWrapping
:
true
,
keyMap
:
"accessible"
});
//Store the inital contents so we can compare for unsaved changes
var
initial_contents
=
editor
.
getValue
();
window
.
onbeforeunload
=
function
askConfirm
()
{
//Warn the user before they navigate away
if
(
editor
.
getValue
()
!=
initial_contents
)
{
return
"You have made changes to the article that have not been saved yet."
;
}
};
$
(
".btn-primary"
).
click
(
function
()
{
initial_contents
=
editor
.
getValue
();
});
});
\ No newline at end of file
});
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