@teachinglab/omd 0.1.3 → 0.1.5

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.
Files changed (43) hide show
  1. package/canvas/tools/EraserTool.js +1 -1
  2. package/canvas/tools/PencilTool.js +1 -1
  3. package/canvas/tools/SelectTool.js +1 -1
  4. package/docs/api/configuration-options.md +198 -104
  5. package/docs/api/eventManager.md +83 -68
  6. package/docs/api/focusFrameManager.md +145 -150
  7. package/docs/api/index.md +106 -91
  8. package/docs/api/main.md +63 -58
  9. package/docs/api/omdBinaryExpressionNode.md +86 -227
  10. package/docs/api/omdCanvas.md +84 -142
  11. package/docs/api/omdConfigManager.md +113 -192
  12. package/docs/api/omdConstantNode.md +53 -117
  13. package/docs/api/omdDisplay.md +87 -121
  14. package/docs/api/omdEquationNode.md +174 -161
  15. package/docs/api/omdEquationSequenceNode.md +259 -301
  16. package/docs/api/omdEquationStack.md +157 -103
  17. package/docs/api/omdFunctionNode.md +83 -141
  18. package/docs/api/omdGroupNode.md +79 -182
  19. package/docs/api/omdHelpers.md +88 -96
  20. package/docs/api/omdLeafNode.md +86 -163
  21. package/docs/api/omdNode.md +202 -101
  22. package/docs/api/omdOperationDisplayNode.md +118 -139
  23. package/docs/api/omdOperatorNode.md +92 -127
  24. package/docs/api/omdParenthesisNode.md +134 -122
  25. package/docs/api/omdPopup.md +192 -117
  26. package/docs/api/omdPowerNode.md +132 -127
  27. package/docs/api/omdRationalNode.md +145 -128
  28. package/docs/api/omdSimplification.md +79 -110
  29. package/docs/api/omdSqrtNode.md +144 -79
  30. package/docs/api/omdStepVisualizer.md +147 -115
  31. package/docs/api/omdStepVisualizerHighlighting.md +66 -61
  32. package/docs/api/omdStepVisualizerInteractiveSteps.md +109 -129
  33. package/docs/api/omdStepVisualizerLayout.md +71 -60
  34. package/docs/api/omdStepVisualizerTextBoxes.md +77 -68
  35. package/docs/api/omdToolbar.md +131 -102
  36. package/docs/api/omdTranscriptionService.md +96 -76
  37. package/docs/api/omdTreeDiff.md +170 -134
  38. package/docs/api/omdUnaryExpressionNode.md +137 -174
  39. package/docs/api/omdUtilities.md +83 -70
  40. package/docs/api/omdVariableNode.md +123 -148
  41. package/index.js +2 -2
  42. package/package.json +1 -1
  43. /package/canvas/drawing/{segment.js → Segment.js} +0 -0
