| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Sri Office — Editor</title> |
| <style> |
| * { box-sizing: border-box; font-family: -apple-system, Segoe UI, Roboto, sans-serif; } |
| html, body { margin: 0; height: 100%; } |
| |
| body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; } |
| header { flex: 0 0 50px; display: flex; align-items: center; gap: 14px; padding: 0 14px; |
| background: #fff; border-bottom: 1px solid #e1dfdd; } |
| .back { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid #e1dfdd; |
| border-radius: 6px; color: #201f1e; text-decoration: none; font-size: 13px; font-weight: 500; |
| white-space: nowrap; flex: 0 0 auto; } |
| .back:hover { background: #f3f2f1; } |
| .title { font-size: 14px; color: #201f1e; font-weight: 600; white-space: nowrap; overflow: hidden; |
| text-overflow: ellipsis; flex: 0 1 auto; max-width: 30vw; } |
| |
| |
| .ad { flex: 1 1 auto; height: 100%; display: flex; align-items: center; justify-content: center; |
| min-width: 0; overflow: hidden; } |
| #ad-slot { height: 38px; width: 100%; max-width: 728px; background: #faf9f8; border: 1px dashed #d2d0ce; |
| border-radius: 6px; display: flex; align-items: center; justify-content: center; |
| color: #a19f9d; font-size: 12px; } |
| #ad-slot a { display: block; } |
| #ad-slot img { max-height: 38px; } |
| #editor { flex: 1 1 auto; min-height: 0; } |
| #placeholder { width: 100%; height: 100%; } |
| #msg { padding: 40px; color: #b30b00; font-size: 15px; } |
| </style> |
| </head> |
| <body> |
| <header> |
| <a class="back" href="/dashboard">← Back</a> |
| <span class="title" id="title"></span> |
| <div class="ad"><div id="ad-slot">Advertisement</div></div> |
| </header> |
| <div id="editor"><div id="placeholder"></div></div> |
| <div id="msg"></div> |
| <script> |
| const params = new URLSearchParams(location.search); |
| const filename = params.get('file'); |
| document.getElementById('title').textContent = filename || ''; |
| |
| const token = localStorage.getItem('token'); |
| if (!token) location.href = '/'; |
| |
| async function init() { |
| if (!filename) { document.getElementById('msg').textContent = 'No file specified.'; return; } |
| let data; |
| try { |
| const res = await fetch('/api/editor-config?filename=' + encodeURIComponent(filename), |
| { headers: { 'Authorization': 'Bearer ' + token } }); |
| if (res.status === 401) { localStorage.clear(); location.href = '/'; return; } |
| if (!res.ok) { document.getElementById('msg').textContent = 'File not found.'; return; } |
| data = await res.json(); |
| } catch (e) { |
| document.getElementById('msg').textContent = 'Could not load editor config.'; return; |
| } |
| |
| try { |
| const c = data.config.editorConfig.customization; |
| c.logo = c.logo || {}; |
| c.logo.url = location.origin + '/dashboard'; |
| } catch (e) {} |
| |
| const s = document.createElement('script'); |
| s.src = data.ds_api_url; |
| s.onload = () => new DocsAPI.DocEditor('placeholder', data.config); |
| s.onerror = () => { document.getElementById('msg').textContent = |
| 'Could not reach the editor service. Please try again.'; }; |
| document.body.appendChild(s); |
| } |
| init(); |
| </script> |
| </body> |
| </html> |
|
|