Skip to content

Commit

Permalink
Add editor to new comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cwetanow committed May 23, 2017
1 parent e79d07f commit 4ed8789
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions src/Logs.Web/Views/Shared/_CommentBoxPartial.cshtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
@model Logs.Web.Models.Entries.NewCommentViewModel

<script src="~/Scripts/ckeditor/ckeditor.js"></script>

@using (Html.BeginForm("Comment", "Comment", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.TextAreaFor(m => m.Content, new { @class = "form-control", rows = 20 });
@Html.TextAreaFor(m => m.Content, new { @class = "form-control", rows = 20, @id = "my-editor" });
@Html.HiddenFor(m => m.LogId)
@Html.ValidationSummary()
<input type="submit" class="btn btn-primary" id="submit" value="Submit" />
}
}

<script>
CKEDITOR.replace("my-editor", {
toolbar: [
{ name: 'clipboard', groups: ['clipboard', 'undo'], items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
{ name: 'editing', groups: ['find', 'selection', 'spellchecker'], items: ['Find', 'Replace', '-', 'SelectAll'] },
'/',
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup'], items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
{ name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi'], items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language'] },
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
{ name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley'] },
'/',
{ name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] },
{ name: 'colors', items: ['TextColor', 'BGColor'] },
{ name: 'tools', items: ['Maximize', 'ShowBlocks'] }
]
}
)
</script>
2 changes: 1 addition & 1 deletion src/Logs.Web/Views/Shared/_CommentPartial.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<small>@string.Format(Logs.Common.Constants.ShortDateFormat, Model.Date)</small>
</h4>
<span id="@($"comment{Model.CommentId}")">
@Html.Raw("<pre>" + Html.Encode(Model.Content) + "</pre>")
@Html.Raw(Model.Content)
</span>
@if (Model.CanEdit)
{
Expand Down

0 comments on commit 4ed8789

Please sign in to comment.