diff --git a/app/post/routes.py b/app/post/routes.py index 453504e5..15a0b801 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -1993,3 +1993,9 @@ def post_cross_post(post_id: int): joined_communities=joined, menu_topics=menu_topics(), site=g.site ) + + +@bp.route('/post_preview', methods=['POST']) +@login_required +def preview(): + return markdown_to_html(request.form.get('body')) diff --git a/app/static/js/coolfieldset.js b/app/static/js/coolfieldset.js index 1452cccb..836a2d95 100644 --- a/app/static/js/coolfieldset.js +++ b/app/static/js/coolfieldset.js @@ -55,14 +55,6 @@ fieldsets.forEach((fieldset) => { const legend = fieldset.querySelector('legend'); - const content = fieldset.querySelectorAll('*:not(legend)'); - - content.forEach((element) => { - const wrapper = document.createElement('div'); - wrapper.classList.add('wrapper'); - element.parentNode.insertBefore(wrapper, element); - wrapper.appendChild(element); - }); if (setting.collapsed) { hideFieldsetContent(fieldset, { animation: false }); diff --git a/app/static/styles.css b/app/static/styles.css index 7cfda5ad..0c59adf5 100644 --- a/app/static/styles.css +++ b/app/static/styles.css @@ -1991,6 +1991,13 @@ form h5 { } } +#preview:has(p, a, h1, h2, h3, ul, ol) { + border: solid 1px #ddd; + border-radius: 5px; + padding: 5px 10px; + margin-bottom: 15px; +} + /* high contrast */ @media (prefers-contrast: more) { :root { diff --git a/app/static/styles.scss b/app/static/styles.scss index 2c21b058..29b474d5 100644 --- a/app/static/styles.scss +++ b/app/static/styles.scss @@ -1716,6 +1716,13 @@ form { } +#preview:has(p, a, h1, h2, h3, ul, ol) { + border: solid 1px #ddd; + border-radius: 5px; + padding: 5px 10px; + margin-bottom: 15px; +} + /* high contrast */ @import "scss/high_contrast"; diff --git a/app/templates/post/post_edit.html b/app/templates/post/post_edit.html index ec0fdc0d..e426fb85 100644 --- a/app/templates/post/post_edit.html +++ b/app/templates/post/post_edit.html @@ -6,6 +6,7 @@ {% from 'bootstrap/form.html' import render_form, render_field %} {% block app_content %} +