@hussmartinez/image-sdk 0.3.0 → 0.4.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/dist/styles.css CHANGED
@@ -131,12 +131,20 @@
131
131
  border-radius: var(--hm-radius-surface);
132
132
  }
133
133
 
134
+ /*
135
+ * Every state shares the stage's one cell, and every one is positioned, so
136
+ * they stack in source order: the frame and its canvas first, then
137
+ * whatever sits over them. A positioned box paints, and takes the pointer,
138
+ * above one that isn't, whatever their order. So if only the frame were
139
+ * positioned, it would cover the drop zone's button and the Cancel button
140
+ * of an open in progress, and take their clicks and drops.
141
+ */
134
142
  .hm-image-stage > * {
143
+ position: relative;
135
144
  grid-area: 1 / 1;
136
145
  }
137
146
 
138
147
  .hm-image-stage-frame {
139
- position: relative;
140
148
  min-block-size: 0;
141
149
  }
142
150
 
@@ -164,8 +172,6 @@
164
172
 
165
173
  /* The notices and a failure, stacked at the stage's foot, over the image. */
166
174
  .hm-image-stage-foot {
167
- /* Positioned, so it paints over the canvas, which is too. */
168
- position: relative;
169
175
  align-self: end;
170
176
  display: grid;
171
177
  gap: var(--hm-gap-tight);
@@ -215,7 +221,6 @@
215
221
  }
216
222
 
217
223
  .hm-image-stage-overlay {
218
- position: relative;
219
224
  min-block-size: 0;
220
225
  }
221
226
 
@@ -238,7 +243,9 @@
238
243
  outline-offset: var(--hm-border-width-2);
239
244
  }
240
245
 
