Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render Map blocks in editor #498

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mu-plugins/blocks/google-map-event-filters/src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@
"supports": {
"inserter": false
},
"editorScript": "file:./index.js",
"style": "file:./style.css"
"editorScript": "file:./index.js"
}
17 changes: 8 additions & 9 deletions mu-plugins/blocks/google-map-event-filters/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { Placeholder } from '@wordpress/components';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';

/**
* Internal dependencies
Expand All @@ -12,13 +11,13 @@ import metadata from './block.json';

function Edit() {
return (
<Placeholder
instructions={ __(
'This is a placeholder for the editor until a back-end UI is built. See the README for instructions on supplying data.',
'wporg'
) }
label={ __( 'Google Map Event Filters', 'wporg' ) }
/>
<div { ...useBlockProps() }>
<InnerBlocks
allowedBlocks={ [ 'wporg/google-map' ] }
template={ [ [ 'wporg/google-map' ] ] }
templateLock="all"
/>
</div>
);
}

Expand Down
9 changes: 9 additions & 0 deletions mu-plugins/blocks/google-map/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ function render( $attributes, $content, $block ) {
'before'
);

wp_add_inline_script(
$block->block_type->editor_script_handles[0],
sprintf(
'const wporgGoogleMap = %s;',
wp_json_encode( $attributes )
),
'before'
);

$wrapper_attributes = get_block_wrapper_attributes( array( 'id' => $attributes['id'] ) );

ob_start();
Expand Down
1 change: 1 addition & 0 deletions mu-plugins/blocks/google-map/src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"inserter": false
},
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"viewScript": "file:./front.js",
"style": "file:./style.css"
}
16 changes: 7 additions & 9 deletions mu-plugins/blocks/google-map/src/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
/* global wporgGoogleMap */

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { Placeholder } from '@wordpress/components';
import { useBlockProps } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import metadata from './block.json';
import Main from './components/main';

function Edit() {
return (
<Placeholder
instructions={ __(
'This is a placeholder for the editor. Data is supplied to this block via the pattern that includes it.',
'wporg'
) }
label={ __( 'WordPress.org Google Map', 'wporg' ) }
/>
<div { ...useBlockProps() }>
<Main { ...wporgGoogleMap } />
</div>
);
}

Expand Down
Loading