diff --git a/core/modules/outside_in/js/outside_in.js b/core/modules/outside_in/js/outside_in.js index c038cd2..61ad096 100644 --- a/core/modules/outside_in/js/outside_in.js +++ b/core/modules/outside_in/js/outside_in.js @@ -12,6 +12,7 @@ var itemsToToggleSelector = '[data-offcanvas-main-canvas], #toolbar-bar, [data-drupal-outsidein="editable"] a, [data-drupal-outsidein="editable"] button'; var contextualItemsSelector = '[data-contextual-id] a, [data-contextual-id] button'; var quickEditItemSelector = '[data-quickedit-entity-id]'; + var excludedLinksSelector = '[data-outside-in-exclude] [data-outside-in-edit]'; /** * Reacts to contextual links being added. @@ -24,6 +25,9 @@ * @listens event:drupalContextualLinkAdded */ $(document).on('drupalContextualLinkAdded', function (event, data) { + // Remove contextual links that should be excluded. + // @see outside_in_block_view_alter(). + $(excludedLinksSelector).remove(); // Bind Ajax behaviors to all items showing the class. // @todo Fix contextual links to work with use-ajax links in // https://www.drupal.org/node/2764931. diff --git a/core/modules/outside_in/outside_in.module b/core/modules/outside_in/outside_in.module index 147b824..5b9a79a 100644 --- a/core/modules/outside_in/outside_in.module +++ b/core/modules/outside_in/outside_in.module @@ -34,11 +34,6 @@ function outside_in_help($route_name, RouteMatchInterface $route_match) { */ function outside_in_contextual_links_view_alter(&$element, $items) { if (isset($element['#links']['outside-inblock-configure'])) { - if (!empty($element['#contextual_links']['block']['metadata']['remove_outside_in'])) { - unset($element['#links']['outside-inblock-configure']); - unset($items['outside_in.block_configure']); - return; - } $element['#links']['outside-inblock-configure']['attributes'] = [ 'class' => ['use-ajax'], 'data-dialog-type' => 'dialog', @@ -61,9 +56,11 @@ function outside_in_block_view_alter(array &$build) { 'route_parameters' => [], ]; if (!\Drupal::service('outside_in.manager')->isBlockEditable($build['#plugin_id']) && isset($build['#contextual_links']['block'])) { - // If this block should not be editable flag for contextual link removable. + // If this block should not be editable set an attribute which will be used + // to remove the link on the client-side. // The individual links are not available here to remove. - $build['#contextual_links']['block']['metadata']['remove_outside_in'] = TRUE; + // @see outside_in.js + $build['#attributes']['data-outside-in-exclude'] = TRUE; } } diff --git a/core/modules/outside_in/src/OutsideInManager.php b/core/modules/outside_in/src/OutsideInManager.php index 6549e2a..26bda75 100644 --- a/core/modules/outside_in/src/OutsideInManager.php +++ b/core/modules/outside_in/src/OutsideInManager.php @@ -68,7 +68,7 @@ public function isApplicable() { */ public function isBlockEditable($plugin_id) { $non_editable_blocks = ['page_title_block', 'system_main_block']; - return !in_array($plugin_id, $non_editable_blocks); + return !in_array($plugin_id, $non_editable_blocks, TRUE); } } diff --git a/core/modules/outside_in/src/OutsideInManagerInterface.php b/core/modules/outside_in/src/OutsideInManagerInterface.php index 0cfc70c..054074e 100644 --- a/core/modules/outside_in/src/OutsideInManagerInterface.php +++ b/core/modules/outside_in/src/OutsideInManagerInterface.php @@ -16,13 +16,14 @@ public function isApplicable(); /** - * Checks whether a block should be covered by this module. + * Checks whether a block is editable by this module. * * @param string $plugin_id - * The plugin id for the block to check. + * The plugin ID for the block to check. * * @return bool - * TRUE if the block should the "Quick Edit" link provided by this module. + * TRUE if the block should have the "Quick Edit" link provided by this + * module. */ public function isBlockEditable($plugin_id);