Skip to content

Commit

Permalink
Make use of Webpack ready JS MD lib
Browse files Browse the repository at this point in the history
  • Loading branch information
allejo committed Jun 24, 2017
1 parent d2cf782 commit d202ed0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
[submodule "web/assets/css/vendor/OnTheRocks"]
path = assets/css/vendor/OnTheRocks
url = https://github.com/allejo/OnTheRocks.git
[submodule "web/includes/markdown-it"]
path = web/includes/markdown-it
url = https://github.com/markdown-it/markdown-it.git
[submodule "web/assets/css/vendor/SassyCast"]
path = assets/css/vendor/SassyCast
url = https://github.com/HugoGiraudel/SassyCast.git
11 changes: 5 additions & 6 deletions assets/js/src/md-editor.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module.exports = function() {
if (window.markdownit === undefined) {
return;
}
var md = require('markdown').markdown;

module.exports = function() {
$('#mde__toolbar__preview').click(function() {
var markdown = $('#form_content').val();
var result = md.render(markdown);
var formID = $(this).data('textarea');
var markdown = $('#' + formID).val();
var result = md.toHTML(markdown);

$('#mde__preview').html(result);
});
Expand Down
4 changes: 1 addition & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"gulp-util": "^3.0.7",
"gulp.spritesmith": "^6.2.1",
"jquery": "^3.2.1",
"markdown": "^0.5.0",
"modernizr": "^3.5.0",
"modernizr-webpack-plugin": "^1.0.6",
"node-sass": "^4.5.3",
Expand Down
1 change: 1 addition & 0 deletions views/md-editor.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
aria-controls="mde__panel__preview"
aria-selected="false"
tabindex="0"
data-textarea="{{ form_textarea.vars.id }}"
>
<i class="fa fa-eye" aria-hidden="true"></i> Preview
</li>
Expand Down
1 change: 0 additions & 1 deletion web/includes/markdown-it
Submodule markdown-it deleted from 0e5182

0 comments on commit d202ed0

Please sign in to comment.