mirror of
https://github.com/zadam/trilium.git
synced 2024-11-18 05:35:56 +08:00
42 lines
No EOL
1.2 KiB
JavaScript
42 lines
No EOL
1.2 KiB
JavaScript
import StandardWidget from "./standard_widget.js";
|
|
|
|
let linkMapContainerIdCtr = 1;
|
|
|
|
const TPL = `
|
|
<div style="outline: none; overflow: hidden;">
|
|
<div class="link-map-container"></div>
|
|
</div>
|
|
`;
|
|
|
|
class LinkMapWidget extends StandardWidget {
|
|
getWidgetTitle() { return "Link map"; }
|
|
|
|
getHeaderActions() {
|
|
const $showFullButton = $("<a>").append("show full").addClass('widget-header-action');
|
|
$showFullButton.click(async () => {
|
|
const linkMapDialog = await import("../dialogs/link_map.js");
|
|
linkMapDialog.showDialog();
|
|
});
|
|
|
|
return [$showFullButton];
|
|
}
|
|
|
|
async doRenderBody() {
|
|
this.$body.html(TPL);
|
|
|
|
const $linkMapContainer = this.$body.find('.link-map-container');
|
|
$linkMapContainer.attr("id", "link-map-container-" + linkMapContainerIdCtr++);
|
|
$linkMapContainer.css("height", "300px");
|
|
|
|
const LinkMapServiceClass = (await import('../services/link_map.js')).default;
|
|
|
|
const linkMapService = new LinkMapServiceClass(this.ctx.note, $linkMapContainer, {
|
|
maxDepth: 1,
|
|
zoom: 0.7
|
|
});
|
|
|
|
await linkMapService.render();
|
|
}
|
|
}
|
|
|
|
export default LinkMapWidget; |