You are here

public function TinyMCE::getJSSettings in TinyMCE 1.x

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

src/Plugin/Editor/TinyMCE.php, line 69

Class

TinyMCE
Defines a TinyMCE-based text editor for Drupal.

Namespace

Drupal\tinymce\Plugin\Editor

Code

public function getJSSettings(Editor $editor) {
  $default_Settings = $this
    ->getDefaults();
  $customSettings = ($settings = $editor
    ->getSettings()) && !empty($settings['tinymce_editor_settings']) ? $settings['tinymce_editor_settings'] : Json::encode($default_Settings);
  return [
    'json' => Json::decode($customSettings),
  ];
}