'checkbox', '#title' => $this->t('Bold Text'), '#default_value' => $paragraph->getBehaviorSetting($this->getPluginId(), 'bold_text', FALSE), '#description' => $this->t("Bold text for the paragraph."), ]; return $form; } /** * {@inheritdoc} */ public function view(array &$build, Paragraph $paragraphs_entity, EntityViewDisplayInterface $display, $view_mode) { if ($paragraphs_entity->getBehaviorSetting($this->getPluginId(), 'bold_text')) { $build['#attributes']['class'][] = 'bold_plugin_text'; $build['#attached']['library'][] = 'paragraphs_test/drupal.paragraphs_test.bold_text'; } } /** * {@inheritdoc} */ public static function isApplicable(ParagraphsType $paragraphs_type) { // If the name of the field is not text_paragraph_test then allow using this // plugin. if ($paragraphs_type->id() != 'text_paragraph_test') { return TRUE; } return FALSE; } /** * {@inheritdoc} */ public function settingsSummary(Paragraph $paragraph) { $bold_setting = $paragraph->getBehaviorSetting($this->getPluginId(), 'bold_text'); return [$bold_setting ? $this->t('Bold: Yes') : $this->t('Bold: No')]; } }