|
@@ -18,7 +18,7 @@
|
|
|
@onChange="handleChange"
|
|
@onChange="handleChange"
|
|
|
/>
|
|
/>
|
|
|
<!-- 隐藏的图片上传input -->
|
|
<!-- 隐藏的图片上传input -->
|
|
|
- <input type="file" ref="imageUploadRef" accept="image/*" style="display: none" @change="handleImageUpload" />
|
|
|
|
|
|
|
+ <!-- <input type="file" ref="imageUploadRef" accept="image/*" style="display: none" @change="handleImageUpload" /> -->
|
|
|
</div>
|
|
</div>
|
|
|
<AIModal
|
|
<AIModal
|
|
|
v-if="show_ai_modal"
|
|
v-if="show_ai_modal"
|
|
@@ -32,34 +32,55 @@
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import '@wangeditor/editor/dist/css/style.css'; // 引入 css
|
|
import '@wangeditor/editor/dist/css/style.css'; // 引入 css
|
|
|
|
|
|
|
|
-import { onBeforeUnmount, ref, shallowRef, onMounted, watch, nextTick } from 'vue';
|
|
|
|
|
|
|
+import { onBeforeUnmount, ref, shallowRef, onMounted, watch, nextTick, computed } from 'vue';
|
|
|
import { Editor, Toolbar } from '@wangeditor/editor-for-vue';
|
|
import { Editor, Toolbar } from '@wangeditor/editor-for-vue';
|
|
|
-import RobotIcon from '../../assets/tray-icon.png';
|
|
|
|
|
|
|
+// import RobotIcon from '../../assets/tray-icon.png';
|
|
|
|
|
+import RobotIcon_a from '../../assets/icon-robot/icon_green_a-1.png';
|
|
|
|
|
+import RobotIcon_b from '../../assets/icon-robot/icon_blue_b-1.png';
|
|
|
|
|
+import RobotIcon_c from '../../assets/icon-robot/icon_blue_c-1.png';
|
|
|
|
|
+import { THEME_LIGHT, THEME_DARK, THEME_GREEN, THEME_PARTY } from '../../base/variables';
|
|
|
import { str_html } from './text';
|
|
import { str_html } from './text';
|
|
|
-
|
|
|
|
|
|
|
+import { Message } from '@arco-design/web-vue';
|
|
|
import AIModal from './AIModal.vue';
|
|
import AIModal from './AIModal.vue';
|
|
|
|
|
+import { useThemeStore } from '../../base/store/use-theme';
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
- target_active_item: Object
|
|
|
|
|
|
|
+ target_active_item: Object,
|
|
|
|
|
+ html_content: String,
|
|
|
|
|
+ report_title: String
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const emit = defineEmits(['showMenus']);
|
|
|
|
|
|
|
+const emit = defineEmits(['showMenus', 'changeSaveStatus']);
|
|
|
|
|
+
|
|
|
|
|
+const themeStore = useThemeStore();
|
|
|
|
|
|
|
|
// 编辑器实例,必须用 shallowRef
|
|
// 编辑器实例,必须用 shallowRef
|
|
|
const editorRef = shallowRef();
|
|
const editorRef = shallowRef();
|
|
|
const toolbarRef = ref(null);
|
|
const toolbarRef = ref(null);
|
|
|
const editorContentRef = ref();
|
|
const editorContentRef = ref();
|
|
|
// 图片上传input的ref
|
|
// 图片上传input的ref
|
|
|
-const imageUploadRef = ref(null);
|
|
|
|
|
|
|
+// const imageUploadRef = ref(null);
|
|
|
|
|
|
|
|
// 内容 HTML
|
|
// 内容 HTML
|
|
|
const valueHtml = ref('');
|
|
const valueHtml = ref('');
|
|
|
|
|
+const pre_html_content = ref('');
|
|
|
// 目录
|
|
// 目录
|
|
|
const menus = ref([]);
|
|
const menus = ref([]);
|
|
|
|
|
|
|
|
// 当前要AI转写的P标签
|
|
// 当前要AI转写的P标签
|
|
|
const target_active_pElement = ref(null);
|
|
const target_active_pElement = ref(null);
|
|
|
const show_ai_modal = ref(false);
|
|
const show_ai_modal = ref(false);
|
|
|
|
|
+const RobotIcon = computed(() => {
|
|
|
|
|
+ if (themeStore.value == THEME_GREEN) {
|
|
|
|
|
+ return RobotIcon_a;
|
|
|
|
|
+ } else if (themeStore.value == THEME_PARTY) {
|
|
|
|
|
+ return RobotIcon_b;
|
|
|
|
|
+ } else if (themeStore.value == THEME_LIGHT) {
|
|
|
|
|
+ return RobotIcon_c;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return RobotIcon_a;
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
// 模拟 ajax 异步获取内容
|
|
// 模拟 ajax 异步获取内容
|
|
|
onMounted(() => {});
|
|
onMounted(() => {});
|
|
@@ -108,6 +129,13 @@ const editorConfig = {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // image: {
|
|
|
|
|
+ // // 清空 image 元素的 hoverbar
|
|
|
|
|
+ // menuKeys: ['imageWidth30', 'imageWidth50', 'imageWidth100', 'deleteImage']
|
|
|
|
|
+ // },
|
|
|
|
|
+ // link: {
|
|
|
|
|
+ // menuKeys: []
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -120,7 +148,7 @@ onBeforeUnmount(() => {
|
|
|
|
|
|
|
|
const handleCreated = (editor) => {
|
|
const handleCreated = (editor) => {
|
|
|
editorRef.value = editor; // 记录 editor 实例,重要!
|
|
editorRef.value = editor; // 记录 editor 实例,重要!
|
|
|
-
|
|
|
|
|
|
|
+ // console.log(editor);
|
|
|
// 修改工具栏配置,保留图片上传按钮
|
|
// 修改工具栏配置,保留图片上传按钮
|
|
|
toolbarConfig.excludeKeys = [
|
|
toolbarConfig.excludeKeys = [
|
|
|
'insertImage',
|
|
'insertImage',
|
|
@@ -135,19 +163,25 @@ const handleCreated = (editor) => {
|
|
|
'insertTable',
|
|
'insertTable',
|
|
|
'editImage',
|
|
'editImage',
|
|
|
'editLink',
|
|
'editLink',
|
|
|
- 'viewImageLink'
|
|
|
|
|
|
|
+ 'viewImageLink',
|
|
|
|
|
+ 'codeBlock'
|
|
|
];
|
|
];
|
|
|
- console.log(editor.getAllMenuKeys());
|
|
|
|
|
|
|
+ // console.log(editor.getConfig().hoverbarKeys);
|
|
|
|
|
+ // console.log(editor.getAllMenuKeys());
|
|
|
|
|
|
|
|
- valueHtml.value = str_html;
|
|
|
|
|
|
|
+ // valueHtml.value = str_html;
|
|
|
|
|
+ // valueHtml.value = props.html_content;
|
|
|
// 让所有的h1居中
|
|
// 让所有的h1居中
|
|
|
- toAlginCenterByH1();
|
|
|
|
|
|
|
+ // toAlginCenterByH1();
|
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
|
bindPElementEvents();
|
|
bindPElementEvents();
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleChange = () => {
|
|
const handleChange = () => {
|
|
|
|
|
+ if (pre_html_content.value !== valueHtml.value) {
|
|
|
|
|
+ emit('changeSaveStatus');
|
|
|
|
|
+ }
|
|
|
menus.value = generateTableOfContents();
|
|
menus.value = generateTableOfContents();
|
|
|
emit('showMenus', menus);
|
|
emit('showMenus', menus);
|
|
|
|
|
|
|
@@ -198,19 +232,21 @@ const toAlginCenterByH1 = () => {
|
|
|
}
|
|
}
|
|
|
count += 1;
|
|
count += 1;
|
|
|
if (editorRef.value.getHtml()) {
|
|
if (editorRef.value.getHtml()) {
|
|
|
- console.log(document.querySelectorAll('.editor_content h1'));
|
|
|
|
|
|
|
+ // console.log(document.querySelectorAll('.editor_content h1'));
|
|
|
const headers = document.querySelectorAll('.editor_content h1');
|
|
const headers = document.querySelectorAll('.editor_content h1');
|
|
|
headers.forEach((item, index) => {
|
|
headers.forEach((item, index) => {
|
|
|
if (index + 1 == item.id.split('-')[1]) {
|
|
if (index + 1 == item.id.split('-')[1]) {
|
|
|
item.setAttribute('style', 'text-align: center ');
|
|
item.setAttribute('style', 'text-align: center ');
|
|
|
}
|
|
}
|
|
|
if (item.id.split('-')[1] / 1 === 1) {
|
|
if (item.id.split('-')[1] / 1 === 1) {
|
|
|
- console.log(item.innerText);
|
|
|
|
|
|
|
+ if (props.report_title) return;
|
|
|
emit('renderTitle', item.innerText);
|
|
emit('renderTitle', item.innerText);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
editorRef.value.updateView();
|
|
editorRef.value.updateView();
|
|
|
count = 11;
|
|
count = 11;
|
|
|
|
|
+ pre_html_content.value = valueHtml.value;
|
|
|
|
|
+ // console.log(pre_html_content.value == valueHtml.value, 99);
|
|
|
}
|
|
}
|
|
|
}, 300);
|
|
}, 300);
|
|
|
};
|
|
};
|
|
@@ -239,11 +275,12 @@ const generateTableOfContents = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const getHTML = () => {
|
|
const getHTML = () => {
|
|
|
- console.log(editorRef.value.getHtml());
|
|
|
|
|
|
|
+ // console.log(editorRef.value.getHtml());
|
|
|
menus.value = generateTableOfContents();
|
|
menus.value = generateTableOfContents();
|
|
|
emit('showMenus', menus);
|
|
emit('showMenus', menus);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+// 点击目录 锚点定位编辑器内容位置
|
|
|
const handleItemClick = (item) => {
|
|
const handleItemClick = (item) => {
|
|
|
const editorContent = document.querySelector('.editor_content');
|
|
const editorContent = document.querySelector('.editor_content');
|
|
|
const targetElement = document.getElementById(item.id);
|
|
const targetElement = document.getElementById(item.id);
|
|
@@ -271,49 +308,54 @@ const getAllPTags = (parentNode) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleMouseEnter = (pElement) => {
|
|
const handleMouseEnter = (pElement) => {
|
|
|
|
|
+ // TODO 这里后面可以改一下,当鼠标移入是不加光标,当点击左侧按钮时再加入光标
|
|
|
const hasImg = pElement.querySelector('img') !== null;
|
|
const hasImg = pElement.querySelector('img') !== null;
|
|
|
- if (!hasImg) {
|
|
|
|
|
- // 添加光标到段落末尾
|
|
|
|
|
- const range = document.createRange();
|
|
|
|
|
- const selection = window.getSelection();
|
|
|
|
|
- range.selectNodeContents(pElement);
|
|
|
|
|
- range.collapse(false); // 折叠到元素末尾
|
|
|
|
|
- selection.removeAllRanges();
|
|
|
|
|
- selection.addRange(range);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- if (!pElement.innerText.trim()) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- pElement.style.background = 'rgba(10, 129, 126, 0.3)';
|
|
|
|
|
- // 若已存在按钮,则不再添加
|
|
|
|
|
- const existingBtn = pElement.querySelector('.ai-btn');
|
|
|
|
|
- if (!existingBtn) {
|
|
|
|
|
- const btn = document.createElement('img');
|
|
|
|
|
- btn.classList.add('ai-btn');
|
|
|
|
|
- btn.style.position = 'absolute';
|
|
|
|
|
- btn.style.height = '40px';
|
|
|
|
|
- btn.style.top = '-10px';
|
|
|
|
|
- btn.style.left = '-45px';
|
|
|
|
|
- btn.style.padding = '5px 10px';
|
|
|
|
|
- btn.src = RobotIcon;
|
|
|
|
|
- btn.style.color = '#fff';
|
|
|
|
|
- btn.style.border = 'none';
|
|
|
|
|
- btn.style.cursor = 'pointer';
|
|
|
|
|
- btn.style.borderRadius = '4px';
|
|
|
|
|
- btn.addEventListener('click', () => {
|
|
|
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
|
+ if (!pElement.innerText.trim()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ pElement.style.background = 'var(--editor_hover)';
|
|
|
|
|
+ // 若已存在按钮,则不再添加
|
|
|
|
|
+ const existingBtn = pElement.querySelector('.ai-btn');
|
|
|
|
|
+ if (!existingBtn) {
|
|
|
|
|
+ // console.log(RobotIcon, 666);
|
|
|
|
|
+ const btn = document.createElement('img');
|
|
|
|
|
+ btn.classList.add('ai-btn');
|
|
|
|
|
+ btn.style.position = 'absolute';
|
|
|
|
|
+ btn.style.height = '40px';
|
|
|
|
|
+ btn.style.top = '-10px';
|
|
|
|
|
+ btn.style.left = '-45px';
|
|
|
|
|
+ btn.style.padding = '5px 10px';
|
|
|
|
|
+ btn.src = RobotIcon.value;
|
|
|
|
|
+ btn.style.color = '#fff';
|
|
|
|
|
+ btn.style.border = 'none';
|
|
|
|
|
+ btn.style.cursor = 'pointer';
|
|
|
|
|
+ btn.style.borderRadius = '4px';
|
|
|
|
|
+ btn.style.zIndex = '9999';
|
|
|
|
|
+ btn.addEventListener('click', () => {
|
|
|
|
|
+ if (!hasImg) {
|
|
|
|
|
+ // 添加光标到段落末尾
|
|
|
|
|
+ const range = document.createRange();
|
|
|
|
|
+ const selection = window.getSelection();
|
|
|
|
|
+ range.selectNodeContents(pElement);
|
|
|
|
|
+ range.collapse(false); // 折叠到元素末尾
|
|
|
|
|
+ selection.removeAllRanges();
|
|
|
|
|
+ selection.addRange(range);
|
|
|
|
|
+ }
|
|
|
|
|
+ setTimeout(() => {
|
|
|
target_active_pElement.value = pElement;
|
|
target_active_pElement.value = pElement;
|
|
|
show_ai_modal.value = true;
|
|
show_ai_modal.value = true;
|
|
|
- });
|
|
|
|
|
- //设置p元素为相对定位,确保按钮能相对于P元素定位
|
|
|
|
|
- pElement.style.position = 'relative';
|
|
|
|
|
- pElement.appendChild(btn);
|
|
|
|
|
- btn.addEventListener('mouseleave', () => handleMouseLeave(pElement));
|
|
|
|
|
- setTimeout(() => {}, 50);
|
|
|
|
|
- console.log(editorRef.value.selection, 9999);
|
|
|
|
|
- }
|
|
|
|
|
- }, 50);
|
|
|
|
|
|
|
+ }, 50);
|
|
|
|
|
+ });
|
|
|
|
|
+ //设置p元素为相对定位,确保按钮能相对于P元素定位
|
|
|
|
|
+ pElement.style.position = 'relative';
|
|
|
|
|
+ pElement.appendChild(btn);
|
|
|
|
|
+ btn.addEventListener('mouseleave', () => handleMouseLeave(pElement));
|
|
|
|
|
+ // setTimeout(() => {}, 50);
|
|
|
|
|
+ // console.log(editorRef.value.selection, 9999);
|
|
|
|
|
+ }
|
|
|
|
|
+ // }, 50);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleMouseLeave = (pElement) => {
|
|
const handleMouseLeave = (pElement) => {
|
|
@@ -339,7 +381,7 @@ let offset = 0;
|
|
|
const changePElement = (obj) => {
|
|
const changePElement = (obj) => {
|
|
|
if (editorRef.value) {
|
|
if (editorRef.value) {
|
|
|
const editor = editorRef.value;
|
|
const editor = editorRef.value;
|
|
|
- console.log(editor.selection);
|
|
|
|
|
|
|
+ // console.log(editor.selection);
|
|
|
const targetP = document.querySelector(`p#${obj.pid}`);
|
|
const targetP = document.querySelector(`p#${obj.pid}`);
|
|
|
if (targetP) {
|
|
if (targetP) {
|
|
|
// 创建一个临时Range来选中整个p元素
|
|
// 创建一个临时Range来选中整个p元素
|
|
@@ -349,7 +391,7 @@ const changePElement = (obj) => {
|
|
|
// 将DOM范围转换为编辑器选区
|
|
// 将DOM范围转换为编辑器选区
|
|
|
editor.restoreSelection(range);
|
|
editor.restoreSelection(range);
|
|
|
|
|
|
|
|
- offset = Number(editor.selection.focus.offset);
|
|
|
|
|
|
|
+ offset = Number(editor.selection.focus.offset) || 0;
|
|
|
// 删除选中内容
|
|
// 删除选中内容
|
|
|
for (let i = 0; i <= offset; i++) {
|
|
for (let i = 0; i <= offset; i++) {
|
|
|
editor.deleteBackward();
|
|
editor.deleteBackward();
|
|
@@ -359,7 +401,7 @@ const changePElement = (obj) => {
|
|
|
// 替换为新内容
|
|
// 替换为新内容
|
|
|
editor.dangerouslyInsertHtml(obj.content.innerHTML);
|
|
editor.dangerouslyInsertHtml(obj.content.innerHTML);
|
|
|
// targetP.innerHTML = obj.content.innerHTML;
|
|
// targetP.innerHTML = obj.content.innerHTML;
|
|
|
- console.log(editor.getHtml());
|
|
|
|
|
|
|
+ // console.log(editor.getHtml());
|
|
|
}
|
|
}
|
|
|
// }
|
|
// }
|
|
|
}
|
|
}
|
|
@@ -375,9 +417,10 @@ const insertPElement = (obj) => {
|
|
|
const targetP = editorContentRef.value.$el.querySelector(`p#${obj.pid}`);
|
|
const targetP = editorContentRef.value.$el.querySelector(`p#${obj.pid}`);
|
|
|
if (targetP) {
|
|
if (targetP) {
|
|
|
// targetP.innerHTML += obj.content.innerHTML;
|
|
// targetP.innerHTML += obj.content.innerHTML;
|
|
|
|
|
+ // console.log(obj);
|
|
|
editor.dangerouslyInsertHtml(obj.content.innerHTML);
|
|
editor.dangerouslyInsertHtml(obj.content.innerHTML);
|
|
|
editor.updateView();
|
|
editor.updateView();
|
|
|
- console.log(editor.getHtml());
|
|
|
|
|
|
|
+ // console.log(editor.getHtml());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
closeAIModal();
|
|
closeAIModal();
|
|
@@ -403,34 +446,74 @@ const convertImageToBase64 = (file) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 处理图片上传
|
|
// 处理图片上传
|
|
|
-const handleImageUpload = async (e) => {
|
|
|
|
|
- const file = e.target.files[0];
|
|
|
|
|
- if (!file) return;
|
|
|
|
|
|
|
+// const handleImageUpload = async (e) => {
|
|
|
|
|
+// const file = e.target.files[0];
|
|
|
|
|
+// if (!file) return;
|
|
|
|
|
+// console.log(11111111111111);
|
|
|
|
|
+// try {
|
|
|
|
|
+// const editor = editorRef.value;
|
|
|
|
|
+// if (!editor) {
|
|
|
|
|
+// console.error('编辑器实例不存在');
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 转换为base64
|
|
|
|
|
+// const base64Url = await convertImageToBase64(file);
|
|
|
|
|
+// console.log(editor);
|
|
|
|
|
+// // 插入图片到编辑器
|
|
|
|
|
+// editor.insertImage(base64Url, file.name);
|
|
|
|
|
+
|
|
|
|
|
+// // 图片插入后重新绑定事件
|
|
|
|
|
+// nextTick(() => {
|
|
|
|
|
+// bindPElementEvents();
|
|
|
|
|
+// });
|
|
|
|
|
+// } catch (error) {
|
|
|
|
|
+// console.error('图片上传失败:', error);
|
|
|
|
|
+// alert('图片上传失败,请重试');
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 重置input值,以便可以重复上传同一文件
|
|
|
|
|
+// e.target.value = '';
|
|
|
|
|
+// };
|
|
|
|
|
+// 插入图片
|
|
|
|
|
+const insertPic = async (base64) => {
|
|
|
|
|
+ // 1. 验证编辑器实例是否初始化
|
|
|
|
|
+ if (!editorRef.value) {
|
|
|
|
|
+ console.error('编辑器尚未初始化');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 验证base64格式是否有效
|
|
|
|
|
+ if (!base64 || !base64.startsWith('data:image/')) {
|
|
|
|
|
+ console.error('无效的base64图片格式(需以data:image/开头)');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const editor = editorRef.value;
|
|
const editor = editorRef.value;
|
|
|
- if (!editor) {
|
|
|
|
|
- console.error('编辑器实例不存在');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 如果没有选中区域,将光标移到文档末尾
|
|
|
|
|
+ if (!editor.selection) {
|
|
|
|
|
+ // editor.moveCursorToEnd(); // 移动光标到末尾
|
|
|
|
|
+ // alert('请选择插入位置');
|
|
|
|
|
+ Message.error('请选择图片插入位置');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 转换为base64
|
|
|
|
|
- const base64Url = await convertImageToBase64(file);
|
|
|
|
|
-
|
|
|
|
|
- // 插入图片到编辑器
|
|
|
|
|
- editor.insertImage(base64Url, file.name);
|
|
|
|
|
|
|
+ // 4. 生成图片HTML标签(使用dangerouslyInsertHtml插入)
|
|
|
|
|
+ const imgHtml = `<img src="${base64}" alt="插入的图片" style="max-width:100%;height:auto;margin:10px 0;" />`;
|
|
|
|
|
+ editor.dangerouslyInsertHtml(imgHtml); // 核心:插入图片HTML
|
|
|
|
|
|
|
|
- // 图片插入后重新绑定事件
|
|
|
|
|
|
|
+ // 5. 插入后重新绑定事件(保持原有逻辑)
|
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
|
bindPElementEvents();
|
|
bindPElementEvents();
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error('图片上传失败:', error);
|
|
|
|
|
- alert('图片上传失败,请重试');
|
|
|
|
|
|
|
+ console.error('插入图片失败:', error);
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 重置input值,以便可以重复上传同一文件
|
|
|
|
|
- e.target.value = '';
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
watch(
|
|
watch(
|
|
@@ -441,6 +524,14 @@ watch(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.html_content,
|
|
|
|
|
+ (newValue) => {
|
|
|
|
|
+ valueHtml.value = newValue;
|
|
|
|
|
+ pre_html_content.value = valueHtml.value;
|
|
|
|
|
+ toAlginCenterByH1();
|
|
|
|
|
+ }
|
|
|
|
|
+);
|
|
|
defineExpose({
|
|
defineExpose({
|
|
|
getHtml: () => {
|
|
getHtml: () => {
|
|
|
if (editorRef.value) {
|
|
if (editorRef.value) {
|
|
@@ -448,7 +539,11 @@ defineExpose({
|
|
|
} else {
|
|
} else {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ // insertEchartPic: ()=>{
|
|
|
|
|
+ // 插入base64图片到富文本
|
|
|
|
|
+ insertEchartPic: insertPic
|
|
|
|
|
+ // }
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
|
<style scoped lang="css">
|
|
<style scoped lang="css">
|
|
@@ -476,6 +571,9 @@ defineExpose({
|
|
|
-ms-overflow-style: none;
|
|
-ms-overflow-style: none;
|
|
|
/* scrollbar-width: none; */
|
|
/* scrollbar-width: none; */
|
|
|
}
|
|
}
|
|
|
|
|
+:deep(.w-e-text-container .w-e-text-placeholder) {
|
|
|
|
|
+ padding: 20px 40px;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/* 为图片添加一些样式 */
|
|
/* 为图片添加一些样式 */
|
|
|
:deep(.w-e-image-container img) {
|
|
:deep(.w-e-image-container img) {
|