Skip to content

Commit

Permalink
New RC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxwellBo committed Dec 9, 2024
1 parent f8be7dd commit a1d632e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bibhtml/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celine/bibhtml",
"version": "1.10.0-RC",
"version": "1.12.0-RC",
"license": "MIT",
"exports": "./mod.ts"
}
18 changes: 13 additions & 5 deletions bibhtml/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,18 @@ export class BibhtmlCite extends HTMLElement {
if (this.hasAttribute('deref')) {
const ref = bibliography._refIdToReference.get(this.refId);
if (!ref) {
throw new Error(`Could not find a reference with id ${this.refId} in the bibliography.`);
console.warn(`Could not find a reference with id ${this.refId} in the bibliography.`);
return;
}
const citation = ref._citation;
if (!citation) {
throw new Error(`Could not find a citation for reference with id ${this.refId}.`);
console.log(`Could not find a citation for reference with id ${this.refId}.`);
return;
}
const url = citation.data[0].URL;
if (!url) {
throw new Error(`Could not find a URL for reference with id ${this.refId}.`);
console.log(`Could not find a citation for reference with id ${this.refId}.`);
return;
}
clonedA!.href = url;
}
Expand All @@ -147,6 +150,9 @@ export class BibhtmlCite extends HTMLElement {
tooltip.style.padding = '5px';
tooltip.style.display = 'none';
tooltip.style.zIndex = '1000';
tooltip.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)';
tooltip.style.borderRadius = '4px';
tooltip.style.maxWidth = '300px';

this.shadowRoot!.appendChild(tooltip);

Expand All @@ -165,6 +171,7 @@ export class BibhtmlReference extends HTMLElement {
_citation: any;
_notifiedBibliography: boolean;
_citationCount = 0;
_citationPromise: Promise<any> | null;

static customElementName = 'bh-reference';

Expand All @@ -182,6 +189,7 @@ export class BibhtmlReference extends HTMLElement {
super();
this.attachShadow({ mode: 'open' });
this._citation = null;
this._citationPromise = null;
this._notifiedBibliography = false;

if (!this.getAttribute('id')) {
Expand All @@ -195,8 +203,8 @@ export class BibhtmlReference extends HTMLElement {
}

connectedCallback() {
if (!this._citation) {
Cite.async(this.textContent).then((citation: any) => {
if (!this._citation && this._citationPromise == null) {
this._citationPromise = Cite.async(this.textContent).then((citation: any) => {
this._citation = citation;
this.render();
return getBibliography().then(bib => bib.render())
Expand Down

0 comments on commit a1d632e

Please sign in to comment.