Skip to content

Commit

Permalink
Merge pull request #1 from Jam3/feature/markdown-toolbar
Browse files Browse the repository at this point in the history
Add Markdown Toolbar
  • Loading branch information
njam3 authored May 1, 2019
2 parents 4ee0fde + 8d6fc83 commit 2e600df
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 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
18 changes: 18 additions & 0 deletions resources/assets/sass/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
#markdown-editor {
position: relative;
z-index: 5;
markdown-toolbar {
padding: 5px;
}
markdown-toolbar > * {
border: solid 1px #666;
border-radius: 5px;
cursor: pointer;
margin: 5px 0px;
padding: 2px 5px;
text-align: center;
}
markdown-toolbar > *:hover {
background-color: #666;
color: #fff;
}
markdown-toolbar > * > i {
padding-left: 5px;
}
#markdown-editor-input {
font-style: normal;
font-weight: 400;
Expand Down
1 change: 1 addition & 0 deletions resources/views/pages/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@extends('base')

@section('head')
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<script src="{{ baseUrl('/libs/tinymce/tinymce.min.js?ver=4.6.6') }}"></script>
@stop

Expand Down
14 changes: 13 additions & 1 deletion resources/views/pages/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
</div>
</div>

<markdown-toolbar for="markdown-textarea">
<md-bold><i class="fas fa-bold"></i></md-bold>
<md-header><i class="fas fa-heading"></i></md-header>
<md-italic><i class="fas fa-italic"></i></md-italic>
<md-quote><i class="fas fa-quote-right"></i></md-quote>
<md-code><i class="fas fa-code"></i></md-code>
<md-link><i class="fas fa-link"></i></md-link>
<md-unordered-list><i class="fas fa-list-ul"></i></md-unordered-list>
<md-ordered-list><i class="fas fa-list-ol"></i></md-ordered-list>
<md-task-list><i class="fas fa-tasks"></i></md-task-list>
</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 All @@ -123,4 +135,4 @@
@endif

</div>
</div>
</div>

0 comments on commit 2e600df

Please sign in to comment.