@seafile/sdoc-editor 1.0.206-test0.2.8 → 1.0.206-test0.3.0
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,49 @@ const generateVideoNode = (src, videoFiles) => {
|
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
exports.generateVideoNode = generateVideoNode;
|
|
57
|
+
const parseVideoLink = url => {
|
|
58
|
+
if (!url) return false;
|
|
59
|
+
console.log(0, url);
|
|
60
|
+
|
|
61
|
+
// Youtube url conversion
|
|
62
|
+
if (url.includes('youtube.com')) {
|
|
63
|
+
const videoId = new URL(url).searchParams.get('v');
|
|
64
|
+
const videoUrl = videoId ? `https://www.youtube.com/embed/${videoId}/?rel=0` : false;
|
|
65
|
+
console.log(videoUrl);
|
|
66
|
+
return videoUrl;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Tencent url conversion
|
|
70
|
+
if (url.includes('v.qq.com')) {
|
|
71
|
+
const vidMatch = url.match(/\/([^\/]+)\.html$/);
|
|
72
|
+
const videoUrl = vidMatch !== null && vidMatch !== void 0 && vidMatch[1] ? `https://v.qq.com/txp/iframe/player.html?vid=${vidMatch[1]}` : false;
|
|
73
|
+
console.log(videoUrl);
|
|
74
|
+
return videoUrl;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Unsupported url
|
|
78
|
+
return false;
|
|
79
|
+
};
|
|
80
|
+
exports.parseVideoLink = parseVideoLink;
|
|
57
81
|
const insertVideo = function (editor, videoFiles, srcList, selection) {
|
|
82
|
+
var _videoFiles$;
|
|
58
83
|
let position = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _constants.INSERT_POSITION.CURRENT;
|
|
59
84
|
if (!srcList) return;
|
|
60
85
|
if (position !== _constants.INSERT_POSITION.AFTER) {
|
|
61
86
|
if (isInsertVideoMenuDisabled(editor)) return;
|
|
62
87
|
}
|
|
63
|
-
console.log(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
console.log(videoFiles, srcList);
|
|
89
|
+
let videoNodes;
|
|
90
|
+
// Parse youtube and tencent video url when embed thirdPlatform link
|
|
91
|
+
if (Array.isArray(videoFiles) && (_videoFiles$ = videoFiles[0]) !== null && _videoFiles$ !== void 0 && _videoFiles$.isEmbeddableLink) {
|
|
92
|
+
const parsedSrc = parseVideoLink(srcList[0]);
|
|
93
|
+
if (!parsedSrc) return;
|
|
94
|
+
videoNodes = generateVideoNode(parsedSrc, videoFiles);
|
|
95
|
+
} else {
|
|
96
|
+
videoNodes = srcList.map(src => {
|
|
97
|
+
return generateVideoNode(src, videoFiles);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
67
100
|
const validSelection = selection || editor.selection;
|
|
68
101
|
let path = _slate.Editor.path(editor, validSelection);
|
|
69
102
|
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:
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
141
|
+
src: (0, _helpers.getVideoURL)(data),
|
|
142
|
+
onLoad: handleVideoLoad
|
|
134
143
|
}))));
|
|
135
144
|
};
|
|
136
145
|
const SdocVideo = (0, _reactI18next.withTranslation)('sdoc-editor')(Video);
|