From 7ee8009a1acd4ea06ab6d1cc79fcf5e1746b3906 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Wed, 5 Jun 2024 16:17:44 -0400 Subject: [PATCH 1/3] Add transform to allow using "AQL" or "aql" short cuts to insert new instance. --- src/variations/controls.js | 49 +++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/variations/controls.js b/src/variations/controls.js index 6d2394b..2ce0dfe 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,50 @@ 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, + 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 +); From ae43482e882e39c5e6556918b2f4feb8934eff43 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Fri, 7 Jun 2024 11:09:40 -0400 Subject: [PATCH 2/3] Update drafter to no longer collapse after 3 items. --- .github/release-drafter.yml | 2 -- 1 file changed, 2 deletions(-) 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' From 25f73186234737a118c74fd6c0ec23cd7fbe2c17 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Mon, 10 Jun 2024 13:16:03 -0400 Subject: [PATCH 3/3] Add some keywords to make it easer to use the slash command. --- src/variations/controls.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/variations/controls.js b/src/variations/controls.js index 2ce0dfe..9a604d5 100644 --- a/src/variations/controls.js +++ b/src/variations/controls.js @@ -113,6 +113,7 @@ function addAQLTransforms( settings, name ) { return { ...settings, + keywords: [ ...settings.keywords, 'AQL', 'aql' ], transforms: { to: settings?.transforms?.to || [], from: [