mirror of
https://github.com/harness/drone.git
synced 2025-05-20 10:59:56 +08:00
feat: [code-1316]: add video support in comment box (#965)
This commit is contained in:
parent
123267c918
commit
634a70a833
@ -79,6 +79,7 @@ export const Editor = React.memo(function CodeMirrorReactEditor({
|
||||
const { getString } = useStrings()
|
||||
const view = useRef<EditorView>()
|
||||
const ref = useRef<HTMLDivElement>()
|
||||
const [fileData, setFile] = useState<File>()
|
||||
|
||||
const languageConfig = useMemo(() => new Compartment(), [])
|
||||
const [markdownContent, setMarkdownContent] = useState('')
|
||||
@ -103,7 +104,7 @@ export const Editor = React.memo(function CodeMirrorReactEditor({
|
||||
const updateContentWithoutStateChange = () => {
|
||||
setUploading(true)
|
||||
if (view.current && markdownContent && !inGitBlame) {
|
||||
const markdownInsert = ``
|
||||
const markdownInsert = fileData?.type.startsWith('image/') ? `` : `${markdownContent}`
|
||||
const range = view.current.state.selection.main
|
||||
const cursorPos = range.from
|
||||
const newCursorPos = cursorPos + markdownInsert.length
|
||||
@ -206,6 +207,7 @@ export const Editor = React.memo(function CodeMirrorReactEditor({
|
||||
}, [filename, forMarkdown, view, languageConfig, markdownLanguageSupport])
|
||||
const handleUploadCallback = (file: File) => {
|
||||
if (!inGitBlame) {
|
||||
setFile(file)
|
||||
handleUpload(file, setMarkdownContent, repoMetadata, showError, standalone, routingId)
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,7 @@ export function MarkdownEditorWithPreview({
|
||||
}
|
||||
|
||||
case ToolbarAction.UPLOAD: {
|
||||
setFile(undefined)
|
||||
setOpen(true)
|
||||
|
||||
break
|
||||
@ -303,7 +304,7 @@ export function MarkdownEditorWithPreview({
|
||||
useEffect(() => {
|
||||
const view = viewRef.current
|
||||
if (markdownContent && view) {
|
||||
const insertText = ``
|
||||
const insertText = file?.type.startsWith('image/') ? `` : `${markdownContent}`
|
||||
view.dispatch(
|
||||
view.state.changeByRange(range => ({
|
||||
changes: [{ from: range.from, insert: insertText }],
|
||||
@ -384,7 +385,6 @@ export function MarkdownEditorWithPreview({
|
||||
onClick={() => {
|
||||
handleUpload(file as File, setMarkdownContent, repoMetadata, showError, standalone, routingId)
|
||||
setOpen(false)
|
||||
setFile(undefined)
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
|
@ -852,7 +852,7 @@ enterBitbucketPlaceholder: https://bitbucket.org/
|
||||
changeRepoVis: Change repository visibility
|
||||
changeRepoVisContent: Are you sure you want to make this repository {repoVis}? {repoText}
|
||||
repoVisibility: Repository Visibility
|
||||
attachText: Attach images by dragging & dropping, selecting or pasting them.
|
||||
attachText: Attach images & videos by dragging & dropping, selecting or pasting them.
|
||||
key: Key
|
||||
setting: Setting
|
||||
mergeCommit: Merge commit
|
||||
|
@ -258,7 +258,7 @@ export const handlePaste = (event: { preventDefault: () => void; clipboardData:
|
||||
|
||||
if (items.length > 0) {
|
||||
const firstItem = items[0]
|
||||
if (firstItem.type.startsWith('image/')) {
|
||||
if (firstItem.type.startsWith('image/') || firstItem.type.startsWith('video/')) {
|
||||
const blob = firstItem.getAsFile()
|
||||
callback(blob)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user