Skip to content

Commit

Permalink
Dynamic ckeditor migration
Browse files Browse the repository at this point in the history
* Dynamic ckeditor migration

* Fix cs

---------

Co-authored-by: Christian Fritsch <[email protected]>
  • Loading branch information
chrfritsch and Christian Fritsch authored Dec 19, 2023
1 parent c30600b commit bc4cbe0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 270 deletions.
270 changes: 0 additions & 270 deletions config/update/thunder_post_update_0001_upgrade_to_thunder7.yml
Original file line number Diff line number Diff line change
@@ -1,276 +1,6 @@
__global_actions:
install_themes:
- gin
editor.editor.basic_html:
expected_config:
editor: ckeditor
image_upload:
max_dimensions:
height: null
width: null
settings:
plugins:
drupallink:
linkit_enabled: true
linkit_profile: default
toolbar:
rows:
-
-
items:
- Bold
- Italic
name: Formatting
-
items:
- DrupalLink
- DrupalUnlink
name: Linking
-
items:
- BulletedList
- NumberedList
name: Lists
-
items:
- Blockquote
name: Media
-
items:
- Format
name: 'Block Formatting'
-
items:
- Source
name: Tools
update_actions:
delete:
settings:
plugins:
drupallink:
linkit_enabled: true
linkit_profile: default
toolbar:
rows:
-
-
items:
- Bold
- Italic
name: Formatting
-
items:
- DrupalLink
- DrupalUnlink
name: Linking
-
items:
- BulletedList
- NumberedList
name: Lists
-
items:
- Blockquote
name: Media
-
items:
- Format
name: 'Block Formatting'
-
items:
- Source
name: Tools
change:
editor: ckeditor5
image_upload:
max_dimensions:
height: 0
width: 0
settings:
plugins:
ckeditor5_heading:
enabled_headings:
- heading2
- heading3
- heading4
- heading5
- heading6
ckeditor5_list:
reversed: false
startIndex: true
ckeditor5_sourceEditing:
allowed_tags:
- '<cite>'
- '<dl>'
- '<dt>'
- '<dd>'
- '<a hreflang>'
- '<blockquote cite>'
- '<ul type>'
- '<ol start type>'
- '<h2 id>'
- '<h3 id>'
- '<h4 id>'
- '<h5 id>'
- '<h6 id>'
linkit_extension:
linkit_enabled: true
linkit_profile: default
toolbar:
items:
- bold
- italic
- '|'
- link
- '|'
- bulletedList
- numberedList
- '|'
- blockQuote
- '|'
- heading
- '|'
- sourceEditing
editor.editor.full_html:
expected_config:
editor: ckeditor
image_upload:
max_dimensions:
height: null
width: null
settings:
plugins:
drupallink:
linkit_enabled: true
linkit_profile: default
toolbar:
rows:
-
-
items:
- Bold
- Italic
- Strike
- Superscript
- Subscript
- '-'
- RemoveFormat
name: Formatting
-
items:
- DrupalLink
- DrupalUnlink
name: Linking
-
items:
- BulletedList
- NumberedList
name: Lists
-
items:
- Blockquote
- Table
- HorizontalRule
name: Media
-
items:
- Format
name: 'Block Formatting'
-
items:
- ShowBlocks
- Source
name: Tools
update_actions:
delete:
settings:
plugins:
drupallink:
linkit_enabled: true
linkit_profile: default
toolbar:
rows:
-
-
items:
- Bold
- Italic
- Strike
- Superscript
- Subscript
- '-'
- RemoveFormat
name: Formatting
-
items:
- DrupalLink
- DrupalUnlink
name: Linking
-
items:
- BulletedList
- NumberedList
name: Lists
-
items:
- Blockquote
- Table
- HorizontalRule
name: Media
-
items:
- Format
name: 'Block Formatting'
-
items:
- ShowBlocks
- Source
name: Tools
change:
editor: ckeditor5
image_upload:
max_dimensions:
height: 0
width: 0
settings:
plugins:
ckeditor5_heading:
enabled_headings:
- heading2
- heading3
- heading4
- heading5
- heading6
ckeditor5_list:
reversed: true
startIndex: true
ckeditor5_sourceEditing:
allowed_tags: { }
linkit_extension:
linkit_enabled: true
linkit_profile: default
toolbar:
items:
- bold
- italic
- strikethrough
- superscript
- subscript
- removeFormat
- '|'
- link
- '|'
- bulletedList
- numberedList
- '|'
- blockQuote
- insertTable
- horizontalLine
- '|'
- heading
- codeBlock
- '|'
- sourceEditing
image.style.thumbnail:
expected_config:
effects:
Expand Down
16 changes: 16 additions & 0 deletions thunder.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* Update functions for the thunder installation profile.
*/

use Drupal\ckeditor5\SmartDefaultSettings;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\editor\Entity\Editor;
use Drupal\entity_browser\Entity\EntityBrowser;
use Drupal\user\Entity\Role;

Expand Down Expand Up @@ -69,6 +71,20 @@ function thunder_post_update_0001_upgrade_to_thunder7(array &$sandbox): string {
}
}

/** @var \Drupal\ckeditor5\SmartDefaultSettings $ckEditorMigration */
$ckEditorMigration = new SmartDefaultSettings(
\Drupal::service('plugin.manager.ckeditor5.plugin'),
\Drupal::service('plugin.manager.public_ckeditor4to5upgrade.plugin'),
$updater->logger(),
\Drupal::service('module_handler'),
\Drupal::service('current_user'));

foreach (Editor::loadMultiple() as $editor) {
$format = $editor->getFilterFormat();
[$updated_text_editor] = $ckEditorMigration->computeSmartDefaultSettings($editor, $format);
$updated_text_editor->save();
}

/** @var \Drupal\Core\Extension\ModuleInstallerInterface $moduleInstaller */
$moduleInstaller = \Drupal::service('module_installer');
$moduleInstaller->uninstall([
Expand Down
4 changes: 4 additions & 0 deletions thunder.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ services:
class: Drupal\thunder\Breadcrumb\ThunderNodeEditBreadcrumbBuilder
tags:
- { name: breadcrumb_builder, priority: 100 }

plugin.manager.public_ckeditor4to5upgrade.plugin:
class: Drupal\ckeditor5\Plugin\CKEditor4To5UpgradePluginManager
parent: default_plugin_manager

0 comments on commit bc4cbe0

Please sign in to comment.