Skip to content

Commit

Permalink
Merge pull request #690 from City-of-Helsinki/UHF-9497
Browse files Browse the repository at this point in the history
UHF-9497 Word vs. CKEditor5
  • Loading branch information
teroelonen authored Feb 22, 2024
2 parents 89b8a11 + 1f3a9ca commit ab06735
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 31 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"drupal/admin_toolbar": "^3.0",
"drupal/allowed_formats": "^2.0",
"drupal/ckeditor": "^1.0",
"drupal/ckeditor5_paste_filter": "^1.0",
"drupal/config_filter": "^2.6",
"drupal/config_ignore": "^3.0",
"drupal/config_rewrite": "^1.4",
Expand Down
105 changes: 86 additions & 19 deletions modules/helfi_ckeditor/config/install/editor.editor.full_html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- filter.format.full_html
module:
- ckeditor5
- ckeditor5_paste_filter
format: full_html
editor: ckeditor5
settings:
Expand Down Expand Up @@ -44,28 +45,94 @@ settings:
reversed: false
startIndex: true
multiBlock: true
ckeditor5_paste_filter_pasteFilter:
enabled: true
filters:
-
enabled: true
weight: 0
search: '<o:p><\/o:p>'
replace: ''
-
enabled: true
weight: 1
search: '(<[^>]*) (style="[^"]*")'
replace: $1
-
enabled: true
weight: 2
search: '(<[^>]*) (face="[^"]*")'
replace: $1
-
enabled: true
weight: 3
search: '(<[^>]*) (class="[^"]*")'
replace: $1
-
enabled: true
weight: 4
search: '(<[^>]*) (valign="[^"]*")'
replace: $1
-
enabled: true
weight: 5
search: '<font[^>]*>'
replace: ''
-
enabled: true
weight: 6
search: '<\/font>'
replace: ''
-
enabled: true
weight: 7
search: '<span(?![^>]*\b(?:dir|lang)="[^"]*")[^>]*>(.*?)<\/span>'
replace: $1
-
enabled: true
weight: 8
search: '<p><span lang="[^"]*"><\/span><\/p>'
replace: ''
-
enabled: true
weight: 9
search: '<span lang="[^"]*"><\/span>'
replace: ''
-
enabled: true
weight: 10
search: '<p>&nbsp;<\/p>'
replace: ''
-
enabled: true
weight: 11
search: '<p><\/p>'
replace: ''
-
enabled: true
weight: 12
search: '<b><\/b>'
replace: ''
-
enabled: true
weight: 13
search: '<i><\/i>'
replace: ''
-
enabled: true
weight: 14
search: '<a name="OLE_LINK[^"]*">(.*?)<\/a>'
replace: $1
-
enabled: true
weight: 15
search: '<a name="[^"]*">(.*?)<\/a>'
replace: $1
ckeditor5_sourceEditing:
allowed_tags:
- '<dl>'
- '<dt>'
- '<dd>'
- '<blockquote role aria-* cite class>'
- '<div role aria-* class>'
- '<img src alt height width data-entity-type data-entity-uuid data-align data-caption data-responsive-image-style>'
- '<span role aria-* class>'
- '<ul type>'
- '<ol type>'
- '<h2 id>'
- '<h3 id>'
- '<h4 id>'
- '<h5 id>'
- '<h6 id>'
- '<figure tabindex>'
- '<figcaption>'
allowed_tags: { }
helfi_ckeditor_helfi_link:
helfi_link_attributes:
- '<a aria-label class data-design data-hds-icon-start data-is-external data-link-text data-protocol data-selected-icon data-hds-component data-hds-variant id rel role target="_blank" title>'
- '<span aria-hidden class role>'
- '<a data-hds-icon-start data-is-external data-protocol data-hds-component data-hds-variant rel target="_blank">'
linkit_extension:
linkit_enabled: true
linkit_profile: helfi
Expand Down
93 changes: 86 additions & 7 deletions modules/helfi_ckeditor/config/install/editor.editor.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- filter.format.minimal
module:
- ckeditor5
- ckeditor5_paste_filter
format: minimal
editor: ckeditor5
settings:
Expand All @@ -26,16 +27,94 @@ settings:
reversed: false
startIndex: true
multiBlock: true
ckeditor5_paste_filter_pasteFilter:
enabled: true
filters:
-
enabled: true
weight: 0
search: '<o:p><\/o:p>'
replace: ''
-
enabled: true
weight: 1
search: '(<[^>]*) (style="[^"]*")'
replace: $1
-
enabled: true
weight: 2
search: '(<[^>]*) (face="[^"]*")'
replace: $1
-
enabled: true
weight: 3
search: '(<[^>]*) (class="[^"]*")'
replace: $1
-
enabled: true
weight: 4
search: '(<[^>]*) (valign="[^"]*")'
replace: $1
-
enabled: true
weight: 5
search: '<font[^>]*>'
replace: ''
-
enabled: true
weight: 6
search: '<\/font>'
replace: ''
-
enabled: true
weight: 7
search: '<span(?![^>]*\b(?:dir|lang)="[^"]*")[^>]*>(.*?)<\/span>'
replace: $1
-
enabled: true
weight: 8
search: '<p><span lang="[^"]*"><\/span><\/p>'
replace: ''
-
enabled: true
weight: 9
search: '<span lang="[^"]*"><\/span>'
replace: ''
-
enabled: true
weight: 10
search: '<p>&nbsp;<\/p>'
replace: ''
-
enabled: true
weight: 11
search: '<p><\/p>'
replace: ''
-
enabled: true
weight: 12
search: '<b><\/b>'
replace: ''
-
enabled: true
weight: 13
search: '<i><\/i>'
replace: ''
-
enabled: true
weight: 14
search: '<a name="OLE_LINK[^"]*">(.*?)<\/a>'
replace: $1
-
enabled: true
weight: 15
search: '<a name="[^"]*">(.*?)<\/a>'
replace: $1
ckeditor5_sourceEditing:
allowed_tags:
- '<span role aria-* class>'
- '<ul type>'
- '<ol type>'
- '<a hreflang accesskey id rel target title data-design data-link-text data-selected-icon data-is-external data-protocol>'
allowed_tags: { }
helfi_ckeditor_helfi_link:
helfi_link_attributes:
- '<a aria-label class data-design data-hds-icon-start data-is-external data-link-text data-protocol data-selected-icon data-hds-component data-hds-variant id rel role target="_blank" title>'
- '<span aria-hidden class role>'
- '<a data-hds-icon-start data-is-external data-protocol data-hds-component data-hds-variant rel target="_blank">'
linkit_extension:
linkit_enabled: true
linkit_profile: helfi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ filters:
status: true
weight: -50
settings:
allowed_html: '<br> <p data-helfi-quote-text> <h2> <h3> <h4> <h5> <h6> <blockquote role aria-* cite class data-helfi-quote> <div role aria-* class> <span role aria-* class dir> <ul type> <ol type start> <figure tabindex> <figcaption> <strong> <em> <s> <sub> <sup> <a href data-entity-type data-entity-uuid data-entity-substitution aria-label class data-design data-hds-icon-start data-is-external data-link-text data-protocol data-selected-icon data-hds-component data-hds-variant rel role target="_blank"> <li> <table> <tr> <td> <th> <thead> <tbody> <tfoot> <caption> <footer data-helfi-quote-author> <cite>'
allowed_html: '<br> <p data-helfi-quote-text> <h2> <h3> <h4> <h5> <h6> <blockquote data-helfi-quote> <span dir> <ul> <ol start> <li> <strong> <em> <s> <sub> <sup> <a href data-entity-type data-entity-uuid data-entity-substitution data-hds-icon-start data-is-external data-protocol data-hds-component data-hds-variant rel target="_blank"> <table> <tr> <td> <th> <thead> <tbody> <footer data-helfi-quote-author> <cite>'
filter_html_help: true
filter_html_nofollow: false
filter_html_escape:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ filters:
status: true
weight: -50
settings:
allowed_html: '<br> <p> <span role aria-* class lang dir> <ul type> <ol type start> <a hreflang accesskey id rel target title data-design data-link-text data-selected-icon data-is-external data-protocol href data-entity-type data-entity-uuid data-entity-substitution aria-label class data-hds-icon-start data-hds-component data-hds-variant role> <strong> <em> <li>'
allowed_html: '<br> <p> <span dir> <ul> <ol start> <li> <a href data-entity-type data-entity-uuid data-entity-substitution data-hds-icon-start data-is-external data-protocol data-hds-component data-hds-variant rel target="_blank"> <strong> <em>'
filter_html_help: true
filter_html_nofollow: false
filter_html_escape:
Expand Down
6 changes: 3 additions & 3 deletions modules/helfi_ckeditor/helfi_ckeditor.ckeditor5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ helfi_ckeditor_helfi_link:
label: Helfi Link
library: helfi_ckeditor/helfi_link
elements:
- <a aria-label class data-design data-hds-icon-start data-is-external data-link-text data-protocol data-selected-icon data-hds-component data-hds-variant id rel role target="_blank" title>
- <span aria-hidden class role>
- <a data-design data-hds-icon-start data-is-external data-protocol data-hds-component data-hds-variant rel target="_blank">
conditions:
plugins:
- ckeditor5_link
Expand All @@ -34,7 +33,8 @@ helfi_ckeditor_helfi_language_selector:
helfiLanguageSelector:
label: Select language
elements:
- <span dir lang>
- <span>
- <span lang dir>
class: Drupal\helfi_ckeditor\Plugin\CKEditor5Plugin\HelfiLanguageSelector

helfi_ckeditor_helfi_quote:
Expand Down
1 change: 1 addition & 0 deletions modules/helfi_ckeditor/helfi_ckeditor.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ type: module
core_version_requirement: '^9 || ^10'
dependencies:
- drupal:ckeditor5
- drupal:ckeditor5_paste_filter
- drupal:filter
- helfi_api_base:helfi_api_base
- helfi_platform_config:helfi_platform_config
Expand Down
Loading

0 comments on commit ab06735

Please sign in to comment.