Loading config/install/webform.settings.yml +2 −2 Original line number Diff line number Diff line Loading @@ -197,8 +197,8 @@ element: password_confirm: password_confirm html_editor: disabled: false element_format: webform mail_format: webform element_format: webform_default mail_format: webform_default tidy: true make_unused_managed_files_temporary: true file: Loading config/optional/editor.editor.webform.yml→config/optional/editor.editor.webform_default.yml +3 −2 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ langcode: en status: true dependencies: config: - filter.format.webform - filter.format.webform_default module: - ckeditor format: webform format: webform_default editor: ckeditor settings: toolbar: Loading @@ -23,6 +23,7 @@ settings: name: Media items: - SpecialChar - ImceImage - name: Linking items: Loading config/optional/filter.format.webform.yml→config/optional/filter.format.webform_default.yml +2 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,8 @@ status: true dependencies: module: - editor name: Webform format: webform name: 'Webform (Default)' format: webform_default weight: 100 roles: - authenticated Loading includes/webform.editor.inc +23 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,29 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Serialization\Yaml; use Drupal\webform\WebformInterface; use Drupal\Component\Utility\Html; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\webform\Element\WebformHtmlEditor; /** * Implements hook_ENTITY_TYPE_load(). */ function webform_filter_format_load($entities) { foreach ($entities as $entity) { if ($entity->id() === WebformHtmlEditor::DEFAULT_FILTER_FORMAT) { $route_name = \Drupal::routeMatch()->getRouteName(); $filter_format = \Drupal::routeMatch()->getParameter('filter_format'); if ($route_name === 'filter.admin_overview') { // Set status to FALSE which hides the default webform filter format. $entity->set('status', FALSE); } elseif ($filter_format === WebformHtmlEditor::DEFAULT_FILTER_FORMAT) { // Throw not found exception to prevent the default webform // filter format from being edited. throw new NotFoundHttpException(); } } } } /* ************************************************************************** */ // Webform entity hooks. Loading src/Element/WebformHtmlEditor.php +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ use Drupal\webform\Utility\WebformXss; */ class WebformHtmlEditor extends FormElement implements TrustedCallbackInterface { /** * Default webform filter format. */ const DEFAULT_FILTER_FORMAT = 'webform_default'; /** * {@inheritdoc} */ Loading Loading @@ -238,7 +243,7 @@ class WebformHtmlEditor extends FormElement implements TrustedCallbackInterface // has been customized with filter types, if has not been customized then // use the 'webform_html_editor_markup' template with the webform module's // allowed tags. if ($format === 'webform') { if ($format === static::DEFAULT_FILTER_FORMAT) { /** @var \Drupal\filter\FilterFormatInterface $format */ $fiter_format = FilterFormat::load($format); if (empty($fiter_format) || empty($fiter_format->getFilterTypes())) { Loading Loading
config/install/webform.settings.yml +2 −2 Original line number Diff line number Diff line Loading @@ -197,8 +197,8 @@ element: password_confirm: password_confirm html_editor: disabled: false element_format: webform mail_format: webform element_format: webform_default mail_format: webform_default tidy: true make_unused_managed_files_temporary: true file: Loading
config/optional/editor.editor.webform.yml→config/optional/editor.editor.webform_default.yml +3 −2 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ langcode: en status: true dependencies: config: - filter.format.webform - filter.format.webform_default module: - ckeditor format: webform format: webform_default editor: ckeditor settings: toolbar: Loading @@ -23,6 +23,7 @@ settings: name: Media items: - SpecialChar - ImceImage - name: Linking items: Loading
config/optional/filter.format.webform.yml→config/optional/filter.format.webform_default.yml +2 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,8 @@ status: true dependencies: module: - editor name: Webform format: webform name: 'Webform (Default)' format: webform_default weight: 100 roles: - authenticated Loading
includes/webform.editor.inc +23 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,29 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Serialization\Yaml; use Drupal\webform\WebformInterface; use Drupal\Component\Utility\Html; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\webform\Element\WebformHtmlEditor; /** * Implements hook_ENTITY_TYPE_load(). */ function webform_filter_format_load($entities) { foreach ($entities as $entity) { if ($entity->id() === WebformHtmlEditor::DEFAULT_FILTER_FORMAT) { $route_name = \Drupal::routeMatch()->getRouteName(); $filter_format = \Drupal::routeMatch()->getParameter('filter_format'); if ($route_name === 'filter.admin_overview') { // Set status to FALSE which hides the default webform filter format. $entity->set('status', FALSE); } elseif ($filter_format === WebformHtmlEditor::DEFAULT_FILTER_FORMAT) { // Throw not found exception to prevent the default webform // filter format from being edited. throw new NotFoundHttpException(); } } } } /* ************************************************************************** */ // Webform entity hooks. Loading
src/Element/WebformHtmlEditor.php +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ use Drupal\webform\Utility\WebformXss; */ class WebformHtmlEditor extends FormElement implements TrustedCallbackInterface { /** * Default webform filter format. */ const DEFAULT_FILTER_FORMAT = 'webform_default'; /** * {@inheritdoc} */ Loading Loading @@ -238,7 +243,7 @@ class WebformHtmlEditor extends FormElement implements TrustedCallbackInterface // has been customized with filter types, if has not been customized then // use the 'webform_html_editor_markup' template with the webform module's // allowed tags. if ($format === 'webform') { if ($format === static::DEFAULT_FILTER_FORMAT) { /** @var \Drupal\filter\FilterFormatInterface $format */ $fiter_format = FilterFormat::load($format); if (empty($fiter_format) || empty($fiter_format->getFilterTypes())) { Loading