@layers-app/editor-video 0.1.3 → 0.1.5

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.d.ts CHANGED
@@ -6,4 +6,6 @@ export { INSERT_VIDEO_COMMAND, UPLOAD_VIDEO_COMMAND, parseVideoURL, getVideoIfra
6
6
  export { VideoPluginProvider, useVideoPluginContext, useVideoPluginDependencies, useVideoPluginConfig, } from './context';
7
7
  export { VideoPlugin } from './plugin';
8
8
  export { insertVideoNode, applyVideoSource, setVideoSize, setVideoPoster, setVideoPrimaryUrl, setVideoChaptersDisabled, removeVideoNode, } from './plugin/behaviour';
9
+ export { VideoPlayerState } from './ui/states/VideoPlayerState';
10
+ export { useVideoStatus } from './ui/hooks/useVideoStatus';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,GAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,GAChB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,GAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -168,16 +168,7 @@ function getVideoIframeUrl(platform, id) {
168
168
  url = `https://www.youtube-nocookie.com/embed/${id}`;
169
169
  break;
170
170
  case "download":
171
- if (!id.includes("/")) {
172
- const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
173
- if (uuidRegex.test(id)) {
174
- url = `/v1/attachments/${id}`;
175
- } else {
176
- url = `${id}`;
177
- }
178
- } else {
179
- url = `${id}`;
180
- }
171
+ url = id;
181
172
  break;
182
173
  case "vk":
183
174
  const ids = id.split("-");
@@ -3564,6 +3555,7 @@ function getSubtitleUrl(track, baseUrl) {
3564
3555
  }
3565
3556
  function VideoPlayerState({
3566
3557
  videoId,
3558
+ language,
3567
3559
  baseUrl,
3568
3560
  videoUrl,
3569
3561
  primaryUrl,
@@ -3575,7 +3567,7 @@ function VideoPlayerState({
3575
3567
  posterUrl,
3576
3568
  onPlayerInfo
3577
3569
  }) {
3578
- const { t } = useTranslation();
3570
+ const { t, i18n } = useTranslation();
3579
3571
  const [currentVideoUrl, setCurrentVideoUrl] = useState(null);
3580
3572
  const [currentNativeVideoUrl, setCurrentNativeVideoUrl] = useState(null);
3581
3573
  const [playerError, setPlayerError] = useState(null);
@@ -3600,6 +3592,13 @@ function VideoPlayerState({
3600
3592
  const shakaAddedIdsRef = useRef([]);
3601
3593
  const shakaFilterRegisteredRef = useRef(false);
3602
3594
  const subtitlesFetchedRef = useRef(false);
3595
+ useEffect(() => {
3596
+ if (!language) {
3597
+ return;
3598
+ }
3599
+ i18n.changeLanguage(language).catch(() => {
3600
+ });
3601
+ }, [language]);
3603
3602
  useEffect(() => {
3604
3603
  if (!videoId) {
3605
3604
  setSubtitleTracks([]);
@@ -4411,7 +4410,7 @@ function VideoUploadComponent({
4411
4410
  }) {
4412
4411
  var _a, _b;
4413
4412
  const [editor] = useLexicalComposerContext();
4414
- const { t } = useTranslation();
4413
+ const { t, i18n } = useTranslation();
4415
4414
  const { config, registerUpload, unregisterUpload, reportError } = useVideoPluginContext();
4416
4415
  const { maxFileSize = 5, pageId } = config;
4417
4416
  const [currentState, setCurrentState] = useState(
@@ -4517,7 +4516,7 @@ function VideoUploadComponent({
4517
4516
  const subtitles = subtitlesOverride ?? (resolvedStatus == null ? void 0 : resolvedStatus.subtitles) ?? void 0;
4518
4517
  const inferredNativeVideoUrl = useMemo(() => {
4519
4518
  if (fallbackNativeVideoUrl) return fallbackNativeVideoUrl;
4520
- if (platform === "download" || platform === "link") {
4519
+ if (platform === "link") {
4521
4520
  const id = videoId ?? initialVideoId;
4522
4521
  if (id) {
4523
4522
  return getVideoIframeUrl(platform, id);
@@ -4809,6 +4808,7 @@ function VideoUploadComponent({
4809
4808
  VideoPlayerState,
4810
4809
  {
4811
4810
  videoId,
4811
+ language: i18n.resolvedLanguage || i18n.language,
4812
4812
  videoUrl: resolvedVideoUrl,
4813
4813
  primaryUrl: resolvedPrimaryUrl,
4814
4814
  optimizedReady: resolvedOptimizedReady,
@@ -6728,7 +6728,7 @@ function convertVideoElement(domNode) {
6728
6728
  }
6729
6729
  return { node };
6730
6730
  }
6731
- const platform = platformAttr || ((src == null ? void 0 : src.startsWith("/v1/attachments/")) ? "download" : null);
6731
+ const platform = platformAttr || null;
6732
6732
  const resolvedId = (typeof videoIdAttr === "string" && videoIdAttr.length > 0 ? videoIdAttr : null) || src || null;
6733
6733
  if (platform && resolvedId) {
6734
6734
  const node = $createVideoNode(
@@ -7001,9 +7001,6 @@ function $createVideoNode(url, width, height, alignment, create) {
7001
7001
  alignment,
7002
7002
  create
7003
7003
  );
7004
- if (platform === "download" && url.startsWith("/")) {
7005
- node.setUrl(url);
7006
- }
7007
7004
  return node;
7008
7005
  }
7009
7006
  function $isVideoNode(node) {
@@ -7122,6 +7119,7 @@ export {
7122
7119
  INSERT_VIDEO_COMMAND,
7123
7120
  UPLOAD_VIDEO_COMMAND,
7124
7121
  VideoNode,
7122
+ VideoPlayerState,
7125
7123
  VideoPlugin,
7126
7124
  VideoPluginProvider,
7127
7125
  applyVideoSource,
@@ -7138,6 +7136,7 @@ export {
7138
7136
  useVideoPluginConfig,
7139
7137
  useVideoPluginContext,
7140
7138
  useVideoPluginDependencies,
7139
+ useVideoStatus,
7141
7140
  videoPlugin
7142
7141
  };
7143
7142
  //# sourceMappingURL=index.js.map