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
a14574ec
Commit
a14574ec
authored
Mar 14, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 1.3 of CodeMirror plugin.
parent
1ece49c3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
330 additions
and
0 deletions
+330
-0
common/static/js/vendor/tiny_mce/plugins/codemirror/LICENSE.txt
+0
-0
common/static/js/vendor/tiny_mce/plugins/codemirror/README.txt
+26
-0
common/static/js/vendor/tiny_mce/plugins/codemirror/langs/en.js
+8
-0
common/static/js/vendor/tiny_mce/plugins/codemirror/langs/nl.js
+8
-0
common/static/js/vendor/tiny_mce/plugins/codemirror/plugin.js
+54
-0
common/static/js/vendor/tiny_mce/plugins/codemirror/plugin.min.js
+3
-0
common/static/js/vendor/tiny_mce/plugins/codemirror/source.html
+231
-0
No files found.
common/static/js/vendor/tiny_mce/plugins/codemirror/LICENSE.txt
0 → 100644
View file @
a14574ec
This diff is collapsed.
Click to expand it.
common/static/js/vendor/tiny_mce/plugins/codemirror/README.txt
0 → 100644
View file @
a14574ec
+=========================+
| CodeMirror for TinyMCE4 |
+=========================+
(c) 2013-2014 Arjan Haverkamp (arjan@avoid.org)
Download: http://www.avoid.org/codemirror-for-tinymce4/
Version: 1.3 (2014-03-04)
License: see LICENSE.txt
Changelog
=========
Version 1.3 - 2014-03-04
- Bugfix: If any text was highlighted in CodeMirror and the code dialog is closed and saved,
the selected text was removed from TinyMCE.
- Macintosh users now see Macintosh keyboard shortcuts.
Version 1.2 - 2013-09-04
- Dirty state of CodeMirror now passed on to TinyMCE.
- When submitting CodeMirror code to TinyMCE, cursor position is retained.
Note: this only works when the cursor is *not* inside a <tag>.
Version 1.1 - 2013-07-19
- New options jsFiles and cssFiles.
Version 1.0 - 2013-06-29
- Initial release.
common/static/js/vendor/tiny_mce/plugins/codemirror/langs/en.js
0 → 100644
View file @
a14574ec
tinymce
.
addI18n
(
'en'
,{
'HTML source code'
:
'HTML source code'
,
'Start search'
:
'Start search'
,
'Find next'
:
'Find next'
,
'Find previous'
:
'Find previous'
,
'Replace'
:
'Replace'
,
'Replace all'
:
'Replace all'
});
common/static/js/vendor/tiny_mce/plugins/codemirror/langs/nl.js
0 → 100644
View file @
a14574ec
tinymce
.
addI18n
(
'nl'
,{
'HTML source code'
:
'HTML broncode'
,
'Start search'
:
'Start zoeken'
,
'Find next'
:
'Zoek volgende'
,
'Find previous'
:
'Zoek vorige'
,
'Replace'
:
'Vervang'
,
'Replace all'
:
'Vervang alle'
});
common/static/js/vendor/tiny_mce/plugins/codemirror/plugin.js
0 → 100644
View file @
a14574ec
/**
* plugin.js
*
* Copyright 2013 Web Power, www.webpower.nl
* @author Arjan Haverkamp
*/
/*jshint unused:false */
/*global tinymce:true */
tinymce
.
PluginManager
.
requireLangPack
(
'codemirror'
);
tinymce
.
PluginManager
.
add
(
'codemirror'
,
function
(
editor
,
url
)
{
function
showSourceEditor
()
{
// Insert caret marker
editor
.
focus
();
editor
.
selection
.
collapse
(
true
);
editor
.
selection
.
setContent
(
'<span class="CmCaReT" style="display:none">�</span>'
);
// Open editor window
var
win
=
editor
.
windowManager
.
open
({
title
:
'HTML source code'
,
url
:
url
+
'/source.html'
,
width
:
800
,
height
:
550
,
resizable
:
true
,
maximizable
:
true
,
buttons
:
[
{
text
:
'Ok'
,
subtype
:
'primary'
,
onclick
:
function
(){
var
doc
=
document
.
querySelectorAll
(
'.mce-container-body>iframe'
)[
0
];
doc
.
contentWindow
.
submit
();
win
.
close
();
}},
{
text
:
'Cancel'
,
onclick
:
'close'
}
]
});
};
// Add a button to the button bar
editor
.
addButton
(
'code'
,
{
title
:
'Source code'
,
icon
:
'code'
,
onclick
:
showSourceEditor
});
// Add a menu item to the tools menu
editor
.
addMenuItem
(
'code'
,
{
icon
:
'code'
,
text
:
'Source code'
,
context
:
'tools'
,
onclick
:
showSourceEditor
});
});
common/static/js/vendor/tiny_mce/plugins/codemirror/plugin.min.js
0 → 100644
View file @
a14574ec
tinymce
.
PluginManager
.
requireLangPack
(
"codemirror"
);
tinymce
.
PluginManager
.
add
(
"codemirror"
,
function
(
a
,
c
){
function
b
(){
a
.
focus
();
a
.
selection
.
collapse
(
!
0
);
a
.
selection
.
setContent
(
'<span class="CmCaReT" style="display:none">�</span>'
);
var
b
=
a
.
windowManager
.
open
({
title
:
"HTML source code"
,
url
:
c
+
"/source.html"
,
width
:
800
,
height
:
550
,
resizable
:
!
0
,
maximizable
:
!
0
,
buttons
:[{
text
:
"Ok"
,
subtype
:
"primary"
,
onclick
:
function
(){
document
.
querySelectorAll
(
".mce-container-body>iframe"
)[
0
].
contentWindow
.
submit
();
b
.
close
()}},{
text
:
"Cancel"
,
onclick
:
"close"
}]})}
a
.
addButton
(
"code"
,
{
title
:
"Source code"
,
icon
:
"code"
,
onclick
:
b
});
a
.
addMenuItem
(
"code"
,{
icon
:
"code"
,
text
:
"Source code"
,
context
:
"tools"
,
onclick
:
b
})});
common/static/js/vendor/tiny_mce/plugins/codemirror/source.html
0 → 100644
View file @
a14574ec
<!DOCTYPE html>
<html>
<head>
<script>
/**
* source.html
*
* Copyright 2013-2014 Web Power, www.webpower.nl
* @author Arjan Haverkamp
*/
// Global vars:
var
tinymce
,
// Reference to TinyMCE
editor
,
// Reference to TinyMCE editor
codemirror
,
// CodeMirror instance
chr
=
0
,
// Unused utf-8 character, placeholder for cursor
isMac
=
/macintosh|mac os/i
.
test
(
navigator
.
userAgent
),
CMsettings
;
// CodeMirror settings
function
inArray
(
key
,
arr
)
{
"use strict"
;
arr
=
'|'
+
arr
.
join
(
'|'
)
+
'|'
;
return
arr
.
indexOf
(
'|'
+
key
+
'|'
)
!=
-
1
;
}
(
function
()
{
// Initialise (before load)
"use strict"
;
tinymce
=
parent
.
tinymce
;
editor
=
tinymce
.
activeEditor
;
var
i
,
userSettings
=
editor
.
settings
.
codemirror
?
editor
.
settings
.
codemirror
:
null
;
CMsettings
=
{
path
:
userSettings
.
path
||
'CodeMirror'
,
indentOnInit
:
userSettings
.
indentOnInit
||
false
,
config
:
{
// Default config
mode
:
'htmlmixed'
,
lineNumbers
:
true
,
lineWrapping
:
true
,
indentUnit
:
1
,
tabSize
:
1
,
matchBrackets
:
true
,
styleActiveLine
:
true
},
jsFiles
:
[
// Default JS files
'lib/codemirror.js'
,
'addon/edit/matchbrackets.js'
,
'mode/xml/xml.js'
,
'mode/javascript/javascript.js'
,
'mode/css/css.js'
,
'mode/htmlmixed/htmlmixed.js'
,
'addon/dialog/dialog.js'
,
'addon/search/searchcursor.js'
,
'addon/search/search.js'
,
'addon/selection/active-line.js'
],
cssFiles
:
[
// Default CSS files
'lib/codemirror.css'
,
'addon/dialog/dialog.css'
]
};
// Merge config
for
(
i
in
userSettings
.
config
)
{
CMsettings
.
config
[
i
]
=
userSettings
.
config
[
i
];
}
// Merge jsFiles
for
(
i
in
userSettings
.
jsFiles
)
{
if
(
!
inArray
(
userSettings
.
jsFiles
[
i
],
CMsettings
.
jsFiles
))
{
CMsettings
.
jsFiles
.
push
(
userSettings
.
jsFiles
[
i
]);
}
}
// Merge cssFiles
for
(
i
in
userSettings
.
cssFiles
)
{
if
(
!
inArray
(
userSettings
.
cssFiles
[
i
],
CMsettings
.
cssFiles
))
{
CMsettings
.
cssFiles
.
push
(
userSettings
.
cssFiles
[
i
]);
}
}
// Add trailing slash to path
if
(
!
/
\/
$/
.
test
(
CMsettings
.
path
))
{
CMsettings
.
path
+=
'/'
;
}
// Write stylesheets
for
(
i
=
0
;
i
<
CMsettings
.
cssFiles
.
length
;
i
++
)
{
document
.
write
(
'<li'
+
'nk rel="stylesheet" type="text/css" href="'
+
CMsettings
.
path
+
CMsettings
.
cssFiles
[
i
]
+
'" />'
);
}
// Write JS source files
for
(
i
=
0
;
i
<
CMsettings
.
jsFiles
.
length
;
i
++
)
{
document
.
write
(
'<scr'
+
'ipt type="text/javascript" src="'
+
CMsettings
.
path
+
CMsettings
.
jsFiles
[
i
]
+
'"></scr'
+
'ipt>'
);
}
window
.
onload
=
start
;
}());
function
start
()
{
// Initialise (on load)
"use strict"
;
if
(
typeof
(
window
.
CodeMirror
)
!==
'function'
)
{
alert
(
'CodeMirror not found in "'
+
CMsettings
.
path
+
'", aborting...'
);
return
;
}
// Create legend for keyboard shortcuts for find & replace:
var
head
=
parent
.
document
.
querySelectorAll
(
'.mce-foot'
)[
0
],
div
=
parent
.
document
.
createElement
(
'div'
),
td1
=
'<td style="font-size:11px;background:#777;color:#fff;padding:0 4px">'
,
td2
=
'<td style="font-size:11px;padding-right:5px">'
;
div
.
innerHTML
=
'<table cellspacing="0" cellpadding="0" style="border-spacing:4px"><tr>'
+
td1
+
(
isMac
?
'⌘-F'
:
'Ctrl-F</td>'
)
+
td2
+
tinymce
.
translate
(
'Start search'
)
+
'</td>'
+
td1
+
(
isMac
?
'⌘-G'
:
'Ctrl-G'
)
+
'</td>'
+
td2
+
tinymce
.
translate
(
'Find next'
)
+
'</td>'
+
td1
+
(
isMac
?
'⌘-Alt-F'
:
'Shift-Ctrl-F'
)
+
'</td>'
+
td2
+
tinymce
.
translate
(
'Find previous'
)
+
'</td></tr>'
+
'<tr>'
+
td1
+
(
isMac
?
'⌘-Alt-F'
:
'Shift-Ctrl-F'
)
+
'</td>'
+
td2
+
tinymce
.
translate
(
'Replace'
)
+
'</td>'
+
td1
+
(
isMac
?
'Shift-⌘-Alt-F'
:
'Shift-Ctrl-R'
)
+
'</td>'
+
td2
+
tinymce
.
translate
(
'Replace all'
)
+
'</td></tr></table>'
;
div
.
style
.
position
=
'absolute'
;
div
.
style
.
left
=
div
.
style
.
bottom
=
'5px'
;
head
.
appendChild
(
div
);
// Set CodeMirror cursor to same position as cursor was in TinyMCE:
var
html
=
editor
.
getContent
({
source_view
:
true
});
html
=
html
.
replace
(
/<span
\s
+class="CmCaReT"
([^
>
]
*
)
>
([^
<
]
*
)
<
\/
span>/gm
,
String
.
fromCharCode
(
chr
));
editor
.
dom
.
remove
(
editor
.
dom
.
select
(
'.CmCaReT'
));
CodeMirror
.
defineInitHook
(
function
(
inst
)
{
// Move cursor to correct position:
inst
.
focus
();
var
cursor
=
inst
.
getSearchCursor
(
String
.
fromCharCode
(
chr
),
false
);
if
(
cursor
.
findNext
())
{
inst
.
setCursor
(
cursor
.
to
());
cursor
.
replace
(
''
);
}
// Indent all code, if so requested:
if
(
editor
.
settings
.
codemirror
.
indentOnInit
)
{
var
last
=
inst
.
lineCount
();
inst
.
operation
(
function
()
{
for
(
var
i
=
0
;
i
<
last
;
++
i
)
{
inst
.
indentLine
(
i
);
}
});
}
});
CMsettings
.
config
.
value
=
html
;
// Instantiante CodeMirror:
codemirror
=
CodeMirror
(
document
.
body
,
CMsettings
.
config
);
codemirror
.
isDirty
=
false
;
codemirror
.
on
(
'change'
,
function
(
inst
)
{
inst
.
isDirty
=
true
;
});
}
function
findDepth
(
haystack
,
needle
)
{
"use strict"
;
var
idx
=
haystack
.
indexOf
(
needle
),
depth
=
0
,
x
;
for
(
x
=
idx
;
x
>=
0
;
x
--
)
{
switch
(
haystack
.
charAt
(
x
))
{
case
'<'
:
depth
--
;
break
;
case
'>'
:
depth
++
;
break
;
}
}
return
depth
;
}
// This function is called by plugin.js, when user clicks 'Ok' button
function
submit
()
{
"use strict"
;
var
cc
=
'�'
,
isDirty
=
codemirror
.
isDirty
,
doc
=
codemirror
.
doc
;
if
(
doc
.
somethingSelected
())
{
// Clear selection:
doc
.
setCursor
(
doc
.
getCursor
());
}
// Insert cursor placeholder (�)
doc
.
replaceSelection
(
cc
);
var
pos
=
codemirror
.
getCursor
(),
curLineHTML
=
doc
.
getLine
(
pos
.
line
);
if
(
findDepth
(
curLineHTML
,
cc
)
!==
0
)
{
// Cursor is inside a
<
tag
>
,
don
't set cursor:
curLineHTML = curLineHTML.replace(cc, '');
doc.setLine(pos.line, curLineHTML);
}
// Submit HTML to TinyMCE:
editor.setContent(codemirror.getValue().replace(cc, '
<
span
id
=
"CmCaReT"
><
/span>'
))
;
editor
.
isNotDirty
=
!
isDirty
;
if
(
isDirty
)
{
editor
.
nodeChanged
();
}
// Set cursor:
var
el
=
editor
.
dom
.
select
(
'span#CmCaReT'
)[
0
];
if
(
el
)
{
editor
.
selection
.
scrollIntoView
(
el
);
editor
.
selection
.
setCursorLocation
(
el
,
0
);
editor
.
dom
.
remove
(
el
);
}
}
</script>
<style
type=
"text/css"
>
body
{
margin
:
0
;
}
.CodeMirror
{
height
:
100%
;
font-size
:
12px
;
line-height
:
18px
;
}
.CodeMirror-activeline-background
{
background
:
#e8f2ff
!important
;
}
</style>
</head>
<body></body>
</html>
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