Beautiful Open-Source Form Builder
feat: enhance email integration with customizable appearance settings
Chirag Chhatrala5e96a57c643b
diff --git a/api/app/Integrations/Handlers/EmailIntegration.php b/api/app/Integrations/Handlers/EmailIntegration.phpindex f779ee494..b27cd9c50 100644--- a/api/app/Integrations/Handlers/EmailIntegration.php+++ b/api/app/Integrations/Handlers/EmailIntegration.php@@ -27,7 +27,12 @@ class EmailIntegration extends AbstractIntegrationHandler'include_submission_data' => 'boolean','include_hidden_fields_submission_data' => ['nullable', 'boolean'],'reply_to' => 'nullable',- 'link_edit_submission' => ['nullable', 'boolean']+ 'link_edit_submission' => ['nullable', 'boolean'],+ 'logo_url' => ['nullable', 'url', 'starts_with:https://'],+ 'font_family' => ['nullable', 'string', 'max:255'],+ 'font_color' => ['nullable', 'string', 'regex:/^#[0-9A-Fa-f]{6}$/'],+ 'outer_background_color' => ['nullable', 'string', 'regex:/^#[0-9A-Fa-f]{6}$/'],+ 'inner_background_color' => ['nullable', 'string', 'regex:/^#[0-9A-Fa-f]{6}$/'],];if ($form->is_pro || config('app.self_hosted')) {diff --git a/api/app/Notifications/Forms/FormEmailNotification.php b/api/app/Notifications/Forms/FormEmailNotification.phpindex 19f74ab21..106400a5a 100644--- a/api/app/Notifications/Forms/FormEmailNotification.php+++ b/api/app/Notifications/Forms/FormEmailNotification.php@@ -192,20 +192,78 @@ class FormEmailNotification extends Notificationprivate function getMailData(): array{+ $form = $this->event->form;+ $isPro = $form->is_pro ?? false;++ $emailAppearance = $isPro ? [+ 'logoUrl' => $this->integrationData->logo_url ?? null,+ 'fontFamily' => $this->integrationData->font_family ?? null,+ 'fontColor' => $this->integrationData->font_color ?? null,+ 'outerBackgroundColor' => $this->integrationData->outer_background_color ?? null,+ 'innerBackgroundColor' => $this->integrationData->inner_background_color ?? null,+ ] : [];+return ['emailContent' => $this->getEmailContent(),'fields' => $this->formatSubmissionData(),- 'form' => $this->event->form,+ 'form' => $form,'integrationData' => $this->integrationData,- 'noBranding' => $this->event->form->no_branding,+ 'noBranding' => $form->no_branding,'submission_id' => $this->getEncodedSubmissionId(),+ 'emailAppearance' => $emailAppearance,];}private function getEmailContent(): string{$parser = new MentionParser($this->integrationData->email_content ?? '', $this->formatSubmissionData());- return $parser->parse();+ $html = $parser->parse();++ return $this->convertResizeAlignmentToInlineStyles($html);+ }++ /**+ * Convert quill-resize-module CSS classes to inline styles for email client compatibility.+ * Email clients often strip class-based styles; inline styles are required.+ */+ private function convertResizeAlignmentToInlineStyles(string $html): string+ {+ $alignments = [+ 'ql-resize-style-left' => 'float:left; margin:0 1em 1em 0;',+ 'ql-resize-style-right' => 'float:right; margin:0 0 1em 1em;',+ 'ql-resize-style-center' => 'display:block; margin:auto; text-align:center;',+ 'ql-resize-style-full' => 'width:100% !important;',+ ];++ foreach ($alignments as $class => $inlineStyle) {+ $html = preg_replace_callback(+ '/<([a-z]+)([^>]*\bclass\s*=\s*["\']([^"\']*' . preg_quote($class, '/') . '[^"\']*)["\'])([^>]*)>/i',+ function ($m) use ($class, $inlineStyle) {+ $tagName = $m[1];+ $beforeClass = $m[2];+ $classes = $m[3];+ $after = $m[4];++ $newClasses = preg_replace('/\s*' . preg_quote($class, '/') . '\s*/', ' ', $classes);+ $newClasses = trim(preg_replace('/\s+/', ' ', $newClasses));++ $style = $inlineStyle;+ if (preg_match('/style\s*=\s*["\']([^"\']*)["\']/', $beforeClass . $after, $sm)) {+ $style = $inlineStyle . $sm[1];+ $beforeClass = preg_replace('/\s*style\s*=\s*["\'][^"\']*["\']/', '', $beforeClass);+ $after = preg_replace('/\s*style\s*=\s*["\'][^"\']*["\']/', '', $after);+ }++ $beforeClass = preg_replace('/\s*class\s*=\s*["\'][^"\']*["\']/', '', $beforeClass);+ $classAttr = $newClasses !== '' ? ' class="' . $newClasses . '"' : '';++ return '<' . $tagName . $beforeClass . $classAttr . ' style="' . $style . '"' . $after . '>';+ },+ $html+ );+ }++ return $html;}private function getEncodedSubmissionId(): ?stringdiff --git a/api/resources/views/mail/form/email-notification.blade.php b/api/resources/views/mail/form/email-notification.blade.phpindex 1e6630535..f22e14465 100644--- a/api/resources/views/mail/form/email-notification.blade.php+++ b/api/resources/views/mail/form/email-notification.blade.php@@ -1,4 +1,7 @@-@component('mail::message', ['noBranding' => $noBranding])+@component('mail::message', [+'noBranding' => $noBranding,+'emailAppearance' => $emailAppearance ?? [],+]){!! $emailContent !!}diff --git a/api/resources/views/vendor/mail/html/layout.blade.php b/api/resources/views/vendor/mail/html/layout.blade.phpindex 21d349b39..190d03372 100644--- a/api/resources/views/vendor/mail/html/layout.blade.php+++ b/api/resources/views/vendor/mail/html/layout.blade.php@@ -1,56 +1,78 @@+@props(['emailAppearance' => []])++@php+$appearance = is_array($emailAppearance) ? $emailAppearance : [];+$outerBackgroundColor = $appearance['outerBackgroundColor'] ?? null;+$innerBackgroundColor = $appearance['innerBackgroundColor'] ?? null;+$fontFamily = $appearance['fontFamily'] ?? null;+$fontColor = $appearance['fontColor'] ?? null;++$wrapperStyle = $outerBackgroundColor ? 'background-color: ' . e($outerBackgroundColor) . ';' : '';+$bodyStyle = $outerBackgroundColor ? 'background-color: ' . e($outerBackgroundColor) . ';' : '';+$innerBodyStyle = $innerBackgroundColor ? 'background-color: ' . e($innerBackgroundColor) . ';' : '';+$fontFamilyCss = $fontFamily ? 'font-family: \'' . e($fontFamily) . '\', sans-serif;' : '';+$fontColorCss = $fontColor ? 'color: ' . e($fontColor) . ';' : '';+$contentCellStyle = ($fontFamilyCss || $fontColorCss) ? $fontFamilyCss . ' ' . $fontColorCss : '';+@endphp<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">+<head>-<meta name="viewport" content="width=device-width, initial-scale=1.0" />-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />-<meta name="color-scheme" content="light">-<meta name="supported-color-schemes" content="light">-<style>-@media only screen and (max-width: 600px) {-.inner-body {-width: 100% !important;-}--.footer {-width: 100% !important;-}-}--@media only screen and (max-width: 500px) {-.button {-width: 100% !important;-}-}-</style>+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />+ <meta name="color-scheme" content="light">+ <meta name="supported-color-schemes" content="light">+ @if($fontFamily && preg_match('/^[A-Za-z0-9\s\-]+$/', $fontFamily))+ <link href="https://fonts.googleapis.com/css2?family={{ str_replace(' ', '+', $fontFamily) }}:wght@400;600;700&display=swap" rel="stylesheet">+ @endif+ <style>+ @media only screen and (max-width: 600px) {+ .inner-body {+ width: 100% !important;+ }++ .footer {+ width: 100% !important;+ }+ }++ @media only screen and (max-width: 500px) {+ .button {+ width: 100% !important;+ }+ }+ </style></head>+<body>-<table class="wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">-<tr>-<td align="center">-<table class="content" width="100%" cellpadding="0" cellspacing="0" role="presentation">-{{ $header ?? '' }}--<!-- Email Body -->-<tr>-<td class="body" width="100%" cellpadding="0" cellspacing="0">-<table class="inner-body" align="center" width="570" cellpadding="0" cellspacing="0" role="presentation">-<!-- Body content -->-<tr>-<td class="content-cell">-{{ Illuminate\Mail\Markdown::parse($slot) }}--{{ $subcopy ?? '' }}-</td>-</tr>-</table>-</td>-</tr>--{{ $footer ?? '' }}-</table>-</td>-</tr>-</table>+ <table class="wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation" @if($wrapperStyle) style="{{ $wrapperStyle }}" @endif>+ <tr>+ <td align="center">+ <table class="content" width="100%" cellpadding="0" cellspacing="0" role="presentation">+ {{ $header ?? '' }}++ <!-- Email Body -->+ <tr>+ <td class="body" width="100%" cellpadding="0" cellspacing="0" @if($bodyStyle) style="{{ $bodyStyle }}" @endif>+ <table class="inner-body" align="center" width="570" cellpadding="0" cellspacing="0" role="presentation" @if($innerBodyStyle) style="{{ $innerBodyStyle }}" @endif>+ <!-- Body content -->+ <tr>+ <td class="content-cell" @if($contentCellStyle) style="{{ $contentCellStyle }}" @endif>+ {{ Illuminate\Mail\Markdown::parse($slot) }}++ {{ $subcopy ?? '' }}+ </td>+ </tr>+ </table>+ </td>+ </tr>++ {{ $footer ?? '' }}+ </table>+ </td>+ </tr>+ </table></body>-</html>++</html>\ No newline at end of filediff --git a/api/resources/views/vendor/mail/html/message.blade.php b/api/resources/views/vendor/mail/html/message.blade.phpindex 27ffb4d79..1cfb1cb01 100644--- a/api/resources/views/vendor/mail/html/message.blade.php+++ b/api/resources/views/vendor/mail/html/message.blade.php@@ -1,33 +1,43 @@-@component('mail::layout')-{{-- Header --}}-@slot('header')-@if (!(isset($noBranding) && $noBranding))- @component('mail::header', ['url' => config('app.url')])- {{ config('app.name') }}- @endcomponent-@else- <div style="margin-top:25px;" />-@endif-@endslot+@php+$appearance = isset($emailAppearance) && is_array($emailAppearance) ? $emailAppearance : [];+$logoUrl = $appearance['logoUrl'] ?? null;+@endphp+<x-mail::layout :email-appearance="$appearance">+ {{-- Header --}}+ <x-slot:header>+ @if (!(isset($noBranding) && $noBranding))+ @if(!empty($logoUrl))+ <x-mail::header :url="config('app.url')">+ <img src="{{ $logoUrl }}" class="logo" alt="Logo" style="max-height: 75px; height: 75px;">+ </x-mail::header>+ @else+ <x-mail::header :url="config('app.url')">+ {{ config('app.name') }}+ </x-mail::header>+ @endif+ @else+ <div style="margin-top:25px;" />+ @endif+ </x-slot:header>-{{-- Body --}}-{{ $slot }}+ {{-- Body --}}+ {{ $slot }}-{{-- Subcopy --}}-@isset($subcopy)-@slot('subcopy')-@component('mail::subcopy')-{{ $subcopy }}-@endcomponent-@endslot-@endisset+ {{-- Subcopy --}}+ @isset($subcopy)+ <x-slot:subcopy>+ <x-mail::subcopy>+ {{ $subcopy }}+ </x-mail::subcopy>+ </x-slot:subcopy>+ @endisset-{{-- Footer --}}-@slot('footer')-@component('mail::footer')-@if (!(isset($noBranding) && $noBranding))- © {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.')-@endif-@endcomponent-@endslot-@endcomponent+ {{-- Footer --}}+ <x-slot:footer>+ <x-mail::footer>+ @if (!(isset($noBranding) && $noBranding))+ © {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.')+ @endif+ </x-mail::footer>+ </x-slot:footer>+</x-mail::layout>\ No newline at end of filediff --git a/api/tests/Feature/Integrations/Email/EmailIntegrationTest.php b/api/tests/Feature/Integrations/Email/EmailIntegrationTest.phpindex 60bc38cb8..e39b41e8d 100644--- a/api/tests/Feature/Integrations/Email/EmailIntegrationTest.php+++ b/api/tests/Feature/Integrations/Email/EmailIntegrationTest.php@@ -242,3 +242,145 @@ test('free user cannot update integration to other email addresses', function ()expect($errorMessage)->toContain($user->email);expect($errorMessage)->toContain('Please upgrade to the Pro plan to send to other email addresses.');});+++test('free user can create with email appearance settings but email notification does not use them', function () {+ $user = $this->actingAsUser();+ $workspace = $this->createUserWorkspace($user);+ $form = $this->createForm($user, $workspace);++ $response = $this->postJson(route('open.forms.integrations.create', $form), [+ 'integration_id' => 'email',+ 'status' => 'active',+ 'data' => [+ 'send_to' => $user->email,+ 'sender_name' => 'Test Sender',+ 'subject' => 'Test Subject',+ 'email_content' => 'Test Content',+ 'include_submission_data' => true,+ 'logo_url' => 'https://example.com/logo.png',+ 'font_family' => 'Inter',+ 'font_color' => '#1a1a1a',+ 'outer_background_color' => '#f5f5f5',+ 'inner_background_color' => '#ffffff',+ ],+ ]);++ $response->assertSuccessful();++ $integration = FormIntegration::where('form_id', $form->id)->first();+ expect($integration->data->logo_url)->toBe('https://example.com/logo.png');++ $integrationData = $integration->data;+ $formData = $this->generateFormSubmissionData($form);+ $event = new \App\Events\Forms\FormSubmitted($form, $formData);+ $notification = new \App\Notifications\Forms\FormEmailNotification($event, $integrationData);+ $mailable = $notification->toMail(new \Illuminate\Notifications\AnonymousNotifiable());+ $mailData = $mailable->viewData;++ expect($mailData['emailAppearance'])->toBe([]);+});++test('pro user can create email integration with email appearance settings', function () {+ $user = $this->actingAsProUser();+ $workspace = $this->createUserWorkspace($user);+ $form = $this->createForm($user, $workspace);++ $response = $this->postJson(route('open.forms.integrations.create', $form), [+ 'integration_id' => 'email',+ 'status' => 'active',+ 'data' => [+ 'send_to' => $user->email,+ 'sender_name' => 'Test Sender',+ 'subject' => 'Test Subject',+ 'email_content' => 'Test Content',+ 'include_submission_data' => true,+ 'logo_url' => 'https://example.com/logo.png',+ 'font_family' => 'Inter',+ 'font_color' => '#1a1a1a',+ 'outer_background_color' => '#f5f5f5',+ 'inner_background_color' => '#ffffff',+ ],+ ]);++ $response->assertSuccessful();++ $integration = FormIntegration::where('form_id', $form->id)->first();+ expect($integration)->not->toBeNull();+ expect($integration->data->logo_url)->toBe('https://example.com/logo.png');+ expect($integration->data->font_family)->toBe('Inter');+ expect($integration->data->font_color)->toBe('#1a1a1a');+ expect($integration->data->outer_background_color)->toBe('#f5f5f5');+ expect($integration->data->inner_background_color)->toBe('#ffffff');+});++test('pro user email integration validates appearance settings format', function () {+ $user = $this->actingAsProUser();+ $workspace = $this->createUserWorkspace($user);+ $form = $this->createForm($user, $workspace);++ $response = $this->postJson(route('open.forms.integrations.create', $form), [+ 'integration_id' => 'email',+ 'status' => 'active',+ 'data' => [+ 'send_to' => $user->email,+ 'sender_name' => 'Test Sender',+ 'subject' => 'Test Subject',+ 'email_content' => 'Test Content',+ 'include_submission_data' => true,+ 'logo_url' => 'http://example.com/logo.png',+ 'font_color' => 'invalid-color',+ ],+ ]);++ $response->assertStatus(422)+ ->assertJsonValidationErrors(['data.logo_url'])+ ->assertJsonValidationErrors(['data.font_color']);+});++test('pro user can update email integration with email appearance settings', function () {+ $user = $this->actingAsProUser();+ $workspace = $this->createUserWorkspace($user);+ $form = $this->createForm($user, $workspace);++ $response = $this->postJson(route('open.forms.integrations.create', $form), [+ 'integration_id' => 'email',+ 'status' => 'active',+ 'data' => [+ 'send_to' => $user->email,+ 'sender_name' => 'Test Sender',+ 'subject' => 'Test Subject',+ 'email_content' => 'Test Content',+ 'include_submission_data' => true,+ ],+ ]);++ $response->assertSuccessful();+ $integrationId = $response->json('form_integration.id');++ $response = $this->putJson(route('open.forms.integrations.update', [$form, $integrationId]), [+ 'integration_id' => 'email',+ 'status' => 'active',+ 'data' => [+ 'send_to' => $user->email,+ 'sender_name' => 'Test Sender',+ 'subject' => 'Test Subject',+ 'email_content' => 'Test Content',+ 'include_submission_data' => true,+ 'logo_url' => 'https://example.com/updated-logo.png',+ 'font_family' => 'Open Sans',+ 'font_color' => '#333333',+ 'outer_background_color' => '#e0e0e0',+ 'inner_background_color' => '#fafafa',+ ],+ ]);++ $response->assertSuccessful();++ $integration = FormIntegration::find($integrationId);+ expect($integration->data->logo_url)->toBe('https://example.com/updated-logo.png');+ expect($integration->data->font_family)->toBe('Open Sans');+ expect($integration->data->font_color)->toBe('#333333');+ expect($integration->data->outer_background_color)->toBe('#e0e0e0');+ expect($integration->data->inner_background_color)->toBe('#fafafa');+});diff --git a/client/components/forms/heavy/RichTextAreaInput.client.vue b/client/components/forms/heavy/RichTextAreaInput.client.vueindex a6ae78072..3f39c3d6b 100644--- a/client/components/forms/heavy/RichTextAreaInput.client.vue+++ b/client/components/forms/heavy/RichTextAreaInput.client.vue@@ -156,6 +156,10 @@ const props = defineProps({allowFullscreen: {type: Boolean,default: false+ },+ enableImage: {+ type: Boolean,+ default: false}})const emit = defineEmits(['update:modelValue'])@@ -246,6 +250,7 @@ const buildQuillOptions = (includeFullscreen = false) => {['link'],[{ list: 'ordered' }, { list: 'bullet' }],[{ color: [] }],+ ...(props.enableImage ? [['image']] : []),],keyboard: {bindings: {@@ -254,7 +259,14 @@ const buildQuillOptions = (includeFullscreen = false) => {handler: () => true // Allow Tab to navigate out of editor for accessibility}}- }+ },+ ...(props.enableImage ? {+ resize: {+ modules: ['DisplaySize', 'Toolbar', 'Resize', 'Keyboard'],+ keyboardSelect: true,+ tools: ['left', 'center', 'right', 'full']+ }+ } : {})}}@@ -281,6 +293,15 @@ const buildQuillOptions = (includeFullscreen = false) => {}}}++ // Add image and resize alignment formats if enabled+ if (props.enableImage) {+ const formats = mergedOptions.formats || baseFormats+ const toAdd = ['image', 'resize-inline', 'resize-block'].filter((f) => !formats.includes(f))+ if (toAdd.length) {+ mergedOptions.formats = [...formats, ...toAdd]+ }+ }// Add mentions module and toolbar button if enabledif (props.enableMentions) {diff --git a/client/components/open/integrations/EmailIntegration.vue b/client/components/open/integrations/EmailIntegration.vueindex cd6a87ba4..cde868259 100644--- a/client/components/open/integrations/EmailIntegration.vue+++ b/client/components/open/integrations/EmailIntegration.vue@@ -37,7 +37,7 @@</InputHelp></template></MentionInput>- <div class="flex space-x-4">+ <div class="flex space-x-4 mt-4"><MentionInput:form="integrationData":mentions="form.properties"@@ -67,7 +67,90 @@:mentions="form.properties"name="data.email_content"label="Email Content"+ class="mt-4"/>+ <collapse+ v-model="showEmailAppearance"+ class="mt-4 w-full border rounded-lg bg-gray-50 dark:bg-neutral-900"+ >+ <template #title>+ <div class="flex gap-x-3 items-start pr-8 p-4">+ <div+ class="transition-colors"+ :class="{+ 'text-blue-600': showEmailAppearance,+ 'text-gray-300 dark:text-neutral-500': !showEmailAppearance,+ }"+ >+ <Icon+ name="heroicons:paint-brush-16-solid"+ size="24"+ />+ </div>+ <div class="grow">+ <h4 class="font-semibold flex items-center gap-2">+ Email appearance+ <ProTag upgrade-modal-title="Upgrade to customise email appearance" />+ </h4>+ <p class="text-gray-400 dark:text-neutral-500 text-xs">+ Logo, fonts and colors for your email notifications+ </p>+ </div>+ </div>+ </template>+ <div class="border-t dark:border-neutral-700 p-4 space-y-4">+ <TextInput+ :form="integrationData"+ name="data.logo_url"+ label="Logo URL"+ placeholder="https://example.com/logo.png"+ help="Display your logo in the email header (replaces app name)"+ />+ <div class="grid grid-cols-2 gap-4 mt-4">+ <div>+ <label class="text-neutral-700 dark:text-neutral-300 font-semibold text-xs mb-2 block">Font family</label>+ <UButton+ color="neutral"+ block+ size="lg"+ variant="outline"+ @click="showGoogleFontPicker = true"+ >+ <span :style="{ 'font-family': (integrationData.data.font_family ? integrationData.data.font_family + ', sans-serif' : null) }">+ {{ integrationData.data.font_family || 'Default' }}+ </span>+ </UButton>+ <GoogleFontPicker+ :show="showGoogleFontPicker"+ :font="integrationData.data.font_family || null"+ @close="showGoogleFontPicker = false"+ @apply="onApplyFont"+ />+ </div>+ <ColorInput+ :form="integrationData"+ name="data.font_color"+ label="Font color"+ help="Color of the text in the email"+ />+ </div>+ <div class="grid grid-cols-2 gap-4">+ <ColorInput+ :form="integrationData"+ name="data.outer_background_color"+ label="Outer background color"+ help="Background around the email content area"+ />+ <ColorInput+ :form="integrationData"+ name="data.inner_background_color"+ label="Inner background color"+ help="Background of the email content area"+ />+ </div>+ </div>+ </collapse>+<toggle-switch-input:form="integrationData"name="data.include_submission_data"@@ -103,6 +186,9 @@<script setup>import IntegrationWrapper from "./components/IntegrationWrapper.vue"+import GoogleFontPicker from "~/components/open/editors/GoogleFontPicker.vue"+import Collapse from "~/components/app/Collapse.vue"+import ProTag from "~/components/app/ProTag.vue"const props = defineProps({integration: { type: Object, required: true },@@ -115,6 +201,16 @@ const selfHosted = computed(() => useFeatureFlag('self_hosted'))const { openWorkspaceSettings } = useAppModals()const { data: user } = useAuth().user()+const showEmailAppearance = ref(false)+const showGoogleFontPicker = ref(false)++function onApplyFont(val) {+ if (props.integrationData.data) {+ props.integrationData.data.font_family = val+ }+ showGoogleFontPicker.value = false+}+function openEmailsModal () {openWorkspaceSettings('emails')}@@ -134,6 +230,11 @@ onBeforeMount(() => {email_content: "Hello there 👋 <br>This is a confirmation that your submission was successfully saved.",include_submission_data: true,include_hidden_fields_submission_data: false,+ logo_url: null,+ font_family: null,+ font_color: null,+ outer_background_color: '#f0f0f0',+ inner_background_color: '#ffffff',})) {if (props.integrationData.data[keyname] === undefined) {props.integrationData.data[keyname] = defaultValuediff --git a/client/lib/quill/quillPatches.js b/client/lib/quill/quillPatches.jsindex 6d2b6e7de..ee57f4c5d 100644--- a/client/lib/quill/quillPatches.js+++ b/client/lib/quill/quillPatches.js@@ -1,5 +1,9 @@import Quill from 'quill'-+import QuillResize from 'quill-resize-module'+import 'quill-resize-module/dist/resize.css'++Quill.register('modules/resize', QuillResize)+// Self-executing function to patch Quill's prototype;(function installQuillFixes() {@@ -44,18 +48,46 @@ import Quill from 'quill'}Clipboard.DEFAULTS.matchers.push([Node.TEXT_NODE, matcher])- }- // ---------------------------------------------------------------------------- // Tab key accessibility fix: allow Tab to navigate out of editor- // ----------------------------------------------------------------------------- const Keyboard = Quill.import('modules/keyboard')-- // Override Tab key behavior to allow navigation instead of inserting tabs- Keyboard.DEFAULTS.bindings.tab = {- key: 'Tab',- handler: () => true // Return true to let browser handle Tab navigation+ // 2c) Preserve quill-resize-module alignment (ql-resize-style-*) when pasting HTML+ const resizeAlignments = ['left', 'right', 'center', 'full']+ const getResizeAlignment = (el) => {+ if (!el || !el.classList) return null+ for (const align of resizeAlignments) {+ if (el.classList.contains(`ql-resize-style-${align}`)) return align+ }+ return null+ }++ const imgMatcher = (node, delta) => {+ const align = getResizeAlignment(node) || getResizeAlignment(node.parentElement)+ if (align && delta && delta.ops && delta.ops[0]) {+ const attrs = delta.ops[0].attributes || {}+ if (delta.ops[0].insert && typeof delta.ops[0].insert === 'object' && delta.ops[0].insert.image) {+ attrs['resize-inline'] = align+ delta.ops[0].attributes = attrs+ }+ }+ return delta+ }++ const blockMatcher = (node, delta) => {+ const align = getResizeAlignment(node)+ if (align && delta && delta.ops) {+ for (const op of delta.ops) {+ if (op.insert === '\n' || (typeof op.insert === 'string' && op.insert.includes('\n'))) {+ op.attributes = op.attributes || {}+ op.attributes['resize-block'] = align+ break+ }+ }+ }+ return delta+ }++ Clipboard.DEFAULTS.matchers.push(['IMG', imgMatcher])+ Clipboard.DEFAULTS.matchers.push(['P', blockMatcher])+ Clipboard.DEFAULTS.matchers.push(['DIV', blockMatcher])}})()diff --git a/client/package-lock.json b/client/package-lock.jsonindex 55811b72a..28777d9f3 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -47,6 +47,7 @@"prismjs": "^1.29.0","qrcode": "^1.5.4","quill": "^2.0.2",+ "quill-resize-module": "^2.1.3","tailwind-merge": "^2.5.4","tailwindcss": "^4.1.10","tinymotion": "^0.2.0",@@ -19238,6 +19239,11 @@"node": ">= 12.0.0"}},+ "node_modules/quill-resize-module": {+ "version": "2.1.3",+ "resolved": "https://registry.npmjs.org/quill-resize-module/-/quill-resize-module-2.1.3.tgz",+ "integrity": "sha512-Hrs/pwKqmnEkY8Z5zbp4LxdLSHmQBXGAR5yzEFDeSfWTZIMpi6yII/dqIeXfwQBKAxWAVSxEeWqY7DMZ2GLTaQ=="+ },"node_modules/quote-unquote": {"version": "1.0.0","resolved": "https://registry.npmjs.org/quote-unquote/-/quote-unquote-1.0.0.tgz",diff --git a/client/package.json b/client/package.jsonindex 196400d48..27869ddd5 100644--- a/client/package.json+++ b/client/package.json@@ -88,6 +88,7 @@"prismjs": "^1.29.0","qrcode": "^1.5.4","quill": "^2.0.2",+ "quill-resize-module": "^2.1.3","tailwind-merge": "^2.5.4","tailwindcss": "^4.1.10","tinymotion": "^0.2.0",