labellife-design-tool 2.4.1 → 2.4.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/dist/cjs/canvas/workspace.js +328 -95
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +381 -68
- 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 +272 -39
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +382 -70
- 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
package/dist/cjs/index.js
CHANGED
|
@@ -60,6 +60,7 @@ require('@mui/icons-material/AlignVerticalCenter');
|
|
|
60
60
|
require('@mui/icons-material/AlignVerticalBottom');
|
|
61
61
|
var VerticalAlignTopIcon = require('@mui/icons-material/VerticalAlignTop');
|
|
62
62
|
var VerticalAlignBottomIcon = require('@mui/icons-material/VerticalAlignBottom');
|
|
63
|
+
var GestureIcon = require('@mui/icons-material/Gesture');
|
|
63
64
|
var ZoomInIcon = require('@mui/icons-material/ZoomIn');
|
|
64
65
|
var ZoomOutIcon = require('@mui/icons-material/ZoomOut');
|
|
65
66
|
var FitScreenIcon = require('@mui/icons-material/FitScreen');
|
|
@@ -9836,10 +9837,85 @@ var PositionButton = mobxReactLite.observer(function (_ref8) {
|
|
|
9836
9837
|
});
|
|
9837
9838
|
});
|
|
9838
9839
|
|
|
9840
|
+
// Curve (text-only) slider popover — same button/popover pattern as
|
|
9841
|
+
// PositionButton, holding the same control previously in the Text
|
|
9842
|
+
// Effects panel's Curve section. No separate enable toggle: curvePower
|
|
9843
|
+
// itself is the on/off state (0 = straight, matching how the renderer
|
|
9844
|
+
// already treats curvePower === 0 as "no curve").
|
|
9845
|
+
var CurveButton = mobxReactLite.observer(function (_ref0) {
|
|
9846
|
+
var element = _ref0.element;
|
|
9847
|
+
var _useState5 = React.useState(null),
|
|
9848
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
9849
|
+
anchorEl = _useState6[0],
|
|
9850
|
+
setAnchorEl = _useState6[1];
|
|
9851
|
+
var open = Boolean(anchorEl);
|
|
9852
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
9853
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
9854
|
+
size: "small",
|
|
9855
|
+
onClick: function onClick(e) {
|
|
9856
|
+
return setAnchorEl(e.currentTarget);
|
|
9857
|
+
},
|
|
9858
|
+
startIcon: /*#__PURE__*/jsxRuntime.jsx(GestureIcon, {
|
|
9859
|
+
sx: {
|
|
9860
|
+
fontSize: '16px !important'
|
|
9861
|
+
}
|
|
9862
|
+
}),
|
|
9863
|
+
sx: _objectSpread2({
|
|
9864
|
+
textTransform: 'none',
|
|
9865
|
+
fontSize: 12,
|
|
9866
|
+
whiteSpace: 'nowrap',
|
|
9867
|
+
px: 1.5,
|
|
9868
|
+
minWidth: 'auto'
|
|
9869
|
+
}, open ? {
|
|
9870
|
+
backgroundColor: '#e3f2fd',
|
|
9871
|
+
color: '#0d83cd'
|
|
9872
|
+
} : {}),
|
|
9873
|
+
children: t('toolbar.curve', 'Curve')
|
|
9874
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Popover, {
|
|
9875
|
+
open: open,
|
|
9876
|
+
anchorEl: anchorEl,
|
|
9877
|
+
onClose: function onClose() {
|
|
9878
|
+
return setAnchorEl(null);
|
|
9879
|
+
},
|
|
9880
|
+
anchorOrigin: {
|
|
9881
|
+
vertical: 'bottom',
|
|
9882
|
+
horizontal: 'left'
|
|
9883
|
+
},
|
|
9884
|
+
transformOrigin: {
|
|
9885
|
+
vertical: 'top',
|
|
9886
|
+
horizontal: 'left'
|
|
9887
|
+
},
|
|
9888
|
+
slotProps: {
|
|
9889
|
+
paper: {
|
|
9890
|
+
sx: {
|
|
9891
|
+
mt: 0.5,
|
|
9892
|
+
p: 2,
|
|
9893
|
+
width: 260,
|
|
9894
|
+
borderRadius: '10px',
|
|
9895
|
+
boxShadow: '0 4px 20px rgba(0,0,0,0.12)'
|
|
9896
|
+
}
|
|
9897
|
+
}
|
|
9898
|
+
},
|
|
9899
|
+
children: /*#__PURE__*/jsxRuntime.jsx(SliderRow, {
|
|
9900
|
+
label: t('toolbar.curve', 'Curve'),
|
|
9901
|
+
value: element.curvePower,
|
|
9902
|
+
onChange: function onChange(v) {
|
|
9903
|
+
return element.set({
|
|
9904
|
+
curveEnabled: true,
|
|
9905
|
+
curvePower: v
|
|
9906
|
+
});
|
|
9907
|
+
},
|
|
9908
|
+
min: -500,
|
|
9909
|
+
max: 500
|
|
9910
|
+
})
|
|
9911
|
+
})]
|
|
9912
|
+
});
|
|
9913
|
+
});
|
|
9914
|
+
|
|
9839
9915
|
// Common controls for all element types
|
|
9840
|
-
var CommonControls = mobxReactLite.observer(function (
|
|
9841
|
-
var element =
|
|
9842
|
-
store =
|
|
9916
|
+
var CommonControls = mobxReactLite.observer(function (_ref1) {
|
|
9917
|
+
var element = _ref1.element,
|
|
9918
|
+
store = _ref1.store;
|
|
9843
9919
|
var isLocked = element.locked;
|
|
9844
9920
|
var handleDuplicate = function handleDuplicate() {
|
|
9845
9921
|
if (element.clone) {
|
|
@@ -9917,6 +9993,9 @@ var CommonControls = mobxReactLite.observer(function (_ref0) {
|
|
|
9917
9993
|
}), /*#__PURE__*/jsxRuntime.jsx(PositionButton, {
|
|
9918
9994
|
element: element,
|
|
9919
9995
|
store: store
|
|
9996
|
+
}), element.type === 'text' && /*#__PURE__*/jsxRuntime.jsx(CurveButton, {
|
|
9997
|
+
element: element,
|
|
9998
|
+
store: store
|
|
9920
9999
|
}), /*#__PURE__*/jsxRuntime.jsx(material.Divider, {
|
|
9921
10000
|
orientation: "vertical",
|
|
9922
10001
|
flexItem: true,
|
|
@@ -9960,26 +10039,26 @@ var CommonControls = mobxReactLite.observer(function (_ref0) {
|
|
|
9960
10039
|
});
|
|
9961
10040
|
|
|
9962
10041
|
// Download button with format/quality popover
|
|
9963
|
-
var DefaultDownloadButton = mobxReactLite.observer(function (
|
|
9964
|
-
var store =
|
|
9965
|
-
var
|
|
9966
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
9967
|
-
anchorEl = _useState6[0],
|
|
9968
|
-
setAnchorEl = _useState6[1];
|
|
9969
|
-
var _useState7 = React.useState('png'),
|
|
10042
|
+
var DefaultDownloadButton = mobxReactLite.observer(function (_ref10) {
|
|
10043
|
+
var store = _ref10.store;
|
|
10044
|
+
var _useState7 = React.useState(null),
|
|
9970
10045
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
9971
|
-
|
|
9972
|
-
|
|
10046
|
+
anchorEl = _useState8[0],
|
|
10047
|
+
setAnchorEl = _useState8[1];
|
|
10048
|
+
var _useState9 = React.useState('png'),
|
|
10049
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
10050
|
+
fileType = _useState0[0],
|
|
10051
|
+
setFileType = _useState0[1];
|
|
9973
10052
|
// Default quality so pixelRatio=1 (output = template's own pixel size).
|
|
9974
10053
|
// qualityToPixelRatio(q) = q * 3, so q = 1/3 → pixelRatio = 1.
|
|
9975
|
-
var
|
|
9976
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
9977
|
-
quality = _useState0[0],
|
|
9978
|
-
setQuality = _useState0[1];
|
|
9979
|
-
var _useState1 = React.useState(false),
|
|
10054
|
+
var _useState1 = React.useState(1 / 3),
|
|
9980
10055
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
9981
|
-
|
|
9982
|
-
|
|
10056
|
+
quality = _useState10[0],
|
|
10057
|
+
setQuality = _useState10[1];
|
|
10058
|
+
var _useState11 = React.useState(false),
|
|
10059
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
10060
|
+
exporting = _useState12[0],
|
|
10061
|
+
setExporting = _useState12[1];
|
|
9983
10062
|
var open = Boolean(anchorEl);
|
|
9984
10063
|
var handleClick = function handleClick(e) {
|
|
9985
10064
|
setAnchorEl(e.currentTarget);
|
|
@@ -10212,15 +10291,15 @@ var DefaultDownloadButton = mobxReactLite.observer(function (_ref1) {
|
|
|
10212
10291
|
});
|
|
10213
10292
|
|
|
10214
10293
|
// Import button — loads a JSON template file into the store
|
|
10215
|
-
var DefaultImportButton = mobxReactLite.observer(function (
|
|
10216
|
-
var store =
|
|
10217
|
-
var
|
|
10218
|
-
|
|
10219
|
-
importing =
|
|
10220
|
-
setImporting =
|
|
10294
|
+
var DefaultImportButton = mobxReactLite.observer(function (_ref12) {
|
|
10295
|
+
var store = _ref12.store;
|
|
10296
|
+
var _useState13 = React.useState(false),
|
|
10297
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
10298
|
+
importing = _useState14[0],
|
|
10299
|
+
setImporting = _useState14[1];
|
|
10221
10300
|
var fileInputRef = React.useRef(null);
|
|
10222
10301
|
var handleFileChange = React.useCallback(/*#__PURE__*/function () {
|
|
10223
|
-
var
|
|
10302
|
+
var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
|
|
10224
10303
|
var _e$target$files;
|
|
10225
10304
|
var file, text, jsonData, _t3;
|
|
10226
10305
|
return _regenerator().w(function (_context2) {
|
|
@@ -10258,7 +10337,7 @@ var DefaultImportButton = mobxReactLite.observer(function (_ref11) {
|
|
|
10258
10337
|
}, _callee2, null, [[2, 4, 5, 6]]);
|
|
10259
10338
|
}));
|
|
10260
10339
|
return function (_x) {
|
|
10261
|
-
return
|
|
10340
|
+
return _ref13.apply(this, arguments);
|
|
10262
10341
|
};
|
|
10263
10342
|
}(), [store]);
|
|
10264
10343
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -10324,10 +10403,10 @@ var rowSx = {
|
|
|
10324
10403
|
display: 'none'
|
|
10325
10404
|
}
|
|
10326
10405
|
};
|
|
10327
|
-
var Toolbar = mobxReactLite.observer(function (
|
|
10328
|
-
var store =
|
|
10329
|
-
|
|
10330
|
-
components =
|
|
10406
|
+
var Toolbar = mobxReactLite.observer(function (_ref14) {
|
|
10407
|
+
var store = _ref14.store,
|
|
10408
|
+
_ref14$components = _ref14.components,
|
|
10409
|
+
components = _ref14$components === void 0 ? {} : _ref14$components;
|
|
10331
10410
|
var ActionControls = components.ActionControls;
|
|
10332
10411
|
var ImportButton = 'ImportButton' in components ? components.ImportButton : DefaultImportButton;
|
|
10333
10412
|
var DownloadButton = 'DownloadButton' in components ? components.DownloadButton : DefaultDownloadButton;
|
|
@@ -11047,6 +11126,203 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11047
11126
|
});
|
|
11048
11127
|
ImageElementComponent.displayName = 'ImageElement';
|
|
11049
11128
|
|
|
11129
|
+
// Composes a canvas/Konva font-style string (e.g. "italic bold") from the
|
|
11130
|
+
// element model's separate fontStyle/fontWeight fields. Shared by
|
|
11131
|
+
// text-element.js (KonvaText) and curved-text.js (custom Shape), which
|
|
11132
|
+
// both need to build a canvas `ctx.font` / Konva fontStyle string the same
|
|
11133
|
+
// way.
|
|
11134
|
+
function composeFontStyle(fontStyle, fontWeight) {
|
|
11135
|
+
var parts = [];
|
|
11136
|
+
var style = String(fontStyle || '').trim();
|
|
11137
|
+
var weight = String(fontWeight || '').trim();
|
|
11138
|
+
if (style === 'italic' || style.includes('italic')) parts.push('italic');
|
|
11139
|
+
if (weight && weight !== 'normal') parts.push(weight);
|
|
11140
|
+
return parts.length > 0 ? parts.join(' ') : 'normal';
|
|
11141
|
+
}
|
|
11142
|
+
|
|
11143
|
+
// src/canvas/curved-text-geometry.js
|
|
11144
|
+
//
|
|
11145
|
+
// Pure, framework-free geometry math for the curved-text effect.
|
|
11146
|
+
// Deliberately authored as CommonJS (not ESM like the rest of src/canvas)
|
|
11147
|
+
// so this one file can be unit-tested with plain `node`, no jest/babel
|
|
11148
|
+
// required — this repo has no test framework installed. Rollup's
|
|
11149
|
+
// commonjs() plugin (already in rollup.config.mjs) interops this into the
|
|
11150
|
+
// ESM build correctly when curved-text.js imports it with `import`.
|
|
11151
|
+
|
|
11152
|
+
// At curvePower = 100 (max), the radius is this many multiples of
|
|
11153
|
+
// fontSize. Tuned empirically: 3x let realistic multi-word labels wrap
|
|
11154
|
+
// into a nearly-closed loop well before the slider reached 100 (e.g. a
|
|
11155
|
+
// ~500px-wide line swept ~341° — individual glyphs rotate past horizontal
|
|
11156
|
+
// once a line wraps past ~180°, which read as "letters rotating wrong").
|
|
11157
|
+
// 6x keeps the same line under ~170° at max curvePower, a clearly-open arc.
|
|
11158
|
+
// Adjust this constant (and re-run curved-text-geometry.test.js, which
|
|
11159
|
+
// exercises it) if the on-screen result needs to be tighter/looser.
|
|
11160
|
+
var MAX_RADIUS_FONT_MULTIPLIER = 6;
|
|
11161
|
+
|
|
11162
|
+
// Maps curvePower (-100..100) to a positive radius magnitude in px.
|
|
11163
|
+
// Direction (smile vs frown) is NOT encoded here — callers apply
|
|
11164
|
+
// Math.sign(curvePower) separately (see curved-text.js). curvePower = 0
|
|
11165
|
+
// returns Infinity (a "straight line" radius) for defensiveness, though
|
|
11166
|
+
// callers should treat curvePower === 0 as "don't curve at all" before
|
|
11167
|
+
// reaching here (falls back to plain KonvaText).
|
|
11168
|
+
function computeArcRadius(curvePower, fontSize) {
|
|
11169
|
+
var power = Math.abs(curvePower);
|
|
11170
|
+
if (power === 0) return Infinity;
|
|
11171
|
+
return fontSize * MAX_RADIUS_FONT_MULTIPLIER / (power / 100);
|
|
11172
|
+
}
|
|
11173
|
+
|
|
11174
|
+
// Computes the radius for line `lineIndex` (0-based, top to bottom) of a
|
|
11175
|
+
// multi-line curved text block, so all lines share one arc center
|
|
11176
|
+
// (concentric) and stack in normal reading order.
|
|
11177
|
+
//
|
|
11178
|
+
// For curvePower > 0 ("smile", center below the text), later lines move
|
|
11179
|
+
// closer to the center (smaller radius). For curvePower < 0 ("frown",
|
|
11180
|
+
// center above the text), later lines move away from the center (larger
|
|
11181
|
+
// radius).
|
|
11182
|
+
function computeLineRadius(baseRadius, lineIndex, lineHeight, curvePower) {
|
|
11183
|
+
var direction = curvePower > 0 ? -1 : 1;
|
|
11184
|
+
return baseRadius + lineIndex * lineHeight * direction;
|
|
11185
|
+
}
|
|
11186
|
+
|
|
11187
|
+
// Distributes characters of one line along an arc of the given radius,
|
|
11188
|
+
// centered so the line's midpoint sits at angle 0 — i.e. center-aligned.
|
|
11189
|
+
//
|
|
11190
|
+
// charWidths: array of per-glyph advance widths (px), in reading order.
|
|
11191
|
+
// radius: positive, finite radius magnitude (px) for this line.
|
|
11192
|
+
//
|
|
11193
|
+
// Returns an array, one entry per character, each: { angle } — the angle
|
|
11194
|
+
// (radians) from the arc's center-line, in reading order. Callers convert
|
|
11195
|
+
// `angle` + `radius` into an (x, y) position and a tangent rotation for
|
|
11196
|
+
// drawing (see curved-text.js).
|
|
11197
|
+
function layoutCharsOnArc(charWidths, radius) {
|
|
11198
|
+
if (!Number.isFinite(radius) || radius <= 0) {
|
|
11199
|
+
throw new Error('layoutCharsOnArc requires a finite, positive radius');
|
|
11200
|
+
}
|
|
11201
|
+
var totalWidth = charWidths.reduce(function (sum, w) {
|
|
11202
|
+
return sum + w;
|
|
11203
|
+
}, 0);
|
|
11204
|
+
var totalAngle = totalWidth / radius;
|
|
11205
|
+
var cumBefore = 0;
|
|
11206
|
+
return charWidths.map(function (w) {
|
|
11207
|
+
var cumMid = cumBefore + w / 2;
|
|
11208
|
+
cumBefore += w;
|
|
11209
|
+
var angleFromStart = cumMid / radius;
|
|
11210
|
+
return {
|
|
11211
|
+
angle: angleFromStart - totalAngle / 2
|
|
11212
|
+
};
|
|
11213
|
+
});
|
|
11214
|
+
}
|
|
11215
|
+
var curvedTextGeometry = {
|
|
11216
|
+
computeArcRadius: computeArcRadius,
|
|
11217
|
+
computeLineRadius: computeLineRadius,
|
|
11218
|
+
layoutCharsOnArc: layoutCharsOnArc
|
|
11219
|
+
};
|
|
11220
|
+
|
|
11221
|
+
var CurvedText = mobxReactLite.observer(/*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
11222
|
+
var element = _ref.element,
|
|
11223
|
+
displayText = _ref.displayText,
|
|
11224
|
+
width = _ref.width;
|
|
11225
|
+
var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
|
|
11226
|
+
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
11227
|
+
var lineHeightPx = element.fontSize * lineHeightMultiplier;
|
|
11228
|
+
var letterSpacing = element.letterSpacing || 0;
|
|
11229
|
+
var curvePower = element.curvePower;
|
|
11230
|
+
|
|
11231
|
+
// Precondition: caller must not mount this component with curvePower === 0.
|
|
11232
|
+
// Defensive guard to avoid passing Infinity to layoutCharsOnArc.
|
|
11233
|
+
if (curvePower === 0) return null;
|
|
11234
|
+
var direction = curvePower > 0 ? 1 : -1;
|
|
11235
|
+
var baseRadius = curvedTextGeometry.computeArcRadius(curvePower, element.fontSize);
|
|
11236
|
+
var lines = (displayText || '').split('\n');
|
|
11237
|
+
|
|
11238
|
+
// Shared per-character geometry: walks every line/character and invokes
|
|
11239
|
+
// `draw(ctx, ch, x, y, angle)` inside the same save/translate/rotate/
|
|
11240
|
+
// restore frame. Used by both sceneFunc (real glyph fill/stroke) and
|
|
11241
|
+
// hitFunc (hit-region rects) so the clickable area always matches what's
|
|
11242
|
+
// actually painted — duplicating this math between the two would risk
|
|
11243
|
+
// them drifting apart.
|
|
11244
|
+
var forEachChar = function forEachChar(ctx, draw) {
|
|
11245
|
+
var centerX = width / 2;
|
|
11246
|
+
lines.forEach(function (lineText, lineIndex) {
|
|
11247
|
+
var chars = Array.from(lineText);
|
|
11248
|
+
if (chars.length === 0) return;
|
|
11249
|
+
var charWidths = chars.map(function (ch) {
|
|
11250
|
+
return ctx.measureText(ch).width + letterSpacing;
|
|
11251
|
+
});
|
|
11252
|
+
var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, curvePower);
|
|
11253
|
+
var signedRadius = direction * lineRadius;
|
|
11254
|
+
var baselineY = lineIndex * lineHeightPx + element.fontSize;
|
|
11255
|
+
var centerY = baselineY + signedRadius;
|
|
11256
|
+
var layout = curvedTextGeometry.layoutCharsOnArc(charWidths, lineRadius);
|
|
11257
|
+
chars.forEach(function (ch, idx) {
|
|
11258
|
+
var angle = layout[idx].angle;
|
|
11259
|
+
var x = centerX + lineRadius * Math.sin(angle);
|
|
11260
|
+
var y = centerY - signedRadius * Math.cos(angle);
|
|
11261
|
+
draw(ctx, ch, x, y, angle, charWidths[idx]);
|
|
11262
|
+
});
|
|
11263
|
+
});
|
|
11264
|
+
};
|
|
11265
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactKonva.Shape, {
|
|
11266
|
+
ref: ref,
|
|
11267
|
+
width: width,
|
|
11268
|
+
height: lines.length * lineHeightPx,
|
|
11269
|
+
sceneFunc: function sceneFunc(ctx) {
|
|
11270
|
+
ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
|
|
11271
|
+
ctx.textAlign = 'center';
|
|
11272
|
+
ctx.textBaseline = 'alphabetic';
|
|
11273
|
+
forEachChar(ctx, function (c, ch, x, y, angle) {
|
|
11274
|
+
c.save();
|
|
11275
|
+
c.translate(x, y);
|
|
11276
|
+
c.rotate(direction * angle);
|
|
11277
|
+
if (element.strokeWidth > 0) {
|
|
11278
|
+
c.strokeStyle = element.stroke || '#000000';
|
|
11279
|
+
c.lineWidth = element.strokeWidth;
|
|
11280
|
+
c.strokeText(ch, 0, 0);
|
|
11281
|
+
}
|
|
11282
|
+
c.fillStyle = element.fill;
|
|
11283
|
+
c.fillText(ch, 0, 0);
|
|
11284
|
+
c.restore();
|
|
11285
|
+
});
|
|
11286
|
+
},
|
|
11287
|
+
hitFunc: function hitFunc(ctx, shape) {
|
|
11288
|
+
ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
|
|
11289
|
+
ctx.textAlign = 'center';
|
|
11290
|
+
ctx.textBaseline = 'alphabetic';
|
|
11291
|
+
ctx.beginPath();
|
|
11292
|
+
forEachChar(ctx, function (c, ch, x, y, angle, charWidth) {
|
|
11293
|
+
c.save();
|
|
11294
|
+
c.translate(x, y);
|
|
11295
|
+
c.rotate(direction * angle);
|
|
11296
|
+
c.rect(-charWidth / 2, -element.fontSize * 0.8, charWidth, element.fontSize * 1.1);
|
|
11297
|
+
c.restore();
|
|
11298
|
+
});
|
|
11299
|
+
ctx.fillStrokeShape(shape);
|
|
11300
|
+
}
|
|
11301
|
+
});
|
|
11302
|
+
}));
|
|
11303
|
+
CurvedText.displayName = 'CurvedText';
|
|
11304
|
+
|
|
11305
|
+
function computeCurvedCacheBounds(element) {
|
|
11306
|
+
var lineCount = (element.text || element.placeholder || '').split('\n').length;
|
|
11307
|
+
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
11308
|
+
var lineHeightPx = element.fontSize * lineHeightMultiplier;
|
|
11309
|
+
var baseRadius = curvedTextGeometry.computeArcRadius(element.curvePower, element.fontSize);
|
|
11310
|
+
var halfChord = element.width / 2;
|
|
11311
|
+
var maxSagitta = 0;
|
|
11312
|
+
for (var lineIndex = 0; lineIndex < lineCount; lineIndex++) {
|
|
11313
|
+
var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, element.curvePower);
|
|
11314
|
+
var sagitta = halfChord >= lineRadius ? lineRadius : lineRadius - Math.sqrt(lineRadius * lineRadius - halfChord * halfChord);
|
|
11315
|
+
if (sagitta > maxSagitta) maxSagitta = sagitta;
|
|
11316
|
+
}
|
|
11317
|
+
var declaredHeight = lineCount * lineHeightPx;
|
|
11318
|
+
var xPad = maxSagitta / 2;
|
|
11319
|
+
return {
|
|
11320
|
+
x: -xPad,
|
|
11321
|
+
y: -maxSagitta,
|
|
11322
|
+
width: element.width + xPad * 2,
|
|
11323
|
+
height: declaredHeight + maxSagitta * 2
|
|
11324
|
+
};
|
|
11325
|
+
}
|
|
11050
11326
|
var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
11051
11327
|
var _element$backgroundOp;
|
|
11052
11328
|
var element = _ref.element;
|
|
@@ -11061,13 +11337,24 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11061
11337
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11062
11338
|
textHeight = _useState2[0],
|
|
11063
11339
|
setTextHeight = _useState2[1];
|
|
11340
|
+
var isCurved = element.curveEnabled && element.curvePower !== 0;
|
|
11064
11341
|
|
|
11065
11342
|
// Force Konva to recalculate text layout when fonts finish loading.
|
|
11066
11343
|
React.useEffect(function () {
|
|
11067
11344
|
var onFontLoaded = function onFontLoaded() {
|
|
11068
|
-
var _node$
|
|
11345
|
+
var _node$getLayer2;
|
|
11069
11346
|
var node = textRef.current;
|
|
11070
11347
|
if (!node) return;
|
|
11348
|
+
|
|
11349
|
+
// CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
|
|
11350
|
+
// every draw (no internal cached layout like Konva.Text has), so
|
|
11351
|
+
// there's no stale-layout workaround needed — just repaint.
|
|
11352
|
+
if (element.curveEnabled && element.curvePower !== 0) {
|
|
11353
|
+
var _node$getLayer;
|
|
11354
|
+
if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
|
|
11355
|
+
(_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
|
|
11356
|
+
return;
|
|
11357
|
+
}
|
|
11071
11358
|
var f = node.fontFamily();
|
|
11072
11359
|
node.fontFamily('serif');
|
|
11073
11360
|
node.fontFamily(f);
|
|
@@ -11082,7 +11369,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11082
11369
|
if (element.blurEnabled && node) {
|
|
11083
11370
|
node.cache();
|
|
11084
11371
|
}
|
|
11085
|
-
(_node$
|
|
11372
|
+
(_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
|
|
11086
11373
|
};
|
|
11087
11374
|
document.fonts.addEventListener('loadingdone', onFontLoaded);
|
|
11088
11375
|
return function () {
|
|
@@ -11091,7 +11378,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11091
11378
|
}, []);
|
|
11092
11379
|
|
|
11093
11380
|
// Sync Konva auto-sized height back to element model after text reflows
|
|
11381
|
+
// (straight text only — curved text's height is computed synchronously
|
|
11382
|
+
// below, since it doesn't width-wrap and doesn't need a measured node).
|
|
11094
11383
|
React.useEffect(function () {
|
|
11384
|
+
if (element.curveEnabled && element.curvePower !== 0) return;
|
|
11095
11385
|
var node = textRef.current;
|
|
11096
11386
|
if (!node) return;
|
|
11097
11387
|
var frame = requestAnimationFrame(function () {
|
|
@@ -11106,23 +11396,40 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11106
11396
|
return function () {
|
|
11107
11397
|
return cancelAnimationFrame(frame);
|
|
11108
11398
|
};
|
|
11109
|
-
}, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width]);
|
|
11399
|
+
}, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width, element.curveEnabled, element.curvePower]);
|
|
11400
|
+
|
|
11401
|
+
// Curved text: height is deterministic from line count (no width-based
|
|
11402
|
+
// wrapping), so sync it directly without waiting on Konva measurement.
|
|
11403
|
+
React.useEffect(function () {
|
|
11404
|
+
if (!(element.curveEnabled && element.curvePower !== 0)) return;
|
|
11405
|
+
var lineCount = (element.text || element.placeholder || '').split('\n').length;
|
|
11406
|
+
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
11407
|
+
var h = lineCount * element.fontSize * lineHeightMultiplier;
|
|
11408
|
+
setTextHeight(h);
|
|
11409
|
+
if (Math.abs(h - element.height) > 1) element.set({
|
|
11410
|
+
height: h
|
|
11411
|
+
});
|
|
11412
|
+
}, [element.text, element.placeholder, element.fontSize, element.lineHeight, element.curveEnabled, element.curvePower]);
|
|
11110
11413
|
|
|
11111
11414
|
// Apply blur filter: cache the text node when blur is enabled
|
|
11112
11415
|
React.useEffect(function () {
|
|
11113
|
-
var _node$
|
|
11416
|
+
var _node$getLayer3;
|
|
11114
11417
|
var node = textRef.current;
|
|
11115
11418
|
if (!node) return;
|
|
11116
11419
|
if (element.blurEnabled) {
|
|
11117
11420
|
node.filters([Konva.Filters.Blur]);
|
|
11118
11421
|
node.blurRadius(element.blurRadius);
|
|
11119
|
-
|
|
11422
|
+
if (isCurved) {
|
|
11423
|
+
node.cache(computeCurvedCacheBounds(element));
|
|
11424
|
+
} else {
|
|
11425
|
+
node.cache();
|
|
11426
|
+
}
|
|
11120
11427
|
} else {
|
|
11121
11428
|
node.filters([]);
|
|
11122
11429
|
node.clearCache();
|
|
11123
11430
|
}
|
|
11124
|
-
(_node$
|
|
11125
|
-
}, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width]);
|
|
11431
|
+
(_node$getLayer3 = node.getLayer()) === null || _node$getLayer3 === void 0 || _node$getLayer3.batchDraw();
|
|
11432
|
+
}, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width, isCurved, element.curvePower, element.lineHeight]);
|
|
11126
11433
|
if (!element.visible) return null;
|
|
11127
11434
|
var handleDragEnd = function handleDragEnd(e) {
|
|
11128
11435
|
element.set({
|
|
@@ -11147,7 +11454,9 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11147
11454
|
var tNode = textRef.current;
|
|
11148
11455
|
if (tNode) {
|
|
11149
11456
|
tNode.width(newWidth);
|
|
11150
|
-
tNode.fontSize
|
|
11457
|
+
if (typeof tNode.fontSize === 'function') {
|
|
11458
|
+
tNode.fontSize(newFontSize);
|
|
11459
|
+
}
|
|
11151
11460
|
}
|
|
11152
11461
|
node.scaleX(1);
|
|
11153
11462
|
node.scaleY(1);
|
|
@@ -11182,8 +11491,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11182
11491
|
var cssFontWeight = String(element.fontWeight || 'normal');
|
|
11183
11492
|
var originalText = element.text;
|
|
11184
11493
|
var textarea = document.createElement('textarea');
|
|
11185
|
-
textarea.value =
|
|
11186
|
-
|
|
11494
|
+
textarea.value = originalText;
|
|
11495
|
+
// Only show the dimmed placeholder hint when there's no real text yet
|
|
11496
|
+
// (e.g. a freshly-added text element) — not when editing existing text.
|
|
11497
|
+
textarea.placeholder = originalText ? '' : element.placeholder;
|
|
11187
11498
|
textarea.style.position = 'absolute';
|
|
11188
11499
|
textarea.style.top = "".concat(textPosition.y, "px");
|
|
11189
11500
|
textarea.style.left = "".concat(textPosition.x, "px");
|
|
@@ -11223,12 +11534,14 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11223
11534
|
stageContainer.appendChild(placeholderStyle);
|
|
11224
11535
|
stageContainer.appendChild(textarea);
|
|
11225
11536
|
textarea.focus();
|
|
11537
|
+
var caretPos = textarea.value.length;
|
|
11538
|
+
textarea.setSelectionRange(caretPos, caretPos);
|
|
11226
11539
|
var removed = false;
|
|
11227
11540
|
var removeTextarea = function removeTextarea() {
|
|
11228
11541
|
var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
11229
11542
|
if (removed) return;
|
|
11230
11543
|
removed = true;
|
|
11231
|
-
var newText =
|
|
11544
|
+
var newText = cancel ? originalText : textarea.value;
|
|
11232
11545
|
element.set({
|
|
11233
11546
|
text: newText
|
|
11234
11547
|
});
|
|
@@ -11261,14 +11574,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11261
11574
|
return c.toUpperCase();
|
|
11262
11575
|
});
|
|
11263
11576
|
}
|
|
11264
|
-
var fontStyleStr =
|
|
11265
|
-
var parts = [];
|
|
11266
|
-
var style = String(element.fontStyle || '').trim();
|
|
11267
|
-
var weight = String(element.fontWeight || '').trim();
|
|
11268
|
-
if (style === 'italic' || style.includes('italic')) parts.push('italic');
|
|
11269
|
-
if (weight && weight !== 'normal') parts.push(weight);
|
|
11270
|
-
return parts.length > 0 ? parts.join(' ') : 'normal';
|
|
11271
|
-
}();
|
|
11577
|
+
var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
|
|
11272
11578
|
var pad = element.backgroundEnabled ? element.backgroundPadding || 0 : 0;
|
|
11273
11579
|
return /*#__PURE__*/jsxRuntime.jsxs(reactKonva.Group, {
|
|
11274
11580
|
ref: groupRef,
|
|
@@ -11302,7 +11608,12 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11302
11608
|
opacity: (_element$backgroundOp = element.backgroundOpacity) !== null && _element$backgroundOp !== void 0 ? _element$backgroundOp : 1,
|
|
11303
11609
|
cornerRadius: element.backgroundCornerRadius || 0,
|
|
11304
11610
|
listening: false
|
|
11305
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
11611
|
+
}), isCurved ? /*#__PURE__*/jsxRuntime.jsx(CurvedText, {
|
|
11612
|
+
ref: textRef,
|
|
11613
|
+
element: element,
|
|
11614
|
+
displayText: displayText,
|
|
11615
|
+
width: element.width
|
|
11616
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(reactKonva.Text, {
|
|
11306
11617
|
ref: textRef,
|
|
11307
11618
|
text: displayText,
|
|
11308
11619
|
width: element.width,
|
|
@@ -11888,9 +12199,19 @@ function parseDateFromFormat(dateStr, format) {
|
|
|
11888
12199
|
return new Date();
|
|
11889
12200
|
}
|
|
11890
12201
|
|
|
12202
|
+
// Shared sizing for the popup's action row (Back / Continue / Do it later),
|
|
12203
|
+
// exported so a custom `PopupActions` component can visually match them.
|
|
12204
|
+
var popupActionButtonSx = {
|
|
12205
|
+
textTransform: 'none',
|
|
12206
|
+
fontSize: 21,
|
|
12207
|
+
py: 1.65,
|
|
12208
|
+
borderRadius: '10px'
|
|
12209
|
+
};
|
|
12210
|
+
|
|
11891
12211
|
// ── Default single-field dialog (full-page overlay) ──────────────────
|
|
11892
12212
|
var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
11893
12213
|
var field = _ref.field,
|
|
12214
|
+
store = _ref.store,
|
|
11894
12215
|
onSubmit = _ref.onSubmit,
|
|
11895
12216
|
onSkip = _ref.onSkip,
|
|
11896
12217
|
onBack = _ref.onBack,
|
|
@@ -12451,36 +12772,30 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
12451
12772
|
mt: 4.5,
|
|
12452
12773
|
flexShrink: 0
|
|
12453
12774
|
},
|
|
12454
|
-
children: [
|
|
12775
|
+
children: [config.PopupActions && /*#__PURE__*/jsxRuntime.jsx(config.PopupActions, {
|
|
12776
|
+
store: store
|
|
12777
|
+
}), canGoBack && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
12455
12778
|
variant: "outlined",
|
|
12456
12779
|
onClick: onBack,
|
|
12457
12780
|
startIcon: /*#__PURE__*/jsxRuntime.jsx(ArrowBackIcon, {}),
|
|
12458
|
-
sx: {
|
|
12459
|
-
textTransform: 'none',
|
|
12781
|
+
sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
|
|
12460
12782
|
fontWeight: 500,
|
|
12461
|
-
fontSize: 21,
|
|
12462
12783
|
px: 3,
|
|
12463
|
-
py: 1.65,
|
|
12464
|
-
borderRadius: '10px',
|
|
12465
12784
|
color: '#555',
|
|
12466
12785
|
borderColor: '#d0d5dd',
|
|
12467
12786
|
'&:hover': {
|
|
12468
12787
|
borderColor: '#aaa',
|
|
12469
12788
|
backgroundColor: 'rgba(0,0,0,0.02)'
|
|
12470
12789
|
}
|
|
12471
|
-
},
|
|
12790
|
+
}),
|
|
12472
12791
|
children: t('inputFieldsDialog.back', 'Back')
|
|
12473
12792
|
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
12474
12793
|
variant: "contained",
|
|
12475
12794
|
onClick: handleSubmit,
|
|
12476
12795
|
disabled: isSubmitDisabled,
|
|
12477
|
-
sx: _objectSpread2({
|
|
12478
|
-
textTransform: 'none',
|
|
12796
|
+
sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
|
|
12479
12797
|
fontWeight: 600,
|
|
12480
|
-
fontSize: 21,
|
|
12481
12798
|
px: 5,
|
|
12482
|
-
py: 1.65,
|
|
12483
|
-
borderRadius: '10px',
|
|
12484
12799
|
backgroundColor: accentColor,
|
|
12485
12800
|
boxShadow: 'none',
|
|
12486
12801
|
'&:hover': {
|
|
@@ -12494,13 +12809,9 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
12494
12809
|
onClick: function onClick() {
|
|
12495
12810
|
return onSkip(field.id);
|
|
12496
12811
|
},
|
|
12497
|
-
sx: _objectSpread2({
|
|
12498
|
-
textTransform: 'none',
|
|
12812
|
+
sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
|
|
12499
12813
|
fontWeight: 500,
|
|
12500
|
-
fontSize: 21,
|
|
12501
12814
|
px: 4.5,
|
|
12502
|
-
py: 1.65,
|
|
12503
|
-
borderRadius: '10px',
|
|
12504
12815
|
color: '#555',
|
|
12505
12816
|
borderColor: '#d0d5dd',
|
|
12506
12817
|
'&:hover': {
|
|
@@ -12743,6 +13054,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
12743
13054
|
}
|
|
12744
13055
|
return /*#__PURE__*/jsxRuntime.jsx(SingleFieldDialog, {
|
|
12745
13056
|
field: currentField,
|
|
13057
|
+
store: store,
|
|
12746
13058
|
onSubmit: handleSubmit,
|
|
12747
13059
|
onSkip: handleSkip,
|
|
12748
13060
|
onBack: handleBack,
|
|
@@ -13518,6 +13830,7 @@ exports.getTheme = getTheme;
|
|
|
13518
13830
|
exports.getTranslations = getTranslations;
|
|
13519
13831
|
exports.loadGoogleFont = loadGoogleFont;
|
|
13520
13832
|
exports.loadImage = loadImage;
|
|
13833
|
+
exports.popupActionButtonSx = popupActionButtonSx;
|
|
13521
13834
|
exports.pxToUnit = pxToUnit;
|
|
13522
13835
|
exports.setInputFieldsConfig = setInputFieldsConfig;
|
|
13523
13836
|
exports.setTheme = setTheme;
|