Skip to content

Commit

Permalink
[AIDAPP-281]: fixed GDPR hyperlink issue
Browse files Browse the repository at this point in the history
  • Loading branch information
payal-canyon committed Oct 14, 2024
1 parent db531ea commit 59e6d31
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app-modules/portal/src/Filament/Pages/ManagePortalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,35 @@ public function form(Form $form): Form
->visible(fn (Get $get) => $get('knowledge_management_portal_enabled')),
]);
}

public function updateLinks(array $array): array
{
foreach ($array['content'] as &$paragraph) {
foreach ($paragraph['content'] as &$text) {
if (isset($text['marks'])) {
foreach ($text['marks'] as &$mark) {
if ($mark['type'] === 'link' && isset($mark['attrs']['href'])) {
if (strpos($mark['attrs']['href'], 'www.') === 0) {
$mark['attrs']['href'] = 'https://' . $mark['attrs']['href'];
} elseif (strpos($mark['attrs']['href'], 'http') !== 0) {
$mark['attrs']['href'] = 'https://' . $mark['attrs']['href'];
}
}
}
}
}
}

return $array;
}

protected function mutateFormDataBeforeSave(array $data): array
{
$tiptapContent = $data['gdpr_banner_text'];
$tiptapContent = $this->updateLinks($tiptapContent);

$data['gdpr_banner_text'] = $tiptapContent;

return $data;
}
}

0 comments on commit 59e6d31

Please sign in to comment.