/** @var \Drupal\editor\Entity\Editor $editor */
$editor =
$text_editor !== NULL
?
clone $text_editor : Editor::
create([ 'format' =>
$text_format->
id(),
// @see \Drupal\editor\Entity\Editor::__construct()
// @see \Drupal\ckeditor5\Plugin\Editor\CKEditor5::getDefaultSettings()
'editor' => 'ckeditor5',
]);
$editor->
setEditor('ckeditor5'
);
$source_editing_additions = HTMLRestrictions::
emptySet();
// Compute the appropriate settings based on the CKEditor 4 configuration
// if it exists.
$old_editor =
$editor->
id() ? Editor::
load($editor->
id()) : NULL;
$old_editor_restrictions =
$old_editor ? HTMLRestrictions::
fromTextFormat($old_editor->
getFilterFormat()) : HTMLRestrictions::
emptySet();
// @todo Remove in https://www.drupal.org/project/drupal/issues/3245351
if ($old_editor) { $editor->
setImageUploadSettings($old_editor->
getImageUploadSettings());
} if ($old_editor &&
$old_editor->
getEditor() === 'ckeditor'
) { [$upgraded_settings,
$messages] =
$this->
createSettingsFromCKEditor4($old_editor->
getSettings(), HTMLRestrictions::
fromTextFormat($old_editor->
getFilterFormat()));
$editor->
setSettings($upgraded_settings);