提交
This commit is contained in:
@@ -226,8 +226,7 @@ export default {
|
||||
|
||||
|
||||
str = this.transformHtmlString(processedContent, 'table',{ keepBr: true })
|
||||
console.log("🚀 ~ extractContentWithoutOuterSpan888888 ~ str:", str);
|
||||
|
||||
|
||||
|
||||
// 创建一个临时的 DOM 元素来解析 HTML
|
||||
const div = document.createElement('div');
|
||||
@@ -917,9 +916,9 @@ str = str.replace(regex, function (match, content, offset, fullString) {
|
||||
});
|
||||
// 2. 删除所有不需要的标签 (除 `strong`, `em`, `sub`, `sup`, `b`, `i` 外的所有标签)
|
||||
if (type == 'table') {
|
||||
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|img|myfigure|mytable|myh3))[^>]+>/g, ''); // 删除不需要的标签
|
||||
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|img|myfigure|mytable|myh3|autocite))[^>]+>/g, ''); // 删除不需要的标签
|
||||
} else {
|
||||
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|myfigure|mytable|myh3))[^>]+>/g, ''); // 删除不需要的标签
|
||||
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|myfigure|mytable|myh3|autocite))[^>]+>/g, ''); // 删除不需要的标签
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1152,12 +1152,17 @@ colTitle: 'Template title',
|
||||
placeholder: 'Please enter email content'
|
||||
},
|
||||
wordCite: {
|
||||
noRefs: 'Reference list is not loaded yet. Please wait or refresh the page.',
|
||||
notFoundById: 'No reference found for citation ID {id}',
|
||||
selectRef: 'Select Reference',
|
||||
reference: 'Reference',
|
||||
cancel: 'Cancel',
|
||||
confirm: 'Confirm',
|
||||
remove: 'Remove'
|
||||
remove: 'Remove',
|
||||
selected: 'Selected',
|
||||
modifyRef: 'Edit citation',
|
||||
removeRefTag: 'Remove citation',
|
||||
citeUpdateFail: 'Could not update the citation in the text. Try again or use Edit.'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1137,12 +1137,17 @@ const zh = {
|
||||
placeholder: '请输入邮件内容'
|
||||
},
|
||||
wordCite: {
|
||||
noRefs: '参考文献列表尚未加载,请稍候再试或刷新页面',
|
||||
notFoundById: '未查询到编号{id}相关参考文献',
|
||||
selectRef: '选择参考文献',
|
||||
reference: '参考文献',
|
||||
cancel: '取消',
|
||||
confirm: '确认',
|
||||
remove: '移除'
|
||||
remove: '移除',
|
||||
selected: '已选择',
|
||||
modifyRef: '修改引用',
|
||||
removeRefTag: '移除引用',
|
||||
citeUpdateFail: '未能更新正文中的引用标签,请重试或进入编辑修改'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
@onEditTitle="onEditTitle"
|
||||
@onAddRow="onAddRow"
|
||||
@changeComment="changeComment"
|
||||
@openRefSelector="handleOpenRefSelectorFromManuscript"
|
||||
style="width: calc(100%); height: calc(100%)"
|
||||
:style="`100%`"
|
||||
>
|
||||
@@ -447,34 +448,46 @@
|
||||
<el-dialog
|
||||
:title="$t('wordCite.selectRef')"
|
||||
:visible.sync="refSelectorVisible"
|
||||
width="860px"
|
||||
width="900px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div v-if="refSelectedRows.length > 0" style="margin-bottom: 10px; font-size: 13px; color: #606266;">
|
||||
{{ $t('wordCite.selected') }}: <b style="color: #0082AA;">[{{ refPreviewLabel }}]</b>
|
||||
</div>
|
||||
<el-table
|
||||
ref="refSelectorTable"
|
||||
:data="chanFerForm"
|
||||
highlight-current-row
|
||||
@current-change="handleRefCurrentChange"
|
||||
@selection-change="handleRefSelectionChange"
|
||||
style="width: 100%"
|
||||
max-height="400"
|
||||
max-height="420"
|
||||
size="small"
|
||||
row-key="p_refer_id"
|
||||
>
|
||||
<el-table-column type="index" :label="'#'" width="60" :index="idx => idx + 1"></el-table-column>
|
||||
<el-table-column :label="$t('wordCite.reference')">
|
||||
<el-table-column type="selection" width="45" :reserve-selection="true"></el-table-column>
|
||||
<el-table-column :label="'#'" width="50">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.refer_frag || [scope.row.author, scope.row.title, scope.row.joura, scope.row.dateno].filter(Boolean).join(' ') || '-' }}
|
||||
<b>{{ scope.$index + 1 }}.</b>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="DOI" width="200">
|
||||
<el-table-column :label="$t('wordCite.reference')">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.doilink || scope.row.doi || scope.row.isbn || '-' }}
|
||||
<div style="line-height: 1.6;">
|
||||
<span>{{ scope.row.refer_frag || [scope.row.author, scope.row.title, scope.row.joura, scope.row.dateno].filter(Boolean).join('. ') || '-' }}</span>
|
||||
<br v-if="scope.row.doilink || scope.row.doi || scope.row.isbn">
|
||||
<a v-if="scope.row.doilink || scope.row.doi || scope.row.isbn"
|
||||
:href="(scope.row.doilink || scope.row.doi || '').startsWith('http') ? (scope.row.doilink || scope.row.doi) : 'https://doi.org/' + (scope.row.doilink || scope.row.doi || scope.row.isbn)"
|
||||
target="_blank"
|
||||
style="color: #0082AA; font-size: 12px;"
|
||||
>{{ scope.row.doilink || scope.row.doi || scope.row.isbn }}</a>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="refSelectorVisible = false">{{ $t('wordCite.cancel') }}</el-button>
|
||||
<el-button type="danger" v-if="refSelectorCurrentRefId" @click="handleRemoveRefCite">{{ $t('wordCite.remove') }}</el-button>
|
||||
<el-button type="primary" :disabled="!refSelectedRow" @click="handleConfirmRefCite">{{ $t('wordCite.confirm') }}</el-button>
|
||||
<el-button type="danger" v-if="refSelectorIsEdit" @click="handleRemoveRefCite">{{ $t('wordCite.remove') }}</el-button>
|
||||
<el-button type="primary" :disabled="refSelectedRows.length === 0" @click="handleConfirmRefCite">{{ $t('wordCite.confirm') }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -616,8 +629,8 @@ export default {
|
||||
chanFerForm: [],
|
||||
chanFerFormRepeatList: [],
|
||||
refSelectorVisible: false,
|
||||
refSelectorCurrentRefId: null,
|
||||
refSelectedRow: null,
|
||||
refSelectorIsEdit: false,
|
||||
refSelectedRows: [],
|
||||
refSelectorSource: 'commonContent'
|
||||
};
|
||||
},
|
||||
@@ -628,6 +641,29 @@ export default {
|
||||
editPublicRefTableOnly
|
||||
},
|
||||
computed: {
|
||||
refPreviewLabel() {
|
||||
if (!this.refSelectedRows.length) return '';
|
||||
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
|
||||
const nums = this.refSelectedRows.map((row) => {
|
||||
const idx = refs.findIndex((r) => r.p_refer_id === row.p_refer_id);
|
||||
return idx >= 0 ? idx + 1 : null;
|
||||
}).filter((n) => n != null);
|
||||
if (!nums.length) return '?';
|
||||
const sorted = [...new Set(nums)].sort((a, b) => a - b);
|
||||
const result = [];
|
||||
let i = 0;
|
||||
while (i < sorted.length) {
|
||||
let j = i;
|
||||
while (j < sorted.length - 1 && sorted[j + 1] === sorted[j] + 1) j++;
|
||||
if (j - i >= 2) {
|
||||
result.push(`${sorted[i]}–${sorted[j]}`);
|
||||
} else {
|
||||
for (let k = i; k <= j; k++) result.push(sorted[k]);
|
||||
}
|
||||
i = j + 1;
|
||||
}
|
||||
return result.join(', ');
|
||||
},
|
||||
catalogueContent() {
|
||||
const base = Array.isArray(this.Main_List) ? this.Main_List : [];
|
||||
if (!Array.isArray(this.chanFerForm) || this.chanFerForm.length === 0) return base;
|
||||
@@ -721,41 +757,89 @@ export default {
|
||||
if (this.$refs.editPublicRefTableOnly) {
|
||||
this.$refs.editPublicRefTableOnly.init();
|
||||
}
|
||||
if (this.editVisible && this.$refs.commonContent && this.$refs.commonContent.refreshAutociteDisplay) {
|
||||
this.$refs.commonContent.refreshAutociteDisplay();
|
||||
}
|
||||
if (this.addContentVisible && this.$refs.addContent && this.$refs.addContent.refreshAutociteDisplay) {
|
||||
this.$refs.addContent.refreshAutociteDisplay();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
handleOpenRefSelector(data) {
|
||||
this.refSelectorCurrentRefId = data && data.currentRefId ? data.currentRefId : null;
|
||||
this.refSelectedRow = null;
|
||||
if (this.editVisible) {
|
||||
handleOpenRefSelectorFromManuscript(data) {
|
||||
this.handleOpenRefSelector(data, 'manuscriptAutocite');
|
||||
},
|
||||
handleOpenRefSelector(data, sourceOverride) {
|
||||
const currentIds = data && Array.isArray(data.currentRefIds) ? data.currentRefIds : [];
|
||||
this.refSelectorIsEdit = currentIds.length > 0;
|
||||
this.refSelectedRows = [];
|
||||
if (sourceOverride === 'manuscriptAutocite' || (data && data.source === 'manuscript')) {
|
||||
this.refSelectorSource = 'manuscriptAutocite';
|
||||
} else if (this.editVisible) {
|
||||
this.refSelectorSource = 'commonContent';
|
||||
} else if (this.addContentVisible) {
|
||||
this.refSelectorSource = 'addContent';
|
||||
}
|
||||
this.refSelectorVisible = true;
|
||||
this.$nextTick(() => {
|
||||
const table = this.$refs.refSelectorTable;
|
||||
if (table) {
|
||||
table.clearSelection();
|
||||
if (currentIds.length > 0) {
|
||||
const idSet = new Set(currentIds.map(String));
|
||||
this.chanFerForm.forEach((row) => {
|
||||
if (idSet.has(String(row.p_refer_id))) {
|
||||
table.toggleRowSelection(row, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
handleRefCurrentChange(row) {
|
||||
this.refSelectedRow = row;
|
||||
handleRefSelectionChange(rows) {
|
||||
this.refSelectedRows = rows;
|
||||
},
|
||||
handleConfirmRefCite() {
|
||||
if (!this.refSelectedRow) return;
|
||||
if (this.refSelectedRows.length === 0) return;
|
||||
const ids = this.refSelectedRows.map((r) => r.p_refer_id);
|
||||
if (this.refSelectorSource === 'manuscriptAutocite') {
|
||||
const w = this.$refs.commonWord;
|
||||
if (w && typeof w.applyManuscriptAutocite === 'function') {
|
||||
w.applyManuscriptAutocite(ids);
|
||||
}
|
||||
this.refSelectorVisible = false;
|
||||
this.refSelectedRows = [];
|
||||
return;
|
||||
}
|
||||
const ref = this.$refs[this.refSelectorSource];
|
||||
if (ref) {
|
||||
ref.insertAutocite(this.refSelectedRow.p_refer_id);
|
||||
ref.insertAutocite(ids);
|
||||
}
|
||||
this.refSelectorVisible = false;
|
||||
this.refSelectedRow = null;
|
||||
this.refSelectedRows = [];
|
||||
},
|
||||
handleRemoveRefCite() {
|
||||
const idsToStrip = (this.refSelectedRows || []).map((r) => r.p_refer_id);
|
||||
if (this.refSelectorSource === 'manuscriptAutocite') {
|
||||
const w = this.$refs.commonWord;
|
||||
if (w && typeof w.stripManuscriptAutociteIds === 'function') {
|
||||
w.stripManuscriptAutociteIds(idsToStrip);
|
||||
}
|
||||
this.refSelectorVisible = false;
|
||||
this.refSelectedRows = [];
|
||||
return;
|
||||
}
|
||||
const ref = this.$refs[this.refSelectorSource];
|
||||
if (ref) {
|
||||
if (ref && typeof ref.stripAutociteIds === 'function') {
|
||||
ref.stripAutociteIds(idsToStrip);
|
||||
} else if (ref) {
|
||||
ref.removeAutocite();
|
||||
}
|
||||
this.refSelectorVisible = false;
|
||||
this.refSelectedRow = null;
|
||||
this.refSelectedRows = [];
|
||||
},
|
||||
ChanFerMashUp(e) {
|
||||
this.$api
|
||||
@@ -1825,6 +1909,16 @@ export default {
|
||||
|
||||
this.editVisible = true;
|
||||
this.currentId = dataId;
|
||||
if (this.p_article_id) {
|
||||
this.fetchReferList();
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.commonContent && this.$refs.commonContent.refreshAutociteDisplay) {
|
||||
this.$refs.commonContent.refreshAutociteDisplay();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
onAddContent(dataId) {
|
||||
|
||||
@@ -147,7 +147,7 @@ export default {
|
||||
handler(val) {
|
||||
if (!this.hasChange && this.hasInit) {
|
||||
this.$nextTick(() => {
|
||||
window.tinymce.get(this.tinymceId).setContent(val);
|
||||
this.handleSetContent(val);
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -155,9 +155,11 @@ export default {
|
||||
},
|
||||
chanFerForm: {
|
||||
handler() {
|
||||
if (this.editorInstance) {
|
||||
this.renderAutociteInEditor(this.editorInstance);
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (this.editorInstance) {
|
||||
this.renderAutociteInEditor(this.editorInstance);
|
||||
}
|
||||
});
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
@@ -183,10 +185,52 @@ export default {
|
||||
this.destroyTinymce();
|
||||
},
|
||||
methods: {
|
||||
/** 与正文一致:两项连续写作 1, 2;三项及以上连续写作 1-3 */
|
||||
formatCiteNumbers(nums) {
|
||||
if (!nums || !nums.length) return '';
|
||||
const sorted = [...new Set(nums)].sort((a, b) => a - b);
|
||||
const result = [];
|
||||
let i = 0;
|
||||
while (i < sorted.length) {
|
||||
let j = i;
|
||||
while (j < sorted.length - 1 && sorted[j + 1] === sorted[j] + 1) j++;
|
||||
if (j - i >= 2) {
|
||||
result.push(`${sorted[i]}–${sorted[j]}`);
|
||||
} else {
|
||||
for (let k = i; k <= j; k++) result.push(sorted[k]);
|
||||
}
|
||||
i = j + 1;
|
||||
}
|
||||
return result.join(', ');
|
||||
},
|
||||
parseAutociteDataIds(attr) {
|
||||
if (!attr || typeof attr !== 'string') return [];
|
||||
return attr
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
},
|
||||
/** 与 word.vue renderCiteLabels:tooltip 行按引用序号排序 */
|
||||
sortAutociteIdsByCiteNumber(ids) {
|
||||
const uniq = [...new Set(ids.map(String))];
|
||||
const map = this.citeMap || {};
|
||||
return uniq.sort((a, b) => {
|
||||
const na = map[a];
|
||||
const nb = map[b];
|
||||
const ha = na != null && na !== '';
|
||||
const hb = nb != null && nb !== '';
|
||||
if (ha && hb) return Number(na) - Number(nb);
|
||||
if (ha) return -1;
|
||||
if (hb) return 1;
|
||||
return String(a).localeCompare(String(b));
|
||||
});
|
||||
},
|
||||
renderAutociteInEditor(ed) {
|
||||
const body = ed.getBody();
|
||||
if (!body) return;
|
||||
const autocites = body.querySelectorAll('autocite');
|
||||
const allAutocites = Array.from(body.querySelectorAll('autocite'));
|
||||
if (!allAutocites.length) return;
|
||||
|
||||
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
|
||||
const refMap = {};
|
||||
refs.forEach((item) => {
|
||||
@@ -194,41 +238,65 @@ export default {
|
||||
if (key) refMap[key] = item;
|
||||
});
|
||||
|
||||
autocites.forEach((el) => {
|
||||
allAutocites.forEach((el) => {
|
||||
ed.dom.setAttrib(el, 'contenteditable', 'false');
|
||||
const dataId = el.getAttribute('data-id');
|
||||
const num = this.citeMap[String(dataId)];
|
||||
el.textContent = num != null ? `[${num}]` : '[?]';
|
||||
el.style.display = '';
|
||||
const ids = this.parseAutociteDataIds(el.getAttribute('data-id'));
|
||||
const sortedIds = this.sortAutociteIdsByCiteNumber(ids);
|
||||
const nums = sortedIds.map((id) => this.citeMap[String(id)]).filter((n) => n != null);
|
||||
const label = nums.length > 0 ? this.formatCiteNumbers(nums) : '?';
|
||||
|
||||
const ref = refMap[String(dataId)];
|
||||
if (ref) {
|
||||
const content = ref.refer_frag || [ref.author, ref.title, ref.joura, ref.dateno].filter(Boolean).join(' ').trim() || '';
|
||||
const doi = ref.doilink || ref.isbn || ref.doi || '';
|
||||
const tip = `[${num || '?'}] ${content}${doi ? '\nDOI: ' + doi : ''}`;
|
||||
ed.dom.setAttrib(el, 'title', tip);
|
||||
} else {
|
||||
ed.dom.setAttrib(el, 'title', this.$t('wordCite.notFoundById', { id: num != null ? num : dataId }));
|
||||
const lines = sortedIds.map((id) => {
|
||||
const no = this.citeMap[String(id)] != null ? this.citeMap[String(id)] : '?';
|
||||
const ref = refMap[String(id)];
|
||||
if (!ref) return this.$t('wordCite.notFoundById', { id: no === '?' ? id : no });
|
||||
const content = ref.refer_frag || [ref.author, ref.title, ref.joura, ref.dateno].filter(Boolean).join(' ').trim() || '[?]';
|
||||
const doi = ref.doilink || ref.isbn || ref.doi || '[?]';
|
||||
return `[${no}] ${content}\nDOI: ${doi}`;
|
||||
});
|
||||
|
||||
el.textContent = `[${label}]`;
|
||||
ed.dom.setAttrib(el, 'title', lines.join('\n'));
|
||||
});
|
||||
this.padAutociteCaretPlaceholder(ed);
|
||||
},
|
||||
/** 段尾不可编辑节点后浏览器/TinyMCE 容易把后续输入新开 <p>,在引用后补零宽空格让光标留在同一段 */
|
||||
padAutociteCaretPlaceholder(ed) {
|
||||
const doc = ed.getDoc();
|
||||
const body = doc.body;
|
||||
if (!body) return;
|
||||
body.querySelectorAll('autocite').forEach((el) => {
|
||||
const next = el.nextSibling;
|
||||
if (next === null) {
|
||||
el.parentNode.appendChild(doc.createTextNode('\u200b'));
|
||||
return;
|
||||
}
|
||||
if (next.nodeType === 3) {
|
||||
if (next.textContent === '\u200b') return;
|
||||
if (next.textContent === '') {
|
||||
next.textContent = '\u200b';
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
insertAutocite(refId) {
|
||||
insertAutocite(refIds) {
|
||||
const ed = this.editorInstance;
|
||||
if (!ed) return;
|
||||
const ids = (Array.isArray(refIds) ? refIds : [refIds]).map(String);
|
||||
const dataId = ids.join(',');
|
||||
const escaped = dataId.replace(/"/g, '"');
|
||||
|
||||
if (this._editingAutocite) {
|
||||
this._editingAutocite.setAttribute('data-id', refId);
|
||||
const num = this.citeMap[String(refId)];
|
||||
this._editingAutocite.textContent = num != null ? `[${num}]` : '[?]';
|
||||
this._editingAutocite.setAttribute('data-id', dataId);
|
||||
this._editingAutocite = null;
|
||||
ed.fire('change');
|
||||
} else {
|
||||
if (this._refBookmark) {
|
||||
ed.selection.moveToBookmark(this._refBookmark);
|
||||
}
|
||||
const num = this.citeMap[String(refId)];
|
||||
const label = num != null ? `[${num}]` : '[?]';
|
||||
const html = `<autocite data-id="${refId}" contenteditable="false">${label}</autocite>`;
|
||||
ed.insertContent(html);
|
||||
ed.insertContent(`<autocite data-id="${escaped}" contenteditable="false"></autocite>​`);
|
||||
}
|
||||
this.renderAutociteInEditor(ed);
|
||||
},
|
||||
removeAutocite() {
|
||||
const ed = this.editorInstance;
|
||||
@@ -237,10 +305,45 @@ export default {
|
||||
this._editingAutocite = null;
|
||||
ed.fire('change');
|
||||
},
|
||||
/**
|
||||
* 从当前编辑的 autocite 中去掉指定 p_refer_id;去掉后无 id 则删除整段标签。
|
||||
* ids 为空:删除整段(与 removeAutocite 一致)。
|
||||
*/
|
||||
stripAutociteIds(idsToRemove) {
|
||||
const ed = this.editorInstance;
|
||||
if (!ed || !this._editingAutocite) return;
|
||||
const remove = new Set((idsToRemove || []).map((id) => String(id)));
|
||||
const el = this._editingAutocite;
|
||||
this._editingAutocite = null;
|
||||
if (remove.size === 0) {
|
||||
ed.dom.remove(el);
|
||||
ed.fire('change');
|
||||
return;
|
||||
}
|
||||
const parts = this.parseAutociteDataIds(el.getAttribute('data-id') || '');
|
||||
const remaining = parts.filter((id) => !remove.has(String(id)));
|
||||
if (remaining.length === 0) {
|
||||
ed.dom.remove(el);
|
||||
} else {
|
||||
const sorted = this.sortAutociteIdsByCiteNumber(remaining);
|
||||
el.setAttribute('data-id', sorted.join(','));
|
||||
this.renderAutociteInEditor(ed);
|
||||
}
|
||||
ed.fire('change');
|
||||
},
|
||||
/** TinyMCE 会剔除「空」的行内标签;空 autocite 必须在入编辑器前占位,否则合并引用 [1–3] 等整段消失 */
|
||||
normalizeAutociteHtmlForEditor(html) {
|
||||
if (!html || typeof html !== 'string') return html;
|
||||
let out = html.replace(/<autocite([^>]*)>\s*<\/autocite>/gi, '<autocite$1>​</autocite>');
|
||||
// 与 getSafeContent 标签边界逻辑一致:autocite 左右水平空白改为 ,不换行符(避免吃掉段间 \n)
|
||||
out = out.replace(/[^\S\r\n]+(?=<autocite\b)/gi, ' ');
|
||||
out = out.replace(/(?<=<\/autocite>)[^\S\r\n]+/gi, ' ');
|
||||
return out;
|
||||
},
|
||||
handleSetContent(val) {
|
||||
if (!this.editorInstance) return;
|
||||
|
||||
let finalContent = val || '';
|
||||
let finalContent = this.normalizeAutociteHtmlForEditor(val || '');
|
||||
// 你的业务逻辑:自动包裹 <p> 标签
|
||||
if (!finalContent.includes('wordTableHtml') && !finalContent.startsWith('<p>')) {
|
||||
finalContent = '<p>' + finalContent + '</p>';
|
||||
@@ -394,7 +497,10 @@ export default {
|
||||
},
|
||||
getDetail(val) {
|
||||
if (this.hasInit == true) {
|
||||
this.$nextTick(() => window.tinymce.get(this.tinymceId).setContent(val));
|
||||
this.$nextTick(() => {
|
||||
const ed = window.tinymce.get(this.tinymceId);
|
||||
if (ed) ed.setContent(this.normalizeAutociteHtmlForEditor(val || ''));
|
||||
});
|
||||
}
|
||||
},
|
||||
//将字符串添加到富文本编辑器中
|
||||
@@ -505,7 +611,7 @@ export default {
|
||||
return new Blob([u8arr], { type: mime });
|
||||
},
|
||||
formatHtml(val) {
|
||||
const rawValue = val || ''; // 处理 null
|
||||
const rawValue = this.normalizeAutociteHtmlForEditor(val || ''); // 须先于 cleanEmptyTags,否则空 autocite 被删
|
||||
const cleanEmptyTags = /<([a-zA-Z1-6]+)\b[^>]*><\/\1>/g;
|
||||
const replaceSpaces = /\s+(?=<)|(?<=>)\s+/g;
|
||||
const removeBr = /<br\s*\/?>/gi; // 移除所有 br 标签
|
||||
@@ -530,7 +636,7 @@ export default {
|
||||
}
|
||||
},
|
||||
getSafeContent(val) {
|
||||
const rawValue = val || '';
|
||||
const rawValue = this.normalizeAutociteHtmlForEditor(val || '');
|
||||
const cleanEmptyTags = /<([a-zA-Z1-6]+)\b[^>]*><\/\1>/g;
|
||||
const replaceSpaces = /\s+(?=<)|(?<=>)\s+/g;
|
||||
|
||||
@@ -572,7 +678,8 @@ export default {
|
||||
..._this.tinymceOtherInit,
|
||||
trim_span_elements: false, // 禁止修剪内联标签周围的空格
|
||||
extended_valid_elements: 'blue[*],autocite[*]',
|
||||
custom_elements: 'blue,autocite',
|
||||
/* ~ 前缀:按行内(类似 span)处理,否则默认当块级会拆段导致引用后强制换行 */
|
||||
custom_elements: 'blue,~autocite',
|
||||
valid_children: '+blue[#text|i|em|b|strong|span],+body[blue|autocite],+p[blue|autocite]',
|
||||
|
||||
inline: false, // 使用 iframe 模式
|
||||
@@ -615,16 +722,19 @@ export default {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
/* inline 与 blue 引用一致,避免 inline-block 在行尾产生多余换行感 */
|
||||
autocite {
|
||||
display: inline-block;
|
||||
display: inline;
|
||||
vertical-align: baseline;
|
||||
color: rgb(0, 130, 170);
|
||||
font-weight: bold;
|
||||
// font-weight: bold;
|
||||
cursor: pointer;
|
||||
padding: 0 2px;
|
||||
border-radius: 3px;
|
||||
background-color: rgba(0, 130, 170, 0.08);
|
||||
user-select: all;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
autocite:hover {
|
||||
background-color: rgba(0, 130, 170, 0.2);
|
||||
@@ -649,7 +759,23 @@ export default {
|
||||
},
|
||||
body_class: 'panel-body ',
|
||||
object_resizing: false,
|
||||
toolbar: this.toolbar.length > 0 ? this.toolbar : toolbar,
|
||||
toolbar: (function () {
|
||||
const tb = _this.toolbar;
|
||||
const hasCustom =
|
||||
(Array.isArray(tb) && tb.length > 0) ||
|
||||
(typeof tb === 'string' && tb.length > 0);
|
||||
/* 与 content.vue 默认一致,且含 insertRef;避免未传 toolbar 时引用到未定义的变量 */
|
||||
const defaultToolbar = [
|
||||
'bold italic |customBlue removeBlue|LateX insertRef| myuppercase myuppercasea Line MoreSymbols|subscript superscript|clearButton|searchreplace'
|
||||
];
|
||||
if (!hasCustom) return defaultToolbar;
|
||||
const rows = Array.isArray(tb) ? tb : [tb];
|
||||
return rows.map((row) =>
|
||||
typeof row === 'string' && row.indexOf('insertRef') === -1
|
||||
? row.replace(/\|LateX\|/g, '|LateX insertRef|').replace(/\|\s*LateX\s*\|/g, '| LateX insertRef |')
|
||||
: row
|
||||
);
|
||||
})(),
|
||||
menubar: false, // 启用菜单栏并保持必要的项目
|
||||
statusbar: false, // 关闭底部状态栏
|
||||
custom_colors: false,
|
||||
@@ -721,19 +847,29 @@ export default {
|
||||
text: 'Ref',
|
||||
tooltip: 'Insert Reference',
|
||||
onAction: function () {
|
||||
const refs = Array.isArray(_this.chanFerForm) ? _this.chanFerForm : [];
|
||||
if (refs.length === 0) {
|
||||
_this.$message.warning(_this.$t('wordCite.noRefs'));
|
||||
return;
|
||||
}
|
||||
_this._refBookmark = ed.selection.getBookmark(2);
|
||||
_this._editingAutocite = null;
|
||||
_this.$emit('openRefSelector', { currentRefId: null });
|
||||
_this.$emit('openRefSelector', { currentRefIds: [] });
|
||||
}
|
||||
});
|
||||
|
||||
ed.on('click', function (e) {
|
||||
const autociteEl = e.target.closest('autocite');
|
||||
if (autociteEl) {
|
||||
const dataId = autociteEl.getAttribute('data-id');
|
||||
const refs = Array.isArray(_this.chanFerForm) ? _this.chanFerForm : [];
|
||||
if (refs.length === 0) {
|
||||
_this.$message.warning(_this.$t('wordCite.noRefs'));
|
||||
return;
|
||||
}
|
||||
const dataIds = _this.parseAutociteDataIds(autociteEl.getAttribute('data-id'));
|
||||
_this._refBookmark = ed.selection.getBookmark(2);
|
||||
_this._editingAutocite = autociteEl;
|
||||
_this.$emit('openRefSelector', { currentRefId: dataId });
|
||||
_this.$emit('openRefSelector', { currentRefIds: dataIds });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -909,7 +1045,12 @@ export default {
|
||||
ed.on('GetContent', function (e) {
|
||||
e.content = e.content.replace(/<b>/g, '<strong>').replace(/<\/b>/g, '</strong>');
|
||||
e.content = e.content.replace(/<i>/g, '<em>').replace(/<\/em>/g, '</em>');
|
||||
e.content = e.content.replace(/<autocite([^>]*)>[^<]*<\/autocite>/gi, '<autocite$1></autocite>');
|
||||
e.content = e.content.replace(/<\/autocite>\s*​/gi, '</autocite>');
|
||||
e.content = e.content.replace(/<\/autocite>\s*\u200b/g, '</autocite>');
|
||||
e.content = e.content.replace(/<autocite([^>]*)>[^<]*<\/autocite>/gi, function (match, attrs) {
|
||||
var clean = attrs.replace(/\s*style="[^"]*"/gi, '').replace(/\s*title="[^"]*"/gi, '').replace(/\s*contenteditable="[^"]*"/gi, '');
|
||||
return '<autocite' + clean + '></autocite>';
|
||||
});
|
||||
});
|
||||
},
|
||||
paste_preprocess: function (plugin, args) {
|
||||
@@ -1075,7 +1216,8 @@ export default {
|
||||
},
|
||||
//设置内容
|
||||
setContent(value) {
|
||||
window.tinymce.get(this.tinymceId).setContent(value);
|
||||
const ed = window.tinymce.get(this.tinymceId);
|
||||
if (ed) ed.setContent(this.normalizeAutociteHtmlForEditor(value || ''));
|
||||
},
|
||||
//获取内容
|
||||
async getContent(type) {
|
||||
|
||||
@@ -44,8 +44,8 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
toolbarConfig() {
|
||||
const hasRefs = Array.isArray(this.chanFerForm) && this.chanFerForm.length > 0;
|
||||
const refBtn = hasRefs ? ' insertRef' : '';
|
||||
// Ref 必须始终出现在配置里:TinyMCE 只在 init 时读一次 toolbar,若首屏 chanFerForm 为空则按钮会永久缺失
|
||||
const refBtn = ' insertRef';
|
||||
if (!this.isAutomaticUpdate) {
|
||||
return [`bold italic |customBlue removeBlue|LateX${refBtn}| myuppercase myuppercasea Line MoreSymbols|subscript superscript|clearButton|searchreplace`];
|
||||
}
|
||||
@@ -107,6 +107,19 @@ export default {
|
||||
},
|
||||
removeAutocite() {
|
||||
this.$refs.tinymceChild1.removeAutocite();
|
||||
},
|
||||
/** 从当前 autocite 的 data-id 中移除指定 id;无剩余则删标签;未选 id 时删整段 */
|
||||
stripAutociteIds(ids) {
|
||||
if (this.$refs.tinymceChild1 && typeof this.$refs.tinymceChild1.stripAutociteIds === 'function') {
|
||||
this.$refs.tinymceChild1.stripAutociteIds(ids);
|
||||
}
|
||||
},
|
||||
/** 参考文献异步到达后刷新编辑器内 autocite 数字(供父组件在打开弹窗 / fetch 完成后调用) */
|
||||
refreshAutociteDisplay() {
|
||||
const t = this.$refs.tinymceChild1;
|
||||
if (t && typeof t.renderAutociteInEditor === 'function' && t.editorInstance) {
|
||||
t.renderAutociteInEditor(t.editorInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -963,7 +963,12 @@
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div v-if="isMenuVisible || bubbleVisible" class="wps-two-layer-bar selection-bubble no-select" :style="bubbleStyle">
|
||||
<div
|
||||
v-if="isMenuVisible || bubbleVisible"
|
||||
class="wps-two-layer-bar selection-bubble no-select"
|
||||
:style="bubbleStyle"
|
||||
@click.stop
|
||||
>
|
||||
<div class="bar-row" v-if="currentData">
|
||||
<div v-if="currentData.type == 0" class="h-group">
|
||||
<span :class="['h-item', { active: currentData.is_h1 == 1 }]" @click="changeTitle(currentData.is_h1 ? 0 : 1)">H1</span>
|
||||
@@ -977,9 +982,21 @@
|
||||
<div v-if="isEditComment" class="menu-item comment-feat" @mousedown="cacheSelection" @click="menuAction('comment')">
|
||||
<i class="el-icon-chat-line-square"></i><span>{{ $t('commonTable.Annotations') }}</span>
|
||||
</div>
|
||||
<div class="row-divider" v-if="isEditComment && currentData.type == 0"></div>
|
||||
<div class="row-divider" v-if="currentData.type == 0 && (isEditComment || manuscriptAutociteContext)"></div>
|
||||
|
||||
<div class="menu-item menu-link" v-if="currentData.type == 0 && !['figure', 'table'].includes(currentTag)" @click="menuAction('link')">
|
||||
<template v-if="manuscriptAutociteContext && currentData && currentData.type == 0">
|
||||
<div class="menu-item menu-autocite-ref" @click.stop="menuAction('editRefCite')">
|
||||
<i class="el-icon-edit-outline"></i><span>{{ $t('wordCite.modifyRef') }}</span>
|
||||
</div>
|
||||
<div class="menu-item menu-autocite-ref" @click.stop="menuAction('removeRefCite')">
|
||||
<i class="el-icon-remove-outline"></i><span>{{ $t('wordCite.removeRefTag') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
class="menu-item menu-link"
|
||||
v-if="currentData.type == 0 && !['figure', 'table'].includes(currentTag) && !manuscriptAutociteContext"
|
||||
@click="menuAction('link')"
|
||||
>
|
||||
<i class="el-icon-link"></i><span>{{ $t('commonTable.Association') }}</span>
|
||||
</div>
|
||||
<div class="menu-item menu-link menu-jump" v-if="currentData.type == 0 && ['figure', 'table'].includes(currentTag)" @click="menuAction('jump')">
|
||||
@@ -1163,6 +1180,8 @@ export default {
|
||||
editorsInitialized: {}, // 用于存储每个编辑器实例
|
||||
mediaUrl: mediaUrl, //
|
||||
lastTag: null,
|
||||
/** 稿面点击 <autocite> 时记录,用于浮动条「修改引用 / 移除引用」 */
|
||||
manuscriptAutociteContext: null,
|
||||
isEditComment: false,
|
||||
isUserEditComment: false,
|
||||
typesettingType: 1,
|
||||
@@ -1262,9 +1281,9 @@ export default {
|
||||
});
|
||||
if (Object.keys(mapFromRefs).length > 0) return mapFromRefs;
|
||||
|
||||
// 2) 兜底:按正文首次出现顺序编号
|
||||
// 2) 兜底:按正文首次出现顺序编号(支持 data-id 含多个逗号分隔 id)
|
||||
const order = [];
|
||||
const re = /<autocite\s+data-id="(\d+)"/gi;
|
||||
const re = /<autocite\s+data-id="([^"]+)"/gi;
|
||||
const paragraphs =
|
||||
Array.isArray(this.wordList) && this.wordList.length > 0
|
||||
? this.wordList
|
||||
@@ -1280,7 +1299,10 @@ export default {
|
||||
re.lastIndex = 0;
|
||||
let m;
|
||||
while ((m = re.exec(raw)) !== null) {
|
||||
if (!order.includes(m[1])) order.push(m[1]);
|
||||
m[1].split(',').forEach((part) => {
|
||||
const id = part.trim();
|
||||
if (id && !order.includes(id)) order.push(id);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1401,7 +1423,7 @@ export default {
|
||||
this.editors = {};
|
||||
},
|
||||
methods: {
|
||||
// 1. 引用序号合并算法 (1,2,3 -> 1-3)
|
||||
// 1. 引用序号合并:两项连续 1, 2;三项及以上连续 1-3(与富文本 autocite data-id 多 id 一致)
|
||||
formatCiteNumbers(nums) {
|
||||
if (!nums || !nums.length) return "";
|
||||
const sorted = [...new Set(nums)].sort((a, b) => a - b);
|
||||
@@ -1411,7 +1433,7 @@ formatCiteNumbers(nums) {
|
||||
let j = i;
|
||||
while (j < sorted.length - 1 && sorted[j + 1] === sorted[j] + 1) j++;
|
||||
if (j - i >= 2) {
|
||||
result.push(`${sorted[i]}-${sorted[j]}`);
|
||||
result.push(`${sorted[i]}–${sorted[j]}`);
|
||||
} else {
|
||||
for (let k = i; k <= j; k++) result.push(sorted[k]);
|
||||
}
|
||||
@@ -1420,12 +1442,35 @@ formatCiteNumbers(nums) {
|
||||
return result.join(', ');
|
||||
},
|
||||
|
||||
// 2. 最终引用标签渲染器 (将 autocite 转换为 [n])
|
||||
/** 合并引用 tooltip / title 行按正文序号排列,与 [2–4, 6] 标签一致 */
|
||||
sortAutociteIdsByCiteNumber(ids) {
|
||||
const uniq = [...new Set(ids)];
|
||||
const map = this.citeMap || {};
|
||||
return uniq.sort((a, b) => {
|
||||
const na = map[a];
|
||||
const nb = map[b];
|
||||
const ha = na != null && na !== '';
|
||||
const hb = nb != null && nb !== '';
|
||||
if (ha && hb) return Number(na) - Number(nb);
|
||||
if (ha) return -1;
|
||||
if (hb) return 1;
|
||||
return String(a).localeCompare(String(b));
|
||||
});
|
||||
},
|
||||
|
||||
// 2. 最终引用标签渲染器 (将 autocite 转换为 [n]);支持 data-id="a,b,c" 单标签 或 多个相邻单 id 标签(旧数据)
|
||||
renderCiteLabels(html) {
|
||||
// 匹配连续的引用标签
|
||||
const citeGroupRe = /(<autocite\s+data-id="(\d+)"\s*><\/autocite>\s*)+/gi;
|
||||
const citeGroupRe = /(?:<autocite\s+data-id="([^"]+)"\s*><\/autocite>\s*)+/gi;
|
||||
return html.replace(citeGroupRe, (groupMatch) => {
|
||||
const ids = [...groupMatch.matchAll(/data-id="(\d+)"/gi)].map((m) => String(m[1]));
|
||||
const ids = [];
|
||||
const innerRe = /<autocite\s+data-id="([^"]+)"\s*><\/autocite>/gi;
|
||||
let m;
|
||||
while ((m = innerRe.exec(groupMatch)) !== null) {
|
||||
m[1].split(',').forEach((part) => {
|
||||
const id = part.trim();
|
||||
if (id) ids.push(id);
|
||||
});
|
||||
}
|
||||
const refList = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
|
||||
const refMap = refList.reduce((acc, item) => {
|
||||
const key = item && item.p_refer_id != null ? String(item.p_refer_id) : '';
|
||||
@@ -1433,10 +1478,11 @@ renderCiteLabels(html) {
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const nums = ids.map((id) => this.citeMap && this.citeMap[id]).filter((n) => n != null);
|
||||
const sortedIds = this.sortAutociteIdsByCiteNumber(ids);
|
||||
const nums = sortedIds.map((id) => this.citeMap && this.citeMap[id]).filter((n) => n != null);
|
||||
const label = nums.length > 0 ? this.formatCiteNumbers(nums) : '?';
|
||||
|
||||
const lines = ids.map((id) => {
|
||||
const lines = sortedIds.map((id) => {
|
||||
const no = this.citeMap && this.citeMap[id] != null ? this.citeMap[id] : '?';
|
||||
const ref = refMap[id];
|
||||
if (!ref) {
|
||||
@@ -1451,7 +1497,14 @@ renderCiteLabels(html) {
|
||||
return `[${no}] ${content} DOI: ${doi}`;
|
||||
});
|
||||
|
||||
return `<blue title="${lines.join(' ')}">[${label}]<span style="display:none">${groupMatch}</span></blue>`;
|
||||
const escAttr = (s) =>
|
||||
String(s || '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/</g, '<');
|
||||
const dataIdAttr = escAttr(sortedIds.join(','));
|
||||
const titleAttr = escAttr(lines.join('\n'));
|
||||
return `<autocite data-id="${dataIdAttr}" title="${titleAttr}">[${label}]</autocite>`;
|
||||
});
|
||||
},
|
||||
getInvolvedPMain(range) {
|
||||
@@ -1578,6 +1631,7 @@ renderCiteLabels(html) {
|
||||
if(this.isPreview)return;
|
||||
// 如果点在气泡内,不关
|
||||
if (e.target.closest('.bubble-container')) return;
|
||||
if (e.target.closest('.selection-bubble')) return;
|
||||
|
||||
const selection = window.getSelection();
|
||||
const hasSelection = selection && selection.toString().trim() !== '';
|
||||
@@ -1590,6 +1644,7 @@ renderCiteLabels(html) {
|
||||
|
||||
this.currentData = {};
|
||||
this.currentId = '';
|
||||
this.manuscriptAutociteContext = null;
|
||||
|
||||
this.clearActiveGlow(); // 清除高亮
|
||||
}
|
||||
@@ -2038,6 +2093,132 @@ renderCiteLabels(html) {
|
||||
|
||||
this.isMenuVisible = false;
|
||||
},
|
||||
escapeHtmlAttr(val) {
|
||||
return String(val == null ? '' : val).replace(/&/g, '&').replace(/"/g, '"');
|
||||
},
|
||||
/** 同一组 data-id 不同顺序视为相同,便于稿面排序后与存储正文对齐 */
|
||||
normalizeAutociteDataIdKey(str) {
|
||||
const parts = String(str || '')
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
parts.sort((a, b) => {
|
||||
const na = Number(a);
|
||||
const nb = Number(b);
|
||||
if (!isNaN(na) && !isNaN(nb)) return na - nb;
|
||||
return String(a).localeCompare(String(b));
|
||||
});
|
||||
return parts.join(',');
|
||||
},
|
||||
/** 按 data-id 替换第一段匹配的 <autocite>;兼容稿面已排序、正文存储未排序的情况 */
|
||||
replaceFirstAutociteByDataId(html, dataId, replacement) {
|
||||
if (!html || typeof html !== 'string' || dataId == null || dataId === '') return html;
|
||||
const esc = String(dataId).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const reExact = new RegExp(`<autocite\\s[^>]*\\bdata-id="${esc}"[^>]*>[\\s\\S]*?<\\/autocite>`, 'i');
|
||||
let out = html.replace(reExact, replacement);
|
||||
if (out !== html) return out;
|
||||
|
||||
const keyWant = this.normalizeAutociteDataIdKey(dataId);
|
||||
if (!keyWant) return html;
|
||||
|
||||
const _this = this;
|
||||
let done = false;
|
||||
return html.replace(/<autocite\s([^>]*)>([\s\S]*?)<\/autocite>/gi, function (full, attrs) {
|
||||
if (done) return full;
|
||||
const dm = attrs.match(/\bdata-id\s*=\s*"([^"]*)"/i) || attrs.match(/\bdata-id\s*=\s*'([^']*)'/i);
|
||||
if (!dm) return full;
|
||||
if (_this.normalizeAutociteDataIdKey(dm[1]) !== keyWant) return full;
|
||||
done = true;
|
||||
return replacement;
|
||||
});
|
||||
},
|
||||
openManuscriptRefSelector() {
|
||||
const ctx = this.manuscriptAutociteContext;
|
||||
if (!ctx || !ctx.dataId) return;
|
||||
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
|
||||
if (refs.length === 0) {
|
||||
this.$message.warning(this.$t('wordCite.noRefs'));
|
||||
return;
|
||||
}
|
||||
const parts = String(ctx.dataId)
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
this.$emit('openRefSelector', { currentRefIds: parts, source: 'manuscript' });
|
||||
},
|
||||
applyManuscriptAutocite(refIds) {
|
||||
const ctx = this.manuscriptAutociteContext;
|
||||
if (!ctx || !ctx.am_id) return;
|
||||
const item = this.wordList.find((w) => w.am_id == ctx.am_id);
|
||||
if (!item || typeof item.content !== 'string') return;
|
||||
const ids = (Array.isArray(refIds) ? refIds : [refIds]).map(String);
|
||||
const dataId = ids.join(',');
|
||||
const newTag = `<autocite data-id="${this.escapeHtmlAttr(dataId)}"></autocite>`;
|
||||
const newContent = this.replaceFirstAutociteByDataId(item.content, ctx.dataId, newTag);
|
||||
if (newContent === item.content) {
|
||||
this.$message.warning(this.$t('wordCite.citeUpdateFail'));
|
||||
return;
|
||||
}
|
||||
this.$set(item, 'content', newContent);
|
||||
if (item.text !== undefined) this.$set(item, 'text', newContent);
|
||||
this.manuscriptAutociteContext = null;
|
||||
this.$emit('saveContent', newContent, ctx.am_id);
|
||||
},
|
||||
removeManuscriptAutocite() {
|
||||
this.stripManuscriptAutociteIds([]);
|
||||
},
|
||||
/**
|
||||
* 从稿面当前 autocite 的 data-id 中移除给定 id;移除后无 id 则删掉整段标签。
|
||||
* ids 为空:删除整段引用(稿面「移除引用」浮动按钮)。
|
||||
*/
|
||||
stripManuscriptAutociteIds(idsToRemove) {
|
||||
const ctx = this.manuscriptAutociteContext;
|
||||
if (!ctx || !ctx.am_id) return;
|
||||
const item = this.wordList.find((w) => w.am_id == ctx.am_id);
|
||||
if (!item || typeof item.content !== 'string') return;
|
||||
const removeSet = new Set((idsToRemove || []).map((id) => String(id)));
|
||||
if (removeSet.size === 0) {
|
||||
const newContent = this.replaceFirstAutociteByDataId(item.content, ctx.dataId, '');
|
||||
if (newContent === item.content) {
|
||||
this.$message.warning(this.$t('wordCite.citeUpdateFail'));
|
||||
return;
|
||||
}
|
||||
this.$set(item, 'content', newContent);
|
||||
if (item.text !== undefined) this.$set(item, 'text', newContent);
|
||||
this.manuscriptAutociteContext = null;
|
||||
this.$emit('saveContent', newContent, ctx.am_id);
|
||||
return;
|
||||
}
|
||||
|
||||
const keyWant = this.normalizeAutociteDataIdKey(ctx.dataId);
|
||||
const _this = this;
|
||||
let done = false;
|
||||
const newHtml = item.content.replace(/<autocite\s([^>]*)>([\s\S]*?)<\/autocite>/gi, function (full, attrs) {
|
||||
if (done) return full;
|
||||
const dm = attrs.match(/\bdata-id\s*=\s*"([^"]*)"/i) || attrs.match(/\bdata-id\s*=\s*'([^']*)'/i);
|
||||
if (!dm) return full;
|
||||
if (_this.normalizeAutociteDataIdKey(dm[1]) !== keyWant) return full;
|
||||
done = true;
|
||||
const parts = dm[1]
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
const remaining = parts.filter((id) => !removeSet.has(String(id)));
|
||||
if (remaining.length === 0) return '';
|
||||
const sorted = _this.sortAutociteIdsByCiteNumber(remaining);
|
||||
const newDataId = sorted.join(',');
|
||||
return `<autocite data-id="${_this.escapeHtmlAttr(newDataId)}"></autocite>`;
|
||||
});
|
||||
|
||||
if (!done || newHtml === item.content) {
|
||||
this.$message.warning(this.$t('wordCite.citeUpdateFail'));
|
||||
return;
|
||||
}
|
||||
this.$set(item, 'content', newHtml);
|
||||
if (item.text !== undefined) this.$set(item, 'text', newHtml);
|
||||
this.manuscriptAutociteContext = null;
|
||||
this.$emit('saveContent', newHtml, ctx.am_id);
|
||||
},
|
||||
handleAIProofreading() {
|
||||
if (this.currentId) {
|
||||
this.$api
|
||||
@@ -2095,6 +2276,12 @@ renderCiteLabels(html) {
|
||||
case 'delete':
|
||||
this.onDelete();
|
||||
break;
|
||||
case 'editRefCite':
|
||||
this.openManuscriptRefSelector();
|
||||
break;
|
||||
case 'removeRefCite':
|
||||
this.removeManuscriptAutocite();
|
||||
break;
|
||||
}
|
||||
this.closeMenu();
|
||||
},
|
||||
@@ -2159,7 +2346,7 @@ renderCiteLabels(html) {
|
||||
let selectedText = tempDiv.innerText.trim().replace(/\s+/g, ' ');
|
||||
|
||||
|
||||
const allowedTags = ['sup', 'sub', 'strong', 'em', 'b', 'i', 'blue', 'tr', 'td'];
|
||||
const allowedTags = ['sup', 'sub', 'strong', 'em', 'b', 'i', 'blue', 'autocite', 'tr', 'td'];
|
||||
function preserveTags(node) {
|
||||
if (node.nodeType === 3) return node.nodeValue; // 文本节点
|
||||
if (node.nodeType === 1 && allowedTags.includes(node.nodeName.toLowerCase())) {
|
||||
@@ -2903,6 +3090,14 @@ renderCiteLabels(html) {
|
||||
}
|
||||
this.currentTag = '';
|
||||
this.currentTagData = null; // 必须重置,防止带入旧数据
|
||||
this.manuscriptAutociteContext = null;
|
||||
const clickedAutocite = event.target.closest('autocite');
|
||||
if (clickedAutocite && !this.isPreview) {
|
||||
const dataId = clickedAutocite.getAttribute('data-id') || '';
|
||||
if (dataId) {
|
||||
this.manuscriptAutociteContext = { am_id: id, dataId };
|
||||
}
|
||||
}
|
||||
const clickedTag = event.target.closest('myfigure, mytable, myh3');
|
||||
if (clickedTag) {
|
||||
this.currentTag = clickedTag.tagName.toLowerCase().replace('my', '');
|
||||
@@ -3046,6 +3241,7 @@ renderCiteLabels(html) {
|
||||
// 如果你希望滚动时保持高亮,可以不清空这一行
|
||||
this.currentId = '';
|
||||
this.currentData = {};
|
||||
this.manuscriptAutociteContext = null;
|
||||
|
||||
// 4. 清除浏览器原生的文字选中蓝色区域
|
||||
// 这样滚动时就不会有一大片蓝色的选区跟着走,视觉上更干净
|
||||
@@ -4156,6 +4352,18 @@ renderCiteLabels(html) {
|
||||
.comment-feat {
|
||||
color: #f56c6c;
|
||||
}
|
||||
/* 稿面 autocite:与 Association 互斥,品牌色 */
|
||||
.menu-autocite-ref {
|
||||
color: #006699 !important;
|
||||
font-weight: 500;
|
||||
}
|
||||
.menu-autocite-ref i {
|
||||
color: #006699;
|
||||
}
|
||||
.menu-autocite-ref:hover {
|
||||
background-color: rgba(0, 102, 153, 0.08) !important;
|
||||
color: #006699 !important;
|
||||
}
|
||||
.menu-link {
|
||||
color: #2b81ef;
|
||||
}
|
||||
@@ -4494,6 +4702,18 @@ wmath {
|
||||
text-shadow: 0 0 3px #09c2fb, 0 0 4px rgba(0, 130, 170, 0.3);
|
||||
}
|
||||
|
||||
/* 正文预览:引用直接用语义标签 autocite(原 blue 包装已移除) */
|
||||
::v-deep autocite {
|
||||
display: inline;
|
||||
vertical-align: baseline;
|
||||
color: rgb(0, 130, 170) !important;
|
||||
/* font-weight: bold; */
|
||||
/* 勿用 cursor:help,浏览器会显示“问号”帮助光标;悬停仍可用原生 title 提示 */
|
||||
cursor: inherit;
|
||||
text-decoration: none;
|
||||
background-color: rgba(0, 130, 170, 0.08);
|
||||
}
|
||||
|
||||
::v-deep myfigure *,
|
||||
::v-deep mytable * {
|
||||
color: inherit !important;
|
||||
|
||||
@@ -123,10 +123,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<!-- <el-tooltip content="查看日志" placement="top">
|
||||
<el-button type="text" icon="el-icon-document" @click="handleAction('logs', item)"></el-button>
|
||||
</el-tooltip> -->
|
||||
<!-- <el-tooltip content="执行单次抓取" placement="top" > -->
|
||||
<div class="crawl-once-frame">
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="runOnceLoadingId === item.id ? 'el-icon-loading' : 'el-icon-finished'"
|
||||
@@ -134,16 +131,13 @@
|
||||
:disabled="runOnceLoadingId === item.id"
|
||||
@click="handleRunOnce(item)"
|
||||
>{{ runOnceLoadingId === item.id ? $t('crawlTask.runOnceLoading') : $t('crawlTask.runOnceBtn') }}</el-button>
|
||||
<!-- </el-tooltip> -->
|
||||
<!-- <el-tooltip :content="item.state == 'running' ? '暂停抓取' : '恢复抓取'" placement="top"> -->
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="item.state === 'running' ? 'el-icon-video-pause' : 'el-icon-video-play'"
|
||||
:class="['toggle-btn', item.state === 'running' ? 'op-pause' : 'op-resume']"
|
||||
@click="handleToggleTask(item)"
|
||||
>{{ item.state === 'running' ? $t('crawlTask.disabled') : $t('crawlTask.enabled') }}</el-button>
|
||||
<!-- </el-tooltip> -->
|
||||
|
||||
</div>
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="item.state === 'running' ? 'el-icon-video-pause' : 'el-icon-video-play'"
|
||||
:class="['toggle-btn', item.state === 'running' ? 'op-pause' : 'op-resume']"
|
||||
@click="handleToggleTask(item)"
|
||||
>{{ item.state === 'running' ? $t('crawlTask.disabled') : $t('crawlTask.enabled') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -483,6 +477,29 @@ export default {
|
||||
.prog-box { flex: 1; }
|
||||
.prog-num { font-size: 12px; font-weight: bold; display: block; text-align: right; margin-bottom: 4px; min-width: 56px; }
|
||||
.pagination-container { margin-top: 20px; display: flex; justify-content: flex-end; padding: 10px; }
|
||||
|
||||
.btn-group {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/* 单次抓取按钮单独线框(与右侧启停区分) */
|
||||
.crawl-once-frame {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid #006699;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
line-height: 1;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.crawl-once-frame .op-run-once {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.btn-group .el-button.op-pause,
|
||||
.btn-group .el-button.op-pause i { color: #fc4d4d !important; }
|
||||
.btn-group .el-button.op-resume,
|
||||
|
||||
@@ -349,7 +349,7 @@ export default {
|
||||
}
|
||||
// 如果连续数字 >= 3 个,使用连字符 '-'
|
||||
if (j - i >= 2) {
|
||||
result.push(`${sorted[i]}-${sorted[j]}`);
|
||||
result.push(`${sorted[i]}–${sorted[j]}`);
|
||||
} else {
|
||||
// 否则(1个或2个)逐个列出
|
||||
for (let k = i; k <= j; k++) {
|
||||
@@ -368,11 +368,19 @@ export default {
|
||||
let html = this.highlightText2(text, annotations, type, am_id);
|
||||
|
||||
// 2. 借鉴 EndNote:对处理完批注的 HTML 进行引用联动渲染
|
||||
// 正则匹配连续的 autocite 标签(允许中间有空格)
|
||||
const citeGroupRe = /(<autocite\s+data-id="(\d+)"\s*><\/autocite>\s*)+/gi;
|
||||
// 支持 data-id="a,b,c" 单标签 或 多个相邻单 id 标签
|
||||
const citeGroupRe = /(?:<autocite\s+data-id="([^"]+)"\s*><\/autocite>\s*)+/gi;
|
||||
|
||||
return html.replace(citeGroupRe, (groupMatch) => {
|
||||
const ids = [...groupMatch.matchAll(/data-id="(\d+)"/gi)].map((m) => m[1]);
|
||||
const ids = [];
|
||||
const innerRe = /<autocite\s+data-id="([^"]+)"\s*><\/autocite>/gi;
|
||||
let m;
|
||||
while ((m = innerRe.exec(groupMatch)) !== null) {
|
||||
m[1].split(',').forEach((part) => {
|
||||
const id = part.trim();
|
||||
if (id) ids.push(id);
|
||||
});
|
||||
}
|
||||
|
||||
// 从全局 citeMap 中获取序号(citeMap 是你根据全文顺序生成的 {ID: Index})
|
||||
const nums = ids.map((id) => this.citeMap[id]).filter((n) => n);
|
||||
@@ -1876,9 +1884,9 @@ export default {
|
||||
border-radius: 30px;
|
||||
}
|
||||
.text-highlight {
|
||||
background-color: rgb(252, 98, 93);
|
||||
/* background-color: rgb(252, 98, 93);
|
||||
background-color: rgb(252 98 93 / 68%);
|
||||
color: #333;
|
||||
color: #333; */
|
||||
}
|
||||
.template-info {
|
||||
margin-top: 20px;
|
||||
|
||||
Reference in New Issue
Block a user