blob: 901b300444260554511993732d2e504711cc9fd9 [file] [log] [blame]
{@eu.mulk.mulkcms2.benki.wiki.WikiPageRevision page}
{#include base.html}
{#title}{page.title} — Benki Wiki{/title}
{#head}
<link rel="stylesheet" type="text/css" href="/web_modules/ContentTools/build/content-tools.min.css" />
<script type="module">
import {ContentTools} from "/web_modules/ContentTools.js";
window.addEventListener('DOMContentLoaded', function() {
let editor = ContentTools.EditorApp.get();
editor.init('*[data-editable]', 'data-name');
editor.addEventListener('saved', async function (ev) {
let regions = ev.detail().regions;
if (Object.getOwnPropertyNames(regions).length === 0) {
// Nothing changed.
return;
}
this.busy(true);
let requestParams = new URLSearchParams();
for (let name of Object.getOwnPropertyNames(regions)) {
requestParams.append(name, regions[name]);
}
let response = await fetch("/wiki/{page.title}", {
method: 'POST',
body: requestParams
});
this.busy(false);
});
});
</script>
{/head}
{#body}
<article id="wiki-page">
<header>
<div data-editable data-name="wiki-title">
<h1>{page.title}</h1>
</div>
</header>
<main>
<div data-editable data-name="wiki-content">
{#with page}{enrichedContent.raw}{/}
</div>
</main>
<hr>
<footer>
<a href="/wiki/{page.title}/revisions">Page revisions</a>
</footer>
</article>
{/body}
{/include}