@twick/studio 0.15.13 → 0.15.14

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.mjs CHANGED
@@ -1527,6 +1527,9 @@ function TextPanel({
1527
1527
  applyShadow,
1528
1528
  shadowColor,
1529
1529
  strokeWidth,
1530
+ applyBackground,
1531
+ backgroundColor,
1532
+ backgroundOpacity,
1530
1533
  fonts,
1531
1534
  operation,
1532
1535
  setTextContent,
@@ -1539,6 +1542,9 @@ function TextPanel({
1539
1542
  setApplyShadow,
1540
1543
  setShadowColor,
1541
1544
  setStrokeWidth,
1545
+ setApplyBackground,
1546
+ setBackgroundColor,
1547
+ setBackgroundOpacity,
1542
1548
  handleApplyChanges
1543
1549
  }) {
1544
1550
  return /* @__PURE__ */ jsxs("div", { className: "panel-container", children: [
@@ -1707,6 +1713,69 @@ function TextPanel({
1707
1713
  /* @__PURE__ */ jsx("span", { className: "slider-value", children: strokeWidth })
1708
1714
  ] })
1709
1715
  ] }),
1716
+ /* @__PURE__ */ jsxs("div", { className: "panel-section", children: [
1717
+ /* @__PURE__ */ jsx("label", { className: "label-dark", children: "Background" }),
1718
+ /* @__PURE__ */ jsxs("div", { className: "color-section", children: [
1719
+ /* @__PURE__ */ jsx("div", { className: "checkbox-control", children: /* @__PURE__ */ jsxs("label", { className: "checkbox-label", children: [
1720
+ /* @__PURE__ */ jsx(
1721
+ "input",
1722
+ {
1723
+ type: "checkbox",
1724
+ checked: applyBackground,
1725
+ onChange: (e) => setApplyBackground(e.target.checked),
1726
+ className: "checkbox-purple"
1727
+ }
1728
+ ),
1729
+ "Apply Background"
1730
+ ] }) }),
1731
+ applyBackground && /* @__PURE__ */ jsxs(Fragment, { children: [
1732
+ /* @__PURE__ */ jsxs("div", { className: "color-control", children: [
1733
+ /* @__PURE__ */ jsx("label", { className: "label-small", children: "Background Color" }),
1734
+ /* @__PURE__ */ jsxs("div", { className: "color-inputs", children: [
1735
+ /* @__PURE__ */ jsx(
1736
+ "input",
1737
+ {
1738
+ type: "color",
1739
+ value: backgroundColor,
1740
+ onChange: (e) => setBackgroundColor(e.target.value),
1741
+ className: "color-picker"
1742
+ }
1743
+ ),
1744
+ /* @__PURE__ */ jsx(
1745
+ "input",
1746
+ {
1747
+ type: "text",
1748
+ value: backgroundColor,
1749
+ onChange: (e) => setBackgroundColor(e.target.value),
1750
+ className: "color-text"
1751
+ }
1752
+ )
1753
+ ] })
1754
+ ] }),
1755
+ /* @__PURE__ */ jsxs("div", { className: "panel-section", children: [
1756
+ /* @__PURE__ */ jsx("label", { className: "label-small", children: "Background Opacity" }),
1757
+ /* @__PURE__ */ jsxs("div", { className: "slider-container", children: [
1758
+ /* @__PURE__ */ jsx(
1759
+ "input",
1760
+ {
1761
+ type: "range",
1762
+ min: "0",
1763
+ max: "1",
1764
+ step: 0.1,
1765
+ value: backgroundOpacity,
1766
+ onChange: (e) => setBackgroundOpacity(Number(e.target.value)),
1767
+ className: "slider-purple"
1768
+ }
1769
+ ),
1770
+ /* @__PURE__ */ jsxs("span", { className: "slider-value", children: [
1771
+ Math.round(backgroundOpacity * 100),
1772
+ "%"
1773
+ ] })
1774
+ ] })
1775
+ ] })
1776
+ ] })
1777
+ ] })
1778
+ ] }),
1710
1779
  /* @__PURE__ */ jsx("div", { className: "flex panel-section", children: /* @__PURE__ */ jsx("button", { onClick: handleApplyChanges, className: "btn-primary w-full", children: operation }) })
1711
1780
  ] });
1712
1781
  }
