diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-01-27 05:53:07 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-01-27 05:53:07 +0100 |
commit | d50bbb75b8018be054b840cbae6b8e0c48b514ea (patch) | |
tree | 86d275cffe723ae04ec6d1bf92888b7ee10d4951 /src/main/resources/templates/benki/wiki | |
parent | 0246c3e491685e7e3169615c526d627ed989f353 (diff) |
Wiki: Make editing work.
Change-Id: Ibff52be5c595deba96b3f7642307ba1208eff9cf
Diffstat (limited to 'src/main/resources/templates/benki/wiki')
-rw-r--r-- | src/main/resources/templates/benki/wiki/wikiPage.html | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/main/resources/templates/benki/wiki/wikiPage.html b/src/main/resources/templates/benki/wiki/wikiPage.html index 8ca34e7..f9f5214 100644 --- a/src/main/resources/templates/benki/wiki/wikiPage.html +++ b/src/main/resources/templates/benki/wiki/wikiPage.html @@ -11,6 +11,26 @@ 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]); + } + + var response = await fetch("/wiki/{page.title}", { + method: 'POST', + body: requestParams + }); + this.busy(false); + }); }); </script> {/head} @@ -18,11 +38,13 @@ {#body} <article id="wiki-page"> <header> - <h1>{page.title}</h1> + <div data-editable data-name="wiki-title"> + <h1>{page.title}</h1> + </div> </header> <main> - <div data-editable data-name="main-content"> + <div data-editable data-name="wiki-content"> {#with page}{content.raw}{/} </div> </main> |