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