labellife-design-tool 2.4.3 → 2.4.5

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/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
- json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-adventure-fun-cursive.json',
2938
- preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-adventure-fun-cursive.png'
2939
- }, {
2940
- json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-celebration-birthday-cursive-handwritting.json',
2941
- preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-celebration-birthday-cursive-handwritting.png'
2942
- }, {
2943
- json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-business-clean-simple-modern.json',
2944
- preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-business-clean-simple-modern.png'
2945
- }, {
2946
- json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-hiring-simple-clean-modern.json',
2947
- preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-corporate-hiring-simple-clean-modern.png'
2948
- }, {
2949
- json: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-fashion-sale-brand-clothes.json',
2950
- preview: 'https://api.polotno.com/text-templates/2021-06-01-text-plain-fashion-sale-brand-clothes.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-buy-corporate-urgent-now-marketing.json',
2986
- preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-buy-corporate-urgent-now-marketing.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-future-ftureistic-trendy-funky-fun-cool.json',
2992
- preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-future-ftureistic-trendy-funky-fun-cool.png'
2993
- }, {
2994
- json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-halloween-celeration-horror-spooky.json',
2995
- preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-halloween-celeration-horror-spooky.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-orange-fruity-fruit-food-fuun-happy.json',
3007
- preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-orange-fruity-fruit-food-fuun-happy.png'
3008
- }, {
3009
- json: 'https://api.polotno.com/text-templates/2021-06-02-text-color-romantic-elegant-love.json',
3010
- preview: 'https://api.polotno.com/text-templates/2021-06-02-text-color-romantic-elegant-love.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-autumn-red-orange-season-cursive-decorative.json',
3028
- preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-autumn-red-orange-season-cursive-decorative.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-decorative-message-line-lineart.json',
3037
- preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-decorative-message-line-lineart.png'
3038
- }, {
3039
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-fairytale-fanatcy-magic-magical.json',
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
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-motivation-hope-never-giveup-win-wivtory-cool-funky.json',
3055
- preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-motivation-hope-never-giveup-win-wivtory-cool-funky.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-numeric-number-figure-chalk-written-writting.json',
3064
- preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-numeric-number-figure-chalk-written-writting.png'
3065
- }, {
3066
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-save-the-date-celebration-calander-inviation-event.json',
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
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-spring-season-nature-leaf-flower-decorative.json',
3076
- preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-spring-season-nature-leaf-flower-decorative.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-what-when-where-column-fun-cool-question.json',
3085
- preview: 'https://api.polotno.com/text-templates/2021-06-04-text-color-what-when-where-column-fun-cool-question.png'
3086
- }, {
3087
- json: 'https://api.polotno.com/text-templates/2021-06-04-text-color-winter-cold-wonderland-decorative-season.json',
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
- json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-fun-cool-cartoon-animated-game.json',
3100
- preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-fun-cool-cartoon-animated-game.png'
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
- json: 'https://api.polotno.com/text-templates/2021-06-05-text-color-s-sle-black-friday-shopping-buy.json',
3109
- preview: 'https://api.polotno.com/text-templates/2021-06-05-text-color-s-sle-black-friday-shopping-buy.png'
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$_toolbarPanel5, _store$_toolbarPanel6;
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
- element.set({
9237
- x: 0,
9238
- y: 0,
9239
- width: store.width,
9240
- height: store.height
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$_toolbarPanel3;
9246
- if (((_store$_toolbarPanel3 = store._toolbarPanel) === null || _store$_toolbarPanel3 === void 0 ? void 0 : _store$_toolbarPanel3.type) === 'effects') {
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$_toolbarPanel4;
9260
- if (((_store$_toolbarPanel4 = store._toolbarPanel) === null || _store$_toolbarPanel4 === void 0 ? void 0 : _store$_toolbarPanel4.type) === 'mask') {
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$_toolbarPanel5 = store._toolbarPanel) === null || _store$_toolbarPanel5 === void 0 ? void 0 : _store$_toolbarPanel5.type) === 'effects' ? {
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$_toolbarPanel6 = store._toolbarPanel) === null || _store$_toolbarPanel6 === void 0 ? void 0 : _store$_toolbarPanel6.type) === 'mask' ? {
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 (cover-fit, centered)
10978
- if (image && image !== autoCropSrcRef.current) {
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) {
@@ -11475,13 +11476,8 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11475
11476
  element.toggleEditMode(true);
11476
11477
  var textNode = textRef.current;
11477
11478
  if (!textNode) return;
11478
- var grp = groupRef.current;
11479
11479
  var stage = textNode.getStage();
11480
11480
  if (!stage) return;
11481
-
11482
- // Hide the group so the textarea appears as in-place editing
11483
- if (grp) grp.hide();
11484
- stage.batchDraw();
11485
11481
  var stageContainer = stage.container();
11486
11482
  var textPosition = textNode.absolutePosition();
11487
11483
  var absScale = textNode.getAbsoluteScale();
@@ -11490,11 +11486,17 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11490
11486
  var cssFontStyle = element.fontStyle === 'italic' ? 'italic' : 'normal';
11491
11487
  var cssFontWeight = String(element.fontWeight || 'normal');
11492
11488
  var originalText = element.text;
11489
+
11490
+ // The Group stays visible and mirrors the textarea's value live (via the
11491
+ // 'input' listener below), so what's on screen while typing is the real
11492
+ // Konva render — stroke, shadow, background, curve all included — not a
11493
+ // CSS approximation of it (CSS can't reproduce Canvas 2D's stroke/shadow
11494
+ // rendering faithfully; see e.g. -webkit-text-stroke looking bolder and
11495
+ // "welding" adjacent glyphs together vs. Canvas's per-glyph vector stroke).
11496
+ // The textarea itself is fully transparent — it only captures input and
11497
+ // shows a caret positioned over the real text.
11493
11498
  var textarea = document.createElement('textarea');
11494
11499
  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;
11498
11500
  textarea.style.position = 'absolute';
11499
11501
  textarea.style.top = "".concat(textPosition.y, "px");
11500
11502
  textarea.style.left = "".concat(textPosition.x, "px");
@@ -11505,7 +11507,8 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11505
11507
  textarea.style.fontStyle = cssFontStyle;
11506
11508
  textarea.style.fontWeight = cssFontWeight;
11507
11509
  textarea.style.textAlign = element.align;
11508
- textarea.style.color = element.fill;
11510
+ textarea.style.color = 'transparent';
11511
+ textarea.style.caretColor = element.stroke || element.fill || '#000000';
11509
11512
  textarea.style.border = '0';
11510
11513
  textarea.style.borderWidth = '0';
11511
11514
  textarea.style.padding = '0';
@@ -11527,33 +11530,27 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11527
11530
  textarea.style.wordBreak = 'break-word';
11528
11531
  textarea.style.minHeight = '0';
11529
11532
  textarea.style.minWidth = '0';
11530
-
11531
- // Placeholder inherits the element's text color at 40% opacity
11532
- var placeholderStyle = document.createElement('style');
11533
- placeholderStyle.textContent = "\n textarea:placeholder-shown { opacity: 1; }\n textarea::placeholder { color: ".concat(element.fill, "; opacity: 0.4; }\n ");
11534
- stageContainer.appendChild(placeholderStyle);
11535
11533
  stageContainer.appendChild(textarea);
11536
11534
  textarea.focus();
11537
11535
  var caretPos = textarea.value.length;
11538
11536
  textarea.setSelectionRange(caretPos, caretPos);
11537
+ textarea.addEventListener('input', function () {
11538
+ element.set({
11539
+ text: textarea.value
11540
+ });
11541
+ });
11539
11542
  var removed = false;
11540
11543
  var removeTextarea = function removeTextarea() {
11541
11544
  var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11542
11545
  if (removed) return;
11543
11546
  removed = true;
11544
- var newText = cancel ? originalText : textarea.value;
11545
11547
  element.set({
11546
- text: newText
11548
+ text: cancel ? originalText : textarea.value
11547
11549
  });
11548
11550
  element.toggleEditMode(false);
11549
- if (grp) grp.show();
11550
- stage.batchDraw();
11551
11551
  if (textarea.parentNode) {
11552
11552
  textarea.parentNode.removeChild(textarea);
11553
11553
  }
11554
- if (placeholderStyle.parentNode) {
11555
- placeholderStyle.parentNode.removeChild(placeholderStyle);
11556
- }
11557
11554
  };
11558
11555
  textarea.addEventListener('blur', function () {
11559
11556
  return removeTextarea(false);