This commit is contained in:
quantulr
2022-10-19 00:22:03 +08:00
parent 656b6ef510
commit fd5e278fa7
12 changed files with 477 additions and 139 deletions

View File

@ -28,7 +28,8 @@ import {
watch,
} from "vue";
import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
import request from "@/utils/request";
import { getToken } from "@/utils/auth";
export default {
components: { Editor, Toolbar },
props: {
@ -76,26 +77,45 @@ export default {
);
const { height } = toRefs(props);
const toolbarConfig = {
toolbarKeys: [
"bold",
"underline",
"italic",
"through",
"color",
"bgColor",
"fontSize",
"fontFamily",
"lineHeight",
// "emotion",
// "redo",
// "undo",
],
// toolbarKeys: [
// "bold",
// "underline",
// "italic",
// "through",
// "color",
// "bgColor",
// "fontSize",
// "fontFamily",
// "lineHeight",
// "uploadImage",
// // "emotion",
// // "redo",
// // "undo",
// ],
};
const editorConfig = {
placeholder: "请输入内容...",
autoFocus: props.focus,
maxLength: 140,
readOnly: props.readOnly,
MENU_CONF: {
uploadImage: {
async customUpload(file, insertFn) {
const fd = new FormData();
fd.append("file", file);
const resp = await request({
url: "/common/upload",
method: "post",
data: fd,
headers: {
Authorization: "Bearer " + getToken(),
},
});
insertFn(resp.url, "", resp.url);
},
},
},
};
onMounted(() => {
// console.log(editorRef.value.getConfig());
@ -110,6 +130,7 @@ export default {
const handleCreated = (editor) => {
editorRef.value = editor; // 记录 editor 实例,重要!
console.log(editorRef.value.getAllMenuKeys());
};
const handleChange = (editor) => {