Skip to content

Commit

Permalink
Added initial Markdown Toolbar
Browse files Browse the repository at this point in the history
TODO: Style Buttons
  • Loading branch information
njam3 committed Apr 10, 2019
1 parent 4ee0fde commit 8412908
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
13 changes: 7 additions & 6 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 @@ -28,6 +28,7 @@
"webpack-cli": "^3.1.2"
},
"dependencies": {
"@github/markdown-toolbar-element": "^0.2.0",
"axios": "^0.18.0",
"clipboard": "^2.0.4",
"codemirror": "^5.42.0",
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/components/markdown-editor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@github/markdown-toolbar-element';
import MarkdownIt from "markdown-it";
import mdTasksLists from 'markdown-it-task-lists';
import code from '../services/code';
Expand All @@ -20,6 +21,7 @@ class MarkdownEditor {
this.input = this.elem.querySelector('textarea');
this.htmlInput = this.elem.querySelector('input[name=html]');
this.cm = code.markdownEditor(this.input);
this.cm.getInputField().id = 'markdown-textarea';

this.onMarkdownScroll = this.onMarkdownScroll.bind(this);
this.init();
Expand Down
14 changes: 14 additions & 0 deletions resources/views/pages/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@
</div>
</div>

<markdown-toolbar for="markdown-textarea">
<md-bold>bold</md-bold>
<md-header>header</md-header>
<md-italic>italic</md-italic>
<md-quote>quote</md-quote>
<md-code>code</md-code>
<md-link>link</md-link>
<md-unordered-list>unordered-list</md-unordered-list>
<md-ordered-list>ordered-list</md-ordered-list>
<md-task-list>task-list</md-task-list>
<md-mention>mention</md-mention>
<md-ref>ref</md-ref>
</markdown-toolbar>

<div markdown-input class="flex flex-fill">
<textarea id="markdown-editor-input" name="markdown" rows="5"
@if($errors->has('markdown')) class="neg" @endif>@if(isset($model) || old('markdown')){{htmlspecialchars( old('markdown') ? old('markdown') : ($model->markdown === '' ? $model->html : $model->markdown))}}@endif</textarea>
Expand Down

0 comments on commit 8412908

Please sign in to comment.