org-roam / org-roam-server

A Web Application to Visualize the Org-Roam Database
MIT License
639 stars 51 forks source link

[feature request] Is that possible to use a consistent color to highlight the selected node in the Buffer Network? #87

Open randomwangran opened 4 years ago

randomwangran commented 4 years ago

Sorry for bother. Thanks for writing this package.

For example, the user shall define a purple color (#DED1EE) to every node s/he clicks.

I notice that every time the user clicks a node, the Buffer Network will update the network and the colors. If the Buffer Network has many nodes, the user could lose his thoughts.

This feature would help users to quickly find his/her previous thoughts.

randomwangran commented 4 years ago

Sorry for bother. I will enhence my programming skills someday later myself to see if I can do a PR.

aizensoosuke commented 3 years ago

If anyone is looking for a workaround, you can add this to your configuration .

Note that it will only work if you have the org-roam backlinks buffer open (i.e. run M-x org-roam).

(setq org-roam-server-extra-node-options
        (lambda (node)
          (let ((current-node-p (string= (car node) (buffer-file-name org-roam-buffer--current))))
            (when current-node-p
            ;; additional attributes for the current node.
            ;; this must be a list suitable for `json-encode'.
            ;; see https://github.com/visjs/vis-network/tree/master/examples/network/nodeStyles
            ;;   for additional information on available options
            (list (cons 'shape "box") 
                  (cons 'color (list (cons 'background "purple") 
                                     (cons 'border "white"))))))))
goktug97 commented 3 years ago

If anyone is looking for a workaround, you can add this to your configuration .

Note that it will only work if you have the org-roam backlinks buffer open (i.e. run M-x org-roam).

(setq org-roam-server-extra-node-options
        (lambda (node)
          (let ((current-node-p (string= (car node) (buffer-file-name org-roam-buffer--current))))
            (when current-node-p
            ;; additional attributes for the current node.
            ;; this must be a list suitable for `json-encode'.
            ;; see https://github.com/visjs/vis-network/tree/master/examples/network/nodeStyles
            ;;   for additional information on available options
            (list (cons 'shape "box") 
                  (cons 'color (list (cons 'background "purple") 
                                     (cons 'border "white"))))))))

You can try using org-roam-server-current-buffer instead of (buffer-file-name org-roam-buffer--current)