Ekapp/skolehjem/resources/views/admin/news/edit.blade.php

70 lines
2.3 KiB
PHP

@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Nyhed - Rediger
@endsection
@section("path")
<a href="{{route('news.edit', ['news' => $news])}}" class="text-white">Rediger nyhed</a> /
@endsection
@section("content")
<style>
#editor {
margin-bottom: 1rem;
}
</style>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<h1>Rediger nyhed:</h1>
<form method="post" action="{{route("news.update", ["news" => $news])}}">
@csrf
@method("PUT")
<label for="title">Navn</label>
<input value="{{$news->name}}" type="text" name="subname" id="title" required>
<div id="editor">{!! $news->content !!}</div>
<textarea name="content" class="d-none" id="hiddenArea"></textarea>
<input type="submit" class="btn btn-dark text-white" value="Rediger">
</form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script>
var container = document.getElementById("editor");
var fullEditor = new Quill(container, {
modules: {
'toolbar': [
[ 'bold', 'italic', 'underline', 'strike' ],
[{ 'color': [] }],
[{ 'script': 'super' }, { 'script': 'sub' }],
[{ 'header': '1' }, { 'header': '2' }, 'blockquote' ],
[{ 'list': 'ordered' }, { 'list': 'bullet'}, { 'indent': '-1' }, { 'indent': '+1' }],
[ {'direction': 'rtl'}, { 'align': [] }],
[ 'link' ],
[ 'clean' ]
],
},
theme: 'snow'
});
</script>
<script>
var form = document.querySelector('form');
form.onsubmit = function() {
var myEditor = document.getElementById('editor');
var html = myEditor.children[0].innerHTML;
document.getElementById('hiddenArea').innerText = html;
}
</script>
@endsection
@section("scripts")
<script>
$(function() {
$('form').areYouSure(
{
message: 'It looks like you have been editing something. '
+ 'If you leave before saving, your changes will be lost.'
}
);
});
</script>
@endsection