Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unwrap from transforms and add ungroup to animation blocks #1775

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ e.g.

== Changelog ==

[ Specification Change ][ Animation(Pro) ] Fix WordPress 6.3 transforms settings.

= 1.60.0 =
[ Add Function ] Add Font Awesome icon custom list function.
[ Add Function ][ Dynamic Text Block (Pro) ] URL support for custom fields.
Expand Down
36 changes: 29 additions & 7 deletions src/blocks/_pro/animation/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
*/
import { createBlock } from '@wordpress/blocks';

/**
* External dependencies
*/
import compareVersions from 'compare-versions';

// WP6.3以上か NOTE: WP6.2以下をサポートしなくなったら削除すること
const isLargerThanWp63 = () => {
if (
window.wpVersion !== undefined &&
window.wpVersion !== null &&
compareVersions(window.wpVersion, '6.3') < 0
) {
return false;
}
return true;
};

const transforms = {
from: [
{
Expand All @@ -27,13 +44,18 @@ const transforms = {
},
},
],
to: [
{
type: 'block',
blocks: ['*'],
transform: (attributes, innerBlocks) => innerBlocks,
},
],
ungroup: isLargerThanWp63()
? (attributes, innerBlocks) => innerBlocks
: undefined,
to: !isLargerThanWp63()
? [
{
type: 'block',
blocks: ['*'],
transform: (attributes, innerBlocks) => innerBlocks,
},
]
: undefined,
};

export default transforms;