Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
Add support for title attrribute to link mark (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurperton authored Aug 18, 2021
1 parent 46f7f24 commit 7d22a0d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Marks/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public function tag()
$attrs['rel'] = $this->mark->attrs->rel;
}

if (isset($this->mark->attrs->title)) {
$attrs['title'] = $this->mark->attrs->title;
}

$attrs['href'] = $this->mark->attrs->href;

return [
Expand Down
27 changes: 27 additions & 0 deletions tests/Marks/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ public function link_mark_has_support_for_target()
$this->assertEquals($html, (new Renderer)->render($json));
}

/** @test */
public function link_mark_has_support_for_title()
{
$json = [
'type' => 'doc',
'content' => [
[
'type' => 'text',
'text' => 'Example Link',
'marks' => [
[
'type' => 'link',
'attrs' => [
'href' => 'https://scrumpy.io',
'title' => 'Foo',
],
],
],
],
],
];

$html = '<a title="Foo" href="https://scrumpy.io">Example Link</a>';

$this->assertEquals($html, (new Renderer)->render($json));
}

/** @test */
public function link_with_marks_generates_clean_output()
{
Expand Down

0 comments on commit 7d22a0d

Please sign in to comment.