Skip to content

Commit

Permalink
PDF output, editor tweaks, deleted folder system etc...
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Jan 14, 2021
1 parent 9cff491 commit f993ef3
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 234 deletions.
2 changes: 1 addition & 1 deletion editor/dist/quill.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion editor/dist/quill.bundle.js.map

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions editor/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ window.addEventListener('load', () => {

provider.awareness.setLocalStateField('user', {
name: divergent_name,
color: divergent_color
color: divergent_color,
avatar: divergent_avatar
})

tippy('.ql-bold', {
Expand Down Expand Up @@ -91,7 +92,9 @@ window.addEventListener('load', () => {
tippy('.ql-clean', {
content: 'Biçimlendirmeyi Temizle'
})

tippy('.download-pdf', {
content: 'PDF Olarak Kaydet'
})

// Auto-save AJAX
let save = () => {
Expand Down Expand Up @@ -121,7 +124,9 @@ window.addEventListener('load', () => {
if (!checker) {
clearInterval(saveLoop)
saveLoop = setInterval(() => {
save()
if (document.hasFocus()) {
save()
}
}, 8000)
checker = true
}
Expand Down
21 changes: 21 additions & 0 deletions server/app/Http/Controllers/Document/PDFController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Http\Controllers\Document;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Document;
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;

class PDFController extends Controller
{
public static function renderAsHtml($documentId)
{
$document = Document::where('id', $documentId)->first();
$html = view('pdf.show', ['document' => $document])->render();

return $html;
}
}
2 changes: 1 addition & 1 deletion server/public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/public/editor/quill.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/public/editor/quill.bundle.js.map

Large diffs are not rendered by default.

82 changes: 0 additions & 82 deletions server/resources/css/app.css
Original file line number Diff line number Diff line change
@@ -1,85 +1,3 @@
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

:root {
--ck-sample-base-spacing: 2em;
--ck-sample-color-white: #fff;
--ck-sample-color-green: #279863;
--ck-sample-color-blue: #1a9aef;
--ck-sample-container-width: 1285px;
--ck-sample-sidebar-width: 350px;
--ck-sample-editor-min-height: 400px;
}

.editor__editable,
/* Classic build. */
main .ck-editor[role='application'] .ck.ck-content,
/* Decoupled document build. */
.ck.editor__editable[role='textbox'],
.ck.ck-editor__editable[role='textbox'],
/* Inline & Balloon build. */
.ck.editor[role='textbox'] {
width: 100%;
background: #fff;
font-size: 1em;
line-height: 1.6em;
min-height: var(--ck-sample-editor-min-height);
padding: 1.5em 2em;
}

.ck.ck-editor__editable {
background: #fff;
border: 1px solid hsl(0, 0%, 70%);
width: 100%;
}

.ck.ck-editor {
/* To enable toolbar wrapping. */
width: 100%;
overflow-x: hidden;
}

/* Because of sidebar `position: relative`, Edge is overriding the outline of a focused editor. */
.ck.ck-editor__editable {
position: relative;
z-index: 10;
}

/* --------- DECOUPLED (DOCUMENT) BUILD. ---------------------------------------------*/
body[data-editor='DecoupledDocumentEditor'] .document-editor__toolbar {
width: 100%;
}

body[ data-editor='DecoupledDocumentEditor'] .collaboration-demo__editable,
body[ data-editor='DecoupledDocumentEditor'] .row-editor .editor {
width: 18.5cm;
height: 100%;
min-height: 26.25cm;
padding: 1.75cm 1.5cm;
margin: 2.5rem;
border: 1px hsl(0, 0%, 82.7%) solid;
background-color: var(--ck-sample-color-white);
box-shadow: 0 0 5px hsla(0, 0%, 0%, .1);
}

body[ data-editor='DecoupledDocumentEditor'] .row-editor {
display: flex;
position: relative;
justify-content: center;
overflow-y: auto;
background-color: #f2f2f2;
border: 1px solid hsl(0, 0%, 77%);
}

body[data-editor='DecoupledDocumentEditor'] .sidebar {
background: transparent;
border: 0;
box-shadow: none;
}

.ck-toolbar {
background: #fff !important;
font-family: 'Inter', Inter !important;
border-radius: 5px;
}
19 changes: 1 addition & 18 deletions server/resources/views/livewire/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,12 @@
<ol class="list-none p-0 inline-flex">
<li class="flex items-center">
<a href="{{ route('dashboard') }}">Pano</a>
<!--<svg class="fill-current w-3 h-3 mx-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z" />
</svg>-->
</li>
<!--
<li class="flex items-center">
<a href="#">Second Level</a>
<svg class="fill-current w-3 h-3 mx-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z" />
</svg>
</li>
<li>
<a href="#" class="text-gray-500" aria-current="page">Third Level</a>
</li> -->
</ol>
</nav>
</div>

<livewire:document.create :emitTo="null" :folderId="null" />
<livewire:folder.create :emitTo="null" :folderId="null"/>

<livewire:folder.show :folders="null" :folderId="null" />
<livewire:document.show :documents="null" />
</div>
</div>
38 changes: 14 additions & 24 deletions server/resources/views/livewire/document/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,14 @@
<livewire:breadcrumb :folderId="$folderId" :documentId="$document->id" />
<div class="userlist-Dropdown float-right">
<div class="hidden sm:flex sm:items-center sm:ml-6">
<div class="relative" x-data="{ open: false }" @click.away="open = false" @close.stop="open = false">
<div @click="open = ! open">
<button
<div class="flex -space-x-1 overflow-hidden userlist">
<button
class="flex border-2 border-transparent rounded-full focus:outline-none focus:border-gray-300 transition duration-150 ease-in-out p-2 font-bold">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"></path></svg>
&nbsp;
Görüntüleyen kullanıcılar
Görüntüleyen kullanıcılar yükleniyor
</button>
</div>

<div x-show="open" x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="transform opacity-0 scale-95"
x-transition:enter-end="transform opacity-100 scale-100"
x-transition:leave="transition ease-in duration-75"
x-transition:leave-start="transform opacity-100 scale-100"
x-transition:leave-end="transform opacity-0 scale-95"
class="absolute z-50 mt-2 w-48 rounded-md shadow-lg origin-top-right right-0"
style="display: none;" @click="open = false">
<div class="rounded-md shadow-xs py-1 bg-white userlist">
Yükleniyor
</div>
</div>
</div>

</div>
</div>
<br><br>
Expand Down Expand Up @@ -81,6 +65,7 @@ class="absolute z-50 mt-2 w-48 rounded-md shadow-lg origin-top-right right-0"
</div>
<div class="ql-formats">
<button class="ql-clean"></button>
<button class="download-pdf" onclick="window.location.href='{{ route('showDocumentAsPdf', $document->id) }}'"><svg class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V7.414A2 2 0 0015.414 6L12 2.586A2 2 0 0010.586 2H6zm5 6a1 1 0 10-2 0v3.586l-1.293-1.293a1 1 0 10-1.414 1.414l3 3a1 1 0 001.414 0l3-3a1 1 0 00-1.414-1.414L11 11.586V8z" clip-rule="evenodd"></path></svg></button>
</div>
</div>
<div class="editor ql-container"></div>
Expand Down Expand Up @@ -109,6 +94,7 @@ function getRandomColor() {
// Editör cursor bilgileri
var divergent_name = "{{ auth()->user()->name }}";
var divergent_color = getRandomColor();
var divergent_avatar = "{{ auth()->user()->profile_photo_url }}";
// Quill.js dosyasına php tarafından passlamamız gereken değişkenler
var documentUUID = "{{ $document->id }}";
Expand All @@ -135,7 +121,7 @@ function isQuillEmpty() {
} else {
setTimeout(() => {
insertTextIntoEditor()
}, 2000);
}, 3000);
}
}
insertTextIntoEditor();
Expand All @@ -147,16 +133,20 @@ function getUserList() {
let userList = providerInstance.awareness.getStates().entries()
userList = [...userList]
userList.forEach(function (elem) {
$(".userlist").append(`<a style="background-color: ${elem[1].user.color}" class="block px-4 py-2 text-sm leading-5 text-white focus:outline-none"
href="#">${elem[1].user.name}</a>`)
$(".userlist").append(
`<img class="inline-block h-8 w-8 rounded-full ring-2 ring-white" src="${elem[1].user.avatar}" alt="${elem[1].user.name}">`
)
})
setInterval(() => {
getUserList();
if (document.hasFocus())
{
getUserList();
}
}, 8000);
} else {
setTimeout(() => {
getUserList();
}, 2000);
}, 3000);
}
}
getUserList();
Expand Down
32 changes: 0 additions & 32 deletions server/resources/views/livewire/folder/create.blade.php

This file was deleted.

40 changes: 0 additions & 40 deletions server/resources/views/livewire/folder/list-contents.blade.php

This file was deleted.

26 changes: 0 additions & 26 deletions server/resources/views/livewire/folder/show.blade.php

This file was deleted.

38 changes: 38 additions & 0 deletions server/resources/views/pdf/show.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="tr">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ $document->name }}</title>
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<!-- Styles -->
<link rel="stylesheet" href="http://127.0.0.1:8000/css/app.css">
</head>

<body class="font-sans antialiased py-0">
<div class="py-0">
<div style="max-width: 21cm;">
<div class="w-full">
<div id="full-container">
<div class="editor ql-container ql-editor" style="margin:0;box-shadow:none;border:0!important;padding:0;width:auto;">{!! $document->content !!}</div>
</div>
</div>

</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Quill editörü gereksinimleri -->
<script src="{{ asset('editor/highlight.min.js') }}" type="text/javascript"></script>
<link href="{{ asset('editor/quill.css') }}" rel="stylesheet">
<script>
setTimeout(() => {
alert("Çıkan yazdırma ekranında PDF olarak kaydet seçeneğini seçiniz.");
window.print();
window.history.back();
}, 1000);
</script>
</body>

</html>
Loading

0 comments on commit f993ef3

Please sign in to comment.