Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ebba7b4
Add interactivity runtime
luisherranz Apr 21, 2023
af59781
Add it to the image block
luisherranz Apr 21, 2023
cca3d60
Add a separate webpack config
luisherranz Apr 21, 2023
160a029
Make sure the runtime is imported only once
luisherranz Apr 21, 2023
7f16f27
Use sideEffects instead of init
luisherranz Apr 21, 2023
f4b2ee8
Move script registration to a general file
luisherranz Apr 21, 2023
378b041
Add `defer` to the interactivity scripts
luisherranz Apr 21, 2023
409d161
Revert changes of the image block
luisherranz Apr 21, 2023
29e11ab
Fix init import name
luisherranz Apr 21, 2023
f4b6c0a
Move and refactor the interactive scritps registration
gziolo Apr 28, 2023
3d94473
Fix code style violations
gziolo Apr 28, 2023
6ae760f
Use `wp-interactivity-` prefix for script handles
gziolo Apr 28, 2023
9d6869e
Improve the matcher for side effects in `package.json`
gziolo Apr 28, 2023
c6d02d8
Add custom useSignalEffect
DAreRodz May 4, 2023
af55917
Call `init` after `store` has been initialized
DAreRodz May 4, 2023
7c1f2d1
Add lightbox to image block
artemiomorales Apr 3, 2023
9507199
Add logic for hiding lightbox on esc key press and overlay click
artemiomorales Apr 3, 2023
3f89d9b
Improve styles and add note to add conditional for lightbox markup
artemiomorales Apr 5, 2023
cb7f89a
Add editor UI and attribute for toggling lightbox
artemiomorales Apr 13, 2023
437d873
Remove image translation animation and add fade instead
artemiomorales Apr 19, 2023
7bd6b25
Add accessibility; clean up styles; fix bug regarding ref in directives
artemiomorales Apr 21, 2023
109344c
Configure image to use new Interactivity API runtime included in Gute…
artemiomorales Apr 26, 2023
f95a2cd
Remove viewScript from image config
artemiomorales Apr 26, 2023
e37e228
Add Portal directive to Interactivity API runtime
artemiomorales Apr 26, 2023
e17e564
Set scrim to site background color
artemiomorales Apr 26, 2023
f481a35
Remove extraneous image CSS declaration
artemiomorales Apr 26, 2023
848a8fa
Improve aria labeling
artemiomorales May 2, 2023
2204a50
Code cleanup; simplify syntax, consolidate code
artemiomorales May 3, 2023
6244e14
Refactor code, remove event listeners, consolidate logic
artemiomorales May 3, 2023
c388721
Fix formatting in SCSS file
artemiomorales May 3, 2023
9754edb
Change CheckboxControl to a ToggleControl; update API docs
artemiomorales May 3, 2023
b337272
Update wp_enqueue_script to correctly add interactivity runtime
artemiomorales May 3, 2023
ee679e6
Fix linter errors
artemiomorales May 4, 2023
ddbf32c
Update to use core.image namespace
artemiomorales May 4, 2023
f82d8f5
Pause closing of lightbox slightly when using the mousewheel
artemiomorales May 4, 2023
8ce00cd
Rename portal directive to 'wp-body' and remove unused reference
artemiomorales May 4, 2023
1427e8a
Add internal dependencies flag; update comment
artemiomorales May 4, 2023
58b0ef5
Remove extraneous code
artemiomorales May 4, 2023
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
Prev Previous commit
Next Next commit
Add it to the image block
This is still pretty basic, just to check that it works.

Co-authored-by: David Arenas <[email protected]>
  • Loading branch information
2 people authored and gziolo committed Apr 28, 2023
commit af59781fb1c2ba7729901806782fe5fbc4062203
3 changes: 2 additions & 1 deletion packages/block-library/src/image/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@
{ "name": "rounded", "label": "Rounded" }
],
"editorStyle": "wp-block-image-editor",
"style": "wp-block-image"
"style": "wp-block-image",
"viewScript": [ "file:./view.min.js" ]
}
7 changes: 6 additions & 1 deletion packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
function render_block_core_image( $attributes, $content ) {
$processor = new WP_HTML_Tag_Processor( $content );
$processor->next_tag( 'figure' );
$processor->set_attribute( 'data-wp-island', '' );
$processor->next_tag( 'img' );
$processor->set_attribute( 'data-wp-effect', 'effects.alert' );

if ( $processor->get_attribute( 'src' ) === null ) {
return '';
Expand All @@ -27,8 +30,10 @@ function render_block_core_image( $attributes, $content ) {
// which now wraps Image Blocks within innerBlocks.
// The data-id attribute is added in a core/gallery `render_block_data` hook.
$processor->set_attribute( 'data-id', $attributes['data-id'] );
$content = $processor->get_updated_html();
}

$content = $processor->get_updated_html();

return $content;
}

Expand Down
16 changes: 16 additions & 0 deletions packages/block-library/src/image/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Internal dependencies
*/
import { store } from '../utils/interactivity/store';
import init from '../utils/interactivity';

store( {
effects: {
alert: () => {
// eslint-disable-next-line no-console
console.log( 'image hydrated!' );
},
},
} );

init();
10 changes: 8 additions & 2 deletions packages/block-library/src/utils/interactivity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ import { init } from './hydration';
/**
* Initialize the Interactivity API.
*/
registerDirectives();
init();
export default () => {
window.addEventListener( 'DOMContentLoaded', () => {
registerDirectives();
init();
// eslint-disable-next-line no-console
console.log( 'hydrated!' );
} );
};