labellife-design-tool 2.4.1 → 2.4.2
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/cjs/canvas/workspace.js +321 -92
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +374 -65
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js +538 -31
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js +265 -36
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +375 -67
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js +540 -33
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var reactKonva = require('react-konva');
|
|
7
7
|
var mobxReactLite = require('mobx-react-lite');
|
|
8
8
|
var material = require('@mui/material');
|
|
@@ -519,9 +519,9 @@ var VIEWPORT_PAD = 400; // page units of dim area rendered around the crop rect
|
|
|
519
519
|
var CropEditor = mobxReactLite.observer(function (_ref) {
|
|
520
520
|
var element = _ref.element,
|
|
521
521
|
image = _ref.image;
|
|
522
|
-
var rectRef =
|
|
523
|
-
var transformerRef =
|
|
524
|
-
|
|
522
|
+
var rectRef = React.useRef(null);
|
|
523
|
+
var transformerRef = React.useRef(null);
|
|
524
|
+
React.useEffect(function () {
|
|
525
525
|
if (transformerRef.current && rectRef.current) {
|
|
526
526
|
var _transformerRef$curre;
|
|
527
527
|
transformerRef.current.nodes([rectRef.current]);
|
|
@@ -694,19 +694,19 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
694
694
|
onDragEnd = _ref.onDragEnd,
|
|
695
695
|
groupChild = _ref.groupChild,
|
|
696
696
|
store = _ref.store;
|
|
697
|
-
var imageRef =
|
|
698
|
-
var groupRef =
|
|
699
|
-
var _useState =
|
|
697
|
+
var imageRef = React.useRef(null);
|
|
698
|
+
var groupRef = React.useRef(null);
|
|
699
|
+
var _useState = React.useState(null),
|
|
700
700
|
_useState2 = _slicedToArray(_useState, 2),
|
|
701
701
|
image = _useState2[0],
|
|
702
702
|
setImage = _useState2[1];
|
|
703
703
|
|
|
704
704
|
// Persistent auto-crop state: tracks the visible portion of the source image.
|
|
705
705
|
// Initialized on image load (cover-fit centered), then updated directionally on resize.
|
|
706
|
-
var autoCropRef =
|
|
707
|
-
var autoCropSrcRef =
|
|
706
|
+
var autoCropRef = React.useRef(null);
|
|
707
|
+
var autoCropSrcRef = React.useRef(null); // tracks which image the crop was computed for
|
|
708
708
|
|
|
709
|
-
|
|
709
|
+
React.useEffect(function () {
|
|
710
710
|
if (!element.src) {
|
|
711
711
|
setImage(null);
|
|
712
712
|
return;
|
|
@@ -736,7 +736,7 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
736
736
|
var needsCache = hasFilters || element.cornerRadius > 0 || element.shadowEnabled;
|
|
737
737
|
|
|
738
738
|
// Cache the image node whenever filters, cornerRadius, or shadow change so they take effect
|
|
739
|
-
|
|
739
|
+
React.useEffect(function () {
|
|
740
740
|
var node = imageRef.current;
|
|
741
741
|
if (!node || !image) return;
|
|
742
742
|
if (needsCache) {
|
|
@@ -1020,6 +1020,203 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1020
1020
|
});
|
|
1021
1021
|
ImageElementComponent.displayName = 'ImageElement';
|
|
1022
1022
|
|
|
1023
|
+
// Composes a canvas/Konva font-style string (e.g. "italic bold") from the
|
|
1024
|
+
// element model's separate fontStyle/fontWeight fields. Shared by
|
|
1025
|
+
// text-element.js (KonvaText) and curved-text.js (custom Shape), which
|
|
1026
|
+
// both need to build a canvas `ctx.font` / Konva fontStyle string the same
|
|
1027
|
+
// way.
|
|
1028
|
+
function composeFontStyle(fontStyle, fontWeight) {
|
|
1029
|
+
var parts = [];
|
|
1030
|
+
var style = String(fontStyle || '').trim();
|
|
1031
|
+
var weight = String(fontWeight || '').trim();
|
|
1032
|
+
if (style === 'italic' || style.includes('italic')) parts.push('italic');
|
|
1033
|
+
if (weight && weight !== 'normal') parts.push(weight);
|
|
1034
|
+
return parts.length > 0 ? parts.join(' ') : 'normal';
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
// src/canvas/curved-text-geometry.js
|
|
1038
|
+
//
|
|
1039
|
+
// Pure, framework-free geometry math for the curved-text effect.
|
|
1040
|
+
// Deliberately authored as CommonJS (not ESM like the rest of src/canvas)
|
|
1041
|
+
// so this one file can be unit-tested with plain `node`, no jest/babel
|
|
1042
|
+
// required — this repo has no test framework installed. Rollup's
|
|
1043
|
+
// commonjs() plugin (already in rollup.config.mjs) interops this into the
|
|
1044
|
+
// ESM build correctly when curved-text.js imports it with `import`.
|
|
1045
|
+
|
|
1046
|
+
// At curvePower = 100 (max), the radius is this many multiples of
|
|
1047
|
+
// fontSize. Tuned empirically: 3x let realistic multi-word labels wrap
|
|
1048
|
+
// into a nearly-closed loop well before the slider reached 100 (e.g. a
|
|
1049
|
+
// ~500px-wide line swept ~341° — individual glyphs rotate past horizontal
|
|
1050
|
+
// once a line wraps past ~180°, which read as "letters rotating wrong").
|
|
1051
|
+
// 6x keeps the same line under ~170° at max curvePower, a clearly-open arc.
|
|
1052
|
+
// Adjust this constant (and re-run curved-text-geometry.test.js, which
|
|
1053
|
+
// exercises it) if the on-screen result needs to be tighter/looser.
|
|
1054
|
+
var MAX_RADIUS_FONT_MULTIPLIER = 6;
|
|
1055
|
+
|
|
1056
|
+
// Maps curvePower (-100..100) to a positive radius magnitude in px.
|
|
1057
|
+
// Direction (smile vs frown) is NOT encoded here — callers apply
|
|
1058
|
+
// Math.sign(curvePower) separately (see curved-text.js). curvePower = 0
|
|
1059
|
+
// returns Infinity (a "straight line" radius) for defensiveness, though
|
|
1060
|
+
// callers should treat curvePower === 0 as "don't curve at all" before
|
|
1061
|
+
// reaching here (falls back to plain KonvaText).
|
|
1062
|
+
function computeArcRadius(curvePower, fontSize) {
|
|
1063
|
+
var power = Math.abs(curvePower);
|
|
1064
|
+
if (power === 0) return Infinity;
|
|
1065
|
+
return fontSize * MAX_RADIUS_FONT_MULTIPLIER / (power / 100);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// Computes the radius for line `lineIndex` (0-based, top to bottom) of a
|
|
1069
|
+
// multi-line curved text block, so all lines share one arc center
|
|
1070
|
+
// (concentric) and stack in normal reading order.
|
|
1071
|
+
//
|
|
1072
|
+
// For curvePower > 0 ("smile", center below the text), later lines move
|
|
1073
|
+
// closer to the center (smaller radius). For curvePower < 0 ("frown",
|
|
1074
|
+
// center above the text), later lines move away from the center (larger
|
|
1075
|
+
// radius).
|
|
1076
|
+
function computeLineRadius(baseRadius, lineIndex, lineHeight, curvePower) {
|
|
1077
|
+
var direction = curvePower > 0 ? -1 : 1;
|
|
1078
|
+
return baseRadius + lineIndex * lineHeight * direction;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// Distributes characters of one line along an arc of the given radius,
|
|
1082
|
+
// centered so the line's midpoint sits at angle 0 — i.e. center-aligned.
|
|
1083
|
+
//
|
|
1084
|
+
// charWidths: array of per-glyph advance widths (px), in reading order.
|
|
1085
|
+
// radius: positive, finite radius magnitude (px) for this line.
|
|
1086
|
+
//
|
|
1087
|
+
// Returns an array, one entry per character, each: { angle } — the angle
|
|
1088
|
+
// (radians) from the arc's center-line, in reading order. Callers convert
|
|
1089
|
+
// `angle` + `radius` into an (x, y) position and a tangent rotation for
|
|
1090
|
+
// drawing (see curved-text.js).
|
|
1091
|
+
function layoutCharsOnArc(charWidths, radius) {
|
|
1092
|
+
if (!Number.isFinite(radius) || radius <= 0) {
|
|
1093
|
+
throw new Error('layoutCharsOnArc requires a finite, positive radius');
|
|
1094
|
+
}
|
|
1095
|
+
var totalWidth = charWidths.reduce(function (sum, w) {
|
|
1096
|
+
return sum + w;
|
|
1097
|
+
}, 0);
|
|
1098
|
+
var totalAngle = totalWidth / radius;
|
|
1099
|
+
var cumBefore = 0;
|
|
1100
|
+
return charWidths.map(function (w) {
|
|
1101
|
+
var cumMid = cumBefore + w / 2;
|
|
1102
|
+
cumBefore += w;
|
|
1103
|
+
var angleFromStart = cumMid / radius;
|
|
1104
|
+
return {
|
|
1105
|
+
angle: angleFromStart - totalAngle / 2
|
|
1106
|
+
};
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
var curvedTextGeometry = {
|
|
1110
|
+
computeArcRadius: computeArcRadius,
|
|
1111
|
+
computeLineRadius: computeLineRadius,
|
|
1112
|
+
layoutCharsOnArc: layoutCharsOnArc
|
|
1113
|
+
};
|
|
1114
|
+
|
|
1115
|
+
var CurvedText = mobxReactLite.observer(/*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
1116
|
+
var element = _ref.element,
|
|
1117
|
+
displayText = _ref.displayText,
|
|
1118
|
+
width = _ref.width;
|
|
1119
|
+
var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
|
|
1120
|
+
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
1121
|
+
var lineHeightPx = element.fontSize * lineHeightMultiplier;
|
|
1122
|
+
var letterSpacing = element.letterSpacing || 0;
|
|
1123
|
+
var curvePower = element.curvePower;
|
|
1124
|
+
|
|
1125
|
+
// Precondition: caller must not mount this component with curvePower === 0.
|
|
1126
|
+
// Defensive guard to avoid passing Infinity to layoutCharsOnArc.
|
|
1127
|
+
if (curvePower === 0) return null;
|
|
1128
|
+
var direction = curvePower > 0 ? 1 : -1;
|
|
1129
|
+
var baseRadius = curvedTextGeometry.computeArcRadius(curvePower, element.fontSize);
|
|
1130
|
+
var lines = (displayText || '').split('\n');
|
|
1131
|
+
|
|
1132
|
+
// Shared per-character geometry: walks every line/character and invokes
|
|
1133
|
+
// `draw(ctx, ch, x, y, angle)` inside the same save/translate/rotate/
|
|
1134
|
+
// restore frame. Used by both sceneFunc (real glyph fill/stroke) and
|
|
1135
|
+
// hitFunc (hit-region rects) so the clickable area always matches what's
|
|
1136
|
+
// actually painted — duplicating this math between the two would risk
|
|
1137
|
+
// them drifting apart.
|
|
1138
|
+
var forEachChar = function forEachChar(ctx, draw) {
|
|
1139
|
+
var centerX = width / 2;
|
|
1140
|
+
lines.forEach(function (lineText, lineIndex) {
|
|
1141
|
+
var chars = Array.from(lineText);
|
|
1142
|
+
if (chars.length === 0) return;
|
|
1143
|
+
var charWidths = chars.map(function (ch) {
|
|
1144
|
+
return ctx.measureText(ch).width + letterSpacing;
|
|
1145
|
+
});
|
|
1146
|
+
var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, curvePower);
|
|
1147
|
+
var signedRadius = direction * lineRadius;
|
|
1148
|
+
var baselineY = lineIndex * lineHeightPx + element.fontSize;
|
|
1149
|
+
var centerY = baselineY + signedRadius;
|
|
1150
|
+
var layout = curvedTextGeometry.layoutCharsOnArc(charWidths, lineRadius);
|
|
1151
|
+
chars.forEach(function (ch, idx) {
|
|
1152
|
+
var angle = layout[idx].angle;
|
|
1153
|
+
var x = centerX + lineRadius * Math.sin(angle);
|
|
1154
|
+
var y = centerY - signedRadius * Math.cos(angle);
|
|
1155
|
+
draw(ctx, ch, x, y, angle, charWidths[idx]);
|
|
1156
|
+
});
|
|
1157
|
+
});
|
|
1158
|
+
};
|
|
1159
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactKonva.Shape, {
|
|
1160
|
+
ref: ref,
|
|
1161
|
+
width: width,
|
|
1162
|
+
height: lines.length * lineHeightPx,
|
|
1163
|
+
sceneFunc: function sceneFunc(ctx) {
|
|
1164
|
+
ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
|
|
1165
|
+
ctx.textAlign = 'center';
|
|
1166
|
+
ctx.textBaseline = 'alphabetic';
|
|
1167
|
+
forEachChar(ctx, function (c, ch, x, y, angle) {
|
|
1168
|
+
c.save();
|
|
1169
|
+
c.translate(x, y);
|
|
1170
|
+
c.rotate(direction * angle);
|
|
1171
|
+
if (element.strokeWidth > 0) {
|
|
1172
|
+
c.strokeStyle = element.stroke || '#000000';
|
|
1173
|
+
c.lineWidth = element.strokeWidth;
|
|
1174
|
+
c.strokeText(ch, 0, 0);
|
|
1175
|
+
}
|
|
1176
|
+
c.fillStyle = element.fill;
|
|
1177
|
+
c.fillText(ch, 0, 0);
|
|
1178
|
+
c.restore();
|
|
1179
|
+
});
|
|
1180
|
+
},
|
|
1181
|
+
hitFunc: function hitFunc(ctx, shape) {
|
|
1182
|
+
ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
|
|
1183
|
+
ctx.textAlign = 'center';
|
|
1184
|
+
ctx.textBaseline = 'alphabetic';
|
|
1185
|
+
ctx.beginPath();
|
|
1186
|
+
forEachChar(ctx, function (c, ch, x, y, angle, charWidth) {
|
|
1187
|
+
c.save();
|
|
1188
|
+
c.translate(x, y);
|
|
1189
|
+
c.rotate(direction * angle);
|
|
1190
|
+
c.rect(-charWidth / 2, -element.fontSize * 0.8, charWidth, element.fontSize * 1.1);
|
|
1191
|
+
c.restore();
|
|
1192
|
+
});
|
|
1193
|
+
ctx.fillStrokeShape(shape);
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
}));
|
|
1197
|
+
CurvedText.displayName = 'CurvedText';
|
|
1198
|
+
|
|
1199
|
+
function computeCurvedCacheBounds(element) {
|
|
1200
|
+
var lineCount = (element.text || element.placeholder || '').split('\n').length;
|
|
1201
|
+
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
1202
|
+
var lineHeightPx = element.fontSize * lineHeightMultiplier;
|
|
1203
|
+
var baseRadius = curvedTextGeometry.computeArcRadius(element.curvePower, element.fontSize);
|
|
1204
|
+
var halfChord = element.width / 2;
|
|
1205
|
+
var maxSagitta = 0;
|
|
1206
|
+
for (var lineIndex = 0; lineIndex < lineCount; lineIndex++) {
|
|
1207
|
+
var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, element.curvePower);
|
|
1208
|
+
var sagitta = halfChord >= lineRadius ? lineRadius : lineRadius - Math.sqrt(lineRadius * lineRadius - halfChord * halfChord);
|
|
1209
|
+
if (sagitta > maxSagitta) maxSagitta = sagitta;
|
|
1210
|
+
}
|
|
1211
|
+
var declaredHeight = lineCount * lineHeightPx;
|
|
1212
|
+
var xPad = maxSagitta / 2;
|
|
1213
|
+
return {
|
|
1214
|
+
x: -xPad,
|
|
1215
|
+
y: -maxSagitta,
|
|
1216
|
+
width: element.width + xPad * 2,
|
|
1217
|
+
height: declaredHeight + maxSagitta * 2
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1023
1220
|
var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
1024
1221
|
var _element$backgroundOp;
|
|
1025
1222
|
var element = _ref.element;
|
|
@@ -1028,19 +1225,30 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1028
1225
|
onTransformEnd = _ref.onTransformEnd,
|
|
1029
1226
|
onDragEnd = _ref.onDragEnd,
|
|
1030
1227
|
groupChild = _ref.groupChild;
|
|
1031
|
-
var groupRef =
|
|
1032
|
-
var textRef =
|
|
1033
|
-
var _useState =
|
|
1228
|
+
var groupRef = React.useRef(null);
|
|
1229
|
+
var textRef = React.useRef(null);
|
|
1230
|
+
var _useState = React.useState(element.height || 50),
|
|
1034
1231
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1035
1232
|
textHeight = _useState2[0],
|
|
1036
1233
|
setTextHeight = _useState2[1];
|
|
1234
|
+
var isCurved = element.curveEnabled && element.curvePower !== 0;
|
|
1037
1235
|
|
|
1038
1236
|
// Force Konva to recalculate text layout when fonts finish loading.
|
|
1039
|
-
|
|
1237
|
+
React.useEffect(function () {
|
|
1040
1238
|
var onFontLoaded = function onFontLoaded() {
|
|
1041
|
-
var _node$
|
|
1239
|
+
var _node$getLayer2;
|
|
1042
1240
|
var node = textRef.current;
|
|
1043
1241
|
if (!node) return;
|
|
1242
|
+
|
|
1243
|
+
// CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
|
|
1244
|
+
// every draw (no internal cached layout like Konva.Text has), so
|
|
1245
|
+
// there's no stale-layout workaround needed — just repaint.
|
|
1246
|
+
if (element.curveEnabled && element.curvePower !== 0) {
|
|
1247
|
+
var _node$getLayer;
|
|
1248
|
+
if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
|
|
1249
|
+
(_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1044
1252
|
var f = node.fontFamily();
|
|
1045
1253
|
node.fontFamily('serif');
|
|
1046
1254
|
node.fontFamily(f);
|
|
@@ -1055,7 +1263,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1055
1263
|
if (element.blurEnabled && node) {
|
|
1056
1264
|
node.cache();
|
|
1057
1265
|
}
|
|
1058
|
-
(_node$
|
|
1266
|
+
(_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
|
|
1059
1267
|
};
|
|
1060
1268
|
document.fonts.addEventListener('loadingdone', onFontLoaded);
|
|
1061
1269
|
return function () {
|
|
@@ -1064,7 +1272,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1064
1272
|
}, []);
|
|
1065
1273
|
|
|
1066
1274
|
// Sync Konva auto-sized height back to element model after text reflows
|
|
1067
|
-
|
|
1275
|
+
// (straight text only — curved text's height is computed synchronously
|
|
1276
|
+
// below, since it doesn't width-wrap and doesn't need a measured node).
|
|
1277
|
+
React.useEffect(function () {
|
|
1278
|
+
if (element.curveEnabled && element.curvePower !== 0) return;
|
|
1068
1279
|
var node = textRef.current;
|
|
1069
1280
|
if (!node) return;
|
|
1070
1281
|
var frame = requestAnimationFrame(function () {
|
|
@@ -1079,23 +1290,40 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1079
1290
|
return function () {
|
|
1080
1291
|
return cancelAnimationFrame(frame);
|
|
1081
1292
|
};
|
|
1082
|
-
}, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width]);
|
|
1293
|
+
}, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width, element.curveEnabled, element.curvePower]);
|
|
1294
|
+
|
|
1295
|
+
// Curved text: height is deterministic from line count (no width-based
|
|
1296
|
+
// wrapping), so sync it directly without waiting on Konva measurement.
|
|
1297
|
+
React.useEffect(function () {
|
|
1298
|
+
if (!(element.curveEnabled && element.curvePower !== 0)) return;
|
|
1299
|
+
var lineCount = (element.text || element.placeholder || '').split('\n').length;
|
|
1300
|
+
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
1301
|
+
var h = lineCount * element.fontSize * lineHeightMultiplier;
|
|
1302
|
+
setTextHeight(h);
|
|
1303
|
+
if (Math.abs(h - element.height) > 1) element.set({
|
|
1304
|
+
height: h
|
|
1305
|
+
});
|
|
1306
|
+
}, [element.text, element.placeholder, element.fontSize, element.lineHeight, element.curveEnabled, element.curvePower]);
|
|
1083
1307
|
|
|
1084
1308
|
// Apply blur filter: cache the text node when blur is enabled
|
|
1085
|
-
|
|
1086
|
-
var _node$
|
|
1309
|
+
React.useEffect(function () {
|
|
1310
|
+
var _node$getLayer3;
|
|
1087
1311
|
var node = textRef.current;
|
|
1088
1312
|
if (!node) return;
|
|
1089
1313
|
if (element.blurEnabled) {
|
|
1090
1314
|
node.filters([Konva.Filters.Blur]);
|
|
1091
1315
|
node.blurRadius(element.blurRadius);
|
|
1092
|
-
|
|
1316
|
+
if (isCurved) {
|
|
1317
|
+
node.cache(computeCurvedCacheBounds(element));
|
|
1318
|
+
} else {
|
|
1319
|
+
node.cache();
|
|
1320
|
+
}
|
|
1093
1321
|
} else {
|
|
1094
1322
|
node.filters([]);
|
|
1095
1323
|
node.clearCache();
|
|
1096
1324
|
}
|
|
1097
|
-
(_node$
|
|
1098
|
-
}, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width]);
|
|
1325
|
+
(_node$getLayer3 = node.getLayer()) === null || _node$getLayer3 === void 0 || _node$getLayer3.batchDraw();
|
|
1326
|
+
}, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width, isCurved, element.curvePower, element.lineHeight]);
|
|
1099
1327
|
if (!element.visible) return null;
|
|
1100
1328
|
var handleDragEnd = function handleDragEnd(e) {
|
|
1101
1329
|
element.set({
|
|
@@ -1120,7 +1348,9 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1120
1348
|
var tNode = textRef.current;
|
|
1121
1349
|
if (tNode) {
|
|
1122
1350
|
tNode.width(newWidth);
|
|
1123
|
-
tNode.fontSize
|
|
1351
|
+
if (typeof tNode.fontSize === 'function') {
|
|
1352
|
+
tNode.fontSize(newFontSize);
|
|
1353
|
+
}
|
|
1124
1354
|
}
|
|
1125
1355
|
node.scaleX(1);
|
|
1126
1356
|
node.scaleY(1);
|
|
@@ -1234,14 +1464,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1234
1464
|
return c.toUpperCase();
|
|
1235
1465
|
});
|
|
1236
1466
|
}
|
|
1237
|
-
var fontStyleStr =
|
|
1238
|
-
var parts = [];
|
|
1239
|
-
var style = String(element.fontStyle || '').trim();
|
|
1240
|
-
var weight = String(element.fontWeight || '').trim();
|
|
1241
|
-
if (style === 'italic' || style.includes('italic')) parts.push('italic');
|
|
1242
|
-
if (weight && weight !== 'normal') parts.push(weight);
|
|
1243
|
-
return parts.length > 0 ? parts.join(' ') : 'normal';
|
|
1244
|
-
}();
|
|
1467
|
+
var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
|
|
1245
1468
|
var pad = element.backgroundEnabled ? element.backgroundPadding || 0 : 0;
|
|
1246
1469
|
return /*#__PURE__*/jsxRuntime.jsxs(reactKonva.Group, {
|
|
1247
1470
|
ref: groupRef,
|
|
@@ -1275,7 +1498,12 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1275
1498
|
opacity: (_element$backgroundOp = element.backgroundOpacity) !== null && _element$backgroundOp !== void 0 ? _element$backgroundOp : 1,
|
|
1276
1499
|
cornerRadius: element.backgroundCornerRadius || 0,
|
|
1277
1500
|
listening: false
|
|
1278
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
1501
|
+
}), isCurved ? /*#__PURE__*/jsxRuntime.jsx(CurvedText, {
|
|
1502
|
+
ref: textRef,
|
|
1503
|
+
element: element,
|
|
1504
|
+
displayText: displayText,
|
|
1505
|
+
width: element.width
|
|
1506
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(reactKonva.Text, {
|
|
1279
1507
|
ref: textRef,
|
|
1280
1508
|
text: displayText,
|
|
1281
1509
|
width: element.width,
|
|
@@ -1310,12 +1538,12 @@ var SVGElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1310
1538
|
onTransformEnd = _ref.onTransformEnd,
|
|
1311
1539
|
onDragEnd = _ref.onDragEnd,
|
|
1312
1540
|
groupChild = _ref.groupChild;
|
|
1313
|
-
var imageRef =
|
|
1314
|
-
var _useState =
|
|
1541
|
+
var imageRef = React.useRef(null);
|
|
1542
|
+
var _useState = React.useState(null),
|
|
1315
1543
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1316
1544
|
image = _useState2[0],
|
|
1317
1545
|
setImage = _useState2[1];
|
|
1318
|
-
|
|
1546
|
+
React.useEffect(function () {
|
|
1319
1547
|
if (!element.src) {
|
|
1320
1548
|
setImage(null);
|
|
1321
1549
|
return;
|
|
@@ -1419,7 +1647,7 @@ var FigureElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1419
1647
|
onTransformEnd = _ref.onTransformEnd,
|
|
1420
1648
|
onDragEnd = _ref.onDragEnd,
|
|
1421
1649
|
groupChild = _ref.groupChild;
|
|
1422
|
-
var shapeRef =
|
|
1650
|
+
var shapeRef = React.useRef(null);
|
|
1423
1651
|
if (!element.visible) return null;
|
|
1424
1652
|
var handleDragEnd = function handleDragEnd(e) {
|
|
1425
1653
|
element.set({
|
|
@@ -1686,8 +1914,8 @@ var LineElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1686
1914
|
shadowOpacity: element.shadowOpacity,
|
|
1687
1915
|
onDragEnd: handleLineDragEnd
|
|
1688
1916
|
});
|
|
1689
|
-
return /*#__PURE__*/jsxRuntime.jsxs(
|
|
1690
|
-
children: [lineNode, isSelected && /*#__PURE__*/jsxRuntime.jsxs(
|
|
1917
|
+
return /*#__PURE__*/jsxRuntime.jsxs(React.Fragment, {
|
|
1918
|
+
children: [lineNode, isSelected && /*#__PURE__*/jsxRuntime.jsxs(React.Fragment, {
|
|
1691
1919
|
children: [/*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
1692
1920
|
x: startX - HANDLE_SIZE / 2,
|
|
1693
1921
|
y: startY - HANDLE_SIZE / 2,
|
|
@@ -1722,8 +1950,8 @@ var GroupElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1722
1950
|
var onTransformEnd = _ref.onTransformEnd,
|
|
1723
1951
|
onDragEnd = _ref.onDragEnd,
|
|
1724
1952
|
_ElementRenderer = _ref._ElementRenderer;
|
|
1725
|
-
var groupRef =
|
|
1726
|
-
var handleDragEnd =
|
|
1953
|
+
var groupRef = React.useRef(null);
|
|
1954
|
+
var handleDragEnd = React.useCallback(function (e) {
|
|
1727
1955
|
var node = e.target;
|
|
1728
1956
|
element.set({
|
|
1729
1957
|
x: node.x(),
|
|
@@ -1731,7 +1959,7 @@ var GroupElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1731
1959
|
});
|
|
1732
1960
|
if (onDragEnd) onDragEnd(e);
|
|
1733
1961
|
}, [element, onDragEnd]);
|
|
1734
|
-
var handleTransformEnd =
|
|
1962
|
+
var handleTransformEnd = React.useCallback(function (e) {
|
|
1735
1963
|
var node = groupRef.current;
|
|
1736
1964
|
if (!node) return;
|
|
1737
1965
|
var scaleX = node.scaleX();
|
|
@@ -1861,29 +2089,39 @@ function parseDateFromFormat(dateStr, format) {
|
|
|
1861
2089
|
return new Date();
|
|
1862
2090
|
}
|
|
1863
2091
|
|
|
2092
|
+
// Shared sizing for the popup's action row (Back / Continue / Do it later),
|
|
2093
|
+
// exported so a custom `PopupActions` component can visually match them.
|
|
2094
|
+
var popupActionButtonSx = {
|
|
2095
|
+
textTransform: 'none',
|
|
2096
|
+
fontSize: 21,
|
|
2097
|
+
py: 1.65,
|
|
2098
|
+
borderRadius: '10px'
|
|
2099
|
+
};
|
|
2100
|
+
|
|
1864
2101
|
// ── Default single-field dialog (full-page overlay) ──────────────────
|
|
1865
2102
|
var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
1866
2103
|
var field = _ref.field,
|
|
2104
|
+
store = _ref.store,
|
|
1867
2105
|
onSubmit = _ref.onSubmit,
|
|
1868
2106
|
onSkip = _ref.onSkip,
|
|
1869
2107
|
onBack = _ref.onBack,
|
|
1870
2108
|
canGoBack = _ref.canGoBack,
|
|
1871
2109
|
currentIndex = _ref.currentIndex,
|
|
1872
2110
|
totalCount = _ref.totalCount;
|
|
1873
|
-
var _useState =
|
|
2111
|
+
var _useState = React.useState(''),
|
|
1874
2112
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1875
2113
|
value = _useState2[0],
|
|
1876
2114
|
setValue = _useState2[1];
|
|
1877
|
-
var _useState3 =
|
|
2115
|
+
var _useState3 = React.useState(null),
|
|
1878
2116
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
1879
2117
|
imagePreview = _useState4[0],
|
|
1880
2118
|
setImagePreview = _useState4[1];
|
|
1881
|
-
var fileInputRef =
|
|
1882
|
-
var _useState5 =
|
|
2119
|
+
var fileInputRef = React.useRef(null);
|
|
2120
|
+
var _useState5 = React.useState([]),
|
|
1883
2121
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1884
2122
|
selectedItems = _useState6[0],
|
|
1885
2123
|
setSelectedItems = _useState6[1];
|
|
1886
|
-
var _useState7 =
|
|
2124
|
+
var _useState7 = React.useState(''),
|
|
1887
2125
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
1888
2126
|
customRadioValue = _useState8[0],
|
|
1889
2127
|
setCustomRadioValue = _useState8[1];
|
|
@@ -1901,7 +2139,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1901
2139
|
var headerText = config.headerText || null;
|
|
1902
2140
|
var accentColor = config.accentColor || '#0d83cd';
|
|
1903
2141
|
var progressPct = Math.round((currentIndex + 1) / totalCount * 100);
|
|
1904
|
-
|
|
2142
|
+
React.useEffect(function () {
|
|
1905
2143
|
setValue('');
|
|
1906
2144
|
setImagePreview(null);
|
|
1907
2145
|
setSelectedItems([]);
|
|
@@ -2424,36 +2662,30 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
2424
2662
|
mt: 4.5,
|
|
2425
2663
|
flexShrink: 0
|
|
2426
2664
|
},
|
|
2427
|
-
children: [
|
|
2665
|
+
children: [config.PopupActions && /*#__PURE__*/jsxRuntime.jsx(config.PopupActions, {
|
|
2666
|
+
store: store
|
|
2667
|
+
}), canGoBack && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
2428
2668
|
variant: "outlined",
|
|
2429
2669
|
onClick: onBack,
|
|
2430
2670
|
startIcon: /*#__PURE__*/jsxRuntime.jsx(ArrowBackIcon, {}),
|
|
2431
|
-
sx: {
|
|
2432
|
-
textTransform: 'none',
|
|
2671
|
+
sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
|
|
2433
2672
|
fontWeight: 500,
|
|
2434
|
-
fontSize: 21,
|
|
2435
2673
|
px: 3,
|
|
2436
|
-
py: 1.65,
|
|
2437
|
-
borderRadius: '10px',
|
|
2438
2674
|
color: '#555',
|
|
2439
2675
|
borderColor: '#d0d5dd',
|
|
2440
2676
|
'&:hover': {
|
|
2441
2677
|
borderColor: '#aaa',
|
|
2442
2678
|
backgroundColor: 'rgba(0,0,0,0.02)'
|
|
2443
2679
|
}
|
|
2444
|
-
},
|
|
2680
|
+
}),
|
|
2445
2681
|
children: t('inputFieldsDialog.back', 'Back')
|
|
2446
2682
|
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
2447
2683
|
variant: "contained",
|
|
2448
2684
|
onClick: handleSubmit,
|
|
2449
2685
|
disabled: isSubmitDisabled,
|
|
2450
|
-
sx: _objectSpread2({
|
|
2451
|
-
textTransform: 'none',
|
|
2686
|
+
sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
|
|
2452
2687
|
fontWeight: 600,
|
|
2453
|
-
fontSize: 21,
|
|
2454
2688
|
px: 5,
|
|
2455
|
-
py: 1.65,
|
|
2456
|
-
borderRadius: '10px',
|
|
2457
2689
|
backgroundColor: accentColor,
|
|
2458
2690
|
boxShadow: 'none',
|
|
2459
2691
|
'&:hover': {
|
|
@@ -2467,13 +2699,9 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
2467
2699
|
onClick: function onClick() {
|
|
2468
2700
|
return onSkip(field.id);
|
|
2469
2701
|
},
|
|
2470
|
-
sx: _objectSpread2({
|
|
2471
|
-
textTransform: 'none',
|
|
2702
|
+
sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
|
|
2472
2703
|
fontWeight: 500,
|
|
2473
|
-
fontSize: 21,
|
|
2474
2704
|
px: 4.5,
|
|
2475
|
-
py: 1.65,
|
|
2476
|
-
borderRadius: '10px',
|
|
2477
2705
|
color: '#555',
|
|
2478
2706
|
borderColor: '#d0d5dd',
|
|
2479
2707
|
'&:hover': {
|
|
@@ -2499,20 +2727,20 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2499
2727
|
backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
|
|
2500
2728
|
// displayIndex counts how many fields have been answered (for step indicator only).
|
|
2501
2729
|
// Navigation always uses fields[0] — the first remaining pending field.
|
|
2502
|
-
var _useState9 =
|
|
2730
|
+
var _useState9 = React.useState(0),
|
|
2503
2731
|
_useState0 = _slicedToArray(_useState9, 2),
|
|
2504
2732
|
displayIndex = _useState0[0],
|
|
2505
2733
|
setDisplayIndex = _useState0[1];
|
|
2506
|
-
var initialTotalRef =
|
|
2507
|
-
var completedHistoryRef =
|
|
2508
|
-
var removedDueToSkipRef =
|
|
2509
|
-
var isGoingBackRef =
|
|
2510
|
-
var prevBackTriggerRef =
|
|
2734
|
+
var initialTotalRef = React.useRef(0);
|
|
2735
|
+
var completedHistoryRef = React.useRef([]);
|
|
2736
|
+
var removedDueToSkipRef = React.useRef([]);
|
|
2737
|
+
var isGoingBackRef = React.useRef(false);
|
|
2738
|
+
var prevBackTriggerRef = React.useRef(backTrigger);
|
|
2511
2739
|
var config = getInputFieldsConfig();
|
|
2512
2740
|
var pendingFields = store._pendingInputFields || [];
|
|
2513
2741
|
|
|
2514
2742
|
// When disabled, clear any pending fields so they are treated as skipped
|
|
2515
|
-
|
|
2743
|
+
React.useEffect(function () {
|
|
2516
2744
|
if (!enabled && pendingFields.length > 0) {
|
|
2517
2745
|
store.clearPendingInputFields();
|
|
2518
2746
|
}
|
|
@@ -2522,7 +2750,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2522
2750
|
});
|
|
2523
2751
|
|
|
2524
2752
|
// Capture total and reset display counter when a fresh batch appears
|
|
2525
|
-
|
|
2753
|
+
React.useEffect(function () {
|
|
2526
2754
|
if (fields.length > 0 && initialTotalRef.current === 0) {
|
|
2527
2755
|
if (isGoingBackRef.current) {
|
|
2528
2756
|
// Back-from-summary restored a field — recover total from history + pending
|
|
@@ -2571,7 +2799,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2571
2799
|
}
|
|
2572
2800
|
// displayIndex stays unchanged — it already points to the last step (N-1)
|
|
2573
2801
|
};
|
|
2574
|
-
|
|
2802
|
+
React.useEffect(function () {
|
|
2575
2803
|
if (backTrigger !== prevBackTriggerRef.current) {
|
|
2576
2804
|
prevBackTriggerRef.current = backTrigger;
|
|
2577
2805
|
handleBackFromSummary();
|
|
@@ -2716,6 +2944,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2716
2944
|
}
|
|
2717
2945
|
return /*#__PURE__*/jsxRuntime.jsx(SingleFieldDialog, {
|
|
2718
2946
|
field: currentField,
|
|
2947
|
+
store: store,
|
|
2719
2948
|
onSubmit: handleSubmit,
|
|
2720
2949
|
onSkip: handleSkip,
|
|
2721
2950
|
onBack: handleBack,
|
|
@@ -2752,12 +2981,12 @@ var getCheckerboardImage = function getCheckerboardImage() {
|
|
|
2752
2981
|
var CheckerboardBackground = function CheckerboardBackground(_ref) {
|
|
2753
2982
|
var w = _ref.w,
|
|
2754
2983
|
h = _ref.h;
|
|
2755
|
-
var _useState =
|
|
2984
|
+
var _useState = React.useState(false),
|
|
2756
2985
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2757
2986
|
ready = _useState2[0],
|
|
2758
2987
|
setReady = _useState2[1];
|
|
2759
|
-
var imgRef =
|
|
2760
|
-
|
|
2988
|
+
var imgRef = React.useRef(getCheckerboardImage());
|
|
2989
|
+
React.useEffect(function () {
|
|
2761
2990
|
var img = imgRef.current;
|
|
2762
2991
|
if (img.complete) {
|
|
2763
2992
|
setReady(true);
|
|
@@ -2794,11 +3023,11 @@ var ImageBackground = function ImageBackground(_ref2) {
|
|
|
2794
3023
|
var url = _ref2.url,
|
|
2795
3024
|
w = _ref2.w,
|
|
2796
3025
|
h = _ref2.h;
|
|
2797
|
-
var _useState3 =
|
|
3026
|
+
var _useState3 = React.useState(null),
|
|
2798
3027
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
2799
3028
|
image = _useState4[0],
|
|
2800
3029
|
setImage = _useState4[1];
|
|
2801
|
-
|
|
3030
|
+
React.useEffect(function () {
|
|
2802
3031
|
if (!url) {
|
|
2803
3032
|
setImage(null);
|
|
2804
3033
|
return;
|
|
@@ -2990,7 +3219,7 @@ var CORNER_ANCHORS = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
|
|
|
2990
3219
|
var SelectionTransformer = mobxReactLite.observer(function (_ref5) {
|
|
2991
3220
|
var store = _ref5.store,
|
|
2992
3221
|
stageRef = _ref5.stageRef;
|
|
2993
|
-
var transformerRef =
|
|
3222
|
+
var transformerRef = React.useRef(null);
|
|
2994
3223
|
var selectedIds = _toConsumableArray(store.selectedElementsIds);
|
|
2995
3224
|
|
|
2996
3225
|
// Filter out line elements (custom endpoint handles) and elements mid-crop
|
|
@@ -3008,7 +3237,7 @@ var SelectionTransformer = mobxReactLite.observer(function (_ref5) {
|
|
|
3008
3237
|
return el && el.type === 'group';
|
|
3009
3238
|
}();
|
|
3010
3239
|
var targetAnchors = useCorners ? CORNER_ANCHORS : allText ? TEXT_ANCHORS : ALL_ANCHORS;
|
|
3011
|
-
|
|
3240
|
+
React.useEffect(function () {
|
|
3012
3241
|
var frame = requestAnimationFrame(function () {
|
|
3013
3242
|
var _transformerRef$curre;
|
|
3014
3243
|
if (!transformerRef.current || !stageRef.current) return;
|
|
@@ -3054,9 +3283,9 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
3054
3283
|
onInputFieldsComplete = _ref6.onInputFieldsComplete,
|
|
3055
3284
|
_ref6$backTrigger = _ref6.backTrigger,
|
|
3056
3285
|
backTrigger = _ref6$backTrigger === void 0 ? 0 : _ref6$backTrigger;
|
|
3057
|
-
var stageRef =
|
|
3058
|
-
var containerRef =
|
|
3059
|
-
var _useState5 =
|
|
3286
|
+
var stageRef = React.useRef(null);
|
|
3287
|
+
var containerRef = React.useRef(null);
|
|
3288
|
+
var _useState5 = React.useState({
|
|
3060
3289
|
width: 800,
|
|
3061
3290
|
height: 600
|
|
3062
3291
|
}),
|
|
@@ -3066,7 +3295,7 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
3066
3295
|
var PageControls = components.PageControls;
|
|
3067
3296
|
|
|
3068
3297
|
// Resize observer
|
|
3069
|
-
|
|
3298
|
+
React.useEffect(function () {
|
|
3070
3299
|
var container = containerRef.current;
|
|
3071
3300
|
if (!container) return;
|
|
3072
3301
|
var updateSize = function updateSize() {
|
|
@@ -3105,12 +3334,12 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
3105
3334
|
}, [store.width, store.height]);
|
|
3106
3335
|
|
|
3107
3336
|
// Set stage ref on store for export
|
|
3108
|
-
|
|
3337
|
+
React.useEffect(function () {
|
|
3109
3338
|
if (stageRef.current) {
|
|
3110
3339
|
store._setStageRef(stageRef.current);
|
|
3111
3340
|
}
|
|
3112
3341
|
}, [stageRef.current]);
|
|
3113
|
-
var handleStageMouseDown =
|
|
3342
|
+
var handleStageMouseDown = React.useCallback(function (e) {
|
|
3114
3343
|
var _store$_toolbarPanel, _target$attrs, _e$evt, _e$evt2;
|
|
3115
3344
|
// Clicking anywhere outside the crop rect / pannable image / resize
|
|
3116
3345
|
// handles while cropping finishes the crop (like Polotno), then falls
|
|
@@ -3166,17 +3395,17 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
3166
3395
|
store.selectElements([targetId]);
|
|
3167
3396
|
}
|
|
3168
3397
|
}, [store]);
|
|
3169
|
-
var handleTransformEnd =
|
|
3398
|
+
var handleTransformEnd = React.useCallback(function () {
|
|
3170
3399
|
// Save to history after transform
|
|
3171
3400
|
store.history.addUndoState();
|
|
3172
3401
|
}, [store]);
|
|
3173
|
-
var handleDragEnd =
|
|
3402
|
+
var handleDragEnd = React.useCallback(function () {
|
|
3174
3403
|
// Save to history after drag
|
|
3175
3404
|
store.history.addUndoState();
|
|
3176
3405
|
}, [store]);
|
|
3177
3406
|
|
|
3178
3407
|
// Keyboard shortcuts
|
|
3179
|
-
|
|
3408
|
+
React.useEffect(function () {
|
|
3180
3409
|
var handleKeyDown = function handleKeyDown(e) {
|
|
3181
3410
|
var _store$_toolbarPanel2;
|
|
3182
3411
|
// Only handle if stage container or body is focused
|
|
@@ -3297,7 +3526,7 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
3297
3526
|
}, [store]);
|
|
3298
3527
|
|
|
3299
3528
|
// Zoom with mouse wheel
|
|
3300
|
-
var handleWheel =
|
|
3529
|
+
var handleWheel = React.useCallback(function (e) {
|
|
3301
3530
|
e.evt.preventDefault();
|
|
3302
3531
|
var stage = stageRef.current;
|
|
3303
3532
|
if (!stage) return;
|