@seafile/sdoc-editor 1.0.206-test0.2.7 → 1.0.206-test0.2.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.
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.videoFileIcon = exports.isInsertVideoMenuDisabled = exports.insertVideo = exports.getVideoURL = exports.generateVideoNode = exports.formatFileSize = void 0;
7
+ exports.videoFileIcon = exports.parseVideoLink = exports.isInsertVideoMenuDisabled = exports.insertVideo = exports.getVideoURL = exports.generateVideoNode = exports.formatFileSize = void 0;
8
8
  var _urlJoin = _interopRequireDefault(require("url-join"));
9
9
  var _slate = require("@seafile/slate");
10
10
  var _core = require("../../core");
@@ -54,16 +54,45 @@ const generateVideoNode = (src, videoFiles) => {
54
54
  };
55
55
  };
56
56
  exports.generateVideoNode = generateVideoNode;
57
+ const parseVideoLink = url => {
58
+ if (!url) return false;
59
+
60
+ // Youtube url conversion
61
+ if (url.includes('youtube.com')) {
62
+ const videoId = new URL(url).searchParams.get('v');
63
+ const videoUrl = videoId ? `https://www.youtube.com/embed/${videoId}/?rel=0` : false;
64
+ return videoUrl;
65
+ }
66
+
67
+ // Tencent url conversion
68
+ if (url.includes('v.qq.com')) {
69
+ const vidMatch = url.match(/\/([^\/]+)\.html$/);
70
+ const videoUrl = vidMatch !== null && vidMatch !== void 0 && vidMatch[1] ? `https://v.qq.com/txp/iframe/player.html?vid=${vidMatch[1]}` : false;
71
+ return videoUrl;
72
+ }
73
+
74
+ // Unsupported url
75
+ return false;
76
+ };
77
+ exports.parseVideoLink = parseVideoLink;
57
78
  const insertVideo = function (editor, videoFiles, srcList, selection) {
79
+ var _videoFiles$;
58
80
  let position = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _constants.INSERT_POSITION.CURRENT;
59
81
  if (!srcList) return;
60
82
  if (position !== _constants.INSERT_POSITION.AFTER) {
61
83
  if (isInsertVideoMenuDisabled(editor)) return;
62
84
  }
63
- console.log('helper', videoFiles, srcList);
64
- const videoNodes = srcList.map(src => {
65
- return generateVideoNode(src, videoFiles);
66
- });
85
+ let videoNodes;
86
+ // Parse youtube and tencent video url when embed thirdPlatform link
87
+ if (Array.isArray(videoFiles) && (_videoFiles$ = videoFiles[0]) !== null && _videoFiles$ !== void 0 && _videoFiles$.isEmbeddableLink) {
88
+ const parsedSrc = parseVideoLink(srcList[0]);
89
+ if (!parsedSrc) return;
90
+ videoNodes = generateVideoNode(parsedSrc, videoFiles);
91
+ } else {
92
+ videoNodes = srcList.map(src => {
93
+ return generateVideoNode(src, videoFiles);
94
+ });
95
+ }
67
96
  const validSelection = selection || editor.selection;
68
97
  let path = _slate.Editor.path(editor, validSelection);
69
98
  if (position === _constants.INSERT_POSITION.AFTER) {
@@ -50,7 +50,7 @@
50
50
  .sdoc-video-wrapper .sdoc-video-inner {
51
51
  position: relative;
52
52
  width: 100%;
53
- aspect-ratio: 1.6;
53
+ aspect-ratio: 16 / 9;
54
54
  display: flex;
55
55
  margin-top: 5px;
56
56
  margin-bottom: 10px;
@@ -60,6 +60,15 @@
60
60
  width: 100%;
61
61
  }
62
62
 
63
+ /* .sdoc-video-element canvas {
64
+ position: fixed;
65
+ top: 0;
66
+ left: 0;
67
+ width: 100vw;
68
+ height: 100vh;
69
+ object-fit: contain;
70
+ } */
71
+
63
72
  .sdoc-video-inner .sdoc-video-element:focus-visible {
64
73
  outline: none;
65
74
  }
@@ -27,7 +27,7 @@ const Video = _ref => {
27
27
  const videoFileName = data.videoFiles && ((_data$videoFiles$ = data.videoFiles[0]) === null || _data$videoFiles$ === void 0 ? void 0 : _data$videoFiles$.name) || null;
28
28
  const videoFileSize = data.videoFiles && ((_data$videoFiles$2 = data.videoFiles[0]) === null || _data$videoFiles$2 === void 0 ? void 0 : _data$videoFiles$2.size) || null;
29
29
  const isEmbeddableLink = data.videoFiles && ((_data$videoFiles$3 = data.videoFiles[0]) === null || _data$videoFiles$3 === void 0 ? void 0 : _data$videoFiles$3.isEmbeddableLink) || false;
30
- console.log(55, isEmbeddableLink, (0, _helpers.getVideoURL)(data));
30
+ console.log(55, data.videoFiles, isEmbeddableLink, (0, _helpers.getVideoURL)(data));
31
31
  const handlePlay = () => {
32
32
  setVideoStates(prev => ({
33
33
  ...prev,
@@ -69,6 +69,25 @@ const Video = _ref => {
69
69
  document.removeEventListener('click', onClickOutside);
70
70
  };
71
71
  }, [onClickOutside]);
72
+ (0, _react.useEffect)(() => {
73
+ const enterFullscreen = () => {
74
+ if (videoRef.current) {
75
+ const iframeElement = videoRef.current;
76
+ console.log(333);
77
+ if (iframeElement.requestFullscreen) {
78
+ iframeElement.requestFullscreen();
79
+ } else if (iframeElement.webkitRequestFullscreen) {
80
+ iframeElement.webkitRequestFullscreen(); // Safari
81
+ } else if (iframeElement.mozRequestFullScreen) {
82
+ iframeElement.mozRequestFullScreen(); // Firefox
83
+ } else if (iframeElement.msRequestFullscreen) {
84
+ iframeElement.msRequestFullscreen(); // IE/Edge
85
+ }
86
+ }
87
+ };
88
+
89
+ // enterFullscreen();
90
+ }, []);
72
91
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !isLoaded && /*#__PURE__*/_react.default.createElement("div", {
73
92
  className: "video-loading-placeholder"
74
93
  }, /*#__PURE__*/_react.default.createElement("img", {
@@ -94,7 +113,7 @@ const Video = _ref => {
94
113
  style: {
95
114
  visibility: isLoaded ? 'visible' : 'hidden'
96
115
  }
97
- }, !isEmbeddableLink && /*#__PURE__*/_react.default.createElement("video", {
116
+ }, !isEmbeddableLink && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("video", {
98
117
  className: "sdoc-video-element",
99
118
  ref: videoRef,
100
119
  src: (0, _helpers.getVideoURL)(data),
@@ -107,27 +126,20 @@ const Video = _ref => {
107
126
  style: {
108
127
  boxShadow: isSelected ? '0 0 0 2px #007bff' : 'none'
109
128
  }
110
- }), isEmbeddableLink && /*#__PURE__*/_react.default.createElement("iframe", {
111
- className: "sdoc-video-element",
112
- ref: videoRef,
113
- src: (0, _helpers.getVideoURL)(data),
114
- onClick: onClickVideo,
115
- draggable: false,
116
- onPlay: handlePlay,
117
- onPause: handlePause,
118
- onLoad: handleVideoLoad,
119
- title: data.src,
120
- allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
121
- allowFullScreen: true,
122
- style: {
123
- boxShadow: isSelected ? '0 0 0 2px #007bff' : 'none'
124
- }
125
129
  }), /*#__PURE__*/_react.default.createElement("div", {
126
130
  className: "sdoc-video-play sdocfont sdoc-play icon-font",
127
131
  style: {
128
132
  visibility: isPaused ? 'visible' : 'hidden'
129
133
  },
130
134
  contentEditable: "false"
135
+ })), isEmbeddableLink && /*#__PURE__*/_react.default.createElement("iframe", {
136
+ className: "sdoc-video-element",
137
+ ref: videoRef,
138
+ title: data.src,
139
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
140
+ allowFullScreen: true,
141
+ src: (0, _helpers.getVideoURL)(data),
142
+ onLoad: handleVideoLoad
131
143
  }))));
132
144
  };
133
145
  const SdocVideo = (0, _reactI18next.withTranslation)('sdoc-editor')(Video);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.206-test0.2.7",
3
+ "version": "1.0.206-test0.2.9",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",