feat(sidebar): move note_map to sidebar

This commit is contained in:
Elian Doran 2025-01-19 21:39:02 +02:00
parent 5e74e7e618
commit 0ece70ebc3
No known key found for this signature in database
2 changed files with 17 additions and 20 deletions

View File

@ -190,7 +190,6 @@ export default class DesktopLayout {
.ribbon(new BasicPropertiesWidget()) .ribbon(new BasicPropertiesWidget())
.ribbon(new OwnedAttributeListWidget()) .ribbon(new OwnedAttributeListWidget())
.ribbon(new InheritedAttributesWidget()) .ribbon(new InheritedAttributesWidget())
.ribbon(new NoteMapRibbonWidget())
.ribbon(new NoteInfoWidget()) .ribbon(new NoteInfoWidget())
.button(new RevisionsButton()) .button(new RevisionsButton())
.button(new NoteActionsWidget()) .button(new NoteActionsWidget())
@ -237,6 +236,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 NoteMapRibbonWidget())
.child(...this.customWidgets.get("right-pane")) .child(...this.customWidgets.get("right-pane"))
) )
) )

View File

@ -1,6 +1,6 @@
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import NoteMapWidget from "../note_map.js"; import NoteMapWidget from "../note_map.js";
import { t } from "../../services/i18n.js"; import { t } from "../../services/i18n.js";
import RightPanelWidget from "../right_panel_widget.js";
const TPL = ` const TPL = `
<div class="note-map-ribbon-widget"> <div class="note-map-ribbon-widget">
@ -32,7 +32,7 @@ const TPL = `
<div class="note-map-container"></div> <div class="note-map-container"></div>
</div>`; </div>`;
export default class NoteMapRibbonWidget extends NoteContextAwareWidget { export default class NoteMapRibbonWidget extends RightPanelWidget {
private openState!: "small" | "full"; private openState!: "small" | "full";
private noteMapWidget: NoteMapWidget; private noteMapWidget: NoteMapWidget;
@ -55,23 +55,20 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget {
return "toggleRibbonTabNoteMap"; return "toggleRibbonTabNoteMap";
} }
getTitle() { get widgetTitle() {
return { return t("note_map.title");
show: this.isEnabled(),
title: t("note_map.title"),
icon: "bx bxs-network-chart"
};
} }
doRender() { async doRenderBody() {
this.$widget = $(TPL); this.$body.empty().append($(TPL));
this.contentSized(); this.contentSized();
this.$container = this.$widget.find(".note-map-container"); this.$container = this.$body.find(".note-map-container");
this.$container.append(this.noteMapWidget.render()); this.$container.append(this.noteMapWidget.render());
this.openState = "small"; this.openState = "small";
this.$openFullButton = this.$widget.find(".open-full-button"); this.$openFullButton = this.$body.find(".open-full-button");
this.$openFullButton.on("click", () => { this.$openFullButton.on("click", () => {
this.setFullHeight(); this.setFullHeight();
@ -83,7 +80,7 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget {
this.noteMapWidget.setDimensions(); this.noteMapWidget.setDimensions();
}); });
this.$collapseButton = this.$widget.find(".collapse-button"); this.$collapseButton = this.$body.find(".collapse-button");
this.$collapseButton.on("click", () => { this.$collapseButton.on("click", () => {
this.setSmallSize(); this.setSmallSize();
@ -108,23 +105,23 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget {
} }
}; };
new ResizeObserver(handleResize).observe(this.$widget[0]); new ResizeObserver(handleResize).observe(this.$body[0]);
} }
setSmallSize() { setSmallSize() {
const SMALL_SIZE_HEIGHT = 300; const SMALL_SIZE_HEIGHT = 300;
const width = this.$widget.width() ?? 0; const width = this.$body.width() ?? 0;
this.$widget.find(".note-map-container").height(SMALL_SIZE_HEIGHT).width(width); this.$body.find(".note-map-container").height(SMALL_SIZE_HEIGHT).width(width);
} }
setFullHeight() { setFullHeight() {
const { top } = this.$widget[0].getBoundingClientRect(); const { top } = this.$body[0].getBoundingClientRect();
const height = ($(window).height() ?? 0) - top; const height = ($(window).height() ?? 0) - top;
const width = (this.$widget.width() ?? 0); const width = (this.$body.width() ?? 0);
this.$widget.find(".note-map-container") this.$body.find(".note-map-container")
.height(height) .height(height)
.width(width); .width(width);
} }