Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(relation_map): draw arrowheads in the note map's shape
Elian Dorandacb04752d2a
diff --git a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.css b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.cssindex 6daffc0237..8a7c8041c5 100644--- a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.css+++ b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.css@@ -40,3 +40,8 @@.relation-map-wrapper.placing-note {cursor: crosshair;}++.note-detail-relation-map .relation-map-arrow {+ stroke-width: 1.2px;+ stroke-linejoin: round;+}diff --git a/apps/client/src/widgets/type_widgets/relation_map/overlays.ts b/apps/client/src/widgets/type_widgets/relation_map/overlays.tsindex ab4f39d9ce..9b740c2b79 100644--- a/apps/client/src/widgets/type_widgets/relation_map/overlays.ts+++ b/apps/client/src/widgets/type_widgets/relation_map/overlays.ts@@ -1,75 +1,27 @@import { jsPlumbInstance, OverlaySpec } from "jsplumb";+const ARROW_LENGTH_PX = 9;+export const uniDirectionalOverlays: OverlaySpec[] = [- [- "Arrow",- {- location: 1,- id: "arrow",- length: 14,- foldback: 0.8- }- ],+ arrow({ location: 1, id: "arrow" }),["Label", { label: "", id: "label", cssClass: "connection-label" }]];-const biDirectionalOverlays = [- [- "Arrow",- {- location: 1,- id: "arrow",- length: 14,- foldback: 0.8- }- ],+const biDirectionalOverlays: OverlaySpec[] = [+ arrow({ location: 1, id: "arrow" }),["Label", { label: "", id: "label", cssClass: "connection-label" }],- [- "Arrow",- {- location: 0,- id: "arrow2",- length: 14,- direction: -1,- foldback: 0.8- }- ]+ arrow({ location: 0, id: "arrow2", direction: -1 })];-const inverseRelationsOverlays = [- [- "Arrow",- {- location: 1,- id: "arrow",- length: 14,- foldback: 0.8- }- ],+const inverseRelationsOverlays: OverlaySpec[] = [+ arrow({ location: 1, id: "arrow" }),["Label", { label: "", location: 0.2, id: "label-source", cssClass: "connection-label" }],["Label", { label: "", location: 0.8, id: "label-target", cssClass: "connection-label" }],- [- "Arrow",- {- location: 0,- id: "arrow2",- length: 14,- direction: -1,- foldback: 0.8- }- ]+ arrow({ location: 0, id: "arrow2", direction: -1 })];-const linkOverlays = [- [- "Arrow",- {- location: 1,- id: "arrow",- length: 14,- foldback: 0.8- }- ]+const linkOverlays: OverlaySpec[] = [+ arrow({ location: 1, id: "arrow" })];export default function setupOverlays(jsPlumbInstance: jsPlumbInstance) {@@ -97,3 +49,18 @@ export default function setupOverlays(jsPlumbInstance: jsPlumbInstance) {overlays: linkOverlays});}++/**+ * The arrowhead of the note map (`note_map/rendering.ts`): as wide as 0.72 of its length, with the+ * tail swept back to 0.72 of the length from the tip. It is a pixel shorter, because the rounded+ * stroke of `.relation-map-arrow` adds about half a pixel on every side.+ */+function arrow(options: { location: number, id: string, direction?: number }): OverlaySpec {+ return [ "Arrow", {+ ...options,+ length: ARROW_LENGTH_PX,+ width: ARROW_LENGTH_PX * 0.72,+ foldback: 0.72,+ cssClass: "relation-map-arrow"+ } ];+}