修改管理系统中学术交流部分
This commit is contained in:
@@ -472,9 +472,22 @@ const initQuillEditor = () => {
|
||||
quillInstance.root.innerHTML = form.value.intro;
|
||||
}
|
||||
|
||||
quillInstance.on('text-change', (_, __, source) => {
|
||||
quillInstance.on('text-change', (delta, _, source) => {
|
||||
if (source === 'user') {
|
||||
form.value.intro = quillInstance?.root.innerHTML || '';
|
||||
const pastedBase64 = getPastedBase64Image(delta);
|
||||
if (pastedBase64) {
|
||||
const selection = quillInstance?.getSelection();
|
||||
if (!selection) return;
|
||||
|
||||
const imageIndex = selection.index;
|
||||
quillInstance?.deleteText(imageIndex, 1);
|
||||
const blob = base64ToBlob(pastedBase64);
|
||||
|
||||
if (blob) {
|
||||
const file = new File([blob], `pasted-image-${Date.now()}.png`, { type: blob.type });
|
||||
uploadEditorImage(file, imageIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -699,7 +712,6 @@ async function uploadEditorImage(file: File, insertIndex: number) {
|
||||
quillInstance.deleteText(insertIndex, '[图片上传中...]'.length);
|
||||
quillInstance.insertEmbed(insertIndex, 'image', imageUrl);
|
||||
quillInstance.setSelection(insertIndex + 1);
|
||||
form.value.intro = quillInstance.root.innerHTML;
|
||||
|
||||
} catch (err) {
|
||||
const errMsg = err instanceof Error ? err.message : '未知错误';
|
||||
|
||||
Reference in New Issue
Block a user