From 32c7249c587b9d4e259a937c7f945b3859302383 Mon Sep 17 00:00:00 2001 From: bitWolfy Date: Sun, 5 Apr 2020 11:28:42 -0700 Subject: [PATCH] Add FormattingHelper to post description textboxes Resolves #132 --- src/js/components/structure/DomUtilities.ts | 12 ++++++++++++ src/js/modules/general/FormattingHelper.ts | 2 +- src/scss/modules/_formatting-helper.scss | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/js/components/structure/DomUtilities.ts b/src/js/components/structure/DomUtilities.ts index 975e307c..eb476b82 100644 --- a/src/js/components/structure/DomUtilities.ts +++ b/src/js/components/structure/DomUtilities.ts @@ -76,6 +76,18 @@ export class DomUtilities { // Subscribe button container $("").addClass("tag-action-subscribe").appendTo($actionsBox); }); + + /** Wrap the post description textareas in FormattingHelper compatible tags */ + if (Page.matches(PageDefintion.upload) || Page.matches(PageDefintion.post)) { + const $textarea = $("textarea#post_description"); + + $("
") + .addClass("dtext-previewable") + .append($(`
`)) + .insertBefore($textarea) + .append($textarea) + .wrap(`
`); + } } /** diff --git a/src/js/modules/general/FormattingHelper.ts b/src/js/modules/general/FormattingHelper.ts index 12d27f2a..cbad7fc5 100644 --- a/src/js/modules/general/FormattingHelper.ts +++ b/src/js/modules/general/FormattingHelper.ts @@ -173,7 +173,7 @@ class FormattingHelper { this.$container.attr("data-editing", "true"); this.$container.attr("data-drawer", "false"); - this.$form = this.$container.parents("form.simple_form"); + this.$form = this.$container.parents("form.simple_form").first(); this.$textarea = this.$container.find("textarea"); this.$preview = this.$container.find("div.dtext-preview"); diff --git a/src/scss/modules/_formatting-helper.scss b/src/scss/modules/_formatting-helper.scss index 95f3cea5..044ba7e7 100644 --- a/src/scss/modules/_formatting-helper.scss +++ b/src/scss/modules/_formatting-helper.scss @@ -141,7 +141,7 @@ form.formatting-helper { &[data-editing=false] div.comment-buttons, &[data-editing=false] div.settings-buttons, &[data-editing=false] textarea { - display: none; + display: none !important; } &[data-editing=false] div.dtext-preview {