@teachinglab/omd 0.7.11 → 0.7.13

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.
@@ -95,6 +95,12 @@ export class SelectTool extends Tool {
95
95
  this.dragStartPoint = { x: event.x, y: event.y };
96
96
  this.potentialDeselect = segmentSelection;
97
97
 
98
+ // Also enable OMD dragging if we have selected OMD elements
99
+ if (this.selectedOMDElements.size > 0) {
100
+ this.isDraggingOMD = true;
101
+ this.startPoint = { x: event.x, y: event.y };
102
+ }
103
+
98
104
  // Set isDrawing so we get pointermove events
99
105
  if (this.canvas.eventManager) {
100
106
  this.canvas.eventManager.isDrawing = true;
@@ -127,6 +133,13 @@ export class SelectTool extends Tool {
127
133
  this.draggedOMDElement = omdElement; // Primary drag target
128
134
  this.startPoint = { x: event.x, y: event.y };
129
135
 
136
+ // Also enable stroke dragging if we have selected strokes
137
+ if (this.selectedSegments.size > 0) {
138
+ this.isDraggingStrokes = true;
139
+ this.dragStartPoint = { x: event.x, y: event.y };
140
+ this.hasSeparatedForDrag = false;
141
+ }
142
+
130
143
  // Show resize handles if this is the only selected element
131
144
  if (this.selectedOMDElements.size === 1) {
132
145
  this.resizeHandleManager.selectElement(omdElement);
@@ -1121,14 +1121,26 @@ _propagateBackgroundStyle(style, visited = new Set()) {
1121
1121
  * @private
1122
1122
  */
1123
1123
  _renderToTable(options) {
1124
+ // Helper to format expression - if it already has "y =" or starts with variable, use as-is, else prepend "y ="
1125
+ const formatEquation = (expr) => {
1126
+ const normalized = this._normalizeExpressionString(expr);
1127
+ // Check if expression already has "y =" or other variable assignment
1128
+ if (/^[a-zA-Z]\s*=/.test(normalized)) {
1129
+ return normalized;
1130
+ }
1131
+ // Otherwise prepend "y ="
1132
+ return `y = ${normalized}`;
1133
+ };
1134
+
1124
1135
  // Single side: let omdTable generate rows from equation
1125
1136
  if (options.side === 'left') {
1126
1137
  const expr = this._normalizeExpressionString(this.getLeft().toString());
1138
+ const equation = formatEquation(expr);
1127
1139
  return {
1128
1140
  omdType: "table",
1129
- title: `Function Table: y = ${expr}`,
1141
+ title: `Function Table: ${equation}`,
1130
1142
  headers: ["x", "y"],
1131
- equation: `y = ${expr}`,
1143
+ equation: equation,
1132
1144
  xMin: options.xMin,
1133
1145
  xMax: options.xMax,
1134
1146
  stepSize: options.stepSize,
@@ -1145,11 +1157,65 @@ _propagateBackgroundStyle(style, visited = new Set()) {
1145
1157
  };
1146
1158
  } else if (options.side === 'right') {
1147
1159
  const expr = this._normalizeExpressionString(this.getRight().toString());
1160
+ const equation = formatEquation(expr);
1161
+ return {
1162
+ omdType: "table",
1163
+ title: `Function Table: ${equation}`,
1164
+ headers: ["x", "y"],
1165
+ equation: equation,
1166
+ xMin: options.xMin,
1167
+ xMax: options.xMax,
1168
+ stepSize: options.stepSize,
1169
+ // Background customization options
1170
+ backgroundColor: (options.backgroundColor !== undefined) ? options.backgroundColor : undefined,
1171
+ backgroundCornerRadius: (options.backgroundCornerRadius !== undefined) ? options.backgroundCornerRadius : undefined,
1172
+ backgroundOpacity: (options.backgroundOpacity !== undefined) ? options.backgroundOpacity : undefined,
1173
+ showBackground: (options.showBackground !== undefined) ? options.showBackground : undefined,
1174
+ // Alternating row color options
1175
+ alternatingRowColors: (options.alternatingRowColors !== undefined) ? options.alternatingRowColors : undefined,
1176
+ evenRowColor: (options.evenRowColor !== undefined) ? options.evenRowColor : undefined,
1177
+ oddRowColor: (options.oddRowColor !== undefined) ? options.oddRowColor : undefined,
1178
+ alternatingRowOpacity: (options.alternatingRowOpacity !== undefined) ? options.alternatingRowOpacity : undefined
1179
+ };
1180
+ }
1181
+
1182
+ // Both sides: use equation format for proper table generation
1183
+ // The omdTable class can handle this better than manually computing data
1184
+ const leftExpr = this._normalizeExpressionString(this.getLeft().toString());
1185
+ const rightExpr = this._normalizeExpressionString(this.getRight().toString());
1186
+
1187
+ // If left side is just "y", use right side as the equation
1188
+ if (leftExpr.toLowerCase().trim() === 'y') {
1189
+ const equation = formatEquation(rightExpr);
1190
+ return {
1191
+ omdType: "table",
1192
+ title: `Function Table: ${equation}`,
1193
+ headers: ["x", "y"],
1194
+ equation: equation,
1195
+ xMin: options.xMin,
1196
+ xMax: options.xMax,
1197
+ stepSize: options.stepSize,
1198
+ // Background customization options
1199
+ backgroundColor: (options.backgroundColor !== undefined) ? options.backgroundColor : undefined,
1200
+ backgroundCornerRadius: (options.backgroundCornerRadius !== undefined) ? options.backgroundCornerRadius : undefined,
1201
+ backgroundOpacity: (options.backgroundOpacity !== undefined) ? options.backgroundOpacity : undefined,
1202
+ showBackground: (options.showBackground !== undefined) ? options.showBackground : undefined,
1203
+ // Alternating row color options
1204
+ alternatingRowColors: (options.alternatingRowColors !== undefined) ? options.alternatingRowColors : undefined,
1205
+ evenRowColor: (options.evenRowColor !== undefined) ? options.evenRowColor : undefined,
1206
+ oddRowColor: (options.oddRowColor !== undefined) ? options.oddRowColor : undefined,
1207
+ alternatingRowOpacity: (options.alternatingRowOpacity !== undefined) ? options.alternatingRowOpacity : undefined
1208
+ };
1209
+ }
1210
+
1211
+ // If right side is just "y", use left side as the equation
1212
+ if (rightExpr.toLowerCase().trim() === 'y') {
1213
+ const equation = formatEquation(leftExpr);
1148
1214
  return {
1149
1215
  omdType: "table",
1150
- title: `Function Table: y = ${expr}`,
1216
+ title: `Function Table: ${equation}`,
1151
1217
  headers: ["x", "y"],
1152
- equation: `y = ${expr}`,
1218
+ equation: equation,
1153
1219
  xMin: options.xMin,
1154
1220
  xMax: options.xMax,
1155
1221
  stepSize: options.stepSize,
@@ -1166,7 +1232,7 @@ _propagateBackgroundStyle(style, visited = new Set()) {
1166
1232
  };
1167
1233
  }
1168
1234
 
1169
- // Both sides: compute data for x, left(x), right(x)
1235
+ // Both sides have expressions: compute data for x, left(x), right(x)
1170
1236
  const leftSide = this.getLeft();
1171
1237
  const rightSide = this.getRight();
1172
1238
  const leftLabel = leftSide.toString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teachinglab/omd",
3
- "version": "0.7.11",
3
+ "version": "0.7.13",
4
4
  "description": "omd",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",