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 error when retrieving the text for a citation node #211

Open
wants to merge 1 commit 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
17 changes: 10 additions & 7 deletions org-roam-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,15 @@ TODO: Be able to delete individual nodes."
((node (org-roam-populate (org-roam-node-create
:id id)))
(file (org-roam-node-file node)))
(org-roam-with-temp-buffer
(if (null file)
nil
(org-roam-with-temp-buffer
file
(when (> (org-roam-node-level node) 0)
;; Heading nodes have level 1 and greater.
(goto-char (org-roam-node-point node))
(org-narrow-to-element))
(buffer-substring-no-properties (buffer-end -1) (buffer-end 1)))))
(when (> (org-roam-node-level node) 0)
;; Heading nodes have level 1 and greater.
(goto-char (org-roam-node-point node))
(org-narrow-to-element))
(buffer-substring-no-properties (buffer-end -1) (buffer-end 1))))))

(defun org-roam-ui--send-text (id ws)
"Send the text from org-node ID through the websocket WS."
Expand All @@ -300,7 +302,8 @@ TODO: Be able to delete individual nodes."

(defservlet* node/:id text/plain ()
"Servlet for accessing node content."
(insert (org-roam-ui--get-text (org-link-decode id)))
(let ((text (org-roam-ui--get-text (org-link-decode id))))
(if text (insert text)))
(httpd-send-header t "text/plain" 200 :Access-Control-Allow-Origin "*"))

(defservlet* img/:file text/plain ()
Expand Down
2 changes: 1 addition & 1 deletion util/uniorg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const UniOrg = (props: UniOrgProps) => {
})
.then((res) => {
if (res === '') {
return '(empty node)'
setPreviewText('(empty node)')
}
if (res !== 'error') {
console.log(res)
Expand Down