241
- .hm-image-crop-handle {
246
+ .hm-image-crop-handle,
247
+ .hm-image-redact-handle,
248
+ .hm-image-layer-handle {
242
249
  position: absolute;
243
250
  inline-size: var(--hm-target-size);
244
251
  block-size: var(--hm-target-size);
@@ -246,7 +253,9 @@
246
253
  touch-action: none;
247
254
  }
248
255
 
249
- .hm-image-crop-handle::after {
256
+ .hm-image-crop-handle::after,
257
+ .hm-image-redact-handle::after,
258
+ .hm-image-layer-handle::after {
250
259
  content: "";
251
260
  position: absolute;
252
261
  inset: 33%;
@@ -260,70 +269,296 @@
260
269
  * mirrored in a right-to-left page, so "e" stays its right edge, where the
261
270
  * handle moves it (docs/adr/0007).
262
271
  */
263
- .hm-image-crop-handle[data-hm-handle="nw"] {
272
+ .hm-image-crop-handle[data-hm-handle="nw"],
273
+ .hm-image-redact-handle[data-hm-handle="nw"],
274
+ .hm-image-layer-handle[data-hm-handle="nw"] {
264
275
  top: 0;
265
276
  left: 0;
266
277
  cursor: nwse-resize;
267
278
  }
268
- .hm-image-crop-handle[data-hm-handle="n"] {
279
+ .hm-image-crop-handle[data-hm-handle="n"],
280
+ .hm-image-redact-handle[data-hm-handle="n"],
281
+ .hm-image-layer-handle[data-hm-handle="n"] {
269
282
  top: 0;
270
283
  left: 50%;
271
284
  cursor: ns-resize;
272
285
  }
273
- .hm-image-crop-handle[data-hm-handle="ne"] {
286
+ .hm-image-crop-handle[data-hm-handle="ne"],
287
+ .hm-image-redact-handle[data-hm-handle="ne"],
288
+ .hm-image-layer-handle[data-hm-handle="ne"] {
274
289
  top: 0;
275
290
  left: 100%;
276
291
  cursor: nesw-resize;
277
292
  }
278
- .hm-image-crop-handle[data-hm-handle="e"] {
293
+ .hm-image-crop-handle[data-hm-handle="e"],
294
+ .hm-image-redact-handle[data-hm-handle="e"],
295
+ .hm-image-layer-handle[data-hm-handle="e"] {
279
296
  top: 50%;
280
297
  left: 100%;
281
298
  cursor: ew-resize;
282
299
  }
283
- .hm-image-crop-handle[data-hm-handle="se"] {
300
+ .hm-image-crop-handle[data-hm-handle="se"],
301
+ .hm-image-redact-handle[data-hm-handle="se"],
302
+ .hm-image-layer-handle[data-hm-handle="se"] {
284
303
  top: 100%;
285
304
  left: 100%;
286
305
  cursor: nwse-resize;
287
306
  }
288
- .hm-image-crop-handle[data-hm-handle="s"] {
307
+ .hm-image-crop-handle[data-hm-handle="s"],
308
+ .hm-image-redact-handle[data-hm-handle="s"],
309
+ .hm-image-layer-handle[data-hm-handle="s"] {
289
310
  top: 100%;
290
311
  left: 50%;
291
312
  cursor: ns-resize;
292
313
  }
293
- .hm-image-crop-handle[data-hm-handle="sw"] {
314
+ .hm-image-crop-handle[data-hm-handle="sw"],
315
+ .hm-image-redact-handle[data-hm-handle="sw"],
316
+ .hm-image-layer-handle[data-hm-handle="sw"] {
294
317
  top: 100%;
295
318
  left: 0;
296
319
  cursor: nesw-resize;
297
320
  }
298
- .hm-image-crop-handle[data-hm-handle="w"] {
321
+ .hm-image-crop-handle[data-hm-handle="w"],
322
+ .hm-image-redact-handle[data-hm-handle="w"],
323
+ .hm-image-layer-handle[data-hm-handle="w"] {
299
324
  top: 50%;
300
325
  left: 0;
301
326
  cursor: ew-resize;
302
327
  }
303
328
 
329
+ /*
330
+ * The redactions' frames (docs/adr/0010): the overlay takes a drag across
331
+ * the image, which draws a new one, and each frame is outlined over the
332
+ * redaction the canvas already shows, so nothing is dimmed or hidden.
333
+ */
334
+ .hm-image-redact-overlay {
335
+ position: absolute;
336
+ inset: 0;
337
+ overflow: hidden;
338
+ touch-action: none;
339
+ cursor: crosshair;
340
+ }
341
+
342
+ .hm-image-redact-frame {
343
+ position: absolute;
344
+ box-sizing: border-box;
345
+ touch-action: none;
346
+ cursor: move;
347
+ outline: var(--hm-border-width) dashed var(--hm-color-accent);
348
+ }
349
+
350
+ .hm-image-redact-frame[data-hm-selected] {
351
+ outline: var(--hm-border-width-2) solid var(--hm-color-accent);
352
+ }
353
+
354
+ .hm-image-redact-frame:focus-visible {
355
+ outline: var(--hm-border-width-2) solid var(--hm-color-accent-active);
356
+ outline-offset: var(--hm-border-width-2);
357
+ }
358
+
359
+ /*
360
+ * The layers' frames (docs/adr/0013): each sits on its layer, turned as
361
+ * the layer is, by the transform the renderer draws it through. Only the
362
+ * selected one, the one under the pointer and the one with focus are
363
+ * outlined, so the image is seen as it will be exported.
364
+ */
365
+ .hm-image-layers-overlay {
366
+ position: absolute;
367
+ inset: 0;
368
+ overflow: hidden;
369
+ touch-action: none;
370
+ }
371
+
372
+ .hm-image-layer-frame {
373
+ position: absolute;
374
+ inset-block-start: 0;
375
+ /* Physical, as the image's own pixels are: the transform places it from the stage's left. */
376
+ left: 0;
377
+ box-sizing: border-box;
378
+ transform-origin: 0 0;
379
+ touch-action: none;
380
+ cursor: move;
381
+ }
382
+
383
+ .hm-image-layer-frame:hover {
384
+ outline: var(--hm-border-width) dashed var(--hm-color-accent);
385
+ }
386
+
387
+ .hm-image-layer-frame[data-hm-selected] {
388
+ outline: var(--hm-border-width-2) solid var(--hm-color-accent);
389
+ }
390
+
391
+ /* A hidden layer's frame, shown while it's selected: where it would be. */
392
+ .hm-image-layer-frame[data-hm-selected][data-hm-hidden] {
393
+ outline-style: dashed;
394
+ }
395
+
396
+ .hm-image-layer-frame:focus-visible {
397
+ outline: var(--hm-border-width-2) solid var(--hm-color-accent-active);
398
+ outline-offset: var(--hm-border-width-2);
399
+ }
400
+
401
+ /* The buttons that act on the selected layer, in a row. */
402
+ .hm-image-layers-order {
403
+ display: flex;
404
+ flex-wrap: wrap;
405
+ gap: var(--hm-gap-tight);
406
+ }
407
+
408
+ .hm-image-layers-problem {
409
+ margin: 0;
410
+ }
411
+
412
+ .hm-image-editor--styled .hm-image-layers-problem {
413
+ color: var(--hm-color-danger-text);
414
+ }
415
+
416
+ /*
417
+ * The fields of the selected layer's kind (docs/adr/0013): a text layer's
418
+ * and a shape's in one cell, as tall as the taller, so the panel keeps its
419
+ * size whichever kind is selected.
420
+ */
421
+ .hm-image-layer-kinds {
422
+ display: grid;
423
+ align-items: start;
424
+ }
425
+
426
+ .hm-image-layer-kinds > * {
427
+ grid-area: 1 / 1;
428
+ min-inline-size: 0;
429
+ }
430
+
431
+ .hm-image-layer-kind {
432
+ display: grid;
433
+ gap: var(--hm-gap-normal);
434
+ }
435
+
436
+ /* Short controls that belong together, side by side, wrapping when they must. */
437
+ .hm-image-layer-row {
438
+ display: flex;
439
+ flex-wrap: wrap;
440
+ align-items: center;
441
+ gap: var(--hm-gap-tight);
442
+ }
443
+
444
+ /* A layer's name takes the row; its place and size sit in two columns under it. */
445
+ .hm-image-layers-name {
446
+ grid-column: 1 / -1;
447
+ }
448
+
449
+ /* A long name is cut short in its row: the list never grows wider than the inspector. */
450
+ .hm-image-layers-list .hm-image-layer-select {
451
+ min-inline-size: 0;
452
+ overflow: hidden;
453
+ text-overflow: ellipsis;
454
+ white-space: nowrap;
455
+ justify-content: start;
456
+ }
457
+
304
458
  .hm-image-editor-inspector:empty {
305
459
  display: none;
306
460
  }
307
461
 
308
- .hm-image-crop-panel {
462
+ .hm-image-crop-panel,
463
+ .hm-image-redact-panel,
464
+ .hm-image-layers-panel {
309
465
  display: grid;
310
466
  gap: var(--hm-gap-normal);
311
467
  }
312
468
 
313
469
  /* Left and top, then width and height: two columns that shrink with the inspector. */
314
- .hm-image-crop-fields {
470
+ .hm-image-crop-fields,
471
+ .hm-image-redact-fields,
472
+ .hm-image-layers-fields {
315
473
  display: grid;
316
474
  grid-template-columns: repeat(2, minmax(0, 1fr));
317
475
  gap: var(--hm-gap-tight);
318
476
  }
319
477
 
320
- .hm-image-crop-actions {
478
+ .hm-image-crop-actions,
479
+ .hm-image-redact-actions,
480
+ .hm-image-layers-actions {
321
481
  display: flex;
322
482
  flex-wrap: wrap;
323
483
  justify-content: end;
324
484
  gap: var(--hm-gap-tight);
325
485
  }
326
486
 
487
+ .hm-image-redact-intro,
488
+ .hm-image-redact-hint,
489
+ .hm-image-redact-none,
490
+ .hm-image-layers-none {
491
+ margin: 0;
492
+ }
493
+
494
+ .hm-image-editor--styled .hm-image-redact-intro,
495
+ .hm-image-editor--styled .hm-image-redact-none,
496
+ .hm-image-editor--styled .hm-image-layers-none {
497
+ color: var(--hm-color-text-muted);
498
+ }
499
+
500
+ /*
501
+ * The redact panel keeps its size while the tool is on. Under a narrow
502
+ * stage, the inspector sits below it and takes its height from its
503
+ * content, so a panel that grew would shrink the stage and move the image
504
+ * under the pointer, in the middle of placing an area.
505
+ *
506
+ * What doesn't apply keeps its place and is hidden: visibility takes it
507
+ * out of sight, the tab order and the accessibility tree together.
508
+ */
509
+ .hm-image-redact-panel [data-hm-inactive],
510
+ .hm-image-layers-panel [data-hm-inactive] {
511
+ visibility: hidden;
512
+ }
513
+
514
+ /* The colour and pixelation's warning, in one cell as tall as the taller. */
515
+ .hm-image-redact-cover {
516
+ display: grid;
517
+ align-items: start;
518
+ }
519
+
520
+ .hm-image-redact-cover > * {
521
+ grid-area: 1 / 1;
522
+ }
523
+
524
+ /*
525
+ * The list holds three areas' rows and scrolls beyond them, so adding or
526
+ * removing one doesn't change the panel's height either.
527
+ */
528
+ .hm-image-redact-areas,
529
+ .hm-image-layers-list {
530
+ box-sizing: border-box;
531
+ block-size: calc(3 * var(--hm-control-height) + 2 * var(--hm-gap-tight));
532
+ overflow-y: auto;
533
+ }
534
+
535
+ /* Beside the stage, the inspector's height doesn't touch it: the list shows every area. */
536
+ @container (width >= 720px) {
537
+ .hm-image-redact-areas,
538
+ .hm-image-layers-list {
539
+ block-size: auto;
540
+ overflow-y: visible;
541
+ }
542
+ }
543
+
544
+ .hm-image-redact-areas ul,
545
+ .hm-image-layers-list ul {
546
+ display: grid;
547
+ gap: var(--hm-gap-tight);
548
+ margin: 0;
549
+ padding: 0;
550
+ list-style: none;
551
+ }
552
+
553
+ /* An area's button takes the row, and its remove button the end. */
554
+ .hm-image-redact-areas li,
555
+ .hm-image-layers-list li {
556
+ display: grid;
557
+ grid-template-columns: minmax(0, 1fr) auto;
558
+ gap: var(--hm-gap-tight);
559
+ align-items: center;
560
+ }
561
+
327
562
  .hm-image-adjust-panel,
328
563
  .hm-image-filter-panel {
329
564
  display: grid;
@@ -0,0 +1,266 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-command/v2.schema.json",
4
+ "title": "hm-image-command, version 2",
5
+ "description": "One user-level edit to an hm-image-plan (docs/formats/hm-image-plan.md, sdk-core ADR 0045). Version 1's commands are unchanged; this version adds the layer and redaction commands. Beyond this schema, the reducer checks a crop against the plan's source, keys and indexes against the plan's lists, and each layer and redaction that results.",
6
+ "oneOf": [
7
+ {
8
+ "description": "Sets the crop, or removes it with null.",
9
+ "type": "object",
10
+ "required": ["type", "crop"],
11
+ "additionalProperties": false,
12
+ "properties": {
13
+ "type": {
14
+ "const": "image.setCrop"
15
+ },
16
+ "crop": {
17
+ "oneOf": [
18
+ {
19
+ "type": "null"
20
+ },
21
+ {
22
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/crop"
23
+ }
24
+ ]
25
+ }
26
+ }
27
+ },
28
+ {
29
+ "description": "Sets the rotation and flips.",
30
+ "type": "object",
31
+ "required": ["type", "orientation"],
32
+ "additionalProperties": false,
33
+ "properties": {
34
+ "type": {
35
+ "const": "image.setOrientation"
36
+ },
37
+ "orientation": {
38
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/orientation"
39
+ }
40
+ }
41
+ },
42
+ {
43
+ "description": "Sets the export's size.",
44
+ "type": "object",
45
+ "required": ["type", "output"],
46
+ "additionalProperties": false,
47
+ "properties": {
48
+ "type": {
49
+ "const": "image.setOutput"
50
+ },
51
+ "output": {
52
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/output"
53
+ }
54
+ }
55
+ },
56
+ {
57
+ "description": "Sets one kept metadata field.",
58
+ "type": "object",
59
+ "required": ["type", "field", "value"],
60
+ "additionalProperties": false,
61
+ "properties": {
62
+ "type": {
63
+ "const": "image.setMetadata"
64
+ },
65
+ "field": {
66
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/metadataField"
67
+ },
68
+ "value": {
69
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/metadataValue"
70
+ }
71
+ }
72
+ },
73
+ {
74
+ "description": "Sets some develop adjustments.",
75
+ "type": "object",
76
+ "required": ["type", "values"],
77
+ "additionalProperties": false,
78
+ "properties": {
79
+ "type": {
80
+ "const": "image.setDevelop"
81
+ },
82
+ "values": {
83
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/developValues"
84
+ }
85
+ }
86
+ },
87
+ {
88
+ "description": "Sets the filter, or removes it with null.",
89
+ "type": "object",
90
+ "required": ["type", "filter"],
91
+ "additionalProperties": false,
92
+ "properties": {
93
+ "type": {
94
+ "const": "image.setFilter"
95
+ },
96
+ "filter": {
97
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/filter"
98
+ }
99
+ }
100
+ },
101
+ {
102
+ "description": "Inserts layers at an index: 0 is under every layer.",
103
+ "type": "object",
104
+ "required": ["type", "at", "layers"],
105
+ "additionalProperties": false,
106
+ "properties": {
107
+ "type": {
108
+ "const": "image.insertLayers"
109
+ },
110
+ "at": {
111
+ "type": "integer",
112
+ "minimum": 0
113
+ },
114
+ "layers": {
115
+ "type": "array",
116
+ "minItems": 1,
117
+ "items": {
118
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/layer"
119
+ }
120
+ }
121
+ }
122
+ },
123
+ {
124
+ "description": "Removes layers, by key.",
125
+ "type": "object",
126
+ "required": ["type", "keys"],
127
+ "additionalProperties": false,
128
+ "properties": {
129
+ "type": {
130
+ "const": "image.removeLayers"
131
+ },
132
+ "keys": {
133
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/keys"
134
+ }
135
+ }
136
+ },
137
+ {
138
+ "description": "Moves layers to an index of the list without them, keeping their order.",
139
+ "type": "object",
140
+ "required": ["type", "keys", "to"],
141
+ "additionalProperties": false,
142
+ "properties": {
143
+ "type": {
144
+ "const": "image.moveLayers"
145
+ },
146
+ "keys": {
147
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/keys"
148
+ },
149
+ "to": {
150
+ "type": "integer",
151
+ "minimum": 0
152
+ }
153
+ }
154
+ },
155
+ {
156
+ "description": "Sets some fields of some layers.",
157
+ "type": "object",
158
+ "required": ["type", "updates"],
159
+ "additionalProperties": false,
160
+ "properties": {
161
+ "type": {
162
+ "const": "image.updateLayers"
163
+ },
164
+ "updates": {
165
+ "type": "array",
166
+ "minItems": 1,
167
+ "items": {
168
+ "type": "object",
169
+ "required": ["key", "props"],
170
+ "additionalProperties": false,
171
+ "properties": {
172
+ "key": {
173
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/key"
174
+ },
175
+ "props": {
176
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/layerProps"
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ },
183
+ {
184
+ "description": "Inserts redactions at an index.",
185
+ "type": "object",
186
+ "required": ["type", "at", "redactions"],
187
+ "additionalProperties": false,
188
+ "properties": {
189
+ "type": {
190
+ "const": "image.insertRedactions"
191
+ },
192
+ "at": {
193
+ "type": "integer",
194
+ "minimum": 0
195
+ },
196
+ "redactions": {
197
+ "type": "array",
198
+ "minItems": 1,
199
+ "items": {
200
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/redaction"
201
+ }
202
+ }
203
+ }
204
+ },
205
+ {
206
+ "description": "Removes redactions, by key.",
207
+ "type": "object",
208
+ "required": ["type", "keys"],
209
+ "additionalProperties": false,
210
+ "properties": {
211
+ "type": {
212
+ "const": "image.removeRedactions"
213
+ },
214
+ "keys": {
215
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/keys"
216
+ }
217
+ }
218
+ },
219
+ {
220
+ "description": "Moves redactions to an index of the list without them, keeping their order.",
221
+ "type": "object",
222
+ "required": ["type", "keys", "to"],
223
+ "additionalProperties": false,
224
+ "properties": {
225
+ "type": {
226
+ "const": "image.moveRedactions"
227
+ },
228
+ "keys": {
229
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/keys"
230
+ },
231
+ "to": {
232
+ "type": "integer",
233
+ "minimum": 0
234
+ }
235
+ }
236
+ },
237
+ {
238
+ "description": "Sets some fields of some redactions.",
239
+ "type": "object",
240
+ "required": ["type", "updates"],
241
+ "additionalProperties": false,
242
+ "properties": {
243
+ "type": {
244
+ "const": "image.updateRedactions"
245
+ },
246
+ "updates": {
247
+ "type": "array",
248
+ "minItems": 1,
249
+ "items": {
250
+ "type": "object",
251
+ "required": ["key", "props"],
252
+ "additionalProperties": false,
253
+ "properties": {
254
+ "key": {
255
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/key"
256
+ },
257
+ "props": {
258
+ "$ref": "https://github.com/ie-huss-martinez/image-sdk/blob/main/formats/hm-image-plan/v2.schema.json#/$defs/redactionProps"
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+ ]
266
+ }