@pie-players/pie-tool-answer-eliminator 0.3.64 → 0.3.65

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
@@ -213,6 +213,23 @@ Elimination styling is applied by a pluggable `EliminationStrategy` built on the
213
213
  - `strikethrough` (default): a `::highlight(pie-answer-eliminated-<id>)` rule renders a line-through over the choice label.
214
214
  - `mask`: a `::highlight(pie-answer-masked-<id>)` rule dims and blurs the choice.
215
215
 
216
+ Images need separate treatment: they are replaced elements, so neither `::highlight()` nor `text-decoration` paints on them and a picture choice would look untouched. The `strikethrough` strategy therefore wraps each `img` in the eliminated choice in a `span.pie-answer-eliminator-image-strike` (marked with `data-pie-answer-eliminator-image-strike`) and overlays a decorative, `pointer-events: none` SVG that draws an X corner to corner — upper-left to lower-right and lower-left to upper-right. Restoring the choice unwraps the image and returns the DOM to its original shape. Each diagonal is painted over a wider light casing line (`--pie-answer-eliminator-image-strike-casing-color`) so it stays legible over dark artwork.
217
+
218
+ MathJax-rendered math needs its own mark for the same reason. MathJax's CHTML output draws each glyph as an `mjx-c` element with empty `textContent` (the character comes from `::before` generated content, which belongs to no Range), and its SVG output has no text at all — so the highlight had nothing to decorate and a math-only choice looked untouched. For each `mjx-container` in the eliminated choice, the `strikethrough` strategy marks the inner `mjx-math` box with `pie-answer-eliminator-math-strike` plus one of two modifiers, and the theme paints it:
219
+
220
+ | expression | mark | `data-pie-answer-eliminator-math-strike` |
221
+ | --- | --- | --- |
222
+ | single row of symbols | centred line-through, as the prose gets | `line` |
223
+ | contains a fraction bar or table rule | diagonals, as an eliminated image gets | `cross` |
224
+
225
+ A centred line on a fraction lands on the math axis — exactly where the fraction bar already sits — so it reads as a recoloured bar rather than an elimination. The split is structural (`mjx-mfrac`, `mjx-mtable`), not height-based: an inline `a/b` is only 1.16× its font size, indistinguishable in height from a radical or a parenthesised row, yet it is precisely the colliding case. Radicals and stacked limits keep the line, since their bars sit at the top or the strike simply crosses the base.
226
+
227
+ The inner `mjx-math` box is the paint target, not the container: for inline math `mjx-container` is `display: inline`, so its rect is the surrounding line box while the expression itself overflows it — a fraction sticks out several pixels above and below.
228
+
229
+ Only MathJax containers are marked: natively rendered MathML keeps real text in `mi`/`mn`/`mo`, so the highlight already strikes every token there.
230
+
231
+ All three treatments — the text line-through, the diagonals over an image, the line over math — are drawn in one colour, `--pie-answer-eliminator-strike-color` (defaulting to `--pie-incorrect`), so a choice mixing prose, pictures, and math reads as a single strike and can be restyled from one place.
232
+
216
233
  For browsers without the Highlight API, each strategy falls back to a class on the choice container. Either way the eliminated choice also receives ARIA hooks (`data-pie-answer-eliminated`, plus `aria-disabled`/`aria-hidden` and an offscreen "(eliminated)" announcement) for assistive technology.
217
234
 
218
235
  ### 4. Toggle Behavior
