From a00f280f4c85e3a125a3049c4fbe9a509c01a34a Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Wed, 11 Oct 2023 14:59:53 +0100 Subject: [PATCH] Completed markdown (I think) --- .../components/markdown/_markdown.scss | 5 ++++ .../components/markdown/lib/component.js | 4 ++-- .../css/stylesheets/base/_global.scss | 24 +++++++++---------- src/frontend/css/stylesheets/general.scss | 1 + views/fields/textarea.tt | 2 +- views/layout.tt | 8 +++++++ views/snippets/markdown_section.tt | 8 +++++++ views/topic.tt | 11 ++++----- 8 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 src/frontend/components/markdown/_markdown.scss create mode 100644 views/snippets/markdown_section.tt diff --git a/src/frontend/components/markdown/_markdown.scss b/src/frontend/components/markdown/_markdown.scss new file mode 100644 index 000000000..5a8ec0821 --- /dev/null +++ b/src/frontend/components/markdown/_markdown.scss @@ -0,0 +1,5 @@ +div.form-group { + div.js-markdown-preview { + height: 100%; + } +} \ No newline at end of file diff --git a/src/frontend/components/markdown/lib/component.js b/src/frontend/components/markdown/lib/component.js index b2d5059e0..2ace69281 100644 --- a/src/frontend/components/markdown/lib/component.js +++ b/src/frontend/components/markdown/lib/component.js @@ -10,8 +10,8 @@ class MarkdownComponent extends Component { initMarkdownEditor() { marked.use({ breaks: true }); - const $textArea = $(this.element).find("#description"); - const $preview = $(this.element).find("#preview"); + const $textArea = $(this.element).find(".js-markdown-input"); + const $preview = $(this.element).find(".js-markdown-preview"); $().ready(() => { if ($textArea.val() !== "") { const htmlText = marked($textArea.val()); diff --git a/src/frontend/css/stylesheets/base/_global.scss b/src/frontend/css/stylesheets/base/_global.scss index 75ee7dfd4..946a044c6 100644 --- a/src/frontend/css/stylesheets/base/_global.scss +++ b/src/frontend/css/stylesheets/base/_global.scss @@ -94,15 +94,15 @@ table.table-bordered { } } -#preview { - //Copied from bootstrap - padding: $input-padding-y $input-padding-x; - @include border-radius($input-border-radius, 0); - @include box-shadow($input-box-shadow); - @include transition($input-transition); - @include form-control-focus($ignore-warning: true); - background-clip: padding-box; - border: $input-border-width solid $input-border-color; - //Required to stop box "overlapping" other controls below - margin-bottom: 1.2em; -} \ No newline at end of file +// #preview { +// //Copied from bootstrap +// padding: $input-padding-y $input-padding-x; +// @include border-radius($input-border-radius, 0); +// @include box-shadow($input-box-shadow); +// @include transition($input-transition); +// @include form-control-focus($ignore-warning: true); +// background-clip: padding-box; +// border: $input-border-width solid $input-border-color; +// //Required to stop box "overlapping" other controls below +// margin-bottom: 1.2em; +// } \ No newline at end of file diff --git a/src/frontend/css/stylesheets/general.scss b/src/frontend/css/stylesheets/general.scss index be2f7ad48..0f14c5be4 100644 --- a/src/frontend/css/stylesheets/general.scss +++ b/src/frontend/css/stylesheets/general.scss @@ -77,3 +77,4 @@ @import 'table-header/table-header'; @import 'timeline/timeline'; @import 'user/user'; +@import 'markdown/markdown'; \ No newline at end of file diff --git a/views/fields/textarea.tt b/views/fields/textarea.tt index 3d3f5b831..6dca389ec 100644 --- a/views/fields/textarea.tt +++ b/views/fields/textarea.tt @@ -31,7 +31,7 @@ [% INCLUDE fields/sub/label_input.tt label_type="textarea"; %]