From d402145d1f25ac366658151d28a4bc8ae72fecd2 Mon Sep 17 00:00:00 2001 From: Vasile Chindris Date: Tue, 16 Apr 2024 08:57:08 +0300 Subject: [PATCH] feat(SLB-308 SLB-313): move the url field in the sidebar --- .../gutenberg_blocks/src/blocks/cta.tsx | 114 +++++++++--------- 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/packages/drupal/gutenberg_blocks/src/blocks/cta.tsx b/packages/drupal/gutenberg_blocks/src/blocks/cta.tsx index ed98d4d0c..c0bbaacdc 100644 --- a/packages/drupal/gutenberg_blocks/src/blocks/cta.tsx +++ b/packages/drupal/gutenberg_blocks/src/blocks/cta.tsx @@ -1,10 +1,11 @@ import { // @ts-ignore __experimentalLinkControl as LinkControl, + InspectorControls, RichText, } from 'wordpress__block-editor'; import { registerBlockType } from 'wordpress__blocks'; -import { ToggleControl } from 'wordpress__components'; +import { PanelBody, ToggleControl } from 'wordpress__components'; import { compose, withState } from 'wordpress__compose'; // @ts-ignore @@ -58,60 +59,65 @@ registerBlockType('custom/cta', { setPlainTextAttribute(props, 'text', text); }} /> - + + { - props.setAttributes({ - url: link.url, - 'data-id': link.id, - 'data-entity-type': - // At the moment, the silverback_gutenberg link autocomplete - // controller does not return the machine name of the entity - // type. Instead, it returns the human readable, translated, - // entity type label. We should refactor the LinkAutocomplete - // controller to return the machine name of the entity type, and - // then we can set the data-entity-type value more accurate. - // Right now, we just make a "guess" based on the the human - // readable label for English and German. - link.type.startsWith('Media') || link.type.startsWith('Medien') - ? 'media' - : link.type !== 'URL' - ? 'node' - : '', - }); - }} - /> - { - props.setAttributes({ - openInNewTab, - }); - }} - /> + //suggestionsQuery={{ + // type: 'post', + // subtype: 'gutenberg', + //}} + // @ts-ignore + onChange={(link) => { + props.setAttributes({ + url: link.url, + 'data-id': link.id, + 'data-entity-type': + // At the moment, the silverback_gutenberg link autocomplete + // controller does not return the machine name of the entity + // type. Instead, it returns the human readable, translated, + // entity type label. We should refactor the LinkAutocomplete + // controller to return the machine name of the entity type, and + // then we can set the data-entity-type value more accurate. + // Right now, we just make a "guess" based on the the human + // readable label for English and German. + link.type.startsWith('Media') || + link.type.startsWith('Medien') + ? 'media' + : link.type !== 'URL' + ? 'node' + : '', + }); + }} + /> + { + props.setAttributes({ + openInNewTab, + }); + }} + /> + + ); }),