diff --git a/src/modals/CitationModal.ts b/src/modals/CitationModal.ts index da7866c..8bb903e 100644 --- a/src/modals/CitationModal.ts +++ b/src/modals/CitationModal.ts @@ -94,12 +94,23 @@ export class CitationModal extends Modal { // Add each citation instance group.matches.forEach((match, matchIndex) => { - const instanceEl = content.createDiv('cite-wide-instance'); + const isRefSource = match.isReferenceSource === true; + const instanceEl = content.createDiv(`cite-wide-instance ${isRefSource ? 'cite-wide-reference-source' : ''}`); // Show line number and preview const lineInfo = instanceEl.createDiv('cite-wide-line-info'); + + // Add a special badge for reference sources + if (isRefSource) { + lineInfo.createEl('span', { + text: 'Reference', + cls: 'cite-wide-badge cite-wide-badge-reference' + }); + lineInfo.createEl('span', { text: ' • ' }); + } + lineInfo.createEl('span', { - text: `Line ${match.lineNumber + 1}: `, + text: `Line ${match.lineNumber}: `, cls: 'cite-wide-line-number' }); @@ -117,25 +128,31 @@ export class CitationModal extends Modal { // Add view and convert buttons const btnContainer = instanceEl.createDiv('cite-wide-instance-actions'); - const viewBtn = btnContainer.createEl('button', { - text: 'View', - cls: 'mod-cta-outline cite-wide-view-btn' - }); + // Only add view/convert buttons for non-reference entries + if (!isRefSource) { + const viewBtn = btnContainer.createEl('button', { + text: 'View', + cls: 'mod-cta-outline cite-wide-view-btn' + }); - viewBtn.addEventListener('click', (e) => { - e.stopPropagation(); - this.scrollToLine(match.lineNumber); - }); + viewBtn.addEventListener('click', (e) => { + e.stopPropagation(); + this.scrollToLine(match.lineNumber); + }); + } - const convertBtn = btnContainer.createEl('button', { - text: 'Convert', - cls: 'mod-cta cite-wide-convert-btn' - }); + // Only add convert button for non-reference entries + if (!isRefSource) { + const convertBtn = btnContainer.createEl('button', { + text: 'Convert', + cls: 'mod-cta cite-wide-convert-btn' + }); - convertBtn.addEventListener('click', async (e) => { - e.stopPropagation(); - await this.convertCitationInstance(group, matchIndex); - }); + convertBtn.addEventListener('click', async (e) => { + e.stopPropagation(); + await this.convertCitationInstance(group, matchIndex); + }); + } }); } diff --git a/src/services/citationService.ts b/src/services/citationService.ts index 131f346..49e621f 100644 --- a/src/services/citationService.ts +++ b/src/services/citationService.ts @@ -11,6 +11,7 @@ export interface CitationMatch { index: number; lineContent: string; lineNumber: number; + isReferenceSource?: boolean; // Flag to indicate if this is a reference source entry } export interface CitationGroup { @@ -173,6 +174,25 @@ export class CitationService { const source = this.findReferenceSourceInFootnotes(content, number); if (source && typeof source === 'string' && source.trim() !== '') { referenceSources.set(number, source); + + // Add the reference source as a special match + const referenceLine = content.split('\n').findIndex(line => { + const match = line.trim().match(new RegExp(`^${number}\\.\\s+`)); + return !!match; + }); + + if (referenceLine !== -1) { + matches.push({ + type: 'reference', + number, + original: `${number}. ${source}`, + index: content.indexOf(`${number}. `, referenceLine > 0 ? + content.split('\n').slice(0, referenceLine).join('\n').length : 0), + lineContent: `${number}. ${source}`, + lineNumber: referenceLine + 1, + isReferenceSource: true + }); + } } }); diff --git a/src/styles/citations.css b/src/styles/citations.css index 2777607..68b17ba 100644 --- a/src/styles/citations.css +++ b/src/styles/citations.css @@ -61,6 +61,7 @@ border-top: 1px solid var(--background-modifier-border); } +/* Base instance styling */ .cite-wide-instance { display: flex; justify-content: space-between; @@ -69,6 +70,16 @@ border-bottom: 1px solid var(--background-modifier-border); } +/* Reference source specific styling */ +.cite-wide-instance.cite-wide-reference-source { + background-color: var(--background-secondary-alt); + margin: 0 -1rem; + padding: 0.75rem 1rem; + border-radius: 4px; + border: 1px solid var(--background-modifier-border); + border-left: 3px solid var(--interactive-accent); +} + .cite-wide-instance:last-child { border-bottom: none; } @@ -91,6 +102,31 @@ opacity: 0.9; } +/* Badge styling */ +.cite-wide-badge { + display: inline-block; + padding: 0.15em 0.5em; + font-size: 0.75em; + font-weight: 600; + line-height: 1.2; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: 3px; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.cite-wide-badge-reference { + color: var(--text-normal); + background-color: var(--background-modifier-border); +} + +/* Adjust line info spacing when badge is present */ +.cite-wide-line-info > .cite-wide-badge + span { + margin-left: 0.5rem; +} + .cite-wide-instance-actions { display: flex; gap: 0.5rem;