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 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from jasonvarga/blockquote
Support blockquotes
- Loading branch information
Showing
3 changed files
with
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Scrumpy\HtmlToProseMirror\Nodes; | ||
|
||
class Blockquote extends Node | ||
{ | ||
public function matching() | ||
{ | ||
return $this->DOMNode->nodeName === 'blockquote'; | ||
} | ||
|
||
public function data() | ||
{ | ||
return [ | ||
'type' => 'blockquote', | ||
]; | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
namespace Scrumpy\HtmlToProseMirror\Test\Nodes; | ||
|
||
use Scrumpy\HtmlToProseMirror\Renderer; | ||
use Scrumpy\HtmlToProseMirror\Test\TestCase; | ||
|
||
class BlockquoteTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function blockquote_gets_rendered_correctly() | ||
{ | ||
$html = '<blockquote><p>Paragraph</p></blockquote>'; | ||
|
||
$json = [ | ||
'type' => 'doc', | ||
'content' => [ | ||
[ | ||
'type' => 'blockquote', | ||
'content' => [ | ||
[ | ||
'type' => 'paragraph', | ||
'content' => [ | ||
[ | ||
'type' => 'text', | ||
'text' => 'Paragraph', | ||
], | ||
], | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
|
||
$this->assertEquals($json, (new Renderer)->render($html)); | ||
} | ||
} |