Problem/Motivation

In a larger effort to make Paragraphs UX better for end users and editors there is a need for a better browser but also allowing more inline insertion of a new paragraph. For example large articles with 10-20 paragraphs associated if a new paragraph needs to be added at delta 3 a user has to add to bottom of list and drag up sometimes awkwardly to the 3rd position.

Proposed resolution

Work has begun on adding "add" buttons between each existing paragraph that allows insertion of the paragraph between existing paragraphs in #2877927. This is dependent on some modal functionality being worked on within the core paragraphs module. A better solution might be building upon this to add the better UX functionality offered in Paragraphs Browser for powering this modal. On most cases sites that need insertion between Paragraphs also are going to have a larger number of paragraphs and benefit from the more user friendly UX of paragraphs browser.

Remaining tasks

  • MVP - Initiate paragraphs browser modal from between paragraphs buttons - DONE
  • MVP - When paragraph is added from browser insert into from - Not currently working
  • Cleanup ajax response commands
  • Consider future uses or extending

Steps to Reproduce

- Setup D8 site with patch from comment 4 in #2877927 added to paragraphs module.
- Apply patch from this issue to paragraphs_browser
- Edit form display for paragraphs browser and save
- See add buttons between paragraphs but upon adding see that the paragraphs do not add from either new add buttons or the existing Add Paragraph button provided by Paragraphs Browser module
- Change "add_mode" setting from modal back to "paragraphs_browser". Save form display again and reload. See add buttons no longer show but the Add Paragraph default from Paragraphs browser showing.

    $elements['add_mode'] = array(
      '#type' => 'hidden',
      '#value' => 'modal',
    );

Comments

kbasarab created an issue. See original summary.

kbasarab’s picture

Issue summary: View changes
StatusFileSize
new3.81 KB
kbasarab’s picture

Here's an updated patch that provides a working proof of concept. There are quite a few todo's that should be addressed though:

  • Possibly limit turning add between paragraphs on and off via field setting
  • CSS Cleanup. CSS currently does not look quite right
  • See if we can shorten the addMoreSubmit method and leverage more from parent class

This no longer depends on the paragraphs issue either.

samuel.seide’s picture

I've updated the patch with styling for both the buttons on hover and also some basic styling for the modal to make it look a little more cleaned up. For the styling for the buttons on hover, I made the first button smaller than the full 100% width so it wouldn't overlap the page elements or operations text above the first paragraph. The other buttons are 100% width of the area.

kbasarab’s picture

Previous patch did not apply cleanly due to info.yml issues. Here's a new version.

damienmckenna’s picture

Status: Active » Needs review
mpriscella’s picture

Previous patch had conflicts with newest released version of the module - here's a new version with resolved conflicts.

Anonymous’s picture

Hello,
I would like to have multiple add or a functionnal 'add above' button with the latest version of paragraphs & paragraphs_browser.
I tried multiple patches from #2877927 and the latest patch from here (with some modifications to make it compatible with the new version of paragraphs_browser).
Unfortunately, I have not yet managed to get something functional.
For exemple with this latest patch, I have buttons & browser but the paragraphs are added all the time at the end.
As soon as I correct a problem, another appears and I end up going around in circles, it's depressing.
Does anyone have a solution, a lead or even a patch?
Thanks a lot,

stevenx’s picture

If someone stumbles across this issue.
I tried to apply the patches to current module version and it did not work.

So I searched for some other module and found this:
https://www.drupal.org/project/paragraphs_ee

It basically does the same thing and in between buttons work out of the box.