NDOJ/templates/markdown_editor/markdown_editor.html

144 lines
4.6 KiB
HTML
Raw Normal View History

2023-10-02 18:30:46 +00:00
{% extends "base.html" %}
{% block media %}
<style>
2023-10-05 18:08:24 +00:00
main{
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%;
}
2023-10-05 18:08:24 +00:00
#content.wrapper{
2023-10-02 18:30:46 +00:00
padding: 0;
}
2023-10-05 18:08:24 +00:00
.form-area{
2023-10-02 18:30:46 +00:00
float: left;
width: 47%;
height: 100%
}
.wmd-preview{
float: right;
margin-top: 0;
}
.width-controller{
width: 51%;
}
2023-10-05 18:08:24 +00:00
.wmd-input{
height: calc(100vh - 72px);
2023-10-02 18:30:46 +00:00
}
.right-markdown{
2023-10-05 18:08:24 +00:00
height: calc(100vh - 72px);
2023-10-02 18:30:46 +00:00
overflow-y: scroll;
}
2023-10-05 18:08:24 +00:00
.wrap{
display: flex;
}
2023-10-02 18:30:46 +00:00
</style>
{% endblock %}
{% block js_media %}
<script>
$(document).ready(function(){
$("#wmd-input-id_body").on("keyup", function() {
const csrfToken = "{{ csrf_token }}";
$.ajax({
url: "{{url('blog_preview')}}",
type: 'POST',
headers: {
'X-CSRFToken': csrfToken, // Include the CSRF token in the headers
},
data: {
preview: $(this).val()
},
success: function(data) {
2023-10-05 18:08:24 +00:00
$('#display').html(data);
MathJax.typeset();
2023-10-02 18:30:46 +00:00
},
error: function(error) {
alert(error);
console.log(error.message)
}
})
2023-10-05 18:08:24 +00:00
2023-10-02 18:30:46 +00:00
});
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const leftDiv = document.getElementById("wmd-input-id_body");
const rightDiv = document.getElementById("display");
leftDiv.addEventListener("scroll", function() {
rightDiv.scrollTop = leftDiv.scrollTop;
});
rightDiv.addEventListener("scroll", function() {
leftDiv.scrollTop = rightDiv.scrollTop;
});
});
</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('mathjax3_config.js') }}"></script>
<script src="http://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.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 %}
2023-10-05 18:08:24 +00:00
<div class="wrap">
<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>
2023-10-02 18:30:46 +00:00
</div>
2023-10-05 18:08:24 +00:00
<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>
2023-10-02 18:30:46 +00:00
</div>
2023-10-05 18:08:24 +00:00
<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://">
</div>
</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/*">
</div>
</div>
<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>
2023-10-02 18:30:46 +00:00
</div>
2023-10-05 18:08:24 +00:00
</div></div>
</div>
2023-10-02 18:30:46 +00:00
</div>
2023-10-05 18:08:24 +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>
</div>
2023-10-02 18:30:46 +00:00
</div>
{% endblock %}