diff --git a/paragraphs.libraries.yml b/paragraphs.libraries.yml index bb2015d..11531c0 100644 --- a/paragraphs.libraries.yml +++ b/paragraphs.libraries.yml @@ -12,6 +12,21 @@ drupal.paragraphs.admin: theme: css/paragraphs.admin.css: {} +paragraphs.collapse: + version: 1.x + css: + theme: + css/paragraphs_collapse.css: {} + js: + js/paragraphs_collapse.js: {} + dependencies: + - core/drupalSettings + - core/jquery.once + - core/jquery + - core/jquery.form + - core/drupal.ajax + - core/drupal + drupal.paragraphs.widget: css: theme: diff --git a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php index c701e33..3dba72f 100644 --- a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php +++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php @@ -458,6 +458,11 @@ class InlineParagraphsWidget extends WidgetBase { '#value' => $this->t('Edit'), '#name' => strtr($id_prefix, '-', '_') . '_edit', '#weight' => 500, + '#attributes' => [ + 'class' => [ + 'paragraphs-collapsible-action-button', + ], + ], '#submit' => array(array(get_class($this), 'paragraphsItemSubmit')), '#limit_validation_errors' => array(array_merge($parents, array($field_name, 'add_more'))), '#delta' => $delta, @@ -519,25 +524,12 @@ class InlineParagraphsWidget extends WidgetBase { if ($show_links > 0) { + $element['top']['collapsible_button'] = [ + '#type' => 'paragraphs_collapse', + '#weight' => 1000, + ]; $element['top']['links'] = $links; - if ($show_links > 1) { - $element['top']['links']['#theme_wrappers'] = array('dropbutton_wrapper', 'paragraphs_dropbutton_wrapper'); - $element['top']['links']['prefix'] = array( - '#markup' => '