@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.
- package/dist/components/player/player-manager.d.ts +21 -0
- package/dist/hooks/use-editor-manager.d.ts +27 -0
- package/dist/hooks/use-timeline-manager.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +201 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -48
- package/dist/index.mjs.map +1 -1
- package/dist/video-editor.css +0 -3
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useLivePlayerContext, PLAYER_STATE, LivePlayer } from "@twick/live-player";
|
|
6
|
-
import { useTimelineContext, TIMELINE_ACTION, getCurrentElements, ElementDeserializer, Track, getDecimalNumber, VideoElement, AudioElement, TrackElement } from "@twick/timeline";
|
|
6
|
+
import { useTimelineContext, TIMELINE_ACTION, getCurrentElements, CaptionElement, ElementDeserializer, Track, getDecimalNumber, VideoElement, AudioElement, TrackElement, ValidationError, VALIDATION_ERROR_CODE } from "@twick/timeline";
|
|
7
7
|
import React, { useState, useRef, useEffect, useMemo, forwardRef, createElement, createContext, useContext, useId, useCallback, useLayoutEffect, useInsertionEffect, Fragment, Component } from "react";
|
|
8
8
|
function t(t2, e3, s2) {
|
|
9
9
|
return (e3 = function(t3) {
|
|
@@ -6851,7 +6851,9 @@ const CANVAS_OPERATIONS = {
|
|
|
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 @@ const ELEMENT_TYPES = {
|
|
|
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 @@ const addCaptionElement = ({
|
|
|
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
|
-
((
|
|
7229
|
-
((
|
|
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(((
|
|
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: ((
|
|
7241
|
+
angle: ((_d = element.props) == null ? void 0 : _d.rotation) || 0,
|
|
7238
7242
|
fontSize: Math.round(
|
|
7239
|
-
(((
|
|
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: ((
|
|
7242
|
-
fill: ((
|
|
7243
|
-
fontWeight: DEFAULT_CAPTION_PROPS.fontWeight,
|
|
7244
|
-
stroke: ((
|
|
7245
|
-
opacity: ((
|
|
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: ((
|
|
7248
|
-
offsetY: ((
|
|
7249
|
-
blur: ((
|
|
7250
|
-
color: ((
|
|
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: ((
|
|
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 @@ const addRectElement = ({
|
|
|
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 @@ const useTwickCanvas = ({
|
|
|
7517
7555
|
const twickCanvasRef = useRef(null);
|
|
7518
7556
|
const videoSizeRef = useRef({ width: 1, height: 1 });
|
|
7519
7557
|
const canvasResolutionRef = useRef({ width: 1, height: 1 });
|
|
7558
|
+
const captionPropsRef = useRef(null);
|
|
7520
7559
|
const canvasMetadataRef = useRef({
|
|
7521
7560
|
width: 0,
|
|
7522
7561
|
height: 0,
|
|
@@ -7574,7 +7613,7 @@ const useTwickCanvas = ({
|
|
|
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 @@ const useTwickCanvas = ({
|
|
|
7601
7640
|
videoSizeRef.current
|
|
7602
7641
|
);
|
|
7603
7642
|
if (elementMap.current[elementId].type === "caption") {
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
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
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
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 @@ const useTwickCanvas = ({
|
|
|
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 @@ const useTwickCanvas = ({
|
|
|
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 @@ const useTwickCanvas = ({
|
|
|
7758
7823
|
}
|
|
7759
7824
|
switch (element.type) {
|
|
7760
7825
|
case ELEMENT_TYPES.VIDEO:
|
|
7761
|
-
const currentFrameEffect = getCurrentFrameEffect(
|
|
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 @@ const useTwickCanvas = ({
|
|
|
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 @@ const usePlayerManager = ({
|
|
|
7837
7913
|
videoProps
|
|
7838
7914
|
}) => {
|
|
7839
7915
|
const [projectData, setProjectData] = useState(null);
|
|
7840
|
-
const {
|
|
7916
|
+
const {
|
|
7917
|
+
timelineAction,
|
|
7918
|
+
setTimelineAction,
|
|
7919
|
+
setSelectedItem,
|
|
7920
|
+
editor,
|
|
7921
|
+
changeLog
|
|
7922
|
+
} = useTimelineContext();
|
|
7841
7923
|
const currentChangeLog = useRef(changeLog);
|
|
7924
|
+
const prevSeekTime = useRef(0);
|
|
7842
7925
|
const [playerUpdating, setPlayerUpdating] = useState(false);
|
|
7843
7926
|
const handleCanvasReady = (canvas) => {
|
|
7844
7927
|
console.log("canvas ready", canvas);
|
|
7845
7928
|
};
|
|
7846
7929
|
const handleCanvasOperation = (operation, data) => {
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
setSelectedItem(
|
|
7857
|
-
|
|
7858
|
-
|
|
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 = 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 @@ const usePlayerManager = ({
|
|
|
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 = 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 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 @@ const usePlayerManager = ({
|
|
|
7887
7985
|
}
|
|
7888
7986
|
};
|
|
7889
7987
|
useEffect(() => {
|
|
7890
|
-
var _a2, _b, _c, _d;
|
|
7988
|
+
var _a2, _b, _c, _d, _e2;
|
|
7891
7989
|
switch (timelineAction.type) {
|
|
7892
7990
|
case TIMELINE_ACTION.UPDATE_PLAYER_DATA:
|
|
7893
7991
|
if (videoProps) {
|
|
@@ -7901,6 +7999,11 @@ const usePlayerManager = ({
|
|
|
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_ACTION.ON_PLAYER_UPDATED, null);
|
|
7906
8009
|
}
|
|
@@ -9446,6 +9549,7 @@ function SeekTrack({
|
|
|
9446
9549
|
onClick: (e3) => handleSeek(e3.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 @@ function SeekTrack({
|
|
|
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 @@ const VideoEditor = ({
|
|
|
17898
18003
|
] })
|
|
17899
18004
|
] });
|
|
17900
18005
|
};
|
|
18006
|
+
const useEditorManager = () => {
|
|
18007
|
+
const { editor, selectedItem, setSelectedItem } = useTimelineContext();
|
|
18008
|
+
const { getCurrentTime } = useLivePlayerContext();
|
|
18009
|
+
const addElement = async (element) => {
|
|
18010
|
+
const currentTime = getCurrentTime();
|
|
18011
|
+
element.setStart(currentTime);
|
|
18012
|
+
try {
|
|
18013
|
+
if (selectedItem instanceof 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 ValidationError) {
|
|
18027
|
+
if (error.errors.includes(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 {
|
|
@@ -18258,6 +18411,7 @@ export {
|
|
|
18258
18411
|
VideoEditor as default,
|
|
18259
18412
|
getAnimationGif,
|
|
18260
18413
|
setElementColors,
|
|
18414
|
+
useEditorManager,
|
|
18261
18415
|
usePlayerControl,
|
|
18262
18416
|
useTimelineControl
|
|
18263
18417
|
};
|