0) {
+ return this.$t('commonTable.refHtmlPasteParsed', { n: this.referencesPasteCount });
+ }
+ return this.$t('commonTable.refHtmlPasteParseEmpty');
+ },
sortedProofreadingList() {
const order = [2, 1, 3];
const rank = { 2: 0, 1: 1, 3: 2 };
@@ -1496,6 +1601,164 @@ export default {
this.editors = {};
},
methods: {
+ async loadManuscriptReferences(forceReload) {
+ if (!forceReload && this.manuscriptReferences && this.manuscriptReferences.length) {
+ return this.manuscriptReferences;
+ }
+ if (!this.$api) {
+ throw new Error('NO_API');
+ }
+ const references = await fetchManuscriptReferenceList(this.$api, this.articleId, this.pArticleId);
+ this.manuscriptReferences = references || [];
+ return this.manuscriptReferences;
+ },
+ async handleCopyReferences() {
+ if (this.referencesCopyLoading) {
+ return;
+ }
+ if (!this.$api) {
+ this.$message.error(this.$t('commonTable.refHtmlLoadFail'));
+ return;
+ }
+
+ this.referencesCopyLoading = true;
+ try {
+ const references = await this.loadManuscriptReferences(false);
+ if (!references.length) {
+ this.$message.warning(this.$t('commonTable.refHtmlEmpty'));
+ return;
+ }
+ await copyReferencesToClipboard(references);
+ this.$message.success(this.$t('commonTable.refHtmlCopySuccess'));
+ } catch (err) {
+ console.error(err);
+ if (err && err.message === 'EMPTY') {
+ this.$message.warning(this.$t('commonTable.refHtmlEmpty'));
+ } else {
+ this.$message.error(this.$t('commonTable.refHtmlLoadFail'));
+ }
+ } finally {
+ this.referencesCopyLoading = false;
+ }
+ },
+ async handleDownloadReferencesHtml() {
+ if (this.referencesHtmlLoading) {
+ return;
+ }
+ if (!this.$api) {
+ this.$message.error(this.$t('commonTable.refHtmlLoadFail'));
+ return;
+ }
+
+ this.referencesHtmlLoading = true;
+ try {
+ const references = await this.loadManuscriptReferences(false);
+ if (!references.length) {
+ this.$message.warning(this.$t('commonTable.refHtmlEmpty'));
+ return;
+ }
+
+ const labels = buildReferencesHtmlLabels(this.$t.bind(this));
+ const fileName = 'references-editor' + (this.articleId ? '-' + this.articleId : '') + '.html';
+ downloadReferencesEditableHtml(references, labels, fileName);
+ this.$message.success(this.$t('commonTable.refHtmlDownloadSuccess'));
+ } catch (err) {
+ console.error(err);
+ this.$message.error(this.$t('commonTable.refHtmlLoadFail'));
+ } finally {
+ this.referencesHtmlLoading = false;
+ }
+ },
+ triggerReferencesUpload() {
+ const input = this.$refs.referencesHtmlFileInput;
+ if (input) {
+ input.value = '';
+ input.click();
+ }
+ },
+ triggerReferencesHtmlFileImport() {
+ this.triggerReferencesUpload();
+ },
+ parseUploadedReferenceContent(text, fileName) {
+ const raw = String(text || '');
+ const isPlainText = /\.txt$/i.test(String(fileName || ''));
+ if (isPlainText) {
+ return parseReferencesBulkContent(raw);
+ }
+ return parseReferencesEditableHtml(raw);
+ },
+ applyUploadedReferences(items) {
+ if (!items || !items.length) {
+ this.$message.warning(this.$t('commonTable.refHtmlParseEmpty'));
+ return false;
+ }
+ this.uploadedReferenceHtmlItems = items;
+ this.uploadedReferencesCount = items.length;
+ this.$message.success(
+ this.$t('commonTable.refHtmlUploadSuccess', { n: items.length })
+ );
+ return true;
+ },
+ handleReferencesFileUpload(event) {
+ const input = event && event.target;
+ const file = input && input.files && input.files[0];
+ if (!file) {
+ return;
+ }
+
+ this.referencesUploadLoading = true;
+ const reader = new FileReader();
+ reader.onload = () => {
+ try {
+ const items = this.parseUploadedReferenceContent(reader.result, file.name);
+ this.applyUploadedReferences(items);
+ } catch (err) {
+ console.error(err);
+ this.$message.error(this.$t('commonTable.refHtmlToWordFail'));
+ } finally {
+ this.referencesUploadLoading = false;
+ if (input) {
+ input.value = '';
+ }
+ }
+ };
+ reader.onerror = () => {
+ this.referencesUploadLoading = false;
+ if (input) {
+ input.value = '';
+ }
+ this.$message.error(this.$t('commonTable.refHtmlToWordFail'));
+ };
+ reader.readAsText(file, 'UTF-8');
+ },
+ async openReferencesPasteDialog() {
+ if (this.referencesUploadLoading) {
+ return;
+ }
+ if (!this.$api) {
+ this.$message.error(this.$t('commonTable.refHtmlLoadFail'));
+ return;
+ }
+
+ try {
+ const references = await this.loadManuscriptReferences(false);
+ this.referencesPasteText = references.length ? buildReferencesCopyText(references) : '';
+ } catch (err) {
+ console.error(err);
+ this.referencesPasteText = '';
+ }
+ this.updateReferencesPastePreview();
+ this.referencesPasteVisible = true;
+ },
+ updateReferencesPastePreview() {
+ this.referencesPasteCount = countParsedReferences(this.referencesPasteText);
+ },
+ confirmReferencesUpload() {
+ const items = parseReferencesBulkContent(this.referencesPasteText);
+ if (this.applyUploadedReferences(items)) {
+ this.referencesPasteVisible = false;
+ }
+ },
async handleExportManuscriptWord() {
if (this.exportingManuscriptWord) {
return;
@@ -1506,19 +1769,32 @@ export default {
}
this.exportingManuscriptWord = true;
try {
+ const hasUploaded =
+ this.uploadedReferenceHtmlItems && this.uploadedReferenceHtmlItems.length;
await downloadManuscriptWord(this.wordList, this.mediaUrl, 'manuscript', {
- fetchReferences: true,
+ fetchReferences: !hasUploaded,
+ referenceHtmlItems: hasUploaded ? this.uploadedReferenceHtmlItems : null,
apiClient: this.$api,
articleId: this.articleId,
pArticleId: this.pArticleId
});
- this.$message.success(this.$t('commonTable.exportManuscriptSuccess') || 'Word downloaded.');
+ this.$message.success(
+ hasUploaded
+ ? this.$t('commonTable.exportWordWithUploadedRefsSuccess', {
+ n: this.uploadedReferencesCount
+ })
+ : this.$t('commonTable.exportManuscriptSuccess') || 'Word downloaded.'
+ );
} catch (err) {
console.error(err);
if (err && err.message === 'NO_CONTENT') {
this.$message.warning(this.$t('commonTable.exportManuscriptEmpty') || 'No content to export.');
} else {
- this.$message.error(this.$t('commonTable.exportManuscriptFail') || 'Failed to export Word.');
+ const detail =
+ err && err.message
+ ? err.message
+ : this.$t('commonTable.exportManuscriptFail') || 'Failed to export Word.';
+ this.$message.error(detail);
}
} finally {
this.exportingManuscriptWord = false;
@@ -1539,11 +1815,7 @@ export default {
this.citationRelevanceLoading = true;
try {
- let references = this.manuscriptReferences;
- if (!references || !references.length) {
- references = await fetchManuscriptReferenceList(this.$api, this.articleId, this.pArticleId);
- this.manuscriptReferences = references || [];
- }
+ const references = await this.loadManuscriptReferences(false);
const items = buildCitationReviewQueue(this.wordList, this.manuscriptReferences);
if (!items.length) {
@@ -2607,6 +2879,14 @@ export default {
this.selectedIds = [];
this.$forceUpdate();
},
+ handleSelectAll() {
+ this.currentId = null;
+ this.currentData = {};
+ this.selectedIds = (this.wordList || [])
+ .map((item) => (item && item.am_id != null ? item.am_id : null))
+ .filter((id) => id != null);
+ this.$forceUpdate();
+ },
onEdit() {
this.$emit('onEdit', this.currentId);
},
@@ -4378,6 +4658,52 @@ export default {
border-radius: 0;
height: auto;
}
+.HTitleBox li.zy-toolbar-btn {
+ padding: 4px 10px;
+ margin: 0 2px;
+ font-size: 12px !important;
+ font-weight: normal !important;
+ min-width: auto;
+ height: auto;
+ color: #409eff;
+ background: #fff;
+ border: 1px solid #409eff;
+ border-radius: 4px;
+ box-sizing: border-box;
+}
+.HTitleBox li.zy-toolbar-btn:hover {
+ background: #ecf5ff;
+}
+.HTitleBox li.zy-toolbar-btn.zy-toolbar-btn--ready {
+ border-color: #67c23a;
+ color: #67c23a;
+}
+.HTitleBox li.zy-toolbar-btn.zy-toolbar-btn--ready:hover {
+ background: #f0f9eb;
+}
+.zy-toolbar-btn-inner {
+ display: inline-flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: center;
+ gap: 4px;
+ line-height: 1.2;
+ pointer-events: none;
+}
+.zy-toolbar-btn-inner i {
+ font-size: 14px;
+ margin: 0;
+}
+.zy-toolbar-label {
+ font-size: 12px;
+ white-space: nowrap;
+ font-weight: normal;
+}
+.zy-toolbar-badge {
+ font-style: normal;
+ color: inherit;
+ font-weight: bold;
+}
.operateBox {
width: auto;
display: flex;
diff --git a/src/components/page/editPublicRefRdit.vue b/src/components/page/editPublicRefRdit.vue
index 2e910a8..7734f6e 100644
--- a/src/components/page/editPublicRefRdit.vue
+++ b/src/components/page/editPublicRefRdit.vue
@@ -556,6 +556,16 @@
>We have detected updates to the reference content. You need to click the "Automatic parsing" button to
recognize them.
+
+ {{ $t('commonTable.parseBookReference') }}
+
@@ -898,6 +908,8 @@