@@ -53,8 +53,13 @@ type ModifyNodeFormProps = {
5353 onCancel : ( ) => void ;
5454 initialTitle ?: string ;
5555 initialNodeType ?: DiscourseNode ;
56- initialFile ?: TFile ; // for edit mode
57- currentFile ?: TFile ; // the file where the node is being created from
56+ /** Present in edit mode — the file being modified. Also drives `isEditMode`. */
57+ initialFile ?: TFile ;
58+ /** Context file for the "Relationship with …" block (editor "Turn into" flow). */
59+ currentFile ?: TFile ;
60+ /** Hides the search-existing-nodes dropdown. Used when intent is always to create
61+ * (e.g. file explorer "Convert into"), not to reuse an existing node. */
62+ disableExistingNodeSearch ?: boolean ;
5863 plugin : DiscourseGraphPlugin ;
5964} ;
6065
@@ -66,6 +71,7 @@ export const ModifyNodeForm = ({
6671 initialNodeType,
6772 initialFile,
6873 currentFile,
74+ disableExistingNodeSearch = false ,
6975 plugin,
7076} : ModifyNodeFormProps ) => {
7177 const isEditMode = ! ! initialFile ;
@@ -95,9 +101,9 @@ export const ModifyNodeForm = ({
95101 [ selectedNodeType ] ,
96102 ) ;
97103
98- // Search for nodes when query changes (only in create mode)
104+ // Search for nodes when query changes (only in create mode, and only when search is enabled )
99105 useEffect ( ( ) => {
100- if ( isEditMode ) {
106+ if ( isEditMode || disableExistingNodeSearch ) {
101107 setSearchResults ( [ ] ) ;
102108 return ;
103109 }
@@ -137,16 +143,23 @@ export const ModifyNodeForm = ({
137143 clearTimeout ( debounceTimeoutRef . current ) ;
138144 }
139145 } ;
140- } , [ query , selectedNodeType , isEditMode ] ) ;
146+ } , [ query , selectedNodeType , isEditMode , disableExistingNodeSearch ] ) ;
141147
142148 const isOpen = useMemo ( ( ) => {
143149 return (
150+ ! disableExistingNodeSearch &&
144151 ! selectedExistingNode &&
145152 isFocused &&
146153 searchResults . length > 0 &&
147154 query . trim ( ) . length >= 2
148155 ) ;
149- } , [ selectedExistingNode , isFocused , searchResults . length , query ] ) ;
156+ } , [
157+ disableExistingNodeSearch ,
158+ selectedExistingNode ,
159+ isFocused ,
160+ searchResults . length ,
161+ query ,
162+ ] ) ;
150163
151164 useEffect ( ( ) => {
152165 setActiveIndex ( 0 ) ;
@@ -177,9 +190,14 @@ export const ModifyNodeForm = ({
177190 }
178191 } , [ activeIndex , isOpen ] ) ;
179192
180- // Focus the content input on mount so users can start typing immediately
193+ // Focus the content input on mount so users can start typing immediately,
194+ // with cursor placed at the end of any pre-filled text
181195 useEffect ( ( ) => {
182- titleInputRef . current ?. focus ( ) ;
196+ const el = titleInputRef . current ;
197+ if ( ! el ) return ;
198+ el . focus ( ) ;
199+ const len = el . value . length ;
200+ el . setSelectionRange ( len , len ) ;
183201 } , [ ] ) ;
184202
185203 useEffect ( ( ) => {
@@ -449,15 +467,19 @@ export const ModifyNodeForm = ({
449467 placeholder = {
450468 isEditMode
451469 ? "Enter new content"
452- : selectedNodeType
453- ? `Search for existing ${ selectedNodeType . name . toLowerCase ( ) } or enter new content`
454- : "Search for existing nodes or enter new content"
470+ : disableExistingNodeSearch
471+ ? selectedNodeType
472+ ? `Enter ${ selectedNodeType . name . toLowerCase ( ) } content`
473+ : "Enter content"
474+ : selectedNodeType
475+ ? `Search for existing ${ selectedNodeType . name . toLowerCase ( ) } or enter new content`
476+ : "Search for existing nodes or enter new content"
455477 }
456478 value = { query }
457479 onChange = { handleQueryChange }
458480 onKeyDown = { handleKeyDown }
459481 onFocus = { ( ) => {
460- if ( ! isEditMode ) {
482+ if ( ! isEditMode && ! disableExistingNodeSearch ) {
461483 setIsFocused ( true ) ;
462484 }
463485 } }
@@ -604,8 +626,12 @@ type ModifyNodeModalProps = {
604626 } ) => Promise < void > ;
605627 initialTitle ?: string ;
606628 initialNodeType ?: DiscourseNode ;
629+ /** Present in edit mode — the file being modified. */
607630 initialFile ?: TFile ;
631+ /** Context file for the "Relationship with …" block (editor "Turn into" flow). */
608632 currentFile ?: TFile ;
633+ /** See `ModifyNodeFormProps.disableExistingNodeSearch`. */
634+ disableExistingNodeSearch ?: boolean ;
609635} ;
610636
611637class ModifyNodeModal extends Modal {
@@ -623,6 +649,7 @@ class ModifyNodeModal extends Modal {
623649 private initialNodeType ?: DiscourseNode ;
624650 private initialFile ?: TFile ;
625651 private currentFile ?: TFile ;
652+ private disableExistingNodeSearch : boolean ;
626653 private plugin : DiscourseGraphPlugin ;
627654
628655 constructor ( app : App , props : ModifyNodeModalProps ) {
@@ -633,6 +660,7 @@ class ModifyNodeModal extends Modal {
633660 this . initialNodeType = props . initialNodeType ;
634661 this . initialFile = props . initialFile ;
635662 this . currentFile = props . currentFile ;
663+ this . disableExistingNodeSearch = props . disableExistingNodeSearch ?? false ;
636664 this . plugin = props . plugin ;
637665 }
638666
@@ -651,6 +679,7 @@ class ModifyNodeModal extends Modal {
651679 initialNodeType = { this . initialNodeType }
652680 initialFile = { this . initialFile }
653681 currentFile = { this . currentFile }
682+ disableExistingNodeSearch = { this . disableExistingNodeSearch }
654683 plugin = { this . plugin }
655684 />
656685 </ StrictMode > ,
0 commit comments