...
This commit is contained in:
@@ -99,20 +99,34 @@ function save() {
|
||||
}
|
||||
|
||||
function selectLocalImage() {
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute('type', 'file');
|
||||
input.setAttribute('accept', 'image/*');
|
||||
input.click();
|
||||
console.log("on selectLocalImage")
|
||||
input.onchange = () => {
|
||||
const file = input.files[0];
|
||||
console.log("on selectLocalImage File", file);
|
||||
if (!file || !file.type.startsWith('image/')) {
|
||||
console.warn('이미지 파일만 업로드 가능합니다.');
|
||||
return;
|
||||
}
|
||||
uploadImage(file);
|
||||
};
|
||||
// 이미지 URL 입력 받기
|
||||
const url = prompt("이미지 URL을 입력하거나 빈칸으로 두시면 파일 업로드를 합니다.");
|
||||
|
||||
if (url) {
|
||||
// URL이 입력된 경우 이미지 삽입
|
||||
const range = quill.getSelection(true);
|
||||
quill.insertEmbed(range.index, 'image', url);
|
||||
quill.setSelection(range.index + 1);
|
||||
} else {
|
||||
// URL이 없거나 취소한 경우 파일 업로드 처리
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute('type', 'file');
|
||||
input.setAttribute('accept', 'image/*');
|
||||
input.click();
|
||||
|
||||
input.onchange = async () => {
|
||||
const file = input.files[0];
|
||||
if (file) {
|
||||
const file = input.files[0];
|
||||
console.log("on selectLocalImage File", file);
|
||||
if (!file || !file.type.startsWith('image/')) {
|
||||
console.warn('이미지 파일만 업로드 가능합니다.');
|
||||
return;
|
||||
}
|
||||
uploadImage(file);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function uploadImage(blob) {
|
||||
|
||||
Reference in New Issue
Block a user