@@ -1,115 +1,147 @@
1
-
2
- # omdStepVisualizer
3
-
4
- Visualizes a sequence of mathematical steps (typically equations) and provides interactive explanations for how one step transforms into the next. Extends `omdEquationSequenceNode` by adding a visual track of dots and lines to the right of the steps, which can be clicked to reveal details about the simplification or operation applied.
5
-
6
- ## Import
7
-
8
- ```js
9
- import { omdStepVisualizer } from './omd/step-visualizer/omdStepVisualizer.js';
10
- ```
11
-
12
- ## Class Hierarchy
13
-
14
- ```
15
- omdNode
16
- └─ omdEquationSequenceNode
17
- └─ omdStepVisualizer
18
- ```
19
-
20
- See: [`omdEquationSequenceNode`](./omdEquationSequenceNode.md) for base sequence functionality.
21
-
22
- ## Constructor
23
-
24
- ```js
25
- new omdStepVisualizer(steps)
26
- ```
27
-
28
- - `steps` (`Array<omdNode>`): An array of nodes (usually `omdEquationNode`) representing the steps in the sequence.
29
-
30
- ## Key Features
31
-
32
- - **Interactive Dots:** Each step is represented by a clickable dot. Clicking a dot reveals a text box explaining the transformation from the previous step.
33
- - **Highlighting:** When a dot is clicked, the parts of the equations that were changed or involved in the transformation are highlighted.
34
- - **Automatic Layout:** The visualizer automatically handles the layout of the steps, the visual tracker, and the explanation text boxes.
35
- - **Simplification Analysis:** Analyzes the sequence to determine the mathematical justification for each step, whether it's a simplification rule (e.g., "Combine like terms") or a direct operation (e.g., "Add 3 to both sides").
36
-
37
- ## Properties
38
-
39
- In addition to properties from `omdEquationSequenceNode`:
40
-
41
- - `activeDotIndex` (`number`): The index of the currently active (clicked) dot. `-1` if none.
42
- - `dotsClickable` (`boolean`): Controls whether the step dots can be clicked to show explanations. Defaults to `true`.
43
- - `highlighting` ([`omdStepVisualizerHighlighting`](./omdStepVisualizerHighlighting.md)): The manager responsible for all highlighting logic.
44
- - `textBoxManager` ([`omdStepVisualizerTextBoxes`](./omdStepVisualizerTextBoxes.md)): The manager responsible for creating, positioning, and removing the explanation text boxes.
45
- - `layoutManager` ([`omdStepVisualizerLayout`](./omdStepVisualizerLayout.md)): The manager responsible for layout and z-ordering of all visual elements.
46
- - `stepDots`, `stepLines` (`Array`): Internal arrays holding the dot and line objects for the visual tracker. Not part of the public API, but useful for advanced customization.
47
- - `steps` (`Array<omdNode>`): The sequence of steps (usually `omdEquationNode`). Only `omdEquationNode` steps are visualized with dots/lines; other node types are ignored for the visual tracker.
48
-
49
- ## Methods
50
-
51
- This class inherits all methods from `omdEquationSequenceNode`. Overridden and new methods include:
52
-
53
- ### `addStep(step, options)`
54
- Adds a new step to the sequence and creates its corresponding visual dot and connecting line.
55
-
56
- ```js
57
- const newStep = omdEquationNode.fromString('x = 5');
58
- visualizer.addStep(newStep);
59
- ```
60
-
61
- ### `getNodeStepNumber(nodeId)`
62
- Gets the step number (index) associated with a given node ID.
63
-
64
- ```js
65
- const stepIndex = visualizer.getNodeStepNumber('some-node-id');
66
- ```
67
- - **Returns:** `number` (the step number, or `undefined` if the node is not found within a step)
68
-
69
- ### `setDotsClickable(enabled)`
70
- Enables or disables the ability to click on the step dots.
71
-
72
- ```js
73
- visualizer.setDotsClickable(false); // Explanations are now disabled
74
- ```
75
-
76
- ### `getStepTextBoxes()`
77
- Retrieves the array of currently visible text box components.
78
- - **Returns:** `Array` (the active text box instances)
79
-
80
- ## Internal Helpers
81
-
82
- Contains several private methods (`_handleDotClick`, `_getSimplificationDataForDot`, etc.) that manage the internal logic of handling user interaction, analyzing the step sequence, and coordinating the display of highlights and text boxes. These are not intended for external use but are crucial to the component's functionality.
83
-
84
- ## Supporting Classes
85
-
86
- Relies on three main helper classes to organize its complex logic:
87
- - **`omdStepVisualizerLayout`**: Manages the positioning of all visual elements, including the sequence itself, the dots, the lines, and the text boxes.
88
- - **`omdStepVisualizerTextBoxes`**: Handles the lifecycle of the explanation text boxes that appear when a dot is clicked.
89
- - **`omdStepVisualizerHighlighting`**: Manages the logic for highlighting nodes within the equations to show what has changed between steps.
90
-
91
- ## Example
92
-
93
- ```js
94
- import { omdStepVisualizer } from './omd/step-visualizer/omdStepVisualizer.js';
95
- import { omdEquationNode } from './omd/nodes/omdEquationNode.js';
96
- import { omdDisplay } from './omd/display/omdDisplay.js';
97
-
98
- // 1. Define the steps of a solution (must be omdEquationNode for dots to appear)
99
- const steps = [
100
- omdEquationNode.fromString('2x + 4 = 10'),
101
- omdEquationNode.fromString('2x = 6'),
102
- omdEquationNode.fromString('x = 3')
103
- ];
104
-
105
- // 2. Create the visualizer
106
- const visualizer = new omdStepVisualizer(steps);
107
-
108
- // 3. Add it to a display container
109
- const display = new omdDisplay(document.getElementById('container'));
110
- display.render(visualizer);
111
-
112
- // Now the steps will be displayed with interactive dots on the right.
113
- // Only omdEquationNode steps are visualized with dots/lines.
114
- // Clicking the dot next to "2x = 6" will explain that 4 was subtracted from both sides.
115
- ```
1
+ # omdStepVisualizer
2
+
3
+ Visualizes a sequence of mathematical steps (typically equations) and provides interactive explanations for how one step transforms into the next. It extends `omdEquationSequenceNode` by adding a visual track of dots and lines to the right of the steps, which can be clicked to reveal details about the simplification or operation applied.
4
+
5
+ ## Class Hierarchy
6
+
7
+ ```
8
+ omdNode
9
+ └─ omdEquationSequenceNode
10
+ └─ omdStepVisualizer
11
+ ```
12
+
13
+ See: [`omdEquationSequenceNode`](./omdEquationSequenceNode.md) for base sequence functionality.
14
+
15
+ ## Constructor
16
+
17
+ ### `new omdStepVisualizer(steps)`
18
+
19
+ Creates a new `omdStepVisualizer` instance.
20
+
21
+ - **`steps`** (`Array<omdNode>`): An array of nodes (usually `omdEquationNode`) representing the initial steps in the sequence.
22
+
23
+ During construction, it initializes internal arrays for `stepDots` and `stepLines`, creates a `visualContainer` for these elements, and sets up managers for `highlighting`, `textBoxes`, and `layout`. It also populates `nodeToStepMap` for efficient lookup.
24
+
25
+ ## Public Properties
26
+
27
+ - **`stepDots`** (`Array<jsvgEllipse>`): An array of `jsvgEllipse` objects representing the clickable dots for each equation step.
28
+ - **`stepLines`** (`Array<jsvgLine>`): An array of `jsvgLine` objects connecting the step dots.
29
+ - **`visualContainer`** (`jsvgLayoutGroup`): The `jsvgLayoutGroup` that holds the `stepDots` and `stepLines`.
30
+ - **`dotRadius`** (`number`): The radius of the step dots, determined by `omdConfigManager`.
31
+ - **`lineWidth`** (`number`): The stroke width of the connecting lines.
32
+ - **`visualSpacing`** (`number`): The horizontal spacing between the equation sequence and the visual tracker.
33
+ - **`activeDotIndex`** (`number`): The 0-based index of the currently active (clicked) dot. `-1` if none.
34
+ - **`dotsClickable`** (`boolean`): Controls whether the step dots can be clicked to show explanations. Default: `true`.
35
+ - **`nodeToStepMap`** (`Map<string, number>`): A map from `omdNode` IDs to their corresponding step index in the sequence.
36
+ - **`stepVisualizerHighlights`** (`Set<string>`): A set of node IDs that are currently highlighted by the visualizer.
37
+ - **`highlighting`** ([`omdStepVisualizerHighlighting`](./omdStepVisualizerHighlighting.md)): The manager responsible for all highlighting logic.
38
+ - **`textBoxManager`** ([`omdStepVisualizerTextBoxes`](./omdStepVisualizerTextBoxes.md)): The manager responsible for creating, positioning, and removing the explanation text boxes.
39
+ - **`layoutManager`** ([`omdStepVisualizerLayout`](./omdStepVisualizerLayout.md)): The manager responsible for layout and z-ordering of all visual elements.
40
+
41
+ ## Public Methods
42
+
43
+ ### `rebuildVisualizer()`
44
+
45
+ Forces a complete rebuild of the visual elements (dots and lines) from scratch. This is useful after significant changes to the underlying `steps` array.
46
+
47
+ ### `addStep(step, options)`
48
+
49
+ Adds a new step to the sequence. This method overrides the base `omdEquationSequenceNode.addStep` to also create and manage the corresponding visual dot and connecting line for the new step.
50
+
51
+ - **`step`** (`omdNode` | `string`): The node object or expression string for the step.
52
+ - **`options`** (`object`): Options for the step, such as `description` and `stepMark` (importance level).
53
+
54
+ ### `getNodeStepNumber(nodeId)`
55
+
56
+ Retrieves the step number (index) associated with a given `omdNode` ID within the sequence.
57
+
58
+ - **`nodeId`** (`string`): The ID of the node to look up.
59
+ - **Returns**: `number` | `undefined` - The 0-based step index, or `undefined` if the node is not found within a step.
60
+
61
+ ### `computeDimensions()`
62
+
63
+ Calculates the overall dimensions of the visualizer, accounting for the width and height of the equation sequence and the additional space required for the visual tracker (dots and lines).
64
+
65
+ - **Overrides**: `omdEquationSequenceNode.computeDimensions()`.
66
+
67
+ ### `updateLayout()`
68
+
69
+ Updates the layout of the visualizer, positioning both the equation sequence and the visual tracker elements. It delegates to the `layoutManager` for precise positioning of dots and lines.
70
+
71
+ - **Overrides**: `omdEquationSequenceNode.updateLayout()`.
72
+
73
+ ### `undoLastOperation()`
74
+
75
+ Removes the most recent operation and its resulting equation from the sequence. This method overrides the base `omdEquationSequenceNode.undoLastOperation` to also trigger a `rebuildVisualizer()` to ensure visual elements are synchronized.
76
+
77
+ - **Returns**: `boolean` - `true` if an operation was undone, `false` otherwise.
78
+
79
+ ### `setDotColor(dotIndex, color)`
80
+
81
+ Sets the fill and stroke color of a specific step dot.
82
+
83
+ - **`dotIndex`** (`number`): The index of the dot to color.
84
+ - **`color`** (`string`): The new color.
85
+
86
+ ### `setLineAboveColor(dotIndex, color)`
87
+
88
+ Sets the stroke color of the line segment directly above a specific step dot.
89
+
90
+ - **`dotIndex`** (`number`): The index of the dot whose preceding line should be colored.
91
+ - **`color`** (`string`): The new color.
92
+
93
+ ### `setDotsClickable(enabled)`
94
+
95
+ Enables or disables the ability for users to click on the step dots to reveal explanations.
96
+
97
+ - **`enabled`** (`boolean`): `true` to enable clicking, `false` to disable.
98
+
99
+ ### `getStepTextBoxes()`
100
+
101
+ Retrieves the array of currently visible explanation text box components managed by the `textBoxManager`.
102
+
103
+ - **Returns**: `Array<omdStepVisualizerTextBox>` - The active text box instances.
104
+
105
+ ## Internal Methods
106
+
107
+ - **`_initializeVisualElements()`**: Creates and initializes the visual dots and lines for all existing equation steps, and populates the `nodeToStepMap`.
108
+ - **`_createStepDot(equation, index)`**: Creates a single `jsvgEllipse` representing a step dot, associates it with an equation, and adds it to the `visualContainer`.
109
+ - **`_createStepLine(fromIndex, toIndex)`**: Creates a `jsvgLine` connecting two step dots and adds it to the `visualContainer`.
110
+ - **`_clearVisualElements()`**: Removes all existing dots, lines, and text boxes from the display and resets internal arrays.
111
+ - **`_handleDotClick(dot, dotIndex)`**: Event handler for when a step dot is clicked. It manages the active dot state, triggers highlighting, and creates/removes explanation text boxes.
112
+ - **`setActiveDot(dotIndex)`**: Sets a specific dot as the visually active one, changing its color and triggering the display of its explanation text box.
113
+ - **`_clearActiveDot()`**: Clears the currently active dot, resetting its color, removing its text box, and clearing highlights.
114
+ - **`_getSimplificationDataForDot(dotIndex)`**: Gathers and formats the simplification and operation data relevant to a specific step dot, used to populate the explanation text box.
115
+ - **`_createDefaultSimplificationData(message)`**: Helper to create a default data object for step explanations.
116
+ - **`_findPreviousVisibleEquationIndex(currentIndex)`**: Finds the index of the last visible equation step before the given `currentIndex`.
117
+ - **`_getRelevantSimplifications(simplificationHistory, startIndex, endIndex)`**: Filters the full simplification history to find entries relevant to a specific range of steps.
118
+ - **`_createMultipleSimplificationsData(simplifications)`**: Formats data for displaying multiple simplification events in a single text box.
119
+ - **`_checkForOperationStep(equationIndex)`**: Checks if a step at a given index is an `omdOperationDisplayNode` and extracts its data.
120
+ - **`_checkForSingleSimplification(simplificationHistory, equationIndex)`**: Checks for a single simplification entry relevant to a specific step.
121
+ - **`_getFallbackSimplificationData(equationIndex)`**: Provides a default explanation if no specific simplification or operation data is found for a step.
122
+
123
+ ## Example
124
+
125
+ ```javascript
126
+ import { omdStepVisualizer } from '@teachinglab/omd';
127
+ import { omdEquationNode } from '@teachinglab/omd';
128
+ import { omdDisplay } from '@teachinglab/omd';
129
+
130
+ // 1. Define the steps of a solution (must be omdEquationNode for dots to appear)
131
+ const steps = [
132
+ omdEquationNode.fromString('2x + 4 = 10'),
133
+ omdEquationNode.fromString('2x = 6'),
134
+ omdEquationNode.fromString('x = 3')
135
+ ];
136
+
137
+ // 2. Create the visualizer
138
+ const visualizer = new omdStepVisualizer(steps);
139
+
140
+ // 3. Add it to a display container
141
+ const display = new omdDisplay(document.getElementById('container'));
142
+ display.render(visualizer);
143
+
144
+ // Now the steps will be displayed with interactive dots on the right.
145
+ // Only omdEquationNode steps are visualized with dots/lines.
146
+ // Clicking the dot next to "2x = 6" will explain that 4 was subtracted from both sides.
147
+ ```
@@ -1,61 +1,66 @@
1
-
2
- # omdStepVisualizerHighlighting
3
-
4
- Manages the highlighting of nodes within mathematical expressions displayed by the `omdStepVisualizer`. Uses a robust tree differencing algorithm to identify changes between consecutive steps and highlights affected nodes, providing visual feedback on transformations.
5
-
6
- ## Import
7
-
8
- ```js
9
- import { omdStepVisualizerHighlighting } from './omd/step-visualizer/omdStepVisualizerHighlighting.js';
10
- ```
11
-
12
- ## Constructor
13
-
14
- ```js
15
- new omdStepVisualizerHighlighting(stepVisualizer)
16
- ```
17
-
18
- - `stepVisualizer` (`omdStepVisualizer`): The step visualizer instance this highlighting manager is associated with.
19
-
20
- ## Properties
21
-
22
- - `stepVisualizer` (`omdStepVisualizer`): The associated step visualizer instance.
23
- - `highlightedNodes` (`Set<omdNode>`): Set of currently highlighted nodes.
24
- - `educationalMode` (`boolean`): If `true`, enables highlighting of pedagogical simplifications. Default: `true`.
25
-
26
- ## Methods
27
-
28
- ### `highlightAffectedNodes(dotIndex, isOperation = false)`
29
- Main method to trigger highlighting. Compares the equation at `dotIndex` with the previous visible equation to identify changes and applies highlighting.
30
- - `dotIndex` (`number`): The index of the dot (step) for which to highlight affected nodes.
31
- - `isOperation` (`boolean`): If `true`, indicates the step is an operation (e.g., adding to both sides), which affects how provenance is highlighted.
32
-
33
- ### `clearHighlights()`
34
- Removes all active highlights from the expression tree.
35
-
36
- ### Private/Internal Methods
37
-
38
- - `_highlightNode(node)`: Applies the standard explanation highlight color to a single node.
39
- - `_findNearestVisibleEquationAbove(currentIndex)`: Finds the closest visible `omdEquationNode` preceding the given index.
40
- - `_highlightProvenanceNodes(changedNodes, previousEquation)`: Highlights nodes in the previous equation that are linked by provenance to the `changedNodes` in the current equation.
41
- - `_belongsToEquation(node, targetEquation)`: Checks if a given node is part of a specific equation's subtree.
42
- - `_highlightProvenanceNode(node)`: Applies a secondary highlighting style to nodes identified through provenance.
43
-
44
- ## How it Works
45
-
46
- 1. **Tree Differencing:** When `highlightAffectedNodes` is called, it uses `omdTreeDiff.findChangedNodes` to compare the current equation and the previous visible equation in the sequence.
47
- 2. **Change Identification:** `omdTreeDiff` identifies nodes that have been added, removed, or modified between the two steps.
48
- 3. **Direct Highlighting:** Nodes identified as directly changed are highlighted with a primary color.
49
- 4. **Provenance Highlighting:** For non-operation steps, the system traces the `provenance` (history) of the changed nodes back to their origins in the previous equation. These originating nodes are then highlighted with a secondary color, visually connecting the transformation.
50
-
51
- ## Example
52
-
53
- This class is typically used internally by `omdStepVisualizer` when a step dot is clicked:
54
-
55
- ```js
56
- // Inside omdStepVisualizer's _handleDotClick method:
57
- this.highlighting.highlightAffectedNodes(dotIndex, isOperation);
58
-
59
- // Inside omdStepVisualizer's _clearActiveDot method:
60
- this.highlighting.clearHighlights();
61
- ```
1
+ # omdStepVisualizerHighlighting
2
+
3
+ Manages the highlighting of nodes within mathematical expressions displayed by the `omdStepVisualizer`. It uses a robust tree differencing algorithm to identify changes between consecutive steps and highlights affected nodes, providing visual feedback on transformations.
4
+
5
+ ## Class Definition
6
+
7
+ ```javascript
8
+ export class omdStepVisualizerHighlighting
9
+ ```
10
+
11
+ ## Constructor
12
+
13
+ ### `new omdStepVisualizerHighlighting(stepVisualizer)`
14
+
15
+ Creates a new `omdStepVisualizerHighlighting` instance.
16
+
17
+ - **`stepVisualizer`** (`omdStepVisualizer`): The step visualizer instance this highlighting manager is associated with.
18
+
19
+ During construction, it initializes a `Set` to track `highlightedNodes` and sets `educationalMode` to `true` by default.
20
+
21
+ ## Public Properties
22
+
23
+ - **`stepVisualizer`** (`omdStepVisualizer`): The associated step visualizer instance.
24
+ - **`highlightedNodes`** (`Set<omdNode>`): A set of `omdNode` instances that are currently highlighted by this manager.
25
+ - **`educationalMode`** (`boolean`): If `true`, enables highlighting of pedagogical simplifications (e.g., intermediate steps that might be skipped in a final solution). Default: `true`.
26
+
27
+ ## Public Methods
28
+
29
+ ### `highlightAffectedNodes(dotIndex, isOperation = false)`
30
+
31
+ This is the main method to trigger highlighting. It compares the equation at `dotIndex` with the previous visible equation in the sequence to identify changes and then applies appropriate highlighting.
32
+
33
+ - **`dotIndex`** (`number`): The index of the dot (step) for which to highlight affected nodes.
34
+ - **`isOperation`** (`boolean`, optional): If `true`, indicates that the step is an operation (e.g., adding to both sides), which affects how provenance is highlighted. Default: `false`.
35
+
36
+ **How it Works:**
37
+
38
+ 1. **Clear Existing Highlights**: First, any previously active highlights are cleared.
39
+ 2. **Identify Equations**: It determines the `currentEquation` (associated with `dotIndex`) and finds the `previousEquation` (the nearest visible equation before the current one).
40
+ 3. **Tree Differencing**: It uses `omdTreeDiff.findChangedNodes` to perform a robust comparison between the `previousEquation` and `currentEquation`. This algorithm identifies nodes that have been added, removed, or modified.
41
+ 4. **Direct Highlighting**: Nodes identified as directly changed by the diff algorithm are highlighted with a primary explanation color (`omdColor.explainColor`).
42
+ 5. **Provenance Highlighting**: For non-operation steps, the system traces the `provenance` (history) of the directly changed nodes back to their origins in the `previousEquation`. These originating nodes are then highlighted with a secondary provenance color (`omdColor.provenanceColor`), visually connecting the transformation.
43
+
44
+ ### `clearHighlights()`
45
+
46
+ Removes all active highlights managed by this class from the expression tree. It iterates through all `highlightedNodes` and calls `setExplainHighlight(false)` on them, then clears its internal `highlightedNodes` set.
47
+
48
+ ## Internal Methods
49
+
50
+ - **`_highlightNode(node)`**: Applies the standard explanation highlight color (`omdColor.explainColor`) to a single `omdNode` by calling its `setExplainHighlight(true)` method and adds the node to `highlightedNodes`.
51
+ - **`_findNearestVisibleEquationAbove(currentIndex)`**: Searches backward from `currentIndex` in the `stepVisualizer.steps` array to find the closest `omdEquationNode` that is currently visible.
52
+ - **`_highlightProvenanceNodes(changedNodes, previousEquation)`**: Iterates through `changedNodes` and their `provenance` chains to identify and highlight corresponding nodes in the `previousEquation` with `omdColor.provenanceColor`. It uses `rootNode.nodeMap` for efficient node lookup and a `visited` set to prevent redundant processing.
53
+ - **`_belongsToEquation(node, targetEquation)`**: Checks if a given `omdNode` is part of the subtree of a `targetEquation` by traversing up its parent chain.
54
+ - **`_highlightProvenanceNode(node)`**: Applies the secondary provenance highlighting style (`omdColor.provenanceColor`) to a single `omdNode` by calling its `setExplainHighlight(true, omdColor.provenanceColor)` method.
55
+
56
+ ## Example
57
+
58
+ This class is typically used internally by `omdStepVisualizer` when a step dot is clicked:
59
+
60
+ ```javascript
61
+ // Inside omdStepVisualizer's _handleDotClick method:
62
+ this.highlighting.highlightAffectedNodes(dotIndex, isOperation);
63
+
64
+ // Inside omdStepVisualizer's _clearActiveDot method:
65
+ this.highlighting.clearHighlights();
66
+ ```