payload-plugin-newsletter 0.14.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1623,6 +1623,8 @@ var BroadcastProvider = class {
1623
1623
  body: JSON.stringify({
1624
1624
  to: recipients[0],
1625
1625
  // Broadcast API expects a single recipient for transactional emails
1626
+ from: `${from.name} <${from.email}>`,
1627
+ // Include from name and email
1626
1628
  subject: params.subject,
1627
1629
  body: params.html || params.text || "",
1628
1630
  reply_to: params.replyTo || this.replyTo || from.email
@@ -2721,9 +2723,10 @@ var createSigninEndpoint = (config) => {
2721
2723
  siteName: settings?.brandSettings?.siteName || "Newsletter",
2722
2724
  expiresIn: config.auth?.tokenExpiration || "7d"
2723
2725
  }, config);
2726
+ const subject = settings?.emailTemplates?.magicLink?.subjectLine || (settings?.brandSettings?.siteName ? `Sign in to ${settings.brandSettings.siteName}` : "Sign in to your account");
2724
2727
  await emailService.send({
2725
2728
  to: subscriber.email,
2726
- subject: settings?.brandSettings?.siteName ? `Sign in to ${settings.brandSettings.siteName}` : "Sign in to your account",
2729
+ subject,
2727
2730
  html
2728
2731
  });
2729
2732
  } else {
@@ -3758,143 +3761,152 @@ import {
3758
3761
  InlineToolbarFeature,
3759
3762
  lexicalEditor
3760
3763
  } from "@payloadcms/richtext-lexical";
3761
- var emailSafeFeatures = [
3762
- // Toolbars
3763
- FixedToolbarFeature(),
3764
- // Fixed toolbar at the top
3765
- InlineToolbarFeature(),
3766
- // Floating toolbar when text is selected
3767
- // Basic text formatting
3768
- BoldFeature(),
3769
- ItalicFeature(),
3770
- UnderlineFeature(),
3771
- StrikethroughFeature(),
3772
- // Links with enhanced configuration
3773
- LinkFeature({
3774
- fields: [
3775
- {
3776
- name: "url",
3777
- type: "text",
3778
- required: true,
3779
- admin: {
3780
- description: "Enter the full URL (including https://)"
3764
+ var createEmailSafeFeatures = (additionalBlocks) => {
3765
+ const baseBlocks = [
3766
+ {
3767
+ slug: "button",
3768
+ fields: [
3769
+ {
3770
+ name: "text",
3771
+ type: "text",
3772
+ label: "Button Text",
3773
+ required: true
3774
+ },
3775
+ {
3776
+ name: "url",
3777
+ type: "text",
3778
+ label: "Button URL",
3779
+ required: true,
3780
+ admin: {
3781
+ description: "Enter the full URL (including https://)"
3782
+ }
3783
+ },
3784
+ {
3785
+ name: "style",
3786
+ type: "select",
3787
+ label: "Button Style",
3788
+ defaultValue: "primary",
3789
+ options: [
3790
+ { label: "Primary", value: "primary" },
3791
+ { label: "Secondary", value: "secondary" },
3792
+ { label: "Outline", value: "outline" }
3793
+ ]
3781
3794
  }
3782
- },
3783
- {
3784
- name: "newTab",
3785
- type: "checkbox",
3786
- label: "Open in new tab",
3787
- defaultValue: false
3795
+ ],
3796
+ interfaceName: "EmailButton",
3797
+ labels: {
3798
+ singular: "Button",
3799
+ plural: "Buttons"
3788
3800
  }
3789
- ]
3790
- }),
3791
- // Lists
3792
- OrderedListFeature(),
3793
- UnorderedListFeature(),
3794
- // Headings - limited to h1, h2, h3 for email compatibility
3795
- HeadingFeature({
3796
- enabledHeadingSizes: ["h1", "h2", "h3"]
3797
- }),
3798
- // Basic paragraph and alignment
3799
- ParagraphFeature(),
3800
- AlignFeature(),
3801
- // Blockquotes
3802
- BlockquoteFeature(),
3803
- // Upload feature for images
3804
- UploadFeature({
3805
- collections: {
3806
- media: {
3807
- fields: [
3808
- {
3809
- name: "caption",
3810
- type: "text",
3811
- admin: {
3812
- description: "Optional caption for the image"
3813
- }
3814
- },
3815
- {
3816
- name: "altText",
3817
- type: "text",
3818
- label: "Alt Text",
3819
- required: true,
3820
- admin: {
3821
- description: "Alternative text for accessibility and when image cannot be displayed"
3822
- }
3823
- }
3824
- ]
3801
+ },
3802
+ {
3803
+ slug: "divider",
3804
+ fields: [
3805
+ {
3806
+ name: "style",
3807
+ type: "select",
3808
+ label: "Divider Style",
3809
+ defaultValue: "solid",
3810
+ options: [
3811
+ { label: "Solid", value: "solid" },
3812
+ { label: "Dashed", value: "dashed" },
3813
+ { label: "Dotted", value: "dotted" }
3814
+ ]
3815
+ }
3816
+ ],
3817
+ interfaceName: "EmailDivider",
3818
+ labels: {
3819
+ singular: "Divider",
3820
+ plural: "Dividers"
3825
3821
  }
3826
3822
  }
3827
- }),
3828
- // Custom blocks for email-specific content
3829
- BlocksFeature({
3830
- blocks: [
3831
- {
3832
- slug: "button",
3833
- fields: [
3834
- {
3835
- name: "text",
3836
- type: "text",
3837
- label: "Button Text",
3838
- required: true
3839
- },
3840
- {
3841
- name: "url",
3842
- type: "text",
3843
- label: "Button URL",
3844
- required: true,
3845
- admin: {
3846
- description: "Enter the full URL (including https://)"
3847
- }
3848
- },
3849
- {
3850
- name: "style",
3851
- type: "select",
3852
- label: "Button Style",
3853
- defaultValue: "primary",
3854
- options: [
3855
- { label: "Primary", value: "primary" },
3856
- { label: "Secondary", value: "secondary" },
3857
- { label: "Outline", value: "outline" }
3858
- ]
3823
+ ];
3824
+ const allBlocks = [
3825
+ ...baseBlocks,
3826
+ ...additionalBlocks || []
3827
+ ];
3828
+ return [
3829
+ // Toolbars
3830
+ FixedToolbarFeature(),
3831
+ // Fixed toolbar at the top
3832
+ InlineToolbarFeature(),
3833
+ // Floating toolbar when text is selected
3834
+ // Basic text formatting
3835
+ BoldFeature(),
3836
+ ItalicFeature(),
3837
+ UnderlineFeature(),
3838
+ StrikethroughFeature(),
3839
+ // Links with enhanced configuration
3840
+ LinkFeature({
3841
+ fields: [
3842
+ {
3843
+ name: "url",
3844
+ type: "text",
3845
+ required: true,
3846
+ admin: {
3847
+ description: "Enter the full URL (including https://)"
3859
3848
  }
3860
- ],
3861
- interfaceName: "EmailButton",
3862
- labels: {
3863
- singular: "Button",
3864
- plural: "Buttons"
3849
+ },
3850
+ {
3851
+ name: "newTab",
3852
+ type: "checkbox",
3853
+ label: "Open in new tab",
3854
+ defaultValue: false
3865
3855
  }
3866
- },
3867
- {
3868
- slug: "divider",
3869
- fields: [
3870
- {
3871
- name: "style",
3872
- type: "select",
3873
- label: "Divider Style",
3874
- defaultValue: "solid",
3875
- options: [
3876
- { label: "Solid", value: "solid" },
3877
- { label: "Dashed", value: "dashed" },
3878
- { label: "Dotted", value: "dotted" }
3879
- ]
3880
- }
3881
- ],
3882
- interfaceName: "EmailDivider",
3883
- labels: {
3884
- singular: "Divider",
3885
- plural: "Dividers"
3856
+ ]
3857
+ }),
3858
+ // Lists
3859
+ OrderedListFeature(),
3860
+ UnorderedListFeature(),
3861
+ // Headings - limited to h1, h2, h3 for email compatibility
3862
+ HeadingFeature({
3863
+ enabledHeadingSizes: ["h1", "h2", "h3"]
3864
+ }),
3865
+ // Basic paragraph and alignment
3866
+ ParagraphFeature(),
3867
+ AlignFeature(),
3868
+ // Blockquotes
3869
+ BlockquoteFeature(),
3870
+ // Upload feature for images
3871
+ UploadFeature({
3872
+ collections: {
3873
+ media: {
3874
+ fields: [
3875
+ {
3876
+ name: "caption",
3877
+ type: "text",
3878
+ admin: {
3879
+ description: "Optional caption for the image"
3880
+ }
3881
+ },
3882
+ {
3883
+ name: "altText",
3884
+ type: "text",
3885
+ label: "Alt Text",
3886
+ required: true,
3887
+ admin: {
3888
+ description: "Alternative text for accessibility and when image cannot be displayed"
3889
+ }
3890
+ }
3891
+ ]
3886
3892
  }
3887
3893
  }
3888
- ]
3889
- })
3890
- ];
3894
+ }),
3895
+ // Custom blocks for email-specific content
3896
+ BlocksFeature({
3897
+ blocks: allBlocks
3898
+ })
3899
+ ];
3900
+ };
3901
+ var emailSafeFeatures = createEmailSafeFeatures();
3891
3902
  var createEmailContentField = (overrides) => {
3903
+ const features = createEmailSafeFeatures(overrides?.additionalBlocks);
3892
3904
  return {
3893
3905
  name: "content",
3894
3906
  type: "richText",
3895
3907
  required: true,
3896
3908
  editor: lexicalEditor({
3897
- features: emailSafeFeatures
3909
+ features
3898
3910
  }),
3899
3911
  admin: {
3900
3912
  description: "Email content with limited formatting for compatibility",
@@ -3920,6 +3932,7 @@ var createBroadcastInlinePreviewField = () => {
3920
3932
  // src/collections/Broadcasts.ts
3921
3933
  var createBroadcastsCollection = (pluginConfig) => {
3922
3934
  const hasProviders = !!(pluginConfig.providers?.broadcast || pluginConfig.providers?.resend);
3935
+ const customizations = pluginConfig.customizations?.broadcasts;
3923
3936
  return {
3924
3937
  slug: "broadcasts",
3925
3938
  labels: {
@@ -3940,6 +3953,8 @@ var createBroadcastsCollection = (pluginConfig) => {
3940
3953
  description: "Email subject line"
3941
3954
  }
3942
3955
  },
3956
+ // Add any additional fields from customizations after subject
3957
+ ...customizations?.additionalFields || [],
3943
3958
  {
3944
3959
  type: "row",
3945
3960
  fields: [
@@ -3961,10 +3976,13 @@ var createBroadcastsCollection = (pluginConfig) => {
3961
3976
  description: "Preview text shown in email clients"
3962
3977
  }
3963
3978
  },
3964
- createEmailContentField({
3965
- admin: {
3966
- description: "Email content"
3967
- }
3979
+ // Apply content field customization if provided
3980
+ customizations?.fieldOverrides?.content ? customizations.fieldOverrides.content(createEmailContentField({
3981
+ admin: { description: "Email content" },
3982
+ additionalBlocks: customizations.customBlocks
3983
+ })) : createEmailContentField({
3984
+ admin: { description: "Email content" },
3985
+ additionalBlocks: customizations?.customBlocks
3968
3986
  })
3969
3987
  ]
3970
3988
  },