Remove quilljs from admin page editor, fixes #3616

This commit is contained in:
Daniel Supernault 2022-08-15 20:32:17 -06:00
parent dc3a16161b
commit 75fbd373c8
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 122 additions and 114 deletions

View file

@ -80,7 +80,7 @@ class SiteController extends Controller
{ {
$page = Cache::remember('site:privacy', now()->addDays(120), function() { $page = Cache::remember('site:privacy', now()->addDays(120), function() {
$slug = '/site/privacy'; $slug = '/site/privacy';
$page = Page::whereSlug($slug)->whereActive(true)->first(); return Page::whereSlug($slug)->whereActive(true)->first();
}); });
return View::make('site.privacy')->with(compact('page'))->render(); return View::make('site.privacy')->with(compact('page'))->render();
} }

View file

@ -1,27 +1,36 @@
@extends('admin.partial.template') @extends('admin.partial.template-full')
@include('admin.settings.sidebar')
@section('section') @section('section')
<div class="title">
<h3 class="font-weight-bold">Edit Page</h3>
<p class="lead">{{$page->slug}}</p>
</div> </div>
<hr> <div class="header bg-primary pb-3 mt-n4">
<div class="container-fluid">
<div> <div class="header-body">
<div class="row align-items-center py-4">
<div class="col-lg-6 col-7">
<p class="display-1 text-white">Edit Page</p>
<p class="lead text-white mt-n4 mb-0">{{$page->slug}}</p>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid mt-4">
<input type="hidden" id="slug" name="slug" value="{{$page->slug}}"> <input type="hidden" id="slug" name="slug" value="{{$page->slug}}">
<input class="form-control form-control-lg" id="title" name="title" placeholder="Title"> <input class="form-control form-control-lg" id="title" name="title" placeholder="Title">
<p class="small text-muted"> <p class="small text-muted">
Page URL: <span class="page-url font-weight-bold">{{$page->url()}}</span> Page URL: <span class="page-url font-weight-bold">{{$page->url()}}</span>
{{-- <span class="pl-1"><a href="#" class="font-weight-bold">Edit</a></span> --}} {{-- <span class="pl-1"><a href="#" class="font-weight-bold">Edit</a></span> --}}
</p> </p>
<div id="editor" style="height: 400px"> <div id="editor" class="d-none" style="height: 400px">
{!!$page->content!!} {!!$page->content!!}
</div> </div>
<div id="rawEditor" style="height: 400px">
<label class="font-weight-bold">Raw HTML</label>
<textarea class="form-control" rows="8" id="rawText" v-pre>{{$page->content}}</textarea>
</div>
<div class="mt-3 d-flex justify-content-between"> <div class="mt-3 d-flex justify-content-between">
<div> <div>
<div class="custom-control custom-switch d-inline pr-3"> <div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="activeSwitch" {{$page->active?'checked="true"':''}}> <input type="checkbox" class="custom-control-input" id="activeSwitch" {{$page->active?'checked="true"':''}}>
<label class="custom-control-label font-weight-bold" for="activeSwitch">Active</label> <label class="custom-control-label font-weight-bold" for="activeSwitch">Active</label>
</div> </div>
@ -34,37 +43,37 @@
</div> </div>
</div> </div>
</div> </div>
</div>
@endsection @endsection
@push('styles') @push('styles')
<link rel="stylesheet" href="{{mix('css/quill.css')}}"/>
<style type="text/css"> <style type="text/css">
.ql-container { .ql-container {
box-sizing: border-box; box-sizing: border-box;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI", font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
Roboto,Helvetica,Arial,sans-serif;
font-size: 16px; font-size: 16px;
height: 100%; height: 100%;
margin: 0px; margin: 0px;
position: relative; position: relative;
} }
.custom-control {
padding-left: 3.5rem;
}
</style> </style>
@endpush @endpush
@push('scripts') @push('scripts')
<script src="{{mix('js/quill.js')}}"></script>
<script> <script>
window.editor = new Quill('#editor', { window.useRaw = true;
theme: 'snow'
});
$('.btn-save').on('click', function(e) { $('.btn-save').on('click', function(e) {
e.preventDefault(); e.preventDefault();
let confirm = window.confirm('Are you sure you want to save this page?'); let confirm = window.confirm('Are you sure you want to save this page?');
if(confirm !== true) { if(confirm !== true) {
return; return;
} }
let html = editor.container.firstChild.innerHTML; let html = window.useRaw ?
$('#rawText').val() :
editor.root.innerHTML;
let title = $('#title').val(); let title = $('#title').val();
let active = $('#activeSwitch')[0].checked; let active = $('#activeSwitch')[0].checked;
axios.post(window.location.href, { axios.post(window.location.href, {

View file

@ -1,11 +1,56 @@
@extends('admin.partial.template-full') @extends('admin.partial.template-full')
@section('section') @section('section')
<div class="title">
<h3 class="font-weight-bold">Pages</h3>
<p class="lead">Set custom page content</p>
</div> </div>
<div class="header bg-primary pb-3 mt-n4">
<div class="container-fluid">
<div class="header-body">
<div class="row align-items-center py-4">
<div class="col-lg-6 col-7">
<p class="display-1 text-white">Pages</p>
<p class="lead text-white mt-n4 mb-0">Manage public and custom page content</p>
</div>
@if($pages->count() < 4)
<div class="col-12">
<hr> <hr>
<div class="btn-group">
@if(!$pages->contains('slug', '=', '/site/about'))
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="about">
<button type="submit" class="btn btn-default font-weight-bold">Customize About Page</button>
</form>
@endif
@if(!$pages->contains('slug', '=', '/site/privacy'))
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="privacy">
<button type="submit" class="btn btn-default font-weight-bold">Customize Privacy Page</button>
</form>
@endif
@if(!$pages->contains('slug', '=', '/site/terms'))
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="terms">
<button type="submit" class="btn btn-default font-weight-bold">Customize Terms Page</button>
</form>
@endif
@if(!$pages->contains('slug', '=', '/site/kb/community-guidelines'))
<form class="form-inline" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="community_guidelines">
<button type="submit" class="btn btn-default font-weight-bold">Customize Guidelines Page</button>
</form>
@endif
</div>
</div>
@endif
</div>
</div>
</div>
</div>
<div class="container-fluid mt-4">
@if($pages->count()) @if($pages->count())
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <table class="table">
@ -46,57 +91,11 @@
<div class="d-flex justify-content-center mt-5 small"> <div class="d-flex justify-content-center mt-5 small">
{{$pages->links()}} {{$pages->links()}}
</div> </div>
<hr>
<div class="btn-group">
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="about">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create About</button>
</form>
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="privacy">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create Privacy</button>
</form>
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="terms">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create Terms</button>
</form>
<form class="form-inline" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="community_guidelines">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create Guidelines</button>
</form>
</div>
@else @else
<div class="card bg-light shadow-none rounded-0"> <div class="card border shadow-none rounded-0">
<div class="card-body text-center"> <div class="card-body text-center">
<p class="lead text-muted font-weight-bold py-5 mb-0">No custom pages found</p> <p class="lead text-muted font-weight-bold py-5">No custom pages found</p>
</div> </div>
</div> </div>
<hr>
<div class="btn-group">
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="about">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create About</button>
</form>
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="privacy">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create Privacy</button>
</form>
<form class="form-inline mr-1" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="terms">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create Terms</button>
</form>
<form class="form-inline" method="post" action="/i/admin/settings/pages/create">
@csrf
<input type="hidden" name="page" value="community_guidelines">
<button type="submit" class="btn btn-outline-secondary font-weight-bold">Create Guidelines</button>
</form>
</div>
@endif @endif
@endsection @endsection