-
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 branch 'master' of https://github.com/WordPress/gutenberg into …
…rnmobile/887-History-stack-is-not-empty-on-a-fresh-start-of-the-editor * 'master' of https://github.com/WordPress/gutenberg: Reset embed mocks on every request, stop request to instagram (#15046) Refactor core blocks to have save and transforms in their own files (part 2) (#14899) Fix pullquote import (#15036) Refactor core blocks to have save and transforms in their own files (part 4) (#14903) Refactor core blocks to have save and transforms in their own files (part 3) (#14902) Refactor core blocks to have deprecated extracted to their ownf files (p.1) (#14979) Test transform from media to embed blocks (#13997) If a more recent revision/autosave exists, store its state on editor setup (#7945) chore(release): publish
- Loading branch information
Showing
114 changed files
with
3,113 additions
and
2,137 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
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,112 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { omit } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { RichText } from '@wordpress/block-editor'; | ||
|
||
const colorsMigration = ( attributes ) => { | ||
return omit( { | ||
...attributes, | ||
customTextColor: attributes.textColor && '#' === attributes.textColor[ 0 ] ? attributes.textColor : undefined, | ||
customBackgroundColor: attributes.color && '#' === attributes.color[ 0 ] ? attributes.color : undefined, | ||
}, [ 'color', 'textColor' ] ); | ||
}; | ||
|
||
const blockAttributes = { | ||
url: { | ||
type: 'string', | ||
source: 'attribute', | ||
selector: 'a', | ||
attribute: 'href', | ||
}, | ||
title: { | ||
type: 'string', | ||
source: 'attribute', | ||
selector: 'a', | ||
attribute: 'title', | ||
}, | ||
text: { | ||
type: 'string', | ||
source: 'html', | ||
selector: 'a', | ||
}, | ||
}; | ||
|
||
const deprecated = [ | ||
{ | ||
attributes: { | ||
...blockAttributes, | ||
color: { | ||
type: 'string', | ||
}, | ||
textColor: { | ||
type: 'string', | ||
}, | ||
align: { | ||
type: 'string', | ||
default: 'none', | ||
}, | ||
}, | ||
save( { attributes } ) { | ||
const { url, text, title, align, color, textColor } = attributes; | ||
|
||
const buttonStyle = { | ||
backgroundColor: color, | ||
color: textColor, | ||
}; | ||
|
||
const linkClass = 'wp-block-button__link'; | ||
|
||
return ( | ||
<div className={ `align${ align }` }> | ||
<RichText.Content | ||
tagName="a" | ||
className={ linkClass } | ||
href={ url } | ||
title={ title } | ||
style={ buttonStyle } | ||
value={ text } | ||
/> | ||
</div> | ||
); | ||
}, | ||
migrate: colorsMigration, | ||
}, | ||
{ | ||
attributes: { | ||
...blockAttributes, | ||
color: { | ||
type: 'string', | ||
}, | ||
textColor: { | ||
type: 'string', | ||
}, | ||
align: { | ||
type: 'string', | ||
default: 'none', | ||
}, | ||
}, | ||
save( { attributes } ) { | ||
const { url, text, title, align, color, textColor } = attributes; | ||
|
||
return ( | ||
<div className={ `align${ align }` } style={ { backgroundColor: color } }> | ||
<RichText.Content | ||
tagName="a" | ||
href={ url } | ||
title={ title } | ||
style={ { color: textColor } } | ||
value={ text } | ||
/> | ||
</div> | ||
); | ||
}, | ||
migrate: colorsMigration, | ||
}, | ||
]; | ||
|
||
export default deprecated; |
Oops, something went wrong.