-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/release' into SLB-287-background…
…-image-cards
- Loading branch information
Showing
19 changed files
with
287 additions
and
63 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
1 change: 0 additions & 1 deletion
1
packages/drupal/gutenberg_blocks/gutenberg_blocks.libraries.yml
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
edit: | ||
version: VERSION | ||
js: | ||
js/gutenberg_blocks.umd.js: {} | ||
css: | ||
|
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,128 @@ | ||
import { | ||
// @ts-ignore | ||
__experimentalLinkControl as LinkControl, | ||
InspectorControls, | ||
RichText, | ||
} from 'wordpress__block-editor'; | ||
import { registerBlockType } from 'wordpress__blocks'; | ||
import { PanelBody, ToggleControl } from 'wordpress__components'; | ||
import { compose, withState } from 'wordpress__compose'; | ||
|
||
// @ts-ignore | ||
const { t: __ } = Drupal; | ||
|
||
// @ts-ignore | ||
const { setPlainTextAttribute } = silverbackGutenbergUtils; | ||
|
||
// @ts-ignore | ||
registerBlockType('custom/cta', { | ||
title: 'CTA', | ||
icon: 'admin-links', | ||
category: 'common', | ||
attributes: { | ||
url: { | ||
type: 'string', | ||
}, | ||
text: { | ||
type: 'string', | ||
}, | ||
// To have an easier integration with entity usage, we also retrieve and | ||
// store the uuid (data-id) and the entity type of internal links. | ||
'data-id': { | ||
type: 'string', | ||
}, | ||
'data-entity-type': { | ||
type: 'string', | ||
}, | ||
openInNewTab: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
// @ts-ignore | ||
edit: compose(withState({}))((props) => { | ||
return ( | ||
<div> | ||
<RichText | ||
identifier="text" | ||
className={`button`} | ||
tagName="p" | ||
value={props.attributes.text} | ||
allowedFormats={[]} | ||
// @ts-ignore | ||
disableLineBreaks={true} | ||
placeholder={__('Link text')} | ||
keepPlaceholderOnFocus={true} | ||
style={{ | ||
cursor: 'text', | ||
}} | ||
onChange={(text: string) => { | ||
setPlainTextAttribute(props, 'text', text); | ||
}} | ||
/> | ||
<InspectorControls> | ||
<PanelBody title={__('CTA Link')}> | ||
<LinkControl | ||
value={{ | ||
url: props.attributes.url, | ||
openInNewTab: props.attributes.openInNewTab, | ||
}} | ||
settings={{}} | ||
// If you want to use a specific linkit profile for the suggestions, | ||
// then you can do that by using the 'suggestionsQuery' property, like | ||
// the one bellow, and change the 'subtype' property to the machine | ||
// name of the linkit profile. By default, the 'gutenberg' profile | ||
// is used. Of course, in this case, if the linkit profile can search | ||
// through multiple entity types, then you'll have to set the value | ||
// for 'data-entity-type' in the onChange() handler by yourself. | ||
|
||
//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' | ||
: '', | ||
}); | ||
}} | ||
/> | ||
<ToggleControl | ||
label={__('Open in new tab')} | ||
help={ | ||
props.attributes.openInNewTab | ||
? __('Opens in a new tab.') | ||
: __('Opens in the same tab.') | ||
} | ||
checked={props.attributes.openInNewTab} | ||
onChange={(openInNewTab) => { | ||
props.setAttributes({ | ||
openInNewTab, | ||
}); | ||
}} | ||
/> | ||
</PanelBody> | ||
</InspectorControls> | ||
</div> | ||
); | ||
}), | ||
|
||
save: () => { | ||
return null; | ||
}, | ||
}); |
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 |
---|---|---|
|
@@ -219,4 +219,4 @@ access: | |
users: { } | ||
permissions: { } | ||
handlers: { } | ||
variants: { } | ||
variants: { } |
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,5 @@ | ||
fragment BlockCta on BlockCta { | ||
url | ||
text | ||
openInNewTab | ||
} |
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
7 changes: 7 additions & 0 deletions
7
packages/ui/src/components/Organisms/PageContent/BlockCta.tsx
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,7 @@ | ||
import { BlockCtaFragment } from '@custom/schema'; | ||
import React from 'react'; | ||
|
||
export function BlockCta(props: BlockCtaFragment) { | ||
console.log(props); | ||
return <div />; | ||
} |
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
Oops, something went wrong.