slop-editor 0.3.1 → 0.5.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.
package/jsx.mjs ADDED
@@ -0,0 +1,248 @@
1
+ // `slop-editor install --auto Foo.jsx`: markup.mjs for React. It moves a component file's static prose into the text
2
+ // block and swaps each text for <SlopText path="…" />, and alt text and the like for slopAttrs. It reads the file with
3
+ // Babel but changes the source in place, so formatting, comments and everything else stay as they were. The cli loads
4
+ // this file only for a React file, so nothing else pays for the parser.
5
+ import { parse } from '@babel/parser';
6
+ import { PROSE, MIN_WORDS, escape, slug, words } from './markup.mjs';
7
+
8
+ const PROSE_TAG = new RegExp(`^(?:${PROSE})$`);
9
+ // elements that hold other prose: look inside them instead of taking them whole
10
+ const CONTAINER_TAG = /^(?:p|ul|ol|li|div|section|article|aside|table|blockquote|details|figure|dl|dd|dt|header|footer|main|h[1-6])$/;
11
+ const MARKS = { b: '**', strong: '**', i: '*', em: '*', code: '`' };
12
+ // a component that is a link: <ExternalLink href="https://…">words</ExternalLink>
13
+ const LINK_COMPONENT = /(?:Link|Anchor)$/;
14
+ // attributes whose words the editor lists under Hidden, and the group each goes in
15
+ const ATTRS = { alt: 'alt-text', title: 'tooltips', placeholder: 'placeholders', 'aria-label': 'labels' };
16
+ const MARKED = ['data-slop', 'data-slop-ref', 'data-slop-attr'];
17
+ const TAKEN_PROPS = ['as', 'path', 'vars'];
18
+
19
+ // JSX's own rule for the whitespace in a text: lines are trimmed, blank ones dropped, the rest joined with a space
20
+ function jsxText(value) {
21
+ const lines = value.split(/\r\n|\n|\r/);
22
+ let last = 0;
23
+ lines.forEach((l, i) => { if (/[^ \t]/.test(l)) last = i; });
24
+ let out = '';
25
+ lines.forEach((line, i) => {
26
+ let t = line.replace(/\t/g, ' ');
27
+ if (i !== 0) t = t.replace(/^ +/, '');
28
+ if (i !== lines.length - 1) t = t.replace(/ +$/, '');
29
+ if (t) out += i === last ? t : `${t} `;
30
+ });
31
+ return out;
32
+ }
33
+
34
+ const tagOf = (el) => (el.openingElement.name.type === 'JSXIdentifier' ? el.openingElement.name.name : null);
35
+ const propOf = (el, name) => el.openingElement.attributes.find((a) => a.type === 'JSXAttribute' && a.name.name === name);
36
+ const stringOf = (attr) => {
37
+ const v = attr?.value;
38
+ if (v?.type === 'StringLiteral') return v.value;
39
+ if (v?.type === 'JSXExpressionContainer') {
40
+ if (v.expression.type === 'StringLiteral') return v.expression.value;
41
+ if (v.expression.type === 'TemplateLiteral' && !v.expression.expressions.length) return v.expression.quasis[0].value.cooked;
42
+ }
43
+ return null;
44
+ };
45
+
46
+ // is there anything in it that reads as words, or that code builds? That's what's worth telling the user about
47
+ const hasWords = (el) => el.children.some((c) => (c.type === 'JSXText' && /\S/.test(c.value))
48
+ || (c.type === 'JSXExpressionContainer' && c.expression.type !== 'JSXEmptyExpression') || (c.type === 'JSXElement' && hasWords(c)));
49
+
50
+ // JSX children -> the format's inline markup and the plain words, or null if they hold anything it can't say
51
+ function convert(children) {
52
+ let md = '', plain = '';
53
+ for (const c of children) {
54
+ let text = null;
55
+ if (c.type === 'JSXText') text = jsxText(c.value);
56
+ else if (c.type === 'JSXExpressionContainer') {
57
+ if (c.expression.type === 'JSXEmptyExpression') continue; // {/* a comment */}
58
+ if (c.expression.type === 'StringLiteral') text = c.expression.value;
59
+ else if (c.expression.type === 'TemplateLiteral' && !c.expression.expressions.length) text = c.expression.quasis[0].value.cooked;
60
+ else return null;
61
+ } else if (c.type === 'JSXElement') {
62
+ const tag = tagOf(c);
63
+ const attrs = c.openingElement.attributes;
64
+ if (!tag || attrs.some((a) => a.type !== 'JSXAttribute' || typeof a.name.name !== 'string')) return null;
65
+ let href = null, inner = c.children, mark;
66
+ if (tag === 'a') {
67
+ href = stringOf(propOf(c, 'href'));
68
+ // an <a> keeps its href and may say where it opens; any other attribute would be lost
69
+ if (!href || attrs.some((a) => !['href', 'target', 'rel'].includes(a.name.name))) return null;
70
+ } else if (LINK_COMPONENT.test(tag)) {
71
+ href = stringOf(propOf(c, 'href'));
72
+ const kid = propOf(c, 'children');
73
+ if (!/^https?:\/\//.test(href ?? '') || attrs.some((a) => !['href', 'children'].includes(a.name.name))) return null;
74
+ if (kid) {
75
+ const label = stringOf(kid);
76
+ if (label === null || inner.length) return null;
77
+ inner = [{ type: 'JSXText', value: label }];
78
+ }
79
+ } else if (MARKS[tag] && !attrs.length) mark = MARKS[tag];
80
+ else return null;
81
+ if (href && /[()\s]/.test(href)) return null;
82
+ const done = convert(inner);
83
+ if (!done?.md) return null;
84
+ md += href ? `[${done.md}](${href})` : `${mark}${done.md}${mark}`;
85
+ plain += done.plain;
86
+ continue;
87
+ } else return null;
88
+ md += escape(text);
89
+ plain += text;
90
+ }
91
+ return { md: md.replace(/\s+/g, ' ').trim(), plain: plain.replace(/\s+/g, ' ').trim() };
92
+ }
93
+
94
+ // the component a node is in, for a hook: the nearest function named like one, with a block body
95
+ function componentOf(parents) {
96
+ for (let i = parents.length - 1; i >= 0; i--) {
97
+ const p = parents[i];
98
+ if (!/^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/.test(p.type)) continue;
99
+ const name = p.id?.name ?? (parents[i - 1]?.type === 'VariableDeclarator' ? parents[i - 1].id.name : null);
100
+ if (name && /^[A-Z]/.test(name)) return p.body.type === 'BlockStatement' ? p : null;
101
+ }
102
+ return null;
103
+ }
104
+
105
+ // source: the file's text. name: what its texts go under in the block (`articleOne`), and have: what's there already, so
106
+ // a second run never reuses a key. Returns the new source, the
107
+ // texts for the block ({group: {key: markup}}), and what it left alone: lines of prose it couldn't carry (`skipped`),
108
+ // of attributes it couldn't reach (`attrsLeft`) and of words in elements that aren't prose (`loose`)
109
+ export function moveJsx(source, { name, ts = false, have = {} }) {
110
+ const ast = parse(source, { sourceType: 'module', plugins: ['jsx', ...(ts ? ['typescript'] : [])] });
111
+ const found = [];
112
+ const walk = (node, parents) => {
113
+ if (node.type === 'JSXElement') found.push({ node, parents: [...parents] });
114
+ parents.push(node);
115
+ for (const key of Object.keys(node)) {
116
+ if (key === 'loc' || key === 'extra') continue;
117
+ const v = node[key];
118
+ for (const c of Array.isArray(v) ? v : [v]) if (c && typeof c.type === 'string') walk(c, parents);
119
+ }
120
+ parents.pop();
121
+ };
122
+ walk(ast.program, []);
123
+ found.sort((a, b) => a.node.start - b.node.start); // reading order, whichever way the tree was walked
124
+
125
+ const edits = [], block = {}, skipped = [], taken = new Set();
126
+ const used = new Set([...Object.values(ATTRS), ...Object.keys(have)]);
127
+ const need = new Set(), hooks = new Map();
128
+ const free = (group, key) => have[group]?.[key] === undefined && block[group]?.[key] === undefined;
129
+ const unique = (group, key) => { let k = key, i = 2; while (!free(group, k)) k = `${key}-${i++}`; return k; };
130
+ let group = 'intro', n = 0;
131
+
132
+ for (const { node, parents } of found) {
133
+ const tag = tagOf(node);
134
+ if (!tag || !PROSE_TAG.test(tag) || parents.some((p) => taken.has(p))) continue;
135
+ const attrs = node.openingElement.attributes;
136
+ if (attrs.some((a) => a.type === 'JSXAttribute' && (MARKED.includes(a.name.name) || TAKEN_PROPS.includes(a.name.name)))) continue;
137
+ const heading = /^h[1-6]$/.test(tag);
138
+ if (!heading && node.children.some((c) => c.type === 'JSXElement' && CONTAINER_TAG.test(tagOf(c) ?? ''))) continue; // a container
139
+ const done = convert(node.children);
140
+ if (!done) { if (hasWords(node)) skipped.push(node.loc.start.line); continue; }
141
+ if (!/\w/.test(done.md) || (!heading && words(done.md) < MIN_WORDS)) continue;
142
+ let key;
143
+ if (heading) {
144
+ let g = slug(done.plain) || 'text', i = 2;
145
+ while (used.has(g)) g = `${slug(done.plain) || 'text'}-${i++}`;
146
+ used.add(group = g);
147
+ n = 0;
148
+ key = 'title';
149
+ } else {
150
+ used.add(group);
151
+ key = `${tag}${++n}`;
152
+ while (!free(group, key)) key = `${tag}${++n}`;
153
+ }
154
+ (block[group] ||= {})[key] = done.md;
155
+ const rest = source.slice(node.openingElement.name.end, node.openingElement.end - (node.openingElement.selfClosing ? 2 : 1)).trim();
156
+ edits.push({ start: node.start, end: node.end, text: `<SlopText path="${name}.${group}.${key}" as="${tag}"${rest ? ` ${rest}` : ''} />` });
157
+ taken.add(node);
158
+ need.add('SlopText');
159
+ }
160
+
161
+ // alt text, tooltips, placeholders and labels: slopAttrs, and useSlop() in the component so they follow edits
162
+ const attrsLeft = [];
163
+ let attrCount = 0;
164
+ for (const { node, parents } of found) {
165
+ const tag = tagOf(node);
166
+ if (!tag || tag !== tag.toLowerCase() || taken.has(node) || parents.some((p) => taken.has(p))) continue;
167
+ const attrs = node.openingElement.attributes;
168
+ if (attrs.some((a) => a.type === 'JSXAttribute' && MARKED.includes(a.name.name))) continue;
169
+ const hits = attrs.filter((a) => a.type === 'JSXAttribute' && ATTRS[a.name.name] && a.value?.type === 'StringLiteral' && /\w/.test(a.value.value));
170
+ if (!hits.length) continue;
171
+ const fn = componentOf(parents);
172
+ if (!fn) { attrsLeft.push(node.loc.start.line); continue; }
173
+ const pairs = hits.map((a) => {
174
+ const g = ATTRS[a.name.name];
175
+ const k = unique(g, slug(a.value.value) || 'text');
176
+ (block[g] ||= {})[k] = a.value.value;
177
+ return `${/^\w+$/.test(a.name.name) ? a.name.name : `'${a.name.name}'`}: '${name}.${g}.${k}'`;
178
+ });
179
+ attrCount += hits.length;
180
+ edits.push({ start: hits[0].start, end: hits[0].end, text: `{...slopAttrs({ ${pairs.join(', ')} })}` });
181
+ for (const a of hits.slice(1)) {
182
+ let start = a.start;
183
+ while (/\s/.test(source[start - 1])) start--;
184
+ edits.push({ start, end: a.end, text: '' });
185
+ }
186
+ need.add('slopAttrs');
187
+ hooks.set(fn, true);
188
+ }
189
+ for (const fn of hooks.keys()) {
190
+ if (/\buseSlop\(/.test(source.slice(fn.body.start, fn.body.end))) continue;
191
+ const first = fn.body.body[0];
192
+ const line = first ? source.slice(source.lastIndexOf('\n', first.start - 1) + 1, first.start) : '';
193
+ edits.push({ start: fn.body.start + 1, end: fn.body.start + 1, text: `\n${/^\s+$/.test(line) ? line : ' '}useSlop();` });
194
+ need.add('useSlop');
195
+ }
196
+
197
+ // words sitting in an element that isn't prose (a span, an i, a div): not moved, but worth a line to the user
198
+ const loose = found.filter(({ node, parents }) => {
199
+ const tag = tagOf(node);
200
+ return tag && tag === tag.toLowerCase() && !PROSE_TAG.test(tag) && !parents.some((p) => taken.has(p))
201
+ && node.children.some((c) => c.type === 'JSXText' && words(jsxText(c.value)) >= MIN_WORDS);
202
+ }).map(({ node }) => node.loc.start.line);
203
+
204
+ // imports this left unused: a link component that's now a [label](url), say. Only names that were used before
205
+ const imports = ast.program.body.filter((s) => s.type === 'ImportDeclaration');
206
+ const apply = (list) => list.slice().sort((a, b) => b.start - a.start || b.end - a.end).reduce((out, e) => out.slice(0, e.start) + e.text + out.slice(e.end), source);
207
+ const bare = (text) => text.replace(/^import\b[\s\S]*?\bfrom\s*['"][^'"]+['"];?[ \t]*$/gm, '');
208
+ const [was, now] = [bare(source), bare(apply(edits))];
209
+ const uses = (text, name) => text.match(new RegExp(`(?<![\\w$.])${name.replace(/\$/g, '\\$')}(?![\\w$])`, 'g'))?.length ?? 0;
210
+ const dropped = new Set();
211
+ if (edits.length) {
212
+ for (const decl of imports) {
213
+ if (decl.source.value === 'slop-editor/react' || !decl.specifiers.length) continue;
214
+ const gone = decl.specifiers.filter((sp) => uses(was, sp.local.name) && !uses(now, sp.local.name));
215
+ if (gone.length === decl.specifiers.length) {
216
+ const lead = source[decl.start - 1] === '\n' ? 1 : 0;
217
+ edits.push({ start: decl.start - lead, end: decl.end, text: '' });
218
+ dropped.add(decl);
219
+ } else if (gone.length && gone.every((sp) => sp.type === 'ImportSpecifier')) {
220
+ for (const sp of gone) {
221
+ const all = decl.specifiers.filter((x) => x.type === 'ImportSpecifier');
222
+ const i = all.indexOf(sp);
223
+ edits.push(i < all.length - 1 ? { start: sp.start, end: all[i + 1].start, text: '' } : { start: all[i - 1]?.end ?? sp.start, end: sp.end, text: '' });
224
+ }
225
+ }
226
+ }
227
+ }
228
+
229
+ // the import
230
+ const kept = imports.filter((d) => !dropped.has(d));
231
+ const existing = imports.find((s) => s.source.value === 'slop-editor/react' && s.importKind !== 'type');
232
+ const imported = new Set((existing?.specifiers ?? []).filter((s) => s.type === 'ImportSpecifier').map((s) => s.imported.name));
233
+ const missing = [...need].filter((x) => !imported.has(x));
234
+ if (missing.length && edits.length) {
235
+ const named = existing?.specifiers.filter((s) => s.type === 'ImportSpecifier') ?? [];
236
+ const plainDefault = existing?.specifiers.length && !existing.specifiers.some((s) => s.type === 'ImportNamespaceSpecifier');
237
+ if (named.length) edits.push({ start: named.at(-1).end, end: named.at(-1).end, text: `, ${missing.join(', ')}` });
238
+ else if (plainDefault) edits.push({ start: existing.specifiers.at(-1).end, end: existing.specifiers.at(-1).end, text: `, { ${missing.join(', ')} }` });
239
+ else {
240
+ const line = `import { ${missing.join(', ')} } from 'slop-editor/react';`;
241
+ // after the last import, or after 'use client' and the like
242
+ const after = kept.at(-1)?.end ?? ast.program.directives?.at(-1)?.end;
243
+ edits.push(after === undefined ? { start: 0, end: 0, text: `${line}\n` } : { start: after, end: after, text: `\n${line}` });
244
+ }
245
+ }
246
+
247
+ return { code: apply(edits), block, texts: edits.filter((e) => e.text.startsWith('<SlopText')).length, attrs: attrCount, skipped, attrsLeft, loose };
248
+ }
package/markup.mjs CHANGED
@@ -1,19 +1,19 @@
1
- // `slop-editor install --auto`: move a page's static prose into the slop text block, as AI text.
1
+ // `slop-editor install --auto`: move a page's static prose into the slop text block (as AI text, or the author asked for).
2
2
  // It takes paragraphs, headings, list items, captions and quotes whose content is plain words with links, bold,
3
3
  // italic and code, and leaves everything else (labels, buttons, spans, text with other markup, text the code builds)
4
4
  // to whoever ported the page. Returns the new html and what it did.
5
5
 
6
- const PROSE = 'p|h[1-6]|li|dd|dt|figcaption|blockquote';
6
+ export const PROSE = 'p|h[1-6]|li|dd|dt|figcaption|blockquote';
7
7
  const SKIP = 'script|style|svg|textarea|pre|select|button|template|noscript|head|code|kbd|nav|label|form|iframe|canvas|math';
8
8
  const BLOCKS = /<(?:p|ul|ol|li|div|h[1-6]|section|article|aside|table|blockquote|details|figure|dl|dd|dt|header|footer|main|br|img|span|svg|input|button|select|textarea)\b/i;
9
9
  // elements that hold other prose: look inside them instead of taking them whole
10
10
  const CONTAINERS = /<(?:p|ul|ol|li|div|section|article|aside|table|blockquote|details|figure|dl|dd|dt|header|footer|main|h[1-6])\b/i;
11
11
  const ENTITIES = { nbsp: ' ', amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", ndash: '–', mdash: '—', hellip: '…', lsquo: '‘', rsquo: '’', ldquo: '“', rdquo: '”' };
12
- const MIN_WORDS = 3;
12
+ export const MIN_WORDS = 3;
13
13
 
14
14
  const decode = (s) => s.replace(/&(?:#(\d+)|#x([0-9a-f]+)|(\w+));/gi, (all, d, x, n) =>
15
15
  d ? String.fromCodePoint(+d) : x ? String.fromCodePoint(parseInt(x, 16)) : (ENTITIES[n] ?? all));
16
- const escape = (s) => s.replace(/([\\*\[\]{}`])/g, '\\$1');
16
+ export const escape = (s) => s.replace(/([\\*\[\]{}`])/g, '\\$1');
17
17
 
18
18
  // inner HTML -> the format's inline markup, or null if it holds anything the format can't say
19
19
  function convert(inner) {
@@ -47,8 +47,8 @@ function convert(inner) {
47
47
  return out.replace(/\s+/g, ' ').trim();
48
48
  }
49
49
 
50
- const words = (s) => s.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/[*`\\]/g, '').split(/\s+/).filter((w) => /\w/.test(w)).length;
51
- const slug = (s) => s.toLowerCase().replace(/<[^>]*>/g, '').replace(/&\w+;/g, ' ').match(/[a-z0-9]+/g)?.slice(0, 2).join('-') || '';
50
+ export const words = (s) => s.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/[*`\\]/g, '').split(/\s+/).filter((w) => /\w/.test(w)).length;
51
+ export const slug = (s) => s.toLowerCase().replace(/<[^>]*>/g, '').replace(/&\w+;/g, ' ').match(/[a-z0-9]+/g)?.slice(0, 2).join('-') || '';
52
52
 
53
53
  export function markup(html) {
54
54
  const body = /<body\b[^>]*>/i.exec(html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slop-editor",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
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": {
@@ -16,7 +16,8 @@
16
16
  "./slop.js": "./slop.js",
17
17
  "./slop.css": "./slop.css",
18
18
  "./react": "./react.mjs",
19
- "./package.json": "./package.json"
19
+ "./package.json": "./package.json",
20
+ "./vite": "./vite.mjs"
20
21
  },
21
22
  "files": [
22
23
  "cli.mjs",
@@ -24,12 +25,15 @@
24
25
  "react.mjs",
25
26
  "slop.js",
26
27
  "slop.css",
28
+ "jsx.mjs",
29
+ "vite.mjs",
27
30
  "README.md",
28
31
  "LICENSE"
29
32
  ],
30
33
  "scripts": {
31
34
  "test": "node --test test.mjs",
32
- "test:browser": "node browser-test.mjs"
35
+ "test:browser": "node browser-test.mjs",
36
+ "prepublishOnly": "node -e \"const {version:v}=require('./package.json'),{version:w}=require('./.claude-plugin/plugin.json');if(v!==w){console.error('package.json says '+v+' but .claude-plugin/plugin.json says '+w+': make them match');process.exit(1)}const o=JSON.parse(require('child_process').execFileSync('npm',['view','slop-editor','versions','--json'],{encoding:'utf8'}));if(o.includes(v)){console.error('slop-editor '+v+' is already on npm ('+o.at(-1)+' is the latest): bump the version in package.json and .claude-plugin/plugin.json first');process.exit(1)}\""
33
37
  },
34
38
  "engines": {
35
39
  "node": ">=18"
@@ -53,5 +57,8 @@
53
57
  },
54
58
  "devDependencies": {
55
59
  "playwright-core": "^1.65.1"
60
+ },
61
+ "dependencies": {
62
+ "@babel/parser": "^7.29.15"
56
63
  }
57
64
  }
package/slop.css CHANGED
@@ -100,9 +100,28 @@ html.slop-dark {
100
100
  .sp-cover-row .sp-pie { width: 22px; height: 22px; }
101
101
  .sp-cats { display: flex; flex-wrap: wrap; gap: 6px; }
102
102
  .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
- .sp-swatch { position: relative; flex: none; width: 18px; height: 18px; border-radius: 50%; overflow: hidden; cursor: pointer; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--_ink) 18%, transparent); }
103
+ .sp-cat { cursor: pointer; }
104
+ .sp-cat-on { border-color: var(--_accent); box-shadow: 0 0 0 1px var(--_accent); }
105
+ .sp-swatch { flex: none; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; touch-action: none; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--_ink) 18%, transparent); }
104
106
  .sp-swatch:hover { box-shadow: 0 0 0 2px var(--_rule), inset 0 0 0 1px color-mix(in srgb, var(--_ink) 18%, transparent); }
105
- .sp-swatch input { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); padding: 0; border: 0; opacity: 0; cursor: pointer; }
107
+ /* the color picker, under a category's dot, laid out like the browser's own */
108
+ .sp-pick { position: absolute; z-index: 3; width: 240px; display: grid; gap: 12px; padding: 0 0 12px; overflow: hidden; border: 1px solid var(--_rule); border-radius: 10px; background: var(--_bg); box-shadow: var(--_shadow); }
109
+ .sp-pick-sv { position: relative; height: 150px; touch-action: none; }
110
+ .sp-pick-sv:focus-visible { outline: 2px solid var(--_accent); outline-offset: -2px; }
111
+ .sp-pick-sv i { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35); pointer-events: none; }
112
+ .sp-pick-row { display: flex; align-items: center; gap: 10px; padding: 0 12px; }
113
+ .sp-pick-drop { flex: none; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--_ink-2) !important; cursor: pointer; }
114
+ .sp-pick-drop:hover { background: var(--_sunk); color: var(--_ink) !important; }
115
+ .sp-pick-now { flex: none; width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--_ink) 18%, transparent); }
116
+ .sp-pick-hue { flex: 1; min-width: 0; -webkit-appearance: none; appearance: none; height: 10px; margin: 0; border-radius: 99px; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); cursor: pointer; }
117
+ .sp-pick-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border: 2px solid #fff; border-radius: 50%; background: var(--hue, #f00); box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35); }
118
+ .sp-pick-hue::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: var(--hue, #f00); box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35); }
119
+ .sp-pick-nums { display: flex; align-items: flex-start; gap: 6px; padding: 0 12px; }
120
+ .sp-pick-num { flex: 1; min-width: 0; display: grid; gap: 4px; text-align: center; font-size: 0.68rem; color: var(--_ink-3); }
121
+ .sp-pick-num input { width: 100%; height: 26px; padding: 0 4px; border: 1px solid var(--_rule); border-radius: 5px; background: var(--_bg); text-align: center; font: 0.8rem var(--_font); color: var(--_ink); font-variant-numeric: tabular-nums; }
122
+ .sp-pick-num input:focus { outline: none; border-color: var(--_accent); }
123
+ .sp-pick-swap { flex: none; display: grid; place-items: center; width: 22px; height: 26px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--_ink-3) !important; cursor: pointer; }
124
+ .sp-pick-swap:hover { background: var(--_sunk); color: var(--_ink) !important; }
106
125
  .sp-cat-name { min-width: 3ch; padding: 0; border: 0; border-radius: 4px; background: none; font: 600 0.78rem var(--_font); color: var(--_ink); }
