diff --git a/package-lock.json b/package-lock.json index f7c4b44d24..db36e0ed95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,6 @@ "dependencies": { "@citation-js/core": "0.7.9", "@citation-js/plugin-bibtex": "0.7.9", - "@citation-js/plugin-csl": "0.7.9", "@citation-js/plugin-software-formats": "0.6.1", "@claviska/jquery-minicolors": "2.3.6", "@github/markdown-toolbar-element": "2.2.3", @@ -317,21 +316,6 @@ "node": ">=14.0.0" } }, - "node_modules/@citation-js/plugin-csl": { - "version": "0.7.9", - "resolved": "https://registry.npmjs.org/@citation-js/plugin-csl/-/plugin-csl-0.7.9.tgz", - "integrity": "sha512-mbD7CnUiPOuVnjeJwo+d0RGUcY0PE8n01gHyjq0qpTeS42EGmQ9+LzqfsTUVWWBndTwc6zLRuIF1qFAUHKE4oA==", - "dependencies": { - "@citation-js/date": "^0.5.0", - "citeproc": "^2.4.6" - }, - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@citation-js/core": "^0.7.0" - } - }, "node_modules/@citation-js/plugin-github": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/@citation-js/plugin-github/-/plugin-github-0.6.1.tgz", @@ -3673,11 +3657,6 @@ "node": ">=8" } }, - "node_modules/citeproc": { - "version": "2.4.63", - "resolved": "https://registry.npmjs.org/citeproc/-/citeproc-2.4.63.tgz", - "integrity": "sha512-68F95Bp4UbgZU/DBUGQn0qV3HDZLCdI9+Bb2ByrTaNJDL5VEm9LqaiNaxljsvoaExSLEXe1/r6n2Z06SCzW3/Q==" - }, "node_modules/clean-regexp": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", diff --git a/package.json b/package.json index 2380bbf51e..86765e0344 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "dependencies": { "@citation-js/core": "0.7.9", "@citation-js/plugin-bibtex": "0.7.9", - "@citation-js/plugin-csl": "0.7.9", "@citation-js/plugin-software-formats": "0.6.1", "@claviska/jquery-minicolors": "2.3.6", "@github/markdown-toolbar-element": "2.2.3", diff --git a/templates/repo/cite/cite_buttons.tmpl b/templates/repo/cite/cite_buttons.tmpl index 426ca3858e..5a6de23c5c 100644 --- a/templates/repo/cite/cite_buttons.tmpl +++ b/templates/repo/cite/cite_buttons.tmpl @@ -1,9 +1,6 @@ -<button class="ui citation button" id="citation-copy-apa" data-text=""> -APA -</button> -<button class="ui citation button" id="citation-copy-bibtex" data-text=""> +<span class="ui citation label primary" id="citation-copy-bibtex" data-text=""> BibTeX -</button> +</span> <!-- the value will be updated by initCitationFileCopyContent, the code below is used to avoid UI flicking --> <input id="citation-copy-content" value="" size="1" readonly> <button class="ui icon button" id="citation-clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy"}}" data-clipboard-target="#citation-copy-content"> diff --git a/web_src/css/repo.css b/web_src/css/repo.css index 7295abe927..1c37eaeda0 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -2084,11 +2084,6 @@ td .commit-summary { line-height: 1.4; } -#cite-repo-modal #citation-panel .citation.button { - font-size: 13px; - padding: 7.5px 5px; -} - #cite-repo-modal #citation-panel #citation-copy-content { border-radius: 0; padding: 5px 10px; @@ -2097,8 +2092,9 @@ td .commit-summary { flex: 1; } -#cite-repo-modal #citation-panel #citation-copy-apa, #cite-repo-modal #citation-panel #citation-copy-bibtex { + font-size: 13px; + padding: 7.5px 5px; border-right: none; } diff --git a/web_src/js/features/citation.js b/web_src/js/features/citation.js index 918a467136..7e26bff276 100644 --- a/web_src/js/features/citation.js +++ b/web_src/js/features/citation.js @@ -3,12 +3,11 @@ import {getCurrentLocale} from '../utils.js'; const {pageData} = window.config; -async function initInputCitationValue(citationCopyApa, citationCopyBibtex) { +async function initInputCitationValue(inputContent) { const [{Cite, plugins}] = await Promise.all([ import(/* webpackChunkName: "citation-js-core" */'@citation-js/core'), import(/* webpackChunkName: "citation-js-formats" */'@citation-js/plugin-software-formats'), import(/* webpackChunkName: "citation-js-bibtex" */'@citation-js/plugin-bibtex'), - import(/* webpackChunkName: "citation-js-csl" */'@citation-js/plugin-csl'), ]); const {citationFileContent} = pageData; const config = plugins.config.get('@bibtex'); @@ -16,30 +15,16 @@ async function initInputCitationValue(citationCopyApa, citationCopyBibtex) { config.constants.fieldTypes.version = ['field', 'literal']; const citationFormatter = new Cite(citationFileContent); const lang = getCurrentLocale() || 'en-US'; - const apaOutput = citationFormatter.format('bibliography', {template: 'apa', lang}); const bibtexOutput = citationFormatter.format('bibtex', {lang}); - citationCopyBibtex.setAttribute('data-text', bibtexOutput); - citationCopyApa.setAttribute('data-text', apaOutput); + inputContent.value = bibtexOutput; } export async function initCitationFileCopyContent() { - const defaultCitationFormat = 'apa'; // apa or bibtex - if (!pageData.citationFileContent) return; - const citationCopyApa = document.getElementById('citation-copy-apa'); - const citationCopyBibtex = document.getElementById('citation-copy-bibtex'); const inputContent = document.getElementById('citation-copy-content'); - if ((!citationCopyApa && !citationCopyBibtex) || !inputContent) return; - - const updateUi = () => { - const isBibtex = (localStorage.getItem('citation-copy-format') || defaultCitationFormat) === 'bibtex'; - const copyContent = (isBibtex ? citationCopyBibtex : citationCopyApa).getAttribute('data-text'); - inputContent.value = copyContent; - citationCopyBibtex.classList.toggle('primary', isBibtex); - citationCopyApa.classList.toggle('primary', !isBibtex); - }; + if (!inputContent) return; document.getElementById('cite-repo-button')?.addEventListener('click', async (e) => { const dropdownBtn = e.target.closest('.ui.dropdown.button'); @@ -47,22 +32,11 @@ export async function initCitationFileCopyContent() { try { try { - await initInputCitationValue(citationCopyApa, citationCopyBibtex); + await initInputCitationValue(inputContent); } catch (e) { console.error(`initCitationFileCopyContent error: ${e}`, e); return; } - updateUi(); - - citationCopyApa.addEventListener('click', () => { - localStorage.setItem('citation-copy-format', 'apa'); - updateUi(); - }); - - citationCopyBibtex.addEventListener('click', () => { - localStorage.setItem('citation-copy-format', 'bibtex'); - updateUi(); - }); inputContent.addEventListener('click', () => { inputContent.select();