File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,18 +88,22 @@ const NodeSearchMenu = ({
8888 const regex = getDiscourseNodeFormatExpression ( node . format ) ;
8989
9090 const regexPattern = regex . source
91- . replace ( / ^ \^ / , "" )
92- . replace ( / \$ $ / , "" )
93- . replace ( / \\ / g, "\\\\" ) ;
91+ . replace ( / \\ / g, "\\\\" )
92+ . replace ( / " / g, '\\"' ) ;
93+
94+ const searchCondition = searchTerm
95+ ? `[(re-pattern "(?i).*${ escapeCljString ( searchTerm . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ) } .*") ?search-regex]
96+ [(re-find ?search-regex ?node-title)]`
97+ : "" ;
9498
9599 const query = `[
96100 :find
97101 (pull ?node [:block/string :node/title :block/uid])
98102 :where
99103 [(re-pattern "${ regexPattern } ") ?title-regex]
100104 [?node :node/title ?node-title]
101- ${ searchTerm ? `[(clojure.string/includes? ?node-title "${ escapeCljString ( searchTerm ) } ")]` : "" }
102105 [(re-find ?title-regex ?node-title)]
106+ ${ searchCondition }
103107 ]` ;
104108 const results = window . roamAlphaAPI . q ( query ) ;
105109
@@ -110,6 +114,7 @@ const NodeSearchMenu = ({
110114 } ) ) ;
111115 } catch ( error ) {
112116 console . error ( `Error querying for node type ${ node . type } :` , error ) ;
117+ console . error ( `Node format:` , node . format ) ;
113118 return [ ] ;
114119 }
115120 } ;
@@ -377,7 +382,6 @@ const NodeSearchMenu = ({
377382
378383 setIsFilterMenuOpen ( ( prev ) => ! prev ) ;
379384
380- // Restore focus after toggle
381385 setTimeout ( ( ) => {
382386 if ( textarea ) {
383387 textarea . focus ( ) ;
You can’t perform that action at this time.
0 commit comments