107
126
  .sp-cat-name:hover { background: var(--_sunk); }
108
127
  .sp-cat-name:focus { outline: none; background: var(--_sunk); }
@@ -116,6 +135,18 @@ html.slop-dark {
116
135
  .sp-seg button:hover:not([aria-checked="true"]) { color: var(--_ink); }
117
136
  .sp-cat-add, .sp-cat-new { height: 28px; padding: 0 11px; border: 1px dashed var(--_rule); border-radius: 99px; background: none; font: 600 0.78rem var(--_font); color: var(--_ink-2); cursor: pointer; }
118
137
  .sp-cat-add:hover { border-color: var(--_ink-3); color: var(--_ink); }
138
+ .sp-cat-revert { height: 28px; padding: 0 4px; border: 0; background: none; font: 600 0.78rem var(--_font); color: var(--_ink-3) !important; cursor: pointer; }
139
+ .sp-cat-revert:hover { color: var(--_ink) !important; }
140
+ /* whose words a category means, and asking an agent to find them */
141
+ .sp-about { flex: 1 1 100%; display: grid; gap: 6px; padding: 10px; border: 1px solid var(--_rule); border-radius: 10px; }
142
+ .sp-about-q { font-size: 0.76rem; font-weight: 600; color: var(--_ink-2); }
143
+ .sp-about textarea { width: 100%; resize: vertical; padding: 6px 8px; border: 1px solid var(--_rule); border-radius: 8px; background: var(--_sunk); font: 0.82rem/1.4 var(--_font); color: var(--_ink); }
144
+ .sp-about textarea:focus { outline: none; border-color: var(--_accent); background: var(--_bg); }
145
+ .sp-about-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
146
+ .sp-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--_ink-2); cursor: pointer; }
147
+ .sp-check input { margin: 0; accent-color: var(--_accent); }
148
+ .sp-about-note, .sp-found { font-size: 0.76rem; color: var(--_ink-3); }
149
+ .sp-found { flex: 1 1 100%; padding: 6px 9px; border-radius: 8px; background: color-mix(in srgb, var(--_accent) 8%, transparent); color: var(--_ink-2); }
119
150
  .sp-cat-new { width: 150px; border-style: solid; border-color: var(--_accent); color: var(--_ink); cursor: text; outline: none; }
