File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
admin/src/components/CKEditorProvider Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,18 @@ const CKEditorProvider = ( {
1515 useEffect ( ( ) => {
1616 return ( ) => {
1717 const assets = document . querySelectorAll ( '[data-injected-by="ckeditor-integration"]' ) ;
18-
19- assets . forEach ( asset => asset . remove ( ) ) ;
18+ const editables = document . querySelectorAll ( '.ck-editor__editable_inline ' ) ;
19+
20+ // Editors might be nested in repeated components, which are collapsable.
21+ // In this case, expanding another component will collapse the previous one,
22+ // and for a short period of time there will be two active instances. After the first instance is
23+ // collapsed, CDN assets will be removed, which will break the second instance.
24+ // To prevent that, let's check whether there is an active editor on the page, before removing assets.
25+ //
26+ // See: https://github.com/ckeditor/strapi-plugin-ckeditor/issues/143
27+ if ( ! editables . length ) {
28+ assets . forEach ( asset => asset . remove ( ) ) ;
29+ }
2030
2131 window . CKEDITOR_VERSION = null ;
2232 }
You can’t perform that action at this time.
0 commit comments