NDOJ/templates/markdown_editor/markdown_editor.html

135 lines
4.2 KiB
HTML
Raw Normal View History

2024-02-01 02:46:25 +00:00
{% set layout='no_wrapper' %}
2023-10-02 18:30:46 +00:00
{% extends "base.html" %}
{% block media %}
<style>
2024-02-01 02:46:25 +00:00
body{
2023-10-02 18:30:46 +00:00
overflow: hidden;
}
2023-10-05 18:08:24 +00:00
#content{
2023-10-02 18:30:46 +00:00
width: 100%;
2024-02-01 02:46:25 +00:00
height: calc(100vh - 50px);
margin-bottom: 0;
2023-10-02 18:30:46 +00:00
padding: 0;
}
2024-02-01 02:46:25 +00:00
#content-body {
padding: 0;
height: 100%;
display: flex;
2023-10-02 18:30:46 +00:00
}
2024-02-01 02:46:25 +00:00
2023-10-02 18:30:46 +00:00
.wmd-preview{
float: right;
margin-top: 0;
}
.width-controller{
width: 51%;
}
2024-02-01 02:46:25 +00:00
#id_body-preview{
overflow: scroll;
2023-10-02 18:30:46 +00:00
}
2024-02-01 02:46:25 +00:00
.form-area {
flex-grow: 1;
2023-10-05 18:08:24 +00:00
}
2023-10-02 18:30:46 +00:00
</style>
{% endblock %}
{% block js_media %}
<script>
2024-02-01 02:46:25 +00:00
function debounce(func, wait) {
let timeout;
2023-10-05 18:08:24 +00:00
2024-02-01 02:46:25 +00:00
return function executedFunction(...args) {
const context = this;
const later = () => {
clearTimeout(timeout);
func.apply(context, args);
};
2023-10-02 18:30:46 +00:00
2024-02-01 02:46:25 +00:00
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
2023-10-02 18:30:46 +00:00
2024-02-01 02:46:25 +00:00
function update_preview() {
$.ajax({
url: "{{url('blog_preview')}}",
type: 'POST',
data: {
preview: $(this).val()
},
success: function(data) {
$('#display').html(data);
2024-02-05 23:02:49 +00:00
renderKatex();
2024-02-01 02:46:25 +00:00
populateCopyButton();
},
error: function(error) {
console.log(error.message);
}
})
}
2023-10-02 18:30:46 +00:00
2024-02-01 02:46:25 +00:00
$(document).ready(function(){
const debounced_update_preview = debounce(update_preview, 250);
$("#wmd-input-id_body").on("keyup", debounced_update_preview);
2023-10-02 18:30:46 +00:00
});
</script>
<script src="{{ static('pagedown/Markdown.Converter.js') }}"></script>
<script src="{{ static('pagedown-extra/pagedown/Markdown.Converter.js') }}"></script>
<script src="{{ static('pagedown/Markdown.Sanitizer.js') }}"></script>
<script src="{{ static('pagedown/Markdown.Editor.js') }}"></script>
<script src="{{ static('pagedown-extra/Markdown.Extra.js') }}"></script>
<script src="{{ static('pagedown_init.js') }}"></script>
<script src="{{ static('pagedown_math.js') }}"></script>
{% endblock %}
{% block title_row %}
{% endblock %}
2023-10-05 18:08:24 +00:00
{% block title_ruler %}
{% endblock %}
2023-10-02 18:30:46 +00:00
{% block body %}
2024-02-01 02:46:25 +00:00
<div id="new-comment" class="form-area">
<input type="hidden" name="parent" id="id_parent">
<div class="comment-post-wrapper">
<div id="comment-form-body"><div class="wmd-wrapper image-upload-enabled">
<div class="wmd-panel">
<div id="wmd-button-bar-id_body"></div>
<textarea id="wmd-input-id_body" class="wmd-input" name="body" required=""></textarea>
</div>
<div id="id_body-preview" data-preview-url="{{url('comment_preview')}}" data-textarea-id="wmd-input-id_body" data-timeout="1000" class="wmd-panel wmd-preview dmmd-preview dmmd-no-button">
<div class="dmmd-preview-update"><i class="fa fa-refresh"></i> {{_('Update Preview')}}</div>
<div class="dmmd-preview-content content-description"></div>
</div>
<div class="pagedown-image-upload">
<h2>{{_('Insert Image')}}</h2>
<div class="form-row">
<div>
<label class="label">{{_('From the web')}}</label>
<input class="url-input" type="text" placeholder="http://">
2023-10-05 18:08:24 +00:00
</div>
2024-02-01 02:46:25 +00:00
</div>
<div class="form-row">
<div>
<label class="label">{{_('From your computer')}}</label>
<input class="file-input" type="file" name="image" id="file" data-action="/pagedown/image-upload/" accept="image/*">
2023-10-05 18:08:24 +00:00
</div>
2023-10-02 18:30:46 +00:00
</div>
2024-02-01 02:46:25 +00:00
<div class="submit-row">
<div class="submit-loading"></div>
<input class="submit-input show" type="submit" value="{{_('Save')}}" name="_addanother">
<p class="deletelink-box"><a href="#" class="close-image-upload deletelink">{{_('Cancel')}}</a></p>
</div>
</div>
</div></div>
2023-10-02 18:30:46 +00:00
</div>
2024-02-01 02:46:25 +00:00
</div>
2023-10-02 18:30:46 +00:00
2024-02-01 02:46:25 +00:00
<div id="id_body-preview" data-preview-url="{{url('comment_preview')}}" data-textarea-id="wmd-input-id_body" data-timeout="1000" class="width-controller wmd-panel wmd-preview dmmd-preview dmmd-no-button dmmd-preview-has-content">
<div class="right-markdown dmmd-preview-content content-description" id="display"></div>
2023-10-02 18:30:46 +00:00
</div>
{% endblock %}