Add CKEditor support to the email body textarea

Created on 14 September 2022, almost 2 years ago
Updated 28 May 2024, about 1 month ago

Problem/Motivation

I had a requirement, Where we need to use Html text format for the email body.
I am using the beta-1.0 version of commerce email which is compatible with Drupal 8.

So for this, I have created a patch which will convert the text area to text format (ckeditor field) and update config schema to support the value of text format.
Also define the helper function in Commerce Email entity interface.

โœจ Feature request
Status

Fixed

Version

1.0

Component

User interface

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia DhruvR

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland ayalon

    The patch contains another fix #3314082

    Also, the schema was incorrect. I created a cleaned up version. Also supporting the transition of existing text only templates.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States rszrama

    Retitling. If we can get WYSIWYG support here, that'd be awesome.

  • ๐Ÿ‡น๐Ÿ‡ทTurkey RgnYLDZ

    After this patch I'm getting the below error when an email is sent with commerce_email on a status change for example;

    Error: Call to a member function fromArray() on null in Drupal\symfony_mailer\MailManagerReplacement->mail() (line 89 of modules/contrib/symfony_mailer/src/MailManagerReplacement.php).

    Drupal\commerce\MailHandler->sendMail() (Line: 88)
    Drupal\commerce_email\EmailSender->send() (Line: 180)
    Drupal\commerce_email\EventSubscriber\EmailSubscriber->sendEmail() (Line: 139)
    Drupal\commerce_email\EventSubscriber\EmailSubscriber->onEvent()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 422)
    Drupal\state_machine\Plugin\Field\FieldType\StateItem->dispatchTransitionEvent() (Line: 389)
    Drupal\state_machine\Plugin\Field\FieldType\StateItem->postSave()
    call_user_func_array() (Line: 233)
    Drupal\Core\Field\FieldItemList->delegateMethod() (Line: 198)
    Drupal\Core\Field\FieldItemList->postSave()
    call_user_func_array() (Line: 938)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod() (Line: 970)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldPostSave() (Line: 896)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeHook() (Line: 56)
    Drupal\commerce\CommerceContentEntityStorage->invokeHook() (Line: 81)
    Drupal\commerce_order\OrderStorage->invokeHook() (Line: 564)
    Drupal\Core\Entity\EntityStorageBase->doPostSave() (Line: 781)
    Drupal\Core\Entity\ContentEntityStorageBase->doPostSave() (Line: 489)
    Drupal\Core\Entity\EntityStorageBase->save() (Line: 804)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 159)
    Drupal\commerce_order\OrderStorage->save() (Line: 339)
    Drupal\Core\Entity\EntityBase->save() (Line: 123)
    Drupal\state_machine\Form\StateTransitionConfirmForm->submitForm()
    call_user_func_array() (Line: 114)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 52)
    Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
    Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 270)
    Drupal\shield\ShieldMiddleware->bypass() (Line: 226)
    Drupal\shield\ShieldMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 692)
    Drupal\Core\DrupalKernel->handle() (Line: 19)

    Using commerce_email v1.1

  • ๐Ÿ‡ธ๐Ÿ‡ฎSlovenia Maya Slatinek

    I've tested the patch from #3 with v8.x-1.1 on Drupal 10.1.2 and can confirm it works well with the Symfony mailer. The formatted text set in the email configs is seen in the email received.

  • First commit to issue fork.
  • Assigned to karengrey
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom karengrey
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom karengrey

    I have updated the patch based on Ryan's suggestion to check if the site is setup for HTML email. I have added a check for symfony_mailer, as this is the suggested module to use for HTML emails (swiftmailer has been unsupported since November 2021)
    I have also included all text formats, so the user has a choice.

    I saw no other config available to check if a site is setup to use HTML email, as Core MailManager only returns the default `php_mail` interface.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine marchuk.vitaliy Rivne, UA

    vmarchuk โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine marchuk.vitaliy Rivne, UA

    @rszrama

    I don't really want to stick with modules that support HTML email (symfony_mailer or whatever), but give users the choice to figure this out themselves. Also, we probably need to add a good description for the Body field.

  • Status changed to Fixed 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine marchuk.vitaliy Rivne, UA

    Committed!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia DhruvR
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Can this be the cause of issue with missing BODY field in translations? Only label and subject

Production build 0.69.0 2024