This commit is contained in:
parent
23525d5ba1
commit
1b354d464c
@ -132,14 +132,26 @@
|
||||
initCheckImageIndex();
|
||||
}
|
||||
|
||||
// 영상 넣기.
|
||||
// 퍼온 영상 넣기
|
||||
quillInstance.getModule('toolbar').addHandler('video', () => {
|
||||
const url = prompt('영상 URL을 입력하세요:');
|
||||
if (url) {
|
||||
// 에디터에 iframe 형태로 영상 삽입
|
||||
const index = quillInstance.getSelection().index; // 현재 커서 위치
|
||||
quillInstance.insertEmbed(index, 'video', url);
|
||||
quillInstance.setSelection(index + 1); // 커서를 삽입된 콘텐츠 뒤로 이동
|
||||
const url = prompt('iframe 태그가 포함된 주소를 입력해 주세요:');
|
||||
if (url && url.indexOf('<iframe') != -1) {
|
||||
//debugger;
|
||||
//예시 <iframe width="560" height="315" src="https://www.youtube.com/embed/-nSHIYz5SOM?si=o5aVCkG8CfCeNvHY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
|
||||
//가라로 추출이라 불안정 할듯
|
||||
|
||||
// DOMParser를 사용하여 embeded url만 추출
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(url, 'text/html');
|
||||
const iframeEL = doc.querySelector('iframe');
|
||||
const src = iframeEL.getAttribute('src');
|
||||
const width = iframeEL.getAttribute('width');
|
||||
const height = iframeEL.getAttribute('height');
|
||||
|
||||
// 에디터에 삽입
|
||||
const index = quillInstance.getSelection().index;
|
||||
quillInstance.insertEmbed(index, 'video', src);
|
||||
quillInstance.setSelection(index + 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user