diff --git a/composer.json b/composer.json index 2e413226441d0ec183aaa72d3f6f7d0eb6e89d24..a692bf346aac1c7321029ca3b78a2cb01f35687c 100755 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "drupal/ckeditor_media_embed": "~2", "drupal/anchor_link": "~3", "drupal/token": "~1", - "drupal/token_filter": "~2" + "drupal/token_filter": "~2", + "drupal/ckeditor5_paste_filter": "~1" } } diff --git a/config/optional/editor.editor.basic_html.yml b/config/optional/editor.editor.basic_html.yml index 7406710bfad30a0b2cb4167fd73376cb8e7c117e..cd3fe3de84749dda317c1bae187aadfed243d4ca 100644 --- a/config/optional/editor.editor.basic_html.yml +++ b/config/optional/editor.editor.basic_html.yml @@ -74,6 +74,79 @@ settings: linkit_profile: linkit_all_nodes media_media: allow_view_mode_override: true + ckeditor5_paste_filter_pasteFilter: + enabled: true + filters: + - + enabled: true + weight: -10 + search: '<o:p><\/o:p>' + replace: '' + - + enabled: true + weight: -9 + search: '(<[^>]*) (style="[^"]*")' + replace: $1 + - + enabled: true + weight: -8 + search: '(<[^>]*) (face="[^"]*")' + replace: $1 + - + enabled: true + weight: -7 + search: '(<[^>]*) (class="[^"]*")' + replace: $1 + - + enabled: true + weight: -6 + search: '(<[^>]*) (valign="[^"]*")' + replace: $1 + - + enabled: true + weight: -5 + search: '<font[^>]*>' + replace: '' + - + enabled: true + weight: -4 + search: '<\/font>' + replace: '' + - + enabled: true + weight: -3 + search: '<span[^>]*>' + replace: '' + - + enabled: true + weight: -2 + search: '<\/span>' + replace: '' + - + enabled: true + weight: -1 + search: '<p> <\/p>' + replace: '' + - + enabled: true + weight: 0 + search: '<p><\/p>' + replace: '' + - + enabled: true + weight: 1 + search: '<b><\/b>' + replace: '' + - + enabled: true + weight: 2 + search: '<i><\/i>' + replace: '' + - + enabled: true + weight: 3 + search: '<a name="OLE_LINK[^"]*">(.*?)<\/a>' + replace: $1 image_upload: status: true scheme: public diff --git a/config/optional/editor.editor.full_html.yml b/config/optional/editor.editor.full_html.yml index 6439e6620fdcaa9fc3af4ae036644f728e3ad18b..b01f5808343dcafe25069dca984db63370ae699b 100644 --- a/config/optional/editor.editor.full_html.yml +++ b/config/optional/editor.editor.full_html.yml @@ -206,6 +206,79 @@ settings: linkit_profile: linkit_all_nodes media_media: allow_view_mode_override: false + ckeditor5_paste_filter_pasteFilter: + enabled: true + filters: + - + enabled: true + weight: -10 + search: '<o:p><\/o:p>' + replace: '' + - + enabled: true + weight: -9 + search: '(<[^>]*) (style="[^"]*")' + replace: $1 + - + enabled: true + weight: -8 + search: '(<[^>]*) (face="[^"]*")' + replace: $1 + - + enabled: true + weight: -7 + search: '(<[^>]*) (class="[^"]*")' + replace: $1 + - + enabled: true + weight: -6 + search: '(<[^>]*) (valign="[^"]*")' + replace: $1 + - + enabled: true + weight: -5 + search: '<font[^>]*>' + replace: '' + - + enabled: true + weight: -4 + search: '<\/font>' + replace: '' + - + enabled: true + weight: -3 + search: '<span[^>]*>' + replace: '' + - + enabled: true + weight: -2 + search: '<\/span>' + replace: '' + - + enabled: true + weight: -1 + search: '<p> <\/p>' + replace: '' + - + enabled: true + weight: 0 + search: '<p><\/p>' + replace: '' + - + enabled: true + weight: 1 + search: '<b><\/b>' + replace: '' + - + enabled: true + weight: 2 + search: '<i><\/i>' + replace: '' + - + enabled: true + weight: 3 + search: '<a name="OLE_LINK[^"]*">(.*?)<\/a>' + replace: $1 image_upload: status: true scheme: public diff --git a/includes/updates/v9.inc b/includes/updates/v9.inc index da5007a5a0b45be068f6555332f9fec4077bbb93..cafe1a4d09d8914ed5230ef637cd5913787afbbd 100644 --- a/includes/updates/v9.inc +++ b/includes/updates/v9.inc @@ -58,3 +58,41 @@ function varbase_editor_update_90003() { // after all used modules. ModuleInstallerFactory::setModuleWeightAfterInstallation('varbase_editor'); } + +/** + * Issue #3442854: Add CKEditor 5 Paste Filter module to Varbase Editor. + */ +function varbase_editor_update_90004() { + if (!\Drupal::moduleHandler()->moduleExists('ckeditor5_paste_filter')) { + + // Install CKEditor 5 Paste Filter module. + \Drupal::service('module_installer')->install(['ckeditor5_paste_filter'], FALSE); + + // Update Simple and Rich Editors text formats with default filter configs. + $editors = [ + 'editor.editor.full_html', + 'editor.editor.basic_html', + ]; + + $manager = \Drupal::service('plugin.manager.ckeditor5.plugin'); + $paste_filter = $manager->getPlugin('ckeditor5_paste_filter_pasteFilter', NULL); + $paste_filter_config = $paste_filter->defaultConfiguration(); + $paste_filter_config['enabled'] = TRUE; + + foreach ($editors as $editor) { + $editor_config = \Drupal::service('config.factory')->getEditable($editor); + if ($editor_config) { + $editor_data = $editor_config->get(); + if (isset($editor_data['settings']['plugins'])) { + $editor_data['settings']['plugins']['ckeditor5_paste_filter_pasteFilter'] = $paste_filter_config; + } + else { + $editor_data['settings']['plugins'] = [ + 'ckeditor5_paste_filter_pasteFilter' => $paste_filter_config, + ]; + } + $editor_config->setData($editor_data)->save(TRUE); + } + } + } +} diff --git a/varbase_editor.info.yml b/varbase_editor.info.yml index b67bb822b9ff2e1af7bebd57e7b4c550e0b55b75..c8422b507c23e52ab9415fbd9048188f75dadb08 100755 --- a/varbase_editor.info.yml +++ b/varbase_editor.info.yml @@ -20,3 +20,4 @@ install: - pathologic - token - token_filter + - ckeditor5_paste_filter