@twick/canvas 0.15.24 → 0.15.26

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/index.js CHANGED
@@ -26,8 +26,6 @@ const DEFAULT_CAPTION_PROPS = {
26
26
  fill: "#FFFFFF",
27
27
  /** Font weight */
28
28
  fontWeight: 600,
29
- /** Text stroke color */
30
- stroke: "#000000",
31
29
  /** Stroke line width */
32
30
  lineWidth: 0.2,
33
31
  /** Shadow color */
@@ -767,7 +765,7 @@ const addTextElement = ({
767
765
  splitByGrapheme: false,
768
766
  textAlign: ((_q = element.props) == null ? void 0 : _q.textAlign) || "center",
769
767
  stroke: ((_r = element.props) == null ? void 0 : _r.stroke) || DEFAULT_TEXT_PROPS.stroke,
770
- strokeWidth: ((_s = element.props) == null ? void 0 : _s.lineWidth) || DEFAULT_TEXT_PROPS.lineWidth,
768
+ strokeWidth: (((_s = element.props) == null ? void 0 : _s.lineWidth) || DEFAULT_TEXT_PROPS.lineWidth) * 0.025,
771
769
  ...backgroundColor && { backgroundColor },
772
770
  shadow: ((_t = element.props) == null ? void 0 : _t.shadowColor) ? new fabric.Shadow({
773
771
  offsetX: ((_v = (_u = element.props) == null ? void 0 : _u.shadowOffset) == null ? void 0 : _v.length) && ((_x = (_w = element.props) == null ? void 0 : _w.shadowOffset) == null ? void 0 : _x.length) > 1 ? element.props.shadowOffset[0] / 2 : 1,
@@ -839,19 +837,23 @@ const addCaptionElement = ({
839
837
  }
840
838
  const elementColors = (_g = element.props) == null ? void 0 : _g.colors;
841
839
  const resolvedFill = (applyToAll ? captionTextColor : ((_h = element.props) == null ? void 0 : _h.fill) ?? (elementColors == null ? void 0 : elementColors.text) ?? captionTextColor) ?? DEFAULT_CAPTION_PROPS.fill;
842
- const caption = new fabric.Textbox(((_i = element.props) == null ? void 0 : _i.text) || element.t || "", {
840
+ const trackColors = captionProps == null ? void 0 : captionProps.colors;
841
+ const trackStroke = trackColors == null ? void 0 : trackColors.outlineColor;
842
+ const elementStroke = (elementColors == null ? void 0 : elementColors.outlineColor) ?? ((_i = element.props) == null ? void 0 : _i.stroke);
843
+ const resolvedStroke = (applyToAll ? trackStroke ?? elementStroke : elementStroke ?? trackStroke) ?? void 0;
844
+ const caption = new fabric.Textbox(((_j = element.props) == null ? void 0 : _j.text) || element.t || "", {
843
845
  left: x,
844
846
  top: y,
845
847
  originX: "center",
846
848
  originY: "center",
847
- angle: ((_j = element.props) == null ? void 0 : _j.rotation) || 0,
849
+ angle: ((_k = element.props) == null ? void 0 : _k.rotation) || 0,
848
850
  fontSize: Math.round(
849
- ((applyToAll ? (_k = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _k.size : ((_m = (_l = element.props) == null ? void 0 : _l.font) == null ? void 0 : _m.size) ?? ((_n = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _n.size)) ?? DEFAULT_CAPTION_PROPS.size) * canvasMetadata.scaleX
851
+ ((applyToAll ? (_l = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _l.size : ((_n = (_m = element.props) == null ? void 0 : _m.font) == null ? void 0 : _n.size) ?? ((_o = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _o.size)) ?? DEFAULT_CAPTION_PROPS.size) * canvasMetadata.scaleX
850
852
  ),
851
- fontFamily: (applyToAll ? (_o = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _o.family : ((_q = (_p = element.props) == null ? void 0 : _p.font) == null ? void 0 : _q.family) ?? ((_r = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _r.family)) ?? DEFAULT_CAPTION_PROPS.family,
853
+ fontFamily: (applyToAll ? (_p = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _p.family : ((_r = (_q = element.props) == null ? void 0 : _q.font) == null ? void 0 : _r.family) ?? ((_s = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _s.family)) ?? DEFAULT_CAPTION_PROPS.family,
852
854
  fill: resolvedFill,
853
- fontWeight: (applyToAll ? (_s = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _s.weight : ((_u = (_t = element.props) == null ? void 0 : _t.font) == null ? void 0 : _u.weight) ?? ((_v = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _v.weight)) ?? DEFAULT_CAPTION_PROPS.fontWeight,
854
- stroke: (applyToAll ? captionProps == null ? void 0 : captionProps.stroke : ((_w = element.props) == null ? void 0 : _w.stroke) ?? (captionProps == null ? void 0 : captionProps.stroke)) ?? DEFAULT_CAPTION_PROPS.stroke,
855
+ fontWeight: (applyToAll ? (_t = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _t.weight : ((_v = (_u = element.props) == null ? void 0 : _u.font) == null ? void 0 : _v.weight) ?? ((_w = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _w.weight)) ?? DEFAULT_CAPTION_PROPS.fontWeight,
856
+ ...resolvedStroke ? { stroke: resolvedStroke } : {},
855
857
  opacity: (applyToAll ? captionProps == null ? void 0 : captionProps.opacity : ((_x = element.props) == null ? void 0 : _x.opacity) ?? (captionProps == null ? void 0 : captionProps.opacity)) ?? 1,
856
858
  width,
857
859
  splitByGrapheme: false,
@@ -862,7 +864,7 @@ const addCaptionElement = ({
862
864
  blur: (applyToAll ? captionProps == null ? void 0 : captionProps.shadowBlur : ((_J = element.props) == null ? void 0 : _J.shadowBlur) ?? (captionProps == null ? void 0 : captionProps.shadowBlur)) ?? DEFAULT_CAPTION_PROPS.shadowBlur,
863
865
  color: (applyToAll ? captionProps == null ? void 0 : captionProps.shadowColor : ((_K = element.props) == null ? void 0 : _K.shadowColor) ?? (captionProps == null ? void 0 : captionProps.shadowColor)) ?? DEFAULT_CAPTION_PROPS.shadowColor
864
866
  }),
865
- strokeWidth: (applyToAll ? captionProps == null ? void 0 : captionProps.lineWidth : ((_L = element.props) == null ? void 0 : _L.lineWidth) ?? (captionProps == null ? void 0 : captionProps.lineWidth)) ?? DEFAULT_CAPTION_PROPS.lineWidth
867
+ strokeWidth: ((applyToAll ? captionProps == null ? void 0 : captionProps.lineWidth : ((_L = element.props) == null ? void 0 : _L.lineWidth) ?? (captionProps == null ? void 0 : captionProps.lineWidth)) ?? DEFAULT_CAPTION_PROPS.lineWidth) * 0.025
866
868
  });
867
869
  caption.set("id", element.id);
868
870
  caption.set("zIndex", index);