@twick/video-editor 0.14.7 → 0.14.9

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,25 @@
1
1
 
2
+ /**
3
+ * PlayerManager component that manages video playback and canvas rendering.
4
+ * Integrates the live player with canvas operations, handling both video playback
5
+ * and static canvas display modes. Automatically updates canvas when paused and
6
+ * manages player state transitions.
7
+ *
8
+ * @param props - Component configuration props
9
+ * @param props.videoProps - Video dimensions and background color
10
+ * @param props.playerProps - Optional player quality settings
11
+ * @param props.canvasMode - Whether to show canvas overlay when paused
12
+ * @returns JSX element containing player and canvas components
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <PlayerManager
17
+ * videoProps={{ width: 1920, height: 1080, backgroundColor: '#000' }}
18
+ * playerProps={{ quality: 720 }}
19
+ * canvasMode={true}
20
+ * />
21
+ * ```
22
+ */
2
23
  export declare const PlayerManager: ({ videoProps, playerProps, canvasMode, }: {
3
24
  videoProps: {
4
25
  width: number;
@@ -0,0 +1,27 @@
1
+ import { TrackElement } from '@twick/timeline';
2
+
3
+ /**
4
+ * Custom hook for managing video editor operations.
5
+ * Provides functionality to add and update timeline elements with automatic
6
+ * collision detection and error handling. Integrates with live player context
7
+ * to position elements at the current playback time.
8
+ *
9
+ * @returns Object containing editor management functions
10
+ * @property {Function} addElement - Add a new element to the timeline
11
+ * @property {Function} updateElement - Update an existing timeline element
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const { addElement, updateElement } = useEditorManager();
16
+ *
17
+ * // Add a new element at current playback time
18
+ * await addElement(newElement);
19
+ *
20
+ * // Update an existing element
21
+ * updateElement(modifiedElement);
22
+ * ```
23
+ */
24
+ export declare const useEditorManager: () => {
25
+ addElement: (element: TrackElement) => Promise<void>;
26
+ updateElement: (element: TrackElement) => void;
27
+ };
@@ -32,6 +32,6 @@ export declare const useTimelineManager: () => {
32
32
  onReorder: (reorderedItems: Track[]) => void;
33
33
  onSeek: (time: number) => void;
34
34
  onSelectionChange: (selectedItem: TrackElement | Track | null) => void;
35
- selectedItem: TrackElement | Track | null;
35
+ selectedItem: Track | TrackElement | null;
36
36
  totalDuration: number;
37
37
  };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { default as VideoEditor, VideoEditorProps, VideoEditorConfig, TimelineTi
2
2
  import { default as PlayerControls, PlayerControlsProps } from './components/controls/player-controls';
3
3
  import { default as TimelineManager } from './components/timeline/timeline-manager';
4
4
  import { usePlayerControl } from './hooks/use-player-control';
5
+ import { useEditorManager } from './hooks/use-editor-manager';
5
6
  import { default as BrowserMediaManager } from './helpers/media-manager/browser-media-manager';
6
7
  import { MediaItem, PaginationOptions, SearchOptions, Animation, TextEffect, ElementColors } from './helpers/types';
7
8
  import { default as BaseMediaManager } from './helpers/media-manager/base-media-manager';
@@ -15,6 +16,6 @@ export { setElementColors };
15
16
  export type { MediaItem, PaginationOptions, SearchOptions, Animation, TextEffect, ElementColors };
16
17
  export type { PlayerControlsProps, VideoEditorProps, VideoEditorConfig, TimelineTickConfig, TimelineZoomConfig };
17
18
  export { ANIMATIONS, TEXT_EFFECTS };
18
- export { usePlayerControl, BrowserMediaManager, BaseMediaManager, animationGifs, getAnimationGif, PlayerControls, TimelineManager, useTimelineControl };
19
+ export { usePlayerControl, useEditorManager, BrowserMediaManager, BaseMediaManager, animationGifs, getAnimationGif, PlayerControls, TimelineManager, useTimelineControl };
19
20
  export * from './helpers/constants';
20
21
  export default VideoEditor;
package/dist/index.js CHANGED
@@ -6851,7 +6851,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6851
6851
  /** An item has been selected on the canvas */
6852
6852
  ITEM_SELECTED: "ITEM_SELECTED",
6853
6853
  /** An item has been updated/modified on the canvas */
6854
- ITEM_UPDATED: "ITEM_UPDATED"
6854
+ ITEM_UPDATED: "ITEM_UPDATED",
6855
+ /** Caption properties have been updated */
6856
+ CAPTION_PROPS_UPDATED: "CAPTION_PROPS_UPDATED"
6855
6857
  };
6856
6858
  const ELEMENT_TYPES = {
6857
6859
  /** Text element type */
@@ -6863,7 +6865,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6863
6865
  /** Video element type */
6864
6866
  VIDEO: "video",
6865
6867
  /** Rectangle element type */
6866
- RECT: "rect"
6868
+ RECT: "rect",
6869
+ /** Circle element type */
6870
+ CIRCLE: "circle"
6867
6871
  };
6868
6872
  const isBrowser$2 = typeof window !== "undefined";
6869
6873
  const isCanvasSupported = isBrowser$2 && !!window.HTMLCanvasElement;
@@ -7223,33 +7227,33 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7223
7227
  captionProps,
7224
7228
  canvasMetadata
7225
7229
  }) => {
7226
- var _a2, _b, _c, _d, _e2, _f, _g, _h, _i2, _j, _k, _l, _m, _n2, _o2, _p, _q, _r2, _s2, _t2, _u, _v, _w, _x, _y, _z, _A;
7230
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i2, _j, _k, _l, _m, _n2, _o2, _p, _q, _r2, _s2, _t2, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
7227
7231
  const { x: x2, y: y2 } = convertToCanvasPosition(
7228
- ((_b = (_a2 = element.props) == null ? void 0 : _a2.pos) == null ? void 0 : _b.x) || ((_c = captionProps == null ? void 0 : captionProps.pos) == null ? void 0 : _c.x) || 0,
7229
- ((_e2 = (_d = element.props) == null ? void 0 : _d.pos) == null ? void 0 : _e2.y) || ((_f = captionProps == null ? void 0 : captionProps.pos) == null ? void 0 : _f.y) || 0,
7232
+ ((captionProps == null ? void 0 : captionProps.applyToAll) ? captionProps == null ? void 0 : captionProps.x : (_a2 = element.props) == null ? void 0 : _a2.x) ?? 0,
7233
+ ((captionProps == null ? void 0 : captionProps.applyToAll) ? captionProps == null ? void 0 : captionProps.y : (_b = element.props) == null ? void 0 : _b.y) ?? 0,
7230
7234
  canvasMetadata
7231
7235
  );
7232
- const caption = new ko(((_g = element.props) == null ? void 0 : _g.text) || element.t || "", {
7236
+ const caption = new ko(((_c = element.props) == null ? void 0 : _c.text) || element.t || "", {
7233
7237
  left: x2,
7234
7238
  top: y2,
7235
7239
  originX: "center",
7236
7240
  originY: "center",
7237
- angle: ((_h = element.props) == null ? void 0 : _h.rotation) || 0,
7241
+ angle: ((_d = element.props) == null ? void 0 : _d.rotation) || 0,
7238
7242
  fontSize: Math.round(
7239
- (((_j = (_i2 = element.props) == null ? void 0 : _i2.font) == null ? void 0 : _j.size) || ((_k = captionProps.font) == null ? void 0 : _k.size) || DEFAULT_CAPTION_PROPS.size) * canvasMetadata.scaleX
7243
+ (((captionProps == null ? void 0 : captionProps.applyToAll) ? (_e2 = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _e2.size : ((_g = (_f = element.props) == null ? void 0 : _f.font) == null ? void 0 : _g.size) ?? ((_h = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _h.size)) ?? DEFAULT_CAPTION_PROPS.size) * canvasMetadata.scaleX
7240
7244
  ),
7241
- fontFamily: ((_m = (_l = element.props) == null ? void 0 : _l.font) == null ? void 0 : _m.family) || ((_n2 = captionProps.font) == null ? void 0 : _n2.family) || DEFAULT_CAPTION_PROPS.family,
7242
- fill: ((_o2 = element.props) == null ? void 0 : _o2.fill) || ((_p = captionProps.color) == null ? void 0 : _p.text) || DEFAULT_CAPTION_PROPS.fill,
7243
- fontWeight: DEFAULT_CAPTION_PROPS.fontWeight,
7244
- stroke: ((_q = element.props) == null ? void 0 : _q.stroke) || DEFAULT_CAPTION_PROPS.stroke,
7245
- opacity: ((_r2 = element.props) == null ? void 0 : _r2.opacity) ?? 1,
7245
+ fontFamily: ((captionProps == null ? void 0 : captionProps.applyToAll) ? (_i2 = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _i2.family : ((_k = (_j = element.props) == null ? void 0 : _j.font) == null ? void 0 : _k.family) ?? ((_l = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _l.family)) ?? DEFAULT_CAPTION_PROPS.family,
7246
+ fill: ((captionProps == null ? void 0 : captionProps.applyToAll) ? (_m = captionProps.color) == null ? void 0 : _m.text : ((_n2 = element.props) == null ? void 0 : _n2.fill) ?? ((_o2 = captionProps.color) == null ? void 0 : _o2.text)) ?? DEFAULT_CAPTION_PROPS.fill,
7247
+ fontWeight: ((captionProps == null ? void 0 : captionProps.applyToAll) ? (_p = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _p.weight : ((_q = element.props) == null ? void 0 : _q.fontWeight) ?? ((_r2 = captionProps == null ? void 0 : captionProps.font) == null ? void 0 : _r2.weight)) ?? DEFAULT_CAPTION_PROPS.fontWeight,
7248
+ stroke: ((captionProps == null ? void 0 : captionProps.applyToAll) ? captionProps == null ? void 0 : captionProps.stroke : ((_s2 = element.props) == null ? void 0 : _s2.stroke) ?? (captionProps == null ? void 0 : captionProps.stroke)) ?? DEFAULT_CAPTION_PROPS.stroke,
7249
+ opacity: ((captionProps == null ? void 0 : captionProps.applyToAll) ? captionProps == null ? void 0 : captionProps.opacity : ((_t2 = element.props) == null ? void 0 : _t2.opacity) ?? (captionProps == null ? void 0 : captionProps.opacity)) ?? 1,
7246
7250
  shadow: new ds({
7247
- offsetX: ((_t2 = (_s2 = element.props) == null ? void 0 : _s2.shadowOffset) == null ? void 0 : _t2[0]) || ((_u = DEFAULT_CAPTION_PROPS.shadowOffset) == null ? void 0 : _u[0]),
7248
- offsetY: ((_w = (_v = element.props) == null ? void 0 : _v.shadowOffset) == null ? void 0 : _w[1]) || ((_x = DEFAULT_CAPTION_PROPS.shadowOffset) == null ? void 0 : _x[1]),
7249
- blur: ((_y = element.props) == null ? void 0 : _y.shadowBlur) || DEFAULT_CAPTION_PROPS.shadowBlur,
7250
- color: ((_z = element.props) == null ? void 0 : _z.shadowColor) || DEFAULT_CAPTION_PROPS.shadowColor
7251
+ offsetX: ((captionProps == null ? void 0 : captionProps.applyToAll) ? (_u = captionProps == null ? void 0 : captionProps.shadowOffset) == null ? void 0 : _u[0] : ((_w = (_v = element.props) == null ? void 0 : _v.shadowOffset) == null ? void 0 : _w[0]) ?? ((_x = captionProps == null ? void 0 : captionProps.shadowOffset) == null ? void 0 : _x[0])) ?? ((_y = DEFAULT_CAPTION_PROPS.shadowOffset) == null ? void 0 : _y[0]),
7252
+ offsetY: ((captionProps == null ? void 0 : captionProps.applyToAll) ? (_z = captionProps == null ? void 0 : captionProps.shadowOffset) == null ? void 0 : _z[1] : ((_B = (_A = element.props) == null ? void 0 : _A.shadowOffset) == null ? void 0 : _B[1]) ?? ((_C = captionProps == null ? void 0 : captionProps.shadowOffset) == null ? void 0 : _C[1])) ?? ((_D = DEFAULT_CAPTION_PROPS.shadowOffset) == null ? void 0 : _D[1]),
7253
+ blur: ((captionProps == null ? void 0 : captionProps.applyToAll) ? captionProps == null ? void 0 : captionProps.shadowBlur : ((_E = element.props) == null ? void 0 : _E.shadowBlur) ?? (captionProps == null ? void 0 : captionProps.shadowBlur)) ?? DEFAULT_CAPTION_PROPS.shadowBlur,
7254
+ color: ((captionProps == null ? void 0 : captionProps.applyToAll) ? captionProps == null ? void 0 : captionProps.shadowColor : ((_F = element.props) == null ? void 0 : _F.shadowColor) ?? (captionProps == null ? void 0 : captionProps.shadowColor)) ?? DEFAULT_CAPTION_PROPS.shadowColor
7251
7255
  }),
7252
- strokeWidth: ((_A = element.props) == null ? void 0 : _A.lineWidth) || DEFAULT_CAPTION_PROPS.lineWidth
7256
+ strokeWidth: ((captionProps == null ? void 0 : captionProps.applyToAll) ? captionProps == null ? void 0 : captionProps.lineWidth : ((_G = element.props) == null ? void 0 : _G.lineWidth) ?? (captionProps == null ? void 0 : captionProps.lineWidth)) ?? DEFAULT_CAPTION_PROPS.lineWidth
7253
7257
  });
7254
7258
  caption.set("id", element.id);
7255
7259
  caption.set("zIndex", index);
@@ -7476,6 +7480,40 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7476
7480
  canvas.add(rect);
7477
7481
  return rect;
7478
7482
  };
7483
+ const addCircleElement = ({
7484
+ element,
7485
+ index,
7486
+ canvas,
7487
+ canvasMetadata
7488
+ }) => {
7489
+ var _a2, _b, _c, _d, _e2, _f;
7490
+ const { x: x2, y: y2 } = convertToCanvasPosition(
7491
+ ((_a2 = element.props) == null ? void 0 : _a2.x) || 0,
7492
+ ((_b = element.props) == null ? void 0 : _b.y) || 0,
7493
+ canvasMetadata
7494
+ );
7495
+ const circle = new qn({
7496
+ left: x2,
7497
+ // X-coordinate on the canvas
7498
+ top: y2,
7499
+ // Y-coordinate on the canvas
7500
+ radius: (((_c = element.props) == null ? void 0 : _c.radius) || 0) * canvasMetadata.scaleX,
7501
+ fill: ((_d = element.props) == null ? void 0 : _d.fill) || "#000000",
7502
+ stroke: ((_e2 = element.props) == null ? void 0 : _e2.stroke) || "#000000",
7503
+ strokeWidth: (((_f = element.props) == null ? void 0 : _f.lineWidth) || 0) * canvasMetadata.scaleX,
7504
+ originX: "center",
7505
+ originY: "center"
7506
+ });
7507
+ circle.controls.mt = disabledControl;
7508
+ circle.controls.mb = disabledControl;
7509
+ circle.controls.ml = disabledControl;
7510
+ circle.controls.mr = disabledControl;
7511
+ circle.controls.mtr = disabledControl;
7512
+ circle.set("id", element.id);
7513
+ circle.set("zIndex", index);
7514
+ canvas.add(circle);
7515
+ return circle;
7516
+ };
7479
7517
  const addBackgroundColor = ({
7480
7518
  element,
7481
7519
  index,
@@ -7517,6 +7555,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7517
7555
  const twickCanvasRef = React.useRef(null);
7518
7556
  const videoSizeRef = React.useRef({ width: 1, height: 1 });
7519
7557
  const canvasResolutionRef = React.useRef({ width: 1, height: 1 });
7558
+ const captionPropsRef = React.useRef(null);
7520
7559
  const canvasMetadataRef = React.useRef({
7521
7560
  width: 0,
7522
7561
  height: 0,
@@ -7574,7 +7613,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7574
7613
  }
7575
7614
  };
7576
7615
  const handleMouseUp = (event) => {
7577
- var _a2, _b;
7616
+ var _a2, _b, _c;
7578
7617
  if (event.target) {
7579
7618
  const object = event.target;
7580
7619
  const elementId = object.get("id");
@@ -7601,20 +7640,29 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7601
7640
  videoSizeRef.current
7602
7641
  );
7603
7642
  if (elementMap.current[elementId].type === "caption") {
7604
- elementMap.current[elementId] = {
7605
- ...elementMap.current[elementId],
7606
- props: {
7607
- ...elementMap.current[elementId].props,
7608
- pos: {
7643
+ if ((_c = captionPropsRef.current) == null ? void 0 : _c.applyToAll) {
7644
+ onCanvasOperation == null ? void 0 : onCanvasOperation(CANVAS_OPERATIONS.CAPTION_PROPS_UPDATED, {
7645
+ element: elementMap.current[elementId],
7646
+ props: {
7647
+ ...captionPropsRef.current,
7609
7648
  x: x2,
7610
7649
  y: y2
7611
7650
  }
7612
- }
7613
- };
7614
- onCanvasOperation == null ? void 0 : onCanvasOperation(
7615
- CANVAS_OPERATIONS.ITEM_UPDATED,
7616
- elementMap.current[elementId]
7617
- );
7651
+ });
7652
+ } else {
7653
+ elementMap.current[elementId] = {
7654
+ ...elementMap.current[elementId],
7655
+ props: {
7656
+ ...elementMap.current[elementId].props,
7657
+ x: x2,
7658
+ y: y2
7659
+ }
7660
+ };
7661
+ onCanvasOperation == null ? void 0 : onCanvasOperation(
7662
+ CANVAS_OPERATIONS.ITEM_UPDATED,
7663
+ elementMap.current[elementId]
7664
+ );
7665
+ }
7618
7666
  } else {
7619
7667
  if ((object == null ? void 0 : object.type) === "group") {
7620
7668
  const currentFrameEffect = elementFrameMap.current[elementId];
@@ -7678,6 +7726,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7678
7726
  y: y2
7679
7727
  }
7680
7728
  };
7729
+ } else if ((object == null ? void 0 : object.type) === "circle") {
7730
+ const radius = Number(
7731
+ (elementMap.current[elementId].props.radius * object.scaleX).toFixed(2)
7732
+ );
7733
+ elementMap.current[elementId] = {
7734
+ ...elementMap.current[elementId],
7735
+ props: {
7736
+ ...elementMap.current[elementId].props,
7737
+ rotation: object.angle,
7738
+ radius,
7739
+ height: radius * 2,
7740
+ width: radius * 2,
7741
+ x: x2,
7742
+ y: y2
7743
+ }
7744
+ };
7681
7745
  } else {
7682
7746
  elementMap.current[elementId] = {
7683
7747
  ...elementMap.current[elementId],
@@ -7720,6 +7784,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7720
7784
  twickCanvas.renderAll();
7721
7785
  }
7722
7786
  }
7787
+ captionPropsRef.current = captionProps;
7723
7788
  await Promise.all(
7724
7789
  elements.map(async (element, index) => {
7725
7790
  try {
@@ -7758,7 +7823,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7758
7823
  }
7759
7824
  switch (element.type) {
7760
7825
  case ELEMENT_TYPES.VIDEO:
7761
- const currentFrameEffect = getCurrentFrameEffect(element, seekTime || 0);
7826
+ const currentFrameEffect = getCurrentFrameEffect(
7827
+ element,
7828
+ seekTime || 0
7829
+ );
7762
7830
  elementFrameMap.current[element.id] = currentFrameEffect;
7763
7831
  const snapTime = ((seekTime || 0) - ((element == null ? void 0 : element.s) || 0)) * (((_a2 = element == null ? void 0 : element.props) == null ? void 0 : _a2.playbackRate) || 1) + (((_b = element == null ? void 0 : element.props) == null ? void 0 : _b.time) || 0);
7764
7832
  await addVideoElement({
@@ -7802,6 +7870,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7802
7870
  canvasMetadata: canvasMetadataRef.current
7803
7871
  });
7804
7872
  break;
7873
+ case ELEMENT_TYPES.CIRCLE:
7874
+ await addCircleElement({
7875
+ element,
7876
+ index,
7877
+ canvas: twickCanvas,
7878
+ canvasMetadata: canvasMetadataRef.current
7879
+ });
7880
+ break;
7805
7881
  case ELEMENT_TYPES.TEXT:
7806
7882
  await addTextElement({
7807
7883
  element,
@@ -7837,25 +7913,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7837
7913
  videoProps
7838
7914
  }) => {
7839
7915
  const [projectData, setProjectData] = React.useState(null);
7840
- const { timelineAction, setTimelineAction, setSelectedItem, editor, changeLog } = timeline.useTimelineContext();
7916
+ const {
7917
+ timelineAction,
7918
+ setTimelineAction,
7919
+ setSelectedItem,
7920
+ editor,
7921
+ changeLog
7922
+ } = timeline.useTimelineContext();
7841
7923
  const currentChangeLog = React.useRef(changeLog);
7924
+ const prevSeekTime = React.useRef(0);
7842
7925
  const [playerUpdating, setPlayerUpdating] = React.useState(false);
7843
7926
  const handleCanvasReady = (canvas) => {
7844
7927
  console.log("canvas ready", canvas);
7845
7928
  };
7846
7929
  const handleCanvasOperation = (operation, data) => {
7847
- const element = timeline.ElementDeserializer.fromJSON(data);
7848
- switch (operation) {
7849
- case CANVAS_OPERATIONS.ITEM_SELECTED:
7850
- setSelectedItem(element);
7851
- break;
7852
- case CANVAS_OPERATIONS.ITEM_UPDATED:
7853
- if (element) {
7854
- const updatedElement = editor.updateElement(element);
7855
- currentChangeLog.current = currentChangeLog.current + 1;
7856
- setSelectedItem(updatedElement);
7857
- }
7858
- break;
7930
+ if (operation === CANVAS_OPERATIONS.CAPTION_PROPS_UPDATED) {
7931
+ const subtitlesTrack = editor.getSubtiltesTrack();
7932
+ subtitlesTrack == null ? void 0 : subtitlesTrack.setProps(data.props);
7933
+ setSelectedItem(data.element);
7934
+ editor.refresh();
7935
+ } else {
7936
+ const element = timeline.ElementDeserializer.fromJSON(data);
7937
+ switch (operation) {
7938
+ case CANVAS_OPERATIONS.ITEM_SELECTED:
7939
+ setSelectedItem(element);
7940
+ break;
7941
+ case CANVAS_OPERATIONS.ITEM_UPDATED:
7942
+ if (element) {
7943
+ const updatedElement = editor.updateElement(element);
7944
+ currentChangeLog.current = currentChangeLog.current + 1;
7945
+ setSelectedItem(updatedElement);
7946
+ }
7947
+ break;
7948
+ }
7859
7949
  }
7860
7950
  };
7861
7951
  const { twickCanvas, buildCanvas, setCanvasElements } = useTwickCanvas({
@@ -7864,17 +7954,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7864
7954
  });
7865
7955
  const updateCanvas = (seekTime) => {
7866
7956
  var _a2;
7867
- if (changeLog === currentChangeLog.current) {
7957
+ if (changeLog === currentChangeLog.current && seekTime === prevSeekTime.current) {
7868
7958
  return;
7869
7959
  }
7960
+ prevSeekTime.current = seekTime;
7870
7961
  const elements = timeline.getCurrentElements(
7871
7962
  seekTime,
7872
7963
  ((_a2 = editor.getTimelineData()) == null ? void 0 : _a2.tracks) ?? []
7873
7964
  );
7965
+ let captionProps = {};
7966
+ (elements || []).forEach((element) => {
7967
+ if (element instanceof timeline.CaptionElement) {
7968
+ const track = editor.getTrackById(element.getTrackId());
7969
+ captionProps = (track == null ? void 0 : track.getProps()) ?? {};
7970
+ }
7971
+ });
7874
7972
  setCanvasElements({
7875
7973
  elements,
7876
7974
  seekTime,
7877
- captionProps: {},
7975
+ captionProps,
7878
7976
  cleanAndAdd: true
7879
7977
  });
7880
7978
  currentChangeLog.current = changeLog;
@@ -7887,7 +7985,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7887
7985
  }
7888
7986
  };
7889
7987
  React.useEffect(() => {
7890
- var _a2, _b, _c, _d;
7988
+ var _a2, _b, _c, _d, _e2;
7891
7989
  switch (timelineAction.type) {
7892
7990
  case timeline.TIMELINE_ACTION.UPDATE_PLAYER_DATA:
7893
7991
  if (videoProps) {
@@ -7901,6 +7999,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7901
7999
  }
7902
8000
  };
7903
8001
  setProjectData(_latestProjectData);
8002
+ if (((_e2 = timelineAction.payload) == null ? void 0 : _e2.version) === 1) {
8003
+ setTimeout(() => {
8004
+ setPlayerUpdating(false);
8005
+ });
8006
+ }
7904
8007
  } else {
7905
8008
  setTimelineAction(timeline.TIMELINE_ACTION.ON_PLAYER_UPDATED, null);
7906
8009
  }
@@ -9446,6 +9549,7 @@ This message will only show in development mode. It won't appear in production.
9446
9549
  onClick: (e2) => handleSeek(e2.clientX),
9447
9550
  style: {
9448
9551
  overflowX: "auto",
9552
+ overflowY: "hidden",
9449
9553
  position: "relative",
9450
9554
  scrollbarWidth: "none",
9451
9555
  // Firefox
@@ -9507,6 +9611,7 @@ This message will only show in development mode. It won't appear in production.
9507
9611
  "div",
9508
9612
  {
9509
9613
  style: {
9614
+ overflow: "hidden",
9510
9615
  position: "relative",
9511
9616
  width: `${Math.max(1, Math.round(totalWidth))}px`,
9512
9617
  height: "32px",
@@ -17898,6 +18003,54 @@ This message will only show in development mode. It won't appear in production.
17898
18003
  ] })
17899
18004
  ] });
17900
18005
  };
18006
+ const useEditorManager = () => {
18007
+ const { editor, selectedItem, setSelectedItem } = timeline.useTimelineContext();
18008
+ const { getCurrentTime } = livePlayer.useLivePlayerContext();
18009
+ const addElement = async (element) => {
18010
+ const currentTime = getCurrentTime();
18011
+ element.setStart(currentTime);
18012
+ try {
18013
+ if (selectedItem instanceof timeline.Track) {
18014
+ const result = await editor.addElementToTrack(selectedItem, element);
18015
+ if (result) {
18016
+ setSelectedItem(element);
18017
+ }
18018
+ } else {
18019
+ const newTrack = editor.addTrack(`Track_${Date.now()}`);
18020
+ const result = await editor.addElementToTrack(newTrack, element);
18021
+ if (result) {
18022
+ setSelectedItem(element);
18023
+ }
18024
+ }
18025
+ } catch (error) {
18026
+ if (error instanceof timeline.ValidationError) {
18027
+ if (error.errors.includes(timeline.VALIDATION_ERROR_CODE.COLLISION_ERROR)) {
18028
+ try {
18029
+ const newTrack = editor.addTrack(`Track_${Date.now()}`);
18030
+ const result = await editor.addElementToTrack(newTrack, element);
18031
+ if (result) {
18032
+ setSelectedItem(element);
18033
+ }
18034
+ } catch (error2) {
18035
+ }
18036
+ } else {
18037
+ console.log("TIMELINE ERROR: ", error.errors);
18038
+ }
18039
+ } else {
18040
+ console.log("TIMELINE ERROR: ", error);
18041
+ }
18042
+ }
18043
+ };
18044
+ const updateElement = (element) => {
18045
+ const updatedElement = editor.updateElement(element);
18046
+ editor.refresh();
18047
+ setSelectedItem(updatedElement);
18048
+ };
18049
+ return {
18050
+ addElement,
18051
+ updateElement
18052
+ };
18053
+ };
17901
18054
  class BaseMediaManager {
17902
18055
  }
17903
18056
  class BrowserMediaManager extends BaseMediaManager {
@@ -18257,6 +18410,7 @@ This message will only show in development mode. It won't appear in production.
18257
18410
  exports2.default = VideoEditor;
18258
18411
  exports2.getAnimationGif = getAnimationGif;
18259
18412
  exports2.setElementColors = setElementColors;
18413
+ exports2.useEditorManager = useEditorManager;
18260
18414
  exports2.usePlayerControl = usePlayerControl;
18261
18415
  exports2.useTimelineControl = useTimelineControl;
18262
18416
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });