labellife-design-tool 2.4.4 → 2.4.6
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 +63 -14
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +179 -154
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js +5 -0
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/cjs/side-panel/index.js +67 -131
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js +67 -131
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js +57 -13
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js +63 -14
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +179 -154
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js +5 -0
- package/dist/esm/model/store.js.map +1 -1
- package/dist/esm/side-panel/index.js +67 -131
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js +67 -131
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js +57 -13
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -634,6 +634,25 @@ var Shape = Node.named('Shape').props({
|
|
|
634
634
|
};
|
|
635
635
|
});
|
|
636
636
|
|
|
637
|
+
// Cover-fit SIZE (no cropping) for an image of natural size over a box of given size.
|
|
638
|
+
// The image is scaled to the smallest size that fully covers the box, preserving aspect
|
|
639
|
+
// ratio — one dimension matches the box, the other is larger and overflows the box
|
|
640
|
+
// (centered overflow on both sides).
|
|
641
|
+
function coverFitSize(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
642
|
+
var boxAspect = boxWidth / boxHeight;
|
|
643
|
+
var imgAspect = naturalWidth / naturalHeight;
|
|
644
|
+
if (imgAspect > boxAspect) {
|
|
645
|
+
return {
|
|
646
|
+
width: boxHeight * imgAspect,
|
|
647
|
+
height: boxHeight
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
return {
|
|
651
|
+
width: boxWidth,
|
|
652
|
+
height: boxWidth / imgAspect
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
637
656
|
// Cover-fit crop fractions (centered) for a box of given size over an image of natural size.
|
|
638
657
|
// Mirrors the existing auto-crop calculation in canvas/image-element.js.
|
|
639
658
|
function coverFitCrop(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
@@ -2933,46 +2952,21 @@ var addTextToCanvas = function addTextToCanvas(store, opts) {
|
|
|
2933
2952
|
};
|
|
2934
2953
|
|
|
2935
2954
|
// ── Predefined text templates (json = element data, preview = thumbnail image) ──
|
|
2936
|
-
var TEXT_TEMPLATES = [
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
},
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
},
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
},
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
},
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
}, {
|
|
2952
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-modern-minamalistic-simple.json',
|
|
2953
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-modern-minamalistic-simple.png'
|
|
2954
|
-
}, {
|
|
2955
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-party-invitation.json',
|
|
2956
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-party-invitation.png'
|
|
2957
|
-
}, {
|
|
2958
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-price-package-corporate-list.json',
|
|
2959
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-price-package-corporate-list.png'
|
|
2960
|
-
}, {
|
|
2961
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-contemporary.json',
|
|
2962
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-contemporary.png'
|
|
2963
|
-
}, {
|
|
2964
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-quotation-motivation-inspiring.json',
|
|
2965
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-quotation-motivation-inspiring.png'
|
|
2966
|
-
}, {
|
|
2967
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-romantic-handwrittern-cursive-elegant-celebration.json',
|
|
2968
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-romantic-handwrittern-cursive-elegant-celebration.png'
|
|
2969
|
-
}, {
|
|
2970
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sale-fashion-brand.json',
|
|
2971
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sale-fashion-brand.png'
|
|
2972
|
-
}, {
|
|
2973
|
-
json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sassy-fun-feminine.json',
|
|
2974
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sassy-fun-feminine.png'
|
|
2975
|
-
}, {
|
|
2955
|
+
var TEXT_TEMPLATES = [
|
|
2956
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-adventure-fun-cursive.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-adventure-fun-cursive.png' },
|
|
2957
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-celebration-birthday-cursive-handwritting.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-celebration-birthday-cursive-handwritting.png' },
|
|
2958
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-business-clean-simple-modern.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-business-clean-simple-modern.png' },
|
|
2959
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-hiring-simple-clean-modern.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-hiring-simple-clean-modern.png' },
|
|
2960
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-fashion-sale-brand-clothes.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-fashion-sale-brand-clothes.png' },
|
|
2961
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-modern-minamalistic-simple.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-modern-minamalistic-simple.png' },
|
|
2962
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-party-invitation.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-party-invitation.png' },
|
|
2963
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-price-package-corporate-list.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-price-package-corporate-list.png' },
|
|
2964
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-contemporary.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-contemporary.png' },
|
|
2965
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-quotation-motivation-inspiring.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-quote-quotation-motivation-inspiring.png' },
|
|
2966
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-romantic-handwrittern-cursive-elegant-celebration.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-romantic-handwrittern-cursive-elegant-celebration.png' },
|
|
2967
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sale-fashion-brand.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sale-fashion-brand.png' },
|
|
2968
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sassy-fun-feminine.json', preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-sassy-fun-feminine.png' },
|
|
2969
|
+
{
|
|
2976
2970
|
json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-ancient-old-roman-decorative.json',
|
|
2977
2971
|
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-ancient-old-roman-decorative.png'
|
|
2978
2972
|
}, {
|
|
@@ -2981,67 +2975,42 @@ var TEXT_TEMPLATES = [{
|
|
|
2981
2975
|
}, {
|
|
2982
2976
|
json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-beautiful-decorative-love-elgant-cursive-emotion-famenine.json',
|
|
2983
2977
|
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-beautiful-decorative-love-elgant-cursive-emotion-famenine.png'
|
|
2984
|
-
},
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
}, {
|
|
2978
|
+
},
|
|
2979
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-buy-corporate-urgent-now-marketing.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-buy-corporate-urgent-now-marketing.png' },
|
|
2980
|
+
{
|
|
2988
2981
|
json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-classic-west-cowboy-wildwest-country-classic.json',
|
|
2989
2982
|
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-classic-west-cowboy-wildwest-country-classic.png'
|
|
2990
|
-
},
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
},
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
}, {
|
|
2997
|
-
json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-marry-christmas-celebration.json',
|
|
2998
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-marry-christmas-celebration.png'
|
|
2999
|
-
}, {
|
|
3000
|
-
json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-motivating-motivational-inspiring-inspirational-decorative.json',
|
|
3001
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-motivating-motivational-inspiring-inspirational-decorative.png'
|
|
3002
|
-
}, {
|
|
2983
|
+
},
|
|
2984
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-future-ftureistic-trendy-funky-fun-cool.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-future-ftureistic-trendy-funky-fun-cool.png' },
|
|
2985
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-halloween-celeration-horror-spooky.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-halloween-celeration-horror-spooky.png' },
|
|
2986
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-marry-christmas-celebration.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-marry-christmas-celebration.png' },
|
|
2987
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-motivating-motivational-inspiring-inspirational-decorative.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-motivating-motivational-inspiring-inspirational-decorative.png' },
|
|
2988
|
+
{
|
|
3003
2989
|
json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-motivation-inspiration-cursive-decorative.json',
|
|
3004
2990
|
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-motivation-inspiration-cursive-decorative.png'
|
|
3005
|
-
},
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
},
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
json: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-data-stat-statistics-numeric-figures-reports-charts.json',
|
|
3013
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-data-stat-statistics-numeric-figures-reports-charts.png'
|
|
3014
|
-
}, {
|
|
3015
|
-
json: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-list-colum-modern-point-fact.json',
|
|
3016
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-list-colum-modern-point-fact.png'
|
|
3017
|
-
}, {
|
|
3018
|
-
json: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-recipe-food-list.json',
|
|
3019
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-recipe-food-list.png'
|
|
3020
|
-
}, {
|
|
2991
|
+
},
|
|
2992
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-orange-fruity-fruit-food-fuun-happy.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-orange-fruity-fruit-food-fuun-happy.png' },
|
|
2993
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-romantic-elegant-love.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-romantic-elegant-love.png' },
|
|
2994
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-data-stat-statistics-numeric-figures-reports-charts.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-data-stat-statistics-numeric-figures-reports-charts.png' },
|
|
2995
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-list-colum-modern-point-fact.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-list-colum-modern-point-fact.png' },
|
|
2996
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-recipe-food-list.json', preview: 'https://api.polotno.com/text-templates/2021-06-02-text-plain-recipe-food-list.png' },
|
|
2997
|
+
{
|
|
3021
2998
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-ancient-medieval-old-roman-kind-royal.json',
|
|
3022
2999
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-ancient-medieval-old-roman-kind-royal.png'
|
|
3023
3000
|
}, {
|
|
3024
3001
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-anonymous-mystery-suspense.json',
|
|
3025
3002
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-anonymous-mystery-suspense.png'
|
|
3026
|
-
},
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-colorful-color-fun-beads-game-themed-videogames.json',
|
|
3031
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-colorful-color-fun-beads-game-themed-videogames.png'
|
|
3032
|
-
}, {
|
|
3003
|
+
},
|
|
3004
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-autumn-red-orange-season-cursive-decorative.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-autumn-red-orange-season-cursive-decorative.png' },
|
|
3005
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-colorful-color-fun-beads-game-themed-videogames.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-colorful-color-fun-beads-game-themed-videogames.png' },
|
|
3006
|
+
{
|
|
3033
3007
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-decorative-hollow-effect.json',
|
|
3034
3008
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-decorative-hollow-effect.png'
|
|
3035
|
-
},
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
},
|
|
3039
|
-
|
|
3040
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-fairytale-fanatcy-magic-magical.png'
|
|
3041
|
-
}, {
|
|
3042
|
-
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-happy-easter-festive-holiday.json',
|
|
3043
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-happy-easter-festive-holiday.png'
|
|
3044
|
-
}, {
|
|
3009
|
+
},
|
|
3010
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-decorative-message-line-lineart.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-decorative-message-line-lineart.png' },
|
|
3011
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-fairytale-fanatcy-magic-magical.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-fairytale-fanatcy-magic-magical.png' },
|
|
3012
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-happy-easter-festive-holiday.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-happy-easter-festive-holiday.png' },
|
|
3013
|
+
{
|
|
3045
3014
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-happy-fun-joy-celebration.json',
|
|
3046
3015
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-happy-fun-joy-celebration.png'
|
|
3047
3016
|
}, {
|
|
@@ -3050,64 +3019,48 @@ var TEXT_TEMPLATES = [{
|
|
|
3050
3019
|
}, {
|
|
3051
3020
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-inivitation-rsvp-event-celebration-weeding.json',
|
|
3052
3021
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-inivitation-rsvp-event-celebration-weeding.png'
|
|
3053
|
-
},
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
}, {
|
|
3022
|
+
},
|
|
3023
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-motivation-hope-never-giveup-win-wivtory-cool-funky.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-motivation-hope-never-giveup-win-wivtory-cool-funky.png' },
|
|
3024
|
+
{
|
|
3057
3025
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-murder-horror-scary-temed-holloween-haunted-suspence.json',
|
|
3058
3026
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-murder-horror-scary-temed-holloween-haunted-suspence.png'
|
|
3059
3027
|
}, {
|
|
3060
3028
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-music-simple-straight-jazzy-simple.json',
|
|
3061
3029
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-music-simple-straight-jazzy-simple.png'
|
|
3062
|
-
},
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
},
|
|
3066
|
-
|
|
3067
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-celebration-calander-inviation-event.png'
|
|
3068
|
-
}, {
|
|
3069
|
-
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-invitation-party-invited-cool-.json',
|
|
3070
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-invitation-party-invited-cool-.png'
|
|
3071
|
-
}, {
|
|
3030
|
+
},
|
|
3031
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-numeric-number-figure-chalk-written-writting.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-numeric-number-figure-chalk-written-writting.png' },
|
|
3032
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-celebration-calander-inviation-event.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-celebration-calander-inviation-event.png' },
|
|
3033
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-invitation-party-invited-cool-.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-invitation-party-invited-cool-.png' },
|
|
3034
|
+
{
|
|
3072
3035
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-signature-sign-elegant-royal.json',
|
|
3073
3036
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-signature-sign-elegant-royal.png'
|
|
3074
|
-
},
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-summer-sunny-hot-sea-season.json',
|
|
3079
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-summer-sunny-hot-sea-season.png'
|
|
3080
|
-
}, {
|
|
3037
|
+
},
|
|
3038
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-spring-season-nature-leaf-flower-decorative.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-spring-season-nature-leaf-flower-decorative.png' },
|
|
3039
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-summer-sunny-hot-sea-season.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-summer-sunny-hot-sea-season.png' },
|
|
3040
|
+
{
|
|
3081
3041
|
json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-treandu-cool-funky-hip.json',
|
|
3082
3042
|
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-treandu-cool-funky-hip.png'
|
|
3083
|
-
},
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
},
|
|
3087
|
-
|
|
3088
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-winter-cold-wonderland-decorative-season.png'
|
|
3089
|
-
}, {
|
|
3090
|
-
json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-alert-sale-brand-clearance-shop-now-sjopping-discount.json',
|
|
3091
|
-
preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-alert-sale-brand-clearance-shop-now-sjopping-discount.png'
|
|
3092
|
-
}, {
|
|
3043
|
+
},
|
|
3044
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-what-when-where-column-fun-cool-question.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-what-when-where-column-fun-cool-question.png' },
|
|
3045
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-winter-cold-wonderland-decorative-season.json', preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-winter-cold-wonderland-decorative-season.png' },
|
|
3046
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-alert-sale-brand-clearance-shop-now-sjopping-discount.json', preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-alert-sale-brand-clearance-shop-now-sjopping-discount.png' },
|
|
3047
|
+
{
|
|
3093
3048
|
json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-chalk-drawing-chalkboard-pencil-marker-color-fill-hand-drawn-drawing.json',
|
|
3094
3049
|
preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-chalk-drawing-chalkboard-pencil-marker-color-fill-hand-drawn-drawing.png'
|
|
3095
3050
|
}, {
|
|
3096
3051
|
json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-code-matrix-numbers-numeric-data-sale.json',
|
|
3097
3052
|
preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-code-matrix-numbers-numeric-data-sale.png'
|
|
3098
|
-
},
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
}, {
|
|
3053
|
+
},
|
|
3054
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-fun-cool-cartoon-animated-game.json', preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-fun-cool-cartoon-animated-game.png' },
|
|
3055
|
+
{
|
|
3102
3056
|
json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-funky-cool-hashtag-young-fun.json',
|
|
3103
3057
|
preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-funky-cool-hashtag-young-fun.png'
|
|
3104
3058
|
}, {
|
|
3105
3059
|
json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-instagram-tag-tagging-cool-unique.json',
|
|
3106
3060
|
preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-instagram-tag-tagging-cool-unique.png'
|
|
3107
|
-
},
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
}, {
|
|
3061
|
+
},
|
|
3062
|
+
// { json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-s-sle-black-friday-shopping-buy.json', preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-s-sle-black-friday-shopping-buy.png' },
|
|
3063
|
+
{
|
|
3111
3064
|
json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-speed-fast-run-running-cool-themed-cartoon-lines-waves-move-movement.json',
|
|
3112
3065
|
preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-speed-fast-run-running-cool-themed-cartoon-lines-waves-move-movement.png'
|
|
3113
3066
|
}, {
|
|
@@ -9204,7 +9157,7 @@ var toolbarBtnSx = {
|
|
|
9204
9157
|
|
|
9205
9158
|
// Image-specific toolbar
|
|
9206
9159
|
var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
9207
|
-
var _store$
|
|
9160
|
+
var _store$_toolbarPanel6, _store$_toolbarPanel7;
|
|
9208
9161
|
var element = _ref5.element,
|
|
9209
9162
|
store = _ref5.store;
|
|
9210
9163
|
var _useState = React.useState(null),
|
|
@@ -9226,6 +9179,11 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
9226
9179
|
setFlipAnchor(null);
|
|
9227
9180
|
};
|
|
9228
9181
|
var handleCrop = function handleCrop() {
|
|
9182
|
+
var _store$_toolbarPanel3;
|
|
9183
|
+
if (((_store$_toolbarPanel3 = store._toolbarPanel) === null || _store$_toolbarPanel3 === void 0 ? void 0 : _store$_toolbarPanel3.type) === 'crop') {
|
|
9184
|
+
store.closeToolbarPanel();
|
|
9185
|
+
return;
|
|
9186
|
+
}
|
|
9229
9187
|
if (!element._naturalWidth || !element._naturalHeight) return;
|
|
9230
9188
|
element.enterCropMode();
|
|
9231
9189
|
if (element._cropModeEnabled) {
|
|
@@ -9233,17 +9191,37 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
9233
9191
|
}
|
|
9234
9192
|
};
|
|
9235
9193
|
var handleFitToPage = function handleFitToPage() {
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9194
|
+
// Cover-fit: scale the photo (preserving aspect ratio, never stretched) to the
|
|
9195
|
+
// smallest size that fully covers the page, centered. No crop is applied — if the
|
|
9196
|
+
// aspect ratio doesn't match the page, the image simply overflows the page bounds
|
|
9197
|
+
// on two sides (same as manually resizing it to cover), rather than permanently
|
|
9198
|
+
// cropping away image data.
|
|
9199
|
+
var updates = {
|
|
9200
|
+
cropX: 0,
|
|
9201
|
+
cropY: 0,
|
|
9202
|
+
cropWidth: 1,
|
|
9203
|
+
cropHeight: 1
|
|
9204
|
+
};
|
|
9205
|
+
if (element._naturalWidth && element._naturalHeight) {
|
|
9206
|
+
var _coverFitSize = coverFitSize(store.width, store.height, element._naturalWidth, element._naturalHeight),
|
|
9207
|
+
width = _coverFitSize.width,
|
|
9208
|
+
height = _coverFitSize.height;
|
|
9209
|
+
updates.width = width;
|
|
9210
|
+
updates.height = height;
|
|
9211
|
+
updates.x = (store.width - width) / 2;
|
|
9212
|
+
updates.y = (store.height - height) / 2;
|
|
9213
|
+
} else {
|
|
9214
|
+
updates.x = 0;
|
|
9215
|
+
updates.y = 0;
|
|
9216
|
+
updates.width = store.width;
|
|
9217
|
+
updates.height = store.height;
|
|
9218
|
+
}
|
|
9219
|
+
element.set(updates);
|
|
9242
9220
|
store.history.addUndoState();
|
|
9243
9221
|
};
|
|
9244
9222
|
var handleEffects = function handleEffects() {
|
|
9245
|
-
var _store$
|
|
9246
|
-
if (((_store$
|
|
9223
|
+
var _store$_toolbarPanel4;
|
|
9224
|
+
if (((_store$_toolbarPanel4 = store._toolbarPanel) === null || _store$_toolbarPanel4 === void 0 ? void 0 : _store$_toolbarPanel4.type) === 'effects') {
|
|
9247
9225
|
store.closeToolbarPanel();
|
|
9248
9226
|
} else {
|
|
9249
9227
|
store.openToolbarPanel('effects');
|
|
@@ -9256,8 +9234,8 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
9256
9234
|
});
|
|
9257
9235
|
store.history.addUndoState();
|
|
9258
9236
|
} else {
|
|
9259
|
-
var _store$
|
|
9260
|
-
if (((_store$
|
|
9237
|
+
var _store$_toolbarPanel5;
|
|
9238
|
+
if (((_store$_toolbarPanel5 = store._toolbarPanel) === null || _store$_toolbarPanel5 === void 0 ? void 0 : _store$_toolbarPanel5.type) === 'mask') {
|
|
9261
9239
|
store.closeToolbarPanel();
|
|
9262
9240
|
} else {
|
|
9263
9241
|
store.openToolbarPanel('mask');
|
|
@@ -9335,7 +9313,7 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
9335
9313
|
})]
|
|
9336
9314
|
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
9337
9315
|
size: "small",
|
|
9338
|
-
sx: _objectSpread2(_objectSpread2({}, toolbarBtnSx), ((_store$
|
|
9316
|
+
sx: _objectSpread2(_objectSpread2({}, toolbarBtnSx), ((_store$_toolbarPanel6 = store._toolbarPanel) === null || _store$_toolbarPanel6 === void 0 ? void 0 : _store$_toolbarPanel6.type) === 'effects' ? {
|
|
9339
9317
|
backgroundColor: '#e3f2fd',
|
|
9340
9318
|
color: '#0d83cd'
|
|
9341
9319
|
} : {}),
|
|
@@ -9355,7 +9333,7 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
9355
9333
|
size: "small",
|
|
9356
9334
|
sx: _objectSpread2(_objectSpread2(_objectSpread2({}, toolbarBtnSx), hasMask ? {
|
|
9357
9335
|
color: '#d32f2f'
|
|
9358
|
-
} : {}), ((_store$
|
|
9336
|
+
} : {}), ((_store$_toolbarPanel7 = store._toolbarPanel) === null || _store$_toolbarPanel7 === void 0 ? void 0 : _store$_toolbarPanel7.type) === 'mask' ? {
|
|
9359
9337
|
backgroundColor: '#e3f2fd',
|
|
9360
9338
|
color: '#0d83cd'
|
|
9361
9339
|
} : {}),
|
|
@@ -10811,7 +10789,15 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
10811
10789
|
// Initialized on image load (cover-fit centered), then updated directionally on resize.
|
|
10812
10790
|
var autoCropRef = React.useRef(null);
|
|
10813
10791
|
var autoCropSrcRef = React.useRef(null); // tracks which image the crop was computed for
|
|
10814
|
-
|
|
10792
|
+
// Tracks the element size autoCropRef was last computed/updated for, so we can tell
|
|
10793
|
+
// apart a size change made through the drag/transform handlers (which keep this in
|
|
10794
|
+
// sync themselves via updateAutoCrop) from one made externally (e.g. a toolbar
|
|
10795
|
+
// "Fit to page" action) — the latter needs a fresh cover-fit recompute, not a clamp
|
|
10796
|
+
// of the now-unrelated old crop rect.
|
|
10797
|
+
var autoCropSizeRef = React.useRef({
|
|
10798
|
+
w: null,
|
|
10799
|
+
h: null
|
|
10800
|
+
});
|
|
10815
10801
|
React.useEffect(function () {
|
|
10816
10802
|
if (!element.src) {
|
|
10817
10803
|
setImage(null);
|
|
@@ -10916,6 +10902,10 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
10916
10902
|
w: cw,
|
|
10917
10903
|
h: ch
|
|
10918
10904
|
};
|
|
10905
|
+
autoCropSizeRef.current = {
|
|
10906
|
+
w: newW,
|
|
10907
|
+
h: newH
|
|
10908
|
+
};
|
|
10919
10909
|
};
|
|
10920
10910
|
|
|
10921
10911
|
// Live transform — reset scale, set node dimensions, update crop directionally
|
|
@@ -10974,8 +10964,11 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
10974
10964
|
// Crop calculations
|
|
10975
10965
|
var modelHasCrop = image && (element.cropX !== 0 || element.cropY !== 0 || element.cropWidth !== 1 || element.cropHeight !== 1);
|
|
10976
10966
|
|
|
10977
|
-
// Initialize auto-crop when image changes
|
|
10978
|
-
|
|
10967
|
+
// Initialize/refresh auto-crop when the image changes, or when width/height changed
|
|
10968
|
+
// externally — i.e. NOT through the drag/transform handlers, which call
|
|
10969
|
+
// updateAutoCrop themselves and keep autoCropSizeRef in sync as they go.
|
|
10970
|
+
var sizeChangedExternally = autoCropSizeRef.current.w !== null && (Math.abs(element.width - autoCropSizeRef.current.w) > 0.5 || Math.abs(element.height - autoCropSizeRef.current.h) > 0.5);
|
|
10971
|
+
if (image && (image !== autoCropSrcRef.current || !modelHasCrop && sizeChangedExternally)) {
|
|
10979
10972
|
autoCropSrcRef.current = image;
|
|
10980
10973
|
if (!modelHasCrop) {
|
|
10981
10974
|
var natW = image.naturalWidth || image.width;
|
|
@@ -11006,10 +10999,18 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11006
10999
|
} else {
|
|
11007
11000
|
autoCropRef.current = null;
|
|
11008
11001
|
}
|
|
11002
|
+
autoCropSizeRef.current = {
|
|
11003
|
+
w: element.width,
|
|
11004
|
+
h: element.height
|
|
11005
|
+
};
|
|
11009
11006
|
}
|
|
11010
11007
|
if (!image) {
|
|
11011
11008
|
autoCropSrcRef.current = null;
|
|
11012
11009
|
autoCropRef.current = null;
|
|
11010
|
+
autoCropSizeRef.current = {
|
|
11011
|
+
w: null,
|
|
11012
|
+
h: null
|
|
11013
|
+
};
|
|
11013
11014
|
}
|
|
11014
11015
|
var cropProps = {};
|
|
11015
11016
|
if (modelHasCrop) {
|
|
@@ -11323,6 +11324,18 @@ function computeCurvedCacheBounds(element) {
|
|
|
11323
11324
|
height: declaredHeight + maxSagitta * 2
|
|
11324
11325
|
};
|
|
11325
11326
|
}
|
|
11327
|
+
|
|
11328
|
+
// Sync a newly measured/computed height onto the element while keeping its
|
|
11329
|
+
// vertical center fixed — grows/shrinks equally above and below the original
|
|
11330
|
+
// position, instead of anchoring the top edge and only ever expanding downward.
|
|
11331
|
+
function syncHeightKeepingCenter(element, newHeight) {
|
|
11332
|
+
if (Math.abs(newHeight - element.height) <= 1) return;
|
|
11333
|
+
var deltaY = (newHeight - element.height) / 2;
|
|
11334
|
+
element.set({
|
|
11335
|
+
height: newHeight,
|
|
11336
|
+
y: element.y - deltaY
|
|
11337
|
+
});
|
|
11338
|
+
}
|
|
11326
11339
|
var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
11327
11340
|
var _element$backgroundOp;
|
|
11328
11341
|
var element = _ref.element;
|
|
@@ -11333,6 +11346,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11333
11346
|
groupChild = _ref.groupChild;
|
|
11334
11347
|
var groupRef = React.useRef(null);
|
|
11335
11348
|
var textRef = React.useRef(null);
|
|
11349
|
+
var textareaRef = React.useRef(null);
|
|
11336
11350
|
var _useState = React.useState(element.height || 50),
|
|
11337
11351
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11338
11352
|
textHeight = _useState2[0],
|
|
@@ -11361,9 +11375,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11361
11375
|
var h = node.height();
|
|
11362
11376
|
if (h > 0) {
|
|
11363
11377
|
setTextHeight(h);
|
|
11364
|
-
|
|
11365
|
-
height: h
|
|
11366
|
-
});
|
|
11378
|
+
syncHeightKeepingCenter(element, h);
|
|
11367
11379
|
}
|
|
11368
11380
|
// Re-cache if blur is active
|
|
11369
11381
|
if (element.blurEnabled && node) {
|
|
@@ -11388,9 +11400,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11388
11400
|
var h = node.height();
|
|
11389
11401
|
if (h > 0) {
|
|
11390
11402
|
setTextHeight(h);
|
|
11391
|
-
|
|
11392
|
-
height: h
|
|
11393
|
-
});
|
|
11403
|
+
syncHeightKeepingCenter(element, h);
|
|
11394
11404
|
}
|
|
11395
11405
|
});
|
|
11396
11406
|
return function () {
|
|
@@ -11406,11 +11416,24 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11406
11416
|
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
11407
11417
|
var h = lineCount * element.fontSize * lineHeightMultiplier;
|
|
11408
11418
|
setTextHeight(h);
|
|
11409
|
-
|
|
11410
|
-
height: h
|
|
11411
|
-
});
|
|
11419
|
+
syncHeightKeepingCenter(element, h);
|
|
11412
11420
|
}, [element.text, element.placeholder, element.fontSize, element.lineHeight, element.curveEnabled, element.curvePower]);
|
|
11413
11421
|
|
|
11422
|
+
// While the live-typing textarea overlay is open, keep it aligned with the
|
|
11423
|
+
// Konva text node as syncHeightKeepingCenter adjusts element.y/height during
|
|
11424
|
+
// auto-grow — otherwise the invisible textarea (and its caret) stays at its
|
|
11425
|
+
// original position while the visible Konva text re-centers around it.
|
|
11426
|
+
React.useEffect(function () {
|
|
11427
|
+
if (!element._editModeEnabled) return;
|
|
11428
|
+
var node = textRef.current;
|
|
11429
|
+
var textarea = textareaRef.current;
|
|
11430
|
+
if (!node || !textarea) return;
|
|
11431
|
+
var pos = node.absolutePosition();
|
|
11432
|
+
var scaleY = node.getAbsoluteScale().y;
|
|
11433
|
+
textarea.style.top = "".concat(pos.y, "px");
|
|
11434
|
+
textarea.style.height = "".concat(element.height * scaleY, "px");
|
|
11435
|
+
}, [element._editModeEnabled, element.y, element.height]);
|
|
11436
|
+
|
|
11414
11437
|
// Apply blur filter: cache the text node when blur is enabled
|
|
11415
11438
|
React.useEffect(function () {
|
|
11416
11439
|
var _node$getLayer3;
|
|
@@ -11530,6 +11553,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11530
11553
|
textarea.style.minHeight = '0';
|
|
11531
11554
|
textarea.style.minWidth = '0';
|
|
11532
11555
|
stageContainer.appendChild(textarea);
|
|
11556
|
+
textareaRef.current = textarea;
|
|
11533
11557
|
textarea.focus();
|
|
11534
11558
|
var caretPos = textarea.value.length;
|
|
11535
11559
|
textarea.setSelectionRange(caretPos, caretPos);
|
|
@@ -11547,6 +11571,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11547
11571
|
text: cancel ? originalText : textarea.value
|
|
11548
11572
|
});
|
|
11549
11573
|
element.toggleEditMode(false);
|
|
11574
|
+
if (textareaRef.current === textarea) textareaRef.current = null;
|
|
11550
11575
|
if (textarea.parentNode) {
|
|
11551
11576
|
textarea.parentNode.removeChild(textarea);
|
|
11552
11577
|
}
|