Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solve attach id not inherited from parents. #218

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion components/Sidebar/Backlinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface BacklinksProps {
openContextMenu: any
outline: boolean
attachDir: string
attachUseInheritance: boolean
macros: { [key: string]: string }
}

Expand All @@ -36,6 +37,7 @@ export const Backlinks = (props: BacklinksProps) => {
outline,
macros,
attachDir,
attachUseInheritance,
} = props
const links = linksByNodeId[(previewNode as OrgRoamNode)?.id] ?? []

Expand Down Expand Up @@ -73,7 +75,7 @@ export const Backlinks = (props: BacklinksProps) => {
openContextMenu={openContextMenu}
outline={outline}
noUnderline
{...{ attachDir, macros }}
{...{ attachDir, attachUseInheritance, macros }}
>
{nodeById[link as string]?.title}
</PreviewLink>
Expand Down
3 changes: 3 additions & 0 deletions components/Sidebar/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface LinkProps {
isWiki?: boolean
noUnderline?: boolean
attachDir: string
attachUseInheritance: boolean
macros: { [key: string]: string }
}

Expand Down Expand Up @@ -142,6 +143,7 @@ export const PreviewLink = (props: LinkProps) => {
isWiki,
macros,
attachDir,
attachUseInheritance,
} = props
// TODO figure out how to properly type this
// see https://github.com/rehypejs/rehype-react/issues/25
Expand Down Expand Up @@ -296,6 +298,7 @@ export const PreviewLink = (props: LinkProps) => {
linksByNodeId,
macros,
attachDir,
attachUseInheritance,
}}
previewNode={nodeById[id]!}
collapse={false}
Expand Down
4 changes: 4 additions & 0 deletions components/Sidebar/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface NoteProps {
collapse: boolean
macros?: { [key: string]: string }
attachDir: string
attachUseInheritance: boolean
}

export const Note = (props: NoteProps) => {
Expand All @@ -39,6 +40,7 @@ export const Note = (props: NoteProps) => {
collapse,
macros,
attachDir,
attachUseInheritance,
} = props

const extraStyle = outline ? outlineNoteStyle : viewerNoteStyle
Expand Down Expand Up @@ -74,6 +76,7 @@ export const Note = (props: NoteProps) => {
linksByNodeId,
macros,
attachDir,
attachUseInheritance,
}}
/>
<Backlinks
Expand All @@ -87,6 +90,7 @@ export const Note = (props: NoteProps) => {
openContextMenu,
outline,
attachDir,
attachUseInheritance,
}}
macros={macros || {}}
/>
Expand Down
3 changes: 3 additions & 0 deletions components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface SidebarProps {
setTagColors: any
macros?: { [key: string]: string }
attachDir: string
attachUseInheritance: boolean
}

const Sidebar = (props: SidebarProps) => {
Expand Down Expand Up @@ -79,6 +80,7 @@ const Sidebar = (props: SidebarProps) => {
setTagColors,
macros,
attachDir,
attachUseInheritance,
} = props

const { highlightColor } = useContext(ThemeContext)
Expand Down Expand Up @@ -231,6 +233,7 @@ const Sidebar = (props: SidebarProps) => {
collapse,
macros,
attachDir,
attachUseInheritance,
}}
/>
</VStack>
Expand Down
4 changes: 4 additions & 0 deletions org-roam-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ from all other links."
(attach-dir (if (boundp 'org-attach-id-dir)
org-attach-id-dir
(expand-file-name ".attach/" org-directory)))
(attach-use-inheritance (when (boundp 'org-attach-use-inheritance)
org-attach-use-inheritance))
(sub-dirs (org-roam-ui-find-subdirectories)))
(websocket-send-text org-roam-ui-ws-socket
(json-encode
Expand All @@ -595,6 +597,8 @@ from all other links."
,daily-dir)
("attachDir" .
,attach-dir)
("attachUseInheritance" .
,attach-use-inheritance)
("roamDir" . ,org-roam-directory)
("katexMacros" . ,org-roam-ui-latex-macros))))))))

Expand Down
2 changes: 2 additions & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface EmacsVariables {
dailyDir?: string
katexMacros?: { [key: string]: string }
attachDir?: string
attachUseInheritance?: boolean
subDirs: string[]
}
export type Tags = string[]
Expand Down Expand Up @@ -684,6 +685,7 @@ export function GraphPage() {
}}
macros={emacsVariables.katexMacros}
attachDir={emacsVariables.attachDir || ''}
attachUseInheritance={emacsVariables.attachUseInheritance || false}
nodeById={nodeByIdRef.current!}
linksByNodeId={linksByNodeIdRef.current!}
nodeByCite={nodeByCiteRef.current!}
Expand Down
4 changes: 4 additions & 0 deletions util/processOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface ProcessedOrgProps {
linksByNodeId: LinksByNodeId
macros: { [key: string]: string } | {}
attachDir: string
attachUseInheritance: boolean
}

export const ProcessedOrg = (props: ProcessedOrgProps) => {
Expand All @@ -66,6 +67,7 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
linksByNodeId,
macros,
attachDir,
attachUseInheritance,
} = props

if (!previewNode || !linksByNodeId) {
Expand All @@ -77,6 +79,7 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
.use(extractKeywords)
.use(attachments, {
idDir: attachDir || undefined,
useInheritance: attachUseInheritance || undefined,
})
.use(uniorgSlug)
.use(uniorg2rehype, { useSections: true })
Expand Down Expand Up @@ -156,6 +159,7 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
isWiki={isMarkdown}
macros={macros}
attachDir={attachDir}
attachUseInheritance={attachUseInheritance}
>
{children}
</PreviewLink>
Expand Down
3 changes: 3 additions & 0 deletions util/uniorg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface UniOrgProps {
linksByNodeId: LinksByNodeId
macros?: { [key: string]: string }
attachDir: string
attachUseInheritance: boolean
}

export const UniOrg = (props: UniOrgProps) => {
Expand All @@ -30,6 +31,7 @@ export const UniOrg = (props: UniOrgProps) => {
linksByNodeId,
macros,
attachDir,
attachUseInheritance,
} = props

const [previewText, setPreviewText] = useState('')
Expand Down Expand Up @@ -72,6 +74,7 @@ export const UniOrg = (props: UniOrgProps) => {
collapse,
linksByNodeId,
attachDir,
attachUseInheritance,
}}
macros={macros || {}}
/>
Expand Down