feat(sidebar): port backlinks widget partially

This commit is contained in:
Elian Doran 2025-01-19 21:48:11 +02:00
parent c6fef4ec7d
commit 89c4e0bef7
No known key found for this signature in database
2 changed files with 14 additions and 8 deletions

View File

@ -205,7 +205,6 @@ export default class DesktopLayout {
.child(new RelationMapButtons()) .child(new RelationMapButtons())
.child(new CopyImageReferenceButton()) .child(new CopyImageReferenceButton())
.child(new SvgExportButton()) .child(new SvgExportButton())
.child(new BacklinksWidget())
.child(new HideFloatingButtonsButton()) .child(new HideFloatingButtonsButton())
) )
.child(new MermaidWidget()) .child(new MermaidWidget())
@ -236,6 +235,7 @@ export default class DesktopLayout {
.child(new TocWidget()) .child(new TocWidget())
.child(new HighlightsListWidget()) .child(new HighlightsListWidget())
.child(new SimilarNotesWidget()) .child(new SimilarNotesWidget())
.child(new BacklinksWidget())
.child(new NoteMapRibbonWidget()) .child(new NoteMapRibbonWidget())
.child(...this.customWidgets.get("right-pane")) .child(...this.customWidgets.get("right-pane"))
) )

View File

@ -8,6 +8,8 @@ import linkService from "../../services/link.js";
import server from "../../services/server.js"; import server from "../../services/server.js";
import froca from "../../services/froca.js"; import froca from "../../services/froca.js";
import type FNote from "../../entities/fnote.js"; import type FNote from "../../entities/fnote.js";
import RightPaneContainer from "../containers/right_pane_container.js";
import RightPanelWidget from "../right_panel_widget.js";
const TPL = ` const TPL = `
<div class="backlinks-widget"> <div class="backlinks-widget">
@ -72,17 +74,21 @@ interface Backlink {
excerpts?: string[]; excerpts?: string[];
} }
export default class BacklinksWidget extends NoteContextAwareWidget { export default class BacklinksWidget extends RightPanelWidget {
private $count!: JQuery<HTMLElement>; private $count!: JQuery<HTMLElement>;
private $items!: JQuery<HTMLElement>; private $items!: JQuery<HTMLElement>;
private $ticker!: JQuery<HTMLElement>; private $ticker!: JQuery<HTMLElement>;
doRender() { get widgetTitle() {
this.$widget = $(TPL); return "Backlinks";
this.$count = this.$widget.find(".backlinks-count"); }
this.$items = this.$widget.find(".backlinks-items");
this.$ticker = this.$widget.find(".backlinks-ticker"); async doRenderBody() {
this.$body.empty().append($(TPL));
this.$count = this.$body.find(".backlinks-count");
this.$items = this.$body.find(".backlinks-items");
this.$ticker = this.$body.find(".backlinks-ticker");
this.$count.on("click", () => { this.$count.on("click", () => {
this.$items.toggle(); this.$items.toggle();
@ -121,7 +127,7 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
} }
toggle(show: boolean) { toggle(show: boolean) {
this.$widget.toggleClass("hidden-no-content", !show); this.$body.toggleClass("hidden-no-content", !show);
} }
clearItems() { clearItems() {