diff --git a/README.md b/README.md index ac525c3d2bef71187f31a289b2880acce4938759..809aa19fe253a18e748950367d23560a96c69581 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,11 @@ Contributed Modules - **[Duration](https://www.drupal.org/project/duration_field)** Sets duration granularity to hours and minutes. -- **[Entity Browser](https://www.drupal.org/project/content_browser)** - Uses the content browser for node entity references. +- **[Entity Browser](https://www.drupal.org/project/entity_browser)** + Uses the content browser for node entity references. + Looks for either the content_browse.module (via browse_content) or + Entity type specific browsers using `{entity_type_id}_browser` + (i.e., node_browser, media_browser, etc...) entity browsers. - **[Focal Point](https://www.drupal.org/project/focal_point)** Ensures that existing entity image fields use focal point. - **[Linkit](https://www.drupal.org/project/linkit)** diff --git a/composer.json b/composer.json index 7ca9856d2edf413778a097a018902924d166cfe6..3cd39f4e5162b9383cc942feacc6645f3f64aa3a 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ "drupal/cer": "^5.0", "drupal/ckeditor5_embedded_content": "^1.0", "drupal/config_rewrite": "^1.0", - "drupal/content_browser": "^1.0", "drupal/content_model_documentation": "^1.0", "drupal/custom_field": "^3.0", "drupal/devel": "^5.0", diff --git a/composer.libraries.json b/composer.libraries.json index a86a5737563c2a191d359b841bbbf3c60375ffd8..8f483701d21ee2a9955c87ae2de85311727d0f36 100644 --- a/composer.libraries.json +++ b/composer.libraries.json @@ -23,7 +23,6 @@ "drupal/auto_entitylabel": "^3.0", "drupal/cer": "^5.0", "drupal/config_rewrite": "^1.0", - "drupal/content_browser": "^1.0", "drupal/content_model_documentation": "^1.0", "drupal/custom_field": "^3.0", "drupal/embed": "^1.0", @@ -75,7 +74,10 @@ "Issue #3265084: EntityReferenceRevisionsItem:generateSampleValue can break when all bundle types are allowed": "https://www.drupal.org/files/issues/2022-02-18/treat-no-selection-as-all-3265084-2.patch" }, "drupal/entity_browser": { - "Issue #2914385: Warning: key() expects parameter 1 to be array, null given in Drupal\\entity_browser\\Plugin\\Field\\FieldWidget\\EntityReferenceBrowserWidget::processEntityBrowser()": "https://www.drupal.org/files/issues/2024-06-12/2914385-35.patch" + "Issue #2914385: Warning: key() expects parameter 1 to be array, null given in Drupal\\entity_browser\\Plugin\\Field\\FieldWidget\\EntityReferenceBrowserWidget::processEntityBrowser()": "https://www.drupal.org/files/issues/2024-06-12/2914385-35.patch", + "Issue #3012432: Broken views exposed form in modals": "https://www.drupal.org/files/issues/2020-04-29/3012432-4_remove_enctype_on_views_widget.patch", + "Issue #3130748: Exposed filter's JS events not attached on initial load": "https://www.drupal.org/files/issues/2022-12-07/entity_browser-3130748-3.patch", + "Issue #2946829: Make submit button on modal always visible": "https://www.drupal.org/files/issues/2020-10-19/2946829-submit-button-always-visible-on-modals-4.patch" }, "drupal/config_views": { "Issue #3378687: Dynamic property issue in ConfigEntityQuery with PHP 8.2": "https://www.drupal.org/files/issues/2023-08-02/config_views-fix-dynamic-property-3378687-2.patch" @@ -83,7 +85,8 @@ "drupal/mercury_editor": { "Issue #3468130: Allow query string parameters to be passed to node form to mercury editor": "https://www.drupal.org/files/issues/2024-08-27/mercury_editor-issue-3468130-comment-6.patch", "Issue #3468531: Allow fields that do not start with 'field_' to be included the edit component 'Content' tab": "https://www.drupal.org/files/issues/2024-08-16/mercury_editor-issues-3468531-comment-3.patch", - "Issue #3468995: Hide 'Layout' tab when there is only one available layout for a component": "https://www.drupal.org/files/issues/2024-08-19/mercury_editor-issue-3468995-comment-3.patch" + "Issue #3468995: Hide 'Layout' tab when there is only one available layout for a component": "https://www.drupal.org/files/issues/2024-08-19/mercury_editor-issue-3468995-comment-3.patch", + "Issue #3405289: Entity browser JS error on submit selection": "https://www.drupal.org/files/issues/2023-11-30/3405289.patch" }, "drupal/type_tray": { "Issue #3417679: Add type tray icon to node edit and related tasks": "https://www.drupal.org/files/issues/2024-01-28/issue-3417679-mr-22.patch" diff --git a/js/schemadotorg.mermaid.js b/js/schemadotorg.mermaid.js index 300a2c760c0fa0f14cc4b868890873264cce07e7..9d8ca4a19a6c5e7210186cc9bc0e374ad32490d5 100644 --- a/js/schemadotorg.mermaid.js +++ b/js/schemadotorg.mermaid.js @@ -37,7 +37,7 @@ querySelector: '.mermaid, .language-mermaid', postRenderCallback: () => { // Use set timeout to delay closing details until all diagrams are rendered. - window.setTimeout(function () { + window.setTimeout(function closeDetails() { if (closedDetails) { closedDetails.forEach((element) => element.removeAttribute('open'), diff --git a/modules/schemadotorg_inline_entity_form/src/SchemaDotOrgInlineEntityFormManager.php b/modules/schemadotorg_inline_entity_form/src/SchemaDotOrgInlineEntityFormManager.php index a531de8db505386d9d091045165c7b83bf3d9dc1..9d10bddab9577034d48dac051750c3cba3ea89b1 100644 --- a/modules/schemadotorg_inline_entity_form/src/SchemaDotOrgInlineEntityFormManager.php +++ b/modules/schemadotorg_inline_entity_form/src/SchemaDotOrgInlineEntityFormManager.php @@ -139,7 +139,8 @@ class SchemaDotOrgInlineEntityFormManager implements SchemaDotOrgInlineEntityFor return; } - if (empty($widget_id)) { + // @see entity_browser_schemadotorg_property_field_alter() + if (empty($widget_id) || $widget_id === 'entity_browser_entity_reference') { $widget_id = 'inline_entity_form_complex'; $widget_settings = [ 'allow_existing' => TRUE, @@ -157,11 +158,19 @@ class SchemaDotOrgInlineEntityFormManager implements SchemaDotOrgInlineEntityFor $widget_settings['form_mode'] = 'inline_entity_form'; } - // If the 'content browser' module is installed, use it. - if ($this->moduleHandler->moduleExists('content_browser')) { + // If '{entity_type_id}_browser' entity or 'content browser' module + // exists, use it. + $entity_browser_storage = $this->entityTypeManager + ->getStorage('entity_browser'); + $target_type = $field_storage_values['settings']['target_type']; + $entity_browser = $entity_browser_storage->load($target_type . '_browser'); + if (!$entity_browser && $target_type === 'node') { + $entity_browser = $entity_browser_storage->load('browse_content'); + } + if ($entity_browser) { $widget_settings['third_party_settings'] = [ 'entity_browser_entity_form' => [ - 'entity_browser_id' => 'browse_content', + 'entity_browser_id' => $entity_browser->id(), ], ]; } diff --git a/modules/schemadotorg_inline_entity_form/tests/src/Kernel/SchemaDotOrgInlineEntityFormKernelTest.php b/modules/schemadotorg_inline_entity_form/tests/src/Kernel/SchemaDotOrgInlineEntityFormKernelTest.php index 05e03a1fcfa838a3c31401886de83e6117a54cd1..9ed63c8409be689a589d10c630d3b979224a7ceb 100644 --- a/modules/schemadotorg_inline_entity_form/tests/src/Kernel/SchemaDotOrgInlineEntityFormKernelTest.php +++ b/modules/schemadotorg_inline_entity_form/tests/src/Kernel/SchemaDotOrgInlineEntityFormKernelTest.php @@ -30,6 +30,7 @@ class SchemaDotOrgInlineEntityFormKernelTest extends SchemaDotOrgEntityKernelTes */ protected static $modules = [ 'inline_entity_form', + 'entity_browser', 'schemadotorg_inline_entity_form', ]; @@ -53,6 +54,19 @@ class SchemaDotOrgInlineEntityFormKernelTest extends SchemaDotOrgEntityKernelTes ->clear('schema_properties.default_fields.alumniOf.type') ->save(); + $this->installConfig('entity_browser'); + + \Drupal::entityTypeManager() + ->getStorage('entity_browser') + ->create([ + 'name' => 'browse_content', + 'label' => 'browse_content', + 'display' => 'modal', + 'selection_display' => 'no_display', + 'widget_selector' => 'tabs', + ]) + ->save(); + $this->entityDisplayRepository = $this->container->get('entity_display.repository'); } diff --git a/schemadotorg.schemadotorg.inc b/schemadotorg.schemadotorg.inc index 80c061479d0a189e3079cb47f064ffb824e568b3..ec14dab72aa0a45bbd18e736fc51b6b810d65927 100644 --- a/schemadotorg.schemadotorg.inc +++ b/schemadotorg.schemadotorg.inc @@ -33,7 +33,7 @@ function duration_field_schemadotorg_jsonld_schema_property_alter(mixed &$value, /* ************************************************************************** */ /** - * Implements hook_schemadotorg_property_field_alter() for the content_browser.module. + * Implements hook_schemadotorg_property_field_alter() for the entity_browser.module. */ function entity_browser_schemadotorg_property_field_alter( string $schema_type, @@ -52,14 +52,20 @@ function entity_browser_schemadotorg_property_field_alter( // Use the content browser for node entity references. if (empty($widget_id)) { - $nas_browse_content = (bool) \Drupal::entityTypeManager() - ->getStorage('entity_browser') - ->load('browse_content'); + $entity_browser_storage = \Drupal::entityTypeManager() + ->getStorage('entity_browser'); $target_type = $field_storage_values['settings']['target_type']; - if ($nas_browse_content && $target_type === 'node') { + $entity_browser = $entity_browser_storage->load($target_type . '_browser'); + // Support the content_browser.module by looking for the 'browse_content' + // entity browser. + if (!$entity_browser && $target_type === 'node') { + $entity_browser = $entity_browser_storage->load('browse_content'); + } + + if ($entity_browser) { $widget_id = 'entity_browser_entity_reference'; $widget_settings = [ - 'entity_browser' => 'browse_content', + 'entity_browser' => $entity_browser->id(), 'field_widget_display' => 'label', 'field_widget_edit' => TRUE, 'field_widget_remove' => TRUE,