slop-editor 0.5.0 → 0.6.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
@@ -136,7 +136,7 @@ import slopEditor from 'slop-editor/vite';
136
136
  export default defineConfig({ plugins: [react(), slopEditor()] }); // slopEditor({ text: 'content/words.json' }) to move the file
137
137
  ```
138
138
 
139
- It puts the words in the page as its text block, with `slop.js` and `slop.css`. Under `vite` the page gets an **Edit text** button, and saves go into the words file, version-checked: the file changes under an open page and the page reloads. A build has no editor. Other build tools aren't set up for you yet: put the block, `slop.js` and `slop.css` in the page yourself.
139
+ It puts the words in the page as its text block, with `slop.js` and `slop.css`. Under `vite` the page opens with the editor, and saves go into the words file, version-checked: the file changes under an open page and the page reloads. A build has no editor. Other build tools aren't set up for you yet: put the block, `slop.js` and `slop.css` in the page yourself.
140
140
 
141
141
  By hand, `slop-editor/react` wraps it, with no JSX and no build. slop.js still goes in the page first, as a plain `<script>`.
142
142
 
@@ -155,18 +155,22 @@ import Slop, { SlopText, SlopMeter, slopAttrs, slopList, useSlop } from 'slop-ed
155
155
 
156
156
  ## The editor
157
157
 
158
- `slop-editor edit page.html` serves the page's folder on 127.0.0.1 and opens the page with an **Edit text** button. Published, the page shows no sign of the editor. `Slop.start({edit: 'local'})` gives every visitor an editor that saves in their browser instead (the demo page uses it). When the page's author publishes a new version, a visitor's saved edits carry over: the author's changes win, text by text, and the visitor's stay everywhere else. They're kept under the page's path; on a host that gives each version an address of its own, name the page instead: `Slop.start({edit: 'local', key: 'my-page'})`.
158
+ `slop-editor edit page.html` serves the page's folder on 127.0.0.1 and opens the page with the editor on: every text can be typed into where it is, and a bar in the corner has Save, Colors and **Panel**. Published, the page shows no sign of the editor. `Slop.start({edit: 'local'})` gives every visitor an editor that saves in their browser instead (the demo page uses it). When the page's author publishes a new version, a visitor's saved edits carry over: the author's changes win, text by text, and the visitor's stay everywhere else. They're kept under the page's path; on a host that gives each version an address of its own, name the page instead: `Slop.start({edit: 'local', key: 'my-page'})`.
159
159
 
160
- - **All** shows every text, grouped by section. **Slop left** shows only the texts that aren't all yours yet; work through it until it's empty. **Repeats** shows the repeated text. **Hidden** (on pages that have some) shows alt text, tooltips and labels.
160
+ - **All** shows every text, grouped by section. An open section's name stays at the top while you scroll its texts, so you can close it from anywhere in it. **Slop left** shows only the texts that aren't all yours yet; work through it until it's empty. **Repeats** shows the repeated text. **Hidden** (on pages that have some) shows alt text, tooltips and labels.
161
161
  - Each text box shows its words in their authors' colors, as readers see them with the Slop-o-meter on.
162
- - Each text, section and the whole page has a pie of what it's made of, by its name, and a **slop** switch at the right. Off approves the AI's words; on takes that back. Your typed words are never touched. Every switch can be undone from the status line.
163
- - At the top: how much of the page is slop, and every category with its share, the biggest first (as in the meters' legends). Click a category's dot for its color picker, laid out like the browser's (a rectangle of shades; the eyedropper, the color and a hue bar; RGB, HEX or HSL numbers). Its eyedropper, or dragging the dot onto any color on the page, takes a color from the page: the point is a ring, and a magnifier beside it (not over it, so you can see where you are) shows the page around the point three times bigger, rimmed in the color, joined to the ring by a line (Escape drops it). **Revert colors** puts every category back to its default. Rename a category by editing its name. **+ Category** adds one; × deletes it (its words become AI-generated).
164
- - Focus a text and a row of categories appears under it: **Mark all as** (or **Mark selection as**, with words selected) gives the text, or just the selection, to a category.
162
+ - Each text and section has a pie of what it's made of, by its name, and a **slop** switch at the right. Off approves the AI's words; on takes back what that switch approved, so words approved before stay approved (if its words changed since, it makes every approved word slop again). Your typed words are never touched. Every switch can be undone from the status line.
163
+ - At the top: every category with its share of the page, the biggest first (as in the meters' legends). Click a category's dot for its color picker, laid out like the browser's (a rectangle of shades; the eyedropper, the color and a hue bar; RGB, HEX or HSL numbers). Its eyedropper, or dragging the dot onto any color on the page, takes a color from the page: the point is a ring, and a magnifier beside it (not over it, so you can see where you are) shows the page around the point three times bigger, rimmed in the color, joined to the ring by a line (Escape drops it). **Revert colors** puts every category back to its default. Rename a category by editing its name. **+ Category** adds one; × deletes it (its words become AI-generated).
164
+ - Focus a text and a row of categories appears under it: **Mark all as** (or **Mark selection as**, as soon as you start selecting) gives the text, or just the selection, to a category. The words stay selected, to give them to another. Its **+** makes a new category there: a name, whose words it means, and **Add and mark** gives it the selection.
165
+ - Words copied (or cut) from a text keep their authors when pasted into a text: AI words stay AI, approved stay approved. Words pasted from anywhere else are yours, as if typed.
165
166
  - In a list, a **+** under the text you're on adds an empty paragraph after it; pointing at the + draws a line on the page where it would go. The trash can before its slop switch outlines the text on the page in dashed red; a text with words takes a second click (it asks **Remove?**), and stays red until then. A removed text stays in **All** as a row with **Restore** until the next save. New texts get new keys (`p7` between `p2` and `p3` is still called Paragraph 3 in the editor), so a key never moves to other words.
166
- - Click any text on the page to jump to it in the editor. Focus a text in the editor to find it on the page.
167
+ - While the editor is open, every text on the page can be typed into where it is: click it and type. Your letters are yours, as in a text box, and the caret is your color; bold, links and `{name}` values stay as they are (a `{name}` is deleted whole), and what you type is plain words: `**` is two asterisks. For markup, use the shortcuts below, or type it in the text's box in the panel. Enter starts a paragraph and Backspace at a paragraph's start joins it to the one before (in a `<p>`, `<li>` or `<dd>`). A row over the focused text has its slop switch, **Mark as** and **+**. Over a heading (`<h1>`–`<h6>`), the switch covers its whole section: the heading and every text after it, up to the next heading as big or bigger, in the heading's group. The panel scrolls to the text's box, which follows along. Alt text, tooltips, texts inside a button and texts the page builds itself are edited in the panel; clicking one there jumps to its box. Focus a text in the editor to find it on the page.
168
+ - The editor starts as the bar. **Panel** opens the full panel, and the icon left of **Colors** shrinks it back. The editor remembers which you used last.
169
+ - On the page, ⌘B, ⌘I and ⌘E make the selection bold, italic or code (again to undo it), and ⌘K links it (it asks where to, in the row over the text) or takes its link off. The words and who wrote them stay; only the markup around them changes.
167
170
  - Drag the header to move the editor anywhere, and drag any edge or corner to resize it. It stays where you leave it; double-click the header to put it back. On a phone it's a sheet along the bottom, and dragging changes its height.
168
171
  - Nothing is written until you click **Save** (or press ⌘S). The button counts the texts changed since the last save. Each changed text has a **Revert** link that takes its words and authorship back to the last save. Saves are versioned: a tab whose copy of the file is out of date gets an error instead of overwriting newer edits. Leaving with unsaved changes asks first, and a reload keeps them in that tab, still unsaved, with **Discard** (a page in a frame can't ask).
169
- - What you type is yours, every letter, even one typed over a selection that starts with the same letter. ⌘Z in a text undoes typing and gives the restored words back to whoever wrote them. ⌘Z anywhere else undoes the last switch, mark, revert, added or removed text.
172
+ - What you type is yours, every letter, even one typed over a selection that starts with the same letter.
173
+ - ⌘Z undoes the last change, wherever the focus is: typing (on the page or in a box), a switch, a mark, a revert, an added or removed text, a category deleted. The restored words come back with whoever wrote them, and an undone mark selects its words again. ⌘⇧Z redoes it. The history lasts until the page is reloaded.
170
174
 
171
175
  ### Repeated text
172
176
 
@@ -189,7 +193,7 @@ It's the page's choice, made in the editor (**Readers see**) and saved in the bl
189
193
  - **Pie chart**: a pie of who wrote what, and a legend: each category in its color, with its share of the page's text.
190
194
  - **Colors**: the Slop-o-meter, the pie and legend plus a switch that colors every word by who wrote it.
191
195
 
192
- It shows where the page puts `<div data-slop-meter></div>`. While the editor is open, you see the colors whatever readers get.
196
+ It shows where the page puts `<div data-slop-meter></div>`. While the editor is open, you see the colors whatever readers get; its **Colors** switch (or the page's Slop-o-meter) turns them off to compare.
193
197
 
194
198
  A meter can cover one part of the page: `<div data-slop-meter="games.othello"></div>` measures only the texts under `games.othello`, and its switch colors only its section, the closest `[data-slop-section]` or else its parent. A section's switch starts the way the page's is and is its own once flipped. Only the page's is remembered.
195
199
 
package/cli.mjs CHANGED
@@ -226,7 +226,7 @@ async function installReact(files, { auto, author, text, dry }) {
226
226
  if (!{ ...pkg.dependencies, ...pkg.devDependencies }['slop-editor']) todo.push('Add the package to the project: npm i slop-editor');
227
227
  if (todo.length) console.log(`\nStill to do:\n${todo.map((t) => ` - ${t}`).join('\n')}`);
228
228
  }
229
- console.log('\nNext: run your dev server. The page gets an Edit text button, and saves go into the words file.\n'
229
+ console.log('\nNext: run your dev server. The page opens with the editor, and saves go into the words file.\n'
230
230
  + 'Readers see nothing until you pick what they see in the editor ("Readers see"); put <SlopMeter /> (from \'slop-editor/react\')\n'
231
231
  + 'where the meter should go. Texts the code builds (a title from a variable, text in a data array) are still yours to move:\n'
232
232
  + 'render them with <SlopText path="…" /> or Slop.words(\'…\'). Adding and removing paragraphs in the editor needs slopList.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slop-editor",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "A slop editor: track who wrote every word on a page (the AI, you, or nobody), then read the slop and make it yours.",
5
5
  "homepage": "https://baphaelman.github.io/slop-editor/",
6
6
  "repository": {
package/slop.css CHANGED
@@ -44,16 +44,9 @@ html.slop-dark {
44
44
  .slop-key i { width: 8px; height: 8px; border-radius: 50%; }
45
45
 
46
46
  /* ---------- the editor ---------- */
47
- .slop-edit-btn, .slop-panel { font-family: var(--_font); color: var(--_ink); -webkit-font-smoothing: antialiased; }
48
- .slop-edit-btn, .slop-panel *, .slop-panel { box-sizing: border-box; }
49
- .slop-edit-btn {
50
- position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 2147483000;
51
- display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px 10px 12px; border-radius: 99px;
52
- border: 1px solid var(--_accent); background: var(--_bg); color: var(--_accent); font: 600 0.88rem var(--_font); cursor: pointer; box-shadow: var(--_shadow);
53
- }
54
- .slop-edit-btn::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--slop-c-ai, var(--_accent)); }
55
- .slop-edit-btn:hover { background: color-mix(in srgb, var(--_accent) 10%, var(--_bg)); }
56
- .slop-edit-btn[hidden], .slop-panel[hidden], .slop-panel [hidden] { display: none !important; }
47
+ .slop-panel { font-family: var(--_font); color: var(--_ink); -webkit-font-smoothing: antialiased; }
48
+ .slop-panel *, .slop-panel { box-sizing: border-box; }
49
+ .slop-panel[hidden], .slop-panel [hidden] { display: none !important; }
57
50
 
58
51
  .slop-panel {
59
52
  position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: 2147483000; width: min(420px, calc(100vw - 24px));
@@ -74,13 +67,20 @@ html.slop-dark {
74
67
  .sp-status[data-kind="dirty"] { color: var(--_ink-2); }
75
68
  .sp-status[data-kind="error"] { color: #d0453a; }
76
69
  .sp-link { padding: 0; border: 0; background: none; color: var(--_accent) !important; font: 600 0.78rem var(--_font); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
77
- .sp-save { flex: none; margin-left: auto; height: 30px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--_accent); background: var(--_accent); color: var(--_bg) !important; font: 600 0.82rem var(--_font); font-variant-numeric: tabular-nums; cursor: pointer; }
70
+ .sp-colors {
71
+ flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; margin-left: auto; padding: 0 10px 0 7px; border-radius: 8px;
72
+ border: 1px solid var(--_rule); background: none; font: 600 0.78rem var(--_font); color: var(--_ink-3) !important; cursor: pointer;
73
+ }
74
+ .sp-colors:hover { border-color: var(--_ink-3); }
75
+ .sp-colors .sp-switch { background: var(--_rule); }
76
+ .sp-colors[aria-checked="true"] { color: var(--_ink) !important; }
77
+ .sp-colors[aria-checked="true"] .sp-switch { background: var(--slop-c-ai, var(--_accent)); }
78
+ .sp-colors[aria-checked="true"] .sp-switch::after { transform: translateX(10px); }
79
+ .sp-save { flex: none; height: 30px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--_accent); background: var(--_accent); color: var(--_bg) !important; font: 600 0.82rem var(--_font); font-variant-numeric: tabular-nums; cursor: pointer; }
78
80
  .sp-save:hover:not(:disabled) { filter: brightness(1.1); }
79
81
  .sp-save:disabled { border-color: var(--_rule); background: none; color: var(--_ink-3) !important; cursor: default; }
80
82
  .sp-revert { flex: none; padding: 0 2px; border: 0; background: none; font: 600 0.72rem var(--_font); color: var(--_ink-3) !important; text-decoration: underline; text-decoration-color: var(--_rule); text-underline-offset: 2px; cursor: pointer; }
81
83
  .sp-revert:hover { color: var(--_ink) !important; text-decoration-color: currentColor; }
82
- .sp-close { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--_rule); background: none; font-size: 1.2rem; line-height: 1; cursor: pointer; }
83
- .sp-close:hover { background: var(--_sunk); }
84
84
  /* resize handles along every edge and corner */
85
85
  .sp-edge { position: absolute; z-index: 2; touch-action: none; }
86
86
  .sp-edge[data-edge="n"], .sp-edge[data-edge="s"] { left: 14px; right: 14px; height: 8px; cursor: ns-resize; }
@@ -93,11 +93,6 @@ html.slop-dark {
93
93
 
94
94
  /* the whole page: how much is slop, the page's switch, and the categories */
95
95
  .sp-cover { display: grid; gap: 10px; padding: 0 16px 14px; }
96
- .sp-cover-row { display: flex; align-items: center; gap: 10px; }
97
- .sp-big { font-size: 0.9rem; color: var(--_ink-2); }
98
- .sp-big b { font: 700 1.55rem/1 var(--_font); color: var(--slop-c-ai, var(--_accent)); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
99
- .sp-words { margin-right: auto !important; font-size: 0.78rem; color: var(--_ink-3); font-variant-numeric: tabular-nums; }
100
- .sp-cover-row .sp-pie { width: 22px; height: 22px; }
101
96
  .sp-cats { display: flex; flex-wrap: wrap; gap: 6px; }
102
97
  .sp-cat { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px 0 4px; border: 1px solid var(--_rule); border-radius: 99px; font-size: 0.78rem; }
103
98
  .sp-cat { cursor: pointer; }
@@ -164,6 +159,8 @@ html.slop-dark {
164
159
  /* sections */
165
160
  .sp-group { border-bottom: 1px solid var(--_rule); }
166
161
  .sp-group summary { display: flex; align-items: center; gap: 8px; padding: 10px 4px; cursor: pointer; list-style: none; }
162
+ /* an open section's name stays at the top while its texts scroll, so it can be closed from anywhere in it */
163
+ .sp-group[open] > summary { position: sticky; top: -8px; z-index: 3; margin: 0 -12px; padding: 10px 16px; background: var(--_bg); }
167
164
  .sp-group summary::-webkit-details-marker { display: none; }
168
165
  .sp-group summary::before { content: ""; flex: none; width: 6px; height: 6px; margin: 0 3px 0 1px; border: solid var(--_ink-3); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform .15s; }
169
166
  .sp-group[open] summary::before { transform: rotate(45deg) translate(-2px, 0); }
@@ -244,6 +241,15 @@ html.slop-dark {
244
241
  .sp-as { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border: 1px solid var(--_rule); border-radius: 99px; background: var(--_bg); font-size: 0.72rem; font-weight: 600; color: var(--_ink-2) !important; cursor: pointer; }
245
242
  .sp-as i { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--_ink) 15%, transparent); }
246
243
  .sp-as:hover { border-color: var(--_ink-3); color: var(--_ink) !important; }
244
+ /* a new category, made from the row */
245
+ .sp-as-new { justify-content: center; min-width: 22px; padding: 0 7px; border-style: dashed; font-size: 0.82rem; }
246
+ .sp-newcat { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
247
+ .sp-newcat input { height: 24px; padding: 0 8px; border: 1px solid var(--_rule); border-radius: 99px; background: var(--_bg); font: 0.74rem var(--_font); color: var(--_ink); outline: none; }
248
+ .sp-newcat input:focus { border-color: var(--_accent); }
249
+ .sp-newcat-name { width: 9em; }
250
+ .sp-newcat-about { width: 15em; }
251
+ .sp-newcat-add { height: 24px; padding: 0 10px; border: 1px solid var(--_accent); border-radius: 99px; background: var(--_accent); color: var(--_bg) !important; font: 600 0.72rem var(--_font); cursor: pointer; }
252
+ .sp-newcat-x { height: 24px; padding: 0 4px; border: 0; background: none; color: var(--_ink-3) !important; font-size: 1rem; line-height: 1; cursor: pointer; }
247
253
 
248
254
  /* the repeat badge: the same words are elsewhere too */
249
255
  .sp-rep {
@@ -292,8 +298,33 @@ html:not(.slop-editing) .slop-empty { display: none !important; }
292
298
  .slop-remove-hint { outline: 2px dashed var(--_danger) !important; outline-offset: 3px; border-radius: 2px; }
293
299
  .slop-removing { outline: 2px dashed var(--_danger) !important; outline-offset: 3px; border-radius: 2px; background: color-mix(in srgb, var(--_danger) 12%, transparent); }
294
300
 
301
+ /* editing on the page: the panel is only its header, and a row over the focused text marks it and switches its slop */
302
+ .sp-mode { flex: none; display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 7px; border-radius: 8px; border: 1px solid var(--_rule); background: none; font: 600 0.78rem var(--_font); color: var(--_ink-2) !important; cursor: pointer; white-space: nowrap; }
303
+ .sp-mode:hover { border-color: var(--_ink-3); }
304
+ .slop-panel.sp-mini { top: auto !important; left: auto !important; right: max(16px, env(safe-area-inset-right, 0px)) !important; bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important; width: auto !important; max-width: calc(100vw - 32px); height: auto !important; border-radius: 14px; }
305
+ .sp-mini > :not(.sp-head), .sp-mini .sp-grip { display: none !important; }
306
+ .sp-mini .sp-head { align-items: center; padding: 8px 8px 8px 14px; cursor: default; }
307
+ .sp-mini .sp-head h2 { font-size: 0.88rem; }
308
+ .sp-mini .sp-head > div { flex: 1 1 auto; min-width: 0; }
309
+ .sp-mini .sp-head h2, .sp-mini .sp-status { min-height: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
310
+ .sp-mini .sp-colors { margin-left: 8px; }
311
+ .slop-live [contenteditable="true"] { cursor: text; }
312
+ .slop-live [contenteditable="true"]:focus { outline: 2px solid var(--_accent); outline-offset: 3px; border-radius: 2px; }
313
+ .slop-live [data-slop-v] { cursor: default; }
314
+ .slop-live [contenteditable="true"]:empty { min-height: 1em; min-height: 1lh; }
315
+ .slop-float {
316
+ position: fixed; z-index: 2147483000; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; max-width: min(720px, calc(100vw - 16px)); padding: 6px 8px;
317
+ border: 1px solid var(--_rule); border-radius: 12px; background: var(--_bg); box-shadow: var(--_shadow); box-sizing: border-box;
318
+ font: 14px/1.4 var(--_font); color: var(--_ink); text-align: left; -webkit-font-smoothing: antialiased;
319
+ }
320
+ .slop-float[hidden] { display: none !important; }
321
+ .slop-float * { box-sizing: border-box; }
322
+ .slop-float button { font-family: inherit; color: inherit; }
323
+ .slop-float .sp-assign { padding: 0; }
324
+
295
325
  @media (max-width: 900px) {
296
326
  .slop-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 60svh; }
297
327
  .sp-head { cursor: ns-resize; }
298
328
  .sp-edge:not([data-edge="n"]) { display: none; }
329
+ .slop-panel.sp-mini { left: 8px !important; right: 8px !important; bottom: 8px !important; max-width: none; }
299
330
  }