From b4312cbfefc8871c00e73389cd1ad0d1f475af06 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 3 Jan 2013 13:39:01 -0500 Subject: [PATCH 1/3] Starting the markdown editor. --- cms/static/js/speed-editor.js | 3 ++- cms/templates/widgets/problem-edit.html | 3 +++ .../xmodule/js/src/problem/markdown.coffee | 19 ++++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cms/static/js/speed-editor.js b/cms/static/js/speed-editor.js index f310e86cac..4c3df85f13 100644 --- a/cms/static/js/speed-editor.js +++ b/cms/static/js/speed-editor.js @@ -21,7 +21,8 @@ function initProblemEditors($editor, $prev) { $currentEditor = $editor; simpleEditor = CodeMirror.fromTextArea($editor.find('.edit-box')[0], { lineWrapping: true, - extraKeys: { +// TODO: I left out the extra keys for now. + extraKeys: { 'Ctrl-N': newUnit, 'Ctrl-H': makeHeader, 'Ctrl-V': makeVideo, diff --git a/cms/templates/widgets/problem-edit.html b/cms/templates/widgets/problem-edit.html index 99442c0179..d37d605971 100644 --- a/cms/templates/widgets/problem-edit.html +++ b/cms/templates/widgets/problem-edit.html @@ -1,6 +1,9 @@ <%include file="metadata-edit.html" />
+ <% + markdown = 'foo' + %> %if markdown != '' or data == '':
    diff --git a/common/lib/xmodule/xmodule/js/src/problem/markdown.coffee b/common/lib/xmodule/xmodule/js/src/problem/markdown.coffee index 6b87449d83..d938cb0bd3 100644 --- a/common/lib/xmodule/xmodule/js/src/problem/markdown.coffee +++ b/common/lib/xmodule/xmodule/js/src/problem/markdown.coffee @@ -1,10 +1,19 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor constructor: (@element) -> - @edit_box = CodeMirror.fromTextArea($(".xml-box", @element)[0], { - mode: "xml" - lineNumbers: true - lineWrapping: true + @xml_editor = CodeMirror.fromTextArea($(".xml-box", @element)[0], { + mode: "xml" + lineNumbers: true + lineWrapping: true }) + @markdown_editor = CodeMirror.fromTextArea($(".edit-box", @element)[0], { + lineWrapping: true + mode: null + onChange: @onMarkdownEditorUpdate + }) + + onMarkdownEditorUpdate: -> + console.log('update') + save: -> - data: @edit_box.getValue() + data: @xml_editor.getValue() From f443c66bcdea0c3ef104b75904c86561ba7a2c54 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 3 Jan 2013 14:11:53 -0500 Subject: [PATCH 2/3] Rename, add css file. --- .../lib/xmodule/xmodule/css/problem/edit.scss | 64 +++++++++++++++++++ .../problem/{markdown.coffee => edit.coffee} | 0 2 files changed, 64 insertions(+) create mode 100644 common/lib/xmodule/xmodule/css/problem/edit.scss rename common/lib/xmodule/xmodule/js/src/problem/{markdown.coffee => edit.coffee} (100%) diff --git a/common/lib/xmodule/xmodule/css/problem/edit.scss b/common/lib/xmodule/xmodule/css/problem/edit.scss new file mode 100644 index 0000000000..5042731220 --- /dev/null +++ b/common/lib/xmodule/xmodule/css/problem/edit.scss @@ -0,0 +1,64 @@ +.editor-bar { + position: relative; + @include linear-gradient(top, #d4dee8, #c9d5e2); + padding: 5px; + border: 1px solid #3c3c3c; + border-radius: 3px 3px 0 0; + border-bottom-color: #a5aaaf; + @include clearfix; + + a { + display: block; + float: left; + padding: 3px 10px 7px; + margin-left: 7px; + border-radius: 2px; + + &:hover { + background: rgba(255, 255, 255, .5); + } + } + + .editor-tabs { + position: absolute; + top: 10px; + right: 10px; + + li { + float: left; + } + + .tab { + height: 24px; + padding: 7px 20px 3px; + border: 1px solid #a5aaaf; + border-radius: 3px 3px 0 0; + @include linear-gradient(top, rgba(0, 0, 0, 0) 87%, rgba(0, 0, 0, .06)); + background-color: #e5ecf3; + font-size: 13px; + color: #3c3c3c; + box-shadow: 1px -1px 1px rgba(0, 0, 0, .05); + + &.current { + background: #fff; + border-bottom-color: #fff; + } + } + + .cheatsheet-toggle { + width: 21px; + height: 21px; + padding: 0; + margin: 3px 5px 0 16px; + border-radius: 22px; + border: 1px solid #a5aaaf; + background: #e5ecf3; + font-size: 13px; + font-weight: 700; + color: #565d64; + text-align: center; + } + } +} + + diff --git a/common/lib/xmodule/xmodule/js/src/problem/markdown.coffee b/common/lib/xmodule/xmodule/js/src/problem/edit.coffee similarity index 100% rename from common/lib/xmodule/xmodule/js/src/problem/markdown.coffee rename to common/lib/xmodule/xmodule/js/src/problem/edit.coffee From 533f4876b57bfb73ec02855d768132855a013ff7 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 3 Jan 2013 14:27:32 -0500 Subject: [PATCH 3/3] Rename, add css file. --- cms/templates/widgets/problem-edit.html | 5 +---- common/lib/xmodule/xmodule/capa_module.py | 3 ++- common/lib/xmodule/xmodule/js/src/problem/edit.coffee | 11 ++++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cms/templates/widgets/problem-edit.html b/cms/templates/widgets/problem-edit.html index d37d605971..f6baae4d2d 100644 --- a/cms/templates/widgets/problem-edit.html +++ b/cms/templates/widgets/problem-edit.html @@ -1,9 +1,6 @@ <%include file="metadata-edit.html" />
    - <% - markdown = 'foo' - %> %if markdown != '' or data == '':
      @@ -24,7 +21,7 @@
    • ?
    - + %endif
    diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index ff717acdf6..8f01bbccec 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -651,8 +651,9 @@ class CapaDescriptor(RawDescriptor): has_score = True template_dir_name = 'problem' mako_template = "widgets/problem-edit.html" - js = {'coffee': [resource_string(__name__, 'js/src/problem/markdown.coffee')]} + js = {'coffee': [resource_string(__name__, 'js/src/problem/edit.coffee')]} js_module_name = "MarkdownEditingDescriptor" + css = {'scss': [resource_string(__name__, 'css/problem/edit.scss')]} # Capa modules have some additional metadata: # TODO (vshnayder): do problems have any other metadata? Do they diff --git a/common/lib/xmodule/xmodule/js/src/problem/edit.coffee b/common/lib/xmodule/xmodule/js/src/problem/edit.coffee index d938cb0bd3..ce2871fae0 100644 --- a/common/lib/xmodule/xmodule/js/src/problem/edit.coffee +++ b/common/lib/xmodule/xmodule/js/src/problem/edit.coffee @@ -6,11 +6,12 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor lineWrapping: true }) - @markdown_editor = CodeMirror.fromTextArea($(".edit-box", @element)[0], { - lineWrapping: true - mode: null - onChange: @onMarkdownEditorUpdate - }) + if $(".markdown-box", @element).length != 0 + @markdown_editor = CodeMirror.fromTextArea($(".markdown-box", @element)[0], { + lineWrapping: true + mode: null + onChange: @onMarkdownEditorUpdate + }) onMarkdownEditorUpdate: -> console.log('update')