Commits

Ahmad Khayyat committed 07dd3f0

Side-by-side editor and preview

  • Participants
  • Parent commits 0c828e4

Comments (0)

Files changed (2)

File mezzanine_pagedown/static/mezzanine_pagedown/css/pagedown.css

 .wmd-wrapper {
     display: inline-block;
+    width: 1000px;
 }
 
-.wmd-input { height: 25em; }
+.wmd-panel {
+    width: 500px;
+    display: inline-block;
+    vertical-align: top;
+}
+
+.wmd-input {
+    height: 394px;
+    width: 492px;
+    resize: vertical;
+}
 
 .wmd-preview
 {
-    width: 678px;
-    margin-top: 15px;
+    display: inline-block;
+    vertical-align: top;
+    width: 474px;
+    height: 400px;
+    margin-top: 30px;
     padding: 0 10px;
     background-color: #fafafa;
     font-size: 100%;
     margin-left: 5px;
     margin-right: 5px;
     margin-bottom: 5px;
-    margin-top: 10px;
+    margin-top: 5px;
     padding: 0px;
     height: 20px;
 }
     font-weight:normal;
     color:#111;
     line-height:1em;
-    margin-bottom: 0.75em;
     padding: 0;
+    margin-top: 12px;
     background: none;
 }
 .wmd-preview h4,.wmd-preview h5,.wmd-preview h6{ font-weight: bold; }
 
 .wmd-preview table { border-collapse: collapse; border-spacing: 0; }
 .wmd-preview td { vertical-align: top; }
+

File mezzanine_pagedown/templates/mezzanine_pagedown/editor.html

       var editor_{{ id }} = new Markdown.Editor(converter_{{ id }}, "-{{ id }}");
       editor_{{ id }}.hooks.set("insertImageDialog", browseMediaLibrary);
       editor_{{ id }}.run();
+
+      // resize preview along with textarea
+      $('#wmd-input-{{ id }}').on('mouseup', function() {
+        {% if server_side_preview %}
+        $('#server-preview-{{ id }}')
+        {% else %}
+        $('#wmd-preview-{{ id }}')
+        {% endif %}
+           .outerHeight($('#wmd-input-{{ id }}').outerHeight());
+      });
+
       {% if server_side_preview %}
+      // server-side preview
       preview = function() {
         $.post('{% url 'preview' %}',
           {text:$('#wmd-input-{{ id }}').val()},