payload-plugin-newsletter 0.14.3 → 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.cjs CHANGED
@@ -3761,143 +3761,152 @@ init_types();
3761
3761
 
3762
3762
  // src/fields/emailContent.ts
3763
3763
  var import_richtext_lexical = require("@payloadcms/richtext-lexical");
3764
- var emailSafeFeatures = [
3765
- // Toolbars
3766
- (0, import_richtext_lexical.FixedToolbarFeature)(),
3767
- // Fixed toolbar at the top
3768
- (0, import_richtext_lexical.InlineToolbarFeature)(),
3769
- // Floating toolbar when text is selected
3770
- // Basic text formatting
3771
- (0, import_richtext_lexical.BoldFeature)(),
3772
- (0, import_richtext_lexical.ItalicFeature)(),
3773
- (0, import_richtext_lexical.UnderlineFeature)(),
3774
- (0, import_richtext_lexical.StrikethroughFeature)(),
3775
- // Links with enhanced configuration
3776
- (0, import_richtext_lexical.LinkFeature)({
3777
- fields: [
3778
- {
3779
- name: "url",
3780
- type: "text",
3781
- required: true,
3782
- admin: {
3783
- 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
+ ]
3784
3794
  }
3785
- },
3786
- {
3787
- name: "newTab",
3788
- type: "checkbox",
3789
- label: "Open in new tab",
3790
- defaultValue: false
3795
+ ],
3796
+ interfaceName: "EmailButton",
3797
+ labels: {
3798
+ singular: "Button",
3799
+ plural: "Buttons"
3791
3800
  }
3792
- ]
3793
- }),
3794
- // Lists
3795
- (0, import_richtext_lexical.OrderedListFeature)(),
3796
- (0, import_richtext_lexical.UnorderedListFeature)(),
3797
- // Headings - limited to h1, h2, h3 for email compatibility
3798
- (0, import_richtext_lexical.HeadingFeature)({
3799
- enabledHeadingSizes: ["h1", "h2", "h3"]
3800
- }),
3801
- // Basic paragraph and alignment
3802
- (0, import_richtext_lexical.ParagraphFeature)(),
3803
- (0, import_richtext_lexical.AlignFeature)(),
3804
- // Blockquotes
3805
- (0, import_richtext_lexical.BlockquoteFeature)(),
3806
- // Upload feature for images
3807
- (0, import_richtext_lexical.UploadFeature)({
3808
- collections: {
3809
- media: {
3810
- fields: [
3811
- {
3812
- name: "caption",
3813
- type: "text",
3814
- admin: {
3815
- description: "Optional caption for the image"
3816
- }
3817
- },
3818
- {
3819
- name: "altText",
3820
- type: "text",
3821
- label: "Alt Text",
3822
- required: true,
3823
- admin: {
3824
- description: "Alternative text for accessibility and when image cannot be displayed"
3825
- }
3826
- }
3827
- ]
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"
3828
3821
  }
3829
3822
  }
3830
- }),
3831
- // Custom blocks for email-specific content
3832
- (0, import_richtext_lexical.BlocksFeature)({
3833
- blocks: [
3834
- {
3835
- slug: "button",
3836
- fields: [
3837
- {
3838
- name: "text",
3839
- type: "text",
3840
- label: "Button Text",
3841
- required: true
3842
- },
3843
- {
3844
- name: "url",
3845
- type: "text",
3846
- label: "Button URL",
3847
- required: true,
3848
- admin: {
3849
- description: "Enter the full URL (including https://)"
3850
- }
3851
- },
3852
- {
3853
- name: "style",
3854
- type: "select",
3855
- label: "Button Style",
3856
- defaultValue: "primary",
3857
- options: [
3858
- { label: "Primary", value: "primary" },
3859
- { label: "Secondary", value: "secondary" },
3860
- { label: "Outline", value: "outline" }
3861
- ]
3823
+ ];
3824
+ const allBlocks = [
3825
+ ...baseBlocks,
3826
+ ...additionalBlocks || []
3827
+ ];
3828
+ return [
3829
+ // Toolbars
3830
+ (0, import_richtext_lexical.FixedToolbarFeature)(),
3831
+ // Fixed toolbar at the top
3832
+ (0, import_richtext_lexical.InlineToolbarFeature)(),
3833
+ // Floating toolbar when text is selected
3834
+ // Basic text formatting
3835
+ (0, import_richtext_lexical.BoldFeature)(),
3836
+ (0, import_richtext_lexical.ItalicFeature)(),
3837
+ (0, import_richtext_lexical.UnderlineFeature)(),
3838
+ (0, import_richtext_lexical.StrikethroughFeature)(),
3839
+ // Links with enhanced configuration
3840
+ (0, import_richtext_lexical.LinkFeature)({
3841
+ fields: [
3842
+ {
3843
+ name: "url",
3844
+ type: "text",
3845
+ required: true,
3846
+ admin: {
3847
+ description: "Enter the full URL (including https://)"
3862
3848
  }
3863
- ],
3864
- interfaceName: "EmailButton",
3865
- labels: {
3866
- singular: "Button",
3867
- plural: "Buttons"
3849
+ },
3850
+ {
3851
+ name: "newTab",
3852
+ type: "checkbox",
3853
+ label: "Open in new tab",
3854
+ defaultValue: false
3868
3855
  }
3869
- },
3870
- {
3871
- slug: "divider",
3872
- fields: [
3873
- {
3874
- name: "style",
3875
- type: "select",
3876
- label: "Divider Style",
3877
- defaultValue: "solid",
3878
- options: [
3879
- { label: "Solid", value: "solid" },
3880
- { label: "Dashed", value: "dashed" },
3881
- { label: "Dotted", value: "dotted" }
3882
- ]
3883
- }
3884
- ],
3885
- interfaceName: "EmailDivider",
3886
- labels: {
3887
- singular: "Divider",
3888
- plural: "Dividers"
3856
+ ]
3857
+ }),
3858
+ // Lists
3859
+ (0, import_richtext_lexical.OrderedListFeature)(),
3860
+ (0, import_richtext_lexical.UnorderedListFeature)(),
3861
+ // Headings - limited to h1, h2, h3 for email compatibility
3862
+ (0, import_richtext_lexical.HeadingFeature)({
3863
+ enabledHeadingSizes: ["h1", "h2", "h3"]
3864
+ }),
3865
+ // Basic paragraph and alignment
3866
+ (0, import_richtext_lexical.ParagraphFeature)(),
3867
+ (0, import_richtext_lexical.AlignFeature)(),
3868
+ // Blockquotes
3869
+ (0, import_richtext_lexical.BlockquoteFeature)(),
3870
+ // Upload feature for images
3871
+ (0, import_richtext_lexical.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
+ ]
3889
3892
  }
3890
3893
  }
3891
- ]
3892
- })
3893
- ];
3894
+ }),
3895
+ // Custom blocks for email-specific content
3896
+ (0, import_richtext_lexical.BlocksFeature)({
3897
+ blocks: allBlocks
3898
+ })
3899
+ ];
3900
+ };
3901
+ var emailSafeFeatures = createEmailSafeFeatures();
3894
3902
  var createEmailContentField = (overrides) => {
3903
+ const features = createEmailSafeFeatures(overrides?.additionalBlocks);
3895
3904
  return {
3896
3905
  name: "content",
3897
3906
  type: "richText",
3898
3907
  required: true,
3899
3908
  editor: (0, import_richtext_lexical.lexicalEditor)({
3900
- features: emailSafeFeatures
3909
+ features
3901
3910
  }),
3902
3911
  admin: {
3903
3912
  description: "Email content with limited formatting for compatibility",
@@ -3923,6 +3932,7 @@ var createBroadcastInlinePreviewField = () => {
3923
3932
  // src/collections/Broadcasts.ts
3924
3933
  var createBroadcastsCollection = (pluginConfig) => {
3925
3934
  const hasProviders = !!(pluginConfig.providers?.broadcast || pluginConfig.providers?.resend);
3935
+ const customizations = pluginConfig.customizations?.broadcasts;
3926
3936
  return {
3927
3937
  slug: "broadcasts",
3928
3938
  labels: {
@@ -3943,6 +3953,8 @@ var createBroadcastsCollection = (pluginConfig) => {
3943
3953
  description: "Email subject line"
3944
3954
  }
3945
3955
  },
3956
+ // Add any additional fields from customizations after subject
3957
+ ...customizations?.additionalFields || [],
3946
3958
  {
3947
3959
  type: "row",
3948
3960
  fields: [
@@ -3964,10 +3976,13 @@ var createBroadcastsCollection = (pluginConfig) => {
3964
3976
  description: "Preview text shown in email clients"
3965
3977
  }
3966
3978
  },
3967
- createEmailContentField({
3968
- admin: {
3969
- description: "Email content"
3970
- }
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
3971
3986
  })
3972
3987
  ]
3973
3988
  },