diff --git a/.distignore b/.distignore index 16cd3c9e4c..08643a97c8 100644 --- a/.distignore +++ b/.distignore @@ -2,6 +2,8 @@ node_modules/ assets/src/blocks assets/src/css assets/src/js +# Core layer types ship from assets/build/layers (layer.json, PHP and built scripts). +assets/src/layers assets/src/libs/jquery-ui-1.14.2.draggable .browserslistrc .eslintignore @@ -45,3 +47,6 @@ phpunit.xml.dist # Dashboard widget sample data: development and review only, never shipped. /inc/classes/class-dashboard-widget-preview.php + +# Design docs and RFCs: for contributors, not shipped. +/docs/ diff --git a/.eslintrc b/.eslintrc index 428a0e1c8b..d610c35ada 100755 --- a/.eslintrc +++ b/.eslintrc @@ -8,6 +8,10 @@ "env": { "browser": true }, + "settings": { + // Provided at runtime by the `godam-layers` script (a webpack external). + "import/core-modules": [ "@godam/layers" ] + }, "rules": { "jsdoc/check-indentation": "error", "@wordpress/dependency-group": "error" diff --git a/assets/src/blocks/godam-image/render.php b/assets/src/blocks/godam-image/render.php index 34a0db961f..ad0235d8cc 100644 --- a/assets/src/blocks/godam-image/render.php +++ b/assets/src/blocks/godam-image/render.php @@ -12,6 +12,8 @@ * @var array $attributes Block attributes. */ +use RTGODAM\Inc\Layers\Layer_Type_Registry; + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -73,16 +75,9 @@ $godam_meta = get_post_meta( $godam_attachment_id, 'rtgodam_meta', true ); $godam_all_layers = ( is_array( $godam_meta ) && ! empty( $godam_meta['layers'] ) ) ? $godam_meta['layers'] : array(); do_action( 'rtgodam_after_attachment_lookup' ); - foreach ( $godam_all_layers as $godam_layer ) { - if ( ! is_array( $godam_layer ) || empty( $godam_layer['type'] ) ) { - continue; - } - if ( 'hotspot' === $godam_layer['type'] && ! empty( $godam_layer['hotspots'] ) ) { - $godam_layers[] = $godam_layer; - } elseif ( 'woo' === $godam_layer['type'] && ! empty( $godam_layer['productHotspots'] ) ) { - $godam_layers[] = $godam_layer; - } - } + // Layers of types that support images and have something to draw + // (`supports.media` and `should_render` in the layer type registry). + $godam_layers = Layer_Type_Registry::get_instance()->filter_layers_for_media( $godam_all_layers, 'image' ); } // A hotspot link becomes the `href` of a link on the front end, so only http, https diff --git a/assets/src/js/godam-image-layers/render-image-frame.js b/assets/src/js/godam-image-layers/render-image-frame.js index 08ca3262ca..c5b746b8df 100644 --- a/assets/src/js/godam-image-layers/render-image-frame.js +++ b/assets/src/js/godam-image-layers/render-image-frame.js @@ -1,17 +1,16 @@ /** * GoDAM Image Layers — shared frame renderer. * - * Draws hotspot and WooCommerce product-hotspot layers onto a single - * `.godam-image__frame` element. Extracted so it can be reused by both the + * Draws the saved layers of one `.godam-image__frame` element. Used by both the * front-end bootstrap (frontend.js) and the block editor preview (the * `godam/image` block's edit.js), which renders the same markup into the * editor canvas and calls this against a ref. * - * It reuses the existing player-side managers unchanged except for a single - * seam: `manager.computeContentRect` is overridden with an image-box - * implementation (the managers' own version reads a `