- foreach ($this->blockManager->getGroupedDefinitions($definitions) as $category => $blocks) {
- $build[$category]['#type'] = 'details';
- $build[$category]['#open'] = TRUE;
- $build[$category]['#title'] = $category;
- $build[$category]['links'] = [
- '#theme' => 'links',
- ];
- foreach ($blocks as $block_id => $block) {
- $link = [
- 'title' => $block['admin_label'],
- 'url' => Url::fromRoute('layout_builder.add_block',
- [
- 'section_storage_type' => $section_storage->getStorageType(),
- 'section_storage' => $section_storage->getStorageId(),
- 'delta' => $delta,
- 'region' => $region,
- 'plugin_id' => $block_id,
- ]
- ),
- ];
- if ($this->isAjax()) {
- $link['attributes']['class'][] = 'use-ajax';
- $link['attributes']['data-dialog-type'][] = 'dialog';
- $link['attributes']['data-dialog-renderer'][] = 'off_canvas';
- }
- $build[$category]['links']['#links'][] = $link;
+ $grouped_definitions = $this->blockManager->getGroupedDefinitions($definitions);
+ foreach ($grouped_definitions as $category => $blocks) {
+ $block_categories[$category]['#type'] = 'details';
+ $block_categories[$category]['#open'] = TRUE;
+ $block_categories[$category]['#title'] = $category;
+ $block_categories[$category]['links'] = $this->getBlockLinks($section_storage, $delta, $region, $blocks);
+ }
+ $build['block_categories'] = $block_categories;
+ return $build;
+ }
+
+ /**
+ * Provides the UI for choosing a new inline block.
+ *
+ * @param \Drupal\layout_builder\SectionStorageInterface $section_storage
+ * The section storage.
+ * @param int $delta
+ * The delta of the section to splice.
+ * @param string $region
+ * The region the block is going in.
+ *
+ * @return array
+ * A render array.
+ */
+ public function inlineBlockList(SectionStorageInterface $section_storage, $delta, $region) {
+ $definitions = $this->blockManager->getFilteredDefinitions('layout_builder', $this->getAvailableContexts($section_storage), [
+ 'section_storage' => $section_storage,
+ 'region' => $region,
+ 'list' => 'inline_blocks',
+ ]);
+ $blocks = $this->blockManager->getGroupedDefinitions($definitions);
+ $build = [];
+ if (isset($blocks['Inline blocks'])) {
+ $build['links'] = $this->getBlockLinks($section_storage, $delta, $region, $blocks['Inline blocks']);
+ $build['links']['#attributes']['class'][] = 'inline-block-list';
+ foreach ($build['links']['#links'] as &$link) {
+ $link['attributes']['class'][] = 'inline-block-list__item';