@teachinglab/omd 0.7.1 → 0.7.3
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/canvas/ui/toolbar.js +8 -3
- package/package.json +1 -1
- package/src/omdExpression.js +19 -2
package/canvas/ui/toolbar.js
CHANGED
|
@@ -41,6 +41,11 @@ export class Toolbar {
|
|
|
41
41
|
// Create a jsvgGroup for the toolbar
|
|
42
42
|
this.toolbarGroup = new jsvgGroup();
|
|
43
43
|
|
|
44
|
+
// Stop pointer events from bubbling to canvas to prevent drawing while interacting with toolbar
|
|
45
|
+
const stopPropagation = (e) => e.stopPropagation();
|
|
46
|
+
this.toolbarGroup.svgObject.addEventListener('pointerdown', stopPropagation);
|
|
47
|
+
this.toolbarGroup.svgObject.addEventListener('pointermove', stopPropagation);
|
|
48
|
+
this.toolbarGroup.svgObject.addEventListener('pointerup', stopPropagation);
|
|
44
49
|
|
|
45
50
|
// Create background rectangle
|
|
46
51
|
this.background = new jsvgRect();
|
|
@@ -135,7 +140,7 @@ export class Toolbar {
|
|
|
135
140
|
const button = new jsvgButton();
|
|
136
141
|
button.setWidthAndHeight(size, size);
|
|
137
142
|
button.setCornerRadius(size / 2); // Make it circular
|
|
138
|
-
button.setFillColor(
|
|
143
|
+
button.setFillColor(this.omdColor.lightGray);
|
|
139
144
|
|
|
140
145
|
// Remove any default text from the button group (if present)
|
|
141
146
|
// jsvgButton may add a <text> element by default; remove it
|
|
@@ -193,13 +198,13 @@ export class Toolbar {
|
|
|
193
198
|
_updateActiveButton(toolName) {
|
|
194
199
|
// Reset all buttons
|
|
195
200
|
this.buttons.forEach(button => {
|
|
196
|
-
button.setFillColor(
|
|
201
|
+
button.setFillColor(this.omdColor.lightGray);
|
|
197
202
|
});
|
|
198
203
|
|
|
199
204
|
// Highlight active button
|
|
200
205
|
const activeButton = this.buttons.get(toolName);
|
|
201
206
|
if (activeButton) {
|
|
202
|
-
activeButton.setFillColor(
|
|
207
|
+
activeButton.setFillColor('white');
|
|
203
208
|
this.activeButton = activeButton;
|
|
204
209
|
} else {
|
|
205
210
|
this.activeButton = null;
|
package/package.json
CHANGED
package/src/omdExpression.js
CHANGED
|
@@ -35,6 +35,14 @@ export class omdExpression extends omdMetaExpression
|
|
|
35
35
|
const parsed = parseExpressionString(data);
|
|
36
36
|
if ( parsed ) data = parsed;
|
|
37
37
|
}
|
|
38
|
+
// Handle object with 'expression' string property
|
|
39
|
+
else if ( typeof data === 'object' && data.expression && typeof data.expression === 'string' ) {
|
|
40
|
+
const parsed = parseExpressionString(data.expression);
|
|
41
|
+
if ( parsed ) {
|
|
42
|
+
// Merge parsed data into data object
|
|
43
|
+
data = { ...data, ...parsed };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
38
46
|
|
|
39
47
|
if ( typeof data.termsAndOpers != "undefined" )
|
|
40
48
|
{
|
|
@@ -73,6 +81,14 @@ export class omdExpression extends omdMetaExpression
|
|
|
73
81
|
this.operatorSet.push( P );
|
|
74
82
|
this.expressionStack.addChild( P );
|
|
75
83
|
}
|
|
84
|
+
else if ( elem.omdType == "string" )
|
|
85
|
+
{
|
|
86
|
+
// Fallback for string tokens - treat as term with variable name
|
|
87
|
+
var T = new omdTerm(1, elem.name, 1);
|
|
88
|
+
T.hideBackgroundByDefault();
|
|
89
|
+
this.termSet.push( T );
|
|
90
|
+
this.expressionStack.addChild( T );
|
|
91
|
+
}
|
|
76
92
|
}
|
|
77
93
|
}
|
|
78
94
|
|
|
@@ -108,9 +124,10 @@ export class omdExpression extends omdMetaExpression
|
|
|
108
124
|
|
|
109
125
|
this.setWidthAndHeight( this.backRect.width, this.backRect.height );
|
|
110
126
|
|
|
111
|
-
// Set individual width/height properties
|
|
127
|
+
// Set individual width/height properties
|
|
112
128
|
this.width = this.backRect.width;
|
|
113
129
|
this.height = this.backRect.height;
|
|
114
|
-
|
|
130
|
+
// Removed viewBox setting as it is not valid for 'g' elements and can cause rendering issues
|
|
131
|
+
// this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
115
132
|
}
|
|
116
133
|
}
|