Chris@0: getTranslation($langcode)->$field_name; Chris@0: $editable_text = check_markup($field->value, $field->format, $langcode, [FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE]); Chris@0: $response->addCommand(new GetUntransformedTextCommand($editable_text)); Chris@0: Chris@0: return $response; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Apply the necessary XSS filtering for using a certain text format's editor. Chris@0: * Chris@0: * @param \Symfony\Component\HttpFoundation\Request $request Chris@0: * The current request object. Chris@0: * @param \Drupal\filter\FilterFormatInterface $filter_format Chris@0: * The text format whose text editor (if any) will be used. Chris@0: * Chris@0: * @return \Symfony\Component\HttpFoundation\JsonResponse Chris@0: * A JSON response containing the XSS-filtered value. Chris@0: * Chris@0: * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException Chris@0: * Thrown if no value to filter is specified. Chris@0: * Chris@0: * @see editor_filter_xss() Chris@0: */ Chris@0: public function filterXss(Request $request, FilterFormatInterface $filter_format) { Chris@0: $value = $request->request->get('value'); Chris@0: if (!isset($value)) { Chris@0: throw new NotFoundHttpException(); Chris@0: } Chris@0: Chris@0: // The original_format parameter will only exist when switching text format. Chris@0: $original_format_id = $request->request->get('original_format_id'); Chris@0: $original_format = NULL; Chris@0: if (isset($original_format_id)) { Chris@18: $original_format = $this->entityTypeManager() Chris@0: ->getStorage('filter_format') Chris@0: ->load($original_format_id); Chris@0: } Chris@0: Chris@0: return new JsonResponse(editor_filter_xss($value, $filter_format, $original_format)); Chris@0: } Chris@0: Chris@0: }