@@ -8,27 +8,21 @@ import Document from "@tiptap/extension-document";
88import Paragraph from "@tiptap/extension-paragraph" ;
99import Text from "@tiptap/extension-text" ;
1010import { Placeholder , UndoRedo } from "@tiptap/extensions" ;
11- import { mount , unmount } from "svelte" ;
11+ import { mount , unmount , getAllContexts } from "svelte" ;
1212import {
1313 convertContextToInlinePrompt ,
1414 INLINE_CHAT_CONTEXT_TAG ,
1515 type InlineContext ,
1616 normalizeInlineContext ,
1717 parseInlineAttr ,
1818} from "@rilldata/web-common/features/chat/core/context/inline-context.ts" ;
19- import {
20- RUNTIME_CONTEXT_KEY ,
21- RuntimeClient ,
22- } from "@rilldata/web-common/runtime-client/v2" ;
2319
2420export function getEditorPlugins ( {
2521 placeholder,
2622 onSubmit,
27- runtimeClient,
2823} : {
2924 placeholder : string ;
3025 onSubmit : ( ) => void ;
31- runtimeClient : RuntimeClient ;
3226} ) {
3327 const sharedEditorStore = new SharedEditorStore ( ) ;
3428
@@ -40,7 +34,7 @@ export function getEditorPlugins({
4034 placeholder,
4135 } ) ,
4236 EditorSubmitExtension . configure ( { onSubmit, sharedEditorStore } ) ,
43- configureInlineContextTipTapExtension ( sharedEditorStore , runtimeClient ) ,
37+ configureInlineContextTipTapExtension ( sharedEditorStore ) ,
4438 UndoRedo ,
4539 ] ;
4640
@@ -103,7 +97,7 @@ const EditorSubmitExtension = Extension.create(() => {
10397
10498type InlineContextOptions = MentionOptions < never , InlineContext > & {
10599 sharedEditorStore : SharedEditorStore ;
106- runtimeClient : RuntimeClient ;
100+ allParentContexts : Map < any , any > ;
107101} ;
108102
109103// Add the startMention command to the Commands type.
@@ -127,7 +121,7 @@ const InlineContextExtension = Mention.extend<InlineContextOptions>({
127121 // These have to be configured for the extension to work
128122 manager : { } as ConversationManager ,
129123 sharedEditorStore : { } as SharedEditorStore ,
130- runtimeClient : { } as RuntimeClient ,
124+ allParentContexts : new Map ( ) ,
131125 } ;
132126 } ,
133127
@@ -188,7 +182,7 @@ const InlineContextExtension = Mention.extend<InlineContextOptions>({
188182 // We need this here to make sure the component is rendered inline.
189183 target . className = "inline-block" ;
190184
191- const { sharedEditorStore, runtimeClient } = this . options ;
185+ const { sharedEditorStore, allParentContexts } = this . options ;
192186
193187 // Create the inline chat context component. Pass the wrapper as the target.
194188 const comp = mount ( InlineContextComponent , {
@@ -216,7 +210,7 @@ const InlineContextExtension = Mention.extend<InlineContextOptions>({
216210 }
217211 : { mode : "readonly" } ,
218212 } ,
219- context : new Map ( [ [ RUNTIME_CONTEXT_KEY , runtimeClient ] ] ) ,
213+ context : allParentContexts ,
220214 } ) as InlineContextExports ;
221215 sharedEditorStore . componentAdded ( comp ) ;
222216
@@ -237,15 +231,16 @@ const InlineContextExtension = Mention.extend<InlineContextOptions>({
237231 */
238232export function configureInlineContextTipTapExtension (
239233 sharedEditorStore : SharedEditorStore ,
240- runtimeClient : RuntimeClient ,
241234) {
242235 let comp : Record < string , unknown > | null = null ;
243236 const pickerProps : Record < string , unknown > = $state ( { } ) ;
244237 let selected = false ;
245238
239+ const allParentContexts = getAllContexts ( ) ;
240+
246241 return InlineContextExtension . configure ( {
247242 sharedEditorStore,
248- runtimeClient ,
243+ allParentContexts ,
249244 suggestion : {
250245 char : "@" ,
251246 allowSpaces : true ,
@@ -264,7 +259,7 @@ export function configureInlineContextTipTapExtension(
264259 comp = mount ( InlineContextPicker , {
265260 target : document . body ,
266261 props : pickerProps ,
267- context : new Map ( [ [ RUNTIME_CONTEXT_KEY , runtimeClient ] ] ) ,
262+ context : allParentContexts ,
268263 } ) ;
269264 sharedEditorStore . contextOpen = true ;
270265 } ,
0 commit comments