@cms-93/editor 0.0.0-stage → 0.0.1

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.
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # @cms-93/editor
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **Preview release (0.0.x).** cms-93 is in early development: the API and the content format may change in any release, without notice. Pin the exact version in your `package.json` and read the changelog before updating.
4
+
5
+ The /admin interface: the real website, editable, plus the collections section.
6
+
7
+ The website is shown in an iframe on the same origin, which puts it in edit mode (`isEditing()` in [`@cms-93/core`](../core)). Over it, the editor outlines what can be edited and lets you write in place, with the rules of the [protocol](../../docs/PROTOCOL.md):
8
+
9
+ - One line of plain text: Enter does nothing, and pasting keeps only the text, in one line.
10
+ - Bold and italic, unless the website's CSS already sets them.
11
+ - Never more characters than `data-editable-max`, with a counter that warns from 90 % on.
12
+ - The same key everywhere: editing a text changes every element with its key.
13
+
14
+ Images are changed in a crop panel: another photo can be uploaded, and the editor chooses how it fills its slot and its alternative text. The slot keeps the proportion of the design (`data-editable-ratio`, or its box on the page): the photo either fills it, cropped, with a focal point that always shows (`cover`), or is shown whole inside it (`contain`).
15
+
16
+ Each locale is edited apart. The bar switches between them, marks with an amber dot the locales with texts still to translate on the page, and outlines those texts. A locale without a value of its own shows the default locale's, and then the HTML.
17
+
18
+ The editor paints the content it has (saved, and not saved yet) over every page it shows, so the website doesn't need its own script to be edited. Save (or Cmd+S, Ctrl+S) sends every change to the server at once; leaving with changes not saved asks first.
19
+
20
+ ## Develop
21
+
22
+ From the root of the repository, `pnpm dev` starts the server and this editor at http://localhost:5193/admin/, with [`examples/html`](../../examples/html) as the website. `CMS_WEBSITE_DIR` points it to another static website, and `CMS_SERVER_URL` to another server.
23
+
24
+ ```bash
25
+ pnpm build # dist/, which the server serves at /admin
26
+ pnpm test
27
+ ```
28
+
29
+ ## Structure
30
+
31
+ - `src/domain/`: the editing itself, in plain JavaScript: the rules for text input, the iframe and the changes.
32
+ - `src/state/`: `EditorController`, which joins them and holds the state the interface draws.
33
+ - `src/components/`, `src/modules/`, `src/pages/`: the interface, in React, only for what is seen.
34
+
35
+ License: AGPL-3.0 (see `LICENSE`).
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Bold">
3
+ <path id="Icon" d="M4 8H9.33333C10.0406 8 10.7189 7.71905 11.219 7.21895C11.719 6.71885 12 6.04058 12 5.33333C12 4.62609 11.719 3.94781 11.219 3.44772C10.7189 2.94762 10.0406 2.66667 9.33333 2.66667H4V8ZM4 8H10C10.7072 8 11.3855 8.28095 11.8856 8.78105C12.3857 9.28115 12.6667 9.95942 12.6667 10.6667C12.6667 11.3739 12.3857 12.0522 11.8856 12.5523C11.3855 13.0524 10.7072 13.3333 10 13.3333H4V8Z" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" stroke="#F4F4F5"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1 @@
1
+ ._frame_6y66j_1{background:#fff;border:0;width:100%;height:100%;display:block}._outline_1dasz_1{border:1px solid var(--cms-color-outline-editable);border-radius:var(--cms-radius-sm);width:100%;height:100%;display:block}._editing_1dasz_9{border-width:2px}._limit_1dasz_13{border-width:2px;border-color:var(--cms-color-danger)}._missing_1dasz_18{border-style:dashed;border-color:var(--cms-color-warning)}._counter_1av2q_1{letter-spacing:0;padding:var(--cms-space-2) var(--cms-space-6);border-radius:var(--cms-radius-sm);font-variant-numeric:tabular-nums;white-space:nowrap;align-items:center;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.6875rem;font-weight:500;line-height:.875rem;display:inline-flex}._normal_1av2q_15{background:var(--cms-color-accent);color:var(--cms-color-on-accent)}._near_1av2q_20{background:var(--cms-color-warning);color:var(--cms-color-on-warning)}._limit_1av2q_25{background:var(--cms-color-danger);color:var(--cms-color-on-danger)}._icon_1wqs8_1{width:1rem;height:1rem;-webkit-mask:var(--icon) center/contain no-repeat;mask:var(--icon) center/contain no-repeat;background-color:currentColor;flex:none;display:block}._button_96mcg_1{letter-spacing:0;align-items:center;gap:var(--cms-space-6);padding:var(--cms-space-8) var(--cms-space-12);border:1px solid var(--cms-color-bar-border);border-radius:var(--cms-radius-full);background:var(--cms-color-bar-bg);color:var(--cms-color-bar-text);white-space:nowrap;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:600;line-height:1rem;display:inline-flex;box-shadow:0 4px 16px #0000003d}._overlay_1luo7_1{pointer-events:none;position:relative;overflow:hidden}._frame_1luo7_7{box-sizing:content-box;margin:-4px;padding:4px;position:absolute}._outline_1luo7_14{width:auto;height:auto;position:absolute;inset:0}._counter_1luo7_21{right:0;bottom:calc(100% + var(--cms-space-4));position:absolute}._imageButton_1luo7_27{position:absolute;top:50%;left:50%;translate:-50% -50%}._bar_uhjr1_1{align-items:center;gap:var(--cms-space-4);padding:var(--cms-space-6);border:1px solid var(--cms-color-bar-border);border-radius:var(--cms-radius-lg);background:var(--cms-color-bar-bg);color:var(--cms-color-bar-text);display:flex;box-shadow:0 2px 6px #00000029,0 12px 32px #00000047}._divider_1ybb7_1{background:var(--cms-color-bar-border);flex:none;width:1px;height:1.25rem;display:block}._button_1o832_1{appearance:none;color:inherit;font:inherit;cursor:pointer;letter-spacing:0;background:0 0;border:0;margin:0;padding:0;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:600;line-height:1rem}._button_1o832_1:focus-visible{outline:2px solid var(--cms-color-accent);outline-offset:2px}._button_1o832_1{padding:var(--cms-space-8) var(--cms-space-12);border-radius:var(--cms-radius-md);white-space:nowrap;justify-content:center;align-items:center;transition:background-color .12s cubic-bezier(.2,0,0,1),color .12s cubic-bezier(.2,0,0,1);display:inline-flex}._button_1o832_1:disabled{cursor:default}._ghost_1o832_33{box-shadow:inset 0 0 0 1px var(--cms-color-bar-border);color:var(--cms-color-bar-text)}._ghost_1o832_33:hover:not(:disabled){background:var(--cms-color-bar-item-hover)}._ghost_1o832_33:disabled{color:var(--cms-color-bar-text-disabled)}._primary_1o832_44{background:var(--cms-color-accent);color:var(--cms-color-on-accent)}._primary_1o832_44:disabled{background:var(--cms-color-bar-item-on);color:var(--cms-color-bar-text-disabled)}._tooltip_1wydf_1{letter-spacing:0;padding:var(--cms-space-6) var(--cms-space-8);border:1px solid var(--cms-color-bar-border);border-radius:var(--cms-radius-md);background:var(--cms-color-surface-tooltip);color:var(--cms-color-bar-text);white-space:nowrap;align-items:center;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:400;line-height:1.125rem;display:inline-flex;box-shadow:0 4px 16px #0000003d}._root_1vtuc_1{display:inline-flex;position:relative}._button_1vtuc_6{appearance:none;color:inherit;font:inherit;cursor:pointer;background:0 0;border:0;margin:0;padding:0}._button_1vtuc_6:focus-visible{outline:2px solid var(--cms-color-accent);outline-offset:2px}._button_1vtuc_6{border-radius:var(--cms-radius-md);width:2rem;height:2rem;color:var(--cms-color-bar-text);justify-content:center;align-items:center;transition:background-color .12s cubic-bezier(.2,0,0,1);display:inline-flex}._button_1vtuc_6:hover{background:var(--cms-color-bar-item-hover)}._button_1vtuc_6[aria-pressed=true]{background:var(--cms-color-bar-item-on)}._button_1vtuc_6[aria-disabled=true]{color:var(--cms-color-bar-text-disabled);cursor:default;background:0 0}._reason_1vtuc_42{bottom:calc(100% + var(--cms-space-8));z-index:30;visibility:hidden;opacity:0;pointer-events:none;transition:opacity .12s cubic-bezier(.2,0,0,1);position:absolute;left:0}._root_1vtuc_1:hover ._reason_1vtuc_42,._root_1vtuc_1:focus-within ._reason_1vtuc_42{visibility:visible;opacity:1}._switch_1dblh_1{align-items:center;gap:var(--cms-space-2);display:flex}._option_1dblh_7{appearance:none;color:inherit;font:inherit;cursor:pointer;letter-spacing:0;background:0 0;border:0;margin:0;padding:0;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:600;line-height:1rem}._option_1dblh_7:focus-visible{outline:2px solid var(--cms-color-accent);outline-offset:2px}._option_1dblh_7{align-items:center;gap:var(--cms-space-4);padding:var(--cms-space-6) var(--cms-space-8);border-radius:var(--cms-radius-sm);color:var(--cms-color-bar-text-muted);display:inline-flex}._option_1dblh_7[aria-pressed=true]{background:var(--cms-color-bar-item-on);color:var(--cms-color-bar-text)}._option_1dblh_7:disabled{cursor:default}._option_1dblh_7:hover:not(:disabled,[aria-pressed=true]){background:var(--cms-color-bar-item-hover)}._missing_1dblh_45{border-radius:var(--cms-radius-full);background:var(--cms-color-warning);flex:none;width:.375rem;height:.375rem}._status_1ea4d_1{letter-spacing:0;align-items:center;gap:var(--cms-space-6);padding:var(--cms-space-4) var(--cms-space-8);color:var(--cms-color-bar-text-muted);white-space:nowrap;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:500;line-height:1rem;display:inline-flex}._dot_1ea4d_15{border-radius:var(--cms-radius-full);flex:none;width:.5rem;height:.5rem}._success_1ea4d_22{background:var(--cms-color-success)}._warning_1ea4d_26{background:var(--cms-color-warning)}._accent_1ea4d_30{background:var(--cms-color-accent)}._danger_1ea4d_34{background:var(--cms-color-danger)}._scrim_1c0ff_1{padding:var(--cms-space-24);background:var(--cms-color-surface-scrim);place-items:center;display:grid}._panel_1c0ff_8{max-width:100%;max-height:100%;padding:var(--cms-space-24);border:1px solid var(--cms-color-bar-border);border-radius:var(--cms-radius-lg);background:var(--cms-color-surface-panel);color:var(--cms-color-bar-text);overflow:auto;box-shadow:0 2px 6px #00000029,0 12px 32px #00000047}._point_di6ry_1{border:2px solid var(--cms-color-on-accent);border-radius:var(--cms-radius-full);background:radial-gradient(circle, var(--cms-color-on-accent) 0 .25rem, transparent calc(.25rem + .5px));width:1.75rem;height:1.75rem;display:block;box-shadow:0 1px 4px #0006}._frame_fbx83_1{place-items:center;width:15rem;height:17.5rem;display:grid}._image_fbx83_8,._slot_fbx83_9{width:min(100%, 17.5rem * var(--ratio));aspect-ratio:var(--ratio)}._image_fbx83_8:focus-visible{outline:2px solid var(--cms-color-accent);outline-offset:2px}._image_fbx83_8{border-radius:var(--cms-radius-md);background:var(--cms-color-surface-field);cursor:crosshair;touch-action:none;-webkit-user-select:none;user-select:none;position:relative;overflow:hidden}._image_fbx83_8[aria-busy=true] ._photo_fbx83_27{opacity:.6}._photo_fbx83_27{object-fit:fill;pointer-events:none;width:100%;height:100%;display:block}._crop_fbx83_39{border:1px solid var(--cms-color-on-accent);box-shadow:0 0 0 100vmax var(--cms-color-crop-shade);pointer-events:none;position:absolute}._pointAt_fbx83_46{pointer-events:none;position:absolute;translate:-50% -50%}._slot_fbx83_9{border:1px dashed var(--cms-color-bar-border);border-radius:var(--cms-radius-md);background:repeating-conic-gradient(var(--cms-color-surface-field) 0 25%, var(--cms-color-surface-panel) 0 50%) 0 0/var(--cms-space-16) var(--cms-space-16);overflow:hidden}._slot_fbx83_9[aria-busy=true] ._contained_fbx83_58{opacity:.6}._contained_fbx83_58{object-fit:contain;width:100%;height:100%;display:block}._field_1aqd4_1{gap:var(--cms-space-6);flex-direction:column;display:flex}._label_1aqd4_7{letter-spacing:0;color:var(--cms-color-bar-text-muted);font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.6875rem;font-weight:500;line-height:.875rem}._input_1aqd4_16{letter-spacing:0;width:100%;height:2.25rem;padding:0 var(--cms-space-12);border:1px solid var(--cms-color-bar-border);border-radius:var(--cms-radius-md);background:var(--cms-color-surface-field);color:var(--cms-color-bar-text);font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:400;line-height:1.125rem}._input_1aqd4_16:focus-visible{border-color:var(--cms-color-accent);outline:none}._control_kpp6t_1{gap:var(--cms-space-2);padding:var(--cms-space-2);border:1px solid var(--cms-color-bar-border);border-radius:var(--cms-radius-md);background:var(--cms-color-surface-field);display:flex}._option_kpp6t_10{appearance:none;color:inherit;font:inherit;cursor:pointer;letter-spacing:0;background:0 0;border:0;margin:0;padding:0;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:600;line-height:1rem}._option_kpp6t_10:focus-visible{outline:2px solid var(--cms-color-accent);outline-offset:2px}._option_kpp6t_10{padding:var(--cms-space-6) var(--cms-space-8);border-radius:var(--cms-radius-sm);color:var(--cms-color-bar-text-muted);flex:1;transition:background-color .12s cubic-bezier(.2,0,0,1),color .12s cubic-bezier(.2,0,0,1)}._option_kpp6t_10[aria-checked=true]{background:var(--cms-color-bar-item-on);color:var(--cms-color-bar-text)}._option_kpp6t_10:hover:not([aria-checked=true]){color:var(--cms-color-bar-text)}._panel_ynyv2_1{gap:var(--cms-space-24);display:flex}._media_ynyv2_6{gap:var(--cms-space-12);flex-direction:column;display:flex}._details_ynyv2_12{gap:var(--cms-space-16);flex-direction:column;width:16.25rem;display:flex}._title_ynyv2_19{letter-spacing:0;margin:0;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.9375rem;font-weight:600;line-height:1.25rem}._help_ynyv2_28,._error_ynyv2_29{letter-spacing:0;color:var(--cms-color-bar-text-muted);margin:0;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:400;line-height:1.125rem}._error_ynyv2_29{color:var(--cms-color-danger)}._actions_ynyv2_43{justify-content:flex-end;gap:var(--cms-space-8);margin-top:auto;display:flex}._page_3d3le_1{height:100%;position:relative;overflow:hidden}._site_3d3le_7,._overlay_3d3le_8,._dialog_3d3le_9{position:absolute;inset:0}._site_3d3le_7{z-index:0}._overlay_3d3le_8{z-index:10}._bar_3d3le_22{z-index:20;position:absolute;bottom:1.5rem;left:50%;translate:-50%}._dialog_3d3le_9{z-index:40}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}#root{height:100%}:root{--cms-color-accent:#0d99ff;--cms-color-on-accent:#fff;--cms-color-outline-editable:#0d99ff;--cms-color-selection:#0d99ff3d;--cms-color-warning:#f5b841;--cms-color-on-warning:#0b0b0d;--cms-color-danger:#f04438;--cms-color-on-danger:#fff;--cms-color-success:#12b76a;--cms-color-bar-bg:#18181b;--cms-color-bar-border:#ffffff1f;--cms-color-bar-item-hover:#27272a;--cms-color-bar-item-on:#3f3f46;--cms-color-bar-text:#f4f4f5;--cms-color-bar-text-muted:#a1a1aa;--cms-color-bar-text-disabled:#71717a;--cms-color-surface-tooltip:#0b0b0d;--cms-color-surface-panel:#18181b;--cms-color-surface-field:#27272a;--cms-color-surface-scrim:#0000008f;--cms-color-crop-shade:#0000008f;--cms-color-page:#0b0b0d;--cms-space-2:.125rem;--cms-space-4:.25rem;--cms-space-6:.375rem;--cms-space-8:.5rem;--cms-space-12:.75rem;--cms-space-16:1rem;--cms-space-24:1.5rem;--cms-radius-sm:.25rem;--cms-radius-md:.5rem;--cms-radius-lg:.75rem;--cms-radius-full:999px;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;font-size:100%}body{letter-spacing:0;background:var(--cms-color-page);color:var(--cms-color-bar-text);-webkit-font-smoothing:antialiased;font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;font-size:.8125rem;font-weight:400;line-height:1.125rem}