11import { BlockNoteViewField } from "@/features/blocknote/blocknote-view-field" ;
22import { BlockNoteSchema , defaultBlockSpecs , defaultInlineContentSpecs } from "@blocknote/core" ;
3+ import { InlineTemplateVariable , TemplateVariableSelector } from "@/features/blocknote/inline-template-variable" ;
34import * as locales from '@blocknote/core/locales' ;
45import { useCreateBlockNote } from "@blocknote/react" ;
56import { FieldProps } from "@openfun/cunningham-react" ;
@@ -9,7 +10,7 @@ import { useTranslation } from "react-i18next";
910import { Toolbar } from "@/features/blocknote/toolbar" ;
1011import MailHelper from "@/features/utils/mail-helper" ;
1112import { BlockSignature , BlockSignatureConfigProps , SignatureTemplateSelector } from "@/features/blocknote/signature-block" ;
12- import { MessageTemplateTypeChoices , useMailboxesMessageTemplatesAvailableList } from "@/features/api/gen" ;
13+ import { MessageTemplateTypeChoices , useMailboxesMessageTemplatesAvailableList , usePlaceholdersRetrieve } from "@/features/api/gen" ;
1314import { useMailboxContext } from "@/features/providers/mailbox" ;
1415
1516const TEMPLATE_BLOCKNOTE_SCHEMA = BlockNoteSchema . create ( {
@@ -19,6 +20,7 @@ const TEMPLATE_BLOCKNOTE_SCHEMA = BlockNoteSchema.create({
1920 } ,
2021 inlineContentSpecs : {
2122 ...defaultInlineContentSpecs ,
23+ 'template-variable' : InlineTemplateVariable ,
2224 }
2325} ) ;
2426
@@ -41,6 +43,13 @@ export const TemplateComposer = ({ blockNoteOptions, defaultValue, disabled = fa
4143 const form = useFormContext ( ) ;
4244 const { selectedMailbox } = useMailboxContext ( ) ;
4345
46+ const { data : { data : placeholders = { } } = { } , isLoading : isLoadingPlaceholders } = usePlaceholdersRetrieve ( {
47+ query : {
48+ refetchOnMount : true ,
49+ refetchOnWindowFocus : true ,
50+ }
51+ } ) ;
52+
4453 const { data : { data : activeSignatures = [ ] } = { } , isLoading : isLoadingSignatures } = useMailboxesMessageTemplatesAvailableList (
4554 selectedMailbox ?. id || "" ,
4655 {
@@ -167,6 +176,10 @@ export const TemplateComposer = ({ blockNoteOptions, defaultValue, disabled = fa
167176 isLoading = { isLoadingSignatures }
168177 mailboxId = { selectedMailbox ?. id }
169178 />
179+ < TemplateVariableSelector
180+ variables = { placeholders }
181+ isLoading = { isLoadingPlaceholders }
182+ />
170183 </ Toolbar >
171184 </ BlockNoteViewField >
172185 < input { ...form . register ( "htmlBody" ) } type = "hidden" />
0 commit comments