tiptap-php icon indicating copy to clipboard operation
tiptap-php copied to clipboard

Sanitize removes links (<a>) and underline (<u>)

Open mreduar opened this issue 3 years ago • 1 comments

Hi, I have installed the package just to sanitize the content generated by tiptap in the frontend. And I notice that when sanitizing it removes the links (a tags) and underlines (u tags), how is it possible to avoid this behavior?

mreduar avatar Jul 13 '22 15:07 mreduar

@mreduar Hi, it is most probably related with https://github.com/ueberdosis/tiptap-php/issues/20 where Link is not included by default in StarterKit.

davorpeic avatar Sep 21 '22 17:09 davorpeic

@mreduar Hi, it is most probably related with #20 where Link is not included by default in StarterKit.

At the time I did not give it much importance, but now that the time has come to solve the problem I had to inquire more about what you mentioned and indeed that was the problem. This should be included by default in my opinion. Solve the problem by adding the Link Mark to the Editor

use Tiptap\Editor;
use Tiptap\Extensions\StarterKit;
use Tiptap\Marks\Link;

(new Editor([
    'extensions' => [
        new StarterKit(),
        new Link(),
    ],
]))->sanitize($content)

Thank you @davorpeic

mreduar avatar Jun 01 '23 15:06 mreduar