Unverified Commit c051ff75 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2763075 by raman.b, Martijn de Wit, anon, borisson_: Adding new text...

Issue #2763075 by raman.b, Martijn de Wit, anon, borisson_: Adding new text format gives Uncaught TypeError: f.format_tags.split is not a function

(cherry picked from commit 190aae10)
parent 5bc445ba
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -116,8 +116,8 @@ public function getConfig(Editor $editor) {

    // Add the format_tags setting, if its button is enabled.
    $toolbar_buttons = CKEditorPluginManager::getEnabledButtons($editor);
    if (in_array('Format', $toolbar_buttons)) {
      $config['format_tags'] = $this->generateFormatTagsSetting($editor);
    if (in_array('Format', $toolbar_buttons) && $format_string = $this->generateFormatTagsSetting($editor)) {
      $config['format_tags'] = $format_string;
    }

    return $config;
@@ -344,14 +344,15 @@ public function getButtons() {
   * @param \Drupal\editor\Entity\Editor $editor
   *   A configured text editor object.
   *
   * @return array
   *   An array containing the "format_tags" configuration.
   * @return string|false
   *   A string containing the "format_tags" configuration or FALSE if the
   *   editor has not an associated filter format.
   */
  protected function generateFormatTagsSetting(Editor $editor) {
    // When no text format is associated yet, assume no tag is allowed.
    // @see \Drupal\editor\EditorInterface::hasAssociatedFilterFormat()
    if (!$editor->hasAssociatedFilterFormat()) {
      return [];
      return FALSE;
    }

    $format = $editor->getFilterFormat();
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public function testEditorSelection() {
    $this->assertNotEmpty($assert_session->waitForText('sulaco'));
    $page->selectFieldOption('editor[editor]', 'ckeditor');
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '#ckeditor-plugin-settings'));
    $page->pressButton('Save configuration');

    // Test that toggling the editor selection off and back on works.