Skip to content

Commit 9a6abaa

Browse files
committed
Provide matrix manually
1 parent e14986a commit 9a6abaa

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
"require": {
2020
"php": "^8.1",
2121
"ext-json": "*",
22-
"illuminate/support": "^9.0",
22+
"illuminate/support": "^9.0|^10.0",
2323
"spatie/laravel-mailcoach": "^6.0"
2424
},
2525
"require-dev": {
26-
"orchestra/testbench": "^7.0",
26+
"orchestra/testbench": "^7.0|^8.0",
2727
"phpunit/phpunit": "^9.5",
2828
"symfony/var-dumper": "^6.0"
2929
},

resources/views/unlayer.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function loadTemplate() {
9999
@foreach ($replacers as $replacerName => $replacerDescription)
100100
mergeTags["{{ $replacerName }}"] = {
101101
name: "{{ $replacerName }}",
102-
value: "::{{ $replacerName }}::"
102+
value: '@{{' + "{{ $replacerName }}" + '}}'
103103
};
104104
@endforeach
105105
@@ -108,8 +108,8 @@ function loadTemplate() {
108108
const component = this;
109109
unlayer.addEventListener('design:updated', () => {
110110
unlayer.exportHtml(function(data) {
111-
component.html = data.html.replaceAll('[[[', '[[[');
112-
component.json = JSON.parse(JSON.stringify(data.design).replaceAll('[[[', '[[['));
111+
component.html = data.html;
112+
component.json = JSON.parse(JSON.stringify(data.design));
113113
document.getElementById('editor').dirty = true;
114114
});
115115
});

src/UnlayerEditor.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ public function rules(): array
3030
];
3131
}
3232

33+
public function saveQuietly()
34+
{
35+
$this->fullHtml = str_replace('[[[', '[[[', $this->fullHtml);
36+
$this->fullHtml = str_replace(']]]', ']]]', $this->fullHtml);
37+
38+
parent::saveQuietly();
39+
}
40+
3341
public function render(): View
3442
{
3543
$this->templateFieldValues['html'] ??= '';
@@ -67,9 +75,9 @@ protected function filterNeededFields(array $fields, \Spatie\Mailcoach\Domain\Ca
6775
private function getSpecialLinks(HasHtmlContent $model): array
6876
{
6977
$links = [
70-
['name' => 'Webview URL', 'href' => '::webviewUrl::', 'target' => '_blank'],
71-
['name' => 'Manage preferences', 'href' => '::preferencesUrl::', 'target' => '_blank'],
72-
['name' => 'Unsubscribe URL', 'href' => '::unsubscribeUrl::', 'target' => '_blank'],
78+
['name' => 'Webview URL', 'href' => '{{webviewUrl}}', 'target' => '_blank'],
79+
['name' => 'Manage preferences', 'href' => '{{preferencesUrl}}', 'target' => '_blank'],
80+
['name' => 'Unsubscribe URL', 'href' => '{{unsubscribeUrl}}', 'target' => '_blank'],
7381
];
7482

7583
if ($model instanceof Campaign && $model->emailList) {
@@ -79,7 +87,7 @@ private function getSpecialLinks(HasHtmlContent $model): array
7987
$tags->each(function (Tag $tag) use (&$unsubscribeLinks) {
8088
$unsubscribeLinks[] = [
8189
'name' => $tag->name,
82-
'href' => "::unsubscribeTag::{$tag->name}::",
90+
'href' => "{{unsubscribeTag['{$tag->name}']",
8391
'target' => '_blank',
8492
];
8593
});

0 commit comments

Comments
 (0)