saveNewTextFormat example

$assert_session = $this->assertSession();

    $this->createNewTextFormat($page$assert_session);
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-drupalInsertImage'));
    $this->triggerKeyUp('.ckeditor5-toolbar-item-drupalInsertImage', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    $page->clickLink('Image');
    $page->checkField('editor[settings][plugins][ckeditor5_image][status]');
    $assert_session->assertWaitOnAjaxRequest();
    $page->checkField('filters[editor_file_reference][status]');
    $assert_session->assertWaitOnAjaxRequest();
    $this->saveNewTextFormat($page$assert_session);

    $this->drupalGet('node/add');
    $page->fillField('title[0][value]', 'My test content');

    // Ensure that CKEditor 5 is focused.     $this->click('.ck-content');

    $this->assertNotEmpty($image_upload_field = $page->find('css', '.ck-file-dialog-button input[type="file"]'));
    $image = $this->getTestFiles('image')[0];
    $image_upload_field->attachFile($this->container->get('file_system')->realpath($image->uri));
    // Wait until preview for the image has rendered to ensure that the image
$page->selectFieldOption('editor[editor]', 'ckeditor5');
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->pageTextContains($filter_warning);

    // Disable the incompatible filter.     $page->uncheckField($incompatible_filter_name);

    // Confirm there are no longer any warnings.     $assert_session->waitForElementRemoved('css', '[data-drupal-messages] [role="alert"]');

    // Confirm the text format can be saved.     $this->saveNewTextFormat($page$assert_session);
  }

  /** * Tests that when image uploads were enabled, they remain enabled. */
  public function testImageUploadsRemainEnabled(): void {
    FilterFormat::create([
      'format' => 'editor_with_image_uploads',
      'name' => 'Text Editor with image uploads enabled',
    ])->save();
    Editor::create([
      
$javascript = <<<JS const allowedTags = document.querySelector('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-sourceediting-allowed-tags"]'); allowedTags.value = '<span>'; allowedTags.dispatchEvent(new Event('input')); JS;
      $this->getSession()->executeScript($javascript);
    }
    $this->assertNotEmpty($assert_session->waitForElement('css', ".ckeditor5-toolbar-item-$toolbar_item_name"));
    $this->triggerKeyUp(".ckeditor5-toolbar-item-$toolbar_item_name", 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    $this->saveNewTextFormat($page$assert_session);

    ConfigurableLanguage::createFromLangcode($langcode)->save();
    $this->config('system.site')->set('default_langcode', $langcode)->save();

    $this->drupalGet('node/add');
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
    // Ensure that blockquote button is translated.     $assert_session->elementExists('xpath', "//span[text()='$toolbar_item_translation']");
  }

  /** * Data provider for ensuring CKEditor 5 UI translations are loaded. * * @return string[][] */
'administer filters',
      'create page content',
      'edit own page content',
    ]));
  }

  /** * Add and save a new text format using CKEditor 5. */
  public function addNewTextFormat($page$assert_session$name = 'ckeditor5') {
    $this->createNewTextFormat($page$assert_session$name);
    $this->saveNewTextFormat($page$assert_session);
  }

  /** * Create a new text format using CKEditor 5. */
  public function createNewTextFormat($page$assert_session$name = 'ckeditor5') {
    $this->drupalGet('admin/config/content/formats/add');
    $page->fillField('name', $name);
    $assert_session->waitForText('Machine name');
    $this->assertNotEmpty($assert_session->waitForText($name));
    $page->checkField('roles[authenticated]');

    

  public function test(): void {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->createNewTextFormat($page$assert_session);
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-drupalMedia'));
    $this->click('#edit-filters-media-embed-status');
    $assert_session->assertWaitOnAjaxRequest();
    $this->triggerKeyUp('.ckeditor5-toolbar-item-drupalMedia', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    $this->saveNewTextFormat($page$assert_session);

    $langcode = 'fr';
    ConfigurableLanguage::createFromLangcode($langcode)->save();
    $this->config('system.site')->set('default_langcode', $langcode)->save();

    // Visit a page that will trigger a JavaScript file parsing for     // translatable strings.     $this->drupalGet('node/add');
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));

    // Ensure a string from the CKEditor 5 plugin is picked up by translation.
Home | Imprint | This part of the site doesn't use cookies.