-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Markdown is working I don't like the way the table "overflows" in the "cheat sheet" if the window is certain sizes - I shall ascertain if this is an issue and try to mitigate * Redone to use popover Also modified popovers to allow for scrolling * Changes as suggested * Style changes for markdown preview * Completed markdown (I think) * Fixed styling for preview and added scrolling * Removed commented code and updated spacing
- Loading branch information
1 parent
18a0d1a
commit 152a500
Showing
14 changed files
with
198 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
div.form-group { | ||
div.js-markdown-preview { | ||
height: 8rem; | ||
overflow: auto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { initializeComponent } from "../../js/lib/component"; | ||
import MarkdownComponent from "./lib/component"; | ||
|
||
export default (scope) => | ||
initializeComponent(scope, ".js-markdown-section", MarkdownComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { marked } from "marked"; | ||
import { Component } from "../../../js/lib/component"; | ||
|
||
class MarkdownComponent extends Component { | ||
constructor(element) { | ||
super(element); | ||
this.initMarkdownEditor(); | ||
} | ||
|
||
initMarkdownEditor() { | ||
marked.use({ breaks: true }); | ||
|
||
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()); | ||
$preview.html(htmlText); | ||
} | ||
}); | ||
$textArea.keyup(() => { | ||
const markdownText = $textArea.val(); | ||
if (!markdownText || markdownText === "") { | ||
$preview.html('<p class="text-info">Nothing to preview!</p>'); | ||
} else { | ||
const htmlText = marked(markdownText); | ||
$preview.html(htmlText); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export default MarkdownComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<p>The following Markdown can be used</p> | ||
<table class="table table-bordered"> | ||
<thead> | ||
<tr> | ||
<th>Markdown</th> | ||
<th>HTML</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<pre># Heading 1</pre> | ||
</td> | ||
<td> | ||
<h1>Heading 1</h1> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<pre>## Heading 2</pre> | ||
</td> | ||
<td> | ||
<h2>Heading 2</h2> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<pre>- bullet | ||
- bullet | ||
- bullet | ||
- bullet</pre> | ||
</td> | ||
<td> | ||
<ul> | ||
<li>bullet</li> | ||
<li>bullet | ||
<ul> | ||
<li>bullet</li> | ||
<li>bullet</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<pre>*italic*</pre> | ||
</td> | ||
<td><em>italic</em></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<pre>**bold**</pre> | ||
</td> | ||
<td><strong>bold</strong></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<pre>[link](https://www.google.com)</pre> | ||
</td> | ||
<td><a href="https://www.google.com">link</a></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<p>For more information on Markdown, see <a href="https://www.markdownguide.org/cheat-sheet/">this cheat sheet</a>.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters