From 528e2ce90f365c8d399410ee9cfb7a05f1ca638a Mon Sep 17 00:00:00 2001
From: Brian Lester <blester125@gmail.com>
Date: Mon, 2 Aug 2021 20:28:48 -0400
Subject: Process org-roam-bibtex citations links differently depending on if
 they have an associated node.

It is easy to imagine how overlapping citations could clue one into
connections about otherwise un-related work and generate insights.
However, `org-roam-ui` currently only shows citation links when the
`target` of the link has an associated node, that is, a node with a
matching `:ROAM_REFS:` property. Often one doesn't have a note for every
single thing they cite, and requiring them to create an empty note is a
bad user experience and something that would often be forgotten. Without
having citations links without associated nodes, connections in a users
notes will most likely be missed.

This change splits the handling of `org-roam-bibtex` citations links into
two categories, a citation link (when the target of the link does not
have an associated node, a node with a matching `:ROAM_REFS:`) and a
reference link (when the target of the link does have a node). Reasoning
for the naming is that a citation in a paper is generally just a link to
it, there is no extra commentary from you when that link if followed,
while a reference sound more like something you would refer to for
information, i.e. the notes you took in the attached node. I am willing
to flip the names if we want though.

Citations and References are customizable separately, with new menu
items for node/link color and dashed links added for Reference links.

A new filter option has also been added, the new switch `Citations
without note files` will remove all Citation nodes (and links to them)
when activated.

On the emacs side, this in implemented by using a new link type keyword,
`"ref"`, for any cite link where the target has an underlying node (a
node with a matching `:ROAM_REFS:` property). Links with this new type
are styled according to the new Ref styles in the UI. Any cite link where
the target does _not_ have an underlying node is left as a `"cite"` link.
Additionally, this set of link targets without associated nodes is used
to create fake nodes. These fake nodes have the `ref` key (the link target)
as their `id`, `file`, `title`, and `.properties.ROAM_REFS`. Their `level`
is set to `0`, and a new property, `FILELESS`, is set to `t`. Their id is
used for actually connecting links in the UI, and the new
`.properties.FILELESS` is used to styling a Citation vs a Reference node.

Theoretically, if we wanted to depend on `org-roam-bibtex`, and pay the
cost of look up citation information in the bibliography, we could use
the citation key to look up an actual title in the bibtex bibliography
during node creation, but that seems like it could get heavy for large
numbers of citations.
---
 components/tweaks.tsx | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

(limited to 'components/tweaks.tsx')

diff --git a/components/tweaks.tsx b/components/tweaks.tsx
index cb1fec0..ff7054f 100644
--- a/components/tweaks.tsx
+++ b/components/tweaks.tsx
@@ -233,6 +233,15 @@ export const Tweaks = (props: TweakProps) => {
                         isChecked={filter.parents}
                       ></Switch>
                     </Flex>
+                    <Flex justifyContent="space-between">
+                      <Text>Citations without note files</Text>
+                      <Switch
+                        onChange={() => {
+                          setFilter({ ...filter, fileless_cites: !filter.fileless_cites })
+                        }}
+                        isChecked={filter.fileless_cites}
+                      ></Switch>
+                    </Flex>
                   </VStack>
                   <Accordion padding={0} allowToggle allowMultiple paddingLeft={3}>
                     <AccordionItem>
@@ -762,6 +771,42 @@ export const Tweaks = (props: TweakProps) => {
                         value={'citeLinkColor'}
                         visValue={visuals.citeLinkColor}
                       />
+
+                      <EnableSection
+                        label="Dash ref links"
+                        infoText="Add dashes to citation links, whose target has a note, made with org-roam-bibtex"
+                        value={visuals.refDashes}
+                        onChange={() => setVisuals({ ...visuals, refDashes: !visuals.refDashes })}
+                      >
+                        <SliderWithInfo
+                          label="Dash length"
+                          value={visuals.refDashLength / 10}
+                          onChange={(value) =>
+                            setVisuals({ ...visuals, refDashLength: value * 10 })
+                          }
+                        />
+                        <SliderWithInfo
+                          label="Gap length"
+                          value={visuals.refGapLength / 5}
+                          onChange={(value) => setVisuals({ ...visuals, refGapLength: value * 5 })}
+                        />
+                      </EnableSection>
+                      <ColorMenu
+                        colorList={colorList}
+                        label="Reference node color"
+                        visuals={visuals}
+                        setVisuals={setVisuals}
+                        value={'refNodeColor'}
+                        visValue={visuals.refNodeColor}
+                      />
+                      <ColorMenu
+                        colorList={colorList}
+                        label="Referencelink color"
+                        visuals={visuals}
+                        setVisuals={setVisuals}
+                        value={'refLinkColor'}
+                        visValue={visuals.refLinkColor}
+                      />
                       <Box>
                         <Flex alignItems="center" justifyContent="space-between">
                           <Text>Labels</Text>
-- 
cgit v1.2.3

