Skip to content

Commit

Permalink
handleVideoUrl: Rename imageUrl to videoUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Jan 3, 2024
1 parent bc22e8f commit 98bb7c1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/common/form/QuillEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,26 @@ export function QuillEditor({ value, onChange }: QuillEditorProps) {
}

function handleVideoInsert() {
let imageUrl = prompt('Enter the URL of the video:') // for a better UX find a way to use the Quill Tooltip or a Modal box
if (!imageUrl) return
let videoUrl = prompt('Enter the URL of the video:') // for a better UX find a way to use the Quill Tooltip or a Modal box
if (!videoUrl) return

const editor = reactQuillRef.current?.getEditor()
if (!editor) return

const unprivilegedEditor = reactQuillRef.current?.makeUnprivilegedEditor(editor)
if (unprivilegedEditor) {
//check if the link is from google drive and if so, change the link to a direct link
const isYoutubeLink = imageUrl.match(
const isYoutubeLink = videoUrl.match(
/(youtu.*be.*)\/(watch\?v=|embed\/|v|shorts|)(.*?((?=[&#?])|$))/,
)
//if video is from youtube, use youtube embed URL
if (isYoutubeLink) {
const videoId = isYoutubeLink[3]
imageUrl = 'https://youtube.com/embed/' + videoId
videoUrl = 'https://youtube.com/embed/' + videoId
}

const range = unprivilegedEditor.getSelection(true)
editor.insertEmbed(range.index, 'video', imageUrl)
editor.insertEmbed(range.index, 'video', videoUrl)
}
}

Expand Down

0 comments on commit 98bb7c1

Please sign in to comment.