Document editor reads like the document page: New Document and the edit page show what it says with the page's typography in the editor and in Markdown Preview, a document toolbar matching the Markdown one with headings, strikethrough, quote, code block, table and line, a taller New Document editor, and Ctrl+S to save on the edit page; other editors unchanged; 26.12.3 changelog entries

This commit is contained in:
johnnyq
2026-11-29 14:27:23 -05:00
parent 85c151eec8
commit 626f472990
5 changed files with 106 additions and 20 deletions

View File

@@ -6,7 +6,8 @@
* edit_document; saving keeps what it said before as a version and goes back to the document.
*
* The editor is .tinymce-page (js/app.js): as tall as the window, with its toolbar always in
* view. Leaving with changes unsaved asks first - js/app.js does that for any editor on a page.
* view, and what it says as it will read on the document's page. Ctrl+S saves. Leaving with
* changes unsaved asks first - js/app.js does that for any editor on a page.
*/
require_once "includes/inc_all_client.php";
@@ -57,7 +58,7 @@ $page_title = 'Editing ' . $row['document_name'];
<div class="card mb-3">
<div class="card-header d-flex flex-wrap align-items-center gap-2">
<h3 class="card-title mb-0 me-auto text-truncate"><i class="fas fa-fw fa-edit me-2"></i>Editing <strong><?= $document_name ?></strong></h3>
<button type="submit" name="edit_document" class="btn btn-primary fw-bold"><i class="fas fa-check me-2"></i>Save</button>
<button type="submit" name="edit_document" class="btn btn-primary fw-bold" title="Save (Ctrl+S)"><i class="fas fa-check me-2"></i>Save</button>
<a class="btn btn-light border" href="document.php?client_id=<?= $client_id ?>&document_id=<?= $document_id ?>"><i class="fas fa-times me-2"></i>Cancel</a>
</div>
<div class="card-body itflow-document-page-form">
@@ -65,22 +66,32 @@ $page_title = 'Editing ' . $row['document_name'];
// The page's own editor, not the window's
ob_start();
require 'modals/document/document_form.php';
echo str_replace('class="form-control tinymce"', 'class="form-control tinymce-page"', ob_get_clean());
echo str_replace('class="form-control tinymce-document"', 'class="form-control tinymce-page"', ob_get_clean());
?>
</div>
</div>
</form>
<script>
// Saving is not leaving with changes unsaved - the editor is marked clean as the form goes
document.querySelector('form[data-document-page-form]').addEventListener('submit', function () {
if (window.tinymce) {
tinymce.get().forEach(function (editor) {
editor.save();
editor.setDirty(false);
});
}
});
(function () {
var form = document.querySelector('form[data-document-page-form]');
// Saving is not leaving with changes unsaved - the editor is marked clean as the form goes
form.addEventListener('submit', function () {
if (window.tinymce) {
tinymce.get().forEach(function (editor) {
editor.save();
editor.setDirty(false);
});
}
});
// Ctrl+S saves from the fields and the Markdown box - the rich text editor has its own (js/app.js)
document.addEventListener('keydown', function (e) {
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === 's') {
e.preventDefault();
form.requestSubmit(form.querySelector('button[name="edit_document"]'));
}
});
})();
</script>
<?php