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