mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
(refs #373)Preview markdown in the text file editor.
This commit is contained in:
@@ -23,18 +23,25 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<select id="wrap" class="input-medium" style="margin-bottom: 0px;">
|
<select id="wrap" class="input-medium" style="margin-bottom: 0px; height: 26px; padding: 0px;">
|
||||||
<optgroup label="Line Wrap Mode">
|
<optgroup label="Line Wrap Mode">
|
||||||
<option value="false">No wrap</option>
|
<option value="false">No wrap</option>
|
||||||
<option value="true">Soft wrap</option>
|
<option value="true">Soft wrap</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@if(renderableSuffixes.find(suffix => fileName.map(_.toLowerCase.endsWith(suffix)).getOrElse(false))) {
|
||||||
|
<div class="btn-group" data-toggle="buttons-radio">
|
||||||
|
<input type="button" id="btn-code" class="btn btn-default btn-small active" value="Code">
|
||||||
|
<input type="button" id="btn-preview" class="btn btn-default btn-small" value="Preview">
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div id="editor" style="width: 100%; height: 600px;"></div>
|
<div id="editor" style="width: 100%; height: 600px;"></div>
|
||||||
|
<div id="preview" class="box-content markdown-body" style="border: none; padding-left: 16px; padding-right: 16px; width: 100%; display: none;"></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -103,5 +110,26 @@ $(function(){
|
|||||||
$('#commit').click(function(){
|
$('#commit').click(function(){
|
||||||
$('#content').val(editor.getValue());
|
$('#content').val(editor.getValue());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#btn-code').click(function(){
|
||||||
|
$('#editor').show();
|
||||||
|
$('#preview').hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btn-preview').click(function(){
|
||||||
|
$('#editor').hide();
|
||||||
|
$('#preview').show()
|
||||||
|
|
||||||
|
// update preview
|
||||||
|
$('#preview').html('<img src="@assets/common/images/indicator.gif"> Previewing...');
|
||||||
|
$.post('@url(repository)/_preview', {
|
||||||
|
content : editor.getValue(),
|
||||||
|
enableWikiLink : false,
|
||||||
|
enableRefsLink : false
|
||||||
|
}, function(data){
|
||||||
|
$('#preview').html(data);
|
||||||
|
prettyPrint();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user