@lvl99dotcom/edaha-editor 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ :root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--colour-text:#1d1d1f;--colour-muted:#5a5a60;--colour-background:#fff;--colour-surface:#f4f4f6;--colour-border:#d8d8de;--colour-table-outline:#c0c0c6;--colour-link:#3b9a04;--colour-link-hover:#2b6f04;--colour-focus:#3b9a04;--colour-error:#b3261e;--toast-scheme:dark;--toast-text:#ececf0;--toast-background:#1f1f23;--toast-border:#38383f;--toast-accent:#fda26d;--font-family-base:Arial, sans-serif;--font-size-base:16px;--font-size-xl:1.4rem;--font-size-l:1.2rem;--font-size-s:.9rem;--font-size-xs:.8rem;--font-size-title:48px;--font-size-h1:32px;--font-size-h2:28px;--font-size-h3:24px;--font-size-h4:20px;--font-size-h5:18px;--font-size-h6:16px;--border-radius:5px}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}:root[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}:root[data-theme=light] .leaf-device:after{content:"🍃"}:root[data-theme=light] .theme-switcher:after{content:"🌚"}:root[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--colour-text:#ececf0;--colour-muted:#a6a6ae;--colour-background:#141416;--colour-surface:#1f1f23;--colour-border:#38383f;--colour-table-outline:#8a8a92;--colour-link:#dc6d2c;--colour-link-hover:#fda26d;--colour-focus:#fda26d;--colour-error:#ffb4ab;--toast-scheme:light;--toast-text:#1d1d1f;--toast-background:#fff;--toast-border:#d8d8de;--toast-accent:#3b9a04}:root[data-theme=dark] .leaf-device:after{content:"🍂"}:root[data-theme=dark] .theme-switcher:after{content:"🌝"}@media (prefers-color-scheme:dark){:root:not([data-theme=light]){--colour-text:#ececf0;--colour-muted:#a6a6ae;--colour-background:#141416;--colour-surface:#1f1f23;--colour-border:#38383f;--colour-table-outline:#8a8a92;--colour-link:#dc6d2c;--colour-link-hover:#fda26d;--colour-focus:#fda26d;--colour-error:#ffb4ab;--toast-scheme:light;--toast-text:#1d1d1f;--toast-background:#fff;--toast-border:#d8d8de;--toast-accent:#3b9a04}:root:not([data-theme=light]) .leaf-device:after{content:"🍂"}:root:not([data-theme=light]) .theme-switcher:after{content:"🌝"}}*,:before,:after{box-sizing:border-box}body{background:var(--colour-background);color:var(--colour-text);font-family:Arial,sans-serif;font-size:var(--font-size-base);margin:0;line-height:1.6}a{color:var(--colour-link)}a:hover{color:var(--colour-link-hover)}a:focus-visible,button:focus-visible,.button:focus-visible{outline:3px solid var(--colour-focus);outline-offset:2px}h1{font-size:var(--font-size-h1)}h2{font-size:var(--font-size-h2)}h3{font-size:var(--font-size-h3)}h4{font-size:var(--font-size-h4)}h5{font-size:var(--font-size-h5)}h6{font-size:var(--font-size-h6)}img{max-width:100%;height:auto}pre{background:var(--colour-surface);padding:1rem;overflow-x:auto}code{background:var(--colour-surface);color:var(--colour-muted);font-size:var(--font-size-s);padding:.2em}.theme-switcher{appearance:unset;background:0 0;border:0;position:absolute;top:1rem;right:1rem}.visually-hidden{clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}input[type=text],input[type=number],input[type=email],input[type=url],input[type=search],input[type=colorpicker],input[type=date],input[type=date-local],input[type=time],input[type=time-local],input[type=datetime],input[type=datetime-local],textarea,select{background:var(--colour-background);border:solid 1px var(--colour-border);border-radius:var(--border-radius);color:var(--colour-text);font-family:var(--font-family-base);font-size:var(--font-size-base);padding:.25rem .5rem;line-height:1}select{appearance:none;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:right .85rem center,right .55rem center;background-repeat:no-repeat;background-size:.3rem .3rem;padding-inline-end:2rem}.btn{background-color:var(--colour-surface);border:solid 1px var(--colour-border);border-radius:var(--border-radius);color:var(--colour-text);padding:.5rem 1rem;font-size:1rem}.btn:hover{background-color:var(--colour-background);color:var(--colour-text);border-color:var(--colour-muted)}.btn-xs{padding:.3rem .5rem;font-size:.8rem}.btn-s{padding:.5rem 1rem;font-size:.9rem}.btn-none{appearance:unset;border:0;margin:0;padding:0}.btn-save-dirty{background-color:var(--colour-link);border-color:var(--colour-link);color:var(--colour-background)}.btn-save-dirty:hover{background-color:var(--colour-link-hover);border-color:var(--colour-link);color:var(--colour-background)}.edaha-title{font-size:var(--font-size-h3);margin:0 0 .5rem;padding:0}edaha-editor{grid-template-rows:minmax(0,1fr);grid-template-columns:16rem minmax(0,1fr);height:100dvh;display:grid;overflow:hidden}.edaha-editor-nav{padding:1rem;position:relative;overflow-y:auto}.edaha-editor-new button{width:100%}.edaha-editor-filters{margin:.5rem 0 1rem}.edaha-editor-filters select{width:100%}.edaha-editor-article-group h2{color:var(--colour-muted);font-size:var(--font-size-xs);text-transform:uppercase;margin:1rem 0 .25rem;padding:0;font-weight:400}.edaha-editor-article-group ul,.edaha-editor-article-group ol,.edaha-editor-article-group li{margin:0;padding:0;list-style-type:none}.edaha-editor-article-group-item-title{padding:.25rem 0;display:block}.edaha-editor-article-group-item-title[aria-current=page]{background-color:var(--colour-link);color:var(--colour-background);border-radius:var(--border-radius);padding:.25rem .5rem;text-decoration:none}.edaha-editor-article-group-item-meta{font-size:var(--font-size-s);color:var(--colour-muted);display:none}.edaha-editor-composer{min-height:0;overflow:hidden}.welcome-prompt{justify-content:center;align-items:center;height:100%;padding:1rem;display:flex;overflow-y:auto}.welcome-prompt-box{width:min(28rem,100%);margin:auto}.welcome-prompt-message{font-size:var(--font-size-l);text-align:center;margin:0 0 1rem}.welcome-prompt-message .btn-link{font-size:inherit;padding:0}.welcome-prompt-list{border-top:1px solid var(--colour-border);margin:0;padding:0;list-style:none}.welcome-prompt-list li{border-bottom:1px solid var(--colour-border);flex-direction:column;padding:.5rem 0;display:flex}.welcome-prompt-meta{color:var(--colour-muted);font-size:var(--font-size-s)}.welcome-prompt-browse{margin:.75rem auto 0;display:block}edaha-article{height:100%;display:block}edaha-article form{grid-template-columns:minmax(0,1fr) 20rem;height:100%;display:grid}.edaha-article-main{flex-direction:column;min-height:0;padding:1rem;display:flex;overflow-y:auto}.edaha-article-main>*{flex:none}.body-tabs{border-bottom:1px solid var(--colour-border);gap:.25rem;margin-block:.5rem;display:flex}.body-tabs [role=tab]{border-radius:var(--border-radius) var(--border-radius) 0 0;color:var(--colour-muted);background:0 0;border:1px solid #0000;margin-bottom:-1px;padding:.5rem 1rem;font-size:1rem}.body-tabs [role=tab]:hover{color:var(--colour-text)}.body-tabs [role=tab][aria-selected=true]{background:var(--colour-background);border-color:var(--colour-border) var(--colour-border) var(--colour-background);color:var(--colour-text);font-weight:700}.edaha-article-main>.body-panel{flex-direction:column;flex:1 1 0;min-height:300px;display:flex}.edaha-article-title{align-items:flex-start;gap:.5rem;display:flex}.edaha-article-title>edaha-article-data-field{flex:auto;min-width:0}.unsaved-notice{color:var(--colour-muted);font-size:var(--font-size-s);margin:0}.body-panel>edaha-article-data-field{flex-direction:column;flex:1 1 0;min-height:0;margin-block:.5rem 0;display:flex}.body-panel edaha-richtext{flex-direction:column;flex:1 1 0;min-height:0;display:flex}.body-panel .richtext-content{border:1px solid var(--colour-border);border-radius:var(--border-radius);flex:1 1 0;min-height:0;position:relative;overflow-y:auto}.body-panel .richtext-content .ProseMirror{min-height:100%}.body-panel textarea{resize:none;flex:1 1 0;min-height:0;line-height:1.5}.edaha-article-metadata{min-height:0;padding:0 1rem 1rem;overflow-y:auto}.edaha-article-controls{z-index:1;background:var(--colour-background);border-bottom:1px solid var(--colour-border);flex-wrap:wrap;gap:.5rem;padding-block:1rem;display:flex;position:sticky;top:0}edaha-article-data-field{margin-block:.5rem;display:block}edaha-article-data-field input,edaha-article-data-field select,edaha-article-data-field textarea{box-sizing:border-box;width:100%}.toasts{z-index:40;flex-direction:column;align-items:center;gap:.5rem;width:max-content;max-width:min(32rem,100vw - 2rem);display:flex;position:fixed;top:1rem;left:50%;transform:translate(-50%)}.toast{color-scheme:var(--toast-scheme);background:var(--toast-background);border:1px solid var(--toast-border);border-radius:var(--border-radius);color:var(--toast-text);justify-content:space-between;align-items:center;gap:.75rem;padding:.5rem .5rem .5rem 1rem;display:flex;box-shadow:0 4px 16px #00000040}.toast.error{border:2px solid var(--toast-accent)}.toast button{border:1px solid var(--toast-border);border-radius:var(--border-radius);color:inherit;font:inherit;cursor:pointer;background:0 0;padding:.25rem .5rem}.toast button:hover{border-color:var(--toast-text)}.toast button:focus-visible{outline-color:var(--toast-accent)}.dialog-backdrop{z-index:30;background:#0006;place-items:center;display:grid;position:fixed;inset:0}.dialog{background:canvas;border:1px solid;padding:1rem}.preview-controls{align-items:center;gap:.5rem;margin-block:.5rem;display:flex}.preview-frame{flex:1 1 0;min-height:0;display:flex;overflow-x:auto}edaha-article .preview{border:1px solid var(--colour-border);flex:none;max-width:none;margin-inline:auto}.richtext-content .ProseMirror{min-height:20rem;padding:1rem}.richtext-content pre.raw{white-space:pre-wrap;border:1px dashed;padding:.5rem}.richtext-content pre.raw:before{content:"Raw";font-family:system-ui,sans-serif;font-weight:700;display:block}.richtext-content span.raw{white-space:pre-wrap;outline:1px dashed}.richtext-content img{max-width:100%}.richtext-content table{border-collapse:collapse;outline:1px dotted var(--colour-table-outline)}.richtext-content th,.richtext-content td{border:1px dotted var(--colour-table-outline);vertical-align:top;min-width:2rem;padding:.25rem .5rem}.richtext-content :is(th,td)>p{margin:0}.richtext-content .readmore-block,.richtext-content .embed-block{cursor:pointer;border:1px dashed;margin-block:.5rem;padding:.5rem}.richtext-content .block-header{align-items:center;gap:.5rem;display:flex}.richtext-content .block-header span{flex:1}.richtext-content [data-type=details]{cursor:pointer;border:1px dashed;margin-block:.5rem;padding:.5rem}.richtext-content [data-type=details] summary,.richtext-content [data-type=detailsContent]{cursor:text}.richtext-content [data-type=details]>button{display:none}.richtext-content [data-type=details] summary,.richtext-content [data-type=detailsContent]{border:1px dotted;margin-block-start:.5rem;padding:.25rem .5rem;display:block}.richtext-content [data-type=detailsContent][hidden]{display:block}.richtext-content [data-type=details]:before,.richtext-content [data-type=details] summary:before,.richtext-content [data-type=detailsContent]:before{opacity:.6;font-size:.75em;font-weight:400;display:block}.richtext-content [data-type=details]:before{content:"Details"}.richtext-content [data-type=details] summary:before{content:"Summary"}.richtext-content [data-type=detailsContent]:before{content:"Content"}.richtext-content .embed-frame{border:0;width:100%;height:10rem;margin-block-start:.5rem;display:block}.richtext-content .block-header .embed-icon{flex:none}.richtext-content .embed-icon svg,.embed-dialog .embed-icon svg{width:1.25rem;height:1.25rem}.richtext-content .embed-content{white-space:pre-wrap;overflow-wrap:anywhere;margin:.5rem 0 0}.richtext-content .embed-errors{color:var(--colour-error);margin-block-start:.5rem}.richtext-content .embed-errors p,.richtext-content .embed-errors ul{margin:0}.toolbar-embed .embed-icon svg{width:1.5rem;height:1.5rem}.richtext-content .embed-warning{color:var(--colour-error);margin:.5rem 0 0}.embed-dialog{width:min(40rem,100vw - 2rem)}.embed-dialog form{flex-direction:column;min-height:0;display:flex}.embed-dialog-body{flex-direction:column;gap:.5rem;padding:.5rem 1rem;display:flex;overflow-y:auto}.embed-dialog-about,.embed-dialog-hint{color:var(--colour-muted);font-size:var(--font-size-s)}.embed-dialog-hint{margin:0}.embed-dialog-errors ul{color:var(--colour-error);margin:0;padding-inline-start:1.25rem}.embed-dialog textarea[aria-invalid=true]{border-color:var(--colour-error)}.embed-dialog textarea{resize:vertical;min-height:2rem;font-family:ui-monospace,monospace}.embed-dialog-actions{gap:.5rem;padding:.5rem 1rem 1rem;display:flex}.richtext-content .heading-id{opacity:.6;-webkit-user-select:all;user-select:all;margin-inline-start:.5em;font-size:.75em;font-weight:400}.richtext-content .ProseMirror-selectednode{outline:3px solid highlight}.editor-toolbar{flex-wrap:wrap;gap:.25rem;padding-block:.25rem .5rem;display:flex}.toolbar-button{background:var(--colour-surface);border:1px solid var(--colour-border);border-radius:var(--border-radius);min-width:2.25rem;min-height:2.25rem;color:var(--colour-text);cursor:pointer;justify-content:center;align-items:center;padding:.25rem;display:inline-flex}.toolbar-button:hover{border-color:var(--colour-muted)}.toolbar-button[aria-pressed=true]{background:var(--colour-link);border-color:var(--colour-link);color:var(--colour-background)}.toolbar-button:disabled,.toolbar-button[data-disabled]{opacity:.4;cursor:not-allowed}.format-menu{z-index:10;background:var(--colour-background);border:1px solid var(--colour-border);border-radius:var(--border-radius);flex-wrap:nowrap;width:max-content;max-width:calc(100vw - 2rem);padding:.25rem;box-shadow:0 4px 16px #00000040}.toolbar-upload:focus-within{outline:3px solid var(--colour-focus);outline-offset:2px}.icon{display:inline-flex}.icon svg{fill:currentColor;width:1.5rem;height:1.5rem}[data-action=Remove\ column] .icon svg{transform:rotate(90deg)}.body-panel edaha-markdown{flex-direction:column;flex:1 1 0;min-height:0;display:flex}.btn-icon{border-radius:var(--border-radius);min-width:2.75rem;min-height:2.75rem;color:var(--colour-text);cursor:pointer;background:0 0;border:1px solid #0000;justify-content:center;align-items:center;padding:0;display:inline-flex}.btn-icon:hover{border-color:var(--colour-border)}.edaha-editor-bar,.nav-backdrop,.nav-close,.btn-metadata-toggle{display:none}edaha-editor[compact]{grid-template-rows:auto minmax(0,1fr);grid-template-columns:minmax(0,1fr)}edaha-editor[compact] .edaha-editor-bar{border-bottom:1px solid var(--colour-border);align-items:center;gap:.5rem;padding:.25rem .5rem;display:flex}edaha-editor[compact] .edaha-editor-bar-title{font-weight:700}edaha-editor[compact] .edaha-editor-nav{z-index:20;background:var(--colour-background);border-right:1px solid var(--colour-border);visibility:hidden;width:min(20rem,85vw);padding-top:3.5rem;transition:transform .2s,visibility .2s;position:fixed;inset:0 auto 0 0;transform:translate(-100%)}edaha-editor[compact] .edaha-editor-nav.open{visibility:visible;transition:transform .2s,visibility;transform:none}edaha-editor[compact] .nav-close{display:inline-flex;position:absolute;top:.5rem;right:.5rem}edaha-editor[compact] .edaha-editor-nav .theme-switcher{min-width:2.75rem;min-height:2.75rem;top:.5rem;right:3.75rem}edaha-editor[compact] .nav-backdrop.open{z-index:19;background:#0006;display:block;position:fixed;inset:0}edaha-editor[compact] edaha-article form{grid-template-columns:minmax(0,1fr)}edaha-editor[compact] .edaha-article-main{padding-bottom:5rem}edaha-editor[compact] .edaha-article-metadata{z-index:10;background:var(--colour-background);border-top:1px solid var(--colour-border);flex-direction:column;padding:0;display:flex;position:fixed;inset:auto 0 0;overflow:hidden;box-shadow:0 -2px 8px #00000026}edaha-editor[compact] .edaha-article-metadata.open{border-top:0;top:0}edaha-editor[compact] .edaha-article-metadata-fields{display:none}edaha-editor[compact] .edaha-article-metadata.open .edaha-article-metadata-fields{flex:1 1 0;min-height:0;padding:.5rem 1rem 1rem;display:block;overflow-y:auto}edaha-editor[compact] .edaha-article-controls{border-top:1px solid var(--colour-border);border-bottom:0;order:2;padding:.5rem 1rem;position:static}edaha-editor[compact] .btn-metadata-toggle{min-width:2.75rem;margin-inline-start:auto;display:inline-block}edaha-editor[focus-mode] .edaha-article-main{box-sizing:border-box;justify-self:center;width:100%;max-width:900px}@media (width<=899.98px){.btn-focus-mode{display:none}}@media (prefers-reduced-motion:reduce){edaha-editor[compact] .edaha-editor-nav,edaha-editor[compact] .edaha-editor-nav.open{transition:none}}.edaha-editor-search{align-items:center;gap:.25rem;margin:.5rem 0 1rem;display:flex}.edaha-editor-search input{flex:1;min-width:0;min-height:2.25rem}.btn-link{color:var(--colour-link);font:inherit;font-size:var(--font-size-s);cursor:pointer;background:0 0;border:0;padding:.25rem 0;text-decoration:underline}.btn-link:hover{color:var(--colour-link-hover)}.article-browser{background:var(--colour-background);border:1px solid var(--colour-border);border-radius:var(--border-radius);width:min(60rem,100vw - 2rem);max-height:calc(100dvh - 2rem);color:var(--colour-text);padding:0}.article-browser[open]{flex-direction:column;display:flex}.article-browser::backdrop{background:#0006}.article-browser-header{justify-content:space-between;align-items:center;padding:.5rem .5rem 0 1rem;display:flex}.article-browser-header h2{font-size:var(--font-size-h4);margin:0}.article-browser-controls{grid-template-columns:repeat(auto-fill,minmax(10rem,1fr));gap:.5rem 1rem;padding:.5rem 1rem;display:grid}.article-browser-field{flex-direction:column;gap:.25rem;display:flex}.article-browser-field label{font-size:var(--font-size-s)}.article-browser-field input,.article-browser-field select{width:100%;min-height:2.25rem}.article-browser-search{grid-column:1/-1}.article-browser-status{color:var(--colour-muted);font-size:var(--font-size-s);border-bottom:1px solid var(--colour-border);margin:0;padding:.25rem 1rem}.article-browser-results{flex:auto;min-height:0;padding:.5rem 1rem 1rem;overflow:auto}.article-browser-table{border-collapse:collapse;width:100%;min-width:36rem;font-size:var(--font-size-s)}.article-browser-table th,.article-browser-table td{border-bottom:1px solid var(--colour-border);text-align:left;vertical-align:top;padding:.5rem .75rem .5rem 0}.article-browser-table td:not(:first-child){color:var(--colour-muted);white-space:nowrap}.article-browser-table td:first-child{font-size:1rem}.article-browser-table td .error{display:block}.sort-heading{min-height:2rem;color:var(--colour-text);font:inherit;white-space:nowrap;cursor:pointer;background:0 0;border:0;align-items:center;gap:.25rem;padding:0;font-weight:700;display:inline-flex}.sort-heading:hover{color:var(--colour-link)}.sort-heading-arrow{font-size:.7em}.article-browser-pages{justify-content:center;align-items:center;gap:1rem;padding-top:1rem;display:flex}@media (width<=899.98px){.article-browser{border:0;border-radius:0;width:100vw;max-width:none;height:100dvh;max-height:none;margin:0}}.file-browser-operations{align-items:center;gap:.25rem;display:flex}.file-browser-operations .btn-icon{min-width:2.25rem;min-height:2.25rem;color:var(--colour-text)}edaha-metadata-field{margin-block:.5rem;display:block}.metadata-field label{display:block}.metadata-field input:not([type=checkbox],[type=radio],[type=color]),.metadata-field select,.metadata-field textarea{box-sizing:border-box;width:100%}.metadata-group,.metadata-radio{border:1px solid var(--colour-border);border-radius:var(--border-radius);margin:0;padding:.5rem}.metadata-item{align-items:flex-end;gap:.5rem;display:flex}.metadata-item edaha-metadata-field{flex:1}.metadata-check,.metadata-choice{grid-template-columns:1rem 1fr;align-items:center;column-gap:.5rem;margin-block:.25rem;display:grid}.metadata-check input,.metadata-choice input{width:1rem;height:1rem;margin:0}.metadata-choice small{color:var(--colour-muted);grid-column:2}.metadata-checkbox>:not(.metadata-check){margin-inline-start:1.5rem}.metadata-description,.metadata-info{color:var(--colour-muted);font-size:var(--font-size-s);margin:.25rem 0}.metadata-problems,.metadata-warnings{font-size:var(--font-size-s);margin:.25rem 0;padding:0;list-style:none}.metadata-problems .error{color:var(--colour-error);font-weight:700}.metadata-problems .error:before{content:"⚠️ "}.metadata-warnings li,.metadata-problems .warning{color:var(--colour-muted)}[aria-invalid=true]{border-color:var(--colour-error);outline:1px solid var(--colour-error)}.metadata-file{align-items:center;gap:.5rem;margin:.25rem 0;display:flex}.welcome-attention{margin-top:1.5rem}.welcome-attention h2{font-size:var(--font-size-h5);margin:0 0 .5rem}.article-browser-table td .problems{color:var(--colour-muted);display:block}.settings-group{border-bottom:1px solid var(--colour-border)}.settings-group>summary{cursor:pointer;align-items:center;gap:.25rem;min-height:2.75rem;padding:.5rem 0;font-weight:700;list-style:none;display:flex}.settings-group>summary::-webkit-details-marker{display:none}.settings-group>summary:before{content:"▸";width:1rem;transition:transform .15s;display:inline-block}.settings-group[open]>summary:before{transform:rotate(90deg)}@media (prefers-reduced-motion:reduce){.settings-group>summary:before{transition:none}}.settings-group>summary:focus-visible{outline:3px solid var(--colour-focus);outline-offset:2px}.settings-group[open]>summary{margin-bottom:.25rem}.settings-group[open]{padding-bottom:.75rem}.settings-group-errors{margin-inline-start:auto}.settings-group-description{color:var(--colour-muted);font-size:var(--font-size-s);margin:0 0 .5rem}.files-title{font-size:var(--font-size-s);margin:.75rem 0 .25rem}.no-author{align-items:center;gap:.5rem;margin-block:.25rem;display:flex}.metadata-warnings li{justify-content:space-between;align-items:flex-start;gap:.5rem;margin-block:.25rem;display:flex}.edaha-title-button{color:inherit;font:inherit;text-align:inherit;cursor:pointer;background:0 0;border:0;margin:0;padding:0}
@@ -0,0 +1,21 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Article editor | edaha.md</title>
7
+ <script>
8
+ // Show the theme chosen with the theme switcher (see src/client/theme) before the page appears
9
+ try {
10
+ const theme = localStorage.getItem("edaha-editor-theme");
11
+ if (theme === "light" || theme === "dark")
12
+ document.documentElement.dataset.theme = theme;
13
+ } catch {}
14
+ </script>
15
+ <script type="module" crossorigin src="/_editor/assets/index-BwcJ6yrI.js"></script>
16
+ <link rel="stylesheet" crossorigin href="/_editor/assets/index-D2Y17Fm-.css">
17
+ </head>
18
+ <body>
19
+ <edaha-editor></edaha-editor>
20
+ </body>
21
+ </html>
@@ -0,0 +1,69 @@
1
+ import { Hono } from "hono";
2
+ import { EDITOR_PORT } from "@lvl99dotcom/edaha.md/cli";
3
+ import type { EmbedPlugin } from "@lvl99dotcom/edaha.md/embeds";
4
+ import { type SiteConfigOptions } from "@lvl99dotcom/edaha.md/generator/configFile";
5
+ /** The editor only listens on this computer's own address, so nothing else on the network can reach it */
6
+ export declare const EDITOR_HOST = "127.0.0.1";
7
+ /** The editor's default port (the same as `edaha editor`'s) */
8
+ export { EDITOR_PORT };
9
+ /** The URL path the editor page's own files (scripts, styles) are served under, apart from the site's static files */
10
+ export declare const EDITOR_BASE = "/_editor/";
11
+ /**
12
+ * The editor page's built files (`dist/client`, bundled by Vite). The path is the same from `src/editor` (in the
13
+ * workspace) and from the published `dist/editor`, so the editor never serves the page's unbuilt source.
14
+ */
15
+ export declare const CLIENT_DIR: string;
16
+ /** Options for the article editor's server */
17
+ export interface EditorServerOptions extends SiteConfigOptions {
18
+ /** The default theme folder that the site's templates and static files override. Default: THEME_DIR */
19
+ themeDir?: string;
20
+ /** The port to listen on. Default: EDITOR_PORT */
21
+ port?: number;
22
+ /** The editor page's built files. Default: CLIENT_DIR */
23
+ clientDir?: string;
24
+ /** Fetches extra data for embeds (defaults to the global fetch) */
25
+ fetch?: typeof fetch;
26
+ /** Embed plugins added after the config file's `plugins` (a key in both uses the config file's). Default: none */
27
+ plugins?: readonly EmbedPlugin[];
28
+ }
29
+ /** A running editor server */
30
+ export interface EditorServer {
31
+ /** The editor's address, e.g. "http://127.0.0.1:5180" */
32
+ url: string;
33
+ /** Stop the server */
34
+ close: () => Promise<void>;
35
+ }
36
+ /**
37
+ * The editor's address for a port.
38
+ *
39
+ * @example
40
+ * editorUrl(5180); // "http://127.0.0.1:5180"
41
+ */
42
+ export declare const editorUrl: (port: number) => string;
43
+ /**
44
+ * The port an editor listens on: the given one, or EDITOR_PORT.
45
+ *
46
+ * @example
47
+ * editorPort({}); // 5180
48
+ */
49
+ export declare const editorPort: (options: EditorServerOptions) => number;
50
+ /**
51
+ * Create the article editor's web app: the editor page at `/`, its files under `EDITOR_BASE`, and the editor API,
52
+ * previews and the site's static files (see createEditorApp) everywhere else. Throws if the site's config file can't be
53
+ * found or read.
54
+ *
55
+ * @example
56
+ * const app = await createEditorServer({ siteDir: "my-site" });
57
+ * await app.request("/"); // the editor page
58
+ */
59
+ export declare const createEditorServer: (options: EditorServerOptions) => Promise<Hono>;
60
+ /**
61
+ * Start the article editor on this computer only (`EDITOR_HOST`). Never deploy it: it reads and writes the site's
62
+ * files.
63
+ *
64
+ * @example
65
+ * const editor = await startEditor({ siteDir: "my-site" });
66
+ * console.log(`Open ${editor.url}`);
67
+ * await editor.close();
68
+ */
69
+ export declare const startEditor: (options: EditorServerOptions) => Promise<EditorServer>;
@@ -0,0 +1,125 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { serve } from "@hono/node-server";
5
+ import { Hono } from "hono";
6
+ import mime from "mime-types";
7
+ import { EDITOR_PORT } from "@lvl99dotcom/edaha.md/cli";
8
+ import { createEditorApp, previewOriginOf } from "../server/app/index.js";
9
+ import { ArticleStore } from "../server/store/index.js";
10
+ import { loadSiteConfig, } from "@lvl99dotcom/edaha.md/generator/configFile";
11
+ /** The editor only listens on this computer's own address, so nothing else on the network can reach it */
12
+ export const EDITOR_HOST = "127.0.0.1";
13
+ /** The editor's default port (the same as `edaha editor`'s) */
14
+ export { EDITOR_PORT };
15
+ /** The URL path the editor page's own files (scripts, styles) are served under, apart from the site's static files */
16
+ export const EDITOR_BASE = "/_editor/";
17
+ /**
18
+ * The editor page's built files (`dist/client`, bundled by Vite). The path is the same from `src/editor` (in the
19
+ * workspace) and from the published `dist/editor`, so the editor never serves the page's unbuilt source.
20
+ */
21
+ export const CLIENT_DIR = fileURLToPath(new URL("../../dist/client", import.meta.url));
22
+ /**
23
+ * The editor's address for a port.
24
+ *
25
+ * @example
26
+ * editorUrl(5180); // "http://127.0.0.1:5180"
27
+ */
28
+ export const editorUrl = (port) => `http://${EDITOR_HOST}:${port}`;
29
+ /**
30
+ * The port an editor listens on: the given one, or EDITOR_PORT.
31
+ *
32
+ * @example
33
+ * editorPort({}); // 5180
34
+ */
35
+ export const editorPort = (options) => options.port ?? EDITOR_PORT;
36
+ /**
37
+ * Read one of the editor page's built files, or undefined if there is no such file or the path leaves the folder.
38
+ */
39
+ const clientFile = async (clientDir, path) => {
40
+ const parts = path.split("/");
41
+ if (parts.some((part) => part === "" || part.startsWith(".")))
42
+ return undefined;
43
+ try {
44
+ return (await readFile(join(clientDir, ...parts)));
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ };
50
+ /**
51
+ * Create the article editor's web app: the editor page at `/`, its files under `EDITOR_BASE`, and the editor API,
52
+ * previews and the site's static files (see createEditorApp) everywhere else. Throws if the site's config file can't be
53
+ * found or read.
54
+ *
55
+ * @example
56
+ * const app = await createEditorServer({ siteDir: "my-site" });
57
+ * await app.request("/"); // the editor page
58
+ */
59
+ export const createEditorServer = async (options) => (await editorServerParts(options)).app;
60
+ /** The editor's web app, and the article store it uses (which watches the articles folder until closed) */
61
+ const editorServerParts = async (options) => {
62
+ const port = editorPort(options);
63
+ const clientDir = options.clientDir ?? CLIENT_DIR;
64
+ const store = new ArticleStore(await loadSiteConfig(options), options.themeDir);
65
+ // Every article is read and checked as the editor starts
66
+ await store.load();
67
+ const previewOrigin = previewOriginOf(editorUrl(port));
68
+ const editorApp = createEditorApp(store, {
69
+ allowedOrigins: [editorUrl(port)],
70
+ fetch: options.fetch,
71
+ plugins: options.plugins,
72
+ previewOrigin,
73
+ });
74
+ const app = new Hono();
75
+ // The previews' own origin doesn't show the editor page or its files
76
+ app.use("/", async (c, next) => new URL(c.req.url).origin === previewOrigin
77
+ ? c.json({ error: "Not found" }, 404)
78
+ : next());
79
+ app.use(`${EDITOR_BASE}*`, async (c, next) => new URL(c.req.url).origin === previewOrigin
80
+ ? c.json({ error: "Not found" }, 404)
81
+ : next());
82
+ app.get("/", async (c) => {
83
+ const html = await clientFile(clientDir, "index.html");
84
+ if (!html)
85
+ return c.text("The editor page is missing; build it with `pnpm build`", 500);
86
+ return c.body(html, 200, {
87
+ "Content-Type": "text/html; charset=utf-8",
88
+ "Cache-Control": "no-store",
89
+ });
90
+ });
91
+ app.get(`${EDITOR_BASE}*`, async (c) => {
92
+ const path = decodeURIComponent(c.req.path.slice(EDITOR_BASE.length));
93
+ const contents = await clientFile(clientDir, path);
94
+ if (!contents)
95
+ return c.json({ error: "File not found" }, 404);
96
+ return c.body(contents, 200, {
97
+ "Content-Type": mime.lookup(path) || "application/octet-stream",
98
+ });
99
+ });
100
+ app.route("/", editorApp);
101
+ return { app, store };
102
+ };
103
+ /**
104
+ * Start the article editor on this computer only (`EDITOR_HOST`). Never deploy it: it reads and writes the site's
105
+ * files.
106
+ *
107
+ * @example
108
+ * const editor = await startEditor({ siteDir: "my-site" });
109
+ * console.log(`Open ${editor.url}`);
110
+ * await editor.close();
111
+ */
112
+ export const startEditor = async (options) => {
113
+ const port = editorPort(options);
114
+ const { app, store } = await editorServerParts(options);
115
+ return new Promise((resolve, reject) => {
116
+ const server = serve({ fetch: app.fetch, hostname: EDITOR_HOST, port }, () => resolve({
117
+ url: editorUrl(port),
118
+ close: () => {
119
+ store.close();
120
+ return new Promise((done, fail) => server.close((error) => (error ? fail(error) : done())));
121
+ },
122
+ }));
123
+ server.once("error", reject);
124
+ });
125
+ };
@@ -0,0 +1 @@
1
+ export { createEditorServer, EDITOR_HOST, EDITOR_PORT, startEditor, type EditorServer, type EditorServerOptions, } from "./editor/index.ts";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // The article editor's public API: start the local editor for an edaha.md site, or create its web app to serve it
2
+ // yourself. `edaha editor` (from @lvl99dotcom/edaha.md) uses startEditor.
3
+ export { createEditorServer, EDITOR_HOST, EDITOR_PORT, startEditor, } from "./editor/index.js";
@@ -0,0 +1,98 @@
1
+ import { Hono } from "hono";
2
+ import { type EmbedPlugin } from "@lvl99dotcom/edaha.md/embeds";
3
+ import { type ArticleStore } from "../store/index.ts";
4
+ import type { ArticleQuery, FileQuery } from "../types/index.ts";
5
+ /**
6
+ * Read a file query from a URL's search parameters, e.g. "?search=photo&kind=image&sort=size&order=desc&page=2".
7
+ * Unknown kinds, sorts and orders, and pages that aren't numbers, are left out.
8
+ *
9
+ * @example
10
+ * fileQuery(new URLSearchParams("kind=image&page=2")); // { kind: "image", page: 2 }
11
+ */
12
+ export declare const fileQuery: (params: URLSearchParams) => FileQuery;
13
+ /**
14
+ * Read an article query from a URL's search parameters, e.g. "?search=hello&type=news&sort=title&order=desc&page=2".
15
+ * Unknown statuses, sorts and orders, and pages that aren't numbers, are left out.
16
+ *
17
+ * @example
18
+ * articleQuery(new URLSearchParams("search=hello&page=2")); // { search: "hello", page: 2 }
19
+ */
20
+ export declare const articleQuery: (params: URLSearchParams) => ArticleQuery;
21
+ /** Options for the editor API */
22
+ export interface EditorAppOptions {
23
+ /** Origins allowed to change articles, e.g. "http://127.0.0.1:5180" */
24
+ allowedOrigins: readonly string[];
25
+ /** Fetches extra data for embeds (defaults to the global fetch) */
26
+ fetch?: typeof fetch | undefined;
27
+ /** Embed plugins added after the config file's `plugins` (a key in both uses the config file's). Default: none */
28
+ plugins?: readonly EmbedPlugin[] | undefined;
29
+ /**
30
+ * Optional; the origin preview pages and embed frames are shown from, e.g. "http://localhost:5180": an address of
31
+ * the same server that isn't the editor's own, so they run in an origin (and site) of their own. The API answers
32
+ * nothing there.
33
+ */
34
+ previewOrigin?: string | undefined;
35
+ }
36
+ /**
37
+ * The origin preview pages and embed frames are shown from, for an editor at an address: `localhost` instead of
38
+ * `127.0.0.1`, which is the same server but another origin and site.
39
+ *
40
+ * @example
41
+ * previewOriginOf("http://127.0.0.1:5180"); // "http://localhost:5180"
42
+ */
43
+ export declare const previewOriginOf: (editorOrigin: string) => string;
44
+ /**
45
+ * The Content Security Policy of preview pages, embed frames and the files they load. They are shown from an origin
46
+ * of their own (`previewOrigin`), which the editor's API doesn't answer and whose changes it refuses, and are
47
+ * sandboxed (`sandbox`, keeping their own origin, so embedded players such as Bandcamp's keep theirs) so they can't
48
+ * send forms or navigate the editor page. Inside, they may run their own scripts and styles, and load from their own
49
+ * address and the web addresses the embed plugins list in `sources`. Only the editor's pages may show them in frames.
50
+ *
51
+ * @param self - the address they are served from, e.g. "http://localhost:5180"
52
+ * @param ancestors - the editor's own addresses, which may show them in frames
53
+ * @example
54
+ * previewCsp([youtube], "http://localhost:5180", ["http://127.0.0.1:5180"]); // "sandbox allow-scripts allow-same-origin ...; default-src http://localhost:5180; ...; frame-src https://www.youtube-nocookie.com; ..."
55
+ */
56
+ export declare const previewCsp: (plugins: readonly EmbedPlugin[], self: string, ancestors?: readonly string[]) => string;
57
+ /**
58
+ * The page shown in an embed block's frame in the editor's body: the embed rendered for the editor, with the HTML it
59
+ * needs once, in the editor's light or dark theme.
60
+ *
61
+ * @example
62
+ * embedFramePage('<div class="embed">...</div>', { head: "", foot: "" }, "dark");
63
+ */
64
+ export declare const embedFramePage: (html: string, parts: {
65
+ head: string;
66
+ foot: string;
67
+ }, theme: "light" | "dark" | undefined) => string;
68
+ /**
69
+ * Create the article editor's local API. Requests that change files must come from the editor's own page (checked
70
+ * with the Origin header), so other websites open in the same browser can't write articles.
71
+ *
72
+ * Routes:
73
+ * - `GET /api/articles`: list articles
74
+ * - `GET /api/types`: the article types from the config file, with their labels
75
+ * - `GET /api/templates/:type`: the template names an article of a type can use
76
+ * - `POST /api/articles`: create an article
77
+ * - `GET|PUT|DELETE /api/articles/:type/:slug`: load, save (and move) or delete an article
78
+ * - `POST /api/articles/:type/:slug/files`: upload a file (multipart field "file")
79
+ * - `GET /files/:type/:slug/:name`: an article's file, for previews in the editor
80
+ * - `GET /api/embeds`: the embed plugins (`EmbedInfo`), for the editor's embed dialog
81
+ * - `POST /api/embed-validations`: check an embed block's content (`{ key, content }`) with its plugin's `validate`,
82
+ * giving why it isn't valid (`EmbedValidation`)
83
+ * - `POST /api/embed-frames`: remember an embed block (`{ key, content }`) for its frame in the editor's body, and give
84
+ * the frame's URL, and why its content isn't valid (then it has no frame) or can't be shown (`EmbedFrame`); `GET /embed-frame/:id/?theme=light|dark` is the frame's page
85
+ * - `POST /api/convert/markdown` and `POST /api/convert/html`: convert an article body between editor HTML and Markdown
86
+ * (`{ html | markdown, location? }`, where `location` is the saved article's, which relative URLs are relative to)
87
+ * - `POST /api/preview`: remember unsaved article data (`{ data, location? }`) for a preview page, and give its URL
88
+ * (`{ url }`); answers 400 if it can't be rendered
89
+ * - `GET /preview/:id/`: render a remembered preview with its type's "single" template, and `GET /<path>`: one of the
90
+ * site's static files (e.g. `/site.css`) or an article's file at its path on the website (e.g.
91
+ * `/news/welcome/photo.png`), all sandboxed by their Content Security Policy (`previewCsp`)
92
+ *
93
+ * Embeds are rendered with the config file's `plugins`, then the given `plugins`.
94
+ *
95
+ * @example
96
+ * const app = createEditorApp(new ArticleStore(await loadSiteConfig({ siteDir: "my-site" })), { allowedOrigins: ["http://127.0.0.1:5180"] });
97
+ */
98
+ export declare const createEditorApp: (store: ArticleStore, { allowedOrigins, fetch: fetchFn, plugins: givenPlugins, previewOrigin, }: EditorAppOptions) => Hono;