@@ -1741,6 +1810,9 @@ const useTextPanel = ({
1741
1810
  const [applyShadow, setApplyShadow] = useState(DEFAULT_TEXT_PROPS.applyShadow);
1742
1811
  const [shadowColor, setShadowColor] = useState(DEFAULT_TEXT_PROPS.shadowColor);
1743
1812
  const [strokeWidth, setStrokeWidth] = useState(DEFAULT_TEXT_PROPS.strokeWidth);
1813
+ const [applyBackground, setApplyBackground] = useState(false);
1814
+ const [backgroundColor, setBackgroundColor] = useState("#FACC15");
1815
+ const [backgroundOpacity, setBackgroundOpacity] = useState(1);
1744
1816
  const fonts = Object.values(AVAILABLE_TEXT_FONTS);
1745
1817
  const handleApplyChanges = async () => {
1746
1818
  let textElement;
@@ -1755,35 +1827,41 @@ const useTextPanel = ({
1755
1827
  textElement.setStrokeColor(strokeColor);
1756
1828
  textElement.setLineWidth(strokeWidth);
1757
1829
  textElement.setTextAlign(DEFAULT_TEXT_PROPS.textAlign);
1830
+ const nextProps = { ...textElement.getProps() };
1758
1831
  if (applyShadow) {
1759
- textElement.setProps({
1760
- ...textElement.getProps(),
1761
- shadowColor,
1762
- shadowOffset: DEFAULT_TEXT_PROPS.shadowOffset,
1763
- shadowBlur: DEFAULT_TEXT_PROPS.shadowBlur,
1764
- shadowOpacity: DEFAULT_TEXT_PROPS.shadowOpacity
1765
- });
1832
+ nextProps.shadowColor = shadowColor;
1833
+ nextProps.shadowOffset = DEFAULT_TEXT_PROPS.shadowOffset;
1834
+ nextProps.shadowBlur = DEFAULT_TEXT_PROPS.shadowBlur;
1835
+ nextProps.shadowOpacity = DEFAULT_TEXT_PROPS.shadowOpacity;
1766
1836
  } else {
1767
- textElement.setProps({
1768
- ...textElement.getProps(),
1769
- shadowColor: void 0,
1770
- shadowOffset: void 0,
1771
- shadowBlur: void 0,
1772
- shadowOpacity: void 0
1773
- });
1837
+ nextProps.shadowColor = void 0;
1838
+ nextProps.shadowOffset = void 0;
1839
+ nextProps.shadowBlur = void 0;
1840
+ nextProps.shadowOpacity = void 0;
1774
1841
  }
1842
+ if (applyBackground) {
1843
+ nextProps.backgroundColor = backgroundColor;
1844
+ nextProps.backgroundOpacity = backgroundOpacity;
1845
+ } else {
1846
+ nextProps.backgroundColor = void 0;
1847
+ nextProps.backgroundOpacity = void 0;
1848
+ }
1849
+ textElement.setProps(nextProps);
1775
1850
  updateElement(textElement);
1776
1851
  } else {
1777
1852
  textElement = new TextElement(textContent).setFontSize(fontSize).setFontFamily(selectedFont).setFontWeight(isBold ? 700 : 400).setFontStyle(isItalic ? "italic" : "normal").setFill(textColor).setStrokeColor(strokeColor).setLineWidth(strokeWidth).setTextAlign("center");
1853
+ const nextProps = { ...textElement.getProps() };
1778
1854
  if (applyShadow) {
1779
- textElement.setProps({
1780
- ...textElement.getProps(),
1781
- shadowColor,
1782
- shadowOffset: DEFAULT_TEXT_PROPS.shadowOffset,
1783
- shadowBlur: DEFAULT_TEXT_PROPS.shadowBlur,
1784
- shadowOpacity: DEFAULT_TEXT_PROPS.shadowOpacity
1785
- });
1855
+ nextProps.shadowColor = shadowColor;
1856
+ nextProps.shadowOffset = DEFAULT_TEXT_PROPS.shadowOffset;
1857
+ nextProps.shadowBlur = DEFAULT_TEXT_PROPS.shadowBlur;
1858
+ nextProps.shadowOpacity = DEFAULT_TEXT_PROPS.shadowOpacity;
1786
1859
  }
1860
+ if (applyBackground) {
1861
+ nextProps.backgroundColor = backgroundColor;
1862
+ nextProps.backgroundOpacity = backgroundOpacity;
1863
+ }
1864
+ textElement.setProps(nextProps);
1787
1865
  await addElement(textElement);
1788
1866
  }
1789
1867
  };
@@ -1803,6 +1881,12 @@ const useTextPanel = ({
1803
1881
  if (hasShadow) {
1804
1882
  setShadowColor(textProps.shadowColor ?? DEFAULT_TEXT_PROPS.shadowColor);
1805
1883
  }
1884
+ const hasBackground = textProps.backgroundColor != null && textProps.backgroundColor !== "";
1885
+ setApplyBackground(hasBackground);
1886
+ if (hasBackground) {
1887
+ setBackgroundColor(textProps.backgroundColor ?? "#FACC15");
1888
+ setBackgroundOpacity(textProps.backgroundOpacity ?? 1);
1889
+ }
1806
1890
  } else {
1807
1891
  setTextContent(DEFAULT_TEXT_PROPS.text);
1808
1892
  setFontSize(DEFAULT_TEXT_PROPS.fontSize);
@@ -1814,6 +1898,9 @@ const useTextPanel = ({
1814
1898
  setStrokeWidth(DEFAULT_TEXT_PROPS.strokeWidth);
1815
1899
  setApplyShadow(DEFAULT_TEXT_PROPS.applyShadow);
1816
1900
  setShadowColor(DEFAULT_TEXT_PROPS.shadowColor);
1901
+ setApplyBackground(false);
1902
+ setBackgroundColor("#FACC15");
1903
+ setBackgroundOpacity(1);
1817
1904
  }
1818
1905
  }, [selectedElement]);
1819
1906
  return {
@@ -1839,6 +1926,12 @@ const useTextPanel = ({
1839
1926
  setApplyShadow,
1840
1927
  setShadowColor,
1841
1928
  setStrokeWidth,
1929
+ applyBackground,
1930
+ backgroundColor,
1931
+ backgroundOpacity,
1932
+ setApplyBackground,
1933
+ setBackgroundColor,
1934
+ setBackgroundOpacity,
1842
1935
  handleApplyChanges
1843
1936
  };
1844
1937
  };
@@ -2549,7 +2642,7 @@ const useSubtitlesPanel = () => {
2549
2642
  const subtitlesTrack = useRef(null);
2550
2643
  const { editor } = useTimelineContext();
2551
2644
  const fetchSubtitles = async () => {
2552
- const editorSubtitlesTrack = editor.getSubtiltesTrack();
2645
+ const editorSubtitlesTrack = editor.getSubtitlesTrack();
2553
2646
  if (editorSubtitlesTrack) {
2554
2647
  subtitlesTrack.current = editorSubtitlesTrack;
2555
2648
  setSubtitles(