feat: 🚀 切换富文本编辑器

This commit is contained in:
2025-05-07 17:55:49 +08:00
parent 4bd5797772
commit ab003714bf
28 changed files with 1145 additions and 132 deletions

View File

@@ -20,7 +20,7 @@ import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
import { uploadImg, uploadVideo } from "@/api/modules/upload";
import "@wangeditor/editor/dist/css/style.css";
import { formContextKey, formItemContextKey } from "element-plus";
// import { cloneDeep } from "lodash-es";
// 富文本 DOM 元素
const editorRef = shallowRef();
@@ -28,6 +28,8 @@ const editorRef = shallowRef();
const handleCreated = (editor: any) => {
editorRef.value = editor;
};
console.log(editorRef.value, "=editorRef.value=");
const $router = useRouter();
const routerValueName: string = $router.currentRoute.value.name as string;
const routerObj: any = {
@@ -55,12 +57,23 @@ const props = withDefaults(defineProps<RichEditorProps>(), {
excludeKeys: []
};
},
editorConfig: () => {
return {
placeholder: "请输入内容...",
MENU_CONF: {}
// parseElemHtml: (elemHtml: string, elem: HTMLElement, editor: any) => {
// console.log(editor, "========editor=========");
// console.log(elem.tagName, "=elem.tagName=");
// if (elem.tagName === "SPAN" && elem.querySelector("img")) {
// // 确保 span 元素可以正确显示 img
// elem.style.display = "inline-block";
// }
// return elemHtml;
// }
};
},
height: "500px",
mode: "default",
hideToolBar: false,
@@ -84,7 +97,9 @@ type EmitProps = {
(e: "update:value", val: string): void;
(e: "check-validate"): void;
};
const emit = defineEmits<EmitProps>();
const valueHtml = computed({
get() {
return props.value;
@@ -112,7 +127,6 @@ props.editorConfig.MENU_CONF!["uploadImage"] = {
const result = await uploadImg(formData, routerName.value);
if (result?.code === 0) {
const { data } = result;
console.log(data, "==============data====================");
insertFn(import.meta.env.VITE_APP_API_BASE_UPLOAD_URL + data.path);
}
} catch (error) {