-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 #1467 from swissspidy/add/nextpage
Add pagination block
- Loading branch information
Showing
11 changed files
with
216 additions
and
34 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
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,40 @@ | ||
.editor-visual-editor__block[data-type="core/nextpage"] { | ||
max-width: 100%; | ||
} | ||
|
||
.wp-block-nextpage { | ||
display: block; | ||
text-align: center; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
} | ||
|
||
.wp-block-nextpage > span { | ||
position: relative; | ||
display: inline-block; | ||
font-size: 12px; | ||
text-transform: uppercase; | ||
font-weight: 600; | ||
font-family: $default-font; | ||
color: $dark-gray-300; | ||
} | ||
|
||
.wp-block-nextpage > span:before, | ||
.wp-block-nextpage > span:after { | ||
content: ''; | ||
position: absolute; | ||
top: 50%; | ||
width: 100vw; | ||
border-top: 3px dashed $light-gray-700; | ||
margin-top: -2px; | ||
} | ||
|
||
.wp-block-nextpage > span:before { | ||
right: 100%; | ||
margin-right: 20px; | ||
} | ||
|
||
.wp-block-nextpage > span:after { | ||
left: 100%; | ||
margin-left: 20px; | ||
} |
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,61 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { RawHTML } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './editor.scss'; | ||
import { createBlock } from '../../api'; | ||
|
||
export const name = 'core/nextpage'; | ||
|
||
export const settings = { | ||
title: __( 'Page break' ), | ||
|
||
description: __( 'This block allows you to set break points on your post. Visitors of your blog are then presented with content split into multiple pages.' ), | ||
|
||
icon: 'admin-page', | ||
|
||
category: 'layout', | ||
|
||
keywords: [ __( 'next page' ), __( 'pagination' ) ], | ||
|
||
supports: { | ||
customClassName: false, | ||
className: false, | ||
html: false, | ||
}, | ||
|
||
attributes: {}, | ||
|
||
transforms: { | ||
from: [ | ||
{ | ||
type: 'raw', | ||
isMatch: ( node ) => node.dataset && node.dataset.block === 'core/nextpage', | ||
transform() { | ||
return createBlock( 'core/nextpage', {} ); | ||
}, | ||
}, | ||
], | ||
}, | ||
|
||
edit() { | ||
return ( | ||
<div className="wp-block-nextpage"> | ||
<span>{ __( 'Page break' ) }</span> | ||
</div> | ||
); | ||
}, | ||
|
||
save() { | ||
return ( | ||
<RawHTML> | ||
{ '<!--nextpage-->' } | ||
</RawHTML> | ||
); | ||
}, | ||
}; |
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/nextpage block edit matches snapshot 1`] = ` | ||
<div | ||
class="wp-block-nextpage" | ||
> | ||
<span> | ||
Page break | ||
</span> | ||
</div> | ||
`; |
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,13 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { name, settings } from '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
describe( 'core/nextpage', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( name, settings ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
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,3 @@ | ||
<!-- wp:core/nextpage --> | ||
<!--nextpage--> | ||
<!-- /wp:core/nextpage --> |
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,10 @@ | ||
[ | ||
{ | ||
"uid": "_uid_0", | ||
"name": "core/nextpage", | ||
"isValid": true, | ||
"attributes": {}, | ||
"innerBlocks": [], | ||
"originalContent": "<!--nextpage-->" | ||
} | ||
] |
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,12 @@ | ||
[ | ||
{ | ||
"blockName": "core/nextpage", | ||
"attrs": null, | ||
"innerBlocks": [], | ||
"innerHTML": "\n<!--nextpage-->\n" | ||
}, | ||
{ | ||
"attrs": {}, | ||
"innerHTML": "\n" | ||
} | ||
] |
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,3 @@ | ||
<!-- wp:nextpage --> | ||
<!--nextpage--> | ||
<!-- /wp:nextpage --> |