This commit is contained in:
2026-01-15 11:52:41 +08:00
parent fe4acbb709
commit b15772e323
15 changed files with 4433 additions and 1346 deletions

View File

@@ -88,7 +88,7 @@
</div> -->
<common-word
:articleId="articleId"
v-if="htmlContent"
ref="commonWord"
:value="htmlContent"
@@ -96,6 +96,7 @@
:comments="comments"
:wordStyle="wordStyle"
@onDrop="onDrop"
@onLinkConfirm="handleConfirmLink"
@saveContent="saveContent"
@editComment="editComment"
@loaded="loadedWord"
@@ -154,6 +155,10 @@
</el-form-item>
<el-form-item label="Figure Title :">
<span slot="label">
<font style="color: #f56c6c; margin-right: 5px">*</font>
Figure Title :
</span>
<common-content
:isAutomaticUpdate="true"
:value="picStyle.title"
@@ -207,6 +212,10 @@
<!-- <common-late-x></common-late-x> -->
<!-- :id="`editor-${new Date().getTime()}-${lineStyle.am_id}-${lineStyle.amt_id}-title`" -->
<el-form-item label="Title:">
<span slot="label">
<font style="color: #f56c6c; margin-right: 5px">*</font>
Title:
</span>
<common-content
:id="`editor-${new Date().getTime()}-${lineStyle.am_id}-${lineStyle.amt_id}-title`"
:isAutomaticUpdate="true"
@@ -696,6 +705,34 @@ export default {
this.addComment(content);
}
},
handleConfirmLink(selectedMedia) {
// selectedMedia 是你从 el-radio 列表中选中的那一项(包含 ami_id 或 amt_id
const targetId = selectedMedia.select.amt_id || selectedMedia.select.ami_id;
const type = selectedMedia.type; // 'table' 或 'figure'
const tagName = `my${type}`; // 生成 mytable 或 myfigure
// 获取当前段落原本的完整 HTML 内容
let originalContent = selectedMedia.linkData.content;
// 获取用户选中的纯文本片段
const label = selectedMedia.linkData.label;
if (!label || !originalContent) return;
// --- 核心替换逻辑 ---
// 使用正则匹配选中的文字,并用自定义标签包裹它
// 注意:这里需要考虑 label 在 HTML 中可能被拆分的情况,简单处理可直接 replace
const replacement = `<${tagName} data-id="${targetId}">${label}</${tagName}>`;
// 执行替换(仅替换第一次匹配到的,防止全篇误伤)
const newContent = originalContent.replace(label, replacement);
console.log('newContent at line 592:', newContent);
this.saveContent(newContent, selectedMedia.linkData.mainId);
},
async saveContent(content, am_id) {
var that = this;
var str = content.replace(/^<p>\s*(.*?)\s*<\/p>$/, '$1').trim();
@@ -1622,10 +1659,19 @@ this.lineStyle1 = { ...formattedData }; // 使用浅拷贝确保两个变量指
// 确定保存图片
async savePic() {
this.picStyle.picUrl;
var str = this.picStyle1.note ? await this.$commonJS.decodeHtml(this.picStyle1.note) : '';
var titleStr = this.picStyle1.title ? await this.$commonJS.decodeHtml(this.picStyle1.title) : '';
if (!this.picStyle.picUrl) {
this.$message.error('Please upload a picture');
return;
}
if (!titleStr) {
this.$message.error('Please enter a title');
return;
}
if (this.picStyle.visiTitle == 'Edit Figure') {
this.$api
.post(this.urlList.editImage, {
@@ -1720,14 +1766,18 @@ this.lineStyle1 = { ...formattedData }; // 使用浅拷贝确保两个变量指
}
if (strTitle != '') {
strTitle = await this.$commonJS.decodeHtml(strTitle);
}else{
this.$message.error('Please enter a title');
return;
}
const loading = this.$loading({
if (content && cleanedTableList && cleanedTableList.length > 0) {
const loading = this.$loading({
lock: true,
text: 'Loading...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
if (content && cleanedTableList && cleanedTableList.length > 0) {
if (this.lineStyle.visiTitle == 'Edit Table') {
this.$api
.post(this.urlList.editTable, {
@@ -2287,4 +2337,5 @@ this.lineStyle1 = { ...formattedData }; // 使用浅拷贝确保两个变量指
background-color: #0066990d;
/* display: block !important; */
}
</style>