This commit is contained in:
2025-05-20 09:55:12 +08:00
parent 4e8e8e796f
commit c60d06194c
22 changed files with 8978 additions and 321 deletions

View File

@@ -29,25 +29,25 @@
<!-- <b class="MaxBtn" style="right: 80px; top: 5px; padding: 0"><common-drag-word @tables="getTables"></common-drag-word></b> -->
<!-- <b class="MaxBtn" @click="MTxtPic()" style="background-color: #13bc20; right: 40px; top: 5px">
<svg
t="1684978324047"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="1967"
width="15"
height="15"
>
<path
d="M512 46.208a42.666667 42.666667 0 0 1 4.992 85.077333L512 131.541333H174.208a42.666667 42.666667 0 0 0-42.368 37.717334l-0.298667 4.949333v487.850667L307.2 501.12a88.874667 88.874667 0 0 1 112.042667-6.570667l5.845333 4.608 150.442667 128.896 101.973333-101.888a88.874667 88.874667 0 0 1 110.122667-12.373333l6.058666 4.138667 104.832 78.592V512a42.666667 42.666667 0 0 1 85.077334-4.992l0.298666 4.992v342.698667a128 128 0 0 1-120.490666 127.786666l-7.509334 0.213334H174.208a128 128 0 0 1-127.786667-120.490667l-0.213333-7.509333V174.208a128 128 0 0 1 120.490667-127.786667l7.509333-0.213333H512zM366.378667 563.2l-1.536 0.853333-233.301334 213.76v76.885334a42.666667 42.666667 0 0 0 37.717334 42.368l4.949333 0.298666H855.893333a42.666667 42.666667 0 0 0 42.368-37.717333l0.298667-4.949333v-151.808l-3.285333-2.090667-152.789334-114.602667a3.541333 3.541333 0 0 0-3.2-0.554666l-1.450666 0.853333-97.28 97.28 76.970666 66.048a42.666667 42.666667 0 0 1-51.2 68.010667l-4.309333-3.2-292.437333-250.666667a3.541333 3.541333 0 0 0-3.2-0.768z m415.829333-516.992a42.666667 42.666667 0 0 1 42.410667 37.717333l0.256 4.949334v96h96a42.666667 42.666667 0 0 1 4.992 85.077333l-4.992 0.256h-96v96a42.666667 42.666667 0 0 1-85.034667 4.992l-0.298667-4.992v-96h-96a42.666667 42.666667 0 0 1-4.949333-85.034667l4.949333-0.298666h96v-96a42.666667 42.666667 0 0 1 42.666667-42.666667z"
fill="#ffffff"
p-id="1968"
></path>
</svg> </b
><b class="MaxBtn" @click="MTxtTable()" style="background-color: #e07404; right: 0px; top: 5px">
<i class="el-icon-document-add"></i>
</b> -->
<svg
t="1684978324047"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="1967"
width="15"
height="15"
>
<path
d="M512 46.208a42.666667 42.666667 0 0 1 4.992 85.077333L512 131.541333H174.208a42.666667 42.666667 0 0 0-42.368 37.717334l-0.298667 4.949333v487.850667L307.2 501.12a88.874667 88.874667 0 0 1 112.042667-6.570667l5.845333 4.608 150.442667 128.896 101.973333-101.888a88.874667 88.874667 0 0 1 110.122667-12.373333l6.058666 4.138667 104.832 78.592V512a42.666667 42.666667 0 0 1 85.077334-4.992l0.298666 4.992v342.698667a128 128 0 0 1-120.490666 127.786666l-7.509334 0.213334H174.208a128 128 0 0 1-127.786667-120.490667l-0.213333-7.509333V174.208a128 128 0 0 1 120.490667-127.786667l7.509333-0.213333H512zM366.378667 563.2l-1.536 0.853333-233.301334 213.76v76.885334a42.666667 42.666667 0 0 0 37.717334 42.368l4.949333 0.298666H855.893333a42.666667 42.666667 0 0 0 42.368-37.717333l0.298667-4.949333v-151.808l-3.285333-2.090667-152.789334-114.602667a3.541333 3.541333 0 0 0-3.2-0.554666l-1.450666 0.853333-97.28 97.28 76.970666 66.048a42.666667 42.666667 0 0 1-51.2 68.010667l-4.309333-3.2-292.437333-250.666667a3.541333 3.541333 0 0 0-3.2-0.768z m415.829333-516.992a42.666667 42.666667 0 0 1 42.410667 37.717333l0.256 4.949334v96h96a42.666667 42.666667 0 0 1 4.992 85.077333l-4.992 0.256h-96v96a42.666667 42.666667 0 0 1-85.034667 4.992l-0.298667-4.992v-96h-96a42.666667 42.666667 0 0 1-4.949333-85.034667l4.949333-0.298666h96v-96a42.666667 42.666667 0 0 1 42.666667-42.666667z"
fill="#ffffff"
p-id="1968"
></path>
</svg> </b
><b class="MaxBtn" @click="MTxtTable()" style="background-color: #e07404; right: 0px; top: 5px">
<i class="el-icon-document-add"></i>
</b> -->
<!-- </p> -->
<div class="unfetteredBox" style="height: 100%">
@@ -64,6 +64,7 @@
@onAddComment="onAddComment"
@addImage="handleImageAdd"
@addTable="handleTableAdd"
@handlePaperclip="handlePaperclip"
@addComment="addCommentSetting"
@goToComment="goToComment"
@edit="handleImageEdit"
@@ -71,19 +72,20 @@
style="width: 100%; height: 100%; padding: 0 0px; box-sizing: border-box; background-color: #fff"
>
</common-word-html-type-setting>
<input type="file" ref="fileInput" style="display: none" @change="handleFileChange" />
</div>
</div>
<div style="width: 100%; width: calc(100% - 285px); float: right; height: calc(100% - 0px); background-color: #e4e9ed">
<!-- <div class="toolbar">
<div class="toolbar_item" @click="handleImageAdd('img')">
<img src="@/assets/img/upload.png" style="object-fit: contain" />
<span>Add Figure </span>
</div>
<div class="toolbar_item" @click="handleTableAdd('table')">
<img src="@/assets/img/uploadTable.png" style="object-fit: contain" />
<span>Add Table </span>
</div>
</div> -->
<div class="toolbar_item" @click="handleImageAdd('img')">
<img src="@/assets/img/upload.png" style="object-fit: contain" />
<span>Add Figure </span>
</div>
<div class="toolbar_item" @click="handleTableAdd('table')">
<img src="@/assets/img/uploadTable.png" style="object-fit: contain" />
<span>Add Table </span>
</div>
</div> -->
<common-word
:key="new Date().getTime()"
@@ -123,7 +125,7 @@
</div>
<!--添加/修改图片 -->
<el-dialog :title="picStyle.visiTitle" :visible.sync="pictVisible" width="800px" :close-on-click-modal="false">
<el-dialog :title="picStyle.visiTitle" :visible.sync="pictVisible" width="1200px" :close-on-click-modal="false">
<el-form ref="editMes" :model="picStyle" label-width="150px">
<el-form-item>
<span slot="label">
@@ -154,7 +156,7 @@
@openLatexEditor="openLatexEditor"
v-if="pictVisible"
@updateChange="(res) => updateChange(res, 'imgNote')"
:height="120"
:height="400"
ref="tinymceChildImgNote"
style="margin-left: -115px"
></common-content>
@@ -238,6 +240,43 @@
</el-button>
</p>
</el-drawer>
<el-drawer
title="我嵌套了表格!"
class="editTableDialog"
destroy-on-close
v-if="tablesHtmlVisible"
:title="lineStyle.visiTitle"
:visible.sync="tablesHtmlVisible"
:wrapperClosable="false"
:close-on-click-modal="false"
direction="rtl"
size="70%"
>
<div v-for="(item, i) in uploadWordTables">
<el-button @click="addUploadWordTable(item)"> 插入Table{{ i + 1 }} </el-button>
<div class="thumbnailTableBox wordTableHtml table_Box pMain myeditabledivTable drop-target">
<!-- 标题部分 -->
<!-- <font class="font" :style="`width: ${item.width ? `${item.width}px` : '100%'}`" style="text-align: center">
<span v-html="highlightText(item.table.title || '', item.checks ? item.checks : [])"></span>
</font> -->
<!-- 表格部分 -->
<table border="1" style="width: 100%; border-collapse: collapse; text-align: center">
<tr v-for="(row, i) in item.table_data" :key="i" :class="{ 'table-header-row': isHeaderRow(i, item.table_data) }">
<td v-for="(cell, i1) in row" :key="i1" :colspan="`${cell.colspan || 1}`" :rowspan="`${cell.rowspan || 1}`">
<span v-html="cell.text"></span>
</td>
</tr>
</table>
<!-- 备注部分 -->
<!-- <font class="font" :style="`width: ${item.width ? `${item.width}px` : '100%'}`">
<span v-html="highlightText(item.table.note || '', item.checks ? item.checks : [])"></span>
</font> -->
</div>
<!-- <div v-html="v.html_data"></div> -->
</div>
</el-drawer>
<el-dialog
destroy-on-close
v-if="commentVisible"
@@ -358,6 +397,9 @@ import bottomTinymce from '@/components/page/components/Tinymce';
export default {
data() {
return {
uploadWordTables: [],
tablesHtmlVisible: false,
tablesHtml: '',
LateXInfo: {},
isEditComment: false,
showLateX: false,
@@ -393,48 +435,48 @@ export default {
editTable: 'api/Preaccept/editMainTable'
},
wordStyle: `
// p {
// position: relative;
// padding: 8px 15px;
// min-height: 22px;
// border: 2px dashed #fff;
// border-radius: 5px;
// color: #606266;
// }
// p {
// font-size: 14px;
// line-height: 22px;
// }
// p {
// position: relative;
// padding: 8px 15px;
// min-height: 22px;
// border: 2px dashed #fff;
// border-radius: 5px;
// color: #606266;
// }
// p {
// font-size: 14px;
// line-height: 22px;
// }
.imgBox .chNumer {
position: absolute;
top: -2px;
right: -1px;
border-radius: 3px;
font-size: 10px;
background-color: rgb(0 102 153 / 85%);
color: #fff;
padding: 0 6px;
}
.imgBox .chNumer {
position: absolute;
top: -2px;
right: -1px;
border-radius: 3px;
font-size: 10px;
background-color: rgb(0 102 153 / 85%);
color: #fff;
padding: 0 6px;
}
.MaxPicture {
text-align: center;
}
.MaxPicture {
text-align: center;
}
.MaxPicture > img {
margin-bottom: 10px;
}
.MaxPicture > img {
margin-bottom: 10px;
}
.font {
display: block;
margin: 0 auto;
font-size: 13px;
}
.tableTitle{
text-align:center!important;
font-weight: bold;
}
`,
.font {
display: block;
margin: 0 auto;
font-size: 13px;
}
.tableTitle{
text-align:center!important;
font-weight: bold;
}
`,
tables: [],
htmlContent: '',
@@ -515,6 +557,19 @@ export default {
},
methods: {
async copyArray(data) {
try {
// 将数组内容转换为字符串,使用换行符分隔
const textToCopy = JSON.stringify(data);
// 使用 Clipboard API 复制文本
await navigator.clipboard.writeText(textToCopy);
alert('数组内容已复制到剪贴板!');
} catch (err) {
console.error('复制失败:', err);
alert('复制失败,请重试!');
}
},
openLatexEditor(data) {
console.log('data at line 563:', data);
this.showLateX = true;
@@ -618,6 +673,7 @@ export default {
// });
// }
str = await that.$commonJS.decodeHtml(str);
await that.$api
.post(that.urlList.editContent, {
am_id: am_id,
@@ -653,6 +709,13 @@ export default {
}
});
},
isHeaderRow(rowIndex, table) {
var table = table;
var head = table[0];
return rowIndex < head[0].rowspan; // 假设前两行是表头
},
deleteComment(comment, index) {
console.log('comment at line 480:', comment);
if (this.isEditComment) {
@@ -1048,6 +1111,76 @@ export default {
this.$message.error(err.msg);
});
},
handlePaperclip() {
this.uploadWordTables = [];
this.$refs.fileInput.click();
},
handleFileChange(event) {
var that = this;
// 处理文件上传并传递回调函数
this.$commonJS.handleFileUpload(event, function (tables) {
console.log('tables at line 786:', tables);
// 使用 Promise.all 等待所有表格解析完成
Promise.all(
tables.map((table) => {
return new Promise((resolve, reject) => {
// 解析每个表格
that.$commonJS.parseTableToArray(table, (tableList) => {
console.log('res at line 104:', tableList);
// 生成 HTML 内容
// var contentHtml = `
// <div class="thumbnailTableBox wordTableHtml table_Box" style="">
// <table border="1" style="width: auto; border-collapse: collapse; text-align: center;">
// ${tableList
// .map((row) => {
// return `
// <tr>
// ${row
// .map((cell) => {
// return `
// <td colspan="${cell.colspan || 1}" rowspan="${cell.rowspan || 1}">
// <span>${cell.text || ''}</span>
// </td>
// `;
// })
// .join('')}
// </tr>
// `;
// })
// .join('')}
// </table>
// </div>
// `;
// 将解析后的数据和生成的 HTML 返回
resolve({ table_data: tableList, html_data: '' });
});
});
})
)
.then((result) => {
// 所有表格的解析完成后,处理结果
that.uploadWordTables = result;
that.tablesHtmlVisible = true;
console.log('Processed tables:', that.uploadWordTables);
})
.catch((error) => {
console.error('Error processing tables:', error);
});
});
const file = event.target.files[0];
if (file) {
// 处理文件逻辑
console.log('处理文件:', file.name);
}
// 关键:重置 input 的值
event.target.value = '';
},
async onAddRow(mainId) {
console.log('data at line 886:', mainId);
@@ -1114,6 +1247,18 @@ export default {
this.lineStyle.visiTitle = 'Add Table';
this.threeVisible = true;
},
addUploadWordTable(data) {
this.lineStyle = {};
this.lineStyle = {
...data,
table: data.table_data,
html_data: data.html_data,
note: '',
title: ''
};
this.lineStyle.visiTitle = 'Insert Table';
this.threeVisible = true;
},
handleImageEdit(data, type) {
console.log('data at line 600:', data);
if (type == 'img') {
@@ -1599,7 +1744,6 @@ export default {
var cleanedTableList = content.table ? content.table : [];
console.log('content at line 998:', content);
cleanedTableList = cleanTableData(content.table);
var strTitle = this.lineStyle.title;
strTitle = await this.$commonJS.decodeHtml(strTitle);
@@ -1899,8 +2043,8 @@ export default {
border: 2px dashed rgb(0 102 153 / 50%);
}
/* .type_MTxt > .imgBox:hover {
background-color: rgb(0 102 153 / 10%);
border: 2px dashed rgb(0 102 153 / 50%);
background-color: rgb(0 102 153 / 10%);
border: 2px dashed rgb(0 102 153 / 50%);
} */
.type_MTxt > div > p {