Skip to content

Commit

Permalink
fix Block
Browse files Browse the repository at this point in the history
  • Loading branch information
nextgenthemes committed Jan 8, 2025
1 parent 6f94131 commit 6dc433b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 42 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* [ARVE Pro changelog](https://nextgenthemes.com/plugins/arve-pro/#changelog)
* [ARVE Random Videos changelog](https://nextgenthemes.com/plugins/arve-random-video/#changelog)

### 2024-01-08 10.5.2 ###

* Fix: Block errors.

### 2024-01-02 10.5.1 ###

* Fix: Array merge with NULL error.
Expand Down
18 changes: 9 additions & 9 deletions src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"type": "boolean"
},
"controls": {
"type": "boolean"
"type": "string"
},
"title": {
"type": "string"
Expand All @@ -74,10 +74,10 @@
"type": "string"
},
"hide_title": {
"type": "boolean"
"type": "string"
},
"grow": {
"type": "boolean"
"type": "string"
},
"fullscreen": {
"type": "string"
Expand All @@ -89,28 +89,28 @@
"type": "string"
},
"disable_links": {
"type": "boolean"
"type": "string"
},
"align": {
"type": "string"
},
"arve_link": {
"type": "boolean"
"type": "string"
},
"duration": {
"type": "string"
},
"autoplay": {
"type": "boolean"
"type": "string"
},
"lightbox_maxwidth": {
"type": "integer"
},
"sticky": {
"type": "boolean"
"type": "string"
},
"sticky_on_mobile": {
"type": "boolean"
"type": "string"
},
"sticky_position": {
"type": "string"
Expand Down Expand Up @@ -143,7 +143,7 @@
"type": "string"
},
"invidious": {
"type": "boolean"
"type": "string"
},
"thumbnail_url": {
"type": "string"
Expand Down
45 changes: 15 additions & 30 deletions src/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface SelectOption {

interface OptionProps {
label: string;
tag: string;
tab: string;
type: string;
description?: string;
descriptionlink?: string;
Expand All @@ -78,22 +78,20 @@ delete settings?.align?.options?.center;
const domParser = new DOMParser();

/**
* Keypair to gutenberg component
* Keypair to Gutenberg component
* @param selectOptions
*/
function PrepareSelectOptions( selectOptions: OptionProps ) {
const gboptions = [] as Array< SelectOption >;

Object.entries( selectOptions ).forEach( ( [ key, value ] ) => {
const o: SelectOption = {
label: value,
value: key,
};

gboptions.push( o );
} );
function PrepareSelectOptions(
selectOptions: Record< string, string > | undefined
): Array< SelectOption > {
if ( ! selectOptions ) {
throw new Error( 'no options' );
}

return gboptions;
return Object.entries( selectOptions ).map( ( [ key, value ] ) => ( {
label: value,
value: key,
} ) );
}

function changeTextControl( key: string, value: string, props ) {
Expand Down Expand Up @@ -122,17 +120,6 @@ function changeTextControl( key: string, value: string, props ) {
} );
}

// function changeSelectControl( key: string, value: string, props ) {

// if ( ! value ) {

// }

// props.setAttributes( {
// [ key ]: value,
// } );
// }

const mediaUploadRender = ( open: VoidFunction, val, url: string ): JSX.Element => {
return (
<div className="editor-post-featured-image__container">
Expand Down Expand Up @@ -169,8 +156,6 @@ const mediaUploadRender = ( open: VoidFunction, val, url: string ): JSX.Element
);
};

function select( val );

function buildControls( props ) {
const controls = [] as Array< JSX.Element >;
const sectionControls = {} as sectionControls;
Expand All @@ -180,14 +165,14 @@ function buildControls( props ) {
let selectedMedia;

Object.values( settings ).forEach( ( option: OptionProps ) => {
sectionControls[ option.tag ] = [];
sectionControls[ option.tab ] = [];
} );

Object.entries( settings ).forEach( ( [ key, option ]: [ string, OptionProps ] ) => {
const val = props.attributes[ key ];
const url = '';

sectionControls[ option.tag ].push(
sectionControls[ option.tab ].push(
<Fragment key={ key + '-fragment' }>
{ 'select' === option.ui_element && (
<SelectControl
Expand All @@ -197,7 +182,7 @@ function buildControls( props ) {
options={ PrepareSelectOptions( option.options ) }
onChange={ ( value ) => {
return props.setAttributes( {
[ key ]: value,
[ key ]: '' === value ? undefined : value,
} );
} }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ public function bool_option_to_select(): void {
throw new \InvalidArgumentException( esc_html( 'Property ' . $this->option_key . ' must be boolean' ) );
}

$this->type = 'string';
$this->ui_element = 'select';
$this->ui_element_type = 'select';
$this->options = array(
'' => \__( 'Default', 'advanced-responsive-video-embedder' ),
'true' => \__( 'True', 'advanced-responsive-video-embedder' ),
'false' => \__( 'False', 'advanced-responsive-video-embedder' ),
'' => __( 'Default', 'advanced-responsive-video-embedder' ),
'true' => __( 'True', 'advanced-responsive-video-embedder' ),
'false' => __( 'False', 'advanced-responsive-video-embedder' ),
);
}

Expand Down

0 comments on commit 6dc433b

Please sign in to comment.