ahao 2024-01-06 17:27:01 +08:00
parent dfdcee9b95
commit 31da01bdd1

View File

@ -57,6 +57,7 @@ const upload = reactive<UploadOption>({
url: import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload'
});
const quillEditorRef = ref();
const uploadRef = ref<HTMLDivElement>();
const options = ref<any>({
theme: 'snow',
@ -66,27 +67,27 @@ const options = ref<any>({
//
toolbar: {
container: [
["bold", "italic", "underline", "strike"], // 线 线
["blockquote", "code-block"], //
[{ list: "ordered" }, { list: "bullet" }], //
[{ indent: "-1" }, { indent: "+1" }], //
[{ size: ["small", false, "large", "huge"] }], //
[{ header: [1, 2, 3, 4, 5, 6, false] }], //
[{ color: [] }, { background: [] }], //
[{ align: [] }], //
["clean"], //
["link", "image", "video"] //
['bold', 'italic', 'underline', 'strike'], // 线 线
['blockquote', 'code-block'], //
[{ list: 'ordered' }, { list: 'bullet' }], //
[{ indent: '-1' }, { indent: '+1' }], //
[{ size: ['small', false, 'large', 'huge'] }], //
[{ header: [1, 2, 3, 4, 5, 6, false] }], //
[{ color: [] }, { background: [] }], //
[{ align: [] }], //
['clean'], //
['link', 'image', 'video'] //
],
handlers: {
image: function (value: any) {
image: (value: boolean) => {
if (value) {
// element
proxy?.$refs.uploadRef.click();
uploadRef.value.click();
} else {
Quill.format("image", true);
Quill.format('image', true);
}
},
},
}
}
}
},
placeholder: '请输入内容',
@ -107,7 +108,7 @@ const styles = computed(() => {
const content = ref('');
watch(
() => props.modelValue,
(v) => {
(v: string) => {
if (v !== content.value) {
content.value = v === undefined ? '<p></p>' : v;
}
@ -129,7 +130,7 @@ const handleUploadSuccess = (res: any) => {
quill.setSelection(length + 1);
proxy?.$modal.closeLoading();
} else {
proxy?.$modal.msgError("图片插入失败");
proxy?.$modal.msgError('图片插入失败');
proxy?.$modal.closeLoading();
}
};