@seafile/sdoc-editor 1.0.206-test0.2.8 → 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
  }
@@ -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", {
@@ -113,24 +132,14 @@ const Video = _ref => {
113
132
  visibility: isPaused ? 'visible' : 'hidden'
114
133
  },
115
134
  contentEditable: "false"
116
- })), isEmbeddableLink &&
117
- /*#__PURE__*/
118
- // <center>
119
- _react.default.createElement("iframe", {
135
+ })), isEmbeddableLink && /*#__PURE__*/_react.default.createElement("iframe", {
120
136
  className: "sdoc-video-element",
121
137
  ref: videoRef,
122
- src: (0, _helpers.getVideoURL)(data),
123
- onClick: onClickVideo,
124
- draggable: false,
125
- onPlay: handlePlay,
126
- onPause: handlePause,
127
- onLoad: handleVideoLoad,
128
138
  title: data.src,
129
139
  allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
130
140
  allowFullScreen: true,
131
- style: {
132
- boxShadow: isSelected ? '0 0 0 2px #007bff' : 'none'
133
- }
141
+ src: (0, _helpers.getVideoURL)(data),
142
+ onLoad: handleVideoLoad
134
143
  }))));
135
144
  };
136
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.8",
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",