diff --git a/frontend/src/components/dialog/add-video-link-dialog.js b/frontend/src/components/dialog/add-video-link-dialog.js deleted file mode 100644 index 56559719b63..00000000000 --- a/frontend/src/components/dialog/add-video-link-dialog.js +++ /dev/null @@ -1,95 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { Button, Modal, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Alert } from 'reactstrap'; -import { gettext } from '../../utils/constants'; -import SeahubModalHeader from '@/components/common/seahub-modal-header'; - -const propTypes = { - onAddLink: PropTypes.func.isRequired, - toggleDialog: PropTypes.func.isRequired, -}; - -class AddVideoLink extends React.Component { - constructor(props) { - super(props); - this.state = { - videoLink: '', - errMessage: '', - isSubmitBtnActive: false, - }; - this.newInput = React.createRef(); - } - - isValidVideoLink = (link) => { - const videoRegex = /v\.qq\.com|youtube\.com|v\.youku\.com|bilibili\.com/i; - return videoRegex.test(link); - }; - - handleChange = (e) => { - const videoLink = e.target.value.trim(); - const isValid = this.isValidVideoLink(videoLink); - - if (!e.target.value.trim()) { - this.setState({ isSubmitBtnActive: false }); - } - - this.setState({ - videoLink: videoLink, - isSubmitBtnActive: isValid, - errMessage: isValid ? '' : gettext('Please enter a valid video URL.'), - }); - - }; - - handleSubmit = () => { - if (!this.state.isSubmitBtnActive) return; - this.props.onAddLink(this.state.videoLink); - this.props.toggleDialog(); - }; - - handleKeyDown = (e) => { - if (e.key === 'Enter') { - this.handleSubmit(); - e.preventDefault(); - } - }; - - onAfterModelOpened = () => { - if (!this.newInput.current) return; - this.newInput.current.focus(); - this.newInput.current.setSelectionRange(0, 0); - }; - - render() { - const { toggleDialog } = this.props; - return ( - - {gettext('Insert_link')} - - - - {gettext('Link_address')} - - - - {gettext('Support Youtube, Tencent, Bilibili and more')} - {this.state.errMessage && {this.state.errMessage}} - - - {gettext('Cancel')} - {gettext('Submit')} - - - ); - } -} - -AddVideoLink.propTypes = propTypes; - -export default AddVideoLink; diff --git a/frontend/src/pages/sdoc/sdoc-editor/external-operations.js b/frontend/src/pages/sdoc/sdoc-editor/external-operations.js index 67f7c994b44..e1918e2fc07 100644 --- a/frontend/src/pages/sdoc/sdoc-editor/external-operations.js +++ b/frontend/src/pages/sdoc/sdoc-editor/external-operations.js @@ -7,7 +7,6 @@ import toaster from '../../../components/toast'; import InternalLinkDialog from '../../../components/dialog/internal-link-dialog'; import ShareDialog from '../../../components/dialog/share-dialog'; import CreateFile from '../../../components/dialog/create-file-dialog'; -import AddVideoLink from '../../../components/dialog/add-video-link-dialog'; const propTypes = { repoID: PropTypes.string.isRequired, @@ -34,8 +33,6 @@ class ExternalOperations extends React.Component { fileType: '.sdoc', editor: null, insertSdocFileLink: null, - isShowAddVideoLinkDialog: false, - insertVideo: null }; } @@ -49,7 +46,6 @@ class ExternalOperations extends React.Component { this.unsubscribeNewNotification = eventBus.subscribe(EXTERNAL_EVENT.NEW_NOTIFICATION, this.onNewNotification); this.unsubscribeClearNotification = eventBus.subscribe(EXTERNAL_EVENT.CLEAR_NOTIFICATION, this.onClearNotification); this.unsubscribeCreateSdocFile = eventBus.subscribe(EXTERNAL_EVENT.CREATE_SDOC_FILE, this.onCreateSdocFile); - this.unsubscribeAddVideoLink = eventBus.subscribe(EXTERNAL_EVENT.ADD_VIDEO_LINK, this.onAddVideoLink); } componentWillUnmount() { @@ -62,18 +58,8 @@ class ExternalOperations extends React.Component { this.unsubscribeNewNotification(); this.unsubscribeCreateSdocFile(); this.unsubscribeClearNotification(); - this.unsubscribeAddVideoLink(); } - onAddVideoLink = (params) => { - if (params?.editor && params?.insertVideo) { - this.setState({ editor: params.editor, insertVideo: params.insertVideo }); - } - this.setState({ - isShowAddVideoLinkDialog: !this.state.isShowAddVideoLinkDialog - }); - }; - onInternalLinkToggle = (options) => { if (options && options.internalLink) { this.setState({ internalLink: options.internalLink }); @@ -178,16 +164,9 @@ class ExternalOperations extends React.Component { }); }; - onAddLink = (videoLink) => { - const { insertVideo, editor } = this.state; - if (insertVideo && editor) { - insertVideo(editor, [{ isEmbeddableLink: true }], [videoLink]); - } - }; - render() { const { repoID, docPath, docName, docPerm, dirPath } = this.props; - const { isShowInternalLinkDialog, isShowShareDialog, internalLink, isShowCreateFileDialog, fileType, isShowAddVideoLinkDialog } = this.state; + const { isShowInternalLinkDialog, isShowShareDialog, internalLink, isShowCreateFileDialog, fileType } = this.state; return ( <> {isShowInternalLinkDialog && ( @@ -217,12 +196,6 @@ class ExternalOperations extends React.Component { toggleDialog={this.onCreateSdocFile} /> )} - {isShowAddVideoLinkDialog && ( - - )} > ); }