@@ -276,32 +276,33 @@ TODO: Be able to delete individual nodes."
276
276
(org-roam-ui-follow-mode -1 )
277
277
(message " Connection with org-roam-ui closed. " ))
278
278
279
- (defun org-roam-ui--send -text (id ws )
280
- " Send the text from org-node ID through the websocket WS ."
279
+ (defun org-roam-ui--get -text (id )
280
+ " Retrieve the text from org-node ID."
281
281
(let*
282
282
((node (org-roam-populate (org-roam-node-create
283
283
:id id)))
284
- (file (org-roam-node-file node))
285
- (text))
284
+ (file (org-roam-node-file node)))
286
285
(org-roam-with-temp-buffer
287
286
file
288
- (setq text
289
- (buffer-substring-no-properties (buffer-end -1 ) (buffer-end 1 )))
290
- text)
287
+ (when (> (org-roam-node-level node) 0 )
288
+ ; ; Heading nodes have level 1 and greater.
289
+ (goto-char (org-roam-node-point node))
290
+ (org-narrow-to-element ))
291
+ (buffer-substring-no-properties (buffer-end -1 ) (buffer-end 1 )))))
292
+
293
+ (defun org-roam-ui--send-text (id ws )
294
+ " Send the text from org-node ID through the websocket WS."
295
+ (let ((text (org-roam-ui--get-text id)))
291
296
(websocket-send-text ws
292
297
(json-encode
293
298
`((type . " orgText" )
294
299
(data . , text ))))))
295
300
296
- (defservlet* file/:file text/plain ()
297
- " Servlet for accessing file contents of org-roam files.
298
-
299
- Just sends the complete content of org-roam files rather than the specific
300
- node, as it's much faster to do that on the UI side."
301
- (insert-file-contents-literally (org-link-decode file))
301
+ (defservlet* node/:id text/plain ()
302
+ " Servlet for accessing node content."
303
+ (insert (org-roam-ui--get-text (org-link-decode id)))
302
304
(httpd-send-header t " text/plain" 200 :Access-Control-Allow-Origin " *" ))
303
305
304
-
305
306
(defservlet* img/:file text/plain ()
306
307
" Servlet for accessing images found in org-roam files."
307
308
(progn
0 commit comments