This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1696544
commit e9186f1
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace ProseMirrorToHtml\Nodes; | ||
|
||
class Image extends Node | ||
{ | ||
protected $nodeType = 'image'; | ||
protected $tagName = 'img'; | ||
|
||
public function selfClosing() | ||
{ | ||
return true; | ||
} | ||
|
||
public function tag() | ||
{ | ||
return [ | ||
[ | ||
'tag' => $this->tagName, | ||
'attrs' => $this->node->attrs, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace ProseMirrorToHtml\Test\Nodes; | ||
|
||
use ProseMirrorToHtml\Renderer; | ||
use ProseMirrorToHtml\Test\TestCase; | ||
|
||
class ImageTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function image_gets_rendered_correctly() | ||
{ | ||
$json = [ | ||
'type' => 'doc', | ||
'content' => [ | ||
[ | ||
'type' => 'image', | ||
'attrs' => [ | ||
'alt' => 'an image', | ||
'src' => 'image/source', | ||
'title' => 'The image title', | ||
], | ||
], | ||
], | ||
]; | ||
|
||
$html = '<img alt="an image" src="image/source" title="The image title">'; | ||
|
||
$this->assertEquals($html, (new Renderer)->render($json)); | ||
} | ||
} |