| 1 | <%
|
|---|
| 2 | // Post editor — split into card sections for visual hierarchy:
|
|---|
| 3 | // - Identity : title, slug, excerpt
|
|---|
| 4 | // - Cover : thumbnail + URL + custom upload button
|
|---|
| 5 | // - Content : markdown textarea with attached toolbar
|
|---|
| 6 | // - Meta : status, type, pin, noindex, tags
|
|---|
| 7 | //
|
|---|
| 8 | // All behavior (IDs, names, upload endpoints) is preserved — only layout
|
|---|
| 9 | // and styling changed.
|
|---|
| 10 | const _hasCover = !!post.cover_image_url;
|
|---|
| 11 | // In hub-modus moeten save/create/cancel de /user/<slug>/-prefix dragen, anders
|
|---|
| 12 | // valt de request terug op de primaire site (siteUrlBase leeg) en rendert de
|
|---|
| 13 | // post na opslaan headerless (bareChrome). In solo is _base leeg.
|
|---|
| 14 | const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
|
|---|
| 15 | %>
|
|---|
| 16 | <div class="container post-edit-page">
|
|---|
| 17 | <h1><%= isNew ? 'Nieuwe post' : 'Post bewerken' %></h1>
|
|---|
| 18 |
|
|---|
| 19 | <form method="post" action="<%= _base %><%= isNew ? '/posts/create' : '/posts/' + post.slug + '/save' %>" class="post-edit-form">
|
|---|
| 20 |
|
|---|
| 21 | <%# ── IDENTITY ─────────────────────────────────────────────── %>
|
|---|
| 22 | <section class="pe-card">
|
|---|
| 23 | <label class="pe-field">
|
|---|
| 24 | <span>Titel</span>
|
|---|
| 25 | <input type="text" name="title" value="<%= post.title %>" required>
|
|---|
| 26 | </label>
|
|---|
| 27 | <div class="pe-row pe-row-2">
|
|---|
| 28 | <label class="pe-field">
|
|---|
| 29 | <span>Slug (URL)</span>
|
|---|
| 30 | <input type="text" name="slug" value="<%= post.slug %>" placeholder="auto van titel als leeg">
|
|---|
| 31 | </label>
|
|---|
| 32 | <label class="pe-field">
|
|---|
| 33 | <span>Tags <small>(komma-gescheiden)</small></span>
|
|---|
| 34 | <input type="text" name="tags" value="<%= Array.isArray(post.tags) ? post.tags.join(', ') : '' %>">
|
|---|
| 35 | </label>
|
|---|
| 36 | </div>
|
|---|
| 37 | <label class="pe-field">
|
|---|
| 38 | <span>Excerpt <small>(preview tekst)</small></span>
|
|---|
| 39 | <textarea name="excerpt" rows="2"><%= post.excerpt %></textarea>
|
|---|
| 40 | <small class="pe-hint" style="opacity:.7">Wordt ook gebruikt als samenvatting in <strong>Cirkels</strong> (andere sites die je post tonen). Leeg laten = begin van de post.</small>
|
|---|
| 41 | </label>
|
|---|
| 42 | </section>
|
|---|
| 43 |
|
|---|
| 44 | <%# ── COVER ────────────────────────────────────────────────── %>
|
|---|
| 45 | <section class="pe-card">
|
|---|
| 46 | <div class="pe-section-title">Cover</div>
|
|---|
| 47 | <div class="pe-cover-row">
|
|---|
| 48 | <div class="pe-cover-thumb" id="cover-preview-wrap" <%= _hasCover ? '' : 'data-empty' %>>
|
|---|
| 49 | <img src="<%= _hasCover ? post.cover_image_url : '' %>" alt="" id="cover-preview-img" <%= _hasCover ? '' : 'hidden' %>>
|
|---|
| 50 | <% if (!_hasCover) { %><span class="pe-cover-empty">🖼</span><% } %>
|
|---|
| 51 | </div>
|
|---|
| 52 | <div class="pe-cover-actions">
|
|---|
| 53 | <label class="pe-field">
|
|---|
| 54 | <span>Cover URL</span>
|
|---|
| 55 | <input type="text" name="cover_image_url" id="cover-url-field"
|
|---|
| 56 | value="<%= post.cover_image_url || '' %>"
|
|---|
| 57 | inputmode="url" autocapitalize="none" spellcheck="false"
|
|---|
| 58 | placeholder="/media/… of https://… (of upload met de knop)">
|
|---|
| 59 | </label>
|
|---|
| 60 | <div class="pe-cover-upload">
|
|---|
| 61 | <button type="button" class="pe-btn pe-btn-secondary" id="cover-upload-trigger">
|
|---|
| 62 | 📷 Upload nieuwe cover
|
|---|
| 63 | </button>
|
|---|
| 64 | <input type="file" id="cover-upload-field" accept="image/jpeg,image/png,image/webp,image/gif" hidden>
|
|---|
| 65 | <small id="cover-upload-status" class="pe-status"></small>
|
|---|
| 66 | </div>
|
|---|
| 67 | </div>
|
|---|
| 68 | </div>
|
|---|
| 69 | </section>
|
|---|
| 70 |
|
|---|
| 71 | <%# ── CONTENT ──────────────────────────────────────────────── %>
|
|---|
| 72 | <section class="pe-card pe-card-content">
|
|---|
| 73 | <div class="pe-section-title">
|
|---|
| 74 | Content
|
|---|
| 75 | <small>Sleep een afbeelding om in te voegen · selecteer tekst om op te maken</small>
|
|---|
| 76 | </div>
|
|---|
| 77 | <div class="pe-editor-frame">
|
|---|
| 78 | <div class="pe-toolbar" id="pe-toolbar" role="toolbar" aria-label="Format">
|
|---|
| 79 | <button type="button" data-cmd="bold" title="Vet (Ctrl+B)" aria-label="Vet">
|
|---|
| 80 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4h8a4 4 0 0 1 0 8H6z"/><path d="M6 12h9a4 4 0 0 1 0 8H6z"/></svg>
|
|---|
| 81 | </button>
|
|---|
| 82 | <button type="button" data-cmd="italic" title="Cursief (Ctrl+I)" aria-label="Cursief">
|
|---|
| 83 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>
|
|---|
| 84 | </button>
|
|---|
| 85 | <button type="button" data-cmd="underline" title="Onderstreept" aria-label="Onderstreept">
|
|---|
| 86 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v6a6 6 0 0 0 12 0V4"/><line x1="4" y1="20" x2="20" y2="20"/></svg>
|
|---|
| 87 | </button>
|
|---|
| 88 | <span class="pe-toolbar-sep" aria-hidden="true"></span>
|
|---|
| 89 | <button type="button" class="pe-tb-text" data-cmd="formatBlock" data-arg="h2" title="Kop">H2</button>
|
|---|
| 90 | <button type="button" class="pe-tb-text" data-cmd="formatBlock" data-arg="h3" title="Subkop">H3</button>
|
|---|
| 91 | <button type="button" class="pe-tb-text" data-cmd="formatBlock" data-arg="p" title="Paragraaf">¶</button>
|
|---|
| 92 | <span class="pe-toolbar-sep" aria-hidden="true"></span>
|
|---|
| 93 | <button type="button" data-cmd="insertUnorderedList" title="Lijst" aria-label="Lijst">
|
|---|
| 94 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4.5" cy="6" r="1.2"/><circle cx="4.5" cy="12" r="1.2"/><circle cx="4.5" cy="18" r="1.2"/></svg>
|
|---|
| 95 | </button>
|
|---|
| 96 | <button type="button" data-cmd="insertOrderedList" title="Genummerde lijst" aria-label="Genummerde lijst">
|
|---|
| 97 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>
|
|---|
| 98 | </button>
|
|---|
| 99 | <button type="button" data-cmd="formatBlock" data-arg="blockquote" title="Quote" aria-label="Quote">
|
|---|
| 100 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2H4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h2.5C6 17.5 4 19 3 19v2z"/><path d="M14 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2h-4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h2.5c-.5 4.5-2.5 6-3.5 6v2z"/></svg>
|
|---|
| 101 | </button>
|
|---|
| 102 | <button type="button" data-cmd="link-prompt" title="Link (Ctrl+K)" aria-label="Link">
|
|---|
| 103 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
|
|---|
| 104 | </button>
|
|---|
| 105 | <button type="button" data-cmd="code-wrap" title="Code (inline)" aria-label="Code">
|
|---|
| 106 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
|
|---|
| 107 | </button>
|
|---|
| 108 | <span class="pe-toolbar-sep" aria-hidden="true"></span>
|
|---|
| 109 | <button type="button" id="insert-image-btn" title="Afbeelding invoegen" aria-label="Afbeelding">
|
|---|
| 110 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M21 15l-5-5L5 21"/></svg>
|
|---|
| 111 | </button>
|
|---|
| 112 | <button type="button" id="insert-track-btn" title="Track invoegen" aria-label="Track">
|
|---|
| 113 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
|
|---|
| 114 | </button>
|
|---|
| 115 | <button type="button" id="insert-playlist-btn" title="Playlist invoegen" aria-label="Playlist">
|
|---|
| 116 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="15" y2="18"/><polygon points="3 5 3 13 9 9"/></svg>
|
|---|
| 117 | </button>
|
|---|
| 118 | <button type="button" id="insert-embed-btn" title="Embed (YouTube, Spotify, SoundCloud, Vimeo…)" aria-label="Media embedden">
|
|---|
| 119 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="4" width="20" height="16" rx="2"/><polygon points="10 9 15.5 12 10 15"/></svg>
|
|---|
| 120 | </button>
|
|---|
| 121 | <span class="pe-toolbar-spacer"></span>
|
|---|
| 122 | <button type="button" data-cmd="removeFormat" title="Wis opmaak" aria-label="Wis opmaak">
|
|---|
| 123 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M5 5l14 14" stroke-linecap="round"/></svg>
|
|---|
| 124 | </button>
|
|---|
| 125 | <button type="button" id="pe-fullscreen-btn" title="Volledig scherm" aria-label="Volledig scherm" aria-pressed="false">
|
|---|
| 126 | <svg class="fs-icon-expand" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>
|
|---|
| 127 | <svg class="fs-icon-compress" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/></svg>
|
|---|
| 128 | </button>
|
|---|
| 129 | </div>
|
|---|
| 130 |
|
|---|
| 131 | <div id="content-editor"
|
|---|
| 132 | class="pe-editor"
|
|---|
| 133 | contenteditable="true"
|
|---|
| 134 | role="textbox"
|
|---|
| 135 | aria-multiline="true"
|
|---|
| 136 | aria-label="Content"
|
|---|
| 137 | data-placeholder="Begin met schrijven…"></div>
|
|---|
| 138 |
|
|---|
| 139 | <%# Sticky "tik om te bewerken"-hint (alleen zichtbaar op touch + niet-fullscreen
|
|---|
| 140 | via CSS). Puur visueel (pointer-events:none); de tik op het veld opent fullscreen. %>
|
|---|
| 141 | <div class="pe-edit-hint" aria-hidden="true">✎ Tik om te bewerken</div>
|
|---|
| 142 |
|
|---|
| 143 | <%# Hidden field is what actually submits to the server. The visible
|
|---|
| 144 | contenteditable's serialized HTML is copied here on submit. %>
|
|---|
| 145 | <input type="hidden" name="content" id="content-hidden" value="">
|
|---|
| 146 |
|
|---|
| 147 | <%# Initial content is injected as a JSON string in a script tag so we
|
|---|
| 148 | can set innerHTML safely from JS. EJS-escaping HTML directly into
|
|---|
| 149 | the editor would render entity-escaped tags as text. %>
|
|---|
| 150 | <script id="initial-content" type="application/json"><%- JSON.stringify(post.content || '').replace(/</g, '\\u003c') %></script>
|
|---|
| 151 |
|
|---|
| 152 | <div class="pe-editor-status">
|
|---|
| 153 | <small id="content-upload-status" class="pe-status"></small>
|
|---|
| 154 | <span class="pe-char-count"><span id="char-count">0</span> tekens</span>
|
|---|
| 155 | </div>
|
|---|
| 156 |
|
|---|
| 157 | <input type="file" id="content-upload-field" accept="image/jpeg,image/png,image/webp,image/gif" hidden>
|
|---|
| 158 | </div>
|
|---|
| 159 | </section>
|
|---|
| 160 |
|
|---|
| 161 | <%# ── META ─────────────────────────────────────────────────── %>
|
|---|
| 162 | <section class="pe-card">
|
|---|
| 163 | <div class="pe-section-title">Publicatie</div>
|
|---|
| 164 | <div class="pe-row pe-row-2">
|
|---|
| 165 | <label class="pe-field">
|
|---|
| 166 | <span>Status</span>
|
|---|
| 167 | <% var _st = isNew ? 'published' : (post.status || 'draft'); %>
|
|---|
| 168 | <select name="status">
|
|---|
| 169 | <option value="published" <%= _st === 'published' ? 'selected' : '' %>>Gepubliceerd</option>
|
|---|
| 170 | <option value="draft" <%= _st === 'draft' ? 'selected' : '' %>>Concept</option>
|
|---|
| 171 | <option value="archived" <%= _st === 'archived' ? 'selected' : '' %>>Gearchiveerd</option>
|
|---|
| 172 | </select>
|
|---|
| 173 | </label>
|
|---|
| 174 | <label class="pe-field">
|
|---|
| 175 | <span>Type</span>
|
|---|
| 176 | <select name="type">
|
|---|
| 177 | <% var ptype = post.type || 'post'; %>
|
|---|
| 178 | <option value="post" <%= ptype === 'post' ? 'selected' : '' %>>Post</option>
|
|---|
| 179 | <option value="foto" <%= ptype === 'foto' ? 'selected' : '' %>>Foto</option>
|
|---|
| 180 | <option value="video" <%= ptype === 'video' ? 'selected' : '' %>>Video</option>
|
|---|
| 181 | <option value="audio" <%= ptype === 'audio' ? 'selected' : '' %>>Audio</option>
|
|---|
| 182 | </select>
|
|---|
| 183 | </label>
|
|---|
| 184 | </div>
|
|---|
| 185 | <div class="pe-checkboxes">
|
|---|
| 186 | <div class="pe-pin">
|
|---|
| 187 | <label class="pe-checkbox">
|
|---|
| 188 | <input type="checkbox" id="pin-toggle" <%= (Number(post.pinned) > 0) ? 'checked' : '' %>>
|
|---|
| 189 | <span>📌 Vastpinnen bovenaan</span>
|
|---|
| 190 | </label>
|
|---|
| 191 | <input type="hidden" name="pinned" id="pin-rank" value="<%= post.pinned || 0 %>">
|
|---|
| 192 | <div class="pe-pin-pos" id="pin-pos" <%= (Number(post.pinned) > 0) ? '' : 'hidden' %>>
|
|---|
| 193 | <span class="pe-pin-steps">
|
|---|
| 194 | <button type="button" class="pe-pin-btn" id="pin-up" aria-label="Hoger zetten">▲</button>
|
|---|
| 195 | <button type="button" class="pe-pin-btn" id="pin-down" aria-label="Lager zetten">▼</button>
|
|---|
| 196 | </span>
|
|---|
| 197 | <span class="pe-pin-label" id="pin-label"></span>
|
|---|
| 198 | </div>
|
|---|
| 199 | </div>
|
|---|
| 200 | <label class="pe-checkbox">
|
|---|
| 201 | <input type="checkbox" name="noindex" value="1" <%= post.noindex ? 'checked' : '' %>>
|
|---|
| 202 | <span>🚫 noindex (verberg voor zoekmachines)</span>
|
|---|
| 203 | </label>
|
|---|
| 204 | <% if (typeof premiumUnlocked === 'undefined' || premiumUnlocked) { %>
|
|---|
| 205 | <label class="pe-checkbox">
|
|---|
| 206 | <input type="checkbox" name="fan_only" value="1" <%= post.fan_only ? 'checked' : '' %>>
|
|---|
| 207 | <span>🔒 Alleen voor ingelogde fans</span>
|
|---|
| 208 | </label>
|
|---|
| 209 | <div style="margin-top:8px">
|
|---|
| 210 | <label style="display:block;font-size:12.5px;opacity:.8;margin-bottom:4px">📅 Publiceren op (laat leeg = direct)</label>
|
|---|
| 211 | <input type="datetime-local" name="publish_at" value="<%= post.publish_at ? String(post.publish_at).replace(' ','T').slice(0,16) : '' %>" style="padding:8px 10px;border-radius:8px;border:1px solid var(--rule,rgba(128,128,128,.4));background:transparent;color:inherit">
|
|---|
| 212 | <% if (post.status === 'scheduled' && post.publish_at) { %><div style="font-size:12px;opacity:.7;margin-top:4px">⏳ Ingepland voor <%= post.publish_at %></div><% } %>
|
|---|
| 213 | </div>
|
|---|
| 214 | <% } %>
|
|---|
| 215 | </div>
|
|---|
| 216 | </section>
|
|---|
| 217 |
|
|---|
| 218 | <%# ── ACTIONS (sticky at bottom) ──────────────────────────── %>
|
|---|
| 219 | <div class="pe-actions">
|
|---|
| 220 | <a href="<%= _base %><%= isNew ? '/' : '/' + post.slug %>" class="pe-btn">Annuleren</a>
|
|---|
| 221 | <div class="pe-actions-spacer"></div>
|
|---|
| 222 | <% if (!isNew && post.status !== 'published') { %>
|
|---|
| 223 | <button type="submit" name="action" value="publish" class="pe-btn pe-btn-success">📤 Publish</button>
|
|---|
| 224 | <% } %>
|
|---|
| 225 | <button type="submit" class="pe-btn pe-btn-primary">💾 Opslaan</button>
|
|---|
| 226 | </div>
|
|---|
| 227 | </form>
|
|---|
| 228 | </div>
|
|---|
| 229 |
|
|---|
| 230 | <style>
|
|---|
| 231 | /* ─── Page wrapper ──────────────────────────────────────────────── */
|
|---|
| 232 | .post-edit-page {
|
|---|
| 233 | max-width: 880px;
|
|---|
| 234 | margin: 1.5rem auto 6rem; /* extra bottom for sticky-actions clearance */
|
|---|
| 235 | padding: 0 1rem;
|
|---|
| 236 | }
|
|---|
| 237 | .post-edit-page h1 {
|
|---|
| 238 | font-family: var(--font-display, serif);
|
|---|
| 239 | margin: 0 0 1.25rem;
|
|---|
| 240 | font-size: 1.75rem;
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | .post-edit-form {
|
|---|
| 244 | display: flex; flex-direction: column;
|
|---|
| 245 | gap: 1rem;
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | /* ─── Card sections ─────────────────────────────────────────────── */
|
|---|
| 249 | .pe-card {
|
|---|
| 250 | background: var(--paper);
|
|---|
| 251 | border: 1px solid var(--rule);
|
|---|
| 252 | border-radius: 12px;
|
|---|
| 253 | padding: 1.25rem;
|
|---|
| 254 | display: flex; flex-direction: column;
|
|---|
| 255 | gap: 0.85rem;
|
|---|
| 256 | }
|
|---|
| 257 | .pe-card-content { padding-bottom: 0; overflow: hidden; } /* editor flush to bottom */
|
|---|
| 258 | .pe-section-title {
|
|---|
| 259 | font-size: 0.8rem;
|
|---|
| 260 | font-weight: 600;
|
|---|
| 261 | text-transform: uppercase;
|
|---|
| 262 | letter-spacing: 0.05em;
|
|---|
| 263 | color: var(--ink-soft);
|
|---|
| 264 | display: flex; align-items: baseline; gap: 0.5rem;
|
|---|
| 265 | flex-wrap: wrap;
|
|---|
| 266 | }
|
|---|
| 267 | .pe-section-title small {
|
|---|
| 268 | font-size: 0.75rem; font-weight: 400;
|
|---|
| 269 | letter-spacing: 0; text-transform: none;
|
|---|
| 270 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | /* ─── Field primitives ──────────────────────────────────────────── */
|
|---|
| 274 | .pe-field {
|
|---|
| 275 | display: flex; flex-direction: column;
|
|---|
| 276 | gap: 0.35rem;
|
|---|
| 277 | min-width: 0; /* allow grid items to shrink */
|
|---|
| 278 | }
|
|---|
| 279 | .pe-field > span {
|
|---|
| 280 | font-size: 0.8rem;
|
|---|
| 281 | font-weight: 600;
|
|---|
| 282 | color: var(--ink-soft);
|
|---|
| 283 | display: flex; align-items: baseline; gap: 0.4rem;
|
|---|
| 284 | }
|
|---|
| 285 | .pe-field > span small {
|
|---|
| 286 | font-weight: 400; color: var(--ink-muted);
|
|---|
| 287 | }
|
|---|
| 288 | .pe-field input,
|
|---|
| 289 | .pe-field textarea,
|
|---|
| 290 | .pe-field select {
|
|---|
| 291 | width: 100%;
|
|---|
| 292 | box-sizing: border-box;
|
|---|
| 293 | display: block;
|
|---|
| 294 | padding: 0.6rem 0.75rem;
|
|---|
| 295 | border: 1px solid var(--rule);
|
|---|
| 296 | border-radius: 6px;
|
|---|
| 297 | background: var(--paper-2);
|
|---|
| 298 | color: var(--ink);
|
|---|
| 299 | font-family: var(--font-ui, system-ui), sans-serif;
|
|---|
| 300 | font-size: 0.95rem;
|
|---|
| 301 | -webkit-appearance: none;
|
|---|
| 302 | appearance: none;
|
|---|
| 303 | transition: border-color 120ms;
|
|---|
| 304 | }
|
|---|
| 305 | .pe-field input:focus,
|
|---|
| 306 | .pe-field textarea:focus,
|
|---|
| 307 | .pe-field select:focus {
|
|---|
| 308 | outline: 2px solid var(--accent);
|
|---|
| 309 | outline-offset: -1px;
|
|---|
| 310 | border-color: var(--accent);
|
|---|
| 311 | }
|
|---|
| 312 | .pe-field textarea {
|
|---|
| 313 | font-family: var(--font-mono, monospace);
|
|---|
| 314 | resize: vertical;
|
|---|
| 315 | }
|
|---|
| 316 | .pe-field select {
|
|---|
| 317 | /* Restore the dropdown arrow we removed with appearance:none */
|
|---|
| 318 | background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
|
|---|
| 319 | background-repeat: no-repeat;
|
|---|
| 320 | background-position: right 0.75rem center;
|
|---|
| 321 | padding-right: 2rem;
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | .pe-row {
|
|---|
| 325 | display: grid;
|
|---|
| 326 | gap: 0.75rem;
|
|---|
| 327 | }
|
|---|
| 328 | .pe-row-2 { grid-template-columns: 1fr 1fr; }
|
|---|
| 329 | @media (max-width: 600px) {
|
|---|
| 330 | .pe-row-2 { grid-template-columns: 1fr; }
|
|---|
| 331 | }
|
|---|
| 332 |
|
|---|
| 333 | /* ─── Cover field ───────────────────────────────────────────────── */
|
|---|
| 334 | .pe-cover-row {
|
|---|
| 335 | display: grid;
|
|---|
| 336 | grid-template-columns: 120px 1fr;
|
|---|
| 337 | gap: 1rem;
|
|---|
| 338 | align-items: start;
|
|---|
| 339 | }
|
|---|
| 340 | .pe-cover-thumb {
|
|---|
| 341 | width: 120px; height: 120px;
|
|---|
| 342 | border-radius: 10px;
|
|---|
| 343 | overflow: hidden;
|
|---|
| 344 | background: var(--paper-2);
|
|---|
| 345 | border: 1px solid var(--rule);
|
|---|
| 346 | display: flex; align-items: center; justify-content: center;
|
|---|
| 347 | position: relative;
|
|---|
| 348 | }
|
|---|
| 349 | .pe-cover-thumb[data-empty] {
|
|---|
| 350 | border-style: dashed;
|
|---|
| 351 | }
|
|---|
| 352 | .pe-cover-thumb img {
|
|---|
| 353 | width: 100%; height: 100%;
|
|---|
| 354 | object-fit: cover; display: block;
|
|---|
| 355 | }
|
|---|
| 356 | /* Honor HTML hidden — our display:block above otherwise renders an empty
|
|---|
| 357 | broken-image icon when no cover is set. */
|
|---|
| 358 | .pe-cover-thumb img[hidden] { display: none; }
|
|---|
| 359 | .pe-cover-empty {
|
|---|
| 360 | font-size: 2rem;
|
|---|
| 361 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 362 | opacity: 0.5;
|
|---|
| 363 | }
|
|---|
| 364 | .pe-cover-actions {
|
|---|
| 365 | display: flex; flex-direction: column;
|
|---|
| 366 | gap: 0.6rem;
|
|---|
| 367 | min-width: 0;
|
|---|
| 368 | }
|
|---|
| 369 | .pe-cover-upload {
|
|---|
| 370 | display: flex; align-items: center; gap: 0.6rem;
|
|---|
| 371 | flex-wrap: wrap;
|
|---|
| 372 | }
|
|---|
| 373 | @media (max-width: 600px) {
|
|---|
| 374 | .pe-cover-row { grid-template-columns: 88px 1fr; }
|
|---|
| 375 | .pe-cover-thumb { width: 88px; height: 88px; }
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | /* ─── Editor frame (WYSIWYG: top toolbar, contenteditable body, status bar) ─── */
|
|---|
| 379 | .pe-editor-frame {
|
|---|
| 380 | margin: 0 -1.25rem -1.25rem; /* break out of card padding for flush edges */
|
|---|
| 381 | border-top: 1px solid var(--rule);
|
|---|
| 382 | background: var(--paper);
|
|---|
| 383 | display: flex; flex-direction: column;
|
|---|
| 384 | }
|
|---|
| 385 |
|
|---|
| 386 | /* Top toolbar — sticks to the top of the viewport while editing */
|
|---|
| 387 | .pe-toolbar {
|
|---|
| 388 | display: flex; align-items: center; gap: .15rem;
|
|---|
| 389 | flex-wrap: wrap;
|
|---|
| 390 | padding: .4rem .75rem;
|
|---|
| 391 | background: color-mix(in srgb, var(--paper) 92%, transparent);
|
|---|
| 392 | backdrop-filter: blur(10px);
|
|---|
| 393 | -webkit-backdrop-filter: blur(10px);
|
|---|
| 394 | border-bottom: 1px solid var(--rule);
|
|---|
| 395 | position: sticky;
|
|---|
| 396 | top: 0;
|
|---|
| 397 | z-index: 10;
|
|---|
| 398 | }
|
|---|
| 399 | .pe-toolbar button {
|
|---|
| 400 | display: inline-flex; align-items: center; justify-content: center;
|
|---|
| 401 | width: 32px; height: 32px;
|
|---|
| 402 | padding: 0;
|
|---|
| 403 | touch-action: manipulation; /* snappy taps op mobiel, geen dubbeltik-zoom */
|
|---|
| 404 | -webkit-user-select: none; user-select: none;
|
|---|
| 405 | background: transparent;
|
|---|
| 406 | border: 1px solid transparent;
|
|---|
| 407 | border-radius: 6px;
|
|---|
| 408 | color: var(--ink);
|
|---|
| 409 | cursor: pointer;
|
|---|
| 410 | font-family: var(--font-ui, system-ui), sans-serif;
|
|---|
| 411 | font-weight: 600; font-size: .85rem;
|
|---|
| 412 | transition: background var(--transition), color var(--transition), border-color var(--transition);
|
|---|
| 413 | -webkit-tap-highlight-color: transparent;
|
|---|
| 414 | }
|
|---|
| 415 | /* Hover alleen op echte hover-apparaten — op touch blijft :hover anders "plakken"
|
|---|
| 416 | na een tik, waardoor de actief/inactief-staat onleesbaar wordt. */
|
|---|
| 417 | @media (hover: hover) {
|
|---|
| 418 | .pe-toolbar button:hover {
|
|---|
| 419 | background: var(--paper-2);
|
|---|
| 420 | color: var(--accent);
|
|---|
| 421 | }
|
|---|
| 422 | }
|
|---|
| 423 | .pe-toolbar button:active { transform: scale(.94); }
|
|---|
| 424 | /* Actieve opmaak = onmiskenbaar gevuld met de accentkleur. Zo is op mobiel
|
|---|
| 425 | meteen duidelijk dat bv. vet AAN staat (tik nogmaals = uit). */
|
|---|
| 426 | .pe-toolbar button.is-active {
|
|---|
| 427 | background: var(--accent);
|
|---|
| 428 | color: #fff;
|
|---|
| 429 | border-color: var(--accent);
|
|---|
| 430 | }
|
|---|
| 431 | .pe-toolbar button.is-active svg { color: #fff; }
|
|---|
| 432 | .pe-toolbar button svg { width: 16px; height: 16px; }
|
|---|
| 433 | .pe-toolbar button.pe-tb-text { font-family: var(--font-display, serif); font-weight: 700; }
|
|---|
| 434 | .pe-toolbar-sep {
|
|---|
| 435 | width: 1px; height: 18px;
|
|---|
| 436 | background: var(--rule);
|
|---|
| 437 | margin: 0 .35rem;
|
|---|
| 438 | flex-shrink: 0;
|
|---|
| 439 | }
|
|---|
| 440 | .pe-toolbar-spacer { flex: 1; }
|
|---|
| 441 |
|
|---|
| 442 | /* ─── Volledig-scherm schrijfmodus ─── */
|
|---|
| 443 | .fs-icon-compress { display: none; }
|
|---|
| 444 | .pe-editor-frame.pe-fs .fs-icon-expand { display: none; }
|
|---|
| 445 | .pe-editor-frame.pe-fs .fs-icon-compress { display: inline; }
|
|---|
| 446 | .pe-editor-frame.pe-fs {
|
|---|
| 447 | position: fixed; inset: 0; z-index: 1000;
|
|---|
| 448 | margin: 0; border-top: 0;
|
|---|
| 449 | height: 100dvh;
|
|---|
| 450 | background: var(--paper);
|
|---|
| 451 | overflow: hidden; /* alléén het tekstveld scrollt, niet het frame zelf */
|
|---|
| 452 | }
|
|---|
| 453 | /* In fullscreen vult het schrijfveld de resterende ruimte en scrollt het zelf
|
|---|
| 454 | (max-height: none overschrijft de mobiele box-begrenzing hieronder). */
|
|---|
| 455 | .pe-editor-frame.pe-fs .pe-editor {
|
|---|
| 456 | flex: 1 1 auto; min-height: 0; height: auto; max-height: none;
|
|---|
| 457 | }
|
|---|
| 458 | /* Pagina vergrendelen achter het fullscreen-veld (html én body) → geen tweede,
|
|---|
| 459 | verwarrende pagina-scrollbalk naast de scrollbalk van het tekstveld. */
|
|---|
| 460 | html.pe-fs-open, body.pe-fs-open { overflow: hidden; }
|
|---|
| 461 |
|
|---|
| 462 | /* Editor body — looks like prose, behaves like a textarea */
|
|---|
| 463 | .pe-editor {
|
|---|
| 464 | width: 100%;
|
|---|
| 465 | box-sizing: border-box;
|
|---|
| 466 | min-height: 420px;
|
|---|
| 467 | padding: 1.25rem 1.5rem;
|
|---|
| 468 | border: 0;
|
|---|
| 469 | background: transparent;
|
|---|
| 470 | color: var(--ink);
|
|---|
| 471 | font-family: var(--font-body, system-ui), serif;
|
|---|
| 472 | font-size: 1.0625rem;
|
|---|
| 473 | line-height: 1.65;
|
|---|
| 474 | outline: none;
|
|---|
| 475 | overflow-y: auto;
|
|---|
| 476 | }
|
|---|
| 477 | .pe-editor:focus { outline: none; }
|
|---|
| 478 | /* Inline (niet-fullscreen) groeit het schrijfveld gewoon mee met de inhoud — geen
|
|---|
| 479 | interne scroll-box (scroll-binnen-scroll is verwarrend). Op mobiel/tablet gaat
|
|---|
| 480 | typen sowieso fullscreen (zie JS), waar het veld de pagina vult en als enige
|
|---|
| 481 | scrollt. */
|
|---|
| 482 | .pe-editor-frame:not(.pe-fs) .pe-editor { overflow: visible; }
|
|---|
| 483 |
|
|---|
| 484 | /* Touch: het inline content-veld is geen tekstveld maar een tap-vlak → fullscreen
|
|---|
| 485 | bewerken. Een "✎ Tik om te bewerken"-pill plakt sticky onderaan de container,
|
|---|
| 486 | zodat de hint altijd in beeld is zonder midden in de tekst te staan. */
|
|---|
| 487 | .pe-editor.pe-tap-to-edit { cursor: pointer; }
|
|---|
| 488 | .pe-edit-hint { display: none; }
|
|---|
| 489 | @media (pointer: coarse) {
|
|---|
| 490 | .pe-editor-frame:not(.pe-fs) .pe-edit-hint {
|
|---|
| 491 | display: block;
|
|---|
| 492 | position: sticky;
|
|---|
| 493 | bottom: 4.5rem; /* boven de sticky Opslaan/Annuleren-balk */
|
|---|
| 494 | width: max-content;
|
|---|
| 495 | max-width: calc(100% - 2rem);
|
|---|
| 496 | margin: .4rem auto;
|
|---|
| 497 | background: var(--accent); color: #fff;
|
|---|
| 498 | font-size: .9rem; font-weight: 700; padding: .5rem 1.1rem; border-radius: 999px;
|
|---|
| 499 | box-shadow: 0 4px 14px rgba(0,0,0,.35);
|
|---|
| 500 | pointer-events: none; text-align: center; white-space: nowrap;
|
|---|
| 501 | }
|
|---|
| 502 | }
|
|---|
| 503 | .pe-editor.is-dragover {
|
|---|
| 504 | outline: 2px dashed var(--accent);
|
|---|
| 505 | outline-offset: -10px;
|
|---|
| 506 | }
|
|---|
| 507 | .pe-editor[data-placeholder]:empty::before,
|
|---|
| 508 | .pe-editor[data-placeholder]:has(br:only-child)::before {
|
|---|
| 509 | content: attr(data-placeholder);
|
|---|
| 510 | color: var(--ink-muted, #999);
|
|---|
| 511 | pointer-events: none;
|
|---|
| 512 | opacity: .55;
|
|---|
| 513 | }
|
|---|
| 514 | /* Inline prose styles inside the editor — match the public post styling so
|
|---|
| 515 | what you see is roughly what you'll get. Margins are tighter than on the
|
|---|
| 516 | live site since this is a confined writing space. */
|
|---|
| 517 | .pe-editor h1, .pe-editor h2, .pe-editor h3, .pe-editor h4 {
|
|---|
| 518 | font-family: var(--font-display, serif);
|
|---|
| 519 | line-height: 1.2;
|
|---|
| 520 | margin: 1.1rem 0 .35rem;
|
|---|
| 521 | }
|
|---|
| 522 | .pe-editor h1 { font-size: 1.85rem; }
|
|---|
| 523 | .pe-editor h2 { font-size: 1.45rem; }
|
|---|
| 524 | .pe-editor h3 { font-size: 1.2rem; }
|
|---|
| 525 | .pe-editor p { margin: 0 0 .85em; }
|
|---|
| 526 | .pe-editor ul, .pe-editor ol { margin: 0 0 .85em 1.4em; padding: 0; }
|
|---|
| 527 | .pe-editor li { margin: .15em 0; }
|
|---|
| 528 | .pe-editor blockquote {
|
|---|
| 529 | margin: 1em 0;
|
|---|
| 530 | padding: .15em 0 .15em 1em;
|
|---|
| 531 | border-left: 3px solid var(--accent);
|
|---|
| 532 | color: var(--ink-soft, var(--ink));
|
|---|
| 533 | font-style: italic;
|
|---|
| 534 | }
|
|---|
| 535 | .pe-editor code {
|
|---|
| 536 | background: var(--paper-2);
|
|---|
| 537 | border: 1px solid var(--rule);
|
|---|
| 538 | border-radius: 4px;
|
|---|
| 539 | padding: .1em .35em;
|
|---|
| 540 | font-family: var(--font-mono, ui-monospace, monospace);
|
|---|
| 541 | font-size: .92em;
|
|---|
| 542 | }
|
|---|
| 543 | .pe-editor a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
|
|---|
| 544 | .pe-editor img {
|
|---|
| 545 | max-width: 100%; height: auto;
|
|---|
| 546 | border-radius: 6px;
|
|---|
| 547 | display: block;
|
|---|
| 548 | margin: 1em auto;
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | /* Shortcode chips — visible inline placeholder in the editor for
|
|---|
| 552 | [[track:UUID]] / [[album:Name]] / [[playlist:slug]]. They serialize back
|
|---|
| 553 | to plain shortcode text on submit. */
|
|---|
| 554 | .sc-chip {
|
|---|
| 555 | display: inline-flex; align-items: center; gap: .3rem;
|
|---|
| 556 | padding: .15em .5em;
|
|---|
| 557 | margin: 0 .15em;
|
|---|
| 558 | background: color-mix(in srgb, var(--accent) 10%, var(--paper-2));
|
|---|
| 559 | border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
|
|---|
| 560 | border-radius: 999px;
|
|---|
| 561 | color: var(--accent);
|
|---|
| 562 | font-family: var(--font-ui, system-ui), sans-serif;
|
|---|
| 563 | font-size: .85em;
|
|---|
| 564 | font-weight: 600;
|
|---|
| 565 | font-style: normal;
|
|---|
| 566 | white-space: nowrap;
|
|---|
| 567 | user-select: none;
|
|---|
| 568 | cursor: default;
|
|---|
| 569 | vertical-align: baseline;
|
|---|
| 570 | }
|
|---|
| 571 | .sc-chip-icon { display: inline-flex; opacity: .8; }
|
|---|
| 572 | .sc-chip-icon svg { width: 12px; height: 12px; }
|
|---|
| 573 |
|
|---|
| 574 | /* Status bar below the editor */
|
|---|
| 575 | .pe-editor-status {
|
|---|
| 576 | display: flex; align-items: center; justify-content: space-between;
|
|---|
| 577 | gap: .75rem;
|
|---|
| 578 | padding: .45rem 1rem;
|
|---|
| 579 | border-top: 1px solid var(--rule);
|
|---|
| 580 | background: var(--paper-2);
|
|---|
| 581 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 582 | font-size: .78rem;
|
|---|
| 583 | }
|
|---|
| 584 | .pe-char-count { font-variant-numeric: tabular-nums; }
|
|---|
| 585 |
|
|---|
| 586 | /* ─── Track picker modal (P59) ─────────────────────────────────
|
|---|
| 587 | Mobile-first: full-screen bottom-sheet on phones, centered card
|
|---|
| 588 | on desktop. Lock body scroll while open via .tp-locked on body. */
|
|---|
| 589 | .tp-modal {
|
|---|
| 590 | position: fixed; inset: 0;
|
|---|
| 591 | z-index: 1000;
|
|---|
| 592 | display: flex; align-items: stretch; justify-content: center;
|
|---|
| 593 | /* Avoid the iOS home-indicator + the keyboard when search is focused */
|
|---|
| 594 | padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
|
|---|
| 595 | }
|
|---|
| 596 | .tp-modal[hidden] { display: none; }
|
|---|
| 597 | .tp-backdrop {
|
|---|
| 598 | position: absolute; inset: 0;
|
|---|
| 599 | background: color-mix(in srgb, var(--ink) 55%, transparent);
|
|---|
| 600 | backdrop-filter: blur(4px);
|
|---|
| 601 | -webkit-backdrop-filter: blur(4px);
|
|---|
| 602 | animation: tp-bd-in .18s ease-out;
|
|---|
| 603 | }
|
|---|
| 604 | @keyframes tp-bd-in { from { opacity: 0 } to { opacity: 1 } }
|
|---|
| 605 |
|
|---|
| 606 | /* Mobile: sheet docks to the bottom and fills viewport almost completely */
|
|---|
| 607 | .tp-sheet {
|
|---|
| 608 | position: relative;
|
|---|
| 609 | margin-top: auto;
|
|---|
| 610 | width: 100%;
|
|---|
| 611 | max-height: calc(100dvh - env(safe-area-inset-top) - 1rem);
|
|---|
| 612 | background: var(--paper);
|
|---|
| 613 | border-top: 1px solid var(--rule);
|
|---|
| 614 | border-radius: 16px 16px 0 0;
|
|---|
| 615 | box-shadow:
|
|---|
| 616 | 0 -2px 8px color-mix(in srgb, var(--ink) 8%, transparent),
|
|---|
| 617 | 0 -16px 48px color-mix(in srgb, var(--ink) 18%, transparent);
|
|---|
| 618 | display: flex; flex-direction: column;
|
|---|
| 619 | animation: tp-sheet-up .22s cubic-bezier(.2, .8, .25, 1);
|
|---|
| 620 | overflow: hidden;
|
|---|
| 621 | }
|
|---|
| 622 | @keyframes tp-sheet-up {
|
|---|
| 623 | from { transform: translateY(100%); opacity: .8; }
|
|---|
| 624 | to { transform: translateY(0); opacity: 1; }
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|
| 627 | /* Header — title + close, with a small grab-handle bar on mobile */
|
|---|
| 628 | .tp-header {
|
|---|
| 629 | display: flex; align-items: center; justify-content: space-between;
|
|---|
| 630 | gap: .75rem;
|
|---|
| 631 | padding: .85rem 1rem .65rem;
|
|---|
| 632 | border-bottom: 1px solid var(--rule);
|
|---|
| 633 | position: relative;
|
|---|
| 634 | }
|
|---|
| 635 | .tp-header::before {
|
|---|
| 636 | /* Grab-handle: visible on mobile only */
|
|---|
| 637 | content: '';
|
|---|
| 638 | position: absolute;
|
|---|
| 639 | top: .35rem; left: 50%;
|
|---|
| 640 | transform: translateX(-50%);
|
|---|
| 641 | width: 38px; height: 4px;
|
|---|
| 642 | background: var(--rule-2, var(--rule));
|
|---|
| 643 | border-radius: 2px;
|
|---|
| 644 | }
|
|---|
| 645 | .tp-h2 {
|
|---|
| 646 | margin: .35rem 0 0;
|
|---|
| 647 | font-family: var(--font-display, serif);
|
|---|
| 648 | font-size: 1.15rem; font-weight: 600;
|
|---|
| 649 | color: var(--ink);
|
|---|
| 650 | line-height: 1.1;
|
|---|
| 651 | }
|
|---|
| 652 | .tp-close {
|
|---|
| 653 | width: 32px; height: 32px; border-radius: 8px;
|
|---|
| 654 | display: inline-flex; align-items: center; justify-content: center;
|
|---|
| 655 | background: transparent; border: 1px solid transparent;
|
|---|
| 656 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 657 | cursor: pointer;
|
|---|
| 658 | transition: background var(--transition), color var(--transition), border-color var(--transition);
|
|---|
| 659 | -webkit-tap-highlight-color: transparent;
|
|---|
| 660 | margin-top: .35rem;
|
|---|
| 661 | }
|
|---|
| 662 | .tp-close:hover, .tp-close:focus-visible {
|
|---|
| 663 | background: var(--paper-2);
|
|---|
| 664 | color: var(--ink);
|
|---|
| 665 | outline: none;
|
|---|
| 666 | }
|
|---|
| 667 | .tp-close svg { width: 18px; height: 18px; }
|
|---|
| 668 |
|
|---|
| 669 | /* Search row — sticky just below header so list scrolls underneath */
|
|---|
| 670 | .tp-search-row {
|
|---|
| 671 | position: relative;
|
|---|
| 672 | padding: .65rem 1rem;
|
|---|
| 673 | border-bottom: 1px solid var(--rule);
|
|---|
| 674 | background: var(--paper);
|
|---|
| 675 | }
|
|---|
| 676 | .tp-search-icon {
|
|---|
| 677 | position: absolute;
|
|---|
| 678 | top: 50%; left: 1.65rem;
|
|---|
| 679 | transform: translateY(-50%);
|
|---|
| 680 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 681 | pointer-events: none;
|
|---|
| 682 | display: inline-flex;
|
|---|
| 683 | }
|
|---|
| 684 | .tp-search-icon svg { width: 16px; height: 16px; }
|
|---|
| 685 | .tp-search {
|
|---|
| 686 | width: 100%; box-sizing: border-box;
|
|---|
| 687 | padding: .65rem .85rem .65rem 2.4rem;
|
|---|
| 688 | font-family: var(--font-ui, system-ui), sans-serif;
|
|---|
| 689 | font-size: 1rem;
|
|---|
| 690 | background: var(--paper-2);
|
|---|
| 691 | color: var(--ink);
|
|---|
| 692 | border: 1px solid var(--rule);
|
|---|
| 693 | border-radius: 9px;
|
|---|
| 694 | -webkit-appearance: none;
|
|---|
| 695 | appearance: none;
|
|---|
| 696 | }
|
|---|
| 697 | .tp-search:focus {
|
|---|
| 698 | outline: none;
|
|---|
| 699 | border-color: var(--accent);
|
|---|
| 700 | box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
|
|---|
| 701 | }
|
|---|
| 702 |
|
|---|
| 703 | /* List — vertically scrollable, takes remaining sheet height */
|
|---|
| 704 | .tp-list {
|
|---|
| 705 | flex: 1 1 auto;
|
|---|
| 706 | overflow-y: auto;
|
|---|
| 707 | -webkit-overflow-scrolling: touch;
|
|---|
| 708 | padding: .35rem .35rem 1rem;
|
|---|
| 709 | }
|
|---|
| 710 | .tp-empty {
|
|---|
| 711 | padding: 1.5rem 1rem;
|
|---|
| 712 | text-align: center;
|
|---|
| 713 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 714 | font-size: .9rem;
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | /* Track row — tap target ≥ 56px for mobile */
|
|---|
| 718 | .tp-row {
|
|---|
| 719 | display: grid;
|
|---|
| 720 | grid-template-columns: 44px 1fr auto;
|
|---|
| 721 | align-items: center;
|
|---|
| 722 | gap: .75rem;
|
|---|
| 723 | width: 100%;
|
|---|
| 724 | padding: .55rem .65rem;
|
|---|
| 725 | border: 0; background: transparent;
|
|---|
| 726 | border-radius: 10px;
|
|---|
| 727 | text-align: left;
|
|---|
| 728 | cursor: pointer;
|
|---|
| 729 | color: inherit;
|
|---|
| 730 | font: inherit;
|
|---|
| 731 | transition: background var(--transition);
|
|---|
| 732 | -webkit-tap-highlight-color: transparent;
|
|---|
| 733 | }
|
|---|
| 734 | .tp-row:hover, .tp-row:focus-visible {
|
|---|
| 735 | background: color-mix(in srgb, var(--accent) 8%, var(--paper-2));
|
|---|
| 736 | outline: none;
|
|---|
| 737 | }
|
|---|
| 738 | .tp-row:active { transform: scale(.98); }
|
|---|
| 739 | .tp-row[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
|
|---|
| 740 |
|
|---|
| 741 | .tp-cover {
|
|---|
| 742 | width: 44px; height: 44px;
|
|---|
| 743 | border-radius: 6px;
|
|---|
| 744 | background-size: cover; background-position: center;
|
|---|
| 745 | background-color: var(--rule);
|
|---|
| 746 | display: inline-flex; align-items: center; justify-content: center;
|
|---|
| 747 | flex-shrink: 0;
|
|---|
| 748 | }
|
|---|
| 749 | .tp-cover-empty {
|
|---|
| 750 | background: linear-gradient(135deg,
|
|---|
| 751 | color-mix(in srgb, var(--accent) 30%, var(--paper-2)),
|
|---|
| 752 | color-mix(in srgb, var(--accent) 8%, var(--paper-2)));
|
|---|
| 753 | color: var(--accent);
|
|---|
| 754 | }
|
|---|
| 755 | .tp-cover-empty svg { width: 18px; height: 18px; opacity: .8; }
|
|---|
| 756 |
|
|---|
| 757 | .tp-meta {
|
|---|
| 758 | display: flex; flex-direction: column;
|
|---|
| 759 | min-width: 0;
|
|---|
| 760 | line-height: 1.25;
|
|---|
| 761 | }
|
|---|
| 762 | .tp-row-title {
|
|---|
| 763 | font-weight: 600; font-size: .94rem;
|
|---|
| 764 | color: var(--ink);
|
|---|
| 765 | white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|---|
| 766 | }
|
|---|
| 767 | .tp-row-artist {
|
|---|
| 768 | font-size: .8rem;
|
|---|
| 769 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 770 | white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|---|
| 771 | margin-top: .1rem;
|
|---|
| 772 | }
|
|---|
| 773 | .tp-duration {
|
|---|
| 774 | font-variant-numeric: tabular-nums;
|
|---|
| 775 | font-size: .8rem;
|
|---|
| 776 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 777 | flex-shrink: 0;
|
|---|
| 778 | }
|
|---|
| 779 |
|
|---|
| 780 | /* Body lock when modal open */
|
|---|
| 781 | body.tp-locked { overflow: hidden; touch-action: none; }
|
|---|
| 782 |
|
|---|
| 783 | /* Desktop: centered card, max-width ~520px */
|
|---|
| 784 | @media (min-width: 640px) {
|
|---|
| 785 | .tp-modal {
|
|---|
| 786 | align-items: center;
|
|---|
| 787 | padding: 1.5rem;
|
|---|
| 788 | }
|
|---|
| 789 | .tp-sheet {
|
|---|
| 790 | margin-top: 0;
|
|---|
| 791 | width: 100%;
|
|---|
| 792 | max-width: 520px;
|
|---|
| 793 | max-height: 80dvh;
|
|---|
| 794 | border-radius: 14px;
|
|---|
| 795 | border: 1px solid var(--rule);
|
|---|
| 796 | animation: tp-sheet-pop .2s cubic-bezier(.2, .8, .25, 1);
|
|---|
| 797 | }
|
|---|
| 798 | .tp-header::before { display: none; } /* hide grab-handle on desktop */
|
|---|
| 799 | .tp-header { padding: 1rem 1.25rem .75rem; }
|
|---|
| 800 | .tp-h2 { margin-top: 0; font-size: 1.25rem; }
|
|---|
| 801 | .tp-close { margin-top: 0; }
|
|---|
| 802 | @keyframes tp-sheet-pop {
|
|---|
| 803 | from { transform: translateY(-8px) scale(.97); opacity: 0; }
|
|---|
| 804 | to { transform: translateY(0) scale(1); opacity: 1; }
|
|---|
| 805 | }
|
|---|
| 806 | }
|
|---|
| 807 |
|
|---|
| 808 | /* ─── Buttons ───────────────────────────────────────────────────── */
|
|---|
| 809 | .pe-btn {
|
|---|
| 810 | display: inline-flex; align-items: center; gap: 0.4rem;
|
|---|
| 811 | padding: 0.55rem 1rem;
|
|---|
| 812 | border: 1px solid var(--rule);
|
|---|
| 813 | background: var(--paper-2);
|
|---|
| 814 | color: var(--ink);
|
|---|
| 815 | font-family: var(--font-ui, system-ui), sans-serif;
|
|---|
| 816 | font-size: 0.9rem; font-weight: 500;
|
|---|
| 817 | text-decoration: none;
|
|---|
| 818 | border-radius: 6px;
|
|---|
| 819 | cursor: pointer;
|
|---|
| 820 | transition: background 120ms, border-color 120ms;
|
|---|
| 821 | min-height: 40px;
|
|---|
| 822 | -webkit-tap-highlight-color: transparent;
|
|---|
| 823 | }
|
|---|
| 824 | .pe-btn:hover { border-color: var(--accent); }
|
|---|
| 825 | .pe-btn:active { transform: scale(0.97); }
|
|---|
| 826 | .pe-btn-tiny {
|
|---|
| 827 | padding: 0.35rem 0.7rem;
|
|---|
| 828 | font-size: 0.85rem;
|
|---|
| 829 | min-height: 32px;
|
|---|
| 830 | }
|
|---|
| 831 | .pe-btn-secondary { background: var(--paper-2); }
|
|---|
| 832 | .pe-btn-primary {
|
|---|
| 833 | background: var(--accent); color: white;
|
|---|
| 834 | border-color: var(--accent);
|
|---|
| 835 | }
|
|---|
| 836 | .pe-btn-primary:hover { opacity: 0.92; border-color: var(--accent); }
|
|---|
| 837 | .pe-btn-success {
|
|---|
| 838 | background: #16a34a; color: white;
|
|---|
| 839 | border-color: #16a34a;
|
|---|
| 840 | }
|
|---|
| 841 | .pe-btn-success:hover { opacity: 0.92; border-color: #16a34a; }
|
|---|
| 842 |
|
|---|
| 843 | .pe-status {
|
|---|
| 844 | color: var(--ink-muted, var(--ink-soft));
|
|---|
| 845 | font-size: 0.8rem;
|
|---|
| 846 | }
|
|---|
| 847 | .pe-status.is-error { color: #dc2626; }
|
|---|
| 848 |
|
|---|
| 849 | /* ─── Checkboxes (clean inline row) ─────────────────────────────── */
|
|---|
| 850 | .pe-checkboxes {
|
|---|
| 851 | display: flex; flex-direction: column;
|
|---|
| 852 | gap: 0.5rem;
|
|---|
| 853 | padding-top: 0.25rem;
|
|---|
| 854 | }
|
|---|
| 855 | .pe-checkbox {
|
|---|
| 856 | display: inline-flex; align-items: center; gap: 0.5rem;
|
|---|
| 857 | cursor: pointer;
|
|---|
| 858 | font-size: 0.95rem;
|
|---|
| 859 | color: var(--ink);
|
|---|
| 860 | user-select: none;
|
|---|
| 861 | }
|
|---|
| 862 | .pe-checkbox input[type="checkbox"] {
|
|---|
| 863 | width: 18px; height: 18px;
|
|---|
| 864 | margin: 0;
|
|---|
| 865 | cursor: pointer;
|
|---|
| 866 | accent-color: var(--accent);
|
|---|
| 867 | }
|
|---|
| 868 |
|
|---|
| 869 | /* Vastpinnen: checkbox + ▲▼-stepper met beschrijving (i.p.v. een ruw rang-getal). */
|
|---|
| 870 | .pe-pin { display: flex; flex-direction: column; gap: 0.45rem; }
|
|---|
| 871 | .pe-pin-pos { display: flex; align-items: center; gap: 0.55rem; padding-left: 1.65rem; }
|
|---|
| 872 | .pe-pin-pos[hidden] { display: none; }
|
|---|
| 873 | .pe-pin-steps { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
|
|---|
| 874 | .pe-pin-btn {
|
|---|
| 875 | width: 30px; height: 28px; padding: 0;
|
|---|
| 876 | border: none; background: var(--paper-2); color: var(--ink);
|
|---|
| 877 | cursor: pointer; font-size: 0.68rem; line-height: 1;
|
|---|
| 878 | display: inline-flex; align-items: center; justify-content: center;
|
|---|
| 879 | }
|
|---|
| 880 | .pe-pin-btn + .pe-pin-btn { border-left: 1px solid var(--rule); }
|
|---|
| 881 | .pe-pin-btn:hover { background: color-mix(in srgb, var(--accent) 14%, var(--paper-2)); color: var(--accent); }
|
|---|
| 882 | .pe-pin-btn:disabled { opacity: 0.35; cursor: default; }
|
|---|
| 883 | .pe-pin-label { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
|
|---|
| 884 |
|
|---|
| 885 | /* ─── Sticky action footer ──────────────────────────────────────── */
|
|---|
| 886 | .pe-actions {
|
|---|
| 887 | position: sticky;
|
|---|
| 888 | bottom: 0;
|
|---|
| 889 | display: flex; align-items: center;
|
|---|
| 890 | gap: 0.5rem;
|
|---|
| 891 | padding: 0.85rem 1rem;
|
|---|
| 892 | margin: 0.5rem -1rem 0; /* extend to viewport edges on tight container */
|
|---|
| 893 | background: color-mix(in srgb, var(--paper) 94%, transparent);
|
|---|
| 894 | -webkit-backdrop-filter: blur(8px);
|
|---|
| 895 | backdrop-filter: blur(8px);
|
|---|
| 896 | border-top: 1px solid var(--rule);
|
|---|
| 897 | z-index: 10;
|
|---|
| 898 | }
|
|---|
| 899 | .pe-actions-spacer { flex: 1; }
|
|---|
| 900 |
|
|---|
| 901 | /* De editor is een focus-scherm: verberg de mobiele site-tabbalk (Home/Zoek/…)
|
|---|
| 902 | zodat er niet twee balken onderaan stapelen (Opslaan-balk + tabbalk). De
|
|---|
| 903 | Opslaan/Annuleren-balk wordt dan de enige onderbalk → gewoon op bottom:0,
|
|---|
| 904 | geen tab-offset meer nodig. Op desktop is de tabbalk toch al verborgen. */
|
|---|
| 905 | body:has(.post-edit-page) .bottom-tab { display: none; }
|
|---|
| 906 | /* Audiospeler (indien aan het spelen) niet meer 56px optillen voor de nu-verborgen
|
|---|
| 907 | tabbalk, anders zou die zweven boven de actiebalk. */
|
|---|
| 908 | body:has(.post-edit-page) .audio-player { bottom: 0; }
|
|---|
| 909 | </style>
|
|---|
| 910 |
|
|---|
| 911 | <script>
|
|---|
| 912 | (function() {
|
|---|
| 913 |
|
|---|
| 914 | // ── Cover upload ────────────────────────────────────────────────
|
|---|
| 915 | const coverField = document.getElementById('cover-upload-field');
|
|---|
| 916 | const coverTrigger = document.getElementById('cover-upload-trigger');
|
|---|
| 917 | const coverUrl = document.getElementById('cover-url-field');
|
|---|
| 918 | const coverStatus = document.getElementById('cover-upload-status');
|
|---|
| 919 | const coverWrap = document.getElementById('cover-preview-wrap');
|
|---|
| 920 | const coverImg = document.getElementById('cover-preview-img');
|
|---|
| 921 |
|
|---|
| 922 | async function uploadImage(file) {
|
|---|
| 923 | const fd = new FormData();
|
|---|
| 924 | fd.append('image', file);
|
|---|
| 925 | const res = await fetch('/posts/upload-image', { method: 'POST', body: fd });
|
|---|
| 926 | if (!res.ok) {
|
|---|
| 927 | const j = await res.json().catch(() => ({}));
|
|---|
| 928 | throw new Error(j.error || ('Upload failed (' + res.status + ')'));
|
|---|
| 929 | }
|
|---|
| 930 | return await res.json(); // {url, size, mime}
|
|---|
| 931 | }
|
|---|
| 932 |
|
|---|
| 933 | function showCoverPreview(url) {
|
|---|
| 934 | if (!coverWrap || !coverImg) return;
|
|---|
| 935 | if (url) {
|
|---|
| 936 | coverImg.src = url;
|
|---|
| 937 | coverImg.hidden = false;
|
|---|
| 938 | coverWrap.removeAttribute('data-empty');
|
|---|
| 939 | const emptyIcon = coverWrap.querySelector('.pe-cover-empty');
|
|---|
| 940 | if (emptyIcon) emptyIcon.remove();
|
|---|
| 941 | } else {
|
|---|
| 942 | coverImg.hidden = true;
|
|---|
| 943 | coverImg.src = '';
|
|---|
| 944 | coverWrap.setAttribute('data-empty', '');
|
|---|
| 945 | if (!coverWrap.querySelector('.pe-cover-empty')) {
|
|---|
| 946 | const span = document.createElement('span');
|
|---|
| 947 | span.className = 'pe-cover-empty';
|
|---|
| 948 | span.textContent = '🖼';
|
|---|
| 949 | coverWrap.appendChild(span);
|
|---|
| 950 | }
|
|---|
| 951 | }
|
|---|
| 952 | }
|
|---|
| 953 |
|
|---|
| 954 | if (coverTrigger && coverField) {
|
|---|
| 955 | coverTrigger.addEventListener('click', () => coverField.click());
|
|---|
| 956 | }
|
|---|
| 957 | if (coverField) {
|
|---|
| 958 | coverField.addEventListener('change', async () => {
|
|---|
| 959 | if (!coverField.files[0]) return;
|
|---|
| 960 | coverStatus.classList.remove('is-error');
|
|---|
| 961 | coverStatus.textContent = 'Uploaden…';
|
|---|
| 962 | try {
|
|---|
| 963 | const j = await uploadImage(coverField.files[0]);
|
|---|
| 964 | coverUrl.value = j.url;
|
|---|
| 965 | showCoverPreview(j.url);
|
|---|
| 966 | coverStatus.textContent = 'Geüpload ✓';
|
|---|
| 967 | setTimeout(() => { coverStatus.textContent = ''; }, 2000);
|
|---|
| 968 | } catch (e) {
|
|---|
| 969 | coverStatus.classList.add('is-error');
|
|---|
| 970 | coverStatus.textContent = 'Mislukt: ' + e.message;
|
|---|
| 971 | }
|
|---|
| 972 | });
|
|---|
| 973 | }
|
|---|
| 974 | // Live-update preview when user pastes a URL manually
|
|---|
| 975 | if (coverUrl) {
|
|---|
| 976 | coverUrl.addEventListener('input', () => {
|
|---|
| 977 | const v = coverUrl.value.trim();
|
|---|
| 978 | if (v) showCoverPreview(v); else showCoverPreview('');
|
|---|
| 979 | });
|
|---|
| 980 | }
|
|---|
| 981 |
|
|---|
| 982 | // ── WYSIWYG editor (P58) ────────────────────────────────────────
|
|---|
| 983 | // Architecture:
|
|---|
| 984 | // - Visible <div contenteditable> (`#content-editor`) is what the user
|
|---|
| 985 | // types in; it shows real HTML (formatted, not raw markup).
|
|---|
| 986 | // - Hidden <input name="content"> (`#content-hidden`) is what submits.
|
|---|
| 987 | // On submit we serialize the editor's HTML into it, with shortcode
|
|---|
| 988 | // chips reduced back to their [[track:UUID]]/[[album:Name]]/[[playlist:slug]] text.
|
|---|
| 989 | // - Initial content comes from a <script type="application/json"> tag
|
|---|
| 990 | // to avoid HTML-escape-into-DOM issues; we set innerHTML once on load
|
|---|
| 991 | // and walk text nodes to render shortcode tokens as chips.
|
|---|
| 992 | const contentField = document.getElementById('content-upload-field');
|
|---|
| 993 | const contentBtn = document.getElementById('insert-image-btn');
|
|---|
| 994 | const contentStatus = document.getElementById('content-upload-status');
|
|---|
| 995 | const editor = document.getElementById('content-editor');
|
|---|
| 996 | const hiddenField = document.getElementById('content-hidden');
|
|---|
| 997 | const charCountEl = document.getElementById('char-count');
|
|---|
| 998 | const initialEl = document.getElementById('initial-content');
|
|---|
| 999 | const toolbar = document.getElementById('pe-toolbar');
|
|---|
| 1000 | const form = editor && editor.closest('form');
|
|---|
| 1001 |
|
|---|
| 1002 | if (!editor) return;
|
|---|
| 1003 |
|
|---|
| 1004 | // Titel alleen automatisch focussen op desktop (muis/trackpad). Op touch zou
|
|---|
| 1005 | // dit meteen het toetsenbord openen bij het openen van de editor — niet gewenst.
|
|---|
| 1006 | try {
|
|---|
| 1007 | const titleInput = form && form.querySelector('input[name="title"]');
|
|---|
| 1008 | if (titleInput && window.matchMedia && window.matchMedia('(hover: hover) and (pointer: fine)').matches) {
|
|---|
| 1009 | titleInput.focus({ preventScroll: true });
|
|---|
| 1010 | }
|
|---|
| 1011 | } catch (_) {}
|
|---|
| 1012 |
|
|---|
| 1013 | // ── Shortcode chip rendering / serialization ────────────────────
|
|---|
| 1014 | // Pattern matches [[track:UUID]] / [[album:any text]] / [[playlist:slug]]
|
|---|
| 1015 | // — but we DON'T want to chipify text the user is mid-typing inside an
|
|---|
| 1016 | // HTML attribute; since chipify only walks text nodes (never attribute
|
|---|
| 1017 | // values) that's already safe.
|
|---|
| 1018 | const SC_RE = /\[\[(track|album|playlist|embed):([^\]]+)\]\]/g;
|
|---|
| 1019 |
|
|---|
| 1020 | const SC_ICONS = {
|
|---|
| 1021 | track: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="6 4 20 12 6 20 6 4"/></svg>',
|
|---|
| 1022 | album: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="3"/></svg>',
|
|---|
| 1023 | playlist: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="15" y2="18"/><polygon points="3 5 3 13 9 9"/></svg>',
|
|---|
| 1024 | embed: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><polygon points="10 9 15.5 12 10 15"/></svg>',
|
|---|
| 1025 | };
|
|---|
| 1026 |
|
|---|
| 1027 | function chipLabel(kind, value) {
|
|---|
| 1028 | if (kind === 'track') {
|
|---|
| 1029 | // UUIDs are noisy — show a 6-char prefix for visual hint
|
|---|
| 1030 | const v = String(value || '');
|
|---|
| 1031 | return 'Track ' + (v.length > 8 ? v.slice(0, 6) + '…' : v);
|
|---|
| 1032 | }
|
|---|
| 1033 | if (kind === 'album') return 'Album: ' + value;
|
|---|
| 1034 | if (kind === 'playlist') return 'Playlist: ' + value;
|
|---|
| 1035 | if (kind === 'embed') {
|
|---|
| 1036 | const clean = String(value || '').replace(/^https?:\/\/(www\.)?/, '');
|
|---|
| 1037 | return '▶ ' + (clean.length > 36 ? clean.slice(0, 34) + '…' : clean);
|
|---|
| 1038 | }
|
|---|
| 1039 | return value;
|
|---|
| 1040 | }
|
|---|
| 1041 |
|
|---|
| 1042 | function makeChip(kind, value) {
|
|---|
| 1043 | const span = document.createElement('span');
|
|---|
| 1044 | span.className = 'sc-chip';
|
|---|
| 1045 | span.contentEditable = 'false';
|
|---|
| 1046 | span.setAttribute('data-sc', kind + ':' + value);
|
|---|
| 1047 | span.innerHTML =
|
|---|
| 1048 | '<span class="sc-chip-icon" aria-hidden="true">' + (SC_ICONS[kind] || '') + '</span>' +
|
|---|
| 1049 | '<span class="sc-chip-label"></span>';
|
|---|
| 1050 | span.querySelector('.sc-chip-label').textContent = chipLabel(kind, value);
|
|---|
| 1051 | return span;
|
|---|
| 1052 | }
|
|---|
| 1053 |
|
|---|
| 1054 | // Walk text nodes inside `root` and replace [[type:value]] tokens with chips.
|
|---|
| 1055 | function chipifyShortcodes(root) {
|
|---|
| 1056 | const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null);
|
|---|
| 1057 | const targets = [];
|
|---|
| 1058 | while (walker.nextNode()) {
|
|---|
| 1059 | const n = walker.currentNode;
|
|---|
| 1060 | // Skip text inside existing chips (their .sc-chip-label is set via .textContent so the [[...]] text never appears)
|
|---|
| 1061 | if (n.parentElement && n.parentElement.closest('.sc-chip')) continue;
|
|---|
| 1062 | if (SC_RE.test(n.nodeValue)) targets.push(n);
|
|---|
| 1063 | SC_RE.lastIndex = 0;
|
|---|
| 1064 | }
|
|---|
| 1065 | for (const node of targets) {
|
|---|
| 1066 | const txt = node.nodeValue;
|
|---|
| 1067 | const frag = document.createDocumentFragment();
|
|---|
| 1068 | let last = 0;
|
|---|
| 1069 | let m;
|
|---|
| 1070 | SC_RE.lastIndex = 0;
|
|---|
| 1071 | while ((m = SC_RE.exec(txt)) !== null) {
|
|---|
| 1072 | if (m.index > last) frag.appendChild(document.createTextNode(txt.slice(last, m.index)));
|
|---|
| 1073 | frag.appendChild(makeChip(m[1], m[2].trim()));
|
|---|
| 1074 | last = m.index + m[0].length;
|
|---|
| 1075 | }
|
|---|
| 1076 | if (last < txt.length) frag.appendChild(document.createTextNode(txt.slice(last)));
|
|---|
| 1077 | node.parentNode.replaceChild(frag, node);
|
|---|
| 1078 | }
|
|---|
| 1079 | }
|
|---|
| 1080 |
|
|---|
| 1081 | // Inverse of chipify: clone the editor, replace every chip with its text.
|
|---|
| 1082 | function serializeChips(rootClone) {
|
|---|
| 1083 | const chips = rootClone.querySelectorAll('.sc-chip[data-sc]');
|
|---|
| 1084 | for (const c of chips) {
|
|---|
| 1085 | const txt = '[[' + c.getAttribute('data-sc') + ']]';
|
|---|
| 1086 | c.replaceWith(document.createTextNode(txt));
|
|---|
| 1087 | }
|
|---|
| 1088 | }
|
|---|
| 1089 |
|
|---|
| 1090 | // ── Boot: load initial content as HTML, then render shortcodes as chips
|
|---|
| 1091 | try {
|
|---|
| 1092 | const initial = JSON.parse(initialEl.textContent || '""');
|
|---|
| 1093 | editor.innerHTML = initial || '';
|
|---|
| 1094 | chipifyShortcodes(editor);
|
|---|
| 1095 | } catch (e) {
|
|---|
| 1096 | console.error('[editor] could not parse initial content', e);
|
|---|
| 1097 | editor.innerHTML = '';
|
|---|
| 1098 | }
|
|---|
| 1099 |
|
|---|
| 1100 | // ── Char counter
|
|---|
| 1101 | function updateCharCount() {
|
|---|
| 1102 | const text = (editor.innerText || '').replace(/\s+/g, ' ').trim();
|
|---|
| 1103 | if (charCountEl) charCountEl.textContent = String(text.length);
|
|---|
| 1104 | }
|
|---|
| 1105 | updateCharCount();
|
|---|
| 1106 | editor.addEventListener('input', updateCharCount);
|
|---|
| 1107 |
|
|---|
| 1108 | // ── Toolbar wiring
|
|---|
| 1109 | // Houd de scrollpositie vast rond een edit-commando. execCommand/insert scrollt
|
|---|
| 1110 | // standaard de caret in beeld → het beeld "verspringt" bij het aanklikken van een
|
|---|
| 1111 | // opmaakknop. We leggen ALLE scrollbare voorouders (editor, frame, #pcms-main, …)
|
|---|
| 1112 | // + de pagina vast en zetten ze terug — sync én over een paar frames, want Chrome
|
|---|
| 1113 | // scrollt soms pas een frame later. De gebruiker scrollt zo zelf.
|
|---|
| 1114 | function scrollableAncestors(el) {
|
|---|
| 1115 | const list = [];
|
|---|
| 1116 | let node = el;
|
|---|
| 1117 | while (node && node !== document.body && node !== document.documentElement) {
|
|---|
| 1118 | const oy = getComputedStyle(node).overflowY;
|
|---|
| 1119 | if (oy === 'auto' || oy === 'scroll' || oy === 'overlay') list.push(node);
|
|---|
| 1120 | node = node.parentElement;
|
|---|
| 1121 | }
|
|---|
| 1122 | return list;
|
|---|
| 1123 | }
|
|---|
| 1124 | function keepScroll(fn) {
|
|---|
| 1125 | // In fullscreen staat de pagina vast (body overflow:hidden) en mag het veld
|
|---|
| 1126 | // gewoon naar de caret scrollen — geen pagina-sprong mogelijk, dus niets fixen.
|
|---|
| 1127 | const frame = document.querySelector('.pe-editor-frame');
|
|---|
| 1128 | if (frame && frame.classList.contains('pe-fs')) { fn(); return; }
|
|---|
| 1129 | const wx = window.scrollX, wy = window.scrollY;
|
|---|
| 1130 | const anc = scrollableAncestors(editor).map(function (n) { return [n, n.scrollTop, n.scrollLeft]; });
|
|---|
| 1131 | const restore = function () {
|
|---|
| 1132 | window.scrollTo(wx, wy);
|
|---|
| 1133 | anc.forEach(function (e) { e[0].scrollTop = e[1]; e[0].scrollLeft = e[2]; });
|
|---|
| 1134 | };
|
|---|
| 1135 | fn();
|
|---|
| 1136 | restore();
|
|---|
| 1137 | requestAnimationFrame(restore);
|
|---|
| 1138 | }
|
|---|
| 1139 | function execCmd(cmd, arg) {
|
|---|
| 1140 | keepScroll(function () {
|
|---|
| 1141 | editor.focus({ preventScroll: true });
|
|---|
| 1142 | document.execCommand(cmd, false, arg);
|
|---|
| 1143 | });
|
|---|
| 1144 | updateToolbarState();
|
|---|
| 1145 | updateCharCount();
|
|---|
| 1146 | }
|
|---|
| 1147 | function wrapCode() {
|
|---|
| 1148 | const sel = window.getSelection();
|
|---|
| 1149 | if (!sel || sel.rangeCount === 0 || sel.isCollapsed) return;
|
|---|
| 1150 | keepScroll(function () {
|
|---|
| 1151 | const range = sel.getRangeAt(0);
|
|---|
| 1152 | const code = document.createElement('code');
|
|---|
| 1153 | code.textContent = sel.toString();
|
|---|
| 1154 | range.deleteContents();
|
|---|
| 1155 | range.insertNode(code);
|
|---|
| 1156 | // Move caret after the new node
|
|---|
| 1157 | range.setStartAfter(code);
|
|---|
| 1158 | range.collapse(true);
|
|---|
| 1159 | sel.removeAllRanges();
|
|---|
| 1160 | sel.addRange(range);
|
|---|
| 1161 | editor.focus({ preventScroll: true });
|
|---|
| 1162 | });
|
|---|
| 1163 | }
|
|---|
| 1164 | function linkPrompt() {
|
|---|
| 1165 | const url = window.prompt('Link URL (https://… of /pad)');
|
|---|
| 1166 | if (!url) return;
|
|---|
| 1167 | execCmd('createLink', url);
|
|---|
| 1168 | }
|
|---|
| 1169 | // De huidige selectie zit in een <blockquote> binnen de editor? Geef 'm terug.
|
|---|
| 1170 | function blockquoteAncestor() {
|
|---|
| 1171 | const sel = window.getSelection();
|
|---|
| 1172 | if (!sel || sel.rangeCount === 0) return null;
|
|---|
| 1173 | let node = sel.anchorNode;
|
|---|
| 1174 | while (node && node !== editor) {
|
|---|
| 1175 | if (node.nodeType === 1 && node.tagName === 'BLOCKQUOTE') return node;
|
|---|
| 1176 | node = node.parentNode;
|
|---|
| 1177 | }
|
|---|
| 1178 | return null;
|
|---|
| 1179 | }
|
|---|
| 1180 | // Echte toggle: execCommand('formatBlock','blockquote') zet 'm wél AAN maar
|
|---|
| 1181 | // krijgt 'm nooit meer UIT (browser-quirk). Staat de caret al in een quote →
|
|---|
| 1182 | // pak de wrapper uit; anders pas blockquote toe.
|
|---|
| 1183 | function toggleBlockquote() {
|
|---|
| 1184 | keepScroll(function () {
|
|---|
| 1185 | editor.focus({ preventScroll: true });
|
|---|
| 1186 | const bq = blockquoteAncestor();
|
|---|
| 1187 | if (bq) {
|
|---|
| 1188 | const parent = bq.parentNode;
|
|---|
| 1189 | // Inhoud uit de quote halen, op z'n plek, en de lege wrapper verwijderen.
|
|---|
| 1190 | const ref = bq;
|
|---|
| 1191 | let firstMoved = null;
|
|---|
| 1192 | while (bq.firstChild) {
|
|---|
| 1193 | const child = bq.firstChild;
|
|---|
| 1194 | if (!firstMoved) firstMoved = child;
|
|---|
| 1195 | parent.insertBefore(child, ref);
|
|---|
| 1196 | }
|
|---|
| 1197 | parent.removeChild(bq);
|
|---|
| 1198 | // Caret terugzetten in de uitgepakte inhoud.
|
|---|
| 1199 | if (firstMoved) {
|
|---|
| 1200 | const sel = window.getSelection();
|
|---|
| 1201 | const range = document.createRange();
|
|---|
| 1202 | range.selectNodeContents(firstMoved.nodeType === 1 ? firstMoved : parent);
|
|---|
| 1203 | range.collapse(false);
|
|---|
| 1204 | sel.removeAllRanges();
|
|---|
| 1205 | sel.addRange(range);
|
|---|
| 1206 | }
|
|---|
| 1207 | } else {
|
|---|
| 1208 | document.execCommand('formatBlock', false, 'blockquote');
|
|---|
| 1209 | }
|
|---|
| 1210 | });
|
|---|
| 1211 | updateToolbarState();
|
|---|
| 1212 | updateCharCount();
|
|---|
| 1213 | }
|
|---|
| 1214 |
|
|---|
| 1215 | if (toolbar) {
|
|---|
| 1216 | // CRUCIAAL (mobiel + desktop): voorkom dat een toolbar-knop de focus/selectie
|
|---|
| 1217 | // uit het editor-veld steelt. Zonder dit raakt de selectie kwijt bij het tikken
|
|---|
| 1218 | // → execCommand werkt op een lege selectie (vet kan niet meer UIT) én de browser
|
|---|
| 1219 | // scrollt de caret opnieuw in beeld (de "sprong naar beneden"). preventDefault op
|
|---|
| 1220 | // mousedown houdt de focus in de editor; de click blijft gewoon vuren.
|
|---|
| 1221 | toolbar.addEventListener('mousedown', (e) => {
|
|---|
| 1222 | if (e.target.closest('button')) e.preventDefault();
|
|---|
| 1223 | });
|
|---|
| 1224 | toolbar.addEventListener('click', (e) => {
|
|---|
| 1225 | const btn = e.target.closest('button[data-cmd]');
|
|---|
| 1226 | if (!btn) return;
|
|---|
| 1227 | e.preventDefault();
|
|---|
| 1228 | const cmd = btn.dataset.cmd;
|
|---|
| 1229 | const arg = btn.dataset.arg || null;
|
|---|
| 1230 | if (cmd === 'link-prompt') linkPrompt();
|
|---|
| 1231 | else if (cmd === 'code-wrap') wrapCode();
|
|---|
| 1232 | else if (cmd === 'formatBlock' && arg === 'blockquote') toggleBlockquote();
|
|---|
| 1233 | else execCmd(cmd, arg);
|
|---|
| 1234 | });
|
|---|
| 1235 | }
|
|---|
| 1236 |
|
|---|
| 1237 | // ── Volledig-scherm schrijfmodus: het schrijfveld vult de hele pagina.
|
|---|
| 1238 | const fsBtn = document.getElementById('pe-fullscreen-btn');
|
|---|
| 1239 | const editorFrame = document.querySelector('.pe-editor-frame');
|
|---|
| 1240 | const isTouch = !!(window.matchMedia && window.matchMedia('(pointer: coarse)').matches);
|
|---|
| 1241 |
|
|---|
| 1242 | // Op mobiel duwt het toetsenbord de zichtbare (visual) viewport omhoog terwijl
|
|---|
| 1243 | // een position:fixed-frame aan de LAYOUT-viewport blijft hangen → de toolbar
|
|---|
| 1244 | // schuift uit beeld. Houd het fullscreen-frame daarom gelijk aan de visual
|
|---|
| 1245 | // viewport (top + hoogte), zodat de toolbar altijd bovenaan zichtbaar blijft.
|
|---|
| 1246 | function syncFsViewport() {
|
|---|
| 1247 | if (!editorFrame || !editorFrame.classList.contains('pe-fs')) return;
|
|---|
| 1248 | const vv = window.visualViewport;
|
|---|
| 1249 | if (!vv) return;
|
|---|
| 1250 | editorFrame.style.top = vv.offsetTop + 'px';
|
|---|
| 1251 | editorFrame.style.height = vv.height + 'px';
|
|---|
| 1252 | }
|
|---|
| 1253 | function clearFsViewport() {
|
|---|
| 1254 | if (!editorFrame) return;
|
|---|
| 1255 | editorFrame.style.top = '';
|
|---|
| 1256 | editorFrame.style.height = '';
|
|---|
| 1257 | }
|
|---|
| 1258 | function toggleFullscreen() {
|
|---|
| 1259 | if (!editorFrame) return;
|
|---|
| 1260 | const on = editorFrame.classList.toggle('pe-fs');
|
|---|
| 1261 | document.body.classList.toggle('pe-fs-open', on);
|
|---|
| 1262 | document.documentElement.classList.toggle('pe-fs-open', on);
|
|---|
| 1263 | if (fsBtn) {
|
|---|
| 1264 | fsBtn.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|---|
| 1265 | fsBtn.title = on ? 'Verklein' : 'Volledig scherm';
|
|---|
| 1266 | }
|
|---|
| 1267 | if (window.visualViewport) {
|
|---|
| 1268 | if (on) {
|
|---|
| 1269 | window.visualViewport.addEventListener('resize', syncFsViewport);
|
|---|
| 1270 | window.visualViewport.addEventListener('scroll', syncFsViewport);
|
|---|
| 1271 | syncFsViewport();
|
|---|
| 1272 | } else {
|
|---|
| 1273 | window.visualViewport.removeEventListener('resize', syncFsViewport);
|
|---|
| 1274 | window.visualViewport.removeEventListener('scroll', syncFsViewport);
|
|---|
| 1275 | clearFsViewport();
|
|---|
| 1276 | }
|
|---|
| 1277 | }
|
|---|
| 1278 | // Op touch is het veld inline NIET bewerkbaar; alleen in fullscreen wel.
|
|---|
| 1279 | if (isTouch) editor.setAttribute('contenteditable', on ? 'true' : 'false');
|
|---|
| 1280 | if (on) {
|
|---|
| 1281 | editor.focus({ preventScroll: true });
|
|---|
| 1282 | } else {
|
|---|
| 1283 | if (isTouch) editor.blur();
|
|---|
| 1284 | // Bij verkleinen: naar de TOP van de content scrollen i.p.v. ergens onderaan
|
|---|
| 1285 | // (footer) te blijven hangen.
|
|---|
| 1286 | requestAnimationFrame(function () {
|
|---|
| 1287 | try { editorFrame.scrollIntoView({ block: 'start' }); } catch (_) {}
|
|---|
| 1288 | });
|
|---|
| 1289 | }
|
|---|
| 1290 | }
|
|---|
| 1291 | if (fsBtn) fsBtn.addEventListener('click', toggleFullscreen);
|
|---|
| 1292 | document.addEventListener('keydown', (e) => {
|
|---|
| 1293 | if (e.key === 'Escape' && editorFrame && editorFrame.classList.contains('pe-fs')) {
|
|---|
| 1294 | e.preventDefault();
|
|---|
| 1295 | toggleFullscreen();
|
|---|
| 1296 | }
|
|---|
| 1297 | });
|
|---|
| 1298 |
|
|---|
| 1299 | // Op mobiel/tablet (touch): het content-veld is INLINE NIET bewerkbaar — het is
|
|---|
| 1300 | // dan geen tekstveld. Eén tik → fullscreen, waar het wél bewerkbaar wordt
|
|---|
| 1301 | // (toggleFullscreen zet contenteditable aan/uit). Zo kun je nooit inline typen.
|
|---|
| 1302 | if (isTouch) {
|
|---|
| 1303 | editor.setAttribute('contenteditable', 'false');
|
|---|
| 1304 | editor.classList.add('pe-tap-to-edit');
|
|---|
| 1305 | editor.setAttribute('data-placeholder', 'Tik om te schrijven…');
|
|---|
| 1306 | editor.addEventListener('click', function () {
|
|---|
| 1307 | if (editorFrame && !editorFrame.classList.contains('pe-fs')) toggleFullscreen();
|
|---|
| 1308 | });
|
|---|
| 1309 | }
|
|---|
| 1310 |
|
|---|
| 1311 | // Reflect bold/italic/list state on the toolbar buttons
|
|---|
| 1312 | function updateToolbarState() {
|
|---|
| 1313 | if (!toolbar) return;
|
|---|
| 1314 | const cmds = ['bold', 'italic', 'underline', 'insertUnorderedList', 'insertOrderedList'];
|
|---|
| 1315 | for (const cmd of cmds) {
|
|---|
| 1316 | const btn = toolbar.querySelector('button[data-cmd="' + cmd + '"]');
|
|---|
| 1317 | if (!btn) continue;
|
|---|
| 1318 | try { btn.classList.toggle('is-active', document.queryCommandState(cmd)); } catch(_) {}
|
|---|
| 1319 | }
|
|---|
| 1320 | // Quote-knop: actief als de caret in een <blockquote> staat (toggle-feedback).
|
|---|
| 1321 | const bqBtn = toolbar.querySelector('button[data-cmd="formatBlock"][data-arg="blockquote"]');
|
|---|
| 1322 | if (bqBtn) bqBtn.classList.toggle('is-active', !!blockquoteAncestor());
|
|---|
| 1323 | }
|
|---|
| 1324 | document.addEventListener('selectionchange', () => {
|
|---|
| 1325 | if (document.activeElement === editor) updateToolbarState();
|
|---|
| 1326 | });
|
|---|
| 1327 |
|
|---|
| 1328 | // Keyboard shortcuts: Ctrl/Cmd + B/I/U/K
|
|---|
| 1329 | editor.addEventListener('keydown', (e) => {
|
|---|
| 1330 | const mod = e.ctrlKey || e.metaKey;
|
|---|
| 1331 | if (!mod) return;
|
|---|
| 1332 | const k = e.key.toLowerCase();
|
|---|
| 1333 | if (k === 'b') { e.preventDefault(); execCmd('bold'); }
|
|---|
| 1334 | else if (k === 'i') { e.preventDefault(); execCmd('italic'); }
|
|---|
| 1335 | else if (k === 'u') { e.preventDefault(); execCmd('underline'); }
|
|---|
| 1336 | else if (k === 'k') { e.preventDefault(); linkPrompt(); }
|
|---|
| 1337 | });
|
|---|
| 1338 |
|
|---|
| 1339 | // Paste: keep it simple — strip formatting unless user wants it. Default
|
|---|
| 1340 | // execCommand 'paste' includes Word/Google-Docs garbage. We accept inline
|
|---|
| 1341 | // styles from clipboard only when shift is held — otherwise plain text.
|
|---|
| 1342 | editor.addEventListener('paste', (e) => {
|
|---|
| 1343 | if (e.shiftKey) return; // user wants formatted paste
|
|---|
| 1344 | const text = (e.clipboardData || window.clipboardData).getData('text/plain');
|
|---|
| 1345 | if (text == null) return;
|
|---|
| 1346 | e.preventDefault();
|
|---|
| 1347 | document.execCommand('insertText', false, text);
|
|---|
| 1348 | });
|
|---|
| 1349 |
|
|---|
| 1350 | // ── Image upload (button + drag-drop into the editor)
|
|---|
| 1351 | async function uploadAndInsertImage(file) {
|
|---|
| 1352 | contentStatus.classList.remove('is-error');
|
|---|
| 1353 | contentStatus.textContent = 'Uploaden…';
|
|---|
| 1354 | try {
|
|---|
| 1355 | const j = await uploadImage(file);
|
|---|
| 1356 | const img = '<img src="' + j.url + '" alt="">';
|
|---|
| 1357 | editor.focus({ preventScroll: true });
|
|---|
| 1358 | document.execCommand('insertHTML', false, img);
|
|---|
| 1359 | contentStatus.textContent = 'Ingevoegd ✓';
|
|---|
| 1360 | setTimeout(() => { contentStatus.textContent = ''; }, 2000);
|
|---|
| 1361 | updateCharCount();
|
|---|
| 1362 | } catch (e) {
|
|---|
| 1363 | contentStatus.classList.add('is-error');
|
|---|
| 1364 | contentStatus.textContent = 'Mislukt: ' + e.message;
|
|---|
| 1365 | }
|
|---|
| 1366 | }
|
|---|
| 1367 |
|
|---|
| 1368 | if (contentBtn && contentField) {
|
|---|
| 1369 | contentBtn.addEventListener('click', () => contentField.click());
|
|---|
| 1370 | contentField.addEventListener('change', () => {
|
|---|
| 1371 | if (contentField.files[0]) uploadAndInsertImage(contentField.files[0]);
|
|---|
| 1372 | contentField.value = '';
|
|---|
| 1373 | });
|
|---|
| 1374 |
|
|---|
| 1375 | editor.addEventListener('dragover', (e) => {
|
|---|
| 1376 | if (e.dataTransfer && e.dataTransfer.types.includes('Files')) {
|
|---|
| 1377 | e.preventDefault();
|
|---|
| 1378 | editor.classList.add('is-dragover');
|
|---|
| 1379 | }
|
|---|
| 1380 | });
|
|---|
| 1381 | editor.addEventListener('dragleave', () => editor.classList.remove('is-dragover'));
|
|---|
| 1382 | editor.addEventListener('drop', async (e) => {
|
|---|
| 1383 | editor.classList.remove('is-dragover');
|
|---|
| 1384 | const files = e.dataTransfer && e.dataTransfer.files;
|
|---|
| 1385 | if (!files || !files.length) return;
|
|---|
| 1386 | e.preventDefault();
|
|---|
| 1387 | for (const f of files) {
|
|---|
| 1388 | if (f.type.startsWith('image/')) await uploadAndInsertImage(f);
|
|---|
| 1389 | }
|
|---|
| 1390 | });
|
|---|
| 1391 | }
|
|---|
| 1392 |
|
|---|
| 1393 | // ── Insert chip helpers (track / playlist)
|
|---|
| 1394 | function insertChip(kind, value) {
|
|---|
| 1395 | editor.focus({ preventScroll: true });
|
|---|
| 1396 | const chip = makeChip(kind, value);
|
|---|
| 1397 | // Insert at caret using the Selection API (execCommand insertNode)
|
|---|
| 1398 | const sel = window.getSelection();
|
|---|
| 1399 | if (sel && sel.rangeCount > 0) {
|
|---|
| 1400 | const range = sel.getRangeAt(0);
|
|---|
| 1401 | range.deleteContents();
|
|---|
| 1402 | range.insertNode(chip);
|
|---|
| 1403 | // Insert a trailing space so the user can keep typing after the chip
|
|---|
| 1404 | const space = document.createTextNode('\u00A0');
|
|---|
| 1405 | chip.after(space);
|
|---|
| 1406 | range.setStartAfter(space);
|
|---|
| 1407 | range.collapse(true);
|
|---|
| 1408 | sel.removeAllRanges();
|
|---|
| 1409 | sel.addRange(range);
|
|---|
| 1410 | } else {
|
|---|
| 1411 | editor.appendChild(chip);
|
|---|
| 1412 | editor.appendChild(document.createTextNode('\u00A0'));
|
|---|
| 1413 | }
|
|---|
| 1414 | updateCharCount();
|
|---|
| 1415 | }
|
|---|
| 1416 |
|
|---|
| 1417 | // ── Embed insert: plak een platform-URL -> [[embed:url]]-chip die server-side
|
|---|
| 1418 | // een iframe wordt (YouTube/Spotify/SoundCloud/Vimeo/Apple Music/Bandcamp).
|
|---|
| 1419 | const embedBtn = document.getElementById('insert-embed-btn');
|
|---|
| 1420 | if (embedBtn) {
|
|---|
| 1421 | embedBtn.addEventListener('click', () => {
|
|---|
| 1422 | const raw = window.prompt('Plak een media-URL om in te sluiten\n(YouTube, Spotify, SoundCloud, Vimeo, Apple Music, Bandcamp):');
|
|---|
| 1423 | if (!raw) return;
|
|---|
| 1424 | const url = raw.trim();
|
|---|
| 1425 | if (!/^https?:\/\//i.test(url)) { alert('Geef een volledige URL (https://…).'); return; }
|
|---|
| 1426 | insertChip('embed', url);
|
|---|
| 1427 | });
|
|---|
| 1428 | }
|
|---|
| 1429 |
|
|---|
| 1430 | // ── Track insert: opens the track-picker modal (P59)
|
|---|
| 1431 | const trackBtn = document.getElementById('insert-track-btn');
|
|---|
| 1432 | const trackPicker = document.getElementById('track-picker');
|
|---|
| 1433 | if (trackBtn && trackPicker) {
|
|---|
| 1434 | const tpList = document.getElementById('tp-list');
|
|---|
| 1435 | const tpEmpty = document.getElementById('tp-empty');
|
|---|
| 1436 | const tpSearch = document.getElementById('tp-search');
|
|---|
| 1437 | let tpCache = null; // cached tracks list (fetched once per page load)
|
|---|
| 1438 | let tpLastFocus = null; // element to restore focus to on close
|
|---|
| 1439 |
|
|---|
| 1440 | const SVG_NOTE = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 17V5l12-2v12"/><circle cx="6" cy="17" r="3"/><circle cx="18" cy="15" r="3"/></svg>';
|
|---|
| 1441 |
|
|---|
| 1442 | function fmtDur(sec) {
|
|---|
| 1443 | sec = Math.max(0, Math.floor(sec || 0));
|
|---|
| 1444 | const m = Math.floor(sec / 60), s = sec % 60;
|
|---|
| 1445 | return m + ':' + String(s).padStart(2, '0');
|
|---|
| 1446 | }
|
|---|
| 1447 | function escAttr(s) {
|
|---|
| 1448 | return String(s == null ? '' : s).replace(/[&<>"']/g, c => ({
|
|---|
| 1449 | '&':'&','<':'<','>':'>','"':'"',"'":'''
|
|---|
| 1450 | }[c]));
|
|---|
| 1451 | }
|
|---|
| 1452 |
|
|---|
| 1453 | function renderList(filter) {
|
|---|
| 1454 | if (!Array.isArray(tpCache)) return;
|
|---|
| 1455 | const q = (filter || '').trim().toLowerCase();
|
|---|
| 1456 | const filtered = q
|
|---|
| 1457 | ? tpCache.filter(t =>
|
|---|
| 1458 | (t.title || '').toLowerCase().includes(q) ||
|
|---|
| 1459 | (t.artist || '').toLowerCase().includes(q))
|
|---|
| 1460 | : tpCache;
|
|---|
| 1461 |
|
|---|
| 1462 | if (!filtered.length) {
|
|---|
| 1463 | tpList.innerHTML = '';
|
|---|
| 1464 | tpEmpty.textContent = q ? 'Geen tracks gevonden voor "' + q + '"' : 'Nog geen tracks. Upload via Beheer → Audio.';
|
|---|
| 1465 | tpList.appendChild(tpEmpty);
|
|---|
| 1466 | return;
|
|---|
| 1467 | }
|
|---|
| 1468 |
|
|---|
| 1469 | tpList.innerHTML = filtered.map(t => {
|
|---|
| 1470 | const cov = t.cover
|
|---|
| 1471 | ? '<span class="tp-cover" style="background-image:url(\'' + escAttr(t.cover) + '\')"></span>'
|
|---|
| 1472 | : '<span class="tp-cover tp-cover-empty">' + SVG_NOTE + '</span>';
|
|---|
| 1473 | const dis = t.playable ? '' : ' aria-disabled="true"';
|
|---|
| 1474 | const sub = t.artist ? '<span class="tp-row-artist">' + escAttr(t.artist) + '</span>' : '';
|
|---|
| 1475 | return (
|
|---|
| 1476 | '<button type="button" class="tp-row" role="option" data-track-id="' + escAttr(t.id) + '"' + dis + '>' +
|
|---|
| 1477 | cov +
|
|---|
| 1478 | '<span class="tp-meta">' +
|
|---|
| 1479 | '<span class="tp-row-title">' + escAttr(t.title) + '</span>' +
|
|---|
| 1480 | sub +
|
|---|
| 1481 | '</span>' +
|
|---|
| 1482 | '<span class="tp-duration">' + fmtDur(t.duration) + '</span>' +
|
|---|
| 1483 | '</button>'
|
|---|
| 1484 | );
|
|---|
| 1485 | }).join('');
|
|---|
| 1486 | }
|
|---|
| 1487 |
|
|---|
| 1488 | async function loadTracks() {
|
|---|
| 1489 | if (Array.isArray(tpCache)) return tpCache;
|
|---|
| 1490 | tpEmpty.textContent = 'Tracks laden…';
|
|---|
| 1491 | try {
|
|---|
| 1492 | const r = await fetch('/admin/playlists/api/tracks', { credentials: 'same-origin' });
|
|---|
| 1493 | const j = await r.json();
|
|---|
| 1494 | tpCache = (j && j.ok && Array.isArray(j.tracks)) ? j.tracks : [];
|
|---|
| 1495 | } catch (e) {
|
|---|
| 1496 | tpCache = [];
|
|---|
| 1497 | tpEmpty.textContent = 'Kon tracks niet laden: ' + e.message;
|
|---|
| 1498 | }
|
|---|
| 1499 | return tpCache;
|
|---|
| 1500 | }
|
|---|
| 1501 |
|
|---|
| 1502 | function openPicker() {
|
|---|
| 1503 | tpLastFocus = document.activeElement;
|
|---|
| 1504 | trackPicker.hidden = false;
|
|---|
| 1505 | trackPicker.setAttribute('aria-hidden', 'false');
|
|---|
| 1506 | document.body.classList.add('tp-locked');
|
|---|
| 1507 | tpSearch.value = '';
|
|---|
| 1508 | renderList('');
|
|---|
| 1509 | // Defer focus so the open animation doesn't get jumped
|
|---|
| 1510 | setTimeout(() => tpSearch.focus(), 30);
|
|---|
| 1511 | }
|
|---|
| 1512 | function closePicker() {
|
|---|
| 1513 | trackPicker.hidden = true;
|
|---|
| 1514 | trackPicker.setAttribute('aria-hidden', 'true');
|
|---|
| 1515 | document.body.classList.remove('tp-locked');
|
|---|
| 1516 | if (tpLastFocus && typeof tpLastFocus.focus === 'function') {
|
|---|
| 1517 | try { tpLastFocus.focus(); } catch(_) {}
|
|---|
| 1518 | }
|
|---|
| 1519 | }
|
|---|
| 1520 |
|
|---|
| 1521 | trackBtn.addEventListener('click', async () => {
|
|---|
| 1522 | openPicker();
|
|---|
| 1523 | await loadTracks();
|
|---|
| 1524 | renderList(tpSearch.value);
|
|---|
| 1525 | });
|
|---|
| 1526 |
|
|---|
| 1527 | // Close: backdrop click, [data-tp-close], or Escape
|
|---|
| 1528 | trackPicker.addEventListener('click', (e) => {
|
|---|
| 1529 | if (e.target.closest('[data-tp-close]')) {
|
|---|
| 1530 | closePicker();
|
|---|
| 1531 | return;
|
|---|
| 1532 | }
|
|---|
| 1533 | const row = e.target.closest('.tp-row[data-track-id]');
|
|---|
| 1534 | if (row) {
|
|---|
| 1535 | if (row.getAttribute('aria-disabled') === 'true') return;
|
|---|
| 1536 | const id = row.dataset.trackId;
|
|---|
| 1537 | if (id) {
|
|---|
| 1538 | insertChip('track', id);
|
|---|
| 1539 | closePicker();
|
|---|
| 1540 | }
|
|---|
| 1541 | }
|
|---|
| 1542 | });
|
|---|
| 1543 | document.addEventListener('keydown', (e) => {
|
|---|
| 1544 | if (!trackPicker.hidden && e.key === 'Escape') {
|
|---|
| 1545 | e.preventDefault();
|
|---|
| 1546 | closePicker();
|
|---|
| 1547 | }
|
|---|
| 1548 | });
|
|---|
| 1549 |
|
|---|
| 1550 | // Live filter
|
|---|
| 1551 | tpSearch.addEventListener('input', () => renderList(tpSearch.value));
|
|---|
| 1552 | }
|
|---|
| 1553 |
|
|---|
| 1554 | // ── Playlist insert (open existing or create new via modal)
|
|---|
| 1555 | const playlistBtn = document.getElementById('insert-playlist-btn');
|
|---|
| 1556 | if (playlistBtn) {
|
|---|
| 1557 | playlistBtn.addEventListener('click', async () => {
|
|---|
| 1558 | if (typeof window.openPlaylistEditor !== 'function') {
|
|---|
| 1559 | alert('Playlist editor niet geladen');
|
|---|
| 1560 | return;
|
|---|
| 1561 | }
|
|---|
| 1562 | try {
|
|---|
| 1563 | const r = await fetch('/admin/playlists/api/list', { credentials: 'same-origin' });
|
|---|
| 1564 | const j = await r.json();
|
|---|
| 1565 | if (j.ok && Array.isArray(j.playlists) && j.playlists.length > 0) {
|
|---|
| 1566 | const choice = prompt(
|
|---|
| 1567 | 'Bestaande playlists:\n\n' +
|
|---|
| 1568 | j.playlists.map((p, i) => `${i + 1}. ${p.title} (${p.track_count} tracks)`).join('\n') +
|
|---|
| 1569 | '\n\nKies een nummer om in te voegen, leeg = nieuwe maken:'
|
|---|
| 1570 | );
|
|---|
| 1571 | if (choice && /^\d+$/.test(choice.trim())) {
|
|---|
| 1572 | const idx = parseInt(choice.trim(), 10) - 1;
|
|---|
| 1573 | if (idx >= 0 && idx < j.playlists.length) {
|
|---|
| 1574 | insertChip('playlist', j.playlists[idx].id);
|
|---|
| 1575 | return;
|
|---|
| 1576 | }
|
|---|
| 1577 | }
|
|---|
| 1578 | if (choice === null) return;
|
|---|
| 1579 | }
|
|---|
| 1580 | } catch (_) { /* fall through to create */ }
|
|---|
| 1581 |
|
|---|
| 1582 | window.openPlaylistEditor({
|
|---|
| 1583 | mode: 'create',
|
|---|
| 1584 | onSaved: ({ id }) => insertChip('playlist', id),
|
|---|
| 1585 | });
|
|---|
| 1586 | });
|
|---|
| 1587 | }
|
|---|
| 1588 |
|
|---|
| 1589 | // ── Submit: serialize editor contents into the hidden field
|
|---|
| 1590 | if (form && hiddenField) {
|
|---|
| 1591 | form.addEventListener('submit', () => {
|
|---|
| 1592 | const clone = editor.cloneNode(true);
|
|---|
| 1593 | serializeChips(clone);
|
|---|
| 1594 | hiddenField.value = clone.innerHTML;
|
|---|
| 1595 | });
|
|---|
| 1596 | }
|
|---|
| 1597 | })();
|
|---|
| 1598 | </script>
|
|---|
| 1599 |
|
|---|
| 1600 | <%# ── Track picker modal (P59). Mobile-first: full-screen sheet on small
|
|---|
| 1601 | viewports, centered modal on ≥640px. Populated lazily on first open. %>
|
|---|
| 1602 | <% if (typeof user !== 'undefined' && user) { %>
|
|---|
| 1603 | <div id="track-picker" class="tp-modal" hidden aria-hidden="true">
|
|---|
| 1604 | <div class="tp-backdrop" data-tp-close></div>
|
|---|
| 1605 | <div class="tp-sheet" role="dialog" aria-modal="true" aria-labelledby="tp-title">
|
|---|
| 1606 | <header class="tp-header">
|
|---|
| 1607 | <h2 id="tp-title" class="tp-h2">Track invoegen</h2>
|
|---|
| 1608 | <button type="button" class="tp-close" data-tp-close aria-label="Sluiten">
|
|---|
| 1609 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|---|
| 1610 | </button>
|
|---|
| 1611 | </header>
|
|---|
| 1612 | <div class="tp-search-row">
|
|---|
| 1613 | <span class="tp-search-icon" aria-hidden="true">
|
|---|
| 1614 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
|
|---|
| 1615 | </span>
|
|---|
| 1616 | <input type="search" class="tp-search" id="tp-search" placeholder="Zoek op titel of artiest…" autocomplete="off" inputmode="search">
|
|---|
| 1617 | </div>
|
|---|
| 1618 | <div class="tp-list" id="tp-list" role="listbox" aria-label="Tracks">
|
|---|
| 1619 | <div class="tp-empty" id="tp-empty">Tracks laden…</div>
|
|---|
| 1620 | </div>
|
|---|
| 1621 | </div>
|
|---|
| 1622 | </div>
|
|---|
| 1623 | <% } %>
|
|---|
| 1624 |
|
|---|
| 1625 | <%# Playlist editor modal — included so its global window.openPlaylistEditor
|
|---|
| 1626 | is available when the toolbar button fires. Only renders if user can post. %>
|
|---|
| 1627 | <% if (typeof user !== 'undefined' && user) { %>
|
|---|
| 1628 | <%- include('../partials/playlist-editor', { csrfToken: (typeof csrfToken !== 'undefined' ? csrfToken : '') }) %>
|
|---|
| 1629 | <% } %>
|
|---|
| 1630 |
|
|---|
| 1631 | <script>
|
|---|
| 1632 | (function () {
|
|---|
| 1633 | // Vastpinnen: checkbox toggelt het verborgen rang-veld (0 = niet gepind),
|
|---|
| 1634 | // ▲▼ verschuift de plek, met een leesbare beschrijving i.p.v. een ruw getal.
|
|---|
| 1635 | var toggle = document.getElementById('pin-toggle');
|
|---|
| 1636 | var rank = document.getElementById('pin-rank');
|
|---|
| 1637 | var pos = document.getElementById('pin-pos');
|
|---|
| 1638 | var label = document.getElementById('pin-label');
|
|---|
| 1639 | var up = document.getElementById('pin-up'); // hoger = lager getal (richting 1/bovenaan)
|
|---|
| 1640 | var down = document.getElementById('pin-down');
|
|---|
| 1641 | if (!toggle || !rank || !pos) return;
|
|---|
| 1642 |
|
|---|
| 1643 | function descr(n) {
|
|---|
| 1644 | n = Number(n) || 0;
|
|---|
| 1645 | if (n <= 1) return 'bovenaan';
|
|---|
| 1646 | return n + 'e van boven';
|
|---|
| 1647 | }
|
|---|
| 1648 | function render() {
|
|---|
| 1649 | var on = toggle.checked;
|
|---|
| 1650 | pos.hidden = !on;
|
|---|
| 1651 | if (on && Number(rank.value) < 1) rank.value = 1;
|
|---|
| 1652 | if (!on) rank.value = 0;
|
|---|
| 1653 | if (label) label.textContent = on ? descr(rank.value) : '';
|
|---|
| 1654 | if (up) up.disabled = Number(rank.value) <= 1;
|
|---|
| 1655 | }
|
|---|
| 1656 | toggle.addEventListener('change', render);
|
|---|
| 1657 | if (up) up.addEventListener('click', function () { rank.value = Math.max(1, (Number(rank.value) || 1) - 1); render(); });
|
|---|
| 1658 | if (down) down.addEventListener('click', function () { rank.value = (Number(rank.value) || 0) + 1; render(); });
|
|---|
| 1659 | render();
|
|---|
| 1660 | })();
|
|---|
| 1661 |
|
|---|
| 1662 | (function () {
|
|---|
| 1663 | // De Opslaan/Annuleren-balk (position: sticky; bottom:0) net boven twee mogelijke
|
|---|
| 1664 | // obstakels houden door een dynamische bottom-offset te zetten = het grootste van:
|
|---|
| 1665 | // 1) de hoogte van het toetsenbord-deel dat de layout-viewport NIET dekt
|
|---|
| 1666 | // (op iOS verschuift de visual viewport; op Android verkleint de layout-
|
|---|
| 1667 | // viewport door interactive-widget=resizes-content → offset ≈ 0);
|
|---|
| 1668 | // 2) de hoogte van de spelende audiospeler (fixed, z-index 1000).
|
|---|
| 1669 | // We blijven bij sticky (geen fixed/top-gegoochel → geen balk midden in beeld).
|
|---|
| 1670 | var bar = document.querySelector('.pe-actions');
|
|---|
| 1671 | if (!bar) return;
|
|---|
| 1672 | var vv = window.visualViewport;
|
|---|
| 1673 | function position() {
|
|---|
| 1674 | var ap = document.querySelector('.audio-player');
|
|---|
| 1675 | var playing = document.body.classList.contains('has-audio-player') &&
|
|---|
| 1676 | ap && getComputedStyle(ap).display !== 'none';
|
|---|
| 1677 | var audioOffset = playing ? Math.round(ap.getBoundingClientRect().height) : 0;
|
|---|
| 1678 | var kbCovered = vv ? Math.max(0, Math.round(window.innerHeight - vv.height - vv.offsetTop)) : 0;
|
|---|
| 1679 | var offset = Math.max(audioOffset, kbCovered);
|
|---|
| 1680 | bar.style.bottom = offset ? offset + 'px' : '';
|
|---|
| 1681 | }
|
|---|
| 1682 | position();
|
|---|
| 1683 | window.addEventListener('resize', position);
|
|---|
| 1684 | if (vv) { vv.addEventListener('resize', position); vv.addEventListener('scroll', position); }
|
|---|
| 1685 | // has-audio-player wisselt via een body-class → daarop reageren.
|
|---|
| 1686 | try { new MutationObserver(position).observe(document.body, { attributes: true, attributeFilter: ['class'] }); } catch (_) {}
|
|---|
| 1687 | })();
|
|---|
| 1688 | </script>
|
|---|