Update insert link callback to insert links with new tags

[MAILPOET-6393]
This commit is contained in:
Rostislav Wolny
2025-01-07 15:26:51 +01:00
committed by Aschepikov
parent 80f35169a2
commit c05a2edfba

View File

@ -33,26 +33,24 @@ export const useContentValidation = (): ContentValidationData => {
const { addValidationNotice, hasValidationNotice, removeValidationNotice } = const { addValidationNotice, hasValidationNotice, removeValidationNotice } =
useValidationNotices(); useValidationNotices();
const { editedContent, editedTemplateContent, defaultTemplateId } = const { editedContent, editedTemplateContent, postTemplateId } = useSelect(
useSelect( ( mapSelect ) => ( { ( mapSelect ) => ( {
editedContent: editedContent:
mapSelect( emailEditorStore ).getEditedEmailContent(), mapSelect( emailEditorStore ).getEditedEmailContent(),
editedTemplateContent: editedTemplateContent:
mapSelect( emailEditorStore ).getTemplateContent(), mapSelect( emailEditorStore ).getTemplateContent(),
defaultTemplateId: mapSelect( coreDataStore ).getDefaultTemplateId( postTemplateId:
{ mapSelect( emailEditorStore ).getEditedPostTemplate()?.id,
slug: 'email-general', } )
} );
),
} ) );
const content = useShallowEqual( editedContent ); const content = useShallowEqual( editedContent );
const templateContent = useShallowEqual( editedTemplateContent ); const templateContent = useShallowEqual( editedTemplateContent );
const contentLink = `<a href='[link:subscription_unsubscribe_url]'>${ __( const contentLink = `<a data-link-href='[mailpoet/subscription-unsubscribe-url]' contenteditable='false' style='text-decoration: underline;' class='mailpoet-email-editor__personalization-tags-link'>${ __(
'Unsubscribe', 'Unsubscribe',
'mailpoet' 'mailpoet'
) }</a> | <a href='[link:subscription_manage_url]'>${ __( ) }</a> | <a data-link-href='[mailpoet/subscription-manage-url]' contenteditable='false' style='text-decoration: underline;' class='mailpoet-email-editor__personalization-tags-link'>${ __(
'Manage subscription', 'Manage subscription',
'mailpoet' 'mailpoet'
) }</a>`; ) }</a>`;
@ -88,7 +86,7 @@ export const useContentValidation = (): ContentValidationData => {
void dispatch( coreDataStore ).editEntityRecord( void dispatch( coreDataStore ).editEntityRecord(
'postType', 'postType',
'wp_template', 'wp_template',
defaultTemplateId, postTemplateId,
{ {
content: ` content: `
${ editedTemplateContent } ${ editedTemplateContent }
@ -108,7 +106,7 @@ export const useContentValidation = (): ContentValidationData => {
contentBlockId, contentBlockId,
hasFooter, hasFooter,
contentLink, contentLink,
defaultTemplateId, postTemplateId,
editedTemplateContent, editedTemplateContent,
] ); ] );