package/dist/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- /**
2
- * pie-tool-answer-eliminator - PIE Assessment Tool
3
- *
4
- * This package exports a web component built from Svelte.
5
- * Import the built version for CDN usage, or the .svelte source for Svelte projects.
6
- */
7
- export { AdapterRegistry } from './adapters/adapter-registry.js';
1
+ export {}
2
+ import PieToolAnswerEliminator from './tool-answer-eliminator.svelte.js'
3
+ export default PieToolAnswerEliminator
4
+ export {}
@@ -15,10 +15,26 @@ export declare class StrikethroughStrategy implements EliminationStrategy {
15
15
  private static readonly LABEL_HOOK_ATTR;
16
16
  private static readonly ELIMINATED_ATTR;
17
17
  private static readonly ELIMINATED_ID_ATTR;
18
+ private static readonly IMAGE_WRAPPER_CLASS;
19
+ private static readonly IMAGE_WRAPPER_ATTR;
20
+ private static readonly IMAGE_OVERLAY_CLASS;
21
+ private static readonly IMAGE_LINE_CLASS;
22
+ private static readonly IMAGE_CASING_CLASS;
23
+ private static readonly MATH_STRIKE_CLASS;
24
+ private static readonly MATH_STRIKE_LINE_CLASS;
25
+ private static readonly MATH_STRIKE_CROSS_CLASS;
26
+ private static readonly MATH_STRIKE_ATTR;
27
+ private static readonly MATH_STACKED_SELECTOR;
28
+ private static readonly MATH_BOX_SELECTOR;
29
+ private static readonly MATH_SELECTOR;
30
+ private static readonly SVG_NS;
31
+ private static readonly BLOCK_DISPLAYS;
18
32
  readonly name = "strikethrough";
19
33
  private highlights;
20
34
  private ranges;
21
35
  private fallbackContainers;
36
+ private imageWrappers;
37
+ private mathTargets;
22
38
  initialize(): void;
23
39
  destroy(): void;
24
40
  apply(choiceId: string, range: Range): void;
@@ -34,5 +50,57 @@ export declare class StrikethroughStrategy implements EliminationStrategy {
34
50
  private findChoiceContainer;
35
51
  private applyFallback;
36
52
  private removeFallback;
53
+ /**
54
+ * Overlay every image in the eliminated choice with a diagonal X, drawn in
55
+ * the same strike colour as the text line-through.
56
+ *
57
+ * Images are replaced elements: `line-through` (and `::highlight()`) never
58
+ * paints on them, and they cannot carry a pseudo-element, so each image is
59
+ * wrapped in a positioned span that hosts an absolutely-positioned overlay.
60
+ * Wrapping keeps the overlay glued to the image through any later reflow —
61
+ * responsive resizing, late image `load`, zoom — with no observers.
62
+ */
63
+ private strikeImages;
64
+ private unstrikeImages;
65
+ /**
66
+ * Give MathJax-rendered math the same line-through the choice's text gets.
67
+ *
68
+ * `::highlight()` cannot reach it: MathJax's CHTML output draws every visible
69
+ * glyph as an `mjx-c` element with empty `textContent`, the character coming
70
+ * from `::before` generated content — which is part of no Range. (Its only
71
+ * real text is the `mjx-assistive-mml` copy of the source MathML, clipped to
72
+ * 1px for assistive tech, so the highlight paints it invisibly.) Its SVG
73
+ * output has no text at all. A math-only choice therefore looked identical to
74
+ * an un-eliminated one.
75
+ *
76
+ * Unlike an image, the rendered math box is a normal element that can carry a
77
+ * pseudo-element, so this only adds a class and lets CSS paint it — no
78
+ * wrapper, nothing restructured, and MathJax's own layout left alone.
79
+ *
80
+ * A single row of symbols gets the line-through the prose gets. An expression
81
+ * that draws horizontal rules of its own gets diagonals instead: a line
82
+ * centred on a fraction lands on the math axis, which is exactly where the
83
+ * fraction bar already sits, so it reads as a recoloured bar rather than as an
84
+ * elimination.
85
+ */
86
+ private strikeMath;
87
+ private unstrikeMath;
88
+ /**
89
+ * The element whose images belong to this elimination. Adapters build the
90
+ * range over the choice's own content (label or choice node), so its common
91
+ * ancestor is the right scope; the choice container is the fallback.
92
+ */
93
+ private resolveImageScope;
94
+ private wrapImage;
95
+ private fillsParentWidth;
96
+ private unwrapImage;
97
+ /**
98
+ * Corner-to-corner X sized to the wrapper. `preserveAspectRatio="none"`
99
+ * stretches the 100x100 viewBox onto any aspect ratio, and
100
+ * `vector-effect="non-scaling-stroke"` keeps both lines an even screen-space
101
+ * thickness under that non-uniform scale. The wider casing line under each
102
+ * red line keeps the X visible over dark or red imagery (WCAG 1.4.11).
103
+ */
104
+ private createImageStrikeOverlay;
37
105
  private resolveLabelElement;
38
106
  }