Documents in Markdown: a document can be written in Markdown with Write and Preview or in the rich text editor and switched either way, pictures pasted or dropped into the Markdown are kept as files, New Document starts in the way last used, Import Markdown Files beside Upload makes a document from each .md file, a Markdown button beside PDF downloads a document as a .md file, and Markdown pasted into a document's rich text editor goes in as formatting; versions, restore, copy and the API carry the Markdown, and the API's document create and update no longer escape values twice; database 4.2.3 adds documents.document_markdown and document_versions.document_version_markdown, and league/commonmark 2.10 and league/html-to-markdown 5.2 are added to libs/vendor through composer; 26.12.3 changelog entries

This commit is contained in:
johnnyq
2026-11-29 00:48:15 -05:00
parent a84c3eca79
commit 8b4fa5a1a0
484 changed files with 43707 additions and 63 deletions

View File

@@ -22,6 +22,7 @@ $document_id = intval($_GET['document_id'] ?? 0);
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT document_archived_at, document_client_visible, document_favorite, document_content, document_created_at,
document_description, document_folder_id, document_name, document_updated_at, document_reviewed_at, document_template_id, document_template_name,
document_template_review_months, document_template_archived_at, " . (documentReviewOwnReady() ? 'document_review_months' : 'NULL AS document_review_months') . ",
" . (documentMarkdownReady() ? 'document_markdown IS NOT NULL' : '0') . " AS document_is_markdown,
creator.user_name AS created_by_name, updater.user_name AS updated_by_name, reviewer.user_name AS reviewed_by_name
FROM documents
LEFT JOIN users creator ON document_created_by = creator.user_id
@@ -105,6 +106,7 @@ $page_title = $row['document_name'];
<?php if ($row['document_template_name'] !== null) { ?>
&middot; From template <?= $session_is_admin ? '<a class="text-reset" href="/admin/document_template.php?document_template_id=' . intval($row['document_template_id']) . '">' . escapeHtml($row['document_template_name']) . '</a>' : escapeHtml($row['document_template_name']) ?>
<?php } ?>
<?php if (intval($row['document_is_markdown'])) { ?>&middot; <span title="Edit shows the Markdown it was written in"><i class="fab fa-markdown me-1"></i>Written in Markdown</span><?php } ?>
<?php if ($versions) { ?>&middot; <a class="text-reset" href="#documentHistory"><?= count($versions) ?> earlier version<?= count($versions) === 1 ? '' : 's' ?></a><?php } ?>
</div>
</div>
@@ -125,6 +127,7 @@ $page_title = $row['document_name'];
</button>
<?php } ?>
<a class="btn btn-outline-secondary" href="post.php?export_document=<?= $document_id ?>&csrf_token=<?= $csrf ?>" title="Export as PDF"><i class="fas fa-file-pdf"></i><span class="d-none d-md-inline ms-2">PDF</span></a>
<a class="btn btn-outline-secondary" href="post.php?export_document_markdown=<?= $document_id ?>&csrf_token=<?= $csrf ?>" title="Download as a Markdown (.md) file"><i class="fab fa-markdown"></i><span class="d-none d-md-inline ms-2">Markdown</span></a>
<button type="button" class="btn btn-outline-secondary" onclick="window.print();" title="Print"><i class="fas fa-print"></i></button>
<?php if ($can_edit) { ?>
<div class="dropdown">