/* * Documents written in Markdown (agent/modals/document/document_form.php, functions/markdown.php). * * A document's form has both editors - the rich text one (TinyMCE, js/app.js) and a plain box for * Markdown with Write and Preview - and shows the one it is written in. The Markdown box has a * toolbar like the rich text editor's (headings, bold, italic, struck, link, lists, checklist, * quote, code, table, line, picture), Ctrl+B, Ctrl+I and Ctrl+K, and Enter in a list starts the * next item. Switching converts what is * written into the other, through agent/ajax.php, so nothing has to be typed again; switching to * Markdown says when some of it stays as HTML, or alignment was dropped. * * A picture pasted or dropped into the Markdown box goes in as ![Pasted image 1](pasted:1), with * the picture itself held here - put back as its data for Preview and when the form is saved, * where it becomes a file of the document's (markdownSaveImages()). * * New Document starts in the way the agent wrote last (data-format-remember, kept in this * browser). On a page of its own, leaving with the Markdown changed asks first, as leaving with * the rich text editor changed does. * * Markdown pasted into a document's rich text editor - copied from GitHub's source view, VS Code, * Obsidian, an AI chat - goes in formatted. Ctrl+Shift+V pastes it as it is. * * Loaded on every agent page (includes/footer.php), once - and on New Document in the client * portal (client/includes/footer.php), which turns Markdown into HTML at client/post.php. */ (function () { 'use strict'; if (window.itflowDocumentFormat) { return; } var REMEMBER = 'itflow.documentFormat'; // Where Markdown is turned into HTML and back - agent/ajax.php, or in the client portal the // address its