lcw
This commit is contained in:
@ -47,7 +47,15 @@ const mode = "default";
|
||||
//工具配置
|
||||
const toolbarConfig = {
|
||||
excludeKeys: ["blockquote", "codeBlock"] //清除不必要的工具,引用和代码块
|
||||
// 注意:wangEditor默认包含了对齐相关的按钮,包括两端对齐
|
||||
// 如果需要自定义工具栏,可以使用以下配置
|
||||
// toolbarKeys: [
|
||||
// // 其他工具栏按钮
|
||||
// 'justifyJustify', // 两端对齐按钮
|
||||
// ]
|
||||
};
|
||||
|
||||
// 为了确保编辑器内容默认应用两端对齐,我们在编辑器创建时设置全局样式
|
||||
const emits = defineEmits(["update:textContent", "changeFn","update:modelValue","SaveReport"]);
|
||||
//编辑器配置
|
||||
const editorConfig = {
|
||||
@ -75,6 +83,27 @@ const editorConfig = {
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化完成后设置默认的两端对齐样式
|
||||
const setDefaultJustifyStyle = () => {
|
||||
const editor = editorRef.value;
|
||||
if (editor) {
|
||||
// 获取编辑区域元素
|
||||
const editableEle = editor.getEditableContainer();
|
||||
if (editableEle) {
|
||||
editableEle.style.textAlign = 'justify';
|
||||
// 添加中文两端对齐的处理样式
|
||||
editableEle.style.textJustify = 'inter-character';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 监听编辑器创建完成事件,设置两端对齐样式
|
||||
watch(editorRef, (newVal) => {
|
||||
if (newVal) {
|
||||
setDefaultJustifyStyle();
|
||||
}
|
||||
});
|
||||
|
||||
const uploadFn = (file, insertFn) => {
|
||||
let param = new FormData();
|
||||
param.append("file", file);
|
||||
@ -110,6 +139,18 @@ const downloadWithStyles = () => {
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>富文本导出</title>
|
||||
<style>
|
||||
/* 应用两端对齐样式 */
|
||||
body {
|
||||
text-align: justify;
|
||||
text-justify: inter-character; /* 中文文本两端对齐 */
|
||||
font-family: "Microsoft YaHei", Arial, sans-serif;
|
||||
}
|
||||
p {
|
||||
text-align: justify;
|
||||
text-justify: inter-character;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
${props.textContent}
|
||||
@ -124,13 +165,15 @@ const downloadWithStyles = () => {
|
||||
saveAs(blob, 'styled-document.doc');
|
||||
};
|
||||
const SaveReport = () => {
|
||||
console.log(props.textContent);
|
||||
|
||||
emits("SaveReport",props.textContent)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.cntBox{
|
||||
height: 60vh;
|
||||
// height: 60vh;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
|
||||
Reference in New Issue
Block a user