diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 92542e0..9bd3bc1 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -7,10 +7,8 @@ template: | categories: - title: '🚀 Features' - collapse-after: 3 label: 'enhancement' - title: '🐛 Bug Fixes' - collapse-after: 3 labels: - 'fix' - 'bugfix' diff --git a/src/variations/controls.js b/src/variations/controls.js index 6d2394b..9a604d5 100644 --- a/src/variations/controls.js +++ b/src/variations/controls.js @@ -5,6 +5,7 @@ import { addFilter } from '@wordpress/hooks'; import { InspectorControls } from '@wordpress/block-editor'; import { PanelBody } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { createBlock } from '@wordpress/blocks'; /** * Internal dependencies */ @@ -92,4 +93,51 @@ const withAdvancedQueryControls = ( BlockEdit ) => ( props ) => { return ; }; -addFilter( 'editor.BlockEdit', 'core/query', withAdvancedQueryControls ); +addFilter( + 'editor.BlockEdit', + 'aql/add-add-controls/core/query', + withAdvancedQueryControls +); + +/** + * Filter to add AQL transform to core/query block + * + * @param {Object} settings + * @param {string} name + * @return {Object} settings + */ +function addAQLTransforms( settings, name ) { + if ( name !== 'core/query' ) { + return settings; + } + + return { + ...settings, + keywords: [ ...settings.keywords, 'AQL', 'aql' ], + transforms: { + to: settings?.transforms?.to || [], + from: [ + ...( settings?.transforms?.from || [] ), + { + type: 'enter', + regExp: /^(AQL|aql)$/, + transform: () => { + return createBlock( + 'core/query', + { + namespace: 'advanced-query-loop', + }, + [] + ); + }, + }, + ], + }, + }; +} + +addFilter( + 'blocks.registerBlockType', + 'aql/add-transforms/query-block', + addAQLTransforms +);