120
151
 
121
152
  /* tabs */
@@ -231,6 +262,21 @@ html.slop-dark {
231
262
  .sp-goto:hover { border-color: var(--_ink-3); color: var(--_ink) !important; }
232
263
  .sp-pie.sp-mini { width: 10px; height: 10px; }
233
264
 
265
+ /* taking a color from the page: a ring at the point, and a magnifier beside it (a copy of the page, scaled up around
266
+ the point) joined to it by a line, with the color as its rim */
267
+ .slop-sampling, .slop-sampling * { cursor: crosshair !important; }
268
+ .slop-sampler, .slop-sampler * { pointer-events: none !important; }
269
+ .slop-sampler { position: fixed; inset: 0; z-index: 2147483647; font: 600 11px/1 var(--_mono); }
270
+ .slop-sampler svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
271
+ .slop-sampler line { stroke: #fff; stroke-width: 3; filter: drop-shadow(0 0 1px rgb(0 0 0 / 0.6)); }
272
+ .slop-sampler-ring, .slop-sampler-lens, .slop-sampler-hex { position: absolute; transform: translate(-50%, -50%); }
273
+ .slop-sampler-ring { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.5); }
274
+ .slop-sampler-lens { box-sizing: content-box; overflow: hidden; border: 6px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.35); }
275
+ .slop-sampler-page { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(1); }
276
+ .slop-sampler-dot { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; outline: 1px solid #fff; box-shadow: 0 0 0 2px rgb(0 0 0 / 0.6); }
277
+ .slop-sampler-hex { padding: 3px 5px; border-radius: 4px; background: #1e1b24; color: #fff; white-space: nowrap; }
278
+ .slop-sampler-hex:empty { display: none; }
279
+
234
280
  /* a text with no words isn't on the page, except while the editor is open */
235
281
  html:not(.slop-editing) .slop-empty { display: none !important; }
236
282
  .slop-editing .slop-empty { min-height: 1em; min-height: 1lh; outline: 1px dashed color-mix(in srgb, var(--_accent) 40%, transparent); outline-offset: 3px; }