Skip to content

Commit

Permalink
Merge pull request #216 from lara-zeus/fix-content
Browse files Browse the repository at this point in the history
Fix content
  • Loading branch information
atmonshi authored Oct 6, 2024
2 parents 0babf4d + 113f59e commit 5d68455
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 47 deletions.
86 changes: 43 additions & 43 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/Editors/MarkdownEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public static function component(): Component
public static function render(string $content): string
{
if (class_exists(MarkdownEditorAlias::class)) {
return str($content)->markdown();
return (new \Illuminate\Support\HtmlString(
str(strip_tags($content))
->replace(['prompt(', 'eval(', '&lt;script', '<script'], '')
->markdown()
))->toHtml();
}

return $content;
Expand Down
4 changes: 3 additions & 1 deletion src/Editors/RichEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static function component(): Component

public static function render(string $content): string
{
return html_entity_decode($content);
return
str(html_entity_decode($content))
->replace(['prompt(', 'eval(', '&lt;script', '<script'], '');
}
}
3 changes: 2 additions & 1 deletion src/Editors/TinyEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static function component(): Component
public static function render(string $content): string
{
if (class_exists(TinyEditorAlias::class)) {
return html_entity_decode($content);
return str(html_entity_decode($content))
->replace(['prompt(', 'eval(', '&lt;script', '<script'], '');
}

return $content;
Expand Down
6 changes: 5 additions & 1 deletion src/Editors/TipTapEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public static function render(string $content): string
{
if (class_exists(\FilamentTiptapEditor\TiptapEditor::class)) {
// @phpstan-ignore-next-line
return tiptap_converter()->asHTML($content);
return tiptap_converter()
->asHTML(
str(html_entity_decode($content))
->replace(['prompt(', 'eval(', '&lt;script', '<script'], '')
);
}

return $content;
Expand Down

0 comments on commit 5d68455

Please sign in to comment.