You are here

public function TRexEditor::getJSSettings in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php \Drupal\editor_test\Plugin\Editor\TRexEditor::getJSSettings()

Returns JavaScript settings to be attached.

Most text editors use JavaScript to provide a WYSIWYG or toolbar on the client-side interface. This method can be used to convert internal settings of the text editor into JavaScript variables that will be accessible when the text editor is loaded.

Parameters

\Drupal\editor\Entity\Editor $editor: A configured text editor object.

Return value

array An array of settings that will be added to the page for use by this text editor's JavaScript integration.

Overrides EditorPluginInterface::getJSSettings

See also

\Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()

EditorManager::getAttachments()

File

core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php, line 47

Class

TRexEditor
Defines a Tyrannosaurus-Rex powered text editor for testing purposes.

Namespace

Drupal\editor_test\Plugin\Editor

Code

public function getJSSettings(Editor $editor) {
  $js_settings = [];
  $settings = $editor
    ->getSettings();
  if ($settings['stumpy_arms']) {
    $js_settings['doMyArmsLookStumpy'] = TRUE;
  }
  return $js_settings;
}