Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board

This commit is contained in:
2026-01-13 13:06:25 +08:00
23 changed files with 3944 additions and 3477 deletions

View File

@@ -73,15 +73,15 @@ export default {
getJournalTypeName(value) {
var list = JSON.parse(localStorage.getItem('journalTypeDataAll'));
if(list&&list.length>0){
const type = list.find(item => item.value === value);
return type ? type.name : 'OTHERS';
}else{
if (list && list.length > 0) {
const type = list.find(item => item.value === value);
return type ? type.name : 'OTHERS';
} else {
return ''
}
},
@@ -119,7 +119,7 @@ export default {
extractLatexFromMathJax() {
@@ -245,7 +245,7 @@ export default {
const content = match.slice(1, match.length - 1); // 去掉方括号
// 这个需要程序去判断所以需要告诉我满足哪些条件的标蓝
// 上标中 只有 * # & 纯数字 纯数字逗号 纯数字逗号和空格 ỻ 标蓝
// 判断是否符合条件,纯数字、逗号后有空格、连字符
if (/^\d+$/.test(content) || /, ?/.test(content) || //.test(content)) {
return `<blue>${match}</blue>`; // 如果符合条件则加上蓝色标签
@@ -412,10 +412,10 @@ export default {
if (!vMergeVal || vMergeVal === "continue") {
if (rowspan < maxRowspan) { // 限制 rowspan 最大值
rowspan++;
nextRowIdx++;
} else {
break;
}
} else if (vMergeVal === "restart") {
@@ -556,10 +556,8 @@ export default {
const target = rel.getAttribute('Target');
rels[id] = target;
});
const imageInfoMap = {};
const blips = docDom.getElementsByTagName('a:blip');
Array.from(blips).forEach((blip) => {
const embedId = blip.getAttribute('r:embed');
const extent = findExtentElement(blip);
@@ -573,7 +571,6 @@ export default {
}
}
});
mammoth.convertToHtml({ arrayBuffer }, {
convertImage: mammoth.images.inline(async function (image) {
console.log('image at line 163:', image)
@@ -834,26 +831,27 @@ export default {
// }
// },
transformHtmlString(inputHtml, type) {
transformHtmlString(inputHtml, type, options = {}) {
const { keepBr = false } = options;
if (!keepBr) {
inputHtml = inputHtml.replace(/<br\s*\/?>/g, '');
}
// inputHtml = inputHtml.replace(/(<[^>]+) style="[^"]*"/g, '$1'); // 移除style属性
// inputHtml = inputHtml.replace(/(<[^>]+) class="[^"]*"/g, '$1'); // 移除class属性
// inputHtml = inputHtml.replace(/<([a-zA-Z0-9]+)[^>]*>/g, '<$1>'); // 删除标签上的所有属性
inputHtml = inputHtml.replace(/<([a-zA-Z0-9]+)([^>]*)>/g, function (match, tag, attributes) {
// 使用正则表达式删除属性(保留 data-latex
let updatedAttributes = attributes.replace(/\s([a-zA-Z0-9-]+)(="[^"]*")?/g, function (attrMatch, attrName) {
// 只保留 data-latex 属性,其他属性删除
if (attrName === "data-latex") {
return attrMatch;
}
if (type == 'table' && tag == 'img' && (attrName === "src" || attrName === "width" || attrName === "height")) {
return attrMatch;
}
return ''; // 删除其他属性
return '';
});
// 返回标签,保留 data-latex 属性
return `<${tag}${updatedAttributes}>`;
});
// 2. 删除所有不需要的标签 (除 `strong`, `em`, `sub`, `sup`, `b`, `i` 外的所有标签)
@@ -864,14 +862,11 @@ export default {
}
// 3. 删除所有 `<br>` 标签
inputHtml = inputHtml.replace(/<br\s*\/?>/g, ''); // 删除 <br> 标签
// 3. 如果有 `<strong>` 和 `<em>` 标签,去掉内部样式并保留内容
// 去掉样式
inputHtml = inputHtml.replace(/<span[^>]*>/g, '').replace(/<\/span>/g, ''); // 去除span标签
inputHtml = inputHtml.replace(/<strong>/g, '<b>').replace(/<\/strong>/g, '</b>'); // 将 `strong` 替换成 `b`
inputHtml = inputHtml.replace(/<em>/g, '<i>').replace(/<\/em>/g, '</i>'); // 将 `em` 替换成 `i`
// 4. 合并相同标签(如多个连续的 <b> 标签)
// 4. 合并相同标签
inputHtml = inputHtml.replace(/<b>(.*?)<\/b>\s*<b>/g, '<b>$1'); // 合并连续的 <b> 标签
inputHtml = inputHtml.replace(/<i>(.*?)<\/i>\s*<i>/g, '<i>$1'); // 合并连续的 <i> 标签
@@ -1204,9 +1199,9 @@ export default {
// 遍历行
table.forEach((row) => {
tableHtml += `<tr>`;
if(row&&row.length>0){
row.forEach((cell) => {
tableHtml += `
if (row && row.length > 0) {
row.forEach((cell) => {
tableHtml += `
<td
colspan="${cell.colspan || 1}"
rowspan="${cell.rowspan || 1}"
@@ -1215,12 +1210,12 @@ if(row&&row.length>0){
<span > ${cell.text}</span>
</td>
`;
});
}else{
tableHtml+=``
}
});
} else {
tableHtml += ``
}
// 遍历单元格
tableHtml += `</tr>`;
});
@@ -2111,41 +2106,41 @@ if(row&&row.length>0){
// 全部大写按钮按钮文本A
ed.ui.registry.addButton('myuppercase', {
text: 'A', // 按钮文本(大写标识)
onAction: function () {
// 获取选中的文本(保留 HTML 格式,确保空格等内容不丢失)
var selectedText = ed.selection.getContent({ format: 'html' });
ed.ui.registry.addButton('myuppercase', {
text: 'A', // 按钮文本(大写标识)
onAction: function () {
// 获取选中的文本(保留 HTML 格式,确保空格等内容不丢失)
var selectedText = ed.selection.getContent({ format: 'html' });
// 校验:非空且仅含字母、数字、空格(可根据需求调整正则)
// if (selectedText.trim() && /^[\s\w]+$/.test(selectedText)) {
// 直接将选中的所有内容转为大写(无需正则,整体转换)
var allUppercaseText = selectedText.toUpperCase();
// 替换选中的文本
ed.selection.setContent(allUppercaseText);
// } else {
// vueInstance.$message.error(vueInstance.$t('commonTable.selectWord'));
// }
}
});
// 校验:非空且仅含字母、数字、空格(可根据需求调整正则)
// if (selectedText.trim() && /^[\s\w]+$/.test(selectedText)) {
// 直接将选中的所有内容转为大写(无需正则,整体转换)
var allUppercaseText = selectedText.toUpperCase();
// 替换选中的文本
ed.selection.setContent(allUppercaseText);
// } else {
// vueInstance.$message.error(vueInstance.$t('commonTable.selectWord'));
// }
}
});
// 全部小写按钮按钮文本a
ed.ui.registry.addButton('myuppercasea', {
text: 'a', // 按钮文本(小写标识)
onAction: function () {
var selectedText = ed.selection.getContent({ format: 'html' });
// 全部小写按钮按钮文本a
ed.ui.registry.addButton('myuppercasea', {
text: 'a', // 按钮文本(小写标识)
onAction: function () {
var selectedText = ed.selection.getContent({ format: 'html' });
// if (selectedText.trim() && /^[\s\w]+$/.test(selectedText)) {
// 直接将选中的所有内容转为小写(整体转换)
var allLowercaseText = selectedText.toLowerCase();
ed.selection.setContent(allLowercaseText);
// } else {
// vueInstance.$message.error(vueInstance.$t('commonTable.selectWord'));
// }
}
});
// if (selectedText.trim() && /^[\s\w]+$/.test(selectedText)) {
// 直接将选中的所有内容转为小写(整体转换)
var allLowercaseText = selectedText.toLowerCase();
ed.selection.setContent(allLowercaseText);
// } else {
// vueInstance.$message.error(vueInstance.$t('commonTable.selectWord'));
// }
}
});
ed.ui.registry.addButton('Line', {
text: '', // 按钮文本
onAction: function () {