mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
#47 - Gets rid of simplemde
This commit is contained in:
parent
3368fe42d8
commit
8b82753218
@ -17,7 +17,7 @@ class CommentController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(Request $request, $pageId, $commentId)
|
public function save(Request $request, $pageId, $commentId = null)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'text' => 'required|string',
|
'text' => 'required|string',
|
||||||
|
15
public/libs/simplemde/simplemde.min.js
vendored
15
public/libs/simplemde/simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
@ -684,19 +684,20 @@ module.exports = function (ngApp, events) {
|
|||||||
|
|
||||||
// CommentCrudController
|
// CommentCrudController
|
||||||
ngApp.controller('CommentAddController', ['$scope', '$http', function ($scope, $http) {
|
ngApp.controller('CommentAddController', ['$scope', '$http', function ($scope, $http) {
|
||||||
|
const MarkdownIt = require("markdown-it");
|
||||||
|
const md = new MarkdownIt({html: true});
|
||||||
let vm = this;
|
let vm = this;
|
||||||
let comment = {};
|
|
||||||
$scope.errors = {};
|
$scope.errors = {};
|
||||||
vm.saveComment = function () {
|
vm.saveComment = function () {
|
||||||
let pageId = $scope.comment.pageId;
|
let pageId = $scope.comment.pageId;
|
||||||
let comment = $scope.comment.newComment;
|
let comment = $scope.comment.newComment;
|
||||||
let commentHTML = $scope.getCommentHTML();
|
let commentHTML = md.render($scope.comment.newComment);
|
||||||
|
|
||||||
$http.post(window.baseUrl(`/ajax/page/${pageId}/comment/`), {
|
$http.post(window.baseUrl(`/ajax/page/${pageId}/comment/`), {
|
||||||
text: comment,
|
text: comment,
|
||||||
html: commentHTML
|
html: commentHTML
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
$scope.clearInput();
|
$scope.comment.newComment = '';
|
||||||
if (!resp.data || resp.data.status !== 'success') {
|
if (!resp.data || resp.data.status !== 'success') {
|
||||||
return events.emit('error', trans('error'));
|
return events.emit('error', trans('error'));
|
||||||
}
|
}
|
||||||
|
@ -818,53 +818,6 @@ module.exports = function (ngApp, events) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
ngApp.directive('simpleMarkdownInput', ['$timeout', function ($timeout) {
|
|
||||||
return {
|
|
||||||
restrict: 'A',
|
|
||||||
scope: {
|
|
||||||
smdModel: '=',
|
|
||||||
smdChange: '=',
|
|
||||||
smdGetContent: '=',
|
|
||||||
smdClear: '='
|
|
||||||
},
|
|
||||||
link: function (scope, element, attrs) {
|
|
||||||
// Set initial model content
|
|
||||||
element = element.find('textarea').first();
|
|
||||||
let simplemde = new SimpleMDE({
|
|
||||||
element: element[0],
|
|
||||||
status: []
|
|
||||||
});
|
|
||||||
let content = element.val();
|
|
||||||
simplemde.value(content)
|
|
||||||
scope.smdModel = content;
|
|
||||||
|
|
||||||
simplemde.codemirror.on('change', (event) => {
|
|
||||||
content = simplemde.value();
|
|
||||||
$timeout(() => {
|
|
||||||
scope.smdModel = content;
|
|
||||||
if (scope.smdChange) {
|
|
||||||
scope.smdChange(element, content);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if ('smdGetContent' in attrs) {
|
|
||||||
scope.smdGetContent = function () {
|
|
||||||
return simplemde.options.previewRender(simplemde.value());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('smdClear' in attrs) {
|
|
||||||
scope.smdClear = function () {
|
|
||||||
simplemde.value('');
|
|
||||||
scope.smdModel = '';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}]);
|
|
||||||
|
|
||||||
ngApp.directive('commentReply', ['$timeout', function ($timeout) {
|
ngApp.directive('commentReply', ['$timeout', function ($timeout) {
|
||||||
return {
|
return {
|
||||||
|
@ -57,4 +57,11 @@
|
|||||||
|
|
||||||
.comment-editor {
|
.comment-editor {
|
||||||
margin-top: 2em;
|
margin-top: 2em;
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
min-height: 120px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -12,7 +12,6 @@
|
|||||||
@import "animations";
|
@import "animations";
|
||||||
@import "tinymce";
|
@import "tinymce";
|
||||||
@import "highlightjs";
|
@import "highlightjs";
|
||||||
@import "simplemde";
|
|
||||||
@import "components";
|
@import "components";
|
||||||
@import "header";
|
@import "header";
|
||||||
@import "lists";
|
@import "lists";
|
||||||
|
@ -239,5 +239,6 @@ return [
|
|||||||
* Comments
|
* Comments
|
||||||
*/
|
*/
|
||||||
'comment' => 'Comment',
|
'comment' => 'Comment',
|
||||||
'comments' => 'Comments'
|
'comments' => 'Comments',
|
||||||
|
'comment_placeholder' => 'Enter your comments here, markdown supported...'
|
||||||
];
|
];
|
@ -1,13 +1,11 @@
|
|||||||
<div class="comment-editor" ng-controller="CommentAddController as vm" ng-cloak>
|
<div class="comment-editor" ng-controller="CommentAddController as vm" ng-cloak>
|
||||||
<form novalidate>
|
<form novalidate>
|
||||||
<div simple-markdown-input smd-model="comment.newComment" smd-get-content="getCommentHTML" smd-clear="clearInput">
|
<textarea name="markdown" rows="3" ng-model="comment.newComment" placeholder="{{ trans('entities.comment_placeholder') }}"
|
||||||
<textarea name="markdown" rows="3"
|
@if($errors->has('markdown')) class="neg" @endif>@if(isset($model) ||
|
||||||
@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>
|
||||||
old('markdown')){{htmlspecialchars( old('markdown') ? old('markdown') : ($model->markdown === '' ? $model->html : $model->markdown))}}@endif</textarea>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" ng-model="pageId" name="comment.pageId" value="{{$pageId}}" ng-init="comment.pageId = {{$pageId }}">
|
<input type="hidden" ng-model="pageId" name="comment.pageId" value="{{$pageId}}" ng-init="comment.pageId = {{$pageId }}">
|
||||||
<button type="submit" class="button pos" ng-click="vm.saveComment()">Save</button>
|
<button type="submit" class="button pos" ng-click="vm.saveComment()">Save</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if($errors->has('markdown'))
|
@if($errors->has('markdown'))
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
@section('head')
|
|
||||||
<script src="{{ baseUrl("/libs/simplemde/simplemde.min.js") }}"></script>
|
|
||||||
@stop
|
|
||||||
<script type="text/ng-template" id="comment-list-item.html">
|
<script type="text/ng-template" id="comment-list-item.html">
|
||||||
@include('comments/list-item')
|
@include('comments/list-item')
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user