protonsystems / paragraph-info
Reusable Drupal 11 module exposing stable paragraph anchor IDs and a permission-gated paragraph info overlay.
Package info
gitlab.com/Proton.Systems/drupal/paragraph-info
Type:drupal-module
pkg:composer/protonsystems/paragraph-info
Requires
- php: ^8.3
- drupal/core: ^11
- drupal/paragraphs: ^1.23
README
This repository contains a reusable Drupal 11 module for exposing stable paragraph anchor IDs and, for permitted users, a toggleable paragraph info overlay.
Purpose
The module is intended to be reused across Drupal 11 projects by installing it as a Composer package and enabling it in the target site.
Requirements
- Drupal 11
- Paragraphs
Features
- Generates a canonical anchor for every rendered paragraph using:
paragraph-{bundle}-{id} - Exposes an opt-in paragraph info label for themes to render for users with
the
view paragraph infopermission - Adds a frontend toggle on non-admin pages
- Persists the toggle state in browser
localStorage
Example anchor:
#paragraph-text-42
Structure
paragraph_info.modulecontains the theme, page, and preprocess hooks.src/contains the markup builder service.templates/contains the label and toggle Twig templates.css/andjs/contain the frontend toggle behavior.
Installation
composer require protonsystems/paragraph-info
Then enable the module in Drupal:
drush en paragraph_info
Grant the View paragraph info permission to the desired roles, then
rebuild caches.
Theme Integration
Use the paragraph_info_anchor_id variable in paragraph templates for the
wrapper id, and render paragraph_info_label where the info label should
appear.
Example:
<div id="{{ paragraph_info_anchor_id }}">
{{ paragraph_info_label }}
</div>
The module no longer prepends the label to every paragraph automatically.
Labels only render where the paragraph template explicitly outputs
paragraph_info_label.
If a project already has theme-specific paragraph info labels or toggles, remove them to avoid duplicate UI.
Notes
The module currently uses Drupal core services directly and is designed to be consumed as a standard Drupal module package.