提交
This commit is contained in:
@@ -28,7 +28,7 @@ export default {
|
||||
var str = ''
|
||||
// 获取单元格的 HTML 内容
|
||||
let htmlContent = cell.innerHTML.trim();
|
||||
console.log('htmlContent at line 30111:', htmlContent)
|
||||
|
||||
str = this.transformHtmlString(htmlContent)
|
||||
|
||||
// 创建一个临时的 DOM 元素来解析 HTML
|
||||
@@ -49,13 +49,25 @@ export default {
|
||||
str = capitalizeFirstLetter(str);
|
||||
|
||||
// 添加蓝色标签
|
||||
const regex = /\[(\d+(?:–\d+)?(?:,\d+(?:–\d+)?)*)\]/g;
|
||||
const regex = /\[(\d+(?:–\d+)?(?:, ?\d+(?:–\d+)?)*)\]/g;
|
||||
|
||||
str = str.replace(/<blue>/g, '').replace(/<\/blue>/g, ''); // 先去掉所有的 <blue> 标签
|
||||
str = str.replace(/<blue>/g, '').replace(/<\/blue>/g, ''); // 先去掉所有的 <blue> 标签
|
||||
|
||||
if (regex.test(str)) {
|
||||
str = str.replace(regex, function(match) {
|
||||
// 提取出方括号中的内容,并进行匹配
|
||||
const content = match.slice(1, match.length - 1); // 去掉方括号
|
||||
|
||||
// 判断是否符合条件,纯数字、逗号后有空格、连字符
|
||||
if (/^\d+$/.test(content) || /, ?/.test(content) || /–/.test(content)) {
|
||||
return `<blue>${match}</blue>`; // 如果符合条件则加上蓝色标签
|
||||
}
|
||||
return match; // 如果不符合条件,则保持原样
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (regex.test(str)) {
|
||||
str = str.replace(regex, `<blue>$&</blue>`); // 然后再进行替换
|
||||
}
|
||||
|
||||
// 如果没有 <span> 标签,直接返回原始 HTML 内容
|
||||
return str;
|
||||
@@ -284,13 +296,28 @@ if (regex.test(str)) {
|
||||
|
||||
// 添加蓝色标签
|
||||
|
||||
const regex = /\[(\d+(?:–\d+)?(?:,\d+(?:–\d+)?)*)\]/g;
|
||||
|
||||
|
||||
formattedText = formattedText.replace(/<blue>/g, '').replace(/<\/blue>/g, ''); // 先去掉所有的 <blue> 标签
|
||||
|
||||
if (regex.test(formattedText)) {
|
||||
formattedText = formattedText.replace(regex, `<blue>$&</blue>`); // 然后再进行替换
|
||||
}
|
||||
const regex = /\[(\d+(?:–\d+)?(?:, ?\d+(?:–\d+)?)*)\]/g;
|
||||
|
||||
formattedText = formattedText.replace(/<blue>/g, '').replace(/<\/blue>/g, ''); // 先去掉所有的 <blue> 标签
|
||||
|
||||
if (regex.test(formattedText)) {
|
||||
formattedText = formattedText.replace(regex, function(match) {
|
||||
// 提取出方括号中的内容,并进行匹配
|
||||
const content = match.slice(1, match.length - 1); // 去掉方括号
|
||||
|
||||
// 判断是否符合条件,纯数字、逗号后有空格、连字符
|
||||
if (/^\d+$/.test(content) || /, ?/.test(content) || /–/.test(content)) {
|
||||
return `<blue>${match}</blue>`; // 如果符合条件则加上蓝色标签
|
||||
}
|
||||
return match; // 如果不符合条件,则保持原样
|
||||
});
|
||||
}
|
||||
console.log("After replacement:", formattedText); // 调试:查看替换后的文本
|
||||
|
||||
|
||||
|
||||
|
||||
paragraphText += formattedText;
|
||||
}
|
||||
@@ -339,7 +366,7 @@ if (regex.test(str)) {
|
||||
}
|
||||
},
|
||||
transformHtmlString(inputHtml) {
|
||||
console.log('inputHtml at line 332:', inputHtml)
|
||||
|
||||
inputHtml = inputHtml.replace(/(<[^>]+) style="[^"]*"/g, '$1'); // 移除style属性
|
||||
inputHtml = inputHtml.replace(/(<[^>]+) class="[^"]*"/g, '$1'); // 移除class属性
|
||||
|
||||
@@ -1273,7 +1300,7 @@ if (regex.test(str)) {
|
||||
emTags[i].parentNode.replaceChild(iTag, emTags[i]);
|
||||
}
|
||||
content = div.innerHTML;
|
||||
console.log('content at line 486:', content);
|
||||
|
||||
vueInstance.$emit('saveContent', content, dataId);
|
||||
}
|
||||
}
|
||||
@@ -1363,6 +1390,8 @@ if (regex.test(str)) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ed.ui.registry.addButton('commentAdd', {
|
||||
icon: 'comment-add',
|
||||
text: 'Comment Add',
|
||||
@@ -1508,6 +1537,80 @@ if (regex.test(str)) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ed.ui.registry.addButton('myuppercase', {
|
||||
text: 'A', // 按钮文本
|
||||
|
||||
onAction: function () {
|
||||
// 在选中的文本周围包裹 <blue> 标签
|
||||
var selectedText = ed.selection.getContent({ format: 'html' });
|
||||
|
||||
// 确保选中的文本是单个单词,包括空格
|
||||
if (selectedText.trim() && /^[\s\w]+$/.test(selectedText)) {
|
||||
// 使用正则将选中的文本中的第一个字母大写
|
||||
var capitalizedText = selectedText.replace(/(^|\s)([a-zA-Z])/g, function(match, p1, p2) {
|
||||
return p1 + p2.toUpperCase();
|
||||
});
|
||||
|
||||
// 替换选中的文本,保持空格和其他内容
|
||||
ed.selection.setContent(capitalizedText);
|
||||
} else {
|
||||
vueInstance.$message.error(vueInstance.$t('commonTable.selectWord'));
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
ed.ui.registry.addButton('myuppercase', {
|
||||
text: 'A', // 按钮文本
|
||||
|
||||
onAction: function () {
|
||||
// 在选中的文本周围包裹 <blue> 标签
|
||||
var selectedText = ed.selection.getContent({ format: 'html' });
|
||||
|
||||
// 确保选中的文本是单个单词,包括空格
|
||||
if (selectedText.trim() && /^[\s\w]+$/.test(selectedText)) {
|
||||
// 使用正则将选中的文本中的第一个字母大写
|
||||
var capitalizedText = selectedText.replace(/(^|\s)([a-zA-Z])/g, function(match, p1, p2) {
|
||||
return p1 + p2.toUpperCase();
|
||||
});
|
||||
|
||||
// 替换选中的文本,保持空格和其他内容
|
||||
ed.selection.setContent(capitalizedText);
|
||||
} else {
|
||||
vueInstance.$message.error(vueInstance.$t('commonTable.selectWord'));
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
ed.ui.registry.addButton('myuppercasea', {
|
||||
text: 'a', // 按钮文本(小写字母)
|
||||
onAction: function () {
|
||||
// 获取选中的文本,保留 HTML 格式
|
||||
var selectedText = ed.selection.getContent({ format: 'html' });
|
||||
|
||||
// 确保选中的文本是单个有效的单词,包括空格
|
||||
if (selectedText.trim() && /^[\s\w]+$/.test(selectedText)) {
|
||||
// 使用正则将选中的文本中的第一个字母转换为小写
|
||||
var lowercasedText = selectedText.replace(/(^|\s)([a-zA-Z])/g, function(match, p1, p2) {
|
||||
return p1 + p2.toLowerCase();
|
||||
});
|
||||
|
||||
// 替换选中的文本,保持空格和其他内容
|
||||
ed.selection.setContent(lowercasedText);
|
||||
} else {
|
||||
vueInstance.$message.error(vueInstance.$t('commonTable.selectWord'));
|
||||
}
|
||||
}
|
||||
});
|
||||
ed.ui.registry.addButton('Line', {
|
||||
text: '−', // 按钮文本
|
||||
onAction: function () {
|
||||
// 插入 `−` 符号到当前光标位置
|
||||
ed.insertContent('−');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ed.ui.registry.addButton('removeBlue', {
|
||||
text: 'Blue', // 按钮文本
|
||||
onAction: function () {
|
||||
|
||||
Reference in New Issue
Block a user