Skip to content

Commit

Permalink
Completed markdown (I think)
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts-ctrlo committed Oct 11, 2023
1 parent 0c9ad06 commit a00f280
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 22 deletions.
5 changes: 5 additions & 0 deletions src/frontend/components/markdown/_markdown.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
div.form-group {
div.js-markdown-preview {
height: 100%;
}
}
4 changes: 2 additions & 2 deletions src/frontend/components/markdown/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
24 changes: 12 additions & 12 deletions src/frontend/css/stylesheets/base/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
// #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;
// }
1 change: 1 addition & 0 deletions src/frontend/css/stylesheets/general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@
@import 'table-header/table-header';
@import 'timeline/timeline';
@import 'user/user';
@import 'markdown/markdown';
2 changes: 1 addition & 1 deletion views/fields/textarea.tt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
[% INCLUDE fields/sub/label_input.tt label_type="textarea"; %]
<div class="input__field">
<textarea
class="form-control"
class="form-control [% custom_classes %]"
id="[% id %]"
name="[% name %]"
rows="[% rows %]"
Expand Down
8 changes: 8 additions & 0 deletions views/layout.tt
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,24 @@
</div>
<div class="row">
<div class="col">
<div class="js-markdown-section">
[%
$popover = INCLUDE snippets/markdown.tt;
INCLUDE fields/textarea.tt
id = "helptext"
name = "helptext"
label = "Help text for the user"
placeholder = "Helptext"
value = column.helptext
filter = "html"
custom_classes = "js-markdown-input"
popover_body = $popover
popover_title = "Markdown Help"
rows = 5;
%]
[% INCLUDE snippets/markdown_section.tt
label = "Help text preview" %]
</div>
</div>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions views/snippets/markdown_section.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="form-group">
<div class="textarea__label">
<label for="preview"><strong>[% IF label; label; ELSE %]Preview[% END; %]</strong></label>
</div>
<div class="js-markdown-preview form-control">
<p class="text-info">Nothing to preview!</p>
</div>
</div>
11 changes: 4 additions & 7 deletions views/topic.tt
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@
help_text = "Use Markdown for formatting"
rows = 5
popover_body = $help
popover_title = "Markdown Help";
popover_title = "Markdown Help"
custom_classes = "js-markdown-input";
%]
<div class="textarea__label">
<label for="preview"><strong>Description Preview</strong></label>
</div>
<div id="preview">
<p class="text-info">Nothing to preview!</p>
</div>
[% INCLUDE snippets/markdown_section.tt
label = "Description Preview" %]
</div>
[%
INCLUDE fields/switch_single.tt
Expand Down

0 comments on commit a00f280

Please sign in to comment.