finish line!

This commit is contained in:
2025-11-26 17:25:27 +08:00
parent 833d125f64
commit 14434bc2ac
261 changed files with 4530 additions and 1014 deletions
+23 -32
View File
@@ -1,5 +1,4 @@
<?php
// views/chapters/create.php
include 'views/layouts/header.php';
?>
@@ -13,7 +12,7 @@ include 'views/layouts/header.php';
<form method="post" id="chapter-form">
<input type="hidden" name="csrf_token" value="<?= generate_csrf_token() ?>">
<div style="margin-bottom: 1rem;">
<label for="title" style="display: block; margin-bottom: 0.5rem; font-weight: bold;">
Название главы *
@@ -23,14 +22,19 @@ include 'views/layouts/header.php';
placeholder="Введите название главы"
style="width: 100%; margin-bottom: 1.5rem;"
required>
<label for="content" style="display: block; margin-bottom: 0.5rem; font-weight: bold;">
Содержание главы *
</label>
<textarea id="content" name="content" class="writer-editor" style="display: none;">
<?= e($_POST['content'] ?? '') ?>
</textarea>
<!-- Контейнер Quill -->
<div id="quill-editor"
class="writer-editor-container"
style="height:500px;"
data-content="<?= htmlspecialchars($_POST['content'] ?? '', ENT_QUOTES) ?>">
</div>
<!-- Скрытый textarea для формы -->
<textarea id="content" name="content" style="display:none;"><?= e($_POST['content'] ?? '') ?></textarea>
<div style="margin-top: 1rem;">
<label for="status" style="display: block; margin-bottom: 0.5rem; font-weight: bold;">
Статус главы
@@ -44,63 +48,50 @@ include 'views/layouts/header.php';
</small>
</div>
</div>
<div style="display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1.5rem;">
<button type="submit" class="contrast">
💾 Сохранить главу
</button>
<button type="button" onclick="previewChapter()" class="secondary">
👁️ Предпросмотр
</button>
<a href="<?= SITE_URL ?>/books/<?= $book['id'] ?>/chapters" role="button" class="secondary">
❌ Отмена
</a>
<button type="submit" class="contrast">💾 Сохранить главу</button>
<button type="button" onclick="previewChapter()" class="secondary">👁️ Предпросмотр</button>
<a href="<?= SITE_URL ?>/books/<?= $book['id'] ?>/chapters" role="button" class="secondary">❌ Отмена</a>
</div>
</form>
<link href="/assets/css/quill_reset.css" rel="stylesheet">
<script>
function previewChapter() {
const form = document.getElementById('chapter-form');
const formData = new FormData(form);
// Создаем временную форму для предпросмотра
const tempForm = document.createElement('form');
tempForm.method = 'POST';
tempForm.action = '<?= SITE_URL ?>/chapters/preview';
tempForm.target = '_blank';
tempForm.style.display = 'none';
// Добавляем CSRF токен
const csrfInput = document.createElement('input');
csrfInput.name = 'csrf_token';
csrfInput.value = '<?= generate_csrf_token() ?>';
tempForm.appendChild(csrfInput);
// Добавляем контент
const contentInput = document.createElement('input');
contentInput.name = 'content';
contentInput.value = document.getElementById('content').value;
tempForm.appendChild(contentInput);
// Добавляем заголовок
const titleInput = document.createElement('input');
titleInput.name = 'title';
titleInput.value = document.getElementById('title').value || 'Предпросмотр главы';
tempForm.appendChild(titleInput);
// Добавляем тип редактора
const editorTypeInput = document.createElement('input');
editorTypeInput.name = 'editor_type';
editorTypeInput.value = '<?= $book['editor_type'] ?? 'markdown' ?>';
tempForm.appendChild(editorTypeInput);
document.body.appendChild(tempForm);
tempForm.submit();
document.body.removeChild(tempForm);
}
</script>
<script src="/assets/js/editor.js"></script>
<script src="/assets/js/autosave.js"></script>
<?php include 'views/layouts/footer.php'; ?>
<?php include 'views/layouts/footer.